[gitg] Add open repository button



commit 9146df639ffad68439cdb9333481f4e6cf798b29
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri Mar 1 13:45:34 2013 +0100

    Add open repository button

 gitg/gitg-window.vala            |   22 +++++++++++++++
 gitg/resources/ui/gitg-window.ui |   56 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 0 deletions(-)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index ac01a4d..de0165c 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -35,6 +35,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
        private Gd.HeaderBar d_header_bar;
        private Gtk.MenuButton d_config;
 
+       private Gd.HeaderSimpleButton d_button_open_repository;
        private Gd.HeaderSimpleButton d_button_dash;
        private Gd.StackSwitcher d_commit_view_switcher;
 
@@ -89,6 +90,7 @@ 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_button_open_repository.hide();
                }
                else
                {
@@ -97,6 +99,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_button_open_repository.show();
                }
 
                d_views.update();
@@ -119,10 +122,29 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
                return base.configure_event(event);
        }
 
+       private void on_open_repository(Gtk.Button button)
+       {
+               Gtk.FileChooserDialog chooser = 
Resource.load_object<Gtk.FileChooserDialog>("ui/gitg-window.ui", "filechooserdialog_open");
+               chooser.transient_for = this;
+               chooser.show();
+
+               chooser.response.connect((c, id) => {
+                       if (id == Gtk.ResponseType.OK)
+                       {
+                               var folder = chooser.get_current_folder_file();
+                               open(folder);
+                       }
+
+                       c.destroy();
+               });
+       }
+
        private void parser_finished(Gtk.Builder builder)
        {
                // Extract widgets from the builder
                d_header_bar = builder.get_object("header-bar") as Gd.HeaderBar;
+               d_button_open_repository = builder.get_object("button_open_repository") as 
Gd.HeaderSimpleButton;
+               d_button_open_repository.clicked.connect(on_open_repository);
                d_button_dash = builder.get_object("button_dash") as Gd.HeaderSimpleButton;
                d_button_dash.clicked.connect((b) => {
                        repository = null;
diff --git a/gitg/resources/ui/gitg-window.ui b/gitg/resources/ui/gitg-window.ui
index 47e466f..c5c3e9e 100644
--- a/gitg/resources/ui/gitg-window.ui
+++ b/gitg/resources/ui/gitg-window.ui
@@ -19,6 +19,16 @@
             <property name="can_focus">False</property>
             <property name="vexpand">False</property>
             <child>
+              <object class="GdHeaderSimpleButton" id="button_open_repository">
+                <property name="visible">False</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Open Repository</property>
+              </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>
@@ -264,4 +274,50 @@
       </object>
     </child>
   </object>
+  <object class="GtkFileChooserDialog" id="filechooserdialog_open">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Open Repository</property>
+    <property name="role">GtkFileChooserDialog</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="action">select-folder</property>
+    <property name="create-folders">False</property>
+    <property name="local-only">True</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="filechooserdialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="filechooserdialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="filechooserdialog_button_open">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton" id="filechooserdialog_button_cancel">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_stock">True</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-5">filechooserdialog_button_open</action-widget>
+      <action-widget response="-6">filechooserdialog_button_cancel</action-widget>
+    </action-widgets>
+  </object>
 </interface>


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