gtkmm: Gtk::AccelGroup Class Reference

A Gtk::AccelGroup represents a group of keyboard accelerators, typically attached to a toplevel Gtk::Window (with Gtk::Window::add_accel_group()). More...

#include <gtkmm/accelgroup.h>

Inheritance diagram for Gtk::AccelGroup:

Public Member Functions

 AccelGroup (AccelGroup&& src) noexcept
 
AccelGroupoperator= (AccelGroup&& src) noexcept
 
 ~AccelGroup () noexcept override
 
GtkAccelGroup* gobj ()
 Provides access to the underlying C GObject. More...

 
const GtkAccelGroup* gobj () const
 Provides access to the underlying C GObject. More...

 
GtkAccelGroup* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...

 
bool get_is_locked () const
 Locks are added and removed using lock() and unlock(). More...

 
Gdk::ModifierType get_modifier_mask () const
 Gets a Gdk::ModifierType representing the mask for this accel_group. More...

 
void lock ()
 Locks the given accelerator group. More...

 
void unlock ()
 Undoes the last call to lock() on this accel_group. More...

 
bool disconnect_key (guint accel_key, Gdk::ModifierType accel_mods)
 Removes an accelerator previously installed through connect(). More...

 
bool activate (GQuark accel_quark, const Glib::RefPtr< Glib::Object >& acceleratable, guint accel_key, Gdk::ModifierType accel_mods)
 Finds the first accelerator in accel_group that matches accel_key and accel_mods, and activates it. More...

 
Glib::SignalProxy< bool, const Glib::RefPtr< Glib::Object >&, guint, Gdk::ModifierTypesignal_accel_activate ()
 
Glib::SignalProxy< void, guint, Gdk::ModifierType, GClosure* > signal_accel_changed ()
 
Glib::SignalProxyDetailedAnyType< void, guint, Gdk::ModifierType, GClosure* > signal_accel_changed (const Glib::ustring& accel_name)
 
Glib::PropertyProxy_ReadOnly< bool > property_is_locked () const
 Is the accel group locked. More...

 
Glib::PropertyProxy_ReadOnly< Gdk::ModifierTypeproperty_modifier_mask () const
 Modifier Mask. More...

 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
void * get_data (const QueryQuark &key)
 
void set_data (const Quark &key, void *data)
 
void set_data (const Quark &key, void *data, DestroyNotify notify)
 
void remove_data (const QueryQuark &quark)
 
void * steal_data (const QueryQuark &quark)
 
Glib::RefPtr< Glib::Objectwrap (GObject *object, bool take_copy=false)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
void connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void > &slot)
 
void connect_property_changed (const Glib::ustring &property_name, sigc::slot< void > &&slot)
 
sigc::connection connect_property_changed_with_return (const Glib::ustring &property_name, const sigc::slot< void > &slot)
 
sigc::connection connect_property_changed_with_return (const Glib::ustring &property_name, sigc::slot< void > &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src)
 
 ~trackable ()
 
void add_destroy_notify_callback (void *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src)
 
void remove_destroy_notify_callback (void *data) const
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...

 
static Glib::RefPtr< AccelGroupcreate ()
 Creates a new Gtk::AccelGroup object. More...

 
static bool valid (guint keyval, Gdk::ModifierType modifiers)
 Determines whether a given keyval and modifier mask constitute a valid keyboard accelerator. More...

 
static void parse (const Glib::ustring& accelerator, guint& accelerator_key, Gdk::ModifierType& accelerator_mods)
 Parse the accelerator string. More...

 
static Glib::ustring name (guint accelerator_key, Gdk::ModifierType accelerator_mods)
 Converts an accelerator keyval and modifier mask into a string parseable by parse(). More...

 
static Glib::ustring get_label (guint accelerator_key, Gdk::ModifierType accelerator_mods)
 Converts an accelerator keyval and modifier mask into a string which can be used to represent the accelerator to the user. More...

 
static void set_default_mod_mask (Gdk::ModifierType default_mod_mask)
 Sets the modifiers that will be considered significant for keyboard accelerators. More...

 
static Gdk::ModifierType get_default_mod_mask ()
 See set_default_mod_mask(). More...

 

Protected Member Functions

 AccelGroup ()
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::AccelGroupwrap (GtkAccelGroup* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...

 

Additional Inherited Members

- Public Types inherited from Glib::Object
typedef void(*)(gpointer data DestroyNotify)
 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 

Detailed Description

A Gtk::AccelGroup represents a group of keyboard accelerators, typically attached to a toplevel Gtk::Window (with Gtk::Window::add_accel_group()).

Usually you won't need to create a Gtk::AccelGroup directly; instead, gtkmm automatically sets up the accelerators for your menus. Note that accelerators are different from mnemonics. Accelerators are shortcuts for activating a menu item; they appear alongside the menu item for which they're a shortcut. For example "Ctrl+Q" might appear alongside the "Quit" menu item. Mnemonics are shortcuts for GUI elements such as text entries or buttons; they appear as underlined characters. See the Gtk::Label constructor. Menu items can have both accelerators and mnemonics, of course.

Constructor & Destructor Documentation

Gtk::AccelGroup::AccelGroup ( AccelGroup&&  src)
noexcept
Gtk::AccelGroup::~AccelGroup ( )
overridenoexcept
Gtk::AccelGroup::AccelGroup ( )
protected

Member Function Documentation

bool Gtk::AccelGroup::activate ( GQuark  accel_quark,
const Glib::RefPtr< Glib::Object > &  acceleratable,
guint  accel_key,
Gdk::ModifierType  accel_mods 
)

Finds the first accelerator in accel_group that matches accel_key and accel_mods, and activates it.

Parameters
accel_quarkThe quark for the accelerator name.
acceleratableThe Glib::Object, usually a Gtk::Window, on which to activate the accelerator.
accel_keyAccelerator keyval from a key event.
accel_modsKeyboard state mask from a key event.
Returns
true if an accelerator was activated and handled this keypress.
static Glib::RefPtr<AccelGroup> Gtk::AccelGroup::create ( )
static

Creates a new Gtk::AccelGroup object.

Returns
A Glib::RefPtr<> to a newly created Gtk::AccelGroup object.
bool Gtk::AccelGroup::disconnect_key ( guint  accel_key,
Gdk::ModifierType  accel_mods 
)

Removes an accelerator previously installed through connect().

Parameters
accel_keyKey value of the accelerator.
accel_modsModifier combination of the accelerator.
Returns
true if there was an accelerator which could be removed, false otherwise.
static Gdk::ModifierType Gtk::AccelGroup::get_default_mod_mask ( )
static
bool Gtk::AccelGroup::get_is_locked ( ) const

Locks are added and removed using lock() and unlock().

Since gtkmm 2.14:
Returns
true if there are 1 or more locks on the accel_group, false otherwise.
static Glib::ustring Gtk::AccelGroup::get_label ( guint  accelerator_key,
Gdk::ModifierType  accelerator_mods 
)
static

Converts an accelerator keyval and modifier mask into a string which can be used to represent the accelerator to the user.

Since gtkmm 2.6:
Parameters
accelerator_keyAccelerator keyval.
accelerator_modsAccelerator modifier mask.
Returns
A newly-allocated string representing the accelerator.
Gdk::ModifierType Gtk::AccelGroup::get_modifier_mask ( ) const

Gets a Gdk::ModifierType representing the mask for this accel_group.

For example, Gdk::CONTROL_MASK, Gdk::SHIFT_MASK, etc.

Since gtkmm 2.14:
Returns
The modifier mask for this accel group.
static GType Gtk::AccelGroup::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

GtkAccelGroup* Gtk::AccelGroup::gobj ( )
inline

Provides access to the underlying C GObject.

const GtkAccelGroup* Gtk::AccelGroup::gobj ( ) const
inline

Provides access to the underlying C GObject.

GtkAccelGroup* Gtk::AccelGroup::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

void Gtk::AccelGroup::lock ( )

Locks the given accelerator group.

Locking an acelerator group prevents the accelerators contained within it to be changed during runtime. Refer to Gtk::AccelMap::change_entry() about runtime accelerator changes.

If called more than once, accel_group remains locked until unlock() has been called an equivalent number of times.

static Glib::ustring Gtk::AccelGroup::name ( guint  accelerator_key,
Gdk::ModifierType  accelerator_mods 
)
static

Converts an accelerator keyval and modifier mask into a string parseable by parse().

For example, if you pass in 'q' and Gdk::CONTROL_MASK, it returns "& lt;Control& gt;q".

AccelGroup& Gtk::AccelGroup::operator= ( AccelGroup&&  src)
noexcept
static void Gtk::AccelGroup::parse ( const Glib::ustring accelerator,
guint &  accelerator_key,
Gdk::ModifierType accelerator_mods 
)
static

Parse the accelerator string.

Parameters
acceleratorSee the Gtk::AccelKey constructor for the format.
accelerator_keyOutput argument
accelerator_modsOutput argument
Glib::PropertyProxy_ReadOnly< bool > Gtk::AccelGroup::property_is_locked ( ) const

Is the accel group locked.

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly< Gdk::ModifierType > Gtk::AccelGroup::property_modifier_mask ( ) const

Modifier Mask.

Default value: Gdk::SHIFT_MASK | Gdk::CONTROL_MASK | Gdk::MOD1_MASK | Gdk::SUPER_MASK | Gdk::HYPER_MASK | Gdk::META_MASK

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.
static void Gtk::AccelGroup::set_default_mod_mask ( Gdk::ModifierType  default_mod_mask)
static

Sets the modifiers that will be considered significant for keyboard accelerators.

The default mod mask is Gdk::CONTROL_MASK | Gdk::SHIFT_MASK | Gdk::MOD1_MASK, that is, Control, Shift, and Alt. Other modifiers will ignored by default. You must include at least the three default modifiers in any value you pass to this function.

The default mod mask should be changed on application startup, before using any accelerator groups.

Glib::SignalProxy< bool,const Glib::RefPtr<Glib::Object>&,guint,Gdk::ModifierType > Gtk::AccelGroup::signal_accel_activate ( )
Slot Prototype:
bool on_my_accel_activate(const Glib::RefPtr<Glib::Object>& acceleratable, guint keyval, Gdk::ModifierType modifier)

The accel-activate signal is an implementation detail of Gtk::AccelGroup and not meant to be used by applications.

Deprecated:
This signal is not meant to be used by applications.
Parameters
acceleratableThe object on which the accelerator was activated.
keyvalThe accelerator keyval.
modifierThe modifier combination of the accelerator.
Returns
true if the accelerator was activated.
Glib::SignalProxy< void,guint,Gdk::ModifierType,GClosure* > Gtk::AccelGroup::signal_accel_changed ( )
Slot Prototype:
void on_my_accel_changed(guint keyval, Gdk::ModifierType modifier, GClosure* accel_closure)

Flags: Run First

The accel-changed signal is emitted when an entry is added to or removed from the accel group.

Widgets like Gtk::AccelLabel which display an associated accelerator should connect to this signal, and rebuild their visual representation if the accel_closure is theirs.

Parameters
keyvalThe accelerator keyval.
modifierThe modifier combination of the accelerator.
accel_closureThe GClosure of the accelerator.
Glib::SignalProxyDetailedAnyType< void,guint,Gdk::ModifierType,GClosure* > Gtk::AccelGroup::signal_accel_changed ( const Glib::ustring accel_name)
Slot Prototype:
void on_my_accel_changed(guint keyval, Gdk::ModifierType modifier, GClosure* accel_closure)

Flags: Run First

The accel-changed signal is emitted when an entry is added to or removed from the accel group.

Widgets like Gtk::AccelLabel which display an associated accelerator should connect to this signal, and rebuild their visual representation if the accel_closure is theirs.

Parameters
keyvalThe accelerator keyval.
modifierThe modifier combination of the accelerator.
accel_closureThe GClosure of the accelerator.
void Gtk::AccelGroup::unlock ( )

Undoes the last call to lock() on this accel_group.

static bool Gtk::AccelGroup::valid ( guint  keyval,
Gdk::ModifierType  modifiers 
)
static

Determines whether a given keyval and modifier mask constitute a valid keyboard accelerator.

For example, the 'a' keyval plus Gdk::CONTROL_MASK is valid - this is a "Ctrl+a" accelerator. But you can't, for instance, use the GDK_Control_L keyval as an accelerator.

Friends And Related Function Documentation

Glib::RefPtr< Gtk::AccelGroup > wrap ( GtkAccelGroup *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.