Toc Gallery Index Tree Gtk.Accel_Label

Screenshot

No screeshot

Hierarchy

Description

The Gtk_Accel_Label widget is a child of 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 displays the accelerators which have been added to a particular widget. This widget is set by calling Set_Accel_Widget.

For example, a 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 is created and added to the Gtk_Menu_Item, and Set_Accel_Widget is called with the Gtk_Menu_Item as the second argument. The Gtk_Accel_Label will now display 'Ctl+S' after its label.

Note that creating a Gtk_Menu_Item with Gtk_New and a non null "label" parameter (ditto for Gtk_Check_Menu_Item and Gtk_Radio_Menu_Item) automatically adds a Gtk_Accel_Label to the Gtk_Menu_Item and calls Set_Accel_Widget to set it up for you.

A Gtk_Accel_Label will only display accelerators which have the Accel_Visible (see Gtk.Accel_Group) flag set. A Gtk_Accel_Label can display multiple accelerators and even signal names, though it is almost always used to display just one accelerator key.

Types

  • type Gtk_Accel_Label is access all Gtk_Accel_Label_Record;
  • type Gtk_Accel_Label_Record is new Gtk.Label.Gtk_Label_Record with private;

Subprograms

  • procedure Gtk_New (Accel_Label : out Gtk_Accel_Label; Str : UTF8_String);
    Create a new Gtk_Accel_Label. Str is the label string.
  • procedure Initialize (Accel_Label : access Gtk_Accel_Label_Record'Class; Str : UTF8_String);
    Internal initialization function. See the section "Creating your own widgets" in the documentation.
  • function Get_Type return Gtk.Gtk_Type;
    Return the internal value associated with a Gtk_Accel_Label.
  • procedure Set_Accel_Widget (Accel_Label : access Gtk_Accel_Label_Record; Accel_Widget : access Gtk.Widget.Gtk_Widget_Record'Class);
    Add an accelerator to a particular widget.
  • function Get_Accel_Widget (Accel_Label : access Gtk_Accel_Label_Record) return Gtk.Widget.Gtk_Widget;
    Return the widget monitored by Accel_Label.
  • function Get_Accel_Width (Accel_Label : access Gtk_Accel_Label_Record) return Guint;
    Return the width needed to display the accelerator key(s). This is used by menus to align all of the Gtk_Menu_Item widgets, and shouldn't be needed by applications.
  • function Refetch (Accel_Label : access Gtk_Accel_Label_Record) return Boolean;
    Recreate 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. Always return False.

Signals

Properties

Example

Creating a simple menu item with an accelerator key. Save_Item : Gtk_Menu_Item; Accel_Group : Gtk_Accel_Group; -- Create a Gtk_Accel_Group and add it to the window. Gtk_New (Accel_Group); Add_Accel_Group (Window, Accel_Group); -- Create the menu item using the convenience function. Gtk_New (Save_Item, "Save"); Show (Save_Item); Add (Menu, Save_Item); -- Now add the accelerator to the Gtk_Menu_Item. Note that since we called -- Gtk_New with a label to create the Gtk_Menu_Item the -- Gtk_Accel_Label is automatically set up to display the Gtk_Menu_Item -- accelerators. We just need to make sure we use Accel_Visible here. Add_Accelerator (Save_Item, "activate", Accel_Group, GDK_S, Control_Mask, Accel_Visible);

Alphabetical Index