Top | ![]() |
![]() |
![]() |
![]() |
GtkWidget * | gtk_accel_label_new () |
guint | gtk_accel_label_get_accel_width () |
void | gtk_accel_label_set_accel () |
void | gtk_accel_label_get_accel () |
gboolean | gtk_accel_label_refetch () |
void | gtk_accel_label_set_label () |
const char * | gtk_accel_label_get_label () |
GtkAccelLabel implements AtkImplementorIface, GtkBuildable and GtkConstraintTarget.
The GtkAccelLabel is a widget that shows an accelerator next to a description of said accelerator, e.g. “Save Document Ctrl+S”. It is commonly used in menus to show the keyboard short-cuts for commands.
The accelerator key to display is typically not set explicitly (although it
can be, with gtk_accel_label_set_accel()
). Instead, the GtkAccelLabel displays
the accelerators which have been added to a particular widget. This widget is
set by calling gtk_accel_label_set_accel_widget()
.
For example, a menu item may have an accelerator added to emit
the “activate” signal when the “Ctrl+S” key combination is pressed.
A GtkAccelLabel is created and added to the menu item widget, and
gtk_accel_label_set_accel_widget()
is called with the item as the
second argument. The GtkAccelLabel will now display “Ctrl+S” after its label.
Note that accel labels are typically set up automatically when menus are created.
A GtkAccelLabel will only display accelerators which have GTK_ACCEL_VISIBLE
set (see GtkAccelFlags).
A GtkAccelLabel can display multiple accelerators and even signal names,
though it is almost always used to display just one accelerator key.
1 2 3 |
accellabel ├── label ╰── accelerator |
GtkAccelLabel has a main CSS node with the name accellabel. It contains the two child nodes with name label and accelerator.
GtkWidget *
gtk_accel_label_new (const gchar *string
);
Creates a new GtkAccelLabel.
guint
gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label
);
Returns the width needed to display the accelerator key(s). This is used by menus to align all of the menu item widgets, and shouldn't be needed by applications.
void gtk_accel_label_set_accel (GtkAccelLabel *accel_label
,guint accelerator_key
,GdkModifierType accelerator_mods
);
Manually sets a keyval and modifier mask as the accelerator rendered
by accel_label
.
If a keyval and modifier are explicitly set then these values are used regardless of any associated accel closure or widget.
Providing an accelerator_key
of 0 removes the manual setting.
void gtk_accel_label_get_accel (GtkAccelLabel *accel_label
,guint *accelerator_key
,GdkModifierType *accelerator_mods
);
Gets the keyval and modifier mask set with
gtk_accel_label_set_accel()
.
gboolean
gtk_accel_label_refetch (GtkAccelLabel *accel_label
);
Recreates the string representing the accelerator keys. This should not be needed since the string is automatically updated whenever accelerators are added or removed from the associated widget.
void gtk_accel_label_set_label (GtkAccelLabel *accel_label
,const char *text
);
Sets the label part of the accel label.
const char *
gtk_accel_label_get_label (GtkAccelLabel *accel_label
);
Returns the current label, set via gtk_accel_label_set_label()