From e424eb21db35129aee934aa528bddff0869b7a38 Mon Sep 17 00:00:00 2001 From: zhuyaliang <15132211195@163.com> Date: Fri, 24 Mar 2023 10:44:43 +0800 Subject: Extract: add the function of automatically closing the dialog box after decompression --- data/org.mate.engrampa.gschema.xml.in | 4 ++++ src/dlg-extract.c | 20 ++++++++++++++++++++ src/fr-window.c | 15 +++++++++++++++ src/fr-window.h | 2 ++ src/preferences.h | 1 + src/ui/dlg-extract.ui | 16 ++++++++++++++++ 6 files changed, 58 insertions(+) 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 @@ true Recreate the folders stored in the archive + + false + Close dialog after decompression + 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 @@ -280,12 +280,21 @@ overwrite_toggled_cb (GtkToggleButton *button, gtk_widget_set_sensitive (GET_WIDGET ("not_newer_checkbutton"), active); } +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 @@ 2 + + + close dialog after decompression + True + True + False + start + True + True + + + False + True + 2 + + -- cgit v1.2.1