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

Sascha Silbe silbe at activitycentral.com
Mon Apr 23 15:51:30 EDT 2012


Excerpts from godiard's message of 2012-04-20 16:35:52 +0200:

> From: Gonzalo Odiard <godiard at gmail.com>
> 

More context would be useful. I had to read the ticket to understand
what this patch is about.


> v2: If there no more objects in the try, clean the clipboard

Please put the changelog below the marker line (the line with just ---
on it). It should not be part of the commit message on
mainline/master.

Similarly, please put the version number inside the subject prefix
(i.e. "[PATCH v2 sugar]"), rather than making it part of the patch
summary.


[src/jarabe/frame/clipboardtray.py]
> @@ -124,6 +124,14 @@ class ClipboardTray(tray.VTray):
>          icon = self._icons[object_id]
>          self.remove_item(icon)
>          del self._icons[object_id]
> +        # select the last available icon
> +        if len(self._icons) > 0:

PEP 8, Programming Recommendations:
>> For sequences, (strings, lists, tuples), use the fact that empty sequences are false
>>    Yes: if not seq:
>>         if seq:

>>    No: if len(seq)
>>        if not len(seq)


> +            n_icons = len(self.get_children())
> +            last_icon = self.get_children()[n_icons - 1]

In Python, you can slice and dereference relative to the end of a
sequence by using a negative integer:

+            last_icon = self.get_children()[-1]

No need to explicitly calculate the length of the sequence. In
specific cases, using negative indexes may be faster (depending on
implementation details of the sequence), but more importantly it's
more readable and concise.


> +            last_icon.props.active = True
> +        else:
> +            gtk_clipboard = gtk.Clipboard()
> +            gtk_clipboard.clear()

Shouldn't all of this happen in
jarabe.frame.clipboard.Clipboard.delete_object()? AIUI ClipboardTray
is just the graphical representation ("UI"), whereas Clipboard is the
actual clipboard service, managing and keeping references to the
clipboard objects.

Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120423/f3b60e90/attachment.pgp>


More information about the Sugar-devel mailing list