[Patch] Show/Hide Tag Icons



Hey,

In response to the request calling for a cleanup and review of the
f-spot patches currently sitting in bugzilla I have subitted my first
patch to f-spot [1]. Hence i'm not too sure of protocol, etc. Comments
appreciated.

Well actually its an update of someone elses that gives the ability to
disable the showing of tag icons. It is very useful to me who has many
nested levels of tags and finds the iconified dialog tool cumbersome.

Applies cleanly against cvs.

John

[1] http://bugzilla.gnome.org/show_bug.cgi?id=321025

? patches
Index: MainWindow.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/MainWindow.cs,v
retrieving revision 1.290
diff -u -p -r1.290 MainWindow.cs
--- MainWindow.cs	19 May 2006 18:46:55 -0000	1.290
+++ MainWindow.cs	24 May 2006 00:09:16 -0000
@@ -77,6 +77,9 @@ public class MainWindow {
 	[Glade.Widget] MenuItem zoom_in;
 	[Glade.Widget] MenuItem zoom_out;
 
+	[Glade.Widget] RadioMenuItem tag_icon_shown;
+	[Glade.Widget] RadioMenuItem tag_icon_hidden;
+
 	[Glade.Widget] RadioMenuItem month;
 	[Glade.Widget] RadioMenuItem directory;
 	[Glade.Widget] CheckMenuItem reverse_order;
@@ -127,6 +130,7 @@ public class MainWindow {
 	string last_import_path;
 	ModeType view_mode;
 	bool write_metadata = false;
+    bool show_tag_icons;
 
 	// Drag and Drop
 	enum TargetType {
@@ -242,6 +246,8 @@ public class MainWindow {
 
 		tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
 		tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
+
+        LoadPreference (Preferences.TAG_ICON_SHOWN);
 		
 		info_box = new InfoBox ();
 		info_box.VersionIdChanged += HandleInfoBoxVersionIdChange;
@@ -1480,6 +1486,19 @@ public class MainWindow {
                            null, authors, new string [0], translators, null).Show();
 	}
 
+	void HandleTagSizeChange (object sender, EventArgs args)
+	{
+		RadioMenuItem choice = sender as RadioMenuItem;
+
+        //Get this callback twice. Once for the activte menuitem,
+        //once for the inactive one. Ignore the inactive one
+        if (!choice.Active)
+            return;
+
+        show_tag_icons = (choice == tag_icon_shown);
+        tag_selection_widget.SetTagIconVisibility(show_tag_icons);
+	}
+
 	public void HandleArrangeByTime (object sender, EventArgs args)
 	{
 		if (group_selector.Adaptor is TimeAdaptor)
@@ -1569,6 +1588,8 @@ public class MainWindow {
 		
 		Preferences.Set (Preferences.SIDEBAR_POSITION,		main_hpaned.Position);
 		Preferences.Set (Preferences.ZOOM,			icon_view.Zoom);
+
+        Preferences.Set (Preferences.TAG_ICON_SHOWN, show_tag_icons);
 		
 		tag_selection_widget.SaveExpandDefaults ();
 
@@ -2369,6 +2390,12 @@ public class MainWindow {
 		case Preferences.SIDEBAR_POSITION:
 			if (main_hpaned.Position != (int) val)
 				main_hpaned.Position = (int) val;
+			break;
+
+		case Preferences.TAG_ICON_SHOWN:
+            tag_icon_shown.Active = (bool) val;
+            tag_icon_hidden.Active = ! (bool) val;
+            tag_selection_widget.SetTagIconVisibility((bool) val);
 			break;
 
 		case Preferences.ZOOM:
Index: Preferences.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/Preferences.cs,v
retrieving revision 1.13
diff -u -p -r1.13 Preferences.cs
--- Preferences.cs	19 May 2006 16:21:10 -0000	1.13
+++ Preferences.cs	24 May 2006 00:09:17 -0000
@@ -47,6 +47,7 @@ namespace FSpot
 		public const string SHOW_TAGS = "/apps/f-spot/ui/show_tags";
 		public const string SHOW_DATES = "/apps/f-spot/ui/show_dates";
 		public const string EXPANDED_TAGS = "/apps/f-spot/ui/expanded_tags";
+		public const string TAG_ICON_SHOWN = "/apps/f-spot/ui/tag_icon_shown";
 		
 		public const string GLASS_POSITION = "/apps/f-spot/ui/glass_position";
 		public const string GROUP_ADAPTOR = "/apps/f-spot/ui/group_adaptor";
@@ -119,6 +120,9 @@ namespace FSpot
 			case SHOW_TIMELINE:
 			case SHOW_TAGS:
 			case SHOW_DATES:
+				return true;
+			
+			case TAG_ICON_SHOWN:
 				return true;
 		
 			case SIDEBAR_POSITION:
Index: TagSelectionWidget.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/TagSelectionWidget.cs,v
retrieving revision 1.37
diff -u -p -r1.37 TagSelectionWidget.cs
--- TagSelectionWidget.cs	2 Mar 2006 02:23:01 -0000	1.37
+++ TagSelectionWidget.cs	24 May 2006 00:09:18 -0000
@@ -48,6 +48,12 @@ public class TagSelectionWidget : TreeVi
 	// Hash of the IDs of the selected tags.
 	private Hashtable selection;
 
+	public CellRenderer Icons {
+		get {
+			return icon_render;
+		}
+	}
+
 	public Tag TagAtPosition (int x, int y) 
 	{
 		TreePath path;
@@ -624,9 +630,16 @@ public class TagSelectionWidget : TreeVi
 		return;
 	}
 
+    public void SetTagIconVisibility(bool icons_visible)
+    {
+        Icons.Visible = icons_visible;
+        ColumnsAutosize();
+    }
+
 	TreeViewColumn check_column;
 	TreeViewColumn icon_column;
 	TreeViewColumn name_column;
+	CellRendererPixbuf icon_render;
 
 	// Constructor.
 	public TagSelectionWidget (TagStore tag_store)
@@ -641,7 +654,8 @@ public class TagSelectionWidget : TreeVi
 		check_column = AppendColumn ("check", toggle_renderer, new TreeCellDataFunc (CheckBoxDataFunc));
 		check_column.SortColumnId = 0;
 
-		icon_column = AppendColumn ("icon", new CellRendererPixbuf (), new TreeCellDataFunc (IconDataFunc));
+		icon_render = new CellRendererPixbuf ();
+		icon_column = AppendColumn ("icon", icon_render, new TreeCellDataFunc (IconDataFunc));
 
 		CellRendererText tr = new CellRendererText ();
 		tr.Editable = true;
Index: f-spot.glade
===================================================================
RCS file: /cvs/gnome/f-spot/src/f-spot.glade,v
retrieving revision 1.160
diff -u -p -r1.160 f-spot.glade
--- f-spot.glade	1 May 2006 20:15:10 -0000	1.160
+++ f-spot.glade	24 May 2006 00:09:50 -0000
@@ -7598,6 +7598,46 @@ Photo Details</property>
 		      <property name="visible">True</property>
 		    </widget>
 		  </child>
+		  
+		  <child>
+		    <widget class="GtkMenuItem" id="tag_icon_size">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">Tag Icons</property>
+		      <property name="use_underline">True</property>
+
+		      <child>
+			<widget class="GtkMenu" id="tag_icon_size_menu">
+
+			  <child>
+			    <widget class="GtkRadioMenuItem" id="tag_icon_shown">
+			      <property name="visible">True</property>
+			      <property name="label" translatable="yes">_Shown</property>
+			      <property name="use_underline">True</property>
+			      <property name="active">True</property>
+			      <signal name="activate" handler="HandleTagSizeChange" last_modification_time="Fri, 20 Aug 2004 22:26:32 GMT"/>
+			    </widget>
+			  </child>
+
+			  <child>
+			    <widget class="GtkRadioMenuItem" id="tag_icon_hidden">
+			      <property name="visible">True</property>
+			      <property name="label" translatable="yes">_Hidden</property>
+			      <property name="active">False</property>
+			      <property name="use_underline">True</property>
+			      <property name="group">tag_icon_shown</property>
+			      <signal name="activate" handler="HandleTagSizeChange" last_modification_time="Fri, 20 Aug 2004 22:26:32 GMT"/>
+			    </widget>
+			  </child>
+			</widget>
+		      </child>
+		    </widget>
+		  </child>
+
+		  <child>
+		    <widget class="GtkSeparatorMenuItem" id="separator16">
+		      <property name="visible">True</property>
+		    </widget>
+		  </child>
 
 		  <child>
 		    <widget class="GtkMenuItem" id="arranged_by">


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