[f-spot] - added usage of DragDrop-classes to SingleView
- From: Stephane Delcroix <sdelcroix src gnome org>
- To: svn-commits-list gnome org
- Subject: [f-spot] - added usage of DragDrop-classes to SingleView
- Date: Tue, 23 Jun 2009 07:35:51 -0400 (EDT)
commit e33c5a93b39e0827b121f76de922c524d0d7359c
Author: Mike Gemuende <mike gemuende de>
Date: Mon Jun 22 16:56:12 2009 +0200
- added usage of DragDrop-classes to SingleView
- small fixups
src/DragDropTargets.cs | 4 ++++
src/MainWindow.cs | 2 +-
src/SingleView.cs | 37 +++++++++++++++++++------------------
src/Util.cs | 41 +++++------------------------------------
4 files changed, 29 insertions(+), 55 deletions(-)
---
diff --git a/src/DragDropTargets.cs b/src/DragDropTargets.cs
index e0f1a44..e158e7d 100644
--- a/src/DragDropTargets.cs
+++ b/src/DragDropTargets.cs
@@ -19,6 +19,7 @@ namespace FSpot.Gui
public static class DragDropTargets
{
public enum TargetType {
+ PlainText,
UriList,
TagList,
TagQueryItem,
@@ -27,6 +28,9 @@ namespace FSpot.Gui
RootWindow
};
+ public static readonly TargetEntry PlainTextEntry =
+ new TargetEntry ("text/plain", 0, (uint) TargetType.PhotoList);
+
public static readonly TargetEntry PhotoListEntry =
new TargetEntry ("application/x-fspot-photos", 0, (uint) TargetType.PhotoList);
diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index ad5bd00..61effa1 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -1213,7 +1213,7 @@ public class MainWindow {
if (source != null)
return;
- UriList list = new UriList (args.SelectionData);
+ UriList list = DragDropUtils.GetUriListData (args.SelectionData);
ImportUriList (list, (args.Context.Action & Gdk.DragAction.Copy) != 0);
Gtk.Drag.Finish (args.Context, true, false, args.Time);
diff --git a/src/SingleView.cs b/src/SingleView.cs
index 9ba6eef..8757e3f 100644
--- a/src/SingleView.cs
+++ b/src/SingleView.cs
@@ -107,8 +107,10 @@ namespace FSpot {
collection = new UriCollection (uris);
- TargetEntry [] dest_table = { new TargetEntry ("text/uri-list", 0, 0),
- new TargetEntry ("text/plain", 0, 1)};
+ TargetEntry [] dest_table = {
+ FSpot.Gui.DragDropTargets.UriListEntry,
+ FSpot.Gui.DragDropTargets.PlainTextEntry
+ };
directory_view = new FSpot.Widgets.IconView (collection);
directory_view.Selection.Changed += HandleSelectionChanged;
@@ -465,23 +467,22 @@ namespace FSpot {
void HandleDragDataReceived (object sender, DragDataReceivedArgs args)
{
-
- switch (args.Info) {
- case 0:
- case 1:
- /*
- * If the drop is coming from inside f-spot then we don't want to import
- */
- if (Gtk.Drag.GetSourceWidget (args.Context) != null)
+ if (args.Info == FSpot.Gui.DragDropTargets.UriListEntry.Info
+ || args.Info == FSpot.Gui.DragDropTargets.PlainTextEntry.Info) {
+
+ /*
+ * If the drop is coming from inside f-spot then we don't want to import
+ */
+ if (Gtk.Drag.GetSourceWidget (args.Context) != null)
+ return;
+
+ UriList list = FSpot.Gui.DragDropUtils.GetUriListData (args.SelectionData);
+ collection.LoadItems (list.ToArray());
+
+ Gtk.Drag.Finish (args.Context, true, false, args.Time);
+
return;
-
- UriList list = new UriList (args.SelectionData);
- collection.LoadItems (list.ToArray());
-
- break;
- }
-
- Gtk.Drag.Finish (args.Context, true, false, args.Time);
+ }
}
private void UpdateStatusLabel ()
diff --git a/src/Util.cs b/src/Util.cs
index d64cd6e..9cfdb87 100644
--- a/src/Util.cs
+++ b/src/Util.cs
@@ -35,9 +35,8 @@ namespace FSpot.Utils
{
}
- private void LoadFromString (string data) {
+ private void LoadFromStrings (string [] items) {
//string [] items = System.Text.RegularExpressions.Regex.Split ("\n", data);
- string [] items = data.Split ('\n');
foreach (String i in items) {
if (!i.StartsWith ("#")) {
@@ -94,49 +93,19 @@ namespace FSpot.Utils
public UriList (string data)
{
- LoadFromString (data);
+ LoadFromStrings (data.Split ('\n'));
}
public UriList (string [] uris)
{
- foreach (String i in uris) {
- if (!i.StartsWith ("#")) {
- Uri uri;
- String s = i;
-
- if (i.EndsWith ("\r")) {
- s = i.Substring (0, i.Length - 1);
- Console.WriteLine ("uri = {0}", s);
- }
-
- try {
- uri = new Uri (s);
- } catch {
-#if true //Workaround to bgo 362016 in gnome-screenshot. Remove this hack when gnome 2.6.18 is widely distributed.
- if (System.Text.RegularExpressions.Regex.IsMatch (s, "^file:/[^/]")) {
- try {
- s = "file:///" + s.Substring(6);
- uri = new Uri (s);
- Console.WriteLine ("Converted uri from file:/ to >>{0}<<", s);
- } catch {
- continue;
- }
- } else
- continue;
-#else
- continue;
-#endif
- }
- Add (uri);
- }
- }
+ LoadFromStrings (uris);
}
- public UriList (Gtk.SelectionData selection)
+ /*public UriList (Gtk.SelectionData selection)
{
// FIXME this should check the atom etc.
LoadFromString (System.Text.Encoding.UTF8.GetString (selection.Data));
- }
+ }*/
public new Uri [] ToArray ()
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]