Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

Gtk::AccelLabel

class Gtk::AccelLabel

The Gtk::AccelLabel widget is a subclass 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::AccelLabel displays the accelerators which have been added to a particular widget. This widget is set by calling Gtk::AccelLabel#accel_widget=.

For example, a Gtk::MenuItem widget may have an accelerator added to emit the "activate" signal when the 'Ctl+S' key combination is pressed. A Gtk::AccelLabel is created and added to the Gtk::MenuItem, and Gtk::AccelLabel#accel_widget= is called with the Gtk::MenuItem as the second argument. The Gtk::AccelLabel will now display 'Ctl+S' after its label.

Note that creating a Gtk::MenuItem with Gtk::MenuItem.new (or one of the similar functions for Gtk::CheckMenuItem and Gtk::RadioMenuItem) automatically adds a Gtk::AccelLabel to the Gtk::MenuItem and calls Gtk::AccelLabel#accel_widget= to set it up for you.

A Gtk::AccelLabel will only display accelerators which have Gtk::ACCEL_VISIBLE set (see GtkAccelFlags). A Gtk::AccelLabel can display multiple accelerators and even signal names, though it is almost always used to display just one accelerator key.

<URL:http://library.gnome.org/devel/gtk/stable/accel-label.png>

Class Methods

Gtk::AccelLabel.new(string)
Creates a new Gtk::AccelLabel.

Instance Methods

accel_closure
Returns the accel_closure.
accel_closure=(accel_closure)
Sets the closure to be monitored by this accelerator label. The closure must be connected to an accelerator group; see Gtk::AccelGroup#connect
  • accel_closure: the closure(GLib::Closure) to monitor for accelerator changes.
  • Returns: the accel_closure
set_accel_closure(accel_closure)
Same as Gtk::AccelLabel#accel_closure=.
  • accel_closure: the closure(GLib::Closure) to monitor for accelerator changes.
  • Returns: self
accel_widget
Fetches the widget monitored by this accelerator label.
  • Returns : the object monitored by the accelerator label, or nil.
accel_widget=(accel_widget)
Sets the widget to be monitored by this accelerator label.
  • accel_widget: the widget to be monitored.
  • Returns: accel_widget
set_accel_widget(accel_widget)
Same as Gtk::AccelLabel#accel_widget=.
  • accel_widget: the widget to be monitored.
  • Returns: self
accel_width
Returns the width needed to display the accelerator key(s). This is used by menus to align all of the Gtk::MenuItem widgets, and shouldn't be needed by applications.
  • Returns: the width needed to display the accelerator key(s).
refetch
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.
ref_accessible
See Atk::Implementor#ref_accessible.
add_child
See Gtk::Buildable#add_child.
construct_child
See Gtk::Buildable#construct_child.
get_internal_child
See Gtk::Buildable#get_internal_child.
name
See Gtk::Buildable#name.
name=
See Gtk::Buildable#name=.
set_buildable_property
See Gtk::Buildable#set_buildable_property.
set_name
See Gtk::Buildable#set_name.
builder_name
See Gtk::Buildable#builder_name.
builder_name=
See Gtk::Buildable#builder_name=.
set_builder_name
See Gtk::Buildable#set_builder_name.

Properties

accel-closure: GLib::Closure (Read/Write)
The closure to be monitored for accelerator changes
accel-widget: Gtk::Widget (Read/Write)
The widget to be monitored for accelerator changes

See Also

Keyboard Accelerators installing and using keyboard short-cuts. Gtk::ItemFactory an easier way to create menus.

Last modified:2010/10/30 23:52:10
Keyword(s):
References:[api-gtk-index] [Ruby/GTK] [ruby-gtk-object-hierarchy] [Gtk::AccelLabel] [index-ruby-gtk2]