[Sugar-devel] [PATCH sugar-toolkit-gtk3] Replacing set_data/get_data with a python attribute
Manuel Quiñones
manuq at laptop.org
Wed Jun 6 08:05:39 EDT 2012
2012/6/6 Simon Schampijer <simon at schampijer.de>:
> set_data/get_data not available anymore is not available anymore [1]. The
> recommended approach is using a python attribute, which we do.
>
> Changing to use the attribute in the activity class slipped by mistake
> into 6330204e919a047c0b0f3579da36197630e8e400.
>
> [1] https://bugzilla.gnome.org/show_bug.cgi?id=641944
Looks good,
> Signed-off-by: Simon Schampijer <simon at laptop.org>
Tested-by: Manuel Quiñones <manuq at laptop.org>
> ---
> src/sugar3/graphics/colorbutton.py | 4 ++--
> src/sugar3/graphics/menuitem.py | 4 ++--
> src/sugar3/graphics/palettewindow.py | 4 ++--
> src/sugar3/graphics/toolbutton.py | 5 ++---
> 4 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/src/sugar3/graphics/colorbutton.py b/src/sugar3/graphics/colorbutton.py
> index 9f490bb..c21da47 100644
> --- a/src/sugar3/graphics/colorbutton.py
> +++ b/src/sugar3/graphics/colorbutton.py
> @@ -396,11 +396,11 @@ def _add_accelerator(tool_button):
>
> # TODO: should we remove the accelerator from the prev top level?
>
> - accel_group = tool_button.get_toplevel().get_data('sugar-accel-group')
> - if not accel_group:
> + if not hasattr(tool_button.get_toplevel(), 'sugar_accel_group'):
> logging.warning('No Gtk.AccelGroup in the top level window.')
> return
>
> + accel_group = tool_button.get_toplevel().sugar_accel_group
> keyval, mask = Gtk.accelerator_parse(tool_button.props.accelerator)
> # the accelerator needs to be set at the child, so the Gtk.AccelLabel
> # in the palette can pick it up.
> diff --git a/src/sugar3/graphics/menuitem.py b/src/sugar3/graphics/menuitem.py
> index 0844e9a..717f7e2 100644
> --- a/src/sugar3/graphics/menuitem.py
> +++ b/src/sugar3/graphics/menuitem.py
> @@ -75,11 +75,11 @@ class MenuItem(Gtk.ImageMenuItem):
>
> # TODO: should we remove the accelerator from the prev top level?
>
> - accel_group = self.get_toplevel().get_data('sugar-accel-group')
> - if not accel_group:
> + if not hasattr(self.get_toplevel(), 'sugar_accel_group'):
> logging.warning('No Gtk.AccelGroup in the top level window.')
> return
>
> + accel_group = self.get_toplevel().sugar_accel_group
> keyval, mask = Gtk.accelerator_parse(self._accelerator)
> self.add_accelerator('activate', accel_group, keyval, mask,
> Gtk.AccelFlags.LOCKED | Gtk.AccelFlags.VISIBLE)
> diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py
> index 449f550..c3431b7 100644
> --- a/src/sugar3/graphics/palettewindow.py
> +++ b/src/sugar3/graphics/palettewindow.py
> @@ -80,7 +80,7 @@ class _PaletteMenuWidget(Gtk.Menu):
> Gtk.Menu.__init__(self)
>
> accel_group = Gtk.AccelGroup()
> - self.set_data('sugar-accel-group', accel_group)
> + self.sugar_accel_group = accel_group
> self.get_toplevel().add_accel_group(accel_group)
>
> self._popup_position = (0, 0)
> @@ -248,7 +248,7 @@ class _PaletteWindowWidget(Gtk.Window):
> self.set_position(Gtk.WindowPosition.NONE)
>
> accel_group = Gtk.AccelGroup()
> - self.set_data('sugar-accel-group', accel_group)
> + self.sugar_accel_group = accel_group
> self.add_accel_group(accel_group)
>
> self._old_alloc = None
> diff --git a/src/sugar3/graphics/toolbutton.py b/src/sugar3/graphics/toolbutton.py
> index 1df7d4c..da02212 100644
> --- a/src/sugar3/graphics/toolbutton.py
> +++ b/src/sugar3/graphics/toolbutton.py
> @@ -35,12 +35,11 @@ def _add_accelerator(tool_button):
> return
>
> # TODO: should we remove the accelerator from the prev top level?
> -
> - accel_group = tool_button.get_toplevel().get_data('sugar-accel-group')
> - if not accel_group:
> + if not hasattr(tool_button.get_toplevel(), 'sugar_accel_group'):
> logging.warning('No Gtk.AccelGroup in the top level window.')
> return
>
> + accel_group = tool_button.get_toplevel().sugar_accel_group
> keyval, mask = Gtk.accelerator_parse(tool_button.props.accelerator)
> # the accelerator needs to be set at the child, so the Gtk.AccelLabel
> # in the palette can pick it up.
> --
> 1.7.10.2
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
--
.. manuq ..
More information about the Sugar-devel
mailing list