AnjutaUI: Anjuta Developers Reference Manual

## AnjutaUI AnjutaUI — User Interface manager |

## Stability Level

Unstable, unless otherwise indicated

## Functions

AnjutaUI * | anjuta_ui_new ()
GtkActionGroup * | anjuta_ui_add_action_group_entries ()
GtkActionGroup * | anjuta_ui_add_toggle_action_group_entries ()
void | anjuta_ui_add_action_group ()
void | anjuta_ui_remove_action_group ()
GtkAction * | anjuta_ui_get_action ()
void | anjuta_ui_activate_action_by_path ()
void | anjuta_ui_activate_action_by_group ()
gint | anjuta_ui_merge ()
void | anjuta_ui_unmerge ()
GtkIconFactory * | anjuta_ui_get_icon_factory ()
GtkAccelGroup * | anjuta_ui_get_accel_group ()
GtkWidget * | anjuta_ui_get_accel_editor ()
void | anjuta_ui_dump_tree ()
void | anjuta_ui_load_accels ()
void | anjuta_ui_save_accels ()
void | anjuta_ui_unload_accels ()
#define | BEGIN_REGISTER_ICON()
#define | REGISTER_ICON_FULL()
#define | REGISTER_ICON()

## Types and Values

#define | END_REGISTER_ICON

## Object Hierarchy

        GObject
        ╰── GtkUIManager
            ╰── AnjutaUI

## Includes

    #include <libanjuta/>

## Description

AnjutaUI subclasses GtkUIManager, so you should really read GtkUIManager documentation first to know about Actions, UI merging and UI XML file format. This documentation will cover only the relevent APIs.

AnjutaUI has its own methods for adding action groups, which is differnt from GtkUIManager methods. All AnjutaPlugin based classes should use these methods instead of GtkUIManager methods. The reason is, in addition to adding the actions and groups to the UI manager, it also resgisters them for UI customization and accellerators editing. It also keeps record of all actions.

An interesting side effect of this is that these actions could be conveniently accessed or activated with `anjuta_ui_get_action()` or `anjuta_ui_activate_action_by_path()`, without the need of original action group object. This makes it is possible for activating actions remotely from other plugins.

anjuta_ui_get_accel_editor() will return a widget containing the UI customization and accellerators editor. All actions and action groups are organized into a tree view, which should be added to a visible container (e.g. a GtkDialog based object) and displayed to users.

Any actions additions/removals using GtkUIManager are not registred with AnjutaUI and hence their accellerators cannot be edited. Nor will they be listed in UI manager dialog. Hence, use AnjutaUI methods whenever possible.

## Functions

### anjuta_ui_new ()

    AnjutaUI *
    anjuta_ui_new (void);

Creates a new instance of AnjutaUI.

#### Returns

A AnjutaUI object

### anjuta_ui_add_action_group_entries ()

    GtkActionGroup *
    anjuta_ui_add_action_group_entries (AnjutaUI *ui,
                                        const gchar *action_group_name,
                                        const gchar *action_group_label,
                                        GtkActionEntry *entries,
                                        gint num_entries,
                                        const gchar *translation_domain,
                                        gboolean can_customize,
                                        gpointer user_data);

GtkAction objects are created from the GtkActionEntry structures and added to the UI Manager. "activate" signal of GtkAction is connected for all the action objects using the callback in the entry structure and the `user_data` passed here.

This group of actions are registered with the name `action_group_name` in AnjutaUI. A GtkAction object from this action group can be later retrieved by `anjuta_ui_get_action()` using `action_group_name` and action name. `action_group_label` is used as the display name for the action group in UI manager dialog where action shortcuts are configured.

#### Parameters

ui | A AnjutaUI object. |
action_group_name | Untranslated name of the action group. |
action_group_label | Translated label of the action group. |
entries | An array of action entries. | [array length=num_entries]
num_entries | Number of elements in the action entries array. |
can_customize | If true the actions are customizable by user. |
translation_domain | The translation domain used to translated the entries. It is usually the GETTEXT_PACKAGE macro in a project. |
user_data | User data to pass to action objects. This is the data that will come as user_data in "activate" signal of the actions. |

#### Returns

A GtkActionGroup object holding all the action objects.

[transfer none]

### anjuta_ui_add_toggle_action_group_entries ()

    GtkActionGroup *
    anjuta_ui_add_toggle_action_group_entries
                                   (AnjutaUI *ui,
                                    const gchar *action_group_name,
                                    const gchar *action_group_label,
                                    GtkToggleActionEntry *entries,
                                    gint num_entries,
                                    const gchar *translation_domain,
                                    gboolean can_customize,
                                    gpointer user_data);

This is similar to `anjuta_ui_add_action_group_entries()`, except that it adds GtkToggleAction objects after creating them from the `entries` .

#### Parameters

ui | A AnjutaUI object. |
action_group_name | Untranslated name of the action group. |
action_group_label | Translated label of the action group. |
entries | An array of action entries. | [array length=num_entries]
num_entries | Number of elements in the action entries array. |
translation_domain | The translation domain used to translated the entries. It is usually the GETTEXT_PACKAGE macro in a project. |
user_data | User data to pass to action objects. This is the data that will come as user_data in "activate" signal of the actions. |

#### Returns

A GtkActionGroup object holding all the action objects.

[transfer none]

### anjuta_ui_add_action_group ()

    void
    anjuta_ui_add_action_group (AnjutaUI *ui,
                                const gchar *action_group_name,
                                const gchar *action_group_label,
                                GtkActionGroup *action_group,
                                gboolean can_customize);

This is similar to `anjuta_ui_add_action_group_entries()`, except that it adds GtkActionGroup object `action_group` directly. All actions in this group are automatically registered in AnjutaUI and can be retrieved normally with `anjuta_ui_get_action()`.

#### Parameters

ui | A AnjutaUI object. |
action_group_name | Untranslated name of the action group. |
action_group_label | Translated label of the action group. |
action_group | GtkActionGroup object to add. | [transfer full]

### anjuta_ui_remove_action_group ()

    void
    anjuta_ui_remove_action_group (AnjutaUI *ui,
                                   GtkActionGroup *action_group);

Removes a previous added action group. All actions in this group are also unregistered from UI manager.

#### Parameters

ui | A AnjutaUI object |
action_group | GtkActionGroup object to remove. |

### anjuta_ui_get_action ()

    GtkAction *
    anjuta_ui_get_action (AnjutaUI *ui,
                          const gchar *action_group_name,
                          const gchar *action_name);

Returns the action object with the name `action_name` in `action_group_name` . Note that it will be only sucessully returned if the group has been added using methods in AnjutaUI.

#### Parameters

ui | This AnjutaUI object |
action_group_name | Group name. |
action_name | Action name. |

#### Returns

A GtkAction object.

[transfer none]

### anjuta_ui_activate_action_by_path ()

    void
    anjuta_ui_activate_action_by_path (AnjutaUI *ui,
                                       const gchar *action_path);

Activates the action represented by `action_path` . The path is in the form "ActionGroupName/ActionName". Note that it will only work if the group has been added using methods in AnjutaUI.

#### Parameters

ui | This AnjutaUI object |
action_path | Path of the action in the form "GroupName/ActionName" |

### anjuta_ui_activate_action_by_group ()

    void
    anjuta_ui_activate_action_by_group (AnjutaUI *ui,
                                        GtkActionGroup *action_group,
                                        const gchar *action_name);

Activates the action `action_name` in the GtkActionGroup `action_group` . "ActionGroupName/ActionName". Note that it will only work if the group has been added using methods in AnjutaUI.

#### Parameters

ui | This AnjutaUI object |
action_group | Action group. |
action_name | Action name. |

### anjuta_ui_merge ()

    gint
    anjuta_ui_merge (AnjutaUI *ui,
                     const gchar *ui_filename);

Merges XML UI definition in `ui_filename` . UI elements defined in the xml are merged with existing UI elements in UI manager. The format of the file content is the standard XML UI definition tree. For more detail, read the documentation for GtkUIManager.

#### Parameters

ui | A AnjutaUI object. |
ui_filename | UI file to merge into UI manager. |

#### Returns

Integer merge ID

### anjuta_ui_unmerge ()

    void
    anjuta_ui_unmerge (AnjutaUI *ui,
                       gint id);

Unmerges UI with the ID value `id` (returned by `anjuta_ui_merge()` when it was merged. For more detail, read the documentation for GtkUIManager.

#### Parameters

ui | A AnjutaUI object. |
id | Merge ID returned by `anjuta_ui_merge()`. |

### anjuta_ui_get_icon_factory ()

    GtkIconFactory *
    anjuta_ui_get_icon_factory (AnjutaUI *ui);

This returns the IconFactory object. All icons should be registered using this icon factory. Read the documentation for GtkIconFactory on how to use it.

#### Parameters

ui | A AnjutaUI object |

#### Returns

The GtkIconFactory object used by it.

[transfer none]

### anjuta_ui_get_accel_group ()

    GtkAccelGroup *
    anjuta_ui_get_accel_group (AnjutaUI *ui);

Returns the GtkAccelGroup object associated with this UI manager.

#### Parameters

ui | A AnjutaUI object. |

#### Returns

A GtkAccelGroup object.

[transfer none]

### anjuta_ui_get_accel_editor ()

    GtkWidget *
    anjuta_ui_get_accel_editor (AnjutaUI *ui);

Creates an accel editor widget and returns it. It should be added to container and displayed to users.

#### Parameters

ui | A AnjutaUI object. |

#### Returns

a GtkWidget containing the editor.

[transfer none]

### anjuta_ui_dump_tree ()

    void
    anjuta_ui_dump_tree (AnjutaUI *ui);

Dumps the current UI XML tree in STDOUT. Useful for debugging.

#### Parameters

ui | A AnjutaUI object. |

### anjuta_ui_load_accels ()

    void
    anjuta_ui_load_accels (const gchar *filename);

### anjuta_ui_save_accels ()

    void
    anjuta_ui_save_accels (const gchar *filename);

### anjuta_ui_unload_accels ()

    void
    anjuta_ui_unload_accels (AnjutaUI *ui);

### BEGIN_REGISTER_ICON()

    #define             BEGIN_REGISTER_ICON(plugin)

Convenience macros to register stock icons

#### Parameters

plugin | The anjuta plugin to register the icons for |

### REGISTER_ICON_FULL()

    #define             REGISTER_ICON_FULL(icon, stock_id)

Register icon with size 16 and size 24, icon should be the filename (without path) striped of the size (16,24) and the *.png (e.g anjuta-icon-24.png => anjuta-icon)

#### Parameters

icon | name of the icon (without size and extension) |
stock_id | stock-id that should be assigned to the icon |

### REGISTER_ICON()

    #define             REGISTER_ICON(icon, stock_id)

Register icon for all sizes (will be scaled) icon should be the full filename without path (e.g anjuta-icon.png)

#### Parameters

icon | name of the icon (without size and extension) |
stock_id | stock-id that should be assigned to the icon |

## Types and Values

### END_REGISTER_ICON

    #define             END_REGISTER_ICON

Ends a BEGIN_REGISTER_ICON sequence

## See Also

GtkAction, GtkActionEntry, GtkToggleAction, GtkToggleActionEntry, GtkRadioAction, GtkRadioActionEntry, GtkActionGroup, GtkUIManager