GtkToolbar::insert_element
Inserts a new toolbar element at the given position.
This is the base function for all other insert/append/prepend functions.
The widget_type determines which type of widget
shall be inserted/created. widget has to be set
if widget_type is set to GTK_TOOLBAR_CHILD_WIDGET.
All other types require a null as widget
because they are created by the function.
button_text specifies the text ("label") to be visible
on the button, tooltip_text is the tooltip text which will
be visible when the user hovers the button for a specific time.
tooltip_private_text is the text being visible using
a GtkTipsQuery. See GtkTooltips
for more details on this topic.
icon is a widget, preferably a GtkPixmap
which shall be used as an icon. The icon is used when the GtkToolbarStyle
is set to icon or
both (only with widgets created by insert_element).
You can use every type of widget, but take care that
the toolbar button can be identified by it when the style is icon only.
If the icon is set to null, the text will still be visible.
The position parameter can be in the range from 0 (insert
as first element) to the number of widgets (append after the last)
being on the toolbar. This can be determined by doing a
count( $toolbar->children()), but just an
append_element() should be more
easy.
Last parameter is callback, the function to be called
when the widget is clicked. You can pass a number of self-defined extra
parameters to the callback function by appending them after the callback parameter.
Example 46. Using the insert_element toolbar function
list($pixmap, $mask) = Gdk::pixmap_create_from_xpm($window->window, null, 'icon-new.xpm');
$newicon = &new GtkPixmap($pixmap, $mask);
$toolbar->insert_element(
GTK_TOOLBAR_CHILD_BUTTON,
'New',
'Create a new document',
"Closes the current document and\r\ncreates a new, empty one.",
$newicon,
0,
'toolbarClicked',
'new'
);
|