Ticket #3903: 0001-Update-clipboard-code-in-sugar-to-fix-visual-represe.patch

File 0001-Update-clipboard-code-in-sugar-to-fix-visual-represe.patch, 7.4 KB (added by godiard, 8 years ago)

Updated version of sugar patch based in the backported pygobject patches

  • src/jarabe/frame/clipboard.py

    From 296d216e88b2fbe4bacba407805a80af8427298e Mon Sep 17 00:00:00 2001
    From: Gonzalo Odiard <godiard@gmail.com>
    Date: Fri, 23 Nov 2012 18:06:49 -0300
    Subject: [PATCH] Update clipboard code in sugar to fix visual representation
     - SL #3903
    
    This patch fixes part of the porting issues, based in the fixes in [1]
    and need these changes backported to the stable pygobject branch.
    The pending issues are related with upstream ticket [2]
    
    [1] https://bugzilla.gnome.org/show_bug.cgi?id=678620
        http://git.gnome.org/browse/pygobject/commit/?id=671361841de797ef
        http://git.gnome.org/browse/pygobject/commit/?id=55070cc
    [2] https://bugzilla.gnome.org/show_bug.cgi?id=656312
    
    Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
    ---
     src/jarabe/frame/clipboard.py            |  3 ++-
     src/jarabe/frame/clipboardicon.py        |  5 +++--
     src/jarabe/frame/clipboardobject.py      |  3 +--
     src/jarabe/frame/clipboardpanelwindow.py | 27 +++++++++++++++------------
     src/jarabe/journal/palettes.py           |  3 ++-
     5 files changed, 23 insertions(+), 18 deletions(-)
    
    diff --git a/src/jarabe/frame/clipboard.py b/src/jarabe/frame/clipboard.py
    index 493a9ce..7305360 100644
    a b import tempfile 
    2222
    2323from gi.repository import GObject
    2424from gi.repository import Gtk
     25from gi.repository import Gdk
    2526
    2627from sugar3 import mime
    2728
    class Clipboard(GObject.GObject): 
    99100        cb_object = self._objects.pop(object_id)
    100101        cb_object.destroy()
    101102        if not self._objects:
    102             gtk_clipboard = Gtk.Clipboard()
     103            gtk_clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
    103104            gtk_clipboard.clear()
    104105        self.emit('object-deleted', object_id)
    105106        logging.debug('Deleted object with object_id %r', object_id)
  • src/jarabe/frame/clipboardicon.py

    diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py
    index 81b3131..b3fdccc 100644
    a b class ClipboardIcon(RadioToolButton): 
    8989
    9090        targets = self._get_targets()
    9191        if targets:
    92             x_clipboard = Gtk.Clipboard()
     92            x_clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
    9393            if not x_clipboard.set_with_data(targets,
    9494                                           self._clipboard_data_get_cb,
    9595                                           self._clipboard_clear_cb,
    class ClipboardIcon(RadioToolButton): 
    170170    def _get_targets(self):
    171171        targets = []
    172172        for format_type in self._cb_object.get_formats().keys():
    173             targets.append((format_type, 0, 0))
     173            targets.append(Gtk.TargetEntry.new(format_type,
     174                    Gtk.TargetFlags.SAME_APP, 0))
    174175        return targets
  • src/jarabe/frame/clipboardobject.py

    diff --git a/src/jarabe/frame/clipboardobject.py b/src/jarabe/frame/clipboardobject.py
    index a91c672..e79fa46 100644
    a b class ClipboardObject(object): 
    8383        if not self._formats:
    8484            return False
    8585        else:
    86             return self._formats.keys()[0] in [ActivityBundle.MIME_TYPE,
    87                     ActivityBundle.DEPRECATED_MIME_TYPE]
     86            return self._formats.keys()[0] == ActivityBundle.MIME_TYPE
    8887
    8988    def get_percent(self):
    9089        return self._percent
  • src/jarabe/frame/clipboardpanelwindow.py

    diff --git a/src/jarabe/frame/clipboardpanelwindow.py b/src/jarabe/frame/clipboardpanelwindow.py
    index fed6ba1..ba86775 100644
    a b from urlparse import urlparse 
    1919import hashlib
    2020
    2121from gi.repository import Gtk
     22from gi.repository import Gdk
    2223
    2324from jarabe.frame.framewindow import FrameWindow
    2425from jarabe.frame.clipboardtray import ClipboardTray
    class ClipboardPanelWindow(FrameWindow): 
    3536        # Listening for new clipboard objects
    3637        # NOTE: we need to keep a reference to Gtk.Clipboard in order to keep
    3738        # listening to it.
    38         self._clipboard = Gtk.Clipboard()
     39        self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
    3940        self._clipboard.connect('owner-change', self._owner_change_cb)
    4041
    4142        self._clipboard_tray = ClipboardTray()
    class ClipboardPanelWindow(FrameWindow): 
    5859
    5960        cb_service = clipboard.get_instance()
    6061
    61         targets = x_clipboard.wait_for_targets()
     62        result, targets = x_clipboard.wait_for_targets()
    6263        cb_selections = []
    63         if targets is None:
     64        if not result:
    6465            return
    6566
    6667        target_is_uri = False
    class ClipboardPanelWindow(FrameWindow): 
    7879                cb_selections.append(selection)
    7980
    8081        if target_is_uri:
    81             uri = selection.data
     82            uri = selection.get_data()
    8283            filename = uri[len('file://'):].strip()
    8384            md5 = self._md5_for_file(filename)
    8485            data_hash = hash(md5)
    8586        else:
    86             data_hash = hash(selection.data)
     87            data_hash = hash(selection.get_data())
    8788
    8889        if len(cb_selections) > 0:
    8990            key = cb_service.add_object(name="", data_hash=data_hash)
    class ClipboardPanelWindow(FrameWindow): 
    111112        return md5.digest()
    112113
    113114    def _add_selection(self, key, selection):
    114         if not selection.data:
    115             logging.warning('no data for selection target %s.', selection.type)
     115        if not selection.get_data():
     116            logging.warning('no data for selection target %s.',
     117                    selection.get_data_type())
    116118            return
    117119
    118         logging.debug('adding type ' + selection.type + '.')
     120        selection_type = str(selection.get_data_type())
     121        logging.debug('adding type ' + selection_type + '.')
    119122
    120123        cb_service = clipboard.get_instance()
    121         if selection.type == 'text/uri-list':
     124        if selection_type == 'text/uri-list':
    122125            uris = selection.get_uris()
    123126
    124127            if len(uris) > 1:
    class ClipboardPanelWindow(FrameWindow): 
    130133            on_disk = (scheme == 'file')
    131134
    132135            cb_service.add_object_format(key,
    133                                          selection.type,
     136                                         selection_type,
    134137                                         uri,
    135138                                         on_disk)
    136139        else:
    137140            cb_service.add_object_format(key,
    138                                          selection.type,
    139                                          selection.data,
     141                                         selection_type,
     142                                         selection.get_data(),
    140143                                         on_disk=False)
  • src/jarabe/journal/palettes.py

    diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
    index 87f4a86..1078d0a 100644
    a b import os 
    2020
    2121from gi.repository import GObject
    2222from gi.repository import Gtk
     23from gi.repository import Gdk
    2324from gi.repository import GConf
    2425from gi.repository import Gio
    2526from gi.repository import GLib
    class ClipboardMenu(MenuItem): 
    309310                      _('Warning'))
    310311            return
    311312
    312         clipboard = Gtk.Clipboard()
     313        clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
    313314        clipboard.set_with_data([('text/uri-list', 0, 0)],
    314315                                self.__clipboard_get_func_cb,
    315316                                self.__clipboard_clear_func_cb)