|
GnuCash 2.3.0
|
Data Structures | |
| struct | GncPluginPrivate |
| struct | GncPlugin |
| struct | GncPluginClass |
| struct | action_toolbar_labels |
Files | |
| file | gnc-plugin.c |
Functions for adding plugins to a Gnucash window. | |
| file | gnc-plugin.h |
Functions for adding plugins to a GnuCash window. | |
Defines | |
| #define | GNC_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN, GncPluginPrivate)) |
| #define | GNC_TYPE_PLUGIN (gnc_plugin_get_type ()) |
| #define | GNC_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_PLUGIN, GncPlugin)) |
| #define | GNC_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN, GncPluginClass)) |
| #define | GNC_IS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_PLUGIN)) |
| #define | GNC_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN)) |
| #define | GNC_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_PLUGIN, GncPluginClass)) |
| #define | GNC_PLUGIN_NAME "GncPlugin" |
Typedefs | |
| typedef struct GncPluginPrivate | GncPluginPrivate |
Functions | |
| GType | gnc_plugin_get_type (void) |
| void | gnc_plugin_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) |
| void | gnc_plugin_remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type) |
| const gchar * | gnc_plugin_get_name (GncPlugin *plugin) |
| void | gnc_plugin_init_short_names (GtkActionGroup *action_group, action_toolbar_labels *toolbar_labels) |
| void | gnc_plugin_set_important_actions (GtkActionGroup *action_group, const gchar **name) |
| void | gnc_plugin_update_actions (GtkActionGroup *action_group, const gchar **action_names, const gchar *property_name, gboolean value) |
| gint | gnc_plugin_add_actions (GtkUIManager *ui_merge, GtkActionGroup *action_group, const gchar *filename) |
| typedef struct GncPluginPrivate GncPluginPrivate |
The instance private data for a menu-only plugin. This data structure is unused.
| gint gnc_plugin_add_actions | ( | GtkUIManager * | ui_merge, |
| GtkActionGroup * | action_group, | ||
| const gchar * | filename | ||
| ) |
Load a new set of actions into an existing UI.
See gnc-plugin.h for documentation on the function arguments.
Load a new set of actions into an existing UI. The actions from the provided group will be merged into the pre-existing ui, as directed by the specified file.
| ui_merge | A pointer to the UI manager data structure for a window. |
| action_group | The set of actions provided by a given plugin. |
| filename | The name of the ui description file. This file name will be searched for in the ui directory. |
Definition at line 374 of file gnc-plugin.c.
{
GError *error = NULL;
gchar *pathname;
gint merge_id;
g_return_val_if_fail (ui_merge, 0);
g_return_val_if_fail (action_group, 0);
g_return_val_if_fail (filename, 0);
ENTER("ui_merge %p, action_group %p, filename %s",
ui_merge, action_group, filename);
gtk_ui_manager_insert_action_group (ui_merge, action_group, 0);
pathname = gnc_gnome_locate_ui_file (filename);
if (pathname == NULL)
{
LEAVE("fail");
return 0;
}
merge_id = gtk_ui_manager_add_ui_from_file (ui_merge, pathname, &error);
DEBUG("merge_id is %d", merge_id);
g_assert(merge_id || error);
if (merge_id)
{
gtk_ui_manager_ensure_update (ui_merge);
}
else
{
g_critical("Failed to load ui file.\n Filename %s\n Error %s",
filename, error->message);
g_error_free(error);
}
g_free(pathname);
LEAVE(" ");
return merge_id;
}
| void gnc_plugin_add_to_window | ( | GncPlugin * | plugin, |
| GncMainWindow * | window, | ||
| GQuark | type | ||
| ) |
Add the specified plugin from the specified window. This function will add the page's user interface from the window, set up gconf notifications if the page uses gconf, and call the plugin to perform any plugin specific actions.
See gnc-plugin.h for documentation on the function arguments.
Add the specified plugin to the specified window. This function will add the page's user interface from the window, set up gconf notifications if the page uses gconf, and call the plugin to perform any plugin specific actions.
| plugin | The plugin to be added. |
| window | Add the plugin to this window. |
| type | An identifier for the type of window specified. |
Definition at line 164 of file gnc-plugin.c.
{
GncPluginClass *class;
GtkActionGroup *action_group;
g_return_if_fail (GNC_IS_PLUGIN (plugin));
class = GNC_PLUGIN_GET_CLASS (plugin);
ENTER (": plugin %s(%p), window %p", gnc_plugin_get_name(plugin),
plugin, window);
/*
* Update window with additional UI items
*/
if (class->actions_name)
{
DEBUG ("%s: %d actions to merge with gui from %s",
class->actions_name, (class->n_actions + class->n_toggle_actions), class->ui_filename);
gnc_main_window_merge_actions (window, class->actions_name,
class->actions, class->n_actions,
class->toggle_actions, class->n_toggle_actions,
class->ui_filename, plugin);
if (class->important_actions)
{
action_group =
gnc_main_window_get_action_group(window, class->actions_name);
gnc_plugin_set_important_actions(action_group,
class->important_actions);
}
}
/*
* Setup gconf notifications if requested
*/
if (class->gconf_section && class->gconf_notifications)
{
DEBUG ("Requesting notification for section %s", class->gconf_section);
gnc_gconf_add_notification(G_OBJECT(window), class->gconf_section,
class->gconf_notifications, GNC_PLUGIN_NAME);
}
/*
* Do plugin specific actions.
*/
if (GNC_PLUGIN_GET_CLASS (plugin)->add_to_window)
{
DEBUG ("Calling child class function %p", GNC_PLUGIN_GET_CLASS (plugin)->add_to_window);
GNC_PLUGIN_GET_CLASS (plugin)->add_to_window (plugin, window, type);
}
LEAVE ("");
}
| const gchar * gnc_plugin_get_name | ( | GncPlugin * | plugin | ) |
Retrieve the textual name of a plugin.
Retrieve the textual name of a plugin.
| plugin | The plugin whose name should be returned. |
Definition at line 274 of file gnc-plugin.c.
{
g_return_val_if_fail (GNC_IS_PLUGIN (plugin), NULL);
return (GNC_PLUGIN_GET_CLASS(plugin)->plugin_name);
}
| GType gnc_plugin_get_type | ( | void | ) |
Get the type of a gnc window plugin.
Get the type of a menu-only plugin.
Definition at line 71 of file gnc-plugin.c.
{
static GType gnc_plugin_type = 0;
if (gnc_plugin_type == 0)
{
static const GTypeInfo our_info =
{
sizeof (GncPluginClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gnc_plugin_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GncPlugin),
0, /* n_preallocs */
(GInstanceInitFunc) gnc_plugin_init,
};
gnc_plugin_type = g_type_register_static (G_TYPE_OBJECT,
GNC_PLUGIN_NAME,
&our_info, 0);
}
return gnc_plugin_type;
}
| void gnc_plugin_init_short_names | ( | GtkActionGroup * | action_group, |
| action_toolbar_labels * | toolbar_labels | ||
| ) |
Add "short" labels to existing actions. The "short" label is the string used on toolbar buttons when the action is visible.
See gnc-plugin.h for documentation on the function arguments.
Add "short" labels to existing actions. The "short" label is the string used on toolbar buttons when the action is visible. All toolbar buttons are homogeneous in size and are sized to fit the longest label. Therefore, this structure should be used if an action name is more than one word. This way the menu can have the label "Whizzy Feature", while the toolbar button only has the label "Whizzy".
| action_group | The group of all actions associated with a plugin or plugin page. All actions to me modified must be in this group. |
| toolbar_labels | A pointer to a NULL terminated array of data action_toolbar_labels items. |
Definition at line 291 of file gnc-plugin.c.
{
GtkAction *action;
GValue value = { 0, };
gint i;
g_value_init (&value, G_TYPE_STRING);
for (i = 0; toolbar_labels[i].action_name; i++)
{
/* Add a couple of short labels for the toolbar */
action = gtk_action_group_get_action (action_group,
toolbar_labels[i].action_name);
g_value_set_static_string (&value, gettext(toolbar_labels[i].label));
g_object_set_property (G_OBJECT(action), "short_label", &value);
}
}
| void gnc_plugin_remove_from_window | ( | GncPlugin * | plugin, |
| GncMainWindow * | window, | ||
| GQuark | type | ||
| ) |
Remove the specified plugin from the specified window. This function will call the plugin to perform any plugin specific actions, remove any gconf notifications that were set up for the page, and remove the page's user interface from the window.
| plugin | The plugin to be removed. |
| window | The window the plugin should be removed from. |
| type | An identifier for the type of window specified. |
Definition at line 227 of file gnc-plugin.c.
{
GncPluginClass *class;
g_return_if_fail (GNC_IS_PLUGIN (plugin));
class = GNC_PLUGIN_GET_CLASS (plugin);
ENTER (": plugin %s(%p), window %p", gnc_plugin_get_name(plugin),
plugin, window);
/*
* Do plugin specific actions.
*/
if (GNC_PLUGIN_GET_CLASS (plugin)->remove_from_window)
{
DEBUG ("Calling child class function %p",
GNC_PLUGIN_GET_CLASS (plugin)->remove_from_window);
GNC_PLUGIN_GET_CLASS (plugin)->remove_from_window (plugin, window, type);
}
/*
* Remove any gconf notifications
*/
if (class->gconf_section && class->gconf_notifications)
{
DEBUG ("Remove notification for section %s", class->gconf_section);
gnc_gconf_remove_notification (G_OBJECT(window), class->gconf_section,
GNC_PLUGIN_NAME);
}
/*
* Update window to remove UI items
*/
if (class->actions_name)
{
DEBUG ("%s: %d actions to unmerge",
class->actions_name, (class->n_actions + class->n_toggle_actions));
gnc_main_window_unmerge_actions (window, class->actions_name);
}
LEAVE ("");
}
| void gnc_plugin_set_important_actions | ( | GtkActionGroup * | action_group, |
| const gchar ** | name | ||
| ) |
Mark certain actions as "important". This means that their labels will appear when the toolbar is set to "Icons and important text" (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode.
See gnc-plugin.h for documentation on the function arguments.
Mark certain actions as "important". This means that their labels will appear when the toolbar is set to "Icons and important text" (e.g. GTK_TOOLBAR_BOTH_HORIZ) mode.
| action_group | The group of all actions associated with a plugin or plugin page. All actions to me modified must be in this group. |
| name | A list of actions names to be marked important. This list must be NULL terminated. |
Definition at line 317 of file gnc-plugin.c.
{
GtkAction *action;
gint i;
for (i = 0; name[i]; i++)
{
action = gtk_action_group_get_action (action_group, name[i]);
g_object_set (G_OBJECT(action), "is_important", TRUE, NULL);
}
/* If this trips, you've got too many "important" actions. That
* can't *all* be that important, can they? */
g_assert(i <= 3);
}
| void gnc_plugin_update_actions | ( | GtkActionGroup * | action_group, |
| const gchar ** | action_names, | ||
| const gchar * | property_name, | ||
| gboolean | value | ||
| ) |
Update a property on a set of existing GtkActions. This function can be easily used to make a list of actions visible, invisible, sensitive, or insensitive.
| action_group | The group of all actions associated with a plugin or plugin page. All actions to be modified must be contained in this group. |
| action_names | A NULL terminated list of actions names that should modified. |
| property_name | The property name to be changed on the specified actions. The only two GtkAction properties that it makes sense to modify are "visible" and "sensitive". |
| value | A boolean specifying the new state for the specified property. |
Definition at line 341 of file gnc-plugin.c.
{
GtkAction *action;
GValue gvalue = { 0 };
gint i;
g_value_init (&gvalue, G_TYPE_BOOLEAN);
g_value_set_boolean (&gvalue, value);
for (i = 0; action_names[i]; i++)
{
action = gtk_action_group_get_action (action_group, action_names[i]);
if (action)
{
g_object_set_property (G_OBJECT(action), property_name, &gvalue);
}
else
{
g_warning("No such action with name '%s' in action group %s (size %d)",
action_names[i], gtk_action_group_get_name(action_group),
g_list_length(gtk_action_group_list_actions(action_group)));
}
}
}
1.7.4