New patch sent, I don't know why, but the In-Reply-To parameter does not add the message to this thread.<div><br></div><div>Gonzalo<br><br><div class="gmail_quote">On Fri, Apr 20, 2012 at 2:34 PM, Simon Schampijer <span dir="ltr"><<a href="mailto:simon@schampijer.de">simon@schampijer.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Great both new versions of your patches do what they describe they would do :)<br>
<br>
There is one trace in the shell.log related to the clipboard when the clipboard owner changes, a TypeError, targets is None.<br>
<br>
Please have a look at it, all the rest looks already really good.<br>
<br>
Regards,<br>
Simon<div><div class="h5"><br>
<br>
<br>
On 04/20/2012 04:17 PM, <a href="mailto:godiard@sugarlabs.org" target="_blank">godiard@sugarlabs.org</a> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Gonzalo Odiard<<a href="mailto:godiard@gmail.com" target="_blank">godiard@gmail.com</a>><br>
<br>
This patch change the behaviour of the clipboard tray,<br>
every object is added only one time, if already exist,<br>
the already added object is selected.<br>
Is needed because a bad interaction between the clipboard in write and<br>
the text to speech feature. See the ticket for more information.<br>
<br>
v2: Select the already added object if needed, as sugested by Sasha.<br>
v3: Show the notification when copy a already existing object, as sugested by Gary<br>
<br>
Signed-off-by: Gonzalo Odiard<<a href="mailto:gonzalo@laptop.org" target="_blank">gonzalo@laptop.org</a>><br>
---<br>
src/jarabe/frame/clipboard.py | 17 +++++++++++++----<br>
src/jarabe/frame/<u></u>clipboardicon.py | 18 ++++++++++--------<br>
src/jarabe/frame/<u></u>clipboardpanelwindow.py | 5 ++++-<br>
src/jarabe/frame/<u></u>clipboardtray.py | 7 +++++++<br>
4 files changed, 34 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/src/jarabe/frame/clipboard.<u></u>py b/src/jarabe/frame/clipboard.<u></u>py<br>
index be2b902..ae1ceb9 100644<br>
--- a/src/jarabe/frame/clipboard.<u></u>py<br>
+++ b/src/jarabe/frame/clipboard.<u></u>py<br>
@@ -36,7 +36,9 @@ class Clipboard(gobject.GObject):<br>
'object-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,<br>
([object])),<br>
'object-deleted': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,<br>
- ([int])),<br>
+ ([long])),<br>
+ 'object-selected': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,<br>
+ ([long])),<br>
'object-state-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,<br>
([object])),<br>
}<br>
@@ -51,9 +53,16 @@ class Clipboard(gobject.GObject):<br>
self._next_id += 1<br>
return self._next_id<br>
<br>
- def add_object(self, name):<br>
- logging.debug('Clipboard.add_<u></u>object')<br>
- object_id = self._get_next_object_id()<br>
+ def add_object(self, name, data_hash=None):<br>
+ logging.debug('Clipboard.add_<u></u>object hash %s', data_hash)<br>
+ if data_hash is None:<br>
+ object_id = self._get_next_object_id()<br>
+ else:<br>
+ object_id = data_hash<br>
+ if object_id in self._objects:<br>
+ logging.debug('Object rejected, already exist')<br>
+ self.emit('object-selected', object_id)<br>
+ return None<br>
self._objects[object_id] = ClipboardObject(object_id, name)<br>
self.emit('object-added', self._objects[object_id])<br>
return object_id<br>
diff --git a/src/jarabe/frame/<u></u>clipboardicon.py b/src/jarabe/frame/<u></u>clipboardicon.py<br>
index aa72d8a..7bc4dc3 100644<br>
--- a/src/jarabe/frame/<u></u>clipboardicon.py<br>
+++ b/src/jarabe/frame/<u></u>clipboardicon.py<br>
@@ -128,17 +128,19 @@ class ClipboardIcon(RadioToolButton)<u></u>:<br>
# Clipboard object became complete. Make it the active one.<br>
if self._current_percent< 100 and cb_object.get_percent() == 100:<br>
self.props.active = True<br>
+ self.show_notification()<br>
<br>
- self._notif_icon = NotificationIcon()<br>
- self._notif_icon.props.icon_<u></u>name = self._icon.props.icon_name<br>
- self._notif_icon.props.xo_<u></u>color = \<br>
- XoColor('%s,%s' % (self._icon.props.stroke_<u></u>color,<br>
- self._icon.props.fill_color))<br>
- frame = jarabe.frame.get_view()<br>
- frame.add_notification(self._<u></u>notif_icon,<br>
- gtk.CORNER_BOTTOM_LEFT)<br>
self._current_percent = cb_object.get_percent()<br>
<br>
+ def show_notification(self):<br>
+ self._notif_icon = NotificationIcon()<br>
+ self._notif_icon.props.icon_<u></u>name = self._icon.props.icon_name<br>
+ self._notif_icon.props.xo_<u></u>color = \<br>
+ XoColor('%s,%s' % (self._icon.props.stroke_<u></u>color,<br>
+ self._icon.props.fill_color))<br>
+ frame = jarabe.frame.get_view()<br>
+ frame.add_notification(self._<u></u>notif_icon, gtk.CORNER_BOTTOM_LEFT)<br>
+<br>
def _drag_begin_cb(self, widget, context):<br>
# TODO: We should get the pixbuf from the icon, with colors, etc.<br>
icon_theme = gtk.icon_theme_get_default()<br>
diff --git a/src/jarabe/frame/<u></u>clipboardpanelwindow.py b/src/jarabe/frame/<u></u>clipboardpanelwindow.py<br>
index b73572e..28c5726 100644<br>
--- a/src/jarabe/frame/<u></u>clipboardpanelwindow.py<br>
+++ b/src/jarabe/frame/<u></u>clipboardpanelwindow.py<br>
@@ -70,7 +70,10 @@ class ClipboardPanelWindow(<u></u>FrameWindow):<br>
cb_selections.append(<u></u>selection)<br>
<br>
if len(cb_selections)> 0:<br>
- key = cb_service.add_object(name="")<br>
+ key = cb_service.add_object(name="",<br>
+ data_hash=hash(selection.data)<u></u>)<br>
+ if key is None:<br>
+ return<br>
cb_service.set_object_percent(<u></u>key, percent=0)<br>
for selection in cb_selections:<br>
self._add_selection(key, selection)<br>
diff --git a/src/jarabe/frame/<u></u>clipboardtray.py b/src/jarabe/frame/<u></u>clipboardtray.py<br>
index f49b799..f736295 100644<br>
--- a/src/jarabe/frame/<u></u>clipboardtray.py<br>
+++ b/src/jarabe/frame/<u></u>clipboardtray.py<br>
@@ -70,6 +70,7 @@ class ClipboardTray(tray.VTray):<br>
cb_service = clipboard.get_instance()<br>
cb_service.connect('object-<u></u>added', self._object_added_cb)<br>
cb_service.connect('object-<u></u>deleted', self._object_deleted_cb)<br>
+ cb_service.connect('object-<u></u>selected', self._object_selected_cb)<br>
<br>
def owns_clipboard(self):<br>
for icon in self._icons.values():<br>
@@ -125,6 +126,12 @@ class ClipboardTray(tray.VTray):<br>
del self._icons[object_id]<br>
logging.debug('ClipboardTray: %r was deleted', object_id)<br>
<br>
+ def _object_selected_cb(self, cb_service, object_id):<br>
+ icon = self._icons[object_id]<br>
+ icon.props.active = True<br>
+ icon.show_notification()<br>
+ logging.debug('ClipboardTray: %r was activated', object_id)<br>
+<br>
def drag_motion_cb(self, widget, context, x, y, time):<br>
logging.debug('ClipboardTray._<u></u>drag_motion_cb')<br>
<br>
</blockquote>
<br></div></div>
______________________________<u></u>_________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org" target="_blank">Sugar-devel@lists.sugarlabs.<u></u>org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/<u></u>listinfo/sugar-devel</a><br>
</blockquote></div><br></div>