[Sugar-devel] [PATCH] Add 'transient' property to Invoker #1742

Simon Schampijer simon at schampijer.de
Wed Oct 13 12:29:03 EDT 2010


On 10/11/2010 11:34 AM, Tomeu Vizoso wrote:
> Meaning that the palette will be disposed when it pops down.
> ---
>   src/sugar/graphics/palette.py       |    1 +
>   src/sugar/graphics/palettewindow.py |   20 +++++++++++++++++---
>   2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/src/sugar/graphics/palette.py b/src/sugar/graphics/palette.py
> index d4632eb..d4f844c 100644
> --- a/src/sugar/graphics/palette.py
> +++ b/src/sugar/graphics/palette.py
> @@ -158,6 +158,7 @@ class Palette(PaletteWindow):
>           self.popdown(immediate=True)
>           # Break the reference cycle. It looks like the gc is not able to free
>           # it, possibly because gtk.Menu memory handling is very special.
> +        self.menu.disconnect_by_func(self.__menu_item_inserted_cb)
>           self.menu = None
>
>       def __show_cb(self, widget):
> diff --git a/src/sugar/graphics/palettewindow.py b/src/sugar/graphics/palettewindow.py
> index 22131c2..3c74662 100644
> --- a/src/sugar/graphics/palettewindow.py
> +++ b/src/sugar/graphics/palettewindow.py
> @@ -179,6 +179,7 @@ class PaletteWindow(gtk.Window):
>
>       def __destroy_cb(self, palette):
>           self.set_group_id(None)
> +        self._mouse_detector.disconnect_by_func(self._mouse_slow_cb)
>
>       def set_invoker(self, invoker):
>           for hid in self._invoker_hids[:]:
> @@ -457,6 +458,7 @@ class Invoker(gobject.GObject):
>           self._cursor_x = -1
>           self._cursor_y = -1
>           self._palette = None
> +        self._transient = False
>
>       def attach(self, parent):
>           self.parent = parent
> @@ -639,18 +641,30 @@ class Invoker(gobject.GObject):
>       def set_palette(self, palette):
>           if self._palette is not None:
>               self._palette.popdown(immediate=True)
> -
> -        if self._palette:
>               self._palette.props.invoker = None
> +            self._palette.destroy()
>
>           self._palette = palette
>
> -        if self._palette:
> +        if self._palette is not None:
>               self._palette.props.invoker = self
> +            self._palette.connect('popdown', self.__palette_popdown_cb)
>
>       palette = gobject.property(
>           type=object, setter=set_palette, getter=get_palette)
>
> +    def get_transient(self):
> +        return self._transient
> +
> +    def set_transient(self, transient):
> +        self._transient = transient
> +
> +    transient = gobject.property(type=object, setter=set_transient,
> +                                 getter=get_transient)
> +
> +    def __palette_popdown_cb(self, palette):
> +        if self.props.transient:
> +            self.set_palette(None)
>
>   class WidgetInvoker(Invoker):
>

Hi Tomeu,

thanks for that patch!

As already discussed on IRC naming the attribute to 'cache_palette' 
would probably be more descriptive. As well like Sascha suggested it 
would be good to add a docstring for it.

As you said already for future work it would be good to do the 
following: Palettes very expensive to create or that the user may be 
staring at, we should update dynamically but others should be just 
disposed when popped down, as we do in your patch.

Another occurrence of the issue we are seeing here is the Journal entry 
palette. Example:

- I want to share an entry and open the palette
- Oh, no buddy there to share with, forgot to add him as a friend.
- doing that in the neighborhood view
- going back and trying again, still not there for that entry other 
entries do contain the buddy.

In short, we should identify the other occurrences and try to fix them 
as well.

Regards,
    Simon




More information about the Sugar-devel mailing list