[gnome-mines] theme-selector: theme switching button placing fixes



commit 0659b217c88a24729c9c373daf4403448df1eb22
Author: Robert Roth <robert roth off gmail com>
Date:   Thu Jan 15 04:26:25 2015 +0200

    theme-selector: theme switching button placing fixes
    
    * in case of headerbar-using desktop shells use the headerbar to show the previous/next buttons
    * in case of unity add the theme switcher buttons to the dialog content area
    * in case of unity add a close button to the action area as we don't have a headerbar with a close button
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742890

 src/gnome-mines.vala           |    4 +--
 src/theme-selector-dialog.vala |   49 ++++++++++++++++++++-------------------
 2 files changed, 26 insertions(+), 27 deletions(-)
---
diff --git a/src/gnome-mines.vala b/src/gnome-mines.vala
index ad84563..0d35a16 100644
--- a/src/gnome-mines.vala
+++ b/src/gnome-mines.vala
@@ -491,9 +491,7 @@ public class Mines : Gtk.Application
 
     private int show_theme_selector ()
     {
-        theme_dialog = new ThemeSelectorDialog ();
-        theme_dialog.modal = true;
-        theme_dialog.transient_for = window;
+        theme_dialog = new ThemeSelectorDialog ( window );
 
         var result = theme_dialog.run ();
         theme_dialog.destroy ();
diff --git a/src/theme-selector-dialog.vala b/src/theme-selector-dialog.vala
index db9b6fc..dfc2cc5 100644
--- a/src/theme-selector-dialog.vala
+++ b/src/theme-selector-dialog.vala
@@ -34,7 +34,7 @@ public class ThemeSelectorDialog : Gtk.Dialog
 
     private Gtk.Button previous;
     private Gtk.Button next;
-    private Settings settings;
+    private Settings settings = new Settings ("org.gnome.mines");
     public List<string> list_themes ()
     {
         string themes_dir = Path.build_path (Path.DIR_SEPARATOR_S, DATA_DIRECTORY, "themes");
@@ -74,33 +74,38 @@ public class ThemeSelectorDialog : Gtk.Dialog
         return frame;
     }
 
-    public ThemeSelectorDialog ( )
+    public ThemeSelectorDialog ( Gtk.Window parent )
     {
-        Object (use_header_bar: 1);
-
+        var desktop = Environment.get_variable ("XDG_CURRENT_DESKTOP");
+        bool use_headerbar = desktop == null || desktop != "Unity";
         MinefieldView minefield;
-        title = _("Select Theme");
 
-        (get_header_bar () as Gtk.HeaderBar).set_show_close_button (true);
-        var overlay = new Gtk.Overlay ();
-        get_content_area ().pack_start (overlay, true, true, 0);
+        Object (use_header_bar: use_headerbar ? 1 : 0, title:  _("Select Theme"),
+                modal: true, transient_for: parent, resizable: false);
 
-        previous = new Gtk.Button.from_icon_name ("go-previous-symbolic", Gtk.IconSize.LARGE_TOOLBAR);
-        previous.show ();
+        previous = new Gtk.Button.from_icon_name ("go-previous-symbolic", Gtk.IconSize.BUTTON);
         previous.valign = Gtk.Align.CENTER;
         previous.halign = Gtk.Align.START;
-        previous.get_style_context ().add_class ("navigation");
-        overlay.add_overlay (previous);
 
-        next = new Gtk.Button.from_icon_name ("go-next-symbolic", Gtk.IconSize.LARGE_TOOLBAR);
-        next.show ();
+        next = new Gtk.Button.from_icon_name ("go-next-symbolic", Gtk.IconSize.BUTTON);
         next.valign = Gtk.Align.CENTER;
         next.halign = Gtk.Align.END;
-        next.get_style_context ().add_class ("navigation");
-        overlay.add_overlay (next);
 
-        settings = new Settings ("org.gnome.mines");
-        settings.delay ();
+        if (use_headerbar) {
+            var headerbar = get_header_bar () as Gtk.HeaderBar;
+            headerbar.set_show_close_button (true);
+            get_content_area ().pack_start (create_preview_widget (out minefield), true, true, 0);
+            headerbar.pack_start (previous);
+            headerbar.pack_start (next);
+        } else {
+            add_button (_("Close"), Gtk.ResponseType.DELETE_EVENT);
+            border_width = 12;
+            var buttons_holder = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+            buttons_holder.pack_start (previous, false, false, 0);
+            buttons_holder.pack_start (create_preview_widget (out minefield), true, true, 0);
+            buttons_holder.pack_start (next, false, false, 0);
+            get_content_area ().pack_end (buttons_holder, true, true, 0);
+        }
 
         var themes = list_themes ();
         var current_theme = settings.get_string ("theme");
@@ -114,8 +119,6 @@ public class ThemeSelectorDialog : Gtk.Dialog
             }
         }
 
-        overlay.add (create_preview_widget (out minefield));
-
         next.clicked.connect (() => {
             switch_theme_preview (++current_index, themes);
             update_sensitivities (themes, current_index);
@@ -128,11 +131,9 @@ public class ThemeSelectorDialog : Gtk.Dialog
             minefield.refresh ();
         });
 
+        set_size_request (420, 400);
         update_sensitivities (themes, current_index);
-        overlay.show_all ();
-
-        set_size_request (400, 400);
-        resizable = false;
+        show_all ();
     }
 
     private void switch_theme_preview (int to_index, List<string> themes)


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