[sugar] How to get pygtk to give you a GtkToolTips from a Toolbar to pass to ToolItem's set_tooltip?
Mon May 21 22:58:25 EDT 2007
I'm trying to set the tooltip of a tool item, which I though would be
easy, but the ToolItem.set_tooltip takes a first parameter that's a
mysterious GtkTooltips object.
But I can't figure out how to get a reference to the required ToolTips
object to pass as a first argument to a ToolItem's set_tooltip(tooltips,
The obvious looking method GtkToolbar.get_tooltips() actually returns a
boolean that tells if the toolbar is using tooltips, but does not return
the toolbar's "GtkTooltips *tooltips" member, which is declared public
but apparently not exposed as a property to Python.
Is there an existing way to get a reference to the GtkTooltips object?
Or another way to set the tooltip of a ToolItem without passing in a
In desperation, I hacked pygtk to support a phantom
"toolbar.get_tooltips_object()" method that returns the toolbar's actual
It seems to work ok, and now I can get the tooltips object, then pass it
to set_tooltip without giving it indigestion, so now I'm getting tooltips!
Is this a change that should be added upstream to pygtk, or is there a
better way to do it? Would there be a better name for it?
Added to gtk-base.defs after the definition of "popup_context_menu":
Added to gtk.override at the end:
override gtk_toolbar_get_tooltips_object noargs
static PyObject *
ret = GTK_TOOLBAR(self->obj)->tooltips;
/* pygobject_new handles NULL checking */
return pygobject_new((GObject *)ret);
I'm kind of winging it with the pygtk-codegen stuff.
It's not very well documented, so I read the code to figure out how it
works, and took some notes.
It would be great if somebody who's more familiar with it could
elaborate on it and correct any mistakes, please!
I've put the notes up on the olpc wiki!
More information about the Sugar-devel