[gitg] Fix back-portable header bar positions



commit 1ea17027e3d19d76f38dfe9e00a58d3a15bae75c
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Thu Jan 9 22:39:25 2014 +0100

    Fix back-portable header bar positions
    
    This reverts dbb2e0feb050d30376455d14b2af656e56686c6f and adds a
    temporary fix for gtk+ >= 3.11. This commit can be reverted once we
    bump our gtk+ requirement to 3.12.

 configure.ac                     |   10 ++++++++++
 gitg/gitg-window.vala            |   13 +++++++++++++
 gitg/resources/ui/gitg-window.ui |   18 +++++++++---------
 vapi/config.vapi                 |    4 ++++
 4 files changed, 36 insertions(+), 9 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bc0e6a2..c370495 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,6 +107,16 @@ PKG_CHECK_MODULES(LIBGITG, [
        json-glib-1.0
 ])
 
+dnl temporary check for 3.11 to switch header bar buttons. This check can
+dnl be removed when we bump the gtk+ requirement to 3.12
+PKG_CHECK_EXISTS(gtk+-3.0 >= 3.11,
+                 [GTK_VERSION_AT_LEAST_3_11=TRUE],
+                 [GTK_VERSION_AT_LEAST_3_11=FALSE])
+
+AC_DEFINE_UNQUOTED([GTK_VERSION_AT_LEAST_3_11],
+                   $GTK_VERSION_AT_LEAST_3_11,
+                   [Set if the gtk+ version is at least 3.11])
+
 AC_MSG_CHECKING([for libgit2-glib threading support])
 
 cflags_save="${CFLAGS}"
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index eedb457..75f2ab3 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -171,6 +171,19 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
                {
                        dash_image.icon_name = "go-previous-symbolic";
                }
+
+               // temporary check for 3.11 to switch header bar buttons. This check can
+               // be removed when we bump the gtk+ requirement to 3.12
+               if (Config.GTK_VERSION_AT_LEAST_3_11)
+               {
+                       d_header_bar.remove(d_activities_switcher);
+                       d_header_bar.remove(d_search_button);
+                       d_header_bar.remove(d_gear_menu);
+
+                       d_header_bar.pack_end(d_gear_menu);
+                       d_header_bar.pack_end(d_search_button);
+                       d_header_bar.pack_end(d_activities_switcher);
+               }
        }
 
        private void on_close_activated()
diff --git a/gitg/resources/ui/gitg-window.ui b/gitg/resources/ui/gitg-window.ui
index 647b6a2..23098b2 100644
--- a/gitg/resources/ui/gitg-window.ui
+++ b/gitg/resources/ui/gitg-window.ui
@@ -35,19 +35,20 @@
           </packing>
         </child>
         <child>
-          <object class="GtkMenuButton" id="d_gear_menu">
+          <object class="GtkToggleButton" id="d_search_button">
             <property name="visible">True</property>
             <property name="valign">center</property>
             <property name="can_focus">False</property>
-            <property name="action_name">win.gear-menu</property>
+            <property name="action_name">win.search</property>
+            <signal name="toggled" handler="search_button_toggled" swapped="no"/>
             <style>
               <class name="image-button"/>
             </style>
             <child>
-              <object class="GtkImage" id="gear_image">
+              <object class="GtkImage" id="search_image">
                 <property name="visible">True</property>
                 <property name="icon_size">1</property>
-                <property name="icon_name">emblem-system-symbolic</property>
+                <property name="icon_name">edit-find-symbolic</property>
               </object>
             </child>
           </object>
@@ -64,20 +65,19 @@
           </packing>
         </child>
         <child>
-          <object class="GtkToggleButton" id="d_search_button">
+          <object class="GtkMenuButton" id="d_gear_menu">
             <property name="visible">True</property>
             <property name="valign">center</property>
             <property name="can_focus">False</property>
-            <property name="action_name">win.search</property>
-            <signal name="toggled" handler="search_button_toggled" swapped="no"/>
+            <property name="action_name">win.gear-menu</property>
             <style>
               <class name="image-button"/>
             </style>
             <child>
-              <object class="GtkImage" id="search_image">
+              <object class="GtkImage" id="gear_image">
                 <property name="visible">True</property>
                 <property name="icon_size">1</property>
-                <property name="icon_name">edit-find-symbolic</property>
+                <property name="icon_name">emblem-system-symbolic</property>
               </object>
             </child>
           </object>
diff --git a/vapi/config.vapi b/vapi/config.vapi
index fa2dd34..c69264b 100644
--- a/vapi/config.vapi
+++ b/vapi/config.vapi
@@ -9,6 +9,10 @@ namespace Gitg.Config
        public const string GITG_LOCALEDIR;
        public const string GITG_LIBDIR;
        public const string VERSION;
+
+       // temporary check for 3.11 to switch header bar buttons. This check can
+       // be removed when we bump the gtk+ requirement to 3.12
+       public const bool GTK_VERSION_AT_LEAST_3_11;
 }
 
 // ex:ts=4 noet


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