GnuCash 2.4.99
Data Structures | Files | Defines | Typedefs | Enumerations | Functions
An Owner Tree Plugin
Content Plugins

Data Structures

struct  GncPluginPageOwnerTreePrivate
struct  action_owners_struct
struct  GncPluginPageOwnerTree
struct  GncPluginPageOwnerTreeClass

Files

file  gnc-plugin-page-owner-tree.c
 

Functions providing a page which lists owners of one type. This type can be vendors, customers or employees.


file  gnc-plugin-page-owner-tree.h
 

Functions providing a page which lists owners of one type. This type can be vendors, customers or employees.


Defines

#define PLUGIN_PAGE_ACCT_TREE_CM_CLASS   "plugin-page-owner-tree"
#define GCONF_SECTION   "window/pages/owner_tree"
#define DELETE_DIALOG_FILTER   "filter"
#define DELETE_DIALOG_OWNER   "owner"
#define GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTreePrivate))
#define OWNER_TYPE_LABEL   "OwnerType"
#define GNC_TYPE_PLUGIN_PAGE_OWNER_TREE   (gnc_plugin_page_owner_tree_get_type ())
#define GNC_PLUGIN_PAGE_OWNER_TREE(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTree))
#define GNC_PLUGIN_PAGE_OWNER_TREE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTreeClass))
#define GNC_IS_PLUGIN_PAGE_OWNER_TREE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE))
#define GNC_IS_PLUGIN_PAGE_OWNER_TREE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE))
#define GNC_PLUGIN_PAGE_OWNER_TREE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, GncPluginPageOwnerTreeClass))
#define GNC_PLUGIN_PAGE_OWNER_TREE_NAME   "GncPluginPageOwnerTree"

Typedefs

typedef struct
GncPluginPageOwnerTreePrivate 
GncPluginPageOwnerTreePrivate

Enumerations

enum  { OWNER_SELECTED, LAST_SIGNAL }

Functions

GType gnc_plugin_page_owner_tree_get_type (void)
GncPluginPagegnc_plugin_page_owner_tree_new (GncOwnerType owner_type)
GncOwnergnc_plugin_page_owner_tree_get_current_owner (GncPluginPageOwnerTree *page)

Function Documentation

GncOwner * gnc_plugin_page_owner_tree_get_current_owner ( GncPluginPageOwnerTree page)

Given a pointer to an owner tree plugin page, return the selected owner (if any).

Parameters:
pageThe "owner tree" page.
Returns:
The currently selected owner. NULL if no owner is selected.

Definition at line 540 of file gnc-plugin-page-owner-tree.c.

{
    GncPluginPageOwnerTreePrivate *priv;
    GncOwner *owner;

    priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(page);
    ENTER("page %p (tree view %p)", page, priv->tree_view);
    owner = gnc_tree_view_owner_get_selected_owner (GNC_TREE_VIEW_OWNER(priv->tree_view));
    if (owner == NULL)
    {
        LEAVE("no owner");
        return NULL;
    }

    LEAVE("owner %p", owner);
    return owner;
}
GType gnc_plugin_page_owner_tree_get_type ( void  )

Retrieve the type number for an "owner tree" plugin page.

Returns:
The type number.

Definition at line 313 of file gnc-plugin-page-owner-tree.c.

{
    static GType gnc_plugin_page_owner_tree_type = 0;

    if (gnc_plugin_page_owner_tree_type == 0)
    {
        static const GTypeInfo our_info =
        {
            sizeof (GncPluginPageOwnerTreeClass),
            NULL,
            NULL,
            (GClassInitFunc) gnc_plugin_page_owner_tree_class_init,
            NULL,
            NULL,
            sizeof (GncPluginPageOwnerTree),
            0,
            (GInstanceInitFunc) gnc_plugin_page_owner_tree_init
        };

        gnc_plugin_page_owner_tree_type = g_type_register_static (GNC_TYPE_PLUGIN_PAGE,
                                          GNC_PLUGIN_PAGE_OWNER_TREE_NAME,
                                          &our_info, 0);
    }

    return gnc_plugin_page_owner_tree_type;
}
GncPluginPage * gnc_plugin_page_owner_tree_new ( GncOwnerType  owner_type)

Create a new "owner tree" plugin page.

Parameters:
owner_typeThe owner type to create a page for. Can be any of the owner types defined in GnuCash, like vendor, customer,...
Returns:
The newly created plugin page.

Definition at line 341 of file gnc-plugin-page-owner-tree.c.

{
    GncPluginPageOwnerTree *plugin_page;

    GncPluginPageOwnerTreePrivate *priv;
    gchar* label = "";
    const GList *item;

    GtkActionGroup *action_group;
    GtkAction    *action;
    GValue        gvalue = { 0 };
    gint          i;

    g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED)
                          && (owner_type != GNC_OWNER_NONE), NULL);
    ENTER(" ");

    /* Is there an existing page? */
    item = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_OWNER_TREE_NAME);
    for ( ; item; item = g_list_next(item))
    {
        plugin_page = (GncPluginPageOwnerTree *)item->data;
        priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
        if (priv->owner_type == owner_type)
        {
            LEAVE("existing %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page);
            return GNC_PLUGIN_PAGE(plugin_page);
        }
    }

    plugin_page = g_object_new(GNC_TYPE_PLUGIN_PAGE_OWNER_TREE, NULL);

    priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE(plugin_page);
    priv->owner_type = owner_type;

    switch (owner_type)
    {
    case GNC_OWNER_NONE :
    case GNC_OWNER_UNDEFINED :
        break;
    case GNC_OWNER_CUSTOMER :
    {
        label = N_("Customers");
        priv->gconf_section = g_strdup("window/pages/customer_tree");
        break;
    }
    case GNC_OWNER_JOB :
    {
        label = N_("Jobs");
        priv->gconf_section = g_strdup("window/pages/job_tree");
        break;
    }
    case GNC_OWNER_VENDOR :
    {
        label = N_("Vendors");
        priv->gconf_section = g_strdup("window/pages/vendor_tree");
        break;
    }
    case GNC_OWNER_EMPLOYEE :
    {
        label = N_("Employees");
        priv->gconf_section = g_strdup("window/pages/employee_tree");
        break;
    }
    }

    /* Hide menu and toolbar items that are not relevant for the active owner list */
    action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(plugin_page));
    g_value_init (&gvalue, G_TYPE_BOOLEAN);
    for (i = 0; action_owners[i].action_name; i++)
    {
        action = gtk_action_group_get_action (action_group, action_owners[i].action_name);
        g_value_set_boolean (&gvalue, (priv->owner_type == action_owners[i].owner_type) );
        g_object_set_property (G_OBJECT(action), "visible", &gvalue);
    }


    g_object_set(G_OBJECT(plugin_page), "page-name", label, NULL);

    LEAVE("new %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page);
    return GNC_PLUGIN_PAGE(plugin_page);
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines