summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhuyaliang <[email protected]>2023-03-24 10:44:43 +0800
committerLuke from DC <[email protected]>2023-04-05 03:17:49 +0000
commite424eb21db35129aee934aa528bddff0869b7a38 (patch)
treec345963472eea6060e50705556f04a25778b6974
parent4ee39ab04260179144ebb9ac7160df79a5b1e6fc (diff)
downloadengrampa-e424eb21db35129aee934aa528bddff0869b7a38.tar.bz2
engrampa-e424eb21db35129aee934aa528bddff0869b7a38.tar.xz
Extract: add the function of automatically closing the dialog box after decompression
-rw-r--r--data/org.mate.engrampa.gschema.xml.in4
-rw-r--r--src/dlg-extract.c20
-rw-r--r--src/fr-window.c15
-rw-r--r--src/fr-window.h2
-rw-r--r--src/preferences.h1
-rw-r--r--src/ui/dlg-extract.ui16
6 files changed, 58 insertions, 0 deletions
diff --git a/data/org.mate.engrampa.gschema.xml.in b/data/org.mate.engrampa.gschema.xml.in
index c997fd9..fed9a1e 100644
--- a/data/org.mate.engrampa.gschema.xml.in
+++ b/data/org.mate.engrampa.gschema.xml.in
@@ -150,6 +150,10 @@
<default>true</default>
<summary>Recreate the folders stored in the archive</summary>
</key>
+ <key name="close-dialog" type="b">
+ <default>false</default>
+ <summary>Close dialog after decompression</summary>
+ </key>
</schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.mate.engrampa.dialogs.add" path="/org/mate/engrampa/dialogs/add/">
<key name="current-folder" type="s">
diff --git a/src/dlg-extract.c b/src/dlg-extract.c
index b85d23b..c00552d 100644
--- a/src/dlg-extract.c
+++ b/src/dlg-extract.c
@@ -281,11 +281,20 @@ overwrite_toggled_cb (GtkToggleButton *button,
}
static void
+close_dialog_changed_cb (GtkToggleButton *button,
+ FrWindow *window)
+{
+ gboolean active = gtk_toggle_button_get_active (button);
+ fr_window_set_close_dialog (window, active);
+}
+
+static void
dlg_extract__common (FrWindow *window,
GList *selected_files,
char *base_dir_for_selection)
{
DialogData *data;
+ GtkWidget *button;
data = g_new0 (DialogData, 1);
data->builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH G_DIR_SEPARATOR_S "dlg-extract.ui");
@@ -317,6 +326,17 @@ dlg_extract__common (FrWindow *window,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("recreate_dir_checkbutton")), g_settings_get_boolean (data->settings, PREF_EXTRACT_RECREATE_FOLDERS));
+ button = GET_WIDGET ("close_dialog_checkbutton");
+ g_settings_bind (data->settings,
+ PREF_EXTRACT_CLOSE_DIALOG,
+ GTK_TOGGLE_BUTTON (button),
+ "active",
+ G_SETTINGS_BIND_GET);
+ g_signal_connect (button,
+ "toggled",
+ G_CALLBACK (close_dialog_changed_cb),
+ window);
+
/* Set the signals handlers. */
gtk_builder_add_callback_symbols (data->builder,
diff --git a/src/fr-window.c b/src/fr-window.c
index 7a18acf..88d8d9a 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -382,6 +382,8 @@ struct _FrWindowPrivateData {
GtkWindow *load_error_parent_window;
gboolean showing_error_dialog;
GtkWindow *error_dialog_parent;
+
+ gboolean close_dialog;
};
/* -- fr_window_free_private_data -- */
@@ -2685,6 +2687,10 @@ open_progress_dialog_with_open_destination (FrWindow *window)
display_progress_dialog (window);
fr_window_progress_cb (NULL, 1.0, window);
fr_window_message_cb (NULL, _("Extraction completed successfully"), window);
+
+ if (window->priv->close_dialog)
+ close_progress_dialog (window, TRUE);
+
}
static void
@@ -8891,3 +8897,12 @@ fr_window_set_batch__add (FrWindow *window,
NULL,
NULL);
}
+
+void
+fr_window_set_close_dialog (FrWindow *window,
+ gboolean state)
+{
+ g_return_if_fail (window != NULL);
+
+ window->priv->close_dialog = state;
+}
diff --git a/src/fr-window.h b/src/fr-window.h
index 5606dfe..9b006a9 100644
--- a/src/fr-window.h
+++ b/src/fr-window.h
@@ -317,4 +317,6 @@ gboolean fr_window_file_list_drag_data_get (FrWindow *window,
void fr_window_update_dialog_closed (FrWindow *window);
+void fr_window_set_close_dialog (FrWindow *window,
+ gboolean state);
#endif /* FR_WINDOW_H */
diff --git a/src/preferences.h b/src/preferences.h
index fe4df4d..575ffb3 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -61,6 +61,7 @@
#define PREF_EXTRACT_OVERWRITE "overwrite"
#define PREF_EXTRACT_SKIP_NEWER "skip-newer"
+#define PREF_EXTRACT_CLOSE_DIALOG "close-dialog"
#define PREF_EXTRACT_RECREATE_FOLDERS "recreate-folders"
#define PREF_ADD_CURRENT_FOLDER "current-folder"
diff --git a/src/ui/dlg-extract.ui b/src/ui/dlg-extract.ui
index 3a44384..745c548 100644
--- a/src/ui/dlg-extract.ui
+++ b/src/ui/dlg-extract.ui
@@ -288,6 +288,22 @@
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="close_dialog_checkbutton">
+ <property name="label" translatable="yes">close dialog after decompression</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
</child>
</object>