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

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

v3 - improved commit message and fixed some typos in the source comment

  • src/jarabe/journal/listmodel.py

    From c7ad0bedbe8af4753db5bb80953272affeca81b7 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
    
    Changed some method names to the new API:
    
     * Gtk.SelectionData.target -> Gtk.SelectionData.get_target()
    
       I had to write a HACK here because Gdk.Atom<UT8_STRING> (returned
       by .get_target()) does not represent the proper string value
       ('text/uri-list' or 'journal-object-id'), instead of that it
       returns 'UTF8_STRING'. So, I formatted a simple empty string
       ('%s' % Gtk.SelectionData.get_target()) to get the proper value.
    
     * Gtk.SelectionData.data -> Gtk.SelectionData.get_data()
    
    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      | 16 ++++++++++++----
     src/jarabe/journal/volumestoolbar.py |  2 +-
     2 files changed, 13 insertions(+), 5 deletions(-)
    
    diff --git a/src/jarabe/journal/listmodel.py b/src/jarabe/journal/listmodel.py
    index b98d01c..fb25b37 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        # FIXME: there is no other way to get this value
     242        # ('text/uri-list' or 'journal-object-id') from
     243        # 'Gdk.Atom<UTF8_STRING>' (selection.get_target()) from Python
     244        # through introspection currently
     245        str_target = '%s' % selection.get_target()
     246
     247        if str_target == 'text/uri-list':
    241248            # Get hold of a reference so the temp file doesn't get deleted
    242249            self._temp_drag_file_path = model.get_file(uid)
    243250            logging.debug('putting %r in selection', self._temp_drag_file_path)
    244             selection.set(selection.target, 8, self._temp_drag_file_path)
     251            selection.set(selection.get_target(), 8,
     252                          str(self._temp_drag_file_path))
    245253            return True
    246         elif selection.target == 'journal-object-id':
    247             selection.set(selection.target, 8, uid)
     254        elif str_target == 'journal-object-id':
     255            selection.set(selection.get_target(), 8, str(uid))
    248256            return True
    249257
    250258        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):