Ticket #4307: 0001-ClipboardIcon-API-fixes-for-the-Gtk.Clipboard-set_wi.patch

File 0001-ClipboardIcon-API-fixes-for-the-Gtk.Clipboard-set_wi.patch, 2.3 KB (added by manuq, 11 years ago)

Patch with API fixes for the Gtk.Clipboard set_with_data get_func callback

  • src/jarabe/frame/clipboardicon.py

    From b0e6f8d2202322158f1a23bf54a9ae0924538075 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Tue, 18 Dec 2012 18:09:48 -0300
    Subject: [PATCH toolkit] ClipboardIcon: API fixes for the Gtk.Clipboard
     set_with_data get_func callback - SL #4307
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    - Gtk.SelectionData, selection.get_target() instead of selection.target
    
    - Gtk.TargetEntry, target.target instead of target[0]
    
    - Gtk.TargetEntry.target is a string representation of the target
      type, so to compare them with the selection target, which is a
      Gdk.Atom [1], we need to convert the latter to str like:
      str(selection.get_target())
    
    [1] http://developer.gnome.org/gtk3/stable/gtk3-Selections.html#GtkSelectionData-struct
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     src/jarabe/frame/clipboardicon.py | 11 +++++++----
     1 file changed, 7 insertions(+), 4 deletions(-)
    
    diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py
    index b3fdccc..26af595 100644
    a b class ClipboardIcon(RadioToolButton): 
    9999                self.owns_clipboard = True
    100100
    101101    def _clipboard_data_get_cb(self, x_clipboard, selection, info, targets):
    102         if not selection.target in [target[0] for target in targets]:
     102        selection_target = selection.get_target()
     103        entries_targets = [entry.target for entry in targets]
     104        if not str(selection_target) in entries_targets:
    103105            logging.warning('ClipboardIcon._clipboard_data_get_cb: asked %s' \
    104                             ' but only have %r.', selection.target, targets)
     106                            ' but only have %r.', selection_target,
     107                            entries_targets)
    105108            return
    106         data = self._cb_object.get_formats()[selection.target].get_data()
    107         selection.set(selection.target, 8, data)
     109        data = self._cb_object.get_formats()[str(selection_target)].get_data()
     110        selection.set(selection_target, 8, data)
    108111
    109112    def _clipboard_clear_cb(self, x_clipboard, targets):
    110113        logging.debug('ClipboardIcon._clipboard_clear_cb')