[Sugar-devel] [PATCH v2 sugar] Frame: show application-set icon for non-Sugar windows

James Cameron quozl at laptop.org
Sun Sep 19 20:48:08 EDT 2010


On Sun, Sep 19, 2010 at 02:43:01PM +0200, Sascha Silbe wrote:
> Display the _NET_WM_ICON content instead of a generic icon for non-Sugar
> applications.

Nice.

> [...] 
> --- a/src/jarabe/frame/activitiestray.py
> +++ b/src/jarabe/frame/activitiestray.py
> @@ -97,6 +104,22 @@ class ActivityButton(RadioToolButton):
>          else:
>              self._icon.props.pulsing = False
> 
> +    def _icon_changed_cb(self, window):
> +        gobject.idle_add(self._update_icon, window)

I'm puzzled.  Why defer the update to an idle task?  If it is because of
a race, I'm worried this won't fix it.

> +    def _update_icon(self, window):
> +        logging.debug('_update_icon: start')
> +        pixbuf = window.get_icon()
> +        if pixbuf is None:
> +            return

When a function is an idle task, the return value has significance, so
I'm not sure if a bare return is the right thing here.

> +
> +        fd, path = tempfile.mkstemp(suffix='.png')
> +        os.close(fd)
> +        pixbuf.save(path, 'png')
> +        self._icon.props.icon_name = None
> +        self._icon.props.file = util.TempFilePath(path)
> +        logging.debug('_update_icon: updated icon')

When are these files cleaned up?

I've seen some applications that change their icon quite frequently.

-- 
James Cameron
http://quozl.linux.org.au/


More information about the Sugar-devel mailing list