[Sugar-devel] [PATCH] fix SL #2001 - Write does not pass parent window xid to ObjectChooser

Tomeu Vizoso tomeu at sugarlabs.org
Fri Oct 15 08:36:20 EDT 2010


On Thu, Oct 14, 2010 at 20:09,  <godiard at sugarlabs.org> wrote:
> From: Gonzalo Odiard <godiard at sugarlabs.org>
>
> This is a regresion, probably introduced when changed the toolbar.
> May be pass self.abiword_canvas and self to ImageToolbar is not the smarter option.

You are right, would be better if the activity listened to signals in
the toolbar and called methods on the canvas as a result.

But in this case, the toolbar can get a reference to the top level window with:

http://www.pygtk.org/docs/pygtk/class-gtkwidget.html#method-gtkwidget--get-toplevel

Btw, is Write maintained these days?

Regards,

Tomeu

> ---
>  AbiWordActivity.py |    2 +-
>  toolbar.py         |    5 +++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/AbiWordActivity.py b/AbiWordActivity.py
> index f6c54fa..7deab8c 100644
> --- a/AbiWordActivity.py
> +++ b/AbiWordActivity.py
> @@ -110,7 +110,7 @@ class AbiWordActivity (activity.Activity):
>         toolbar_box.toolbar.insert(list_toolbar, -1)
>
>         insert_toolbar = ToolbarButton()
> -        insert_toolbar.props.page = InsertToolbar(self.abiword_canvas)
> +        insert_toolbar.props.page = InsertToolbar(self.abiword_canvas, self)
>         insert_toolbar.props.icon_name = 'insert-table'
>         insert_toolbar.props.label = _('Table')
>         toolbar_box.toolbar.insert(insert_toolbar, -1)
> diff --git a/toolbar.py b/toolbar.py
> index 75243c7..a16803c 100644
> --- a/toolbar.py
> +++ b/toolbar.py
> @@ -176,10 +176,11 @@ class EditToolbar(gtk.Toolbar):
>         tool_item.show()
>
>  class InsertToolbar(gtk.Toolbar):
> -    def __init__(self, abiword_canvas):
> +    def __init__(self, abiword_canvas, parent):
>         gtk.Toolbar.__init__(self)
>
>         self._abiword_canvas = abiword_canvas
> +        self._parent = parent
>
>         self._table = abiword.TableCreator()
>         self._table.set_labels(_('Table'), _('Cancel'))
> @@ -234,7 +235,7 @@ class InsertToolbar(gtk.Toolbar):
>         def cb(object):
>             logging.debug('ObjectChooser: %r' % object)
>             self._abiword_canvas.insert_image(object.file_path, True)
> -        chooser.pick(what=chooser.IMAGE, cb=cb)
> +        chooser.pick(parent=self._parent, what=chooser.IMAGE, cb=cb)
>
>     def _table_cb(self, abi, rows, cols):
>         self._abiword_canvas.insert_table(rows, cols)
> --
> 1.7.2.3
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>


More information about the Sugar-devel mailing list