Пример #1
0
GtkTreeModel *
gnc_tree_model_commodity_new (QofBook *book, gnc_commodity_table *ct)
{
    GncTreeModelCommodity *model;
    GncTreeModelCommodityPrivate *priv;
    const GList *item;

    ENTER("");

    item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_COMMODITY_NAME);
    for ( ; item; item = g_list_next(item))
    {
        model = (GncTreeModelCommodity *)item->data;
        priv = GNC_TREE_MODEL_COMMODITY_GET_PRIVATE(model);
        if (priv->commodity_table == ct)
        {
            g_object_ref(G_OBJECT(model));
            LEAVE("returning existing model %p", model);
            return GTK_TREE_MODEL(model);
        }
    }

    model = g_object_new (GNC_TYPE_TREE_MODEL_COMMODITY, NULL);
    priv = GNC_TREE_MODEL_COMMODITY_GET_PRIVATE(model);
    priv->book = book;
    priv->commodity_table = ct;

    priv->event_handler_id =
        qof_event_register_handler (gnc_tree_model_commodity_event_handler, model);

    LEAVE("");
    return GTK_TREE_MODEL (model);
}
Пример #2
0
GtkTreeModel *
gnc_tree_model_owner_new (GncOwnerType owner_type)
{
    GncTreeModelOwner *model;
    GncTreeModelOwnerPrivate *priv;
    const GList *item;

    ENTER("owner_type %d", owner_type);
    item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_OWNER_NAME);
    for ( ; item; item = g_list_next(item))
    {
        model = (GncTreeModelOwner *)item->data;
        priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
        if (priv->owner_type == owner_type)
        {
            g_object_ref(G_OBJECT(model));
            LEAVE("returning existing model %p", model);
            return GTK_TREE_MODEL(model);
        }
    }

    model = g_object_new (GNC_TYPE_TREE_MODEL_OWNER,
                          NULL);

    priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
    priv->book = gnc_get_current_book();
    priv->owner_type = owner_type;
    priv->owner_list = gncBusinessGetOwnerList (priv->book, gncOwnerTypeToQofIdType(owner_type), TRUE);

    priv->event_handler_id = qof_event_register_handler
                             ((QofEventHandler)gnc_tree_model_owner_event_handler, model);

    LEAVE("model %p", model);
    return GTK_TREE_MODEL (model);
}
Пример #3
0
GncPluginPage *
gnc_plugin_page_invoice_new (InvoiceWindow *iw)
{
    GncPluginPageInvoicePrivate *priv;
    GncPluginPageInvoice *invoice_page;
    GncPluginPage *plugin_page;
    const GList *item;

    /* Is there an existing page? */
    item = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_INVOICE_NAME);
    for ( ; item; item = g_list_next(item))
    {
        invoice_page = (GncPluginPageInvoice *)item->data;
        priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(invoice_page);
        if (priv->iw == iw)
            return GNC_PLUGIN_PAGE(invoice_page);
    }

    invoice_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_INVOICE, (char *)NULL);
    priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(invoice_page);
    priv->iw = iw;

    plugin_page = GNC_PLUGIN_PAGE(invoice_page);
    gnc_plugin_page_invoice_update_title(plugin_page);
    gnc_plugin_page_set_uri(plugin_page, "default:");

    priv->component_manager_id = 0;
    return plugin_page;
}
Пример #4
0
static void
gtvo_currency_changed_cb (void)
{
    const GList *views, *ptr;

    views = gnc_gobject_tracking_get_list (GNC_TREE_VIEW_OWNER_NAME);
    for (ptr = views; ptr; ptr = g_list_next(ptr))
    {
        gtvo_update_column_names (ptr->data);
    }
}
GncPluginPage *
gnc_plugin_page_sx_list_new (void)
{
    GncPluginPageSxList *plugin_page;
    const GList *object = gnc_gobject_tracking_get_list (GNC_PLUGIN_PAGE_SX_LIST_NAME);
    if (object && GNC_IS_PLUGIN_PAGE_SX_LIST (object->data))
	plugin_page = GNC_PLUGIN_PAGE_SX_LIST (object->data);
    else
    {
	plugin_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_SX_LIST, NULL);
    }
    return GNC_PLUGIN_PAGE(plugin_page);
}
GncPluginPage *
gnc_plugin_page_owner_tree_new (GncOwnerType owner_type)
{
    GncPluginPageOwnerTree *plugin_page;

    GncPluginPageOwnerTreePrivate *priv;
    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;

    /* 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);
    }

    LEAVE("new %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page);
    return GNC_PLUGIN_PAGE(plugin_page);
}