[f-spot] change the dragDropUtils class in a set of extension methods



commit b2f5d79a1d300d7af48a96842d91a65433c98b73
Author: Stephane Delcroix <stephane delcroix org>
Date:   Tue Jun 23 13:06:33 2009 +0200

    change the dragDropUtils class in a set of extension methods
    
    all methods are now extending SelectionData. fix the usage in other places

 src/MainWindow.cs                                  |    6 ++--
 src/Makefile.am                                    |    2 +-
 ...DragDropUtils.cs => SelectionDataExtensions.cs} |   27 +++++++------------
 src/SingleView.cs                                  |    3 +-
 src/TagQueryWidget.cs                              |    2 +-
 src/TagSelectionWidget.cs                          |    6 ++--
 src/Term.cs                                        |    2 +-
 7 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index 61effa1..e046c2d 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -1116,12 +1116,12 @@ public class MainWindow {
 	void HandleIconViewDragDataGet (object sender, DragDataGetArgs args)
 	{	
 		if (args.Info == DragDropTargets.UriListEntry.Info) {
-			DragDropUtils.SetUriListData (new UriList (SelectedPhotos ()), args.SelectionData, args.Context.Targets[0]);
+			args.SelectionData.SetUriListData (new UriList (SelectedPhotos ()), args.Context.Targets[0]);
 			return;
 		}
 		
 		if (args.Info == DragDropTargets.PhotoListEntry.Info) {
-			DragDropUtils.SetPhotosData (SelectedPhotos (), args.SelectionData, args.Context.Targets[0]);
+			args.SelectionData.SetPhotosData (SelectedPhotos (), args.Context.Targets[0]);
 			return;
 		}
 		
@@ -1213,7 +1213,7 @@ public class MainWindow {
 			if (source != null)
 				return;
 
-			UriList list = DragDropUtils.GetUriListData (args.SelectionData); 
+			UriList list = args.SelectionData.GetUriListData (); 
 			ImportUriList (list, (args.Context.Action & Gdk.DragAction.Copy) != 0);
 			
 			Gtk.Drag.Finish (args.Context, true, false, args.Time);
diff --git a/src/Makefile.am b/src/Makefile.am
index 0029405..17276f6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -128,7 +128,6 @@ F_SPOT_CSDISTFILES =				\
 	$(srcdir)/DirectoryAdaptor.cs		\
 	$(srcdir)/DirectoryCollection.cs	\
 	$(srcdir)/DragDropTargets.cs				\
-	$(srcdir)/DragDropUtils.cs				\
 	$(srcdir)/Editors/Editor.cs		\
 	$(srcdir)/Editors/AutoStretchEditor.cs		\
 	$(srcdir)/Editors/CropEditor.cs		\
@@ -227,6 +226,7 @@ F_SPOT_CSDISTFILES =				\
 	$(srcdir)/QueuedSqliteDatabase.cs	\
 	$(srcdir)/RotateCommand.cs		\
 	$(srcdir)/RollStore.cs			\
+	$(srcdir)/SelectionDataExtensions.cs	\
 	$(srcdir)/SendEmail.cs                  \
 	$(srcdir)/SlideView.cs			\
 	$(srcdir)/SingleView.cs			\
diff --git a/src/DragDropUtils.cs b/src/SelectionDataExtensions.cs
similarity index 73%
rename from src/DragDropUtils.cs
rename to src/SelectionDataExtensions.cs
index 0bf2174..fae55cd 100644
--- a/src/DragDropUtils.cs
+++ b/src/SelectionDataExtensions.cs
@@ -1,34 +1,27 @@
 /*
- * DragDropUtils.cs
+ * FSpot.Gui.SelectionDataExtensions.cs
  *
  * Author(s)
  * 	Mike Gemuende <mike gemuende de>
+ *	Stephane Delcroix <stephane delcroix org>
  *
  * This is free software. See COPYING for details.
  */
 
-
-
 using System;
 using System.Text;
 
 using Gtk;
-
 using Gdk;
 
 using FSpot;
 using FSpot.Utils;
 
-
-
-
 namespace FSpot.Gui
 {
-	
-	public static class DragDropUtils
+	public static class SelectionDataExtensions
 	{
-		
-		public static void SetPhotosData (Photo [] photos, SelectionData selection_data, Atom target)
+		public static void SetPhotosData (this SelectionData selection_data, Photo [] photos, Atom target)
 		{
 			byte [] data = new byte [photos.Length * sizeof (uint)];
 			
@@ -45,7 +38,7 @@ namespace FSpot.Gui
 			selection_data.Set (target, 8, data, data.Length);
 		}
 		
-		public static Photo [] GetPhotosData (SelectionData selection_data)
+		public static Photo [] GetPhotosData (this SelectionData selection_data)
 		{
 			int size = sizeof (uint);
 			int length = selection_data.Length / size;
@@ -62,7 +55,7 @@ namespace FSpot.Gui
 			return photos;
 		}
 		
-		public static void SetTagsData (Tag [] tags, SelectionData selection_data, Atom target)
+		public static void SetTagsData (this SelectionData selection_data, Tag [] tags, Atom target)
 		{
 			byte [] data = new byte [tags.Length * sizeof (uint)];
 			
@@ -79,7 +72,7 @@ namespace FSpot.Gui
 			selection_data.Set (target, 8, data, data.Length);
 		}
 		
-		public static Tag [] GetTagsData (SelectionData selection_data)
+		public static Tag [] GetTagsData (this SelectionData selection_data)
 		{
 			int size = sizeof (uint);
 			int length = selection_data.Length / size;
@@ -96,7 +89,7 @@ namespace FSpot.Gui
 			return tags;
 		}
 		
-		public static string GetStringData (SelectionData selection_data)
+		public static string GetStringData (this SelectionData selection_data)
 		{
 			if (selection_data.Length <= 0)
 				return String.Empty;
@@ -108,14 +101,14 @@ namespace FSpot.Gui
 			}
 		}
 		
-		public static void SetUriListData (UriList uri_list, SelectionData selection_data, Atom target)
+		public static void SetUriListData (this SelectionData selection_data, UriList uri_list, Atom target)
 		{
 			Byte [] data = Encoding.UTF8.GetBytes (uri_list.ToString ());
 			
 			selection_data.Set (target, 8, data, data.Length);
 		}
 		
-		public static UriList GetUriListData (SelectionData selection_data)
+		public static UriList GetUriListData (this SelectionData selection_data)
 		{
 			string [] uris = GetStringData (selection_data).Split ('\n');
 			
diff --git a/src/SingleView.cs b/src/SingleView.cs
index 8757e3f..37c249e 100644
--- a/src/SingleView.cs
+++ b/src/SingleView.cs
@@ -9,6 +9,7 @@ using FSpot.Utils;
 using FSpot.UI.Dialog;
 using FSpot.Widgets;
 using FSpot.Platform;
+using FSpot.Gui;
 
 namespace FSpot {
 	public class SingleView {
@@ -476,7 +477,7 @@ namespace FSpot {
 				if (Gtk.Drag.GetSourceWidget (args.Context) != null)
 					return;
 				
-				UriList list = FSpot.Gui.DragDropUtils.GetUriListData (args.SelectionData);
+				UriList list = args.SelectionData.GetUriListData ();
 				collection.LoadItems (list.ToArray());
 				
 				Gtk.Drag.Finish (args.Context, true, false, args.Time);
diff --git a/src/TagQueryWidget.cs b/src/TagQueryWidget.cs
index 86de7c2..c6ebb3a 100644
--- a/src/TagQueryWidget.cs
+++ b/src/TagQueryWidget.cs
@@ -432,7 +432,7 @@ namespace FSpot
 			
 			if (args.Info == DragDropTargets.TagListEntry.Info) {
 
-				InsertTerm (DragDropUtils.GetTagsData (args.SelectionData), rootTerm, null);
+				InsertTerm (args.SelectionData.GetTagsData (), rootTerm, null);
 				return;
 			}
 			
diff --git a/src/TagSelectionWidget.cs b/src/TagSelectionWidget.cs
index fd21d27..dc8091c 100644
--- a/src/TagSelectionWidget.cs
+++ b/src/TagSelectionWidget.cs
@@ -630,7 +630,7 @@ namespace FSpot.Gui {
 		void HandleDragDataGet (object sender, DragDataGetArgs args)
 		{
 			if (args.Info == DragDropTargets.TagListEntry.Info) {
-				DragDropUtils.SetTagsData (TagHighlight, args.SelectionData, args.Context.Targets[0]);
+				args.SelectionData.SetTagsData (TagHighlight, args.Context.Targets[0]);
 				return;
 			}
 		}
@@ -684,7 +684,7 @@ namespace FSpot.Gui {
 			if (args.Info == DragDropTargets.PhotoListEntry.Info) {
 				database.BeginTransaction ();
 				
-				Photo[] photos = DragDropUtils.GetPhotosData (args.SelectionData);
+				Photo[] photos = args.SelectionData.GetPhotosData ();
 
 				foreach (Photo photo in photos) {
 
@@ -705,7 +705,7 @@ namespace FSpot.Gui {
 			}
 			
 			if (args.Info == DragDropTargets.UriListEntry.Info) {
-				UriList list = DragDropUtils.GetUriListData (args.SelectionData);
+				UriList list = args.SelectionData.GetUriListData ();
 				
 				database.BeginTransaction ();
 				List<Photo> photos = new List<Photo> ();
diff --git a/src/Term.cs b/src/Term.cs
index be9194e..8c9c5f2 100644
--- a/src/Term.cs
+++ b/src/Term.cs
@@ -815,7 +815,7 @@ namespace FSpot {
 			if (args.Info == DragDropTargets.TagListEntry.Info) {
 
 				if (TagsAdded != null)
-					TagsAdded (DragDropUtils.GetTagsData (args.SelectionData), Parent, this);
+					TagsAdded (args.SelectionData.GetTagsData (), Parent, this);
 				
 				return;
 			}



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