Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-11-23 21:06:49 (GMT)
committer Simon Schampijer <simon@laptop.org>2012-11-27 18:28:16 (GMT)
commit9c7d980f8281f145b605710b7383b6fa8f1f58b4 (patch)
tree8007145be681af9179a68008e8ebcba734f88c06
parent330bdf5ac9a4e58ff505a43a14484ca82c2a70aa (diff)
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> Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r--src/jarabe/frame/clipboard.py3
-rw-r--r--src/jarabe/frame/clipboardicon.py5
-rw-r--r--src/jarabe/frame/clipboardobject.py3
-rw-r--r--src/jarabe/frame/clipboardpanelwindow.py27
-rw-r--r--src/jarabe/journal/palettes.py3
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/src/jarabe/frame/clipboard.py
+++ b/src/jarabe/frame/clipboard.py
@@ -22,6 +22,7 @@ import tempfile
from gi.repository import GObject
from gi.repository import Gtk
+from gi.repository import Gdk
from sugar3 import mime
@@ -99,7 +100,7 @@ class Clipboard(GObject.GObject):
cb_object = self._objects.pop(object_id)
cb_object.destroy()
if not self._objects:
- gtk_clipboard = Gtk.Clipboard()
+ gtk_clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
gtk_clipboard.clear()
self.emit('object-deleted', object_id)
logging.debug('Deleted object with object_id %r', object_id)
diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py
index 81b3131..b3fdccc 100644
--- a/src/jarabe/frame/clipboardicon.py
+++ b/src/jarabe/frame/clipboardicon.py
@@ -89,7 +89,7 @@ class ClipboardIcon(RadioToolButton):
targets = self._get_targets()
if targets:
- x_clipboard = Gtk.Clipboard()
+ x_clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
if not x_clipboard.set_with_data(targets,
self._clipboard_data_get_cb,
self._clipboard_clear_cb,
@@ -170,5 +170,6 @@ class ClipboardIcon(RadioToolButton):
def _get_targets(self):
targets = []
for format_type in self._cb_object.get_formats().keys():
- targets.append((format_type, 0, 0))
+ targets.append(Gtk.TargetEntry.new(format_type,
+ Gtk.TargetFlags.SAME_APP, 0))
return targets
diff --git a/src/jarabe/frame/clipboardobject.py b/src/jarabe/frame/clipboardobject.py
index a91c672..e79fa46 100644
--- a/src/jarabe/frame/clipboardobject.py
+++ b/src/jarabe/frame/clipboardobject.py
@@ -83,8 +83,7 @@ class ClipboardObject(object):
if not self._formats:
return False
else:
- return self._formats.keys()[0] in [ActivityBundle.MIME_TYPE,
- ActivityBundle.DEPRECATED_MIME_TYPE]
+ return self._formats.keys()[0] == ActivityBundle.MIME_TYPE
def get_percent(self):
return self._percent
diff --git a/src/jarabe/frame/clipboardpanelwindow.py b/src/jarabe/frame/clipboardpanelwindow.py
index fed6ba1..ba86775 100644
--- a/src/jarabe/frame/clipboardpanelwindow.py
+++ b/src/jarabe/frame/clipboardpanelwindow.py
@@ -19,6 +19,7 @@ from urlparse import urlparse
import hashlib
from gi.repository import Gtk
+from gi.repository import Gdk
from jarabe.frame.framewindow import FrameWindow
from jarabe.frame.clipboardtray import ClipboardTray
@@ -35,7 +36,7 @@ class ClipboardPanelWindow(FrameWindow):
# Listening for new clipboard objects
# NOTE: we need to keep a reference to Gtk.Clipboard in order to keep
# listening to it.
- self._clipboard = Gtk.Clipboard()
+ self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
self._clipboard.connect('owner-change', self._owner_change_cb)
self._clipboard_tray = ClipboardTray()
@@ -58,9 +59,9 @@ class ClipboardPanelWindow(FrameWindow):
cb_service = clipboard.get_instance()
- targets = x_clipboard.wait_for_targets()
+ result, targets = x_clipboard.wait_for_targets()
cb_selections = []
- if targets is None:
+ if not result:
return
target_is_uri = False
@@ -78,12 +79,12 @@ class ClipboardPanelWindow(FrameWindow):
cb_selections.append(selection)
if target_is_uri:
- uri = selection.data
+ uri = selection.get_data()
filename = uri[len('file://'):].strip()
md5 = self._md5_for_file(filename)
data_hash = hash(md5)
else:
- data_hash = hash(selection.data)
+ data_hash = hash(selection.get_data())
if len(cb_selections) > 0:
key = cb_service.add_object(name="", data_hash=data_hash)
@@ -111,14 +112,16 @@ class ClipboardPanelWindow(FrameWindow):
return md5.digest()
def _add_selection(self, key, selection):
- if not selection.data:
- logging.warning('no data for selection target %s.', selection.type)
+ if not selection.get_data():
+ logging.warning('no data for selection target %s.',
+ selection.get_data_type())
return
- logging.debug('adding type ' + selection.type + '.')
+ selection_type = str(selection.get_data_type())
+ logging.debug('adding type ' + selection_type + '.')
cb_service = clipboard.get_instance()
- if selection.type == 'text/uri-list':
+ if selection_type == 'text/uri-list':
uris = selection.get_uris()
if len(uris) > 1:
@@ -130,11 +133,11 @@ class ClipboardPanelWindow(FrameWindow):
on_disk = (scheme == 'file')
cb_service.add_object_format(key,
- selection.type,
+ selection_type,
uri,
on_disk)
else:
cb_service.add_object_format(key,
- selection.type,
- selection.data,
+ selection_type,
+ selection.get_data(),
on_disk=False)
diff --git a/src/jarabe/journal/palettes.py b/src/jarabe/journal/palettes.py
index 87f4a86..1078d0a 100644
--- a/src/jarabe/journal/palettes.py
+++ b/src/jarabe/journal/palettes.py
@@ -20,6 +20,7 @@ import os
from gi.repository import GObject
from gi.repository import Gtk
+from gi.repository import Gdk
from gi.repository import GConf
from gi.repository import Gio
from gi.repository import GLib
@@ -309,7 +310,7 @@ class ClipboardMenu(MenuItem):
_('Warning'))
return
- clipboard = Gtk.Clipboard()
+ clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
clipboard.set_with_data([('text/uri-list', 0, 0)],
self.__clipboard_get_func_cb,
self.__clipboard_clear_func_cb)