Package: gtk
Class gtk-image-menu-item
Superclassesgtk-menu-item, gtk-bin, gtk-container, gtk-widget, gtk-buildable, gtk-activatable, g-object, common-lisp:standard-object, common-lisp:t Documented Subclasses
None
Direct SlotsDetails A gtk-image-menu-item widget is a menu item which has an icon next to
the text label.
This is functionally equivalent to:
(defun create-image-menu-item ()
(let ((box (make-instance 'gtk-box
:orientation :horizontal
:spacing 6))
(icon (make-instance 'gtk-image
:icon-name "folder-music-symbolic"
:icon-size 1))
(label (make-instance 'gtk-label
:label "Music"))
(menu-item (make-instance 'gtk-menu-item)))
(gtk-container-add box icon)
(gtk-container-add box label)
(gtk-container-add menu-item box)
menu-item))
Note that the user may disable display of menu icons using the gtk-menu-images setting, so make sure to still fill in
the text label. If you want to ensure that your menu items show an icon you are strongly encouraged to use a gtk-menu-item widget with a gtk-image widget instead.Furthermore, if you would like to display keyboard accelerator, you must pack the accel label into the box using the gtk-box-pack-end function and align the label, otherwise the accelerator will not display correctly. The following code snippet adds a keyboard accelerator to the menu item, with a key binding of the Ctrl+M key:
(defun create-image-menu-item-with-accel ()
(let ((box (make-instance 'gtk-box
:orientation :horizontal
:spacing 6))
(icon (make-instance 'gtk-image
:icon-name "folder-music-symbolic"
:icon-size 1))
(label (make-instance 'gtk-accel-label
:label "Music"
:use-underline t
:xalign 0.0))
(menu-item (make-instance 'gtk-menu-item))
(accel-group (make-instance 'gtk-accel-group)))
(gtk-widget-add-accelerator menu-item
"activate"
accel-group
(gdk-keyval-from-name "M")
:control-mask
:visible)
(setf (gtk-accel-label-accel-widget label) menu-item)
(gtk-container-add box icon)
(gtk-box-pack-end box label :expand t :fill t :padding 0)
(gtk-container-add menu-item box)
menu-item)) Warning | Slot Access Functions
Inherited Slot Access FunctionsSee also |
2021-7-21