[latexila] Use an headerbar for the preferences dialog



commit 0e7b134397e1b75955194a896dbe45177b2743b5
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Oct 1 12:55:39 2015 +0200

    Use an headerbar for the preferences dialog
    
    This was one of the remaining dialog without an headerbar.

 src/preferences_dialog.vala |   34 +++++++++++++++-------------------
 1 files changed, 15 insertions(+), 19 deletions(-)
---
diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala
index 87e7ba8..fec0da4 100644
--- a/src/preferences_dialog.vala
+++ b/src/preferences_dialog.vala
@@ -28,31 +28,22 @@ public class PreferencesDialog : Dialog
 
     private PreferencesDialog ()
     {
+        Object (use_header_bar : 1);
+
         title = _("Preferences");
         destroy_with_parent = true;
         border_width = 5;
 
+        HeaderBar headerbar = get_header_bar () as HeaderBar;
+
+        headerbar.set_show_close_button (true);
+
         // reset all button
         Button reset_button = new Button.with_mnemonic (_("_Reset All"));
         reset_button.set_tooltip_text (_("Reset all preferences"));
         reset_button.show_all ();
-        add_action_widget (reset_button, ResponseType.APPLY);
-
-        // close button
-        add_button (_("_Close"), ResponseType.CLOSE);
-
-        response.connect ((response_id) =>
-        {
-            switch (response_id)
-            {
-                case ResponseType.CLOSE:
-                    hide ();
-                    return;
-                case ResponseType.APPLY:
-                    reset_all ();
-                    return;
-            }
-        });
+        reset_button.clicked.connect (() => reset_all ());
+        headerbar.pack_start (reset_button);
 
         /* load the UI */
 
@@ -96,10 +87,15 @@ public class PreferencesDialog : Dialog
         {
             _instance = new PreferencesDialog ();
 
+            _instance.delete_event.connect (() =>
+            {
+                _instance.hide ();
+                return true;
+            });
+
             _instance.destroy.connect (() =>
             {
-                if (_instance != null)
-                    _instance = null;
+                _instance = null;
             });
         }
 


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