Gtk2::Toolbar(3)

πŸ“¦
version 1.24993 Β· 2 versions
, in fedora 43

πŸ’– Gtk2::Toolbar πŸ’–

okay bestie, come SIT. this is the wrapper for GtkToolbar and it's literally the little strip of buttons/icons at the top of your app that you've been staring at your whole life without knowing its name. we're gonna get you fluent. no cap.


✨ HIERARCHY ✨

the family tree, and yes she has main character energy all the way up:

Glib::Object
+----Glib::InitiallyUnowned
     +----Gtk2::Object
          +----Gtk2::Widget
               +----Gtk2::Container
                    +----Gtk2::Toolbar

πŸ¦‹ INTERFACES πŸ¦‹

she's multi-talented, she collects these like friendship bracelets:

Glib::Object::_Unregistered::AtkImplementorIface
Gtk2::Buildable
Gtk2::ToolShell
Gtk2::Orientable

🌸 METHODS 🌸

widget = Gtk2::Toolbar->new

make a fresh toolbar. brand new, no items, full of potential 🫢


widget = $toolbar->append_element ($type, $widget, $text, $tooltip_text, $tooltip_private_text, $icon, $callback=undef, $user_data=undef)

add an element to the end of the toolbar. here's the whole menu of what you're passing:

  • $type (Gtk2::ToolbarChildType) β€” what kind of thing it is
  • $widget (Gtk2::Widget or undef)
  • $text (string)
  • $tooltip_text (string or undef)
  • $tooltip_private_text (string or undef)
  • $icon (Gtk2::Widget or undef)
  • $callback (subroutine)
  • $user_data (scalar)

widget = $toolbar->append_item ($text, $tooltip_text, $tooltip_private_text, $icon, $callback=undef, $user_data=undef)

same energy, but the item version. args:

  • $text (string)
  • $tooltip_text (string or undef)
  • $tooltip_private_text (string or undef)
  • $icon (Gtk2::Widget or undef)
  • $callback (subroutine)
  • $user_data (scalar)

$toolbar->append_space

just vibes. a lil blank space at the end. that's it, that's the method πŸ’…


$toolbar->append_widget ($widget, $tooltip_text, $tooltip_private_text)

stick a whole widget on the end:

  • $widget (Gtk2::Widget)
  • $tooltip_text (string or undef)
  • $tooltip_private_text (string or undef)

$toolbar->set_drop_highlight_item ($tool_item, $index)

  • $tool_item (Gtk2::ToolItem or undef)
  • $index (integer)
Since: gtk+ 2.4

integer = $toolbar->get_drop_index ($x, $y)

  • $x (integer)
  • $y (integer)
Since: gtk+ 2.4

iconsize = $toolbar->get_icon_size

$toolbar->set_icon_size ($icon_size)

  • $icon_size (Gtk2::IconSize)

get/set how chonky the icons are.


$toolbar->insert ($item, $pos)

  • $item (Gtk2::ToolItem)
  • $pos (integer)
Since: gtk+ 2.4

widget = $toolbar->insert_element ($type, $widget, $text, $tooltip_text, $tooltip_private_text, $icon, $callback, $user_data, $position)

insert an element at a specific spot. args:

  • $type (Gtk2::ToolbarChildType)
  • $widget (Gtk2::Widget or undef)
  • $text (string)
  • $tooltip_text (string or undef)
  • $tooltip_private_text (string or undef)
  • $icon (Gtk2::Widget or undef)
  • $callback (subroutine)
  • $user_data (scalar)
  • $position (integer)

widget = $toolbar->insert_item ($text, $tooltip_text, $tooltip_private_text, $icon, $callback, $user_data, $position)

  • $text (string)
  • $tooltip_text (string or undef)
  • $tooltip_private_text (string or undef)
  • $icon (Gtk2::Widget or undef)
  • $callback (subroutine)
  • $user_data (scalar)
  • $position (integer)

$toolbar->insert_space ($position)

  • $position (integer)

a lil gap, but make it ✨located✨.


widget = $toolbar->insert_stock ($stock_id, $tooltip_text, $tooltip_private_text, $callback, $user_data, $position)

  • $stock_id (string)
  • $tooltip_text (string or undef)
  • $tooltip_private_text (string or undef)
  • $callback (subroutine)
  • $user_data (scalar)
  • $position (integer)

$toolbar->insert_widget ($widget, $tooltip_text, $tooltip_private_text, $position)

  • $widget (Gtk2::Widget)
  • $tooltip_text (string or undef)
  • $tooltip_private_text (string or undef)
  • $position (integer)

integer = $toolbar->get_item_index ($item)

  • $item (Gtk2::ToolItem)
Since: gtk+ 2.4

integer = $toolbar->get_n_items

Since: gtk+ 2.4

how many items bestie? this tells you.


toolitem or undef = $toolbar->get_nth_item ($n)

  • $n (integer)
Since: gtk+ 2.4

orientation = $toolbar->get_orientation

$toolbar->set_orientation ($orientation)

  • $orientation (Gtk2::Orientation)

horizontal or vertical, pick your vibe.


widget = $toolbar->prepend_element ($type, $widget, $text, $tooltip_text, $tooltip_private_text, $icon, $callback=undef, $user_data=undef)

same as append_element but it goes at the front. args:

  • $type (Gtk2::ToolbarChildType)
  • $widget (Gtk2::Widget or undef)
  • $text (string)
  • $tooltip_text (string or undef)
  • $tooltip_private_text (string or undef)
  • $icon (Gtk2::Widget or undef)
  • $callback (subroutine)
  • $user_data (scalar)

widget = $toolbar->prepend_item ($text, $tooltip_text, $tooltip_private_text, $icon, $callback=undef, $user_data=undef)

  • $text (string)
  • $tooltip_text (string or undef)
  • $tooltip_private_text (string or undef)
  • $icon (Gtk2::Widget or undef)
  • $callback (subroutine)
  • $user_data (scalar)

$toolbar->prepend_space

a lil space, but at the front. iconic.


$toolbar->prepend_widget ($widget, $tooltip_text, $tooltip_private_text)

  • $widget (Gtk2::Widget)
  • $tooltip_text (string or undef)
  • $tooltip_private_text (string or undef)

reliefstyle = $toolbar->get_relief_style

Since: gtk+ 2.4

$toolbar->remove_space ($position)

  • $position (integer)

yeet that gap.


boolean = $toolbar->get_show_arrow

Since: gtk+ 2.4

$toolbar->set_show_arrow ($show_arrow)

  • $show_arrow (boolean)
Since: gtk+ 2.4

toolbarstyle = $toolbar->get_style

$toolbar->set_style ($style)

  • $style (Gtk2::ToolbarStyle)

boolean = $toolbar->get_tooltips

$toolbar->set_tooltips ($enable)

  • $enable (boolean)

$toolbar->unset_icon_size

$toolbar->unset_style

no more custom icon size / no more custom style. back to defaults, we love a reset 🧚


πŸŽ€ PROPERTIES πŸŽ€

  • 'icon-size' (integer : default 3 : readable / writable / private / static-nick / static-blurb) β€” Size of icons in this toolbar
  • 'icon-size-set' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” Whether the icon-size property has been set
  • 'show-arrow' (boolean : default true : readable / writable / private / static-nick / static-blurb) β€” If an arrow should be shown if the toolbar doesn't fit
  • 'toolbar-style' (Gtk2::ToolbarStyle : default "both" : readable / writable / private / static-nick / static-blurb) β€” How to draw the toolbar
  • 'tooltips' (boolean : default true : readable / writable / private / static-nick / static-blurb) β€” If the tooltips of the toolbar should be active or not

🧸 CHILD PROPERTIES 🧸

  • 'expand' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” Whether the item should receive extra space when the toolbar grows
  • 'homogeneous' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” Whether the item should be the same size as other homogeneous items

πŸ’… STYLE PROPERTIES πŸ’…

these ones are readable / private only, so look but don't touch:

  • 'button-relief' (Gtk2::ReliefStyle : default "none" : readable / private / static-nick / static-blurb) β€” Type of bevel around toolbar buttons
  • 'internal-padding' (integer : default 0 : readable / private / static-nick / static-blurb) β€” Amount of border space between the toolbar shadow and the buttons
  • 'max-child-expand' (integer : default INT_MAX : readable / private / static-nick / static-blurb) β€” Maximum amount of space an expandable item will be given
  • 'shadow-type' (Gtk2::ShadowType : default "out" : readable / private / static-nick / static-blurb) β€” Style of bevel around the toolbar
  • 'space-size' (integer : default 12 : readable / private / static-nick / static-blurb) β€” Size of spacers
  • 'space-style' (Gtk2::ToolbarSpaceStyle : default "line" : readable / private / static-nick / static-blurb) β€” Whether spacers are vertical lines or just blank

🌈 SIGNALS 🌈

  • boolean = focus-home-or-end (Gtk2::Toolbar, boolean)
  • orientation-changed (Gtk2::Toolbar, Gtk2::Orientation)
  • boolean = popup-context-menu (Gtk2::Toolbar, integer, integer, integer)
  • style-changed (Gtk2::Toolbar, Gtk2::ToolbarStyle)

⭐ ENUMS AND FLAGS ⭐

enum Gtk2::IconSize

  • 'invalid' / 'GTK_ICON_SIZE_INVALID'
  • 'menu' / 'GTK_ICON_SIZE_MENU'
  • 'small-toolbar' / 'GTK_ICON_SIZE_SMALL_TOOLBAR'
  • 'large-toolbar' / 'GTK_ICON_SIZE_LARGE_TOOLBAR'
  • 'button' / 'GTK_ICON_SIZE_BUTTON'
  • 'dnd' / 'GTK_ICON_SIZE_DND'
  • 'dialog' / 'GTK_ICON_SIZE_DIALOG'

enum Gtk2::Orientation

  • 'horizontal' / 'GTK_ORIENTATION_HORIZONTAL'
  • 'vertical' / 'GTK_ORIENTATION_VERTICAL'

enum Gtk2::ReliefStyle

  • 'normal' / 'GTK_RELIEF_NORMAL'
  • 'half' / 'GTK_RELIEF_HALF'
  • 'none' / 'GTK_RELIEF_NONE'

enum Gtk2::ToolbarChildType

  • 'space' / 'GTK_TOOLBAR_CHILD_SPACE'
  • 'button' / 'GTK_TOOLBAR_CHILD_BUTTON'
  • 'togglebutton' / 'GTK_TOOLBAR_CHILD_TOGGLEBUTTON'
  • 'radiobutton' / 'GTK_TOOLBAR_CHILD_RADIOBUTTON'
  • 'widget' / 'GTK_TOOLBAR_CHILD_WIDGET'

enum Gtk2::ToolbarStyle

  • 'icons' / 'GTK_TOOLBAR_ICONS'
  • 'text' / 'GTK_TOOLBAR_TEXT'
  • 'both' / 'GTK_TOOLBAR_BOTH'
  • 'both-horiz' / 'GTK_TOOLBAR_BOTH_HORIZ'

πŸ”₯ SEE ALSO πŸ”₯

go read these next, bestie, they're the whole friend group:

Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget, Gtk2::Container


Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL. See Gtk2 for a full notice.


and that's the whole page, periodt πŸ’– this one's from the gtk2-perl docs, perl v5.42.0, dated 2025-07-25 β€” go forth and build the slayest toolbar, i'm obsessed with you already 🫢✨

πŸ“¦ where this page comes from