[postr] Allow image list to be re-ordered using D&D (#601536)
- From: Germán Poó Caamaño <gpoo src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [postr] Allow image list to be re-ordered using D&D (#601536)
- Date: Wed, 11 Nov 2009 16:59:26 +0000 (UTC)
commit 130b9f5eb2187e3249a3a550f6c62b1dae746bc6
Author: Francisco Rojas <frojas alumnos utalca cl>
Date: Wed Nov 11 13:28:59 2009 -0300
Allow image list to be re-ordered using D&D (#601536)
Allows the user organize the photo list, once the images are in
the list through the use of Drag and Drop.
Signed-off-by: Germán Póo-Caamaño <gpoo gnome org>
src/ImageList.py | 17 ++++++++++++-----
src/postr.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 58 insertions(+), 6 deletions(-)
---
diff --git a/src/ImageList.py b/src/ImageList.py
index d5334ae..c1706c0 100644
--- a/src/ImageList.py
+++ b/src/ImageList.py
@@ -48,11 +48,18 @@ class ImageList(gtk.TreeView):
selection.set_mode(gtk.SELECTION_MULTIPLE)
# Setup the drag and drop
- self.drag_dest_set (gtk.DEST_DEFAULT_ALL, (), gtk.gdk.ACTION_COPY)
- targets = self.drag_dest_get_target_list()
- targets = gtk.target_list_add_image_targets (targets, DRAG_IMAGE, False)
- targets = gtk.target_list_add_uri_targets (targets, DRAG_URI)
- self.drag_dest_set_target_list (targets)
+ self.targets = self.drag_dest_get_target_list()
+ self.targets = gtk.target_list_add_image_targets (self.targets, DRAG_IMAGE, False)
+ self.targets = gtk.target_list_add_uri_targets (self.targets, DRAG_URI)
+ self.drag_dest_set (gtk.DEST_DEFAULT_ALL, self.targets, gtk.gdk.ACTION_COPY)
+
+ def enable_targets(self):
+ """Enable the drag and drop destination. """
+ self.drag_dest_set(gtk.DEST_DEFAULT_ALL, self.targets, gtk.gdk.ACTION_COPY)
+
+ def unable_targets(self):
+ """Unable the drag and drop destination. """
+ self.drag_dest_unset()
def data_func(self, column, cell, model, it):
from xml.sax.saxutils import escape
diff --git a/src/postr.py b/src/postr.py
index 6fce813..fdbe5ff 100644
--- a/src/postr.py
+++ b/src/postr.py
@@ -115,16 +115,30 @@ class Postr(UniqueApp):
self.model.connect("row-deleted", self.on_model_changed)
self.thumbview.set_model(self.model)
- self.thumbview.connect("drag_data_received", self.on_drag_data_received)
self.set_combo.connect("changed", self.on_set_combo_changed)
selection = self.thumbview.get_selection()
selection.connect("changed", self.on_selection_changed)
+ self.drag_signals = []
+ self.drag_signals.append((self.thumbview, self.thumbview.connect(
+ "drag_data_received", self.on_drag_data_received)))
+
self.thumbview.connect("row-activated",
self.on_row_activated,
self.title_entry)
+
+ self.drop_disabled = False
+ self.drag_started = False
+
+ self.thumbview.connect("button_press_event",
+ self.on_button_press_cb)
+ self.thumbview.connect("button_release_event",
+ self.on_button_release_cb)
+ self.thumbview.connect("drag_begin", self.drag_begin_cb)
+ self.thumbview.connect("drag_end", self.drag_end_cb)
+
if has_gtkspell:
gtkspell.Spell(self.desc_view)
@@ -941,6 +955,37 @@ class Postr(UniqueApp):
one row is activated."""
entry.grab_focus()
+ def drag_begin_cb(self, thumbview, context, data=None):
+ self.drag_started = True
+
+ def drag_end_cb(self, thumbview, context, data=None):
+ self.drop_disabled = False
+ self.drag_started = False
+ self.thumbview.set_reorderable(False)
+
+ self.thumbview.enable_targets()
+ [obj.handler_unblock(i) for obj,i in self.drag_signals]
+
+ def on_button_press_cb(self, thumbview, event, data=None):
+ if self.drop_disabled:
+ return
+ self.thumbview.unable_targets()
+
+ self.drop_disabled = True
+ [obj.handler_block(i) for obj,i in self.drag_signals]
+ thumbview.set_reorderable(True)
+ return
+
+ def on_button_release_cb(self, thumbview, event, data=None):
+
+ if self.drop_disabled and (not self.drag_started):
+ self.drop_disabled = False
+ thumbview.set_reorderable(False)
+ self.thumbview.enable_targets()
+ [obj.handler_unblock(i) for obj,i in self.drag_signals]
+ return False
+
+
def save_upload_set(self):
dialog = gtk.FileChooserDialog(title=None,
action=gtk.FILE_CHOOSER_ACTION_SAVE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]