Ticket #3999: 0001-Port-Journal-s-Drag-N-Drop-to-Gtk3-SL-3999.2.patch

File 0001-Port-Journal-s-Drag-N-Drop-to-Gtk3-SL-3999.2.patch, 2.5 KB (added by humitos, 11 years ago)

v2 - includes a HACK to get the proper value of a Gdk.Atom<UTF8_STRING>

  • src/jarabe/journal/listmodel.py

    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): 
    237237
    238238    def do_drag_data_get(self, path, selection):
    239239        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':
    241247            # Get hold of a reference so the temp file doesn't get deleted
    242248            self._temp_drag_file_path = model.get_file(uid)
    243249            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))
    245251            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))
    248254            return True
    249255
    250256        return False
  • src/jarabe/journal/volumestoolbar.py

    diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py
    index e1e6331..750aea5 100644
    a b class BaseButton(RadioToolButton): 
    291291
    292292    def _drag_data_received_cb(self, widget, drag_context, x, y,
    293293                               selection_data, info, timestamp):
    294         object_id = selection_data.data
     294        object_id = selection_data.get_data()
    295295        metadata = model.get(object_id)
    296296        file_path = model.get_file(metadata['uid'])
    297297        if not file_path or not os.path.exists(file_path):