package Implements_Gtk_Buildable is new Glib.Types.Implements (Gtk.Buildable.Gtk_Buildable, Gtk_Accel_Label_Record, Gtk_Accel_Label);
type Gtk_Accel_Label_Record is new Gtk_Label_Record with null record;
type Gtk_Accel_Label is access all Gtk_Accel_Label_Record'Class;
Accel_Closure_Property : constant Glib.Properties.Property_String := Glib.Properties.Build ("accel-closure");
Accel_Widget_Property : constant Glib.Properties.Property_Object;
procedure Gtk_New
( | Accel_Label | : out Gtk_Accel_Label; |
String | : UTF8_String); |
procedure Initialize
( | Accel_Label | : not null access Gtk_Accel_Label_Record'Class; |
String | : UTF8_String); |
function Gtk_Accel_Label_New
( | String | : UTF8_String) return Gtk_Accel_Label; |
function Get_Type return Glib.GType;
function Get_Accel_Widget
( | Accel_Label | : not null access Gtk_Accel_Label_Record) return Gtk.Widget.Gtk_Widget; |
procedure Set_Accel_Widget
( | Accel_Label | : not null access Gtk_Accel_Label_Record; |
Accel_Widget | : not null access Gtk.Widget.Gtk_Widget_Record'Class); |
function Get_Accel_Width
( | Accel_Label | : not null access Gtk_Accel_Label_Record) return Guint; |
function Refetch
( | Accel_Label | : not null access Gtk_Accel_Label_Record) return Boolean; |
procedure Set_Accel
( | Accel_Label | : not null access Gtk_Accel_Label_Record; |
Accelerator_Key | : Guint; | |
Accelerator_Mods | : Gdk.Types.Gdk_Modifier_Type); |
procedure Set_Accel_Closure
( | Accel_Label | : not null access Gtk_Accel_Label_Record; |
Accel_Closure | : System.Address); |
function "+"
( | Widget | : access Gtk_Accel_Label_Record'Class) return Gtk.Buildable.Gtk_Buildable renames Implements_Gtk_Buildable.To_Interface; |
function "-"
( | Interf | : Gtk.Buildable.Gtk_Buildable) return Gtk_Accel_Label renames Implements_Gtk_Buildable.To_Object; |
The Gtk.Accel_Label.Gtk_Accel_Label widget is a subclass of Gtk.Label.Gtk_Label 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.
The accelerator key to display is not set explicitly. Instead, the Gtk.Accel_Label.Gtk_Accel_Label 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 Gtk.Menu_Item.Gtk_Menu_Item widget may have an accelerator added to emit the "activate" signal when the 'Ctl+S' key combination is pressed. A Gtk.Accel_Label.Gtk_Accel_Label is created and added to the Gtk.Menu_Item.Gtk_Menu_Item, and Gtk.Accel_Label.Set_Accel_Widget is called with the Gtk.Menu_Item.Gtk_Menu_Item as the second argument. The Gtk.Accel_Label.Gtk_Accel_Label will now display 'Ctl+S' after its label.
Note that creating a Gtk.Menu_Item.Gtk_Menu_Item with Gtk.Menu_Item.Gtk_New_With_Label (or one of the similar functions for Gtk.Check_Menu_Item.Gtk_Check_Menu_Item and Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item) automatically adds a Gtk.Accel_Label.Gtk_Accel_Label to the Gtk.Menu_Item.Gtk_Menu_Item and calls Gtk.Accel_Label.Set_Accel_Widget to set it up for you.
A Gtk.Accel_Label.Gtk_Accel_Label will only display accelerators which have Gtk.Target_List.Accel_Visible set (see Gtk.Accel_Group.Gtk_Accel_Flags). A Gtk.Accel_Label.Gtk_Accel_Label can display multiple accelerators and even signal names, though it is almost always used to display just one accelerator key. == Creating a simple menu item with an accelerator key. == 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_KEY_s, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);