Class: Gtk::UIManager

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#accel_groupGtk::AccelGroup

Returns the Gtk::AccelGroup associated with manager.

Returns:

#action_groupsGLib::List

Returns the list of action groups associated with manager.

Returns:

  • (GLib::List)

    a #GList of action groups. The list is owned by GTK+ and should not be modified.

#add_tearoffsTrueClass

Returns whether menus generated by this Gtk::UIManager will have tearoff menu items.

Returns:

  • (TrueClass)

    whether tearoff menu items are added

#add_tearoffs=(add_tearoffs) ⇒ TrueClass

The “add-tearoffs” property controls whether generated menus have tearoff menu items.

Note that this only affects regular menus. Generated popup menus never have tearoff menu items.

Parameters:

  • add_tearoffs (TrueClass)

Returns:

  • (TrueClass)

    add-tearoffs

  • (TrueClass)

    add-tearoffs

#add_tearoffs?TrueClass

The “add-tearoffs” property controls whether generated menus have tearoff menu items.

Note that this only affects regular menus. Generated popup menus never have tearoff menu items.

Returns:

  • (TrueClass)

    add-tearoffs

#add_ui(merge_id, path, name, action, type, top) ⇒ nil

Adds a UI element to the current contents of manager.

If type is %GTK_UI_MANAGER_AUTO, GTK+ inserts a menuitem, toolitem or separator if such an element can be inserted at the place determined by path. Otherwise type must indicate an element that can be inserted at the place determined by path.

If path points to a menuitem or toolitem, the new element will be inserted before or after this item, depending on top.

Parameters:

  • merge_id (Integer)

    the merge id for the merged UI, see gtk_ui_manager_new_merge_id()

  • path (String)

    a path

  • name (String)

    the name for the added UI element

  • action (String)

    the name of the action to be proxied, or nil to add a separator

  • type (Gtk::UIManagerItemType)

    the type of UI element to add.

  • top (TrueClass)

    if true, the UI element is added before its siblings, otherwise it is added after its siblings.

Returns:

  • (nil)

#add_ui_from_file(filename) ⇒ Integer

Parses a file containing a [UI definition] and merges it with the current contents of manager.

Parameters:

  • filename (Gtk::filename)

    the name of the file to parse

Returns:

  • (Integer)

    The merge id for the merged UI. The merge id can be used to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred, the return value is 0.

#add_ui_from_resource(resource_path) ⇒ Integer

Parses a resource file containing a [UI definition] and merges it with the current contents of manager.

Parameters:

  • resource_path (String)

    the resource path of the file to parse

Returns:

  • (Integer)

    The merge id for the merged UI. The merge id can be used to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred, the return value is 0.

#add_ui_from_string(buffer, length) ⇒ Integer

Parses a string containing a [UI definition] and merges it with the current contents of manager. An enclosing <ui> element is added if it is missing.

Parameters:

  • buffer (String)

    the string to parse

  • length (Gtk::gssize)

    the length of buffer (may be -1 if buffer is nul-terminated)

Returns:

  • (Integer)

    The merge id for the merged UI. The merge id can be used to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred, the return value is 0.

#ensure_updatenil

Makes sure that all pending updates to the UI have been completed.

This may occasionally be necessary, since Gtk::UIManager updates the UI in an idle function. A typical example where this function is useful is to enforce that the menubar and toolbar have been added to the main window before showing it:

gtk_container_add (GTK_CONTAINER (window), vbox);
g_signal_connect (merge, "add-widget",
                  G_CALLBACK (add_widget), vbox);
gtk_ui_manager_add_ui_from_file (merge, "my-menus");
gtk_ui_manager_add_ui_from_file (merge, "my-toolbars");
gtk_ui_manager_ensure_update (merge);
gtk_widget_show (window);

Returns:

  • (nil)

#get_action(path) ⇒ Gtk::Action

Looks up an action by following a path. See gtk_ui_manager_get_widget() for more information about paths.

Parameters:

  • path (String)

    a path

Returns:

  • (Gtk::Action)

    the action whose proxy widget is found by following the path, or nil if no widget was found.

#get_toplevels(types) ⇒ GLib::SList

Obtains a list of all toplevel widgets of the requested types. all toplevel widgets of the requested types. Free the returned list with g_slist_free().

Parameters:

  • types (Gtk::UIManagerItemType)

    specifies the types of toplevel widgets to include. Allowed types are #GTK_UI_MANAGER_MENUBAR, #GTK_UI_MANAGER_TOOLBAR and #GTK_UI_MANAGER_POPUP.

Returns:

  • (GLib::SList)

    a newly-allocated #GSList of

#get_widget(path) ⇒ Gtk::Widget

Looks up a widget by following a path. The path consists of the names specified in the XML description of the UI. separated by “/”. Elements which don’t have a name or action attribute in the XML (e.g. <popup>) can be addressed by their XML element name (e.g. “popup”). The root element (“/ui”) can be omitted in the path.

Note that the widget found by following a path that ends in a <menu>; element is the menuitem to which the menu is attached, not the menu it manages.

Also note that the widgets constructed by a ui manager are not tied to the lifecycle of the ui manager. If you add the widgets returned by this function to some container or explicitly ref them, they will survive the destruction of the ui manager.

Parameters:

  • path (String)

    a path

Returns:

  • (Gtk::Widget)

    the widget found by following the path, or nil if no widget was found

#insert_action_group(action_group, pos) ⇒ nil

Inserts an action group into the list of action groups associated with manager. Actions in earlier groups hide actions with the same name in later groups.

If pos is larger than the number of action groups in manager, or negative, action_group will be inserted at the end of the internal list.

Parameters:

  • action_group (Gtk::ActionGroup)

    the action group to be inserted

  • pos (Integer)

    the position at which the group will be inserted.

Returns:

  • (nil)

#newGtk::UIManager

Creates a new ui manager object.

Returns:

#new_merge_idInteger

Returns an unused merge id, suitable for use with gtk_ui_manager_add_ui().

Returns:

  • (Integer)

    an unused merge id.

#remove_action_group(action_group) ⇒ nil

Removes an action group from the list of action groups associated with manager.

Parameters:

Returns:

  • (nil)

#remove_ui(merge_id) ⇒ nil

Unmerges the part of manager’s content identified by merge_id.

Parameters:

  • merge_id (Integer)

    a merge id as returned by gtk_ui_manager_add_ui_from_string()

Returns:

  • (nil)

#uiString

Returns ui.

Returns:

  • (String)

    ui

#ui=(ui) ⇒ String

Parameters:

  • ui (String)

Returns:

  • (String)

    ui

  • (String)

    ui