|
| UIManager (UIManager&& src) noexcept |
|
UIManager& | operator= (UIManager&& src) noexcept |
|
| ~UIManager () noexceptoverride |
|
GtkUIManager* | gobj () |
| Provides access to the underlying C GObject. More...
|
|
const GtkUIManager* | gobj () const |
| Provides access to the underlying C GObject. More...
|
|
GtkUIManager* | gobj_copy () |
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
|
|
void | set_add_tearoffs (bool add_tearoffs=true) |
| Sets the "add_tearoffs" property, which controls whether menus generated by this Gtk::UIManager will have tearoff menu items. More...
|
|
bool | get_add_tearoffs () const |
| Returns whether menus generated by this Gtk::UIManager will have tearoff menu items. More...
|
|
void | insert_action_group (const Glib::RefPtr< ActionGroup >& action_group, int pos=0) |
| Inserts an action group into the list of action groups associated with self. More...
|
|
void | remove_action_group (const Glib::RefPtr< ActionGroup >& action_group) |
| Removes an action group from the list of action groups associated with self. More...
|
|
Glib::ListHandle< Glib::RefPtr< ActionGroup > > | get_action_groups () |
| Returns the list of action groups associated with self. More...
|
|
Glib::ListHandle< Glib::RefPtr< const ActionGroup > > | get_action_groups () const |
| Returns the list of action groups associated with self. More...
|
|
Glib::RefPtr< AccelGroup > | get_accel_group () |
| Returns the Gtk::AccelGroup associated with self. More...
|
|
Glib::RefPtr< const AccelGroup > | get_accel_group () const |
| Returns the Gtk::AccelGroup associated with self. More...
|
|
Widget* | get_widget (const Glib::ustring& path) |
| Looks up a widget by following a path. More...
|
|
const Widget* | get_widget (const Glib::ustring& path) const |
| Looks up a widget by following a path. More...
|
|
Glib::SListHandle< Widget* > | get_toplevels (UIManagerItemType types) |
| Obtains a list of all toplevel widgets of the requested types. More...
|
|
Glib::SListHandle< const Widget* > | get_toplevels (UIManagerItemType types) const |
| Obtains a list of all toplevel widgets of the requested types. More...
|
|
Glib::RefPtr< Action > | get_action (const Glib::ustring& path) |
| Looks up an action by following a path. More...
|
|
Glib::RefPtr< const Action > | get_action (const Glib::ustring& path) const |
| Looks up an action by following a path. More...
|
|
ui_merge_id | add_ui_from_string (const Glib::ustring& buffer) |
| Parses a string containing a UI definition and merges it with the current contents. More...
|
|
ui_merge_id | add_ui_from_file (const Glib::ustring& filename) |
| Parses a file containing a UI definition and merges it with the current contents of self. More...
|
|
void | add_ui (ui_merge_id merge_id, const Glib::ustring& path, const Glib::ustring& name, const Glib::ustring& action, UIManagerItemType type=Gtk::UI_MANAGER_AUTO, bool top=true) |
| Adds a UI element to the current contents of self. More...
|
|
void | add_ui_separator (ui_merge_id merge_id, const Glib::ustring& path, const Glib::ustring& name="", UIManagerItemType type=Gtk::UI_MANAGER_AUTO, bool top=true) |
| Adds a separator UI element to the current contents. More...
|
|
void | remove_ui (ui_merge_id merge_id) |
| Unmerges the part of selfs content identified by merge_id. More...
|
|
Glib::ustring | get_ui () const |
| Creates a UI definition of the merged UI. More...
|
|
void | ensure_update () |
| Makes sure that all pending updates to the UI have been completed. More...
|
|
ui_merge_id | new_merge_id () |
| Returns an unused merge id, suitable for use with gtk_ui_manager_add_ui(). More...
|
|
Glib::SignalProxy< void, Widget* > | signal_add_widget () |
| The add_widget signal is emitted for each generated menubar and toolbar. More...
|
|
Glib::SignalProxy< void > | signal_actions_changed () |
| The "actions-changed" signal is emitted whenever the set of actions changes. More...
|
|
Glib::SignalProxy< void, const Glib::RefPtr< Action >&, Widget* > | signal_connect_proxy () |
| The connect_proxy signal is emitted after connecting a proxy to an action in the group. More...
|
|
Glib::SignalProxy< void, const Glib::RefPtr< Action >&, Widget* > | signal_disconnect_proxy () |
| The disconnect_proxy signal is emitted after disconnecting a proxy from an action in the group. More...
|
|
Glib::SignalProxy< void, const Glib::RefPtr< Action >& > | signal_pre_activate () |
| The pre_activate signal is emitted just before the action is activated. More...
|
|
Glib::SignalProxy< void, const Glib::RefPtr< Action >& > | signal_post_activate () |
| The post_activate signal is emitted just after the action is activated. More...
|
|
Glib::PropertyProxy< bool > | property_add_tearoffs () |
| Whether tearoff menu items should be added to menus. More...
|
|
Glib::PropertyProxy_ReadOnly< bool > | property_add_tearoffs () const |
| Whether tearoff menu items should be added to menus. More...
|
|
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_ui () const |
| An XML string describing the merged UI. More...
|
|
| Object (const Object &)=delete |
|
Object & | operator= (const Object &)=delete |
|
| Object (Object &&src) noexcept |
|
Object & | operator= (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::Object > | wrap (GObject *object, bool take_copy=false) |
|
| ObjectBase (const ObjectBase &)=delete |
|
ObjectBase & | operator= (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 |
|
| 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 () |
|
trackable & | operator= (const trackable &src) |
|
trackable & | operator= (trackable &&src) |
|
void | remove_destroy_notify_callback (void *data) const |
|
Constructing menus and toolbars from an XML description.
A Gtk::UIManager constructs a user interface (menus and toolbars) from one or more UI definitions, which reference actions from one or more action groups.
- UI Definitions
The UI definitions are specified in an XML format which can be roughly described by the following DTD.
<!ELEMENT ui (menubar|toolbar|popup|accelerator)* >
<!ELEMENT menubar (menuitem|separator|placeholder|menu)* >
<!ELEMENT menu (menuitem|separator|placeholder|menu)* >
<!ELEMENT popup (menuitem|separator|placeholder|menu)* >
<!ELEMENT toolbar (toolitem|separator|placeholder)* >
<!ELEMENT placeholder (menuitem|toolitem|separator|placeholder|menu)* >
<!ELEMENT menuitem
EMPTY >
<!ELEMENT toolitem (menu?) >
<!ELEMENT separator
EMPTY >
<!ELEMENT accelerator
EMPTY >
<!ATTLIST menubar name #IMPLIED
action #IMPLIED >
<!ATTLIST toolbar name #IMPLIED
action #IMPLIED >
<!ATTLIST popup name #IMPLIED
action #IMPLIED >
<!ATTLIST placeholder name #IMPLIED
action #IMPLIED >
<!ATTLIST separator name #IMPLIED
action #IMPLIED
expand (true|false) #IMPLIED >
<!ATTLIST menu name #IMPLIED
action #REQUIRED
position (top|bot) #IMPLIED >
<!ATTLIST menuitem name #IMPLIED
action #REQUIRED
position (top|bot) #IMPLIED >
<!ATTLIST toolitem name #IMPLIED
action #REQUIRED
position (top|bot) #IMPLIED >
<!ATTLIST accelerator name #IMPLIED
action #REQUIRED >
There are some additional restrictions beyond those specified in the DTD, e.g. every toolitem must have a toolbar in its anchestry and every menuitem must have a + menubar or popup in its anchestry. Since a GMarkup parser is used to parse the UI description, it must not only be valid XML, but valid GMarkup.
If a name is not specified, it defaults to the action. If an action is not specified either, the element name is used. The name and action attributes must not contain '/' characters after parsing (since that would mess up path lookup) and must be usable as XML attributes when enclosed in doublequotes, thus they must not '"' characters or references to the " entity.
- Example: UI Definition
<ui>
<menubar>
<menu name="FileMenu" action="FileMenuAction">
<menuitem name="New" action="New2Action" />
<placeholder name="FileMenuAdditions" />
</menu>
<menu name="JustifyMenu" action="JustifyMenuAction">
<menuitem name="Left" action="justify-left"/>
<menuitem name="Centre" action="justify-center"/>
<menuitem name="Right" action="justify-right"/>
<menuitem name="Fill" action="justify-fill"/>
</menu>
</menubar>
<toolbar action="toolbar1">
<placeholder name="JustifyToolItems">
<separator/>
<toolitem name="Left" action="justify-left"/>
<toolitem name="Centre" action="justify-center"/>
<toolitem name="Right" action="justify-right"/>
<toolitem name="Fill" action="justify-fill"/>
<separator/>
</placeholder>
</toolbar>
</ui>
The constructed widget hierarchy is very similar to the element tree of the XML, with the exception that placeholders are merged into their parents. The correspondence of XML elements to widgets should be almost obvious:
The "position" attribute determines where a constructed widget is positioned wrt. to its siblings in the partially constructed tree. If it is "top", the widget is prepended, otherwise it is appended.
- UI Merging
The most remarkable feature of Gtk::UIManager is that it can overlay a set of menuitems and toolitems over another one, and demerge them later.
Merging is done based on the names of the XML elements. Each element is identified by a path which consists of the names of its anchestors, separated by slashes. For example, the menuitem named "Left" in the example above has the path /ui/menubar/JustifyMenu/Left and the toolitem with the same name has path /ui/toolbar1/JustifyToolItems/Left.
- Accelerators
Every action has an accelerator path. Accelerators are installed together with menuitem proxies, but they can also be explicitly added with <accelerator> elements in the UI definition. This makes it possible to have accelerators for actions even if they have no visible proxies.
- Smart Separators
The separators created by Gtk::UIManager are "smart", i.e. they do not show up in the UI unless they end up between two visible menu or tool items. Separators which are located at the very beginning or end of the menu or toolbar containing them, or multiple separators next to each other, are hidden. This is a useful feature, since the merging of UI elements from multiple sources can make it hard or impossible to determine in advance whether a separator will end up in such an unfortunate position.
For separators in toolbars, you can set expand="true" to turn them from a small, visible separator to an expanding, invisible one. Toolitems following an expanding separator are effectively right-aligned.
- Empty Menus
Submenus pose similar problems to separators inconnection with merging. It is impossible to know in advance whether they will end up empty after merging. Gtk::UIManager offers two ways to treat empty submenus:
- make them disappear by hiding the menu item they're attached to
- add an insensitive "Empty" item
The behaviour is chosen based on the "hide_if_empty" property of the action to which the submenu is associated.
- Since gtkmm 2.4: