[nautilus] Use header bars for dialogs



commit d8a8ab3b66a0a4849e2f9cd17e96f86f85541dee
Author: William Jon McCann <william jon mccann gmail com>
Date:   Thu Feb 6 14:41:55 2014 -0500

    Use header bars for dialogs
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723793

 .../nautilus-file-conflict-dialog.c                |    2 +
 src/nautilus-connect-server-dialog.c               |   55 +-------------
 src/nautilus-connect-server.c                      |    1 -
 src/nautilus-file-management-properties.c          |   79 +-------------------
 src/nautilus-file-management-properties.ui         |   53 +++----------
 src/nautilus-list-view.c                           |    3 +-
 src/nautilus-properties-window.c                   |   38 ++--------
 src/nautilus-query-editor.c                        |    2 +-
 src/nautilus-view.c                                |   20 +----
 9 files changed, 33 insertions(+), 220 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-conflict-dialog.c 
b/libnautilus-private/nautilus-file-conflict-dialog.c
index a14c5f0..7fcb2d6 100644
--- a/libnautilus-private/nautilus-file-conflict-dialog.c
+++ b/libnautilus-private/nautilus-file-conflict-dialog.c
@@ -624,6 +624,8 @@ nautilus_file_conflict_dialog_new (GtkWindow *parent,
        GtkWidget *dialog;
        
        dialog = GTK_WIDGET (g_object_new (NAUTILUS_TYPE_FILE_CONFLICT_DIALOG,
+                                          "use-header-bar", TRUE,
+                                          "modal", TRUE,
                                           "title", _("File conflict"),
                                           NULL));
        set_source_and_destination (dialog,
diff --git a/src/nautilus-connect-server-dialog.c b/src/nautilus-connect-server-dialog.c
index bd18e4d..aa10cbb 100644
--- a/src/nautilus-connect-server-dialog.c
+++ b/src/nautilus-connect-server-dialog.c
@@ -44,7 +44,6 @@ struct _NautilusConnectServerDialogDetails {
        GtkWidget *menu;
        GtkWidget *remove_menu_item;
        GtkWidget *clear_menu_item;
-       GtkWidget *browse_button;
 
        char **supported;
 };
@@ -59,13 +58,6 @@ enum {
 G_DEFINE_TYPE (NautilusConnectServerDialog, nautilus_connect_server_dialog,
               GTK_TYPE_DIALOG)
 
-void
-nautilus_connect_server_dialog_set_show_browse (NautilusConnectServerDialog *dialog,
-                                               gboolean                     show)
-{
-       gtk_widget_set_visible (dialog->details->browse_button, show);
-}
-
 GFile *
 nautilus_connect_server_dialog_get_location (NautilusConnectServerDialog *dialog)
 {
@@ -80,37 +72,6 @@ nautilus_connect_server_dialog_get_location (NautilusConnectServerDialog *dialog
        return file;
 }
 
-static void
-nautilus_connect_server_dialog_response (GtkDialog *dialog,
-                                        int        response_id,
-                                        gpointer   data)
-{
-       GError *error;
-       NautilusConnectServerDialog *cs_dialog = NAUTILUS_CONNECT_SERVER_DIALOG (dialog);
-
-       switch (response_id) {
-       case GTK_RESPONSE_ACCEPT:
-               g_signal_stop_emission_by_name (dialog, "response");
-               gtk_entry_set_text (GTK_ENTRY (cs_dialog->details->uri_entry), "network:///");
-               gtk_dialog_response (dialog, GTK_RESPONSE_OK);
-               break;
-       case GTK_RESPONSE_HELP:
-               error = NULL;
-               gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (dialog)),
-                             "help:gnome-help/nautilus-connect",
-                             gtk_get_current_event_time (), &error);
-               if (error) {
-                       eel_show_error_dialog (_("There was an error displaying help."), error->message,
-                                              GTK_WINDOW (dialog));
-                       g_error_free (error);
-               }
-               g_signal_stop_emission_by_name (dialog, "response");
-               break;
-       default :
-               break;
-       }
-}
-
 static gboolean
 is_scheme_supported (NautilusConnectServerDialog *dialog,
                     const char                  *scheme)
@@ -565,7 +526,6 @@ static void
 nautilus_connect_server_dialog_init (NautilusConnectServerDialog *dialog)
 {
        GtkWidget *label;
-       GtkWidget *button;
        GtkWidget *sw;
        GtkWidget *view;
        GtkWidget *box;
@@ -689,13 +649,6 @@ nautilus_connect_server_dialog_init (NautilusConnectServerDialog *dialog)
        dialog->details->view = GTK_TREE_VIEW (view);
        dialog->details->store = store;
 
-       button = gtk_dialog_add_button (GTK_DIALOG (dialog),
-                                       _("_Browse"),
-                                       GTK_RESPONSE_ACCEPT);
-       gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))),
-                                           button, TRUE);
-       dialog->details->browse_button = button;
-
        gtk_dialog_add_button (GTK_DIALOG (dialog),
                               _("_Cancel"),
                               GTK_RESPONSE_CANCEL);
@@ -715,10 +668,6 @@ nautilus_connect_server_dialog_init (NautilusConnectServerDialog *dialog)
                          G_CALLBACK (on_uri_entry_clear),
                          dialog);
 
-       g_signal_connect (dialog, "response",
-                         G_CALLBACK (nautilus_connect_server_dialog_response),
-                         NULL);
-
        create_popup_menu (dialog);
        populate_server_list (dialog);
 }
@@ -751,7 +700,9 @@ nautilus_connect_server_dialog_new (NautilusWindow *window)
 {
        GtkWidget *dialog;
 
-       dialog = gtk_widget_new (NAUTILUS_TYPE_CONNECT_SERVER_DIALOG, NULL);
+       dialog = gtk_widget_new (NAUTILUS_TYPE_CONNECT_SERVER_DIALOG,
+                                "use-header-bar", TRUE,
+                                NULL);
 
        if (window) {
                gtk_window_set_screen (GTK_WINDOW (dialog),
diff --git a/src/nautilus-connect-server.c b/src/nautilus-connect-server.c
index acdda73..481664d 100644
--- a/src/nautilus-connect-server.c
+++ b/src/nautilus-connect-server.c
@@ -165,7 +165,6 @@ main (int argc, char *argv[])
        g_option_context_free (context);
 
        dialog = nautilus_connect_server_dialog_new (NULL);
-       nautilus_connect_server_dialog_set_show_browse (NAUTILUS_CONNECT_SERVER_DIALOG (dialog), FALSE);
 
        gtk_window_set_default_icon_name ("folder-remote-symbolic");
 
diff --git a/src/nautilus-file-management-properties.c b/src/nautilus-file-management-properties.c
index fe5c1d8..f1c7f80 100644
--- a/src/nautilus-file-management-properties.c
+++ b/src/nautilus-file-management-properties.c
@@ -170,75 +170,6 @@ nautilus_file_management_properties_size_group_create (GtkBuilder *builder,
 }
 
 static void
-preferences_show_help (GtkWindow *parent,
-                      char const *helpfile,
-                      char const *sect_id)
-{
-       GError *error = NULL;
-       GtkWidget *dialog;
-       char *help_string;
-
-       g_assert (helpfile != NULL);
-       g_assert (sect_id != NULL);
-
-       help_string = g_strdup_printf ("help:%s/%s", helpfile, sect_id);
-
-       gtk_show_uri (gtk_window_get_screen (parent),
-                     help_string, gtk_get_current_event_time (),
-                     &error);
-       g_free (help_string);
-
-       if (error) {
-               dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
-                                                GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                GTK_MESSAGE_ERROR,
-                                                GTK_BUTTONS_OK,
-                                                _("There was an error displaying help: \n%s"),
-                                                error->message);
-
-               g_signal_connect (G_OBJECT (dialog),
-                                 "response", G_CALLBACK (gtk_widget_destroy),
-                                 NULL);
-               gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-               gtk_widget_show (dialog);
-               g_error_free (error);
-       }
-}
-
-
-static void
-nautilus_file_management_properties_dialog_response_cb (GtkDialog *parent,
-                                                       int response_id,
-                                                       GtkBuilder *builder)
-{
-       char *section;
-
-       if (response_id == GTK_RESPONSE_HELP) {
-               switch (gtk_notebook_get_current_page (GTK_NOTEBOOK (gtk_builder_get_object (builder, 
"notebook1")))) {
-               default:
-               case 0:
-                       section = "nautilus-views";
-                       break;
-               case 1:
-                       section = "nautilus-behavior";
-                       break;
-               case 2:
-                       section = "nautilus-display";
-                       break;
-               case 3:
-                       section = "nautilus-list";
-                       break;
-               case 4:
-                       section = "nautilus-preview";
-                       break;
-               }
-               preferences_show_help (GTK_WINDOW (parent), "gnome-help", section);
-       } else if (response_id == GTK_RESPONSE_CLOSE) {
-               gtk_widget_destroy (GTK_WIDGET (parent));
-       }
-}
-
-static void
 columns_changed_callback (NautilusColumnChooser *chooser,
                          gpointer callback_data)
 {
@@ -735,13 +666,9 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
 
        /* UI callbacks */
        dialog = GTK_WIDGET (gtk_builder_get_object (builder, "file_management_dialog"));
-       g_signal_connect_data (dialog, "response",
-                              G_CALLBACK (nautilus_file_management_properties_dialog_response_cb),
-                              g_object_ref (builder),
-                              (GClosureNotify)g_object_unref,
-                              0);
-       g_signal_connect (dialog, "delete-event",
-                         G_CALLBACK (gtk_widget_destroy), NULL);
+       g_signal_connect (dialog, "response",
+                         G_CALLBACK (gtk_widget_destroy),
+                         NULL);
 
        gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-file-manager");
 
diff --git a/src/nautilus-file-management-properties.ui b/src/nautilus-file-management-properties.ui
index 7349ee8..f970a38 100644
--- a/src/nautilus-file-management-properties.ui
+++ b/src/nautilus-file-management-properties.ui
@@ -3,53 +3,29 @@
   <!-- interface-requires gtk+ 3.0 -->
   <object class="GtkDialog" id="file_management_dialog">
     <property name="can_focus">False</property>
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Files Preferences</property>
+    <property name="border_width">0</property>
     <property name="window_position">center</property>
     <property name="type_hint">dialog</property>
+    <child type="titlebar">
+      <object class="GtkHeaderBar" id="headerbar">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="show-close-button">True</property>
+        <property name="title" translatable="yes">Files Preferences</property>
+      </object>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
+        <property name="border_width">0</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
+            <property name="visible">False</property>
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="helpbutton1">
-                <property name="label">gtk-help</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="closebutton1">
-                <property name="label">gtk-close</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -62,7 +38,8 @@
           <object class="GtkNotebook" id="notebook1">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
-            <property name="border_width">5</property>
+            <property name="border_width">0</property>
+            <property name="show_border">False</property>
             <child>
               <object class="GtkBox" id="vbox1">
                 <property name="visible">True</property>
@@ -1296,10 +1273,6 @@
         </child>
       </object>
     </child>
-    <action-widgets>
-      <action-widget response="-11">helpbutton1</action-widget>
-      <action-widget response="-7">closebutton1</action-widget>
-    </action-widgets>
   </object>
   <object class="GtkListStore" id="model1">
     <columns>
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 6faf28f..bb47ca1 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -2943,8 +2943,7 @@ create_column_editor (NautilusListView *view)
 
        window = gtk_dialog_new_with_buttons (str,
                                              GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
-                                             GTK_DIALOG_DESTROY_WITH_PARENT,
-                                             _("_Close"), GTK_RESPONSE_CLOSE,
+                                             GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | 
GTK_DIALOG_USE_HEADER_BAR,
                                              NULL);
        g_free (str);
        g_signal_connect (window, "response", 
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 68e68cd..4cf7244 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -4464,7 +4464,7 @@ on_change_permissions_clicked (GtkWidget                *button,
 
        dialog = gtk_dialog_new_with_buttons (_("Change Permissions for Enclosed Files"),
                                               GTK_WINDOW (window),
-                                              GTK_DIALOG_MODAL,
+                                              GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | 
GTK_DIALOG_USE_HEADER_BAR,
                                              _("_Cancel"), GTK_RESPONSE_CANCEL,
                                              _("Change"), GTK_RESPONSE_OK,
                                              NULL);
@@ -4847,7 +4847,9 @@ create_properties_window (StartupData *startup_data)
        NautilusPropertiesWindow *window;
        GList *l;
 
-       window = NAUTILUS_PROPERTIES_WINDOW (gtk_widget_new (NAUTILUS_TYPE_PROPERTIES_WINDOW, NULL));
+       window = NAUTILUS_PROPERTIES_WINDOW (gtk_widget_new (NAUTILUS_TYPE_PROPERTIES_WINDOW,
+                                                            "use-header-bar", TRUE,
+                                                            NULL));
 
        window->details->original_files = nautilus_file_list_copy (startup_data->original_files);
        
@@ -4923,6 +4925,8 @@ create_properties_window (StartupData *startup_data)
 
        /* Create the notebook tabs. */
        window->details->notebook = GTK_NOTEBOOK (gtk_notebook_new ());
+       gtk_notebook_set_show_border (window->details->notebook, FALSE);
+       gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (window))), 0);
        gtk_widget_show (GTK_WIDGET (window->details->notebook));
        gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))),
                            GTK_WIDGET (window->details->notebook),
@@ -4942,16 +4946,6 @@ create_properties_window (StartupData *startup_data)
        /* append pages from available views */
        append_extension_pages (window);
 
-       gtk_dialog_add_buttons (GTK_DIALOG (window),
-                               _("_Help"), GTK_RESPONSE_HELP,
-                               _("_Close"), GTK_RESPONSE_CLOSE,
-                               NULL);
-
-       /* FIXME - HIGificiation, should be done inside GTK+ */
-       gtk_container_set_border_width (GTK_CONTAINER (window), 5);
-       gtk_container_set_border_width (GTK_CONTAINER (window->details->notebook), 5);
-       gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (window))), 0);
-
        /* Update from initial state */
        properties_window_update (window, NULL);
 
@@ -5177,27 +5171,7 @@ static void
 real_response (GtkDialog *dialog,
               int        response)
 {
-       GError *error = NULL;
-       NautilusPropertiesWindow *window = NAUTILUS_PROPERTIES_WINDOW (dialog);
-       GtkWidget *curpage;
-       const char *helpuri;
-
        switch (response) {
-       case GTK_RESPONSE_HELP:
-               curpage = gtk_notebook_get_nth_page (window->details->notebook,
-                                                    gtk_notebook_get_current_page 
(window->details->notebook));
-               helpuri = g_object_get_data (G_OBJECT (curpage), "help-uri");
-               gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (dialog)),
-                             helpuri ? helpuri : "help:gnome-help/files",
-                             gtk_get_current_event_time (),
-                             &error);
-               if (error != NULL) {
-                       eel_show_error_dialog (_("There was an error displaying help."), error->message,
-                                              GTK_WINDOW (dialog));
-                       g_error_free (error);
-               }
-               break;
-
        case GTK_RESPONSE_NONE:
        case GTK_RESPONSE_CLOSE:
        case GTK_RESPONSE_DELETE_EVENT:
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 20a6e4f..73a3873 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -515,7 +515,7 @@ type_combo_changed (GtkComboBox *combo_box, NautilusQueryEditorRow *row)
                toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
                dialog = gtk_dialog_new_with_buttons (_("Select type"),
                                                      GTK_WINDOW (toplevel),
-                                                     0,
+                                                     GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | 
GTK_DIALOG_USE_HEADER_BAR,
                                                      _("_Cancel"), GTK_RESPONSE_CANCEL,
                                                      _("Select"), GTK_RESPONSE_OK,
                                                      NULL);
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 1965ac0..4a4f580 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -1245,7 +1245,8 @@ choose_program (NautilusView *view,
        location = nautilus_file_get_location (file);
        parent_window = nautilus_view_get_containing_window (view);
 
-       dialog = gtk_app_chooser_dialog_new (parent_window, 0,
+       dialog = gtk_app_chooser_dialog_new (parent_window,
+                                            GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | 
GTK_DIALOG_USE_HEADER_BAR,
                                             location);
        g_object_set_data_full (G_OBJECT (dialog), 
                                "directory-view:file",
@@ -1460,17 +1461,6 @@ pattern_select_response_cb (GtkWidget *dialog, int response, gpointer user_data)
        case GTK_RESPONSE_CANCEL :
                gtk_widget_destroy (GTK_WIDGET (dialog));
                break;
-       case GTK_RESPONSE_HELP :
-               error = NULL;
-               gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (dialog)),
-                             "help:gnome-help/files-select",
-                             gtk_get_current_event_time (), &error);
-               if (error) {
-                       eel_show_error_dialog (_("There was an error displaying help."), error->message,
-                                              GTK_WINDOW (dialog));
-                       g_error_free (error);
-               }
-               break;
        default :
                g_assert_not_reached ();
        }
@@ -1488,12 +1478,10 @@ select_pattern (NautilusView *view)
 
        dialog = gtk_dialog_new_with_buttons (_("Select Items Matching"),
                                              nautilus_view_get_containing_window (view),
-                                             GTK_DIALOG_DESTROY_WITH_PARENT,
-                                             _("_Help"),
-                                             GTK_RESPONSE_HELP,
+                                             GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | 
GTK_DIALOG_USE_HEADER_BAR,
                                              _("_Cancel"),
                                              GTK_RESPONSE_CANCEL,
-                                             _("_OK"),
+                                             _("_Select"),
                                              GTK_RESPONSE_OK,
                                              NULL);
        gtk_dialog_set_default_response (GTK_DIALOG (dialog),


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