[gedit/wip/merge-encoding-settings] EncodingsDialog: Reset button in the inline toolbar



commit e03a55e1a5ccd9007a7c389dc6c3be6393ccb3ee
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Apr 5 18:03:36 2015 +0200

    EncodingsDialog: Reset button in the inline toolbar
    
    It's not great to have both the Reset and Cancel buttons close together,
    so move again the Reset button into the inline toolbar.

 gedit/gedit-encodings-combo-box.c            |    7 +---
 gedit/gedit-encodings-dialog.c               |   36 ++++++++++++++++++++------
 gedit/gedit-encodings-dialog.h               |    2 -
 gedit/resources/ui/gedit-encodings-dialog.ui |   13 +--------
 4 files changed, 31 insertions(+), 27 deletions(-)
---
diff --git a/gedit/gedit-encodings-combo-box.c b/gedit/gedit-encodings-combo-box.c
index b9b5797..bd3b173 100644
--- a/gedit/gedit-encodings-combo-box.c
+++ b/gedit/gedit-encodings-combo-box.c
@@ -169,11 +169,8 @@ dialog_response_cb (GtkDialog              *dialog,
                     gint                    response_id,
                     GeditEncodingsComboBox *menu)
 {
-       if (response_id != GEDIT_ENCODINGS_DIALOG_RESPONSE_RESET)
-       {
-               update_menu (menu);
-               gtk_widget_destroy (GTK_WIDGET (dialog));
-       }
+       update_menu (menu);
+       gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
 static void
diff --git a/gedit/gedit-encodings-dialog.c b/gedit/gedit-encodings-dialog.c
index 8f3039c..a443968 100644
--- a/gedit/gedit-encodings-dialog.c
+++ b/gedit/gedit-encodings-dialog.c
@@ -42,8 +42,6 @@ struct _GeditEncodingsDialogPrivate
 {
        GSettings *enc_settings;
 
-       GtkWidget *reset_button;
-
        /* Available encodings */
        GtkListStore *liststore_available;
        GtkTreeModelSort *sort_available;
@@ -56,6 +54,7 @@ struct _GeditEncodingsDialogPrivate
        GtkWidget *remove_button;
        GtkWidget *up_button;
        GtkWidget *down_button;
+       GtkWidget *reset_button;
 
        State state;
 };
@@ -158,7 +157,8 @@ init_liststores (GeditEncodingsDialog *dialog,
 }
 
 static void
-reset_encodings (GeditEncodingsDialog *dialog)
+reset_button_clicked_cb (GtkWidget            *button,
+                        GeditEncodingsDialog *dialog)
 {
        GtkDialog *msg_dialog;
        gint response;
@@ -285,10 +285,6 @@ gedit_encodings_dialog_response (GtkDialog *gtk_dialog,
 
        switch (response_id)
        {
-               case GEDIT_ENCODINGS_DIALOG_RESPONSE_RESET:
-                       reset_encodings (dialog);
-                       break;
-
                case GTK_RESPONSE_APPLY:
                        apply_settings (dialog);
                        break;
@@ -310,6 +306,7 @@ gedit_encodings_dialog_dispose (GObject *object)
        g_clear_object (&priv->remove_button);
        g_clear_object (&priv->up_button);
        g_clear_object (&priv->down_button);
+       g_clear_object (&priv->reset_button);
 
        G_OBJECT_CLASS (gedit_encodings_dialog_parent_class)->dispose (object);
 }
@@ -333,7 +330,6 @@ gedit_encodings_dialog_class_init (GeditEncodingsDialogClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, GeditEncodingsDialog, sort_available);
        gtk_widget_class_bind_template_child_private (widget_class, GeditEncodingsDialog, treeview_available);
        gtk_widget_class_bind_template_child_private (widget_class, GeditEncodingsDialog, treeview_chosen);
-       gtk_widget_class_bind_template_child_private (widget_class, GeditEncodingsDialog, reset_button);
        gtk_widget_class_bind_template_child_full (widget_class, "scrolledwindow_available", FALSE, 0);
        gtk_widget_class_bind_template_child_full (widget_class, "scrolledwindow_chosen", FALSE, 0);
        gtk_widget_class_bind_template_child_full (widget_class, "toolbar_available", FALSE, 0);
@@ -744,6 +740,7 @@ init_toolbar_chosen (GeditEncodingsDialog *dialog)
        GtkWidget *scrolled_window;
        GtkToolbar *toolbar;
        GtkStyleContext *context;
+       GtkToolItem *separator;
 
        scrolled_window = GTK_WIDGET (gtk_widget_get_template_child (GTK_WIDGET (dialog),
                                                                     GEDIT_TYPE_ENCODINGS_DIALOG,
@@ -820,6 +817,29 @@ init_toolbar_chosen (GeditEncodingsDialog *dialog)
                                 dialog,
                                 0);
 
+       /* Separator */
+       separator = gtk_separator_tool_item_new ();
+       gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (separator), FALSE);
+       gtk_tool_item_set_expand (separator, TRUE);
+       gtk_toolbar_insert (toolbar, separator, -1);
+
+       /* Reset button */
+       dialog->priv->reset_button = GTK_WIDGET (gtk_tool_button_new (NULL, _("_Reset")));
+       g_object_ref_sink (dialog->priv->reset_button);
+
+       gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (dialog->priv->reset_button), TRUE);
+       gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (dialog->priv->reset_button), FALSE);
+
+       gtk_toolbar_insert (toolbar,
+                           GTK_TOOL_ITEM (dialog->priv->reset_button),
+                           -1);
+
+       g_signal_connect_object (dialog->priv->reset_button,
+                                "clicked",
+                                G_CALLBACK (reset_button_clicked_cb),
+                                dialog,
+                                0);
+
        gtk_widget_show_all (GTK_WIDGET (toolbar));
 }
 
diff --git a/gedit/gedit-encodings-dialog.h b/gedit/gedit-encodings-dialog.h
index c99a940..59b2211 100644
--- a/gedit/gedit-encodings-dialog.h
+++ b/gedit/gedit-encodings-dialog.h
@@ -36,8 +36,6 @@ typedef struct _GeditEncodingsDialog          GeditEncodingsDialog;
 typedef struct _GeditEncodingsDialogClass      GeditEncodingsDialogClass;
 typedef struct _GeditEncodingsDialogPrivate    GeditEncodingsDialogPrivate;
 
-#define GEDIT_ENCODINGS_DIALOG_RESPONSE_RESET  1
-
 struct _GeditEncodingsDialog
 {
        GtkDialog dialog;
diff --git a/gedit/resources/ui/gedit-encodings-dialog.ui b/gedit/resources/ui/gedit-encodings-dialog.ui
index 9b7b915..315f3c3 100644
--- a/gedit/resources/ui/gedit-encodings-dialog.ui
+++ b/gedit/resources/ui/gedit-encodings-dialog.ui
@@ -40,21 +40,11 @@
         <property name="has_subtitle">False</property>
         <property name="title" translatable="yes">Character Encodings</property>
         <child>
-          <object class="GtkButton" id="reset_button">
-            <property name="label" translatable="yes">_Reset</property>
-            <property name="visible">True</property>
-            <property name="use_underline">True</property>
-          </object>
-        </child>
-        <child>
           <object class="GtkButton" id="cancel_button">
             <property name="label" translatable="yes">_Cancel</property>
             <property name="visible">True</property>
             <property name="use_underline">True</property>
           </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
         </child>
         <child>
           <object class="GtkButton" id="apply_button">
@@ -65,7 +55,7 @@
           </object>
           <packing>
             <property name="pack_type">end</property>
-            <property name="position">2</property>
+            <property name="position">1</property>
           </packing>
         </child>
       </object>
@@ -282,7 +272,6 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="1">reset_button</action-widget>
       <action-widget response="cancel">cancel_button</action-widget>
       <action-widget response="apply" default="true">apply_button</action-widget>
     </action-widgets>


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