[gitg] Show the gear menu when pressing F10



commit 2a736164afc6b5294163fe861feb93fbc1c631d7
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Mar 16 19:15:51 2013 +0100

    Show the gear menu when pressing F10
    
    Also rename the member for clarity

 gitg/gitg-application.vala       |    2 ++
 gitg/gitg-window.vala            |   12 +++++++++---
 gitg/resources/ui/gitg-window.ui |    3 ++-
 3 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/gitg/gitg-application.vala b/gitg/gitg-application.vala
index 4ab1b88..22274c2 100644
--- a/gitg/gitg-application.vala
+++ b/gitg/gitg-application.vala
@@ -276,6 +276,8 @@ public class Application : Gtk.Application
                        }
                }
 
+               add_accelerator("F10", "win.gear-menu", null);
+
                // Use our own css provider
                Gtk.CssProvider? provider = Resource.load_css("style.css");
                if (provider != null)
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 21d281f..4b9f1fd 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -33,7 +33,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
 
        // Widgets
        private Gd.HeaderBar d_header_bar;
-       private Gtk.MenuButton d_config;
+       private Gtk.MenuButton d_gear_menu;
 
        private Gd.HeaderSimpleButton d_button_open_repository;
        private Gd.HeaderSimpleButton d_button_dash;
@@ -55,6 +55,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
        private GitgExt.NavigationTreeView d_navigation;
 
        private static const ActionEntry[] win_entries = {
+               {"gear-menu", on_gear_menu_activated, null, "false", null},
                {"close", on_close_activated},
        };
 
@@ -68,6 +69,11 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                destroy();
        }
 
+       private void on_gear_menu_activated(SimpleAction action) {
+               var state = action.get_state().get_boolean();
+               action.set_state(new Variant.boolean(!state));
+       }
+
        public GitgExt.View? current_view
        {
                owned get { return d_views.current; }
@@ -188,7 +194,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                d_commit_view_switcher.stack = d_stack_panel;
 
                d_navigation = builder.get_object("tree_view_navigation") as GitgExt.NavigationTreeView;
-               d_config = builder.get_object("button_config") as Gtk.MenuButton;
+               d_gear_menu = builder.get_object("gear-menubutton") as Gtk.MenuButton;
 
                string menuname;
 
@@ -202,7 +208,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                }
 
                var model = Resource.load_object<MenuModel>("ui/gitg-menus.ui", menuname);
-               d_config.menu_model = model;
+               d_gear_menu.menu_model = model;
 
                var search_button = builder.get_object("search-button") as Gd.HeaderToggleButton;
                var revealer = builder.get_object("search-revealer") as Gd.Revealer;
diff --git a/gitg/resources/ui/gitg-window.ui b/gitg/resources/ui/gitg-window.ui
index 54d1569..b9568ab 100644
--- a/gitg/resources/ui/gitg-window.ui
+++ b/gitg/resources/ui/gitg-window.ui
@@ -57,10 +57,11 @@
               </packing>
             </child>
             <child>
-              <object class="GdHeaderMenuButton" id="button_config">
+              <object class="GdHeaderMenuButton" id="gear-menubutton">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="symbolic_icon_name">emblem-system-symbolic</property>
+                <property name="action_name">win.gear-menu</property>
               </object>
               <packing>
                 <property name="pack_type">end</property>


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