Beispiel #1
0
gboolean
gnc_valid_policy (const gchar *name)
{
    GList *list_of_policies = NULL;
    gboolean ret_val = FALSE;

    if (!name)
        return ret_val;

    list_of_policies = gnc_get_valid_policy_list();
    if (!list_of_policies)
    {
        return ret_val;
    }
    else
    {
        GList *l = NULL;
        for (l = list_of_policies; l != NULL; l = l->next)
        {
            GList *policy_list = l->data;
            if (g_strcmp0(policy_list->data, name) == 0)
                ret_val = TRUE;
            g_list_free(policy_list);
        }
        g_list_free(list_of_policies);
    return ret_val;
    }
}
Beispiel #2
0
gboolean
gnc_valid_policy_name (const gchar *policy_name)
{
    GList *list_of_policies = NULL;
    gboolean ret_val = FALSE;

    if (!policy_name)
        return ret_val;

    list_of_policies = gnc_get_valid_policy_list();
    if (!list_of_policies)
    {
        return ret_val;
    }
    else
    {
        GList *l = NULL;
        for (l = list_of_policies; l != NULL; l = l->next)
        {
            GNCPolicy *list_pcy = l->data;
            if (g_strcmp0(PolicyGetName (list_pcy), policy_name) == 0)
                ret_val = TRUE;
        }
        g_list_free(list_of_policies);
        return ret_val;
    }
}
Beispiel #3
0
/* This function returns a widget for selecting a cost policy
 */
GtkWidget *
gnc_cost_policy_select_new (void)
{
    GtkWidget *cost_policy_widget = NULL;
    GList *list_of_policies = NULL;

    list_of_policies = gnc_get_valid_policy_list();

    g_return_val_if_fail(g_list_length (list_of_policies) >= 0, NULL);
    if (list_of_policies)
    {
        GtkListStore *store;
        GtkTreeIter  iter;
        const char *description;
        const char *hintstring;
        GList *l = NULL;

        store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
        /* Add values to the list store, entry and tooltip */
        for (l = list_of_policies; l != NULL; l = l->next)
        {
            GNCPolicy *pcy = l->data;
            description = PolicyGetDescription(pcy);
            hintstring = PolicyGetHint(pcy);
            gtk_list_store_append (store, &iter);
            gtk_list_store_set
                   (store,
                    &iter,
                    0,
                    (description && *description) ? _(description) : "",
                    1,
                    (hintstring && *hintstring) ? _(hintstring) : "",
                    -1);
        }
        g_list_free(list_of_policies);
        /* Create the new Combo with tooltip and add the store */
        cost_policy_widget = GTK_WIDGET(gnc_combott_new());
        g_object_set( G_OBJECT( cost_policy_widget ),
                      "model",
                      GTK_TREE_MODEL(store),
                      NULL );
        g_object_unref(store);
    }
    return cost_policy_widget;
}