Synopsis
#include <gtk/gtk.h>
GtkMenuShell;
void gtk_menu_shell_append (GtkMenuShell *menu_shell,
GtkWidget *child);
void gtk_menu_shell_prepend (GtkMenuShell *menu_shell,
GtkWidget *child);
void gtk_menu_shell_insert (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position);
void gtk_menu_shell_deactivate (GtkMenuShell *menu_shell);
void gtk_menu_shell_select_item (GtkMenuShell *menu_shell,
GtkWidget *menu_item);
void gtk_menu_shell_select_first (GtkMenuShell *menu_shell,
gboolean search_sensitive);
void gtk_menu_shell_deselect (GtkMenuShell *menu_shell);
void gtk_menu_shell_activate_item (GtkMenuShell *menu_shell,
GtkWidget *menu_item,
gboolean force_deactivate);
void gtk_menu_shell_cancel (GtkMenuShell *menu_shell);
void gtk_menu_shell_set_take_focus (GtkMenuShell *menu_shell,
gboolean take_focus);
gboolean gtk_menu_shell_get_take_focus (GtkMenuShell *menu_shell);
enum GtkMenuDirectionType;
Object Hierarchy
GObject
+----GInitiallyUnowned
+----GtkObject
+----GtkWidget
+----GtkContainer
+----GtkMenuShell
+----GtkMenuBar
+----GtkMenu
Signals"activate-current" : Run Last / Action "cancel" : Run Last / Action "cycle-focus" : Run Last / Action "deactivate" : Run First "move-current" : Run Last / Action "move-selected" : Run Last "selection-done" : Run First DescriptionA GtkMenuShell is the abstract base class used to derive the GtkMenu and GtkMenuBar subclasses. A GtkMenuShell is a container of GtkMenuItem objects arranged in a list which can be navigated, selected, and activated by the user to perform application functions. A GtkMenuItem can have a submenu associated with it, allowing for nested hierarchical menus. DetailsGtkMenuShelltypedef struct _GtkMenuShell GtkMenuShell; The GtkMenuShell struct contains the following fields. (These fields should be considered read-only. They should never be set by an application.)
gtk_menu_shell_append ()void gtk_menu_shell_append (GtkMenuShell *menu_shell, GtkWidget *child); Adds a new GtkMenuItem to the end of the menu shell's item list.
gtk_menu_shell_prepend ()void gtk_menu_shell_prepend (GtkMenuShell *menu_shell, GtkWidget *child); Adds a new GtkMenuItem to the beginning of the menu shell's item list.
gtk_menu_shell_insert ()void gtk_menu_shell_insert (GtkMenuShell *menu_shell, GtkWidget *child, gint position);
Adds a new GtkMenuItem to the menu shell's item list at the position
indicated by
gtk_menu_shell_deactivate ()void gtk_menu_shell_deactivate (GtkMenuShell *menu_shell); Deactivates the menu shell. Typically this results in the menu shell being erased from the screen.
gtk_menu_shell_select_item ()void gtk_menu_shell_select_item (GtkMenuShell *menu_shell, GtkWidget *menu_item); Selects the menu item from the menu shell.
gtk_menu_shell_select_first ()void gtk_menu_shell_select_first (GtkMenuShell *menu_shell, gboolean search_sensitive); Select the first visible or selectable child of the menu shell; don't select tearoff items unless the only item is a tearoff item.
Since 2.2 gtk_menu_shell_deselect ()void gtk_menu_shell_deselect (GtkMenuShell *menu_shell); Deselects the currently selected item from the menu shell, if any.
gtk_menu_shell_activate_item ()void gtk_menu_shell_activate_item (GtkMenuShell *menu_shell, GtkWidget *menu_item, gboolean force_deactivate); Activates the menu item within the menu shell.
gtk_menu_shell_cancel ()void gtk_menu_shell_cancel (GtkMenuShell *menu_shell); Cancels the selection within the menu shell.
Since 2.4 gtk_menu_shell_set_take_focus ()void gtk_menu_shell_set_take_focus (GtkMenuShell *menu_shell, gboolean take_focus);
If
Setting
The
Note that setting it to If the focus is in some other app, it keeps the focus and keynav in the menu doesn't work. Consequently, keynav on the menu will only work if the focus is on some toplevel owned by the onscreen keyboard.
To avoid confusing the user, menus with
See also
Since 2.8 gtk_menu_shell_get_take_focus ()gboolean gtk_menu_shell_get_take_focus (GtkMenuShell *menu_shell);
Returns
Since 2.8 enum GtkMenuDirectionTypetypedef enum
{
GTK_MENU_DIR_PARENT,
GTK_MENU_DIR_CHILD,
GTK_MENU_DIR_NEXT,
GTK_MENU_DIR_PREV
} GtkMenuDirectionType;
An enumeration representing directional movements within a menu.
Property DetailsThe
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
the object which received the signal. |
|
if TRUE, hide the menu after activating the menu item. |
|
user data set when the signal handler was connected. |
"cancel" signalvoid user_function (GtkMenuShell *menushell, gpointer user_data) : Run Last / Action
An action signal which cancels the selection within the menu shell. Causes the GtkMenuShell::selection-done signal to be emitted.
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"cycle-focus" signalvoid user_function (GtkMenuShell *menushell, GtkDirectionType arg1, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
|
|
user data set when the signal handler was connected. |
"deactivate" signalvoid user_function (GtkMenuShell *menushell, gpointer user_data) : Run First
This signal is emitted when a menu shell is deactivated.
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"move-current" signalvoid user_function (GtkMenuShell *menushell, GtkMenuDirectionType direction, gpointer user_data) : Run Last / Action
An action signal which moves the current menu item in the direction
specified by direction.
|
the object which received the signal. |
|
the direction to move. |
|
user data set when the signal handler was connected. |
"move-selected" signalgboolean user_function (GtkMenuShell *menu_shell, gint distance, gpointer user_data) : Run Last
The ::move-selected signal is emitted to move the selection to another item.
|
the object on which the signal is emitted |
|
+1 to move to the next item, -1 to move to the previous |
|
user data set when the signal handler was connected. |
Returns : |
TRUE to stop the signal emission, FALSE to continue
|
Since 2.12
"selection-done" signalvoid user_function (GtkMenuShell *menushell, gpointer user_data) : Run First
This signal is emitted when a selection has been completed within a menu shell.
|
the object which received the signal. |
|
user data set when the signal handler was connected. |