Gtk2::MenuItem(3)

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

πŸ’– Gtk2::MenuItem β€” the manual page, but make it cute πŸ’–

okay bestie, welcome to the Gtk2::MenuItem glow-up. this is the Perl wrapper for GtkMenuItem, from the User Contributed Perl Documentation section of your friendly neighbourhood man pages. she's a menu item. she's iconic. she has opinions about garbage collection. let's get into it πŸŽ€


✨ NAME ✨

Gtk2::MenuItem β€” it's a wrapper for GtkMenuItem, periodt πŸ’…


🌸 DESCRIPTION 🌸

okay so here's the tea, and it's important tea πŸ«–

If a MenuItem is created with a $label string, or if the "label" property is set later, then it should be destroyed with $item->destroy. Just dropping the last Perl ref is not enough, bestie. why? because (as of Gtk through to 2.18) there's a circular reference from the child Gtk2::AccelLabel back up to the item β€” it's the accel-widget property doing it. it's giving mutual obsession. it's giving neither of them will ever let go 😭

When a MenuItem is in a Gtk2::Menu a destroy happens automatically. Dropping the last ref to a Menu calls destroy on its children, as usual for a container. but β€” and this is the part where you gotta pay attention β€” if you remove a MenuItem with a label from a menu (or never add it to one) then be sure to $item->destroy explicitly. no cap. do it manually or she will simply never leave 🫢

πŸ’€ fr fr, this is the classic "why is my memory not freeing" jump scare. $item->destroy is your bestie here.

πŸ‘‘ HIERARCHY πŸ‘‘

look at this bloodline. generational. the ancestry is impeccable ✨

Glib::Object
+----Glib::InitiallyUnowned
     +----Gtk2::Object
          +----Gtk2::Widget
               +----Gtk2::Container
                    +----Gtk2::Bin
                         +----Gtk2::Item
                              +----Gtk2::MenuItem

πŸ¦‹ INTERFACES πŸ¦‹

she's got range, she's multi-talented, she does it all πŸ’œ

Glib::Object::_Unregistered::AtkImplementorIface
Gtk2::Buildable
Gtk2::Activatable

πŸ’… METHODS πŸ’…

🌈 widget = Gtk2::MenuItem->new ($label=undef)

  • $label (string) β€” the label text, if you've got one

If a $label argument is given then this is new_with_mnemonic. sneaky little redirect but okay, we love a shortcut ✨

🌈 widget = Gtk2::MenuItem->new_with_label ($label=undef)

  • $label (string) β€” the label text, if you've got one

🌈 widget = Gtk2::MenuItem->new_with_mnemonic ($label=undef)

  • $label (string) β€” the label text, if you've got one

🌈 string = $menu_item->get_accel_path

Since: gtk+ 2.14 ⭐
  • $accel_path (string) β€” the accel path to set

just... activate. no args. she said "I'm doing it" πŸ’…

🌈 string = $menu_item->get_label

Since: gtk+ 2.16 ⭐
  • $label (string) β€” the new label
Since: gtk+ 2.16 ⭐

bye bye submenu πŸ¦‹

🌈 boolean = $menu_item->get_right_justified

  • $right_justified (boolean) β€” true or false, you decide

🌈 widget or undef = $menu_item->get_submenu

  • $submenu (Gtk2::Widget or undef) β€” the widget, or undef if she has none
  • $allocation (integer) β€” the allocation value

🌈 requisition = $menu_item->toggle_size_request

🌈 boolean = $menu_item->get_use_underline

Since: gtk+ 2.16 ⭐
  • $use_underline (boolean) β€” true or false
Since: gtk+ 2.16 ⭐

πŸŽ€ PROPERTIES πŸŽ€

the vibes, the settings, the whole personality 🫢

  • 'accel-path' (string : default undef : readable / writable / private / static-nick / static-blurb) β€” Sets the accelerator path of the menu item
  • 'label' (string : default "" : readable / writable / private / static-nick / static-blurb) β€” The text for the child label
  • 'right-justified' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” Sets whether the menu item appears justified at the right side of a menu bar
  • 'submenu' (Gtk2::Menu : default undef : readable / writable / private / static-nick / static-blurb) β€” The submenu attached to the menu item, or NULL if it has none
  • 'use-underline' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key

🌸 STYLE PROPERTIES 🌸

the aesthetic settings. the glow-up sliders. the ✨lewk✨

  • 'arrow-scaling' (float : default 0.8 : readable / private / static-nick / static-blurb) β€” Amount of space used up by arrow, relative to the menu item's font size
  • 'arrow-spacing' (integer : default 10 : readable / private / static-nick / static-blurb) β€” Space between label and arrow
  • 'horizontal-padding' (integer : default 3 : readable / private / static-nick / static-blurb) β€” Padding to left and right of the menu item
  • 'selected-shadow-type' (Gtk2::ShadowType : default "none" : readable / private / static-nick / static-blurb) β€” Shadow type when item is selected
  • 'toggle-spacing' (integer : default 5 : readable / private / static-nick / static-blurb) β€” Space between icon and label
  • 'width-chars' (integer : default 12 : readable / private / static-nick / static-blurb) β€” The minimum desired width of the menu item in characters

πŸ”₯ SIGNALS πŸ”₯

the events. the plot twists. the moments she reacts πŸ’€

  • activate (Gtk2::MenuItem)
  • activate-item (Gtk2::MenuItem)
  • toggle-size-allocate (Gtk2::MenuItem, integer)
  • toggle-size-request (Gtk2::MenuItem, gpointer)

πŸ¦‹ SEE ALSO πŸ¦‹

go read these next, bestie, iykyk πŸ’œ

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


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, bestie πŸŽ€ this was rendered by perl v5.42.0 on 2025-07-25, from Gtk2::MenuItem(3) β€” she ate and left no crumbs, no cap πŸŒˆβ­πŸ’…

πŸ“¦ where this page comes from