[Sugar-devel] [PATCH] Only add one time every object in the clipboard v3 - SL #3371
Anish Mangal
anish at activitycentral.com
Fri Apr 20 16:42:35 EDT 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sat 21 Apr 2012 01:33:05 AM IST, Gonzalo Odiard wrote:
> New patch sent, I don't know why, but the In-Reply-To parameter does
> not add the message to this thread.
>
> Gonzalo
>
> On Fri, Apr 20, 2012 at 2:34 PM, Simon Schampijer <simon at schampijer.de
> <mailto:simon at schampijer.de>> wrote:
>
> Great both new versions of your patches do what they describe they
> would do :)
>
> There is one trace in the shell.log related to the clipboard when
> the clipboard owner changes, a TypeError, targets is None.
>
> Please have a look at it, all the rest looks already really good.
>
> Regards,
> Simon
>
>
>
> On 04/20/2012 04:17 PM, godiard at sugarlabs.org
> <mailto:godiard at sugarlabs.org> wrote:
>
> From: Gonzalo Odiard<godiard at gmail.com <mailto:godiard at gmail.com>>
>
> This patch change the behaviour of the clipboard tray,
> every object is added only one time, if already exist,
> the already added object is selected.
> Is needed because a bad interaction between the clipboard in
> write and
> the text to speech feature. See the ticket for more information.
>
> v2: Select the already added object if needed, as sugested by
> Sasha.
> v3: Show the notification when copy a already existing object,
> as sugested by Gary
>
> Signed-off-by: Gonzalo Odiard<gonzalo at laptop.org
> <mailto:gonzalo at laptop.org>>
> ---
> src/jarabe/frame/clipboard.py | 17 +++++++++++++----
> src/jarabe/frame/__clipboardicon.py | 18
> ++++++++++--------
> src/jarabe/frame/__clipboardpanelwindow.py | 5 ++++-
> src/jarabe/frame/__clipboardtray.py | 7 +++++++
> 4 files changed, 34 insertions(+), 13 deletions(-)
>
> diff --git a/src/jarabe/frame/clipboard.__py
> b/src/jarabe/frame/clipboard.__py
> index be2b902..ae1ceb9 100644
> --- a/src/jarabe/frame/clipboard.__py
> +++ b/src/jarabe/frame/clipboard.__py
> @@ -36,7 +36,9 @@ class Clipboard(gobject.GObject):
> 'object-added': (gobject.SIGNAL_RUN_FIRST,
> gobject.TYPE_NONE,
> ([object])),
> 'object-deleted': (gobject.SIGNAL_RUN_FIRST,
> gobject.TYPE_NONE,
> - ([int])),
> + ([long])),
> + 'object-selected': (gobject.SIGNAL_RUN_FIRST,
> gobject.TYPE_NONE,
> + ([long])),
> 'object-state-changed': (gobject.SIGNAL_RUN_FIRST,
> gobject.TYPE_NONE,
> ([object])),
> }
> @@ -51,9 +53,16 @@ class Clipboard(gobject.GObject):
> self._next_id += 1
> return self._next_id
>
> - def add_object(self, name):
> - logging.debug('Clipboard.add___object')
> - object_id = self._get_next_object_id()
> + def add_object(self, name, data_hash=None):
> + logging.debug('Clipboard.add___object hash %s',
> data_hash)
> + if data_hash is None:
> + object_id = self._get_next_object_id()
> + else:
> + object_id = data_hash
> + if object_id in self._objects:
> + logging.debug('Object rejected, already exist')
> + self.emit('object-selected', object_id)
> + return None
> self._objects[object_id] = ClipboardObject(object_id,
> name)
> self.emit('object-added', self._objects[object_id])
> return object_id
> diff --git a/src/jarabe/frame/__clipboardicon.py
> b/src/jarabe/frame/__clipboardicon.py
> index aa72d8a..7bc4dc3 100644
> --- a/src/jarabe/frame/__clipboardicon.py
> +++ b/src/jarabe/frame/__clipboardicon.py
> @@ -128,17 +128,19 @@ class ClipboardIcon(RadioToolButton)__:
> # Clipboard object became complete. Make it the
> active one.
> if self._current_percent< 100 and
> cb_object.get_percent() == 100:
> self.props.active = True
> + self.show_notification()
>
> - self._notif_icon = NotificationIcon()
> - self._notif_icon.props.icon___name =
> self._icon.props.icon_name
> - self._notif_icon.props.xo___color = \
> - XoColor('%s,%s' %
> (self._icon.props.stroke___color,
> -
> self._icon.props.fill_color))
> - frame = jarabe.frame.get_view()
> - frame.add_notification(self.___notif_icon,
> - gtk.CORNER_BOTTOM_LEFT)
> self._current_percent = cb_object.get_percent()
>
> + def show_notification(self):
> + self._notif_icon = NotificationIcon()
> + self._notif_icon.props.icon___name =
> self._icon.props.icon_name
> + self._notif_icon.props.xo___color = \
> + XoColor('%s,%s' %
> (self._icon.props.stroke___color,
> + self._icon.props.fill_color))
> + frame = jarabe.frame.get_view()
> + frame.add_notification(self.___notif_icon,
> gtk.CORNER_BOTTOM_LEFT)
> +
> def _drag_begin_cb(self, widget, context):
> # TODO: We should get the pixbuf from the icon, with
> colors, etc.
> icon_theme = gtk.icon_theme_get_default()
> diff --git a/src/jarabe/frame/__clipboardpanelwindow.py
> b/src/jarabe/frame/__clipboardpanelwindow.py
> index b73572e..28c5726 100644
> --- a/src/jarabe/frame/__clipboardpanelwindow.py
> +++ b/src/jarabe/frame/__clipboardpanelwindow.py
> @@ -70,7 +70,10 @@ class ClipboardPanelWindow(__FrameWindow):
> cb_selections.append(__selection)
>
> if len(cb_selections)> 0:
> - key = cb_service.add_object(name="")
> + key = cb_service.add_object(name="",
> + data_hash=hash(selection.data)__)
> + if key is None:
> + return
> cb_service.set_object_percent(__key, percent=0)
> for selection in cb_selections:
> self._add_selection(key, selection)
> diff --git a/src/jarabe/frame/__clipboardtray.py
> b/src/jarabe/frame/__clipboardtray.py
> index f49b799..f736295 100644
> --- a/src/jarabe/frame/__clipboardtray.py
> +++ b/src/jarabe/frame/__clipboardtray.py
> @@ -70,6 +70,7 @@ class ClipboardTray(tray.VTray):
> cb_service = clipboard.get_instance()
> cb_service.connect('object-__added',
> self._object_added_cb)
> cb_service.connect('object-__deleted',
> self._object_deleted_cb)
> + cb_service.connect('object-__selected',
> self._object_selected_cb)
>
> def owns_clipboard(self):
> for icon in self._icons.values():
> @@ -125,6 +126,12 @@ class ClipboardTray(tray.VTray):
> del self._icons[object_id]
> logging.debug('ClipboardTray: %r was deleted', object_id)
>
> + def _object_selected_cb(self, cb_service, object_id):
> + icon = self._icons[object_id]
> + icon.props.active = True
> + icon.show_notification()
> + logging.debug('ClipboardTray: %r was activated',
> object_id)
> +
> def drag_motion_cb(self, widget, context, x, y, time):
> logging.debug('ClipboardTray.___drag_motion_cb')
>
>
> _________________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.__org
> <mailto:Sugar-devel at lists.sugarlabs.org>
> http://lists.sugarlabs.org/__listinfo/sugar-devel
> <http://lists.sugarlabs.org/listinfo/sugar-devel>
>
>
>
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
Tested the following functionality:
* Open write
* Type some text and select it
* Copy -> (Clipboard icon added to left frame, Notification shown)
* Copy (again) -> (No new clipboard icon added, Notification shown)
* Type some more text (different) and select that
* Copy -> (New Clipboard icon added to left frame, Notification shown)
* Copy (again) -> (No new clipboard icon added, Notification shown)
Note:
* I don't seem to have the necessary dependency installed for TTS,
don't know if it affects this though.
* 'Copy' in the above test implies Copying from the Edit toolbar menu.
* Haven't tested any other use-cases
* Also, as the ticket mentions, if an already existing clipboard entry
is selected, it isn't moved visually to the bottom of the list. This,
IMO is a bug (deviance from time-ordered-sorting approach).
Tested-by: Anish Mangal <anish at activitycentral.com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJPkco0AAoJEBoxUdDHDZVpf+oIAI/zli0FmdV/1cNa2kHG/knu
SG+bYRik1OUePe2NGsjBKz0TPlXvxnm/kGnzXgDI4RMGiTCAGPlGkNrmBC4nwhPu
7rL20FTddmZkhtXoViY/AFvryNA3jCSVsliqZAkWJVuARYgNfg7tmamhDdjKXKmo
bVr8mljLUovg358JLInT7oZS+Q9SyolA3Uf//jr9LEd54mSl5YuvfJLg3lv6e0Ym
vBTBAQHGyWN5u8YG4fHQZZs1vJCSE84bwwyTGgmRXoIcPTEEW2GOZjbV735HXwxL
V13rOQwN1c8eV9/OA7Dp9DIaN0NtCcaniZ/u/pCdAAqwiJhctlZVPnANIedcVIs=
=M3/H
-----END PGP SIGNATURE-----
More information about the Sugar-devel
mailing list