[gitg] Put open/clone in the gear menu



commit a113b4067a6271da3ed9d77eb364a2a6b9f157b4
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Mar 28 17:52:00 2013 +0100

    Put open/clone in the gear menu

 gitg/gitg-window.vala            |   23 +++++-------
 gitg/resources/ui/gitg-menus.ui  |   73 ++++++++++++++++++++++++++++++++++++-
 gitg/resources/ui/gitg-window.ui |   27 --------------
 3 files changed, 81 insertions(+), 42 deletions(-)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 8d4846c..522b2a7 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -34,8 +34,9 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
        // Widgets
        private Gd.HeaderBar d_header_bar;
        private Gtk.MenuButton d_gear_menu;
+       private MenuModel d_dash_model;
+       private MenuModel d_views_model;
 
-       private Gtk.Box d_dash_buttons_box;
        private Gd.HeaderSimpleButton d_button_dash;
        private Gd.StackSwitcher d_commit_view_switcher;
 
@@ -57,6 +58,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
        private static const ActionEntry[] win_entries = {
                {"search", on_search_activated, null, "false", null},
                {"gear-menu", on_gear_menu_activated, null, "false", null},
+               {"open-repository", on_open_repository},
+               {"clone-repository", on_clone_repository},
                {"close", on_close_activated},
        };
 
@@ -131,8 +134,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                        d_main_stack.set_visible_child(d_paned_views);
                        d_commit_view_switcher.show();
                        d_button_dash.show();
-                       d_dash_buttons_box.hide();
                        d_dash_view.add_repository(d_repository);
+                       d_gear_menu.menu_model = d_views_model;
                }
                else
                {
@@ -145,7 +148,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                        d_main_stack.set_visible_child(d_dash_scrolled_window);
                        d_commit_view_switcher.hide();
                        d_button_dash.hide();
-                       d_dash_buttons_box.show();
+                       d_gear_menu.menu_model = d_dash_model;
                }
 
                d_views.update();
@@ -168,7 +171,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                return base.configure_event(event);
        }
 
-       private void on_open_repository(Gtk.Button button)
+       private void on_open_repository()
        {
                var chooser = new Gtk.FileChooserDialog (_("Select Repository"), this,
                                                         Gtk.FileChooserAction.SELECT_FOLDER,
@@ -188,7 +191,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                chooser.show();
        }
 
-       private void on_clone_repository(Gtk.Button button)
+       private void on_clone_repository()
        {
                var ret = GitgExt.UI.from_builder("ui/gitg-clone-dialog.ui",
                                                  "dialog-clone",
@@ -227,12 +230,6 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                // Extract widgets from the builder
                d_header_bar = builder.get_object("header-bar") as Gd.HeaderBar;
 
-               d_dash_buttons_box = builder.get_object("dash_buttons_box") as Gtk.Box;
-               var button_open_repository = builder.get_object("button_open_repository") as 
Gd.HeaderSimpleButton;
-               button_open_repository.clicked.connect(on_open_repository);
-               var button_clone_repository = builder.get_object("button_clone_repository") as 
Gd.HeaderSimpleButton;
-               button_clone_repository.clicked.connect(on_clone_repository);
-
                d_button_dash = builder.get_object("button_dash") as Gd.HeaderSimpleButton;
                d_button_dash.clicked.connect((b) => {
                        repository = null;
@@ -268,8 +265,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                        menuname = "app-win-menu";
                }
 
-               var model = Resource.load_object<MenuModel>("ui/gitg-menus.ui", menuname);
-               d_gear_menu.menu_model = model;
+               d_dash_model = Resource.load_object<MenuModel>("ui/gitg-menus.ui", menuname + "-dash");
+               d_views_model = Resource.load_object<MenuModel>("ui/gitg-menus.ui", menuname + "-views");
 
                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-menus.ui b/gitg/resources/ui/gitg-menus.ui
index 06936ff..ccca2c1 100644
--- a/gitg/resources/ui/gitg-menus.ui
+++ b/gitg/resources/ui/gitg-menus.ui
@@ -34,7 +34,18 @@
       </item>
     </section>
   </menu>
-  <menu id="win-menu">
+  <menu id="win-menu-dash">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Open Repository</attribute>
+        <attribute name="action">win.open-repository</attribute>
+        <attribute name="accel">&lt;Primary&gt;o</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Clone Repository</attribute>
+        <attribute name="action">win.clone-repository</attribute>
+      </item>
+    </section>
     <section>
       <item>
         <attribute name="label" translatable="yes">_Close</attribute>
@@ -43,7 +54,65 @@
       </item>
     </section>
   </menu>
-  <menu id="app-win-menu">
+  <menu id="win-menu-views">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Close</attribute>
+        <attribute name="action">win.close</attribute>
+        <attribute name="accel">&lt;Primary&gt;w</attribute>
+      </item>
+    </section>
+  </menu>
+   <menu id="app-win-menu-dash">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_New Window</attribute>
+        <attribute name="action">app.new</attribute>
+        <attribute name="accel">&lt;Primary&gt;n</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Open Repository</attribute>
+        <attribute name="action">win.open-repository</attribute>
+        <attribute name="accel">&lt;Primary&gt;o</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Clone Repository</attribute>
+        <attribute name="action">win.clone-repository</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Preferences</attribute>
+        <attribute name="action">app.preferences</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Help</attribute>
+        <attribute name="action">app.help</attribute>
+        <attribute name="accel">F1</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_About</attribute>
+        <attribute name="action">app.about</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Close</attribute>
+        <attribute name="action">win.close</attribute>
+        <attribute name="accel">&lt;Primary&gt;w</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Quit</attribute>
+        <attribute name="action">app.quit</attribute>
+        <attribute name="accel">&lt;Primary&gt;q</attribute>
+      </item>
+    </section>
+  </menu>
+  <menu id="app-win-menu-views">
     <section>
       <item>
         <attribute name="label" translatable="yes">_New Window</attribute>
diff --git a/gitg/resources/ui/gitg-window.ui b/gitg/resources/ui/gitg-window.ui
index e27c39c..9fc5714 100644
--- a/gitg/resources/ui/gitg-window.ui
+++ b/gitg/resources/ui/gitg-window.ui
@@ -19,33 +19,6 @@
             <property name="can_focus">False</property>
             <property name="vexpand">False</property>
             <child>
-              <object class="GtkBox" id="dash_buttons_box">
-                <property name="visible">False</property>
-                <property name="can_focus">False</property>
-                <property name="orientation">horizontal</property>
-                <style>
-                  <class name="linked"/>
-                </style>
-                <child>
-                  <object class="GdHeaderSimpleButton" id="button_open_repository">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Open Repository</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GdHeaderSimpleButton" id="button_clone_repository">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Clone Repository</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="pack_type">start</property>
-              </packing>
-            </child>
-            <child>
               <object class="GdHeaderSimpleButton" id="button_dash">
                 <property name="visible">False</property>
                 <property name="can_focus">False</property>


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