nemo r31 - in trunk: common gtk gtk-gui uicommon



Author: arj
Date: Mon Jan  7 10:46:16 2008
New Revision: 31
URL: http://svn.gnome.org/viewvc/nemo?rev=31&view=rev

Log:
Make labels work again

- right click and add new labels



Modified:
   trunk/common/Common.cs
   trunk/gtk-gui/MainWindow.cs
   trunk/gtk/MainWindow.cs
   trunk/gtk/RightClickButton.cs
   trunk/uicommon/Categories.cs
   trunk/uicommon/Category.cs
   trunk/uicommon/DocumentItem.cs
   trunk/uicommon/Item.cs
   trunk/uicommon/TypeLabels.cs

Modified: trunk/common/Common.cs
==============================================================================
--- trunk/common/Common.cs	(original)
+++ trunk/common/Common.cs	Mon Jan  7 10:46:16 2008
@@ -249,6 +249,11 @@
     public delegate R Function<R, A, B, C>(A a, B b, C c);
     public delegate R Function<R, A, B, C, D>(A a, B b, C c, D d);
 
+	public class SingletonWrapper<T>
+	{
+		public T wrapped;
+	}
+
 	public class Singleton<T>
 	{
 	    private static T _instance;

Modified: trunk/gtk-gui/MainWindow.cs
==============================================================================
--- trunk/gtk-gui/MainWindow.cs	(original)
+++ trunk/gtk-gui/MainWindow.cs	Mon Jan  7 10:46:16 2008
@@ -237,14 +237,14 @@
         this.prev_button.UseUnderline = true;
         // Container child prev_button.Gtk.Container+ContainerChild
         Gtk.Alignment w22 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
-        // Container child GtkAlignment.Gtk.Container+ContainerChild
+        // Container child GtkAlignment1.Gtk.Container+ContainerChild
         Gtk.HBox w23 = new Gtk.HBox();
         w23.Spacing = 2;
-        // Container child GtkHBox.Gtk.Container+ContainerChild
+        // Container child GtkHBox1.Gtk.Container+ContainerChild
         Gtk.Image w24 = new Gtk.Image();
         w24.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-go-back", Gtk.IconSize.Menu, 16);
         w23.Add(w24);
-        // Container child GtkHBox.Gtk.Container+ContainerChild
+        // Container child GtkHBox1.Gtk.Container+ContainerChild
         Gtk.Label w26 = new Gtk.Label();
         w26.LabelProp = "";
         w23.Add(w26);
@@ -262,14 +262,14 @@
         this.next_button.UseUnderline = true;
         // Container child next_button.Gtk.Container+ContainerChild
         Gtk.Alignment w31 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
-        // Container child GtkAlignment.Gtk.Container+ContainerChild
+        // Container child GtkAlignment2.Gtk.Container+ContainerChild
         Gtk.HBox w32 = new Gtk.HBox();
         w32.Spacing = 2;
-        // Container child GtkHBox.Gtk.Container+ContainerChild
+        // Container child GtkHBox2.Gtk.Container+ContainerChild
         Gtk.Image w33 = new Gtk.Image();
         w33.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-go-forward", Gtk.IconSize.Menu, 16);
         w32.Add(w33);
-        // Container child GtkHBox.Gtk.Container+ContainerChild
+        // Container child GtkHBox2.Gtk.Container+ContainerChild
         Gtk.Label w35 = new Gtk.Label();
         w35.LabelProp = "";
         w32.Add(w35);

Modified: trunk/gtk/MainWindow.cs
==============================================================================
--- trunk/gtk/MainWindow.cs	(original)
+++ trunk/gtk/MainWindow.cs	Mon Jan  7 10:46:16 2008
@@ -18,10 +18,7 @@
 
 	// restrictions
 	CalendarDriver calendar_driver;
-	Categories categories;
 	
-	TypeLabels typelabels;
-
 	bool starred_button_active;
 	
 	private Broker broker;
@@ -70,6 +67,8 @@
 			throw new Exception("die");
 		}
 
+		Singleton<SingletonWrapper<Broker>>.Instance.wrapped = broker;
+
 		System.Console.WriteLine("search tool is: {0}", Singleton<Configuration>.Instance.data.search_tool);
 		
 		// tray
@@ -81,8 +80,7 @@
 		// helpers
 		starred_button_active = false;
 
-		categories = new Categories(broker);
-		categories.set_drawer(new CategoriesDrawer(categories_event_box));
+		Singleton<Categories>.Instance.set_drawer(new CategoriesDrawer(categories_event_box));
 		calendar_driver = new CalendarDriver(new CalendarDrawer(calendar_event_box, day_button, week_button, month_button, 
 																year_button, today_button, current_date));
 		
@@ -92,12 +90,10 @@
 		search_input.AddEvents((int)Gdk.EventMask.KeyReleaseMask);
 
 		// update callbacks
-		categories.set_search_func(do_search);
-
-		typelabels = new TypeLabels(broker);
+		Singleton<Categories>.Instance.set_search_func(do_search);
 
-		typelabels.update_func = update_type_labels;
-		typelabels.search_func = do_search;
+		Singleton<TypeLabels>.Instance.update_func = update_type_labels;
+		Singleton<TypeLabels>.Instance.search_func = do_search;
 
 		calendar_driver.search_func = do_search;
 		calendar_driver.set_active_view = set_active_view;
@@ -224,8 +220,8 @@
 	{
 		Tuple<DateTime, DateTime> dates = calendar_driver.restriction();
 
-		List<long> types = typelabels.restrictions();
-        List<MetaLabel> keywords = categories.restrictions(); 
+		List<long> types = Singleton<TypeLabels>.Instance.restrictions();
+        List<MetaLabel> keywords = Singleton<Categories>.Instance.restrictions(); 
 
 		System.Console.WriteLine("searching for results: {0}, {1} keywords, {2} types", search_input.Text, keywords.Count, types.Count);
 		
@@ -371,7 +367,7 @@
 
 		foreach (TypeLabel label in labels) 
 		{
-			Gtk.ToggleButton b = label.representation(typelabels);
+			Gtk.ToggleButton b = label.representation(Singleton<TypeLabels>.Instance);
 
        		type_labels.PackStart(b, false, false, 0);
 		}
@@ -423,8 +419,8 @@
 	{
 		search_input.Text = "";
 
-		typelabels.clear_restrictions();
-		categories.clear_restrictions(); 
+		Singleton<TypeLabels>.Instance.clear_restrictions();
+		Singleton<Categories>.Instance.clear_restrictions(); 
 
 		do_search();
 	}

Modified: trunk/gtk/RightClickButton.cs
==============================================================================
--- trunk/gtk/RightClickButton.cs	(original)
+++ trunk/gtk/RightClickButton.cs	Mon Jan  7 10:46:16 2008
@@ -43,7 +43,7 @@
 
 		VoidFunction<Gdk.EventButton> button_press_handler;
 
-		protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
+		protected override bool OnButtonPressEvent(Gdk.EventButton evnt)
 		{
 			if (button_press_handler != null)
 				button_press_handler(evnt);

Modified: trunk/uicommon/Categories.cs
==============================================================================
--- trunk/uicommon/Categories.cs	(original)
+++ trunk/uicommon/Categories.cs	Mon Jan  7 10:46:16 2008
@@ -32,7 +32,7 @@
 			foreach (Category cat in categories) {
 				if (cat.metalabel.db_id == db_id) {
 					categories.Remove(cat);
-					Singleton<Broker>.Instance.remove_label(cat.metalabel);
+					Singleton<SingletonWrapper<Broker>>.Instance.wrapped.remove_label(cat.metalabel);
 					break;
 				}
 			}
@@ -107,14 +107,11 @@
 			drawer.set_categories(categories);
 		}
 		
-		public Categories(Broker broker)
+		public Categories()
 		{
 			categories = new List<Category>();
 
-			if (broker == null)
-				System.Console.WriteLine("boo boo");
-
-			broker.get_all_labels(Helpers.RunInMainThread<List<MetaLabel>>(got_labels));	
+			Singleton<SingletonWrapper<Broker>>.Instance.wrapped.get_all_labels(Helpers.RunInMainThread<List<MetaLabel>>(got_labels));	
 		}
 	}
 }

Modified: trunk/uicommon/Category.cs
==============================================================================
--- trunk/uicommon/Category.cs	(original)
+++ trunk/uicommon/Category.cs	Mon Jan  7 10:46:16 2008
@@ -35,7 +35,7 @@
 
         public void add_label(string label_name)
         {
-        	Singleton<Broker>.Instance.add_label(metalabel.db_id, label_name);
+        	Singleton<SingletonWrapper<Broker>>.Instance.wrapped.add_label(metalabel.db_id, label_name);
 		}
 
         public void add_label(MetaLabel l)
@@ -45,19 +45,19 @@
 
 		public void rename_label(MetaLabel label, string new_name)
 		{
-			Singleton<Broker>.Instance.rename_label(label, new_name);
+			Singleton<SingletonWrapper<Broker>>.Instance.wrapped.rename_label(label, new_name);
 			search_func();
 		}
 
         public void remove_label(MetaLabel label)
         {
-        	Singleton<Broker>.Instance.remove_label(label);
+        	Singleton<SingletonWrapper<Broker>>.Instance.wrapped.remove_label(label);
         	search_func();
         }
 
 		public void create_in_db(string name)
 		{
-			Singleton<Broker>.Instance.add_label(-1, name);
+			Singleton<SingletonWrapper<Broker>>.Instance.wrapped.add_label(-1, name);
 		}
 
 		public void rename(string new_name)

Modified: trunk/uicommon/DocumentItem.cs
==============================================================================
--- trunk/uicommon/DocumentItem.cs	(original)
+++ trunk/uicommon/DocumentItem.cs	Mon Jan  7 10:46:16 2008
@@ -64,10 +64,10 @@
 		{
 #if false
 			if (search_text != "") {
-				Singleton<Broker>.Instance.search_snippet(path, search_text, 
+				Singleton<SingletonWrapper<Broker>>.Instance.wrapped.search_snippet(path, search_text, 
 														  Helpers.RunInMainThread<string>(on_snippet_result));
 			} else
-				Singleton<Broker>.Instance.get_text(path, Helpers.RunInMainThread<string>(on_snippet_result));
+				Singleton<SingletonWrapper<Broker>>.Instance.wrapped.get_text(path, Helpers.RunInMainThread<string>(on_snippet_result));
 #endif
  		}
         

Modified: trunk/uicommon/Item.cs
==============================================================================
--- trunk/uicommon/Item.cs	(original)
+++ trunk/uicommon/Item.cs	Mon Jan  7 10:46:16 2008
@@ -202,7 +202,7 @@
 		{
 			file.starred = !file.starred;
 			
-			Singleton<Broker>.Instance.set_starred(file, file.starred);
+			Singleton<SingletonWrapper<Broker>>.Instance.wrapped.set_starred(file, file.starred);
 
 			foreach (VoidFunction<bool> func in starred_update_functions)
 				func(file.starred);
@@ -220,7 +220,7 @@
 				on_labels_callback();
 
 			// update tracker
-			Singleton<Broker>.Instance.add_label_to_file(file, label.metalabel);
+			Singleton<SingletonWrapper<Broker>>.Instance.wrapped.add_label_to_file(file, label.metalabel);
     	}
 		
 		public VoidFunction search_func;
@@ -240,7 +240,7 @@
 			if (on_labels_callback != null)
 				on_labels_callback();
 
-			Singleton<Broker>.Instance.remove_label_from_file(file, label.metalabel);
+			Singleton<SingletonWrapper<Broker>>.Instance.wrapped.remove_label_from_file(file, label.metalabel);
 		}
 
 		public bool contains_label(UserLabel label)

Modified: trunk/uicommon/TypeLabels.cs
==============================================================================
--- trunk/uicommon/TypeLabels.cs	(original)
+++ trunk/uicommon/TypeLabels.cs	Mon Jan  7 10:46:16 2008
@@ -95,11 +95,11 @@
 			search_func();
 		}
 
-        public TypeLabels(Broker broker) 
+        public TypeLabels() 
         {
             labels = new List<TypeLabel>();
 			
-            broker.get_type_labels(Helpers.RunInMainThread<List<Tuple<FileTypeCategory, int>>>(on_broker_labels_result));
+            Singleton<SingletonWrapper<Broker>>.Instance.wrapped.get_type_labels(Helpers.RunInMainThread<List<Tuple<FileTypeCategory, int>>>(on_broker_labels_result));
         }
     }
 }



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