From 5dcca8043844b5be533b63cc1a6225b57d7f950e Mon Sep 17 00:00:00 2001
From: Manuel Kaufmann <humitos@gmail.com>
Date: Thu, 21 Feb 2013 10:21:58 -0300
Subject: [PATCH sugar] Port Journal's Drag N Drop to Gtk3 SL #3999
This commit needs this gtk+ PATCH to work:
* https://bugzilla.gnome.org/show_bug.cgi?id=692844
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
---
src/jarabe/journal/listmodel.py | 18 ++++++++++++++----
src/jarabe/journal/volumestoolbar.py | 2 +-
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/jarabe/journal/listmodel.py b/src/jarabe/journal/listmodel.py
index b98d01c..40134d3 100644
a
|
b
|
class ListModel(GObject.GObject, Gtk.TreeModel, Gtk.TreeDragSource): |
237 | 237 | |
238 | 238 | def do_drag_data_get(self, path, selection): |
239 | 239 | uid = self[path][ListModel.COLUMN_UID] |
240 | | if selection.target == 'text/uri-list': |
| 240 | if selection.get_target() == 'text/uri-list': |
241 | 241 | # Get hold of a reference so the temp file doesn't get deleted |
242 | 242 | self._temp_drag_file_path = model.get_file(uid) |
243 | 243 | logging.debug('putting %r in selection', self._temp_drag_file_path) |
244 | | selection.set(selection.target, 8, self._temp_drag_file_path) |
| 244 | selection.set(selection.get_target(), 8, self._temp_drag_file_path) |
245 | 245 | return True |
246 | | elif selection.target == 'journal-object-id': |
247 | | selection.set(selection.target, 8, uid) |
| 246 | elif selection.get_target() == 'journal-object-id': |
| 247 | selection.set(selection.get_target(), 8, uid) |
| 248 | return True |
| 249 | else: |
| 250 | # README: I wasn't able to get the proper string |
| 251 | # ('text/uri-list' or |
| 252 | # 'journal-object-id'). 'selection.get_target()' returns a |
| 253 | # 'Gdk.Atom<UTF8_STRING>' from where I couldn't get the |
| 254 | # proper target's type |
| 255 | |
| 256 | # NOTE: third argument should be a simple string (not UNICODE) |
| 257 | selection.set(selection.get_target(), 8, str(uid)) |
248 | 258 | return True |
249 | 259 | |
250 | 260 | return False |
diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py
index e1e6331..750aea5 100644
a
|
b
|
class BaseButton(RadioToolButton): |
291 | 291 | |
292 | 292 | def _drag_data_received_cb(self, widget, drag_context, x, y, |
293 | 293 | selection_data, info, timestamp): |
294 | | object_id = selection_data.data |
| 294 | object_id = selection_data.get_data() |
295 | 295 | metadata = model.get(object_id) |
296 | 296 | file_path = model.get_file(metadata['uid']) |
297 | 297 | if not file_path or not os.path.exists(file_path): |