[file-roller] use a function to simplify the code



commit 448cc4bdb05b1c90f578a789fd71134f7372794d
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Feb 15 12:58:34 2015 +0100

    use a function to simplify the code

 src/dlg-ask-password.c        |    7 +------
 src/dlg-delete.c              |    6 +-----
 src/dlg-password.c            |    7 +------
 src/dlg-prop.c                |    6 +-----
 src/fr-file-selector-dialog.c |    8 +-------
 src/fr-new-archive-dialog.c   |   10 ++++------
 src/gtk-utils.c               |   20 ++++++++++++++------
 src/gtk-utils.h               |    1 +
 8 files changed, 24 insertions(+), 41 deletions(-)
---
diff --git a/src/dlg-ask-password.c b/src/dlg-ask-password.c
index 58db714..eea5cc4 100644
--- a/src/dlg-ask-password.c
+++ b/src/dlg-ask-password.c
@@ -102,7 +102,6 @@ dlg_ask_password__common (FrWindow       *window,
        const char *old_password;
        char       *filename;
        char       *message;
-       gboolean   use_header;
 
        data = g_new0 (DialogData, 1);
        data->builder = _gtk_builder_new_from_resource ("ask-password.ui");
@@ -115,14 +114,10 @@ dlg_ask_password__common (FrWindow       *window,
 
        /* Make the widgets. */
 
-       g_object_get (gtk_settings_get_default (),
-                     "gtk-dialogs-use-header", &use_header,
-                     NULL);
-
        data->dialog = g_object_new (GTK_TYPE_DIALOG,
                                     "transient-for", GTK_WINDOW (window),
                                     "modal", TRUE,
-                                    "use-header-bar", use_header,
+                                    "use-header-bar", _gtk_settings_get_dialogs_use_header (),
                                     NULL);
        content_area = gtk_dialog_get_content_area (GTK_DIALOG (data->dialog));
        gtk_container_add (GTK_CONTAINER (content_area),
diff --git a/src/dlg-delete.c b/src/dlg-delete.c
index b19d52d..f39c29b 100644
--- a/src/dlg-delete.c
+++ b/src/dlg-delete.c
@@ -112,7 +112,6 @@ dlg_delete__common (FrWindow *window,
        GtkWidget  *content_area;
        GtkWidget  *delete_box;
        GtkWidget  *ok_button;
-       gboolean    use_header;
 
        data = g_new (DialogData, 1);
        data->window = window;
@@ -125,14 +124,11 @@ dlg_delete__common (FrWindow *window,
        }
 
        /* Get the widgets. */
-       g_object_get (gtk_settings_get_default (),
-                     "gtk-dialogs-use-header", &use_header,
-                     NULL);
 
        data->dialog = g_object_new (GTK_TYPE_DIALOG,
                                     "transient-for", GTK_WINDOW (window),
                                     "modal", TRUE,
-                                    "use-header-bar", use_header,
+                                    "use-header-bar", _gtk_settings_get_dialogs_use_header (),
                                     NULL);
 
        gtk_dialog_add_buttons (GTK_DIALOG (data->dialog),
diff --git a/src/dlg-password.c b/src/dlg-password.c
index 360cd31..25273f9 100644
--- a/src/dlg-password.c
+++ b/src/dlg-password.c
@@ -78,7 +78,6 @@ dlg_password (GtkWidget *widget,
        GtkWidget  *content_area;
        char       *basename;
        char       *title;
-       gboolean    use_header;
 
        data = g_new0 (DialogData, 1);
        data->window = window;
@@ -90,14 +89,10 @@ dlg_password (GtkWidget *widget,
 
        /* Set widgets data. */
 
-       g_object_get (gtk_settings_get_default (),
-                     "gtk-dialogs-use-header", &use_header,
-                     NULL);
-
        data->dialog = g_object_new (GTK_TYPE_DIALOG,
                                     "transient-for", GTK_WINDOW (window),
                                     "modal", TRUE,
-                                    "use-header-bar", use_header,
+                                    "use-header-bar", _gtk_settings_get_dialogs_use_header (),
                                     NULL);
        content_area = gtk_dialog_get_content_area (GTK_DIALOG (data->dialog));
        gtk_container_add (GTK_CONTAINER (content_area),
diff --git a/src/dlg-prop.c b/src/dlg-prop.c
index 31ff6a1..54ab1c3 100644
--- a/src/dlg-prop.c
+++ b/src/dlg-prop.c
@@ -60,7 +60,6 @@ dlg_prop (FrWindow *window)
        char       *utf8_name;
        char       *title_txt;
        double      ratio;
-       gboolean    use_header;
 
        data = g_new (DialogData, 1);
 
@@ -75,14 +74,11 @@ dlg_prop (FrWindow *window)
 
 
        /* Make the dialog */
-       g_object_get (gtk_settings_get_default (),
-                     "gtk-dialogs-use-header", &use_header,
-                     NULL);
 
        data->dialog = gtk_widget_new (GTK_TYPE_DIALOG,
                                       "transient-for", GTK_WINDOW (window),
                                       "modal", TRUE,
-                                      "use-header-bar",  use_header,
+                                      "use-header-bar", _gtk_settings_get_dialogs_use_header (),
                                       NULL);
 
        content_area = gtk_dialog_get_content_area (GTK_DIALOG (data->dialog));
diff --git a/src/fr-file-selector-dialog.c b/src/fr-file-selector-dialog.c
index 38f7425..0e87b02 100644
--- a/src/fr-file-selector-dialog.c
+++ b/src/fr-file-selector-dialog.c
@@ -712,16 +712,10 @@ GtkWidget *
 fr_file_selector_dialog_new (const char *title,
                             GtkWindow  *parent)
 {
-       gboolean use_header;
-
-       g_object_get (gtk_settings_get_default (),
-                     "gtk-dialogs-use-header", &use_header,
-                     NULL);
-
        return (GtkWidget *) g_object_new (FR_TYPE_FILE_SELECTOR_DIALOG,
                                           "title", title,
                                           "transient-for", parent,
-                                          "use-header-bar", use_header,
+                                          "use-header-bar", _gtk_settings_get_dialogs_use_header (),
                                           NULL);
 }
 
diff --git a/src/fr-new-archive-dialog.c b/src/fr-new-archive-dialog.c
index afe0e1f..c6767b9 100644
--- a/src/fr-new-archive-dialog.c
+++ b/src/fr-new-archive-dialog.c
@@ -309,13 +309,11 @@ fr_new_archive_dialog_new (const char         *title,
                           GFile              *original_file)
 {
        FrNewArchiveDialog *self;
-       gboolean            use_header;
 
-       g_object_get (gtk_settings_get_default (),
-                     "gtk-dialogs-use-header", &use_header,
-                     NULL);
-
-       self = g_object_new (FR_TYPE_NEW_ARCHIVE_DIALOG, "title", title, "use-header-bar", use_header, NULL);
+       self = g_object_new (FR_TYPE_NEW_ARCHIVE_DIALOG,
+                            "title", title,
+                            "use-header-bar", _gtk_settings_get_dialogs_use_header (),
+                            NULL);
        _fr_new_archive_dialog_construct (self, parent, action, folder, default_name, original_file);
 
        return (GtkWidget *) self;
diff --git a/src/gtk-utils.c b/src/gtk-utils.c
index 5de4e63..cb9d92b 100644
--- a/src/gtk-utils.c
+++ b/src/gtk-utils.c
@@ -130,11 +130,6 @@ _gtk_request_dialog_run (GtkWindow      *parent,
        GtkWidget  *content_area;
        GtkWidget  *request_box;
        char       *result;
-       gboolean    use_header;
-
-       g_object_get (gtk_settings_get_default (),
-                     "gtk-dialogs-use-header", &use_header,
-                     NULL);
 
        builder = _gtk_builder_new_from_resource ("request-dialog.ui");
        request_box = _gtk_builder_get_widget (builder, "request_box");
@@ -142,7 +137,7 @@ _gtk_request_dialog_run (GtkWindow      *parent,
        dialog = g_object_new (GTK_TYPE_DIALOG,
                              "transient-for", parent,
                              "modal", flags & GTK_DIALOG_MODAL,
-                             "use-header-bar", use_header,
+                             "use-header-bar", _gtk_settings_get_dialogs_use_header (),
                              NULL);
        gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
        gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), (flags & GTK_DIALOG_DESTROY_WITH_PARENT));
@@ -869,3 +864,16 @@ _gtk_window_add_accelerators_from_menu (GtkWindow  *window,
        add_accelerators_from_menu (window, accel_group, menu);
        gtk_window_add_accel_group (window, accel_group);
 }
+
+
+gboolean
+_gtk_settings_get_dialogs_use_header (void)
+{
+       gboolean use_header;
+
+       g_object_get (gtk_settings_get_default (),
+                     "gtk-dialogs-use-header", &use_header,
+                     NULL);
+
+       return use_header;
+}
diff --git a/src/gtk-utils.h b/src/gtk-utils.h
index 12f2902..51d8c92 100644
--- a/src/gtk-utils.h
+++ b/src/gtk-utils.h
@@ -114,5 +114,6 @@ void          _gtk_window_add_accelerator_for_action
 void          _gtk_window_add_accelerators_from_menu
                                                   (GtkWindow        *window,
                                                    GMenuModel       *menu);
+gboolean      _gtk_settings_get_dialogs_use_header (void);
 
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]