[gitg/wip/notebook] Set the dash or repository view depending of active repository



commit a22349ab0da72ecea530b718b309badb353a58e9
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Oct 23 16:00:45 2012 +0200

    Set the dash or repository view depending of active repository

 gitg/gitg-window.vala            |   49 ++++++++++++++++++++++++++-----------
 gitg/resources/ui/gitg-window.ui |    6 ++--
 2 files changed, 37 insertions(+), 18 deletions(-)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 546e21f..6817b93 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -22,6 +22,12 @@ namespace Gitg
 
 public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.Buildable
 {
+	private enum ViewType
+	{
+		DASH = 0,
+		REPOSITORY = 1
+	}
+
 	private Repository? d_repository;
 	private GitgExt.MessageBus d_message_bus;
 	private string? d_action;
@@ -29,6 +35,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
 	private UIElements<GitgExt.View> d_views;
 	private UIElements<GitgExt.Panel> d_panels;
 
+	private Gtk.Notebook d_notebook;
+
 	private Gtk.MenuButton d_config;
 
 	// Widgets
@@ -61,6 +69,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
 	private void parser_finished(Gtk.Builder builder)
 	{
 		// Extract widgets from the builder
+		d_notebook = builder.get_object("notebook") as Gtk.Notebook;
+
 		d_toolbar_views = builder.get_object("toolbar_views") as Gtk.Toolbar;
 		d_paned_views = builder.get_object("paned_views") as Gtk.Paned;
 
@@ -107,25 +117,34 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
 
 	private void activate_default_view()
 	{
-		d_views.foreach((element) => {
-			GitgExt.View view = (GitgExt.View)element;
+		if (d_repository == null)
+		{
+			d_notebook.set_current_page(ViewType.DASH);
+		}
+		else
+		{
+			d_notebook.set_current_page(ViewType.REPOSITORY);
 
-			if (view.is_default_for(d_action))
-			{
-				if (d_views.current == view)
-				{
-					on_view_activated(d_views, view);
-				}
-				else
+			d_views.foreach((element) => {
+				GitgExt.View view = (GitgExt.View)element;
+
+				if (view.is_default_for(d_action))
 				{
-					d_views.current = view;
+					if (d_views.current == view)
+					{
+						on_view_activated(d_views, view);
+					}
+					else
+					{
+						d_views.current = view;
+					}
+
+					return false;
 				}
 
-				return false;
-			}
-
-			return true;
-		});
+				return true;
+			});
+		}
 	}
 
 	private bool init(Cancellable? cancellable)
diff --git a/gitg/resources/ui/gitg-window.ui b/gitg/resources/ui/gitg-window.ui
index 310eec3..c3e4f9e 100644
--- a/gitg/resources/ui/gitg-window.ui
+++ b/gitg/resources/ui/gitg-window.ui
@@ -25,7 +25,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <child>
-          <object class="GtkToolbar" id="toolbar1">
+          <object class="GtkToolbar" id="toolbar">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="hexpand">True</property>
@@ -35,7 +35,7 @@
               <class name="menubar"/>
             </style>
             <child>
-              <object class="GtkToolItem" id="toolbutton1">
+              <object class="GtkToolItem" id="toolitem1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <style>
@@ -65,7 +65,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkToolItem" id="toolbutton2">
+              <object class="GtkToolItem" id="toolitem2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>



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