[Sugar-devel] [PATCH] When a object is removed from the clipboard try, select the last available v3 - SL #1266

Anish Mangal anish at activitycentral.com
Tue Apr 24 08:50:28 EDT 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue 24 Apr 2012 04:48:27 PM IST, godiard at sugarlabs.org wrote:
> From: Gonzalo Odiard <godiard at gmail.com>
>
> If the user remove a object from the clipboard,
> the last available object should be selected,
> and if no more objects are available, the clipboard should be cleaned.
>
> Signed-off-by: Gonzalo Odiard <gonzalo at laptop.org>
> ---
> v2: If there no more objects in the try, clean the clipboard
> v3: Changes suggested in review by Sascha.
> ---
>  src/jarabe/frame/clipboard.py     |    4 ++++
>  src/jarabe/frame/clipboardtray.py |    5 +++++
>  2 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/src/jarabe/frame/clipboard.py b/src/jarabe/frame/clipboard.py
> index f3da89f..3bdc7f2 100644
> --- a/src/jarabe/frame/clipboard.py
> +++ b/src/jarabe/frame/clipboard.py
> @@ -21,6 +21,7 @@ import urlparse
>  import tempfile
>
>  import gobject
> +import gtk
>
>  from sugar import mime
>
> @@ -94,6 +95,9 @@ class Clipboard(gobject.GObject):
>      def delete_object(self, object_id):
>          cb_object = self._objects.pop(object_id)
>          cb_object.destroy()
> +        if not self._objects:
> +            gtk_clipboard = gtk.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/clipboardtray.py b/src/jarabe/frame/clipboardtray.py
> index f49b799..37d5e1a 100644
> --- a/src/jarabe/frame/clipboardtray.py
> +++ b/src/jarabe/frame/clipboardtray.py
> @@ -123,6 +123,11 @@ class ClipboardTray(tray.VTray):
>          icon = self._icons[object_id]
>          self.remove_item(icon)
>          del self._icons[object_id]
> +        # select the last available icon
> +        if self._icons:
> +            last_icon = self.get_children()[-1]
> +            last_icon.props.active = True
> +
>          logging.debug('ClipboardTray: %r was deleted', object_id)
>
>      def drag_motion_cb(self, widget, context, x, y, time):

Tested on f16-jhbuild (14b2326e - v0.95.7 as per the description of the
issue sl#1266)
a. Opened terminal
b. Copied some text
c. Copied some more text
d. Deleted the clipoard entry (c.)
e. On pasting, entry b. is pasted.

Before applying this patch

e. On pasting entry c. is pasted.


Also, upon deleting the the clipboard entry, the previous clipboard
entry is also "visually" selected, which was not the case before.

Patch otherwise looks good to me as well.

Tested-by: Anish Mangal <anish at activitycentral.com>
Reviewed-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/

iQEcBAEBAgAGBQJPlqGUAAoJEBoxUdDHDZVpF8YH/0nZ8f+eZTuL5f3PQp2k4mqU
HfAG8txmEd2Onm2yl2y8XuYPqUw74HdeztO3BCQqcvZb1mDegLeJhM7Rn9Y0s5je
gddn2LriL7ngy0gaXYfflShtiqsqRV7I3om6v3/bSuhUQIuXJWJJ9SjfX1Mid1jK
RKaiRwiGytB1J/+QETK5zO1mcLLxroHml8DUHwrD0JcRmwsNk74xlyn36l1Mjw+s
oKOnPxYcZBJfAnK2ok7K5HPLI+vsXOuQuEkDK6ekhfE7ZTXLDRgJB7koIF+QfoKc
aZ2K0diGdEaJDIF9PJOPvlbYpxvX/LkmGJlJkhz7kpHFJdMj0m1u7Msbm0GcRX0=
=z6Xx
-----END PGP SIGNATURE-----



More information about the Sugar-devel mailing list