From 3d334e762d45c7cbf7c1890fcc76144cce7dac63 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 | 14 ++++++++++----
src/jarabe/journal/volumestoolbar.py | 2 +-
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/jarabe/journal/listmodel.py b/src/jarabe/journal/listmodel.py
index b98d01c..ad751c5 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 | |
| 241 | # HACK: this is the only way that I found to get the proper 'string value' |
| 242 | # ('text/uri-list' or 'journal-object-id') from 'Gtk.Atom<UTF8_STRING>' |
| 243 | # (selection.get_data()) |
| 244 | str_target = '%s' % selection.get_target() |
| 245 | |
| 246 | if str_target == 'text/uri-list': |
241 | 247 | # Get hold of a reference so the temp file doesn't get deleted |
242 | 248 | self._temp_drag_file_path = model.get_file(uid) |
243 | 249 | logging.debug('putting %r in selection', self._temp_drag_file_path) |
244 | | selection.set(selection.target, 8, self._temp_drag_file_path) |
| 250 | selection.set(selection.get_target(), 8, str(self._temp_drag_file_path)) |
245 | 251 | return True |
246 | | elif selection.target == 'journal-object-id': |
247 | | selection.set(selection.target, 8, uid) |
| 252 | elif str_target == 'journal-object-id': |
| 253 | selection.set(selection.get_target(), 8, str(uid)) |
248 | 254 | return True |
249 | 255 | |
250 | 256 | 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): |