1999-08-16 18:51:52 +00:00
|
|
|
<!-- ##### SECTION Title ##### -->
|
|
|
|
GtkAccelLabel
|
|
|
|
|
|
|
|
<!-- ##### SECTION Short_Description ##### -->
|
1999-09-22 21:30:57 +00:00
|
|
|
a label which displays an accelerator key on the right of the text.
|
1999-08-16 18:51:52 +00:00
|
|
|
|
|
|
|
<!-- ##### SECTION Long_Description ##### -->
|
|
|
|
<para>
|
1999-09-22 21:30:57 +00:00
|
|
|
The #GtkAccelLabel widget is a subclass of #GtkLabel that also displays an
|
|
|
|
accelerator key on the right of the label text, e.g. 'Ctl+S'.
|
|
|
|
It is commonly used in menus to show the keyboard short-cuts for commands.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
The accelerator key to display is not set explicitly.
|
|
|
|
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().
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
For example, a #GtkMenuItem widget may have an accelerator added to emit the
|
|
|
|
"activate" signal when the 'Ctl+S' key combination is pressed.
|
|
|
|
A #GtkAccelLabel is created and added to the #GtkMenuItem, and
|
|
|
|
gtk_accel_label_set_accel_widget() is called with the #GtkMenuItem as the
|
|
|
|
second argument. The #GtkAccelLabel will now display 'Ctl+S' after its label.
|
1999-08-16 18:51:52 +00:00
|
|
|
</para>
|
1999-09-22 21:30:57 +00:00
|
|
|
<para>
|
|
|
|
Note that creating a #GtkMenuItem with gtk_menu_item_new_with_label() (or
|
|
|
|
one of the similar functions for #GtkCheckMenuItem and #GtkRadioMenuItem)
|
|
|
|
automatically adds a #GtkAccelLabel to the #GtkMenuItem and calls
|
|
|
|
gtk_accel_label_set_accel_widget() to set it up for you.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
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.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<example>
|
|
|
|
<title>Creating a simple menu item with an accelerator key.</title>
|
|
|
|
<programlisting>
|
|
|
|
GtkWidget *save_item;
|
|
|
|
GtkAccelGroup *accel_group;
|
|
|
|
|
|
|
|
/* Create a #GtkAccelGroup and add it to the window. */
|
|
|
|
accel_group = gtk_accel_group_new ();
|
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
|
|
|
|
|
|
|
/* Create the menu item using the convenience function. */
|
|
|
|
save_item = gtk_menu_item_new_with_label ("Save");
|
|
|
|
gtk_widget_show (save_item);
|
|
|
|
gtk_container_add (GTK_CONTAINER (menu), save_item);
|
|
|
|
|
|
|
|
/* Now add the accelerator to the #GtkMenuItem. Note that since we called
|
|
|
|
gtk_menu_item_new_with_label() to create the #GtkMenuItem the
|
|
|
|
#GtkAccelLabel is automatically set up to display the #GtkMenuItem
|
|
|
|
accelerators. We just need to make sure we use GTK_ACCEL_VISIBLE here. */
|
|
|
|
gtk_widget_add_accelerator (save_item, "activate", accel_group,
|
|
|
|
GDK_s, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
1999-08-16 18:51:52 +00:00
|
|
|
|
|
|
|
<!-- ##### SECTION See_Also ##### -->
|
|
|
|
<para>
|
1999-09-22 21:30:57 +00:00
|
|
|
<variablelist>
|
1999-08-16 18:51:52 +00:00
|
|
|
|
1999-09-22 21:30:57 +00:00
|
|
|
<varlistentry>
|
|
|
|
<term><link linkend="gtk-keyboard-accelerators">Keyboard Accelerators</link>
|
|
|
|
</term>
|
|
|
|
<listitem><para>installing and using keyboard short-cuts.</para></listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term>#GtkItemFactory</term>
|
|
|
|
<listitem><para>an easier way to create menus.</para></listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
</variablelist>
|
1999-08-16 18:51:52 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<!-- ##### STRUCT GtkAccelLabel ##### -->
|
|
|
|
<para>
|
1999-09-22 21:30:57 +00:00
|
|
|
The #GtkAccelLabel-struct struct contains private data only, and
|
|
|
|
should be accessed using the functions below.
|
1999-08-16 18:51:52 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gtk_accel_label_new ##### -->
|
|
|
|
<para>
|
1999-09-22 21:30:57 +00:00
|
|
|
Creates a new #GtkAccelLabel.
|
1999-08-16 18:51:52 +00:00
|
|
|
</para>
|
|
|
|
|
1999-09-22 21:30:57 +00:00
|
|
|
@string: the label string.
|
|
|
|
@Returns: a new #GtkAccelLabel.
|
1999-08-16 18:51:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gtk_accel_label_set_accel_widget ##### -->
|
|
|
|
<para>
|
1999-09-22 21:30:57 +00:00
|
|
|
Sets the widget whose accelerators are to be shown.
|
1999-08-16 18:51:52 +00:00
|
|
|
</para>
|
|
|
|
|
1999-09-22 21:30:57 +00:00
|
|
|
@accel_label: a #GtkAccelLabel.
|
|
|
|
@accel_widget: the widget whose accelerators are to be displayed.
|
1999-08-16 18:51:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gtk_accel_label_get_accel_width ##### -->
|
|
|
|
<para>
|
1999-09-22 21:30:57 +00:00
|
|
|
Returns the width needed to display the accelerator key(s).
|
|
|
|
This is used by menus to align all of the #GtkMenuItem widgets, and shouldn't
|
|
|
|
be needed by applications.
|
1999-08-16 18:51:52 +00:00
|
|
|
</para>
|
|
|
|
|
1999-09-22 21:30:57 +00:00
|
|
|
@accel_label: a #GtkAccelLabel.
|
1999-08-16 18:51:52 +00:00
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gtk_accel_label_refetch ##### -->
|
|
|
|
<para>
|
1999-09-22 21:30:57 +00:00
|
|
|
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.
|
1999-08-16 18:51:52 +00:00
|
|
|
</para>
|
|
|
|
|
1999-09-22 21:30:57 +00:00
|
|
|
@accel_label: a #GtkAccelLabel.
|
|
|
|
@Returns: always returns FALSE.
|
1999-08-16 18:51:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### ARG GtkAccelLabel:accel_widget ##### -->
|
|
|
|
<para>
|
1999-09-22 21:30:57 +00:00
|
|
|
The widget whose accelerators are to be shown by the #GtkAccelLabel.
|
1999-08-16 18:51:52 +00:00
|
|
|
</para>
|
|
|
|
|