[glabels/vala] Default to "search" page if no template history.



commit 4d2dc05f376e6f1c8636425096b76b38315b1720
Author: Jim Evins <evins snaught com>
Date:   Sun Apr 22 21:56:39 2012 -0400

    Default to "search" page if no template history.

 data/ui/new_label_dialog.ui   |    2 +-
 glabels/new_label_dialog.vala |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/data/ui/new_label_dialog.ui b/data/ui/new_label_dialog.ui
index 71740b2..ff7306d 100644
--- a/data/ui/new_label_dialog.ui
+++ b/data/ui/new_label_dialog.ui
@@ -11,7 +11,7 @@
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <child>
-          <object class="GtkNotebook" id="notebook1">
+          <object class="GtkNotebook" id="notebook">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="tab_pos">left</property>
diff --git a/glabels/new_label_dialog.vala b/glabels/new_label_dialog.vala
index 787402e..8de8b10 100644
--- a/glabels/new_label_dialog.vala
+++ b/glabels/new_label_dialog.vala
@@ -29,6 +29,8 @@ namespace glabels
 		private Prefs               prefs;
 		private TemplateHistory     template_history;
 
+		private Gtk.Notebook        notebook;
+
 		private Gtk.Box             recent_box;
 		private Gtk.Box             recent_info_box;
 		private MessageBar          recent_info_bar;
@@ -84,6 +86,8 @@ namespace glabels
 			Gtk.Box main_box = builder.get_object( "main_box" ) as Gtk.Box;
 			((Gtk.Box)get_content_area()).pack_start( main_box );
 
+			notebook             = builder.get_object( "notebook" )             as Gtk.Notebook;
+
 			/* Recent templates widgets */
 			recent_box           = builder.get_object( "recent_box" )           as Gtk.Box;
 			recent_info_box      = builder.get_object( "recent_info_box" )      as Gtk.Box;
@@ -139,6 +143,16 @@ namespace glabels
 			recent_icon_view.button_release_event.connect( on_recent_icon_view_button_release_event );
 			search_icon_view.selection_changed.connect( on_search_icon_view_selection_changed );
 			search_icon_view.button_release_event.connect( on_search_icon_view_button_release_event );
+
+			/* Set initial page. */
+			if ( template_history.get_template_list().length() == 0 )
+			{
+				notebook.set_current_page( notebook.page_num( search_box ) );
+			}
+			else
+			{
+				notebook.set_current_page( notebook.page_num( recent_box ) );
+			}
 		}
 
 



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