f-spot r4105 - in trunk: . src src/Core src/Widgets



Author: sdelcroix
Date: Thu Jun 26 14:04:55 2008
New Revision: 4105
URL: http://svn.gnome.org/viewvc/f-spot?rev=4105&view=rev

Log:
2008-06-26  Stephane Delcroix  <sdelcroix novell com>

	* Core/BrowsableEventArgs.cs:
	* Core/IBrowsableCollection.cs:
	* MainWindow.cs:
	* Makefile.am:
	* PhotoView.cs:
	* Widgets/IconView.cs: Share the DoubleClick Handler between modes. Don't
	catch button press events on scollbars. Fixes bgo #419087.


Added:
   trunk/src/Core/BrowsableEventArgs.cs
Modified:
   trunk/ChangeLog
   trunk/src/Core/IBrowsableCollection.cs
   trunk/src/MainWindow.cs
   trunk/src/Makefile.am
   trunk/src/PhotoView.cs
   trunk/src/Widgets/IconView.cs

Added: trunk/src/Core/BrowsableEventArgs.cs
==============================================================================
--- (empty file)
+++ trunk/src/Core/BrowsableEventArgs.cs	Thu Jun 26 14:04:55 2008
@@ -0,0 +1,29 @@
+/*
+ * FSpot.BrowsableEventArgs.cs
+ * 
+ * Author(s):
+ *	Larry Ewing <lewing novell com>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+namespace FSpot
+{
+	public class BrowsableEventArgs : System.EventArgs {
+		int [] items;
+
+		public int [] Items {
+			get { return items; }
+		}
+
+		public BrowsableEventArgs (int num)
+		{
+			items = new int [] { num };
+		}
+
+		public BrowsableEventArgs (int [] items)
+		{
+			this.items = items;
+		}
+	}
+}

Modified: trunk/src/Core/IBrowsableCollection.cs
==============================================================================
--- trunk/src/Core/IBrowsableCollection.cs	(original)
+++ trunk/src/Core/IBrowsableCollection.cs	Thu Jun 26 14:04:55 2008
@@ -12,24 +12,6 @@
 	public delegate void IBrowsableCollectionChangedHandler (IBrowsableCollection collection);
 	public delegate void IBrowsableCollectionItemsChangedHandler (IBrowsableCollection collection, BrowsableEventArgs args);
 
-	public class BrowsableEventArgs : System.EventArgs {
-		int [] items;
-
-		public int [] Items {
-			get { return items; }
-		}
-
-		public BrowsableEventArgs (int num)
-		{
-			items = new int [] { num };
-		}
-
-		public BrowsableEventArgs (int [] items)
-		{
-			this.items = items;
-		}
-	}
-
 	public interface IBrowsableCollection {
 		// FIXME this should really be ToArray ()
 		IBrowsableItem [] Items {

Modified: trunk/src/MainWindow.cs
==============================================================================
--- trunk/src/MainWindow.cs	(original)
+++ trunk/src/MainWindow.cs	Thu Jun 26 14:04:55 2008
@@ -420,7 +420,7 @@
 		photo_view = new PhotoView (query);
 		photo_box.Add (photo_view);
 
-		photo_view.ButtonPressEvent += HandlePhotoViewButtonPressEvent;
+		photo_view.DoubleClicked += HandleDoubleClicked;
 		photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
 		photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
 		photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;
@@ -1360,10 +1360,17 @@
 	// IconView event handlers
 	// 
 
-	void HandleDoubleClicked (FSpot.Widgets.IconView icon_view, int clicked_item)
+	void HandleDoubleClicked (Widget widget, BrowsableEventArgs args)
 	{
-		icon_view.FocusCell = clicked_item;
-		SetViewMode (ModeType.PhotoView);
+		switch (ViewMode) {
+		case ModeType.IconView:
+			icon_view.FocusCell = args.Items[0];
+			SetViewMode (ModeType.PhotoView);
+			break;
+		case ModeType.PhotoView:
+			SetViewMode (ModeType.IconView);
+			break;
+		}
 	}
 
 	//
@@ -1434,12 +1441,6 @@
 		return;
 	}
 
-	void HandlePhotoViewButtonPressEvent (object sender, Gtk.ButtonPressEventArgs args)
-	{
-		if (args.Event.Type == EventType.TwoButtonPress && args.Event.Button == 1)
-			SetViewMode (ModeType.IconView);
-	}
-
 	void HandlePhotoViewUpdateStarted (PhotoView sender)
 	{
 		main_window.GdkWindow.Cursor = new Gdk.Cursor (Gdk.CursorType.Watch);

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Thu Jun 26 14:04:55 2008
@@ -19,6 +19,7 @@
 
 CORE_CSDISTFILES =				\
 	$(srcdir)/Core/Animator.cs		\
+	$(srcdir)/Core/BrowsableEventArgs.cs	\
 	$(srcdir)/Core/BrowsablePointer.cs	\
 	$(srcdir)/Core/Category.cs		\
 	$(srcdir)/Core/DbItem.cs		\

Modified: trunk/src/PhotoView.cs
==============================================================================
--- trunk/src/PhotoView.cs	(original)
+++ trunk/src/PhotoView.cs	Thu Jun 26 14:04:55 2008
@@ -62,6 +62,9 @@
 	
 		public delegate void UpdateFinishedHandler (PhotoView view);
 		public event UpdateFinishedHandler UpdateFinished;
+
+		public delegate void DoubleClickedHandler (Widget widget, BrowsableEventArgs args);
+		public event DoubleClickedHandler DoubleClicked;
 	
 		public enum ConstraintType {
 			Normal,
@@ -221,6 +224,8 @@
 		// Event handlers.
 		private void HandleButtonPressEvent (object sender, ButtonPressEventArgs args)
 		{
+			if (args.Event.Type == EventType.TwoButtonPress && args.Event.Button == 1 && DoubleClicked != null)
+				DoubleClicked (this, null);
 			if (args.Event.Type == EventType.ButtonPress
 			    && args.Event.Button == 3) {
 				PhotoPopup popup = new PhotoPopup ();
@@ -478,11 +483,11 @@
 			photo_view.SelectionChanged += HandleSelectionChanged;
 	
 			photo_view_scrolled = new ScrolledWindow (null, null);
-	
+
 			photo_view_scrolled.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
 			photo_view_scrolled.ShadowType = ShadowType.None;
 			photo_view_scrolled.Add (photo_view);
-			photo_view_scrolled.ButtonPressEvent += HandleButtonPressEvent;
+			photo_view_scrolled.Child.ButtonPressEvent += HandleButtonPressEvent;
 			photo_view.AddEvents ((int) EventMask.KeyPressMask);
 			inner_vbox.PackStart (photo_view_scrolled, true, true, 0);
 			

Modified: trunk/src/Widgets/IconView.cs
==============================================================================
--- trunk/src/Widgets/IconView.cs	(original)
+++ trunk/src/Widgets/IconView.cs	Thu Jun 26 14:04:55 2008
@@ -194,7 +194,7 @@
 		private int click_count;
 
 		// Public events.
-		public delegate void DoubleClickedHandler (IconView view, int clicked_item);
+		public delegate void DoubleClickedHandler (Widget widget, BrowsableEventArgs args);
 		public event DoubleClickedHandler DoubleClicked;
 
 		public delegate void ZoomChangedHandler (object sender, System.EventArgs args);
@@ -1427,7 +1427,7 @@
 				| ModifierType.ShiftMask)) != 0)
 				return;
 				if (DoubleClicked != null)
-					DoubleClicked (this, cell_num);
+					DoubleClicked (this, new BrowsableEventArgs (cell_num));
 				return;
 
 			case EventType.ButtonPress:
@@ -1544,7 +1544,7 @@
 			case Gdk.Key.Return:
 				if (DoubleClicked == null)
 					break;
-				DoubleClicked (this, FocusCell);
+				DoubleClicked (this, new BrowsableEventArgs (FocusCell));
 				break;
 			default:
 				args.RetVal = false;



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