Ticket #3371: 0001-Only-add-one-time-every-object-in-the-clipboard.patch

File 0001-Only-add-one-time-every-object-in-the-clipboard.patch, 2.5 KB (added by godiard, 9 years ago)
  • src/jarabe/frame/clipboard.py

    From f9af7ecbe0e976b17fa7c902d9811622d64974e3 Mon Sep 17 00:00:00 2001
    From: Gonzalo Odiard <godiard@gmail.com>
    Date: Wed, 14 Mar 2012 18:18:33 -0300
    Subject: [PATCH] Only add one time every object in the clipboard
    
    Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
    ---
     src/jarabe/frame/clipboard.py            |   14 ++++++++++----
     src/jarabe/frame/clipboardpanelwindow.py |    6 +++++-
     2 files changed, 15 insertions(+), 5 deletions(-)
    
    diff --git a/src/jarabe/frame/clipboard.py b/src/jarabe/frame/clipboard.py
    index be2b902..3351146 100644
    a b class Clipboard(gobject.GObject): 
    3636        'object-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
    3737                        ([object])),
    3838        'object-deleted': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
    39                         ([int])),
     39                        ([long])),
    4040        'object-state-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
    4141                        ([object])),
    4242    }
    class Clipboard(gobject.GObject): 
    5151        self._next_id += 1
    5252        return self._next_id
    5353
    54     def add_object(self, name):
    55         logging.debug('Clipboard.add_object')
    56         object_id = self._get_next_object_id()
     54    def add_object(self, name, data_hash=None):
     55        logging.debug('Clipboard.add_object hash %s', data_hash)
     56        if data_hash is None:
     57            object_id = self._get_next_object_id()
     58        else:
     59            object_id = data_hash
     60        if object_id in self._objects:
     61            logging.debug('Object rejected, already exist')
     62            return None
    5763        self._objects[object_id] = ClipboardObject(object_id, name)
    5864        self.emit('object-added', self._objects[object_id])
    5965        return object_id
  • src/jarabe/frame/clipboardpanelwindow.py

    diff --git a/src/jarabe/frame/clipboardpanelwindow.py b/src/jarabe/frame/clipboardpanelwindow.py
    index b73572e..595e23f 100644
    a b class ClipboardPanelWindow(FrameWindow): 
    7070                cb_selections.append(selection)
    7171
    7272        if len(cb_selections) > 0:
    73             key = cb_service.add_object(name="")
     73            key = cb_service.add_object(name="",
     74                    data_hash=hash(selection.data))
     75            if key is None:
     76                return
     77            logging.error('key %s', key)
    7478            cb_service.set_object_percent(key, percent=0)
    7579            for selection in cb_selections:
    7680                self._add_selection(key, selection)