GtkAccelLabel: GtkAccelLabel

Description Methods and Functions Hierarchy Interfaces Detailed Description Structures Convenient Construction Properties Author(s) References

Description

A label which displays an accelerator key on the right of the text

Methods and Functions

gtkAccelLabelNew(string = NULL, show = TRUE)
gtkAccelLabelSetAccelClosure(object, accel.closure)
gtkAccelLabelGetAccelWidget(object)
gtkAccelLabelSetAccelWidget(object, accel.widget)
gtkAccelLabelGetAccelWidth(object)
gtkAccelLabelRefetch(object)
gtkAccelLabel(string = NULL, show = TRUE)

Hierarchy

1
2
3
4
5
6
7
GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkMisc
                           +----GtkLabel
                                 +----GtkAccelLabel

Interfaces

GtkAccelLabel implements AtkImplementorIface and GtkBuildable.

Detailed Description

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.

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 gtkAccelLabelSetAccelWidget.

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 gtkAccelLabelSetAccelWidget is called with the GtkMenuItem as the second argument. The GtkAccelLabel will now display 'Ctl+S' after its label.

Note that creating a GtkMenuItem with gtkMenuItemNewWithLabel (or one of the similar functions for GtkCheckMenuItem and GtkRadioMenuItem) automatically adds a GtkAccelLabel to the GtkMenuItem and calls gtkAccelLabelSetAccelWidget to set it up for you.

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.

Creating a simple menu item with an accelerator key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Creating a simple menu item with an accelerator key.

## Create a GtkAccelGroup and add it to the window.
accel_group = gtkAccelGroup()
window$addAccelGroup(accel_group)

## Create the menu item
save_item = gtkMenuItem("Save")
menu$add(save_item)

## Now add the accelerator to the GtkMenuItem. 
## It will be activated if the user types ctrl-s
## We just need to make sure we use the "visible" flag here to show it.
save_item$addAccelerator("activate", accel_group, GDK_S, 
                         "control-mask", "visible")

Structures

GtkAccelLabel

The GtkAccelLabel struct contains private data only, and should be accessed using the functions below.

Convenient Construction

gtkAccelLabel is the equivalent of gtkAccelLabelNew.

Properties

accel-closure [GClosure : * : Read / Write]

The closure to be monitored for accelerator changes.

accel-widget [GtkWidget : * : Read / Write]

The widget to be monitored for accelerator changes.

Author(s)

Derived by RGtkGen from GTK+ documentation

References

https://developer.gnome.org/gtk2/stable/GtkAccelLabel.html


RGtk2 documentation built on Oct. 14, 2021, 5:08 p.m.

Related to GtkAccelLabel in RGtk2...