File ellipsize.patch of Package f-spot

From bfc9c8925a7d34560e1669040dbf5e15076bb6fc Mon Sep 17 00:00:00 2001
From: sdelcroix <sdelcroix@772769d8-d925-0410-89eb-a6ffa0d40526>
Date: Sun, 23 Nov 2008 12:20:34 +0000
Subject: [PATCH] 2008-09-25  Stephane Delcroix  <sdelcroix@novell.com>

	* src/PhotoVersionMenu.cs: no longer Ellipsize items
	* src/InfoBox.cs: replace the OptionMenu by a ComboBox, Ellipsize the text.

git-svn-id: svn+ssh://svn.gnome.org/svn/f-spot/branches/FSPOT_0_5_0_STABLE@4611 772769d8-d925-0410-89eb-a6ffa0d40526
---
 ChangeLog               |    5 +++
 src/PhotoVersionMenu.cs |    2 -
 src/Widgets/InfoBox.cs  |   64 ++++++++++++++++++++++++++++++-----------------
 3 files changed, 46 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1e62445..6bb4c95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-25  Stephane Delcroix  <sdelcroix@novell.com>
+
+	* src/PhotoVersionMenu.cs: no longer Ellipsize items
+	* src/InfoBox.cs: replace the OptionMenu by a ComboBox, Ellipsize the text.
+
 2008-11-18  Stephane Delcroix  <sdelcroix@novell.com>
 
 	* src/UI.Dialog/PreferenceDialog.cs: handle the case where the 
diff --git a/src/PhotoVersionMenu.cs b/src/PhotoVersionMenu.cs
index 5930125..7c7d734 100644
--- a/src/PhotoVersionMenu.cs
+++ b/src/PhotoVersionMenu.cs
@@ -56,7 +56,6 @@ public class PhotoVersionMenu : Menu {
 			menu_item.Show ();
 			menu_item.Sensitive = true;
 			((Gtk.Label)menu_item.Child).UseUnderline = false;
-			((Gtk.Label)menu_item.Child).Ellipsize = Pango.EllipsizeMode.End;
 			menu_item.Activated += new EventHandler (HandleMenuItemActivated);
 
 			item_infos [i ++] = new MenuItemInfo (menu_item, id);
@@ -68,7 +67,6 @@ public class PhotoVersionMenu : Menu {
 			MenuItem no_edits_menu_item = new MenuItem (Mono.Unix.Catalog.GetString ("(No Edits)"));
 			no_edits_menu_item.Show ();
 			no_edits_menu_item.Sensitive = false;
-			((Gtk.Label)no_edits_menu_item.Child).Ellipsize = Pango.EllipsizeMode.End;
 			Append (no_edits_menu_item);
 		}
 	}
diff --git a/src/Widgets/InfoBox.cs b/src/Widgets/InfoBox.cs
index 5c61322..767185a 100644
--- a/src/Widgets/InfoBox.cs
+++ b/src/Widgets/InfoBox.cs
@@ -103,7 +103,8 @@ namespace FSpot.Widgets
 		private Label name_value_label;
 
 		private Label version_label;
-		private OptionMenu version_option_menu;
+		private ListStore version_list;
+		private ComboBox version_combo;
 
 		private Label date_label;
 		private Label date_value_label;
@@ -120,12 +121,6 @@ namespace FSpot.Widgets
 		private TagView tag_view;
 		private string default_exposure_string;
 
-		private void HandleVersionIdChanged (PhotoVersionMenu menu)
-		{
-			if (VersionIdChanged != null)
-				VersionIdChanged (this, menu.VersionId);
-		}
-	
 		private void HandleRatingChanged (object o, EventArgs e)
 		{
 			MainWindow.Toplevel.HandleRatingMenuSelected ((o as Widgets.Rating).Value);
@@ -220,9 +215,16 @@ namespace FSpot.Widgets
 			date_value_label = AttachLabel (info_table, 2, name_value_label);
 			size_value_label = AttachLabel (info_table, 3, name_value_label);
 			exposure_value_label = AttachLabel (info_table, 4, name_value_label);
-	
-			version_option_menu = new OptionMenu ();
-			info_table.Attach (version_option_menu, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
+			
+			version_list = new ListStore (typeof (uint), typeof (string));
+			version_combo = new ComboBox ();
+			CellRendererText version_name_cell = new CellRendererText ();
+			version_name_cell.Ellipsize = Pango.EllipsizeMode.End;
+			version_combo.PackStart (version_name_cell, true);
+			version_combo.SetCellDataFunc (version_name_cell, new CellLayoutDataFunc (VersionNameCellFunc));
+			version_combo.Model = version_list;
+			version_combo.Changed += OnVersionComboChanged;
+			info_table.Attach (version_combo, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
 	
 			date_value_label.Text = Environment.NewLine;
 			exposure_value_label.Text = Environment.NewLine;
@@ -435,21 +437,18 @@ namespace FSpot.Widgets
 			
 	
 			version_label.Visible = true;
-			version_option_menu.Visible = true;
-			PhotoVersionMenu menu = new PhotoVersionMenu (photo);
-			menu.VersionIdChanged += new PhotoVersionMenu.VersionIdChangedHandler (HandleVersionIdChanged);
-			menu.WidthRequest = version_option_menu.Allocation.Width;
-			version_option_menu.Menu = menu;
-			
-			uint i = 0;
+			version_combo.Visible = true;
+			version_list.Clear ();
+			version_combo.Changed -= OnVersionComboChanged;
+			int i = 0;
 			foreach (uint version_id in photo.VersionIds) {
-				if (version_id == photo.DefaultVersionId) {
-					// FIXME GTK# why not just .History = i ?
-					version_option_menu.SetHistory (i);
-					break;
-				}
+				version_list.AppendValues (version_id, (photo.GetVersion (version_id) as PhotoVersion).Name);
+				if (version_id == photo.DefaultVersionId)
+					version_combo.Active = i;
 				i++;
 			}
+			version_combo.Changed += OnVersionComboChanged;
+
 			if (show_tags)
 				tag_view.Current = photo;
 			rating_label.Visible = show_rating;
@@ -461,6 +460,25 @@ namespace FSpot.Widgets
 			Show ();
 		}
 
+		void VersionNameCellFunc (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
+		{
+			string name = (string)tree_model.GetValue (iter, 1);
+			(cell as CellRendererText).Text = name;
+		}
+
+
+		void OnVersionComboChanged (object o, EventArgs e)
+		{
+			ComboBox combo = o as ComboBox;
+			if (combo == null)
+				return;
+
+			TreeIter iter;
+
+			if (combo.GetActiveIter (out iter))
+				VersionIdChanged (this, (uint)version_list.GetValue (iter, 0));
+		}
+
 		private void UpdateMultiple ()
 		{
 			histogram_expander.Visible = false;
@@ -469,7 +487,7 @@ namespace FSpot.Widgets
 			name_value_label.Text = String.Format(Catalog.GetString("{0} Photos"), Photos.Length);
 
 			version_label.Visible = false;
-			version_option_menu.Visible = false;
+			version_combo.Visible = false;
 
 			exposure_label.Visible = false;
 			exposure_value_label.Visible = false;
-- 
1.6.0.2

openSUSE Build Service is sponsored by