| GTK+ 3 Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#include <gtk/gtk.h> struct GtkMenuItem; GtkWidget * gtk_menu_item_new (void); GtkWidget * gtk_menu_item_new_with_label (const gchar *label); GtkWidget * gtk_menu_item_new_with_mnemonic (const gchar *label); void gtk_menu_item_set_right_justified (GtkMenuItem *menu_item,gboolean right_justified); gboolean gtk_menu_item_get_right_justified (GtkMenuItem *menu_item); const gchar * gtk_menu_item_get_label (GtkMenuItem *menu_item); void gtk_menu_item_set_label (GtkMenuItem *menu_item,const gchar *label); gboolean gtk_menu_item_get_use_underline (GtkMenuItem *menu_item); void gtk_menu_item_set_use_underline (GtkMenuItem *menu_item,gboolean setting); void gtk_menu_item_set_submenu (GtkMenuItem *menu_item,GtkWidget *submenu); GtkWidget * gtk_menu_item_get_submenu (GtkMenuItem *menu_item); void gtk_menu_item_set_accel_path (GtkMenuItem *menu_item,const gchar *accel_path); const gchar * gtk_menu_item_get_accel_path (GtkMenuItem *menu_item); void gtk_menu_item_select (GtkMenuItem *menu_item); void gtk_menu_item_deselect (GtkMenuItem *menu_item); void gtk_menu_item_activate (GtkMenuItem *menu_item); void gtk_menu_item_toggle_size_request (GtkMenuItem *menu_item,gint *requisition); void gtk_menu_item_toggle_size_allocate (GtkMenuItem *menu_item,gint allocation); gboolean gtk_menu_item_get_reserve_indicator (GtkMenuItem *menu_item); void gtk_menu_item_set_reserve_indicator (GtkMenuItem *menu_item,gboolean reserve);
GtkWidget * gtk_menu_item_new_with_mnemonic (const gchar *label);
Creates a new GtkMenuItem containing a label.
The label will be created using gtk_label_new_with_mnemonic(),
so underscores in label indicate the mnemonic for the menu item.
|
The text of the button, with an underscore in front of the mnemonic character |
Returns : |
a new GtkMenuItem |
void gtk_menu_item_set_right_justified (GtkMenuItem *menu_item,gboolean right_justified);
Sets whether the menu item appears justified at the right side of a menu bar. This was traditionally done for "Help" menu items, but is now considered a bad idea. (If the widget layout is reversed for a right-to-left language like Hebrew or Arabic, right-justified-menu-items appear at the left.)
|
a GtkMenuItem. |
|
if TRUE the menu item will appear at the
far right if added to a menu bar |
gboolean gtk_menu_item_get_right_justified (GtkMenuItem *menu_item);
Gets whether the menu item appears justified at the right side of the menu bar.
|
a GtkMenuItem |
Returns : |
TRUE if the menu item will appear at the
far right if added to a menu bar. |
const gchar * gtk_menu_item_get_label (GtkMenuItem *menu_item);
Sets text on the menu_item label
|
a GtkMenuItem |
Returns : |
The text in the menu_item label. This is the internal
string used by the label, and must not be modified. |
Since 2.16
void gtk_menu_item_set_label (GtkMenuItem *menu_item,const gchar *label);
Sets text on the menu_item label
|
a GtkMenuItem |
|
the text you want to set |
Since 2.16
gboolean gtk_menu_item_get_use_underline (GtkMenuItem *menu_item);
Checks if an underline in the text indicates the next character should be used for the mnemonic accelerator key.
|
a GtkMenuItem |
Returns : |
TRUE if an embedded underline in the label
indicates the mnemonic accelerator key. |
Since 2.16
void gtk_menu_item_set_use_underline (GtkMenuItem *menu_item,gboolean setting);
If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
|
a GtkMenuItem |
|
TRUE if underlines in the text indicate mnemonics |
Since 2.16
void gtk_menu_item_set_submenu (GtkMenuItem *menu_item,GtkWidget *submenu);
Sets or replaces the menu item's submenu, or removes it when a NULL
submenu is passed.
|
a GtkMenuItem |
|
the submenu, or NULL. [allow-none]
|
GtkWidget * gtk_menu_item_get_submenu (GtkMenuItem *menu_item);
Gets the submenu underneath this menu item, if any.
See gtk_menu_item_set_submenu().
|
a GtkMenuItem |
Returns : |
submenu for this menu item, or NULL if none. [transfer none]
|
void gtk_menu_item_set_accel_path (GtkMenuItem *menu_item,const gchar *accel_path);
Set the accelerator path on menu_item, through which runtime
changes of the menu item's accelerator caused by the user can be
identified and saved to persistent storage (see gtk_accel_map_save()
on this). To set up a default accelerator for this menu item, call
gtk_accel_map_add_entry() with the same accel_path. See also
gtk_accel_map_add_entry() on the specifics of accelerator paths,
and gtk_menu_set_accel_path() for a more convenient variant of
this function.
This function is basically a convenience wrapper that handles
calling gtk_widget_set_accel_path() with the appropriate accelerator
group for the menu item.
Note that you do need to set an accelerator on the parent menu with
gtk_menu_set_accel_group() for this to work.
Note that accel_path string will be stored in a GQuark.
Therefore, if you pass a static string, you can save some memory
by interning it first with g_intern_static_string().
|
a valid GtkMenuItem |
|
accelerator path, corresponding to this menu
item's functionality, or NULL to unset the current path. [allow-none]
|
const gchar * gtk_menu_item_get_accel_path (GtkMenuItem *menu_item);
Retrieve the accelerator path that was previously set on menu_item.
See gtk_menu_item_set_accel_path() for details.
|
a valid GtkMenuItem |
Returns : |
the accelerator path corresponding to this menu
item's functionality, or NULL if not set |
Since 2.14
void gtk_menu_item_toggle_size_request (GtkMenuItem *menu_item,gint *requisition);
void gtk_menu_item_toggle_size_allocate (GtkMenuItem *menu_item,gint allocation);
gboolean gtk_menu_item_get_reserve_indicator (GtkMenuItem *menu_item);
Returns whether the menu_item reserves space for
the submenu indicator, regardless if it has a submenu
or not.
|
a GtkMenuItem |
Returns : |
TRUE if menu_item always reserves space for the
submenu indicator |
Since 3.0
void gtk_menu_item_set_reserve_indicator (GtkMenuItem *menu_item,gboolean reserve);
Sets whether the menu_item should reserve space for
the submenu indicator, regardless if it actually has
a submenu or not.
There should be little need for applications to call this functions.
|
a GtkMenuItem |
|
the new value |
Since 3.0