Exemplo n.º 1
0
static gint
sort_ns_or_cm (GtkTreeModel *f_model,
               GtkTreeIter *f_iter_a,
               GtkTreeIter *f_iter_b)
{
    GncTreeModelPrice *model;
    GtkTreeModel *tree_model;
    GtkTreeIter iter_a, iter_b;
    gnc_commodity_namespace *ns_a, *ns_b;
    gnc_commodity *comm_a, *comm_b;

    tree_model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
    model = GNC_TREE_MODEL_PRICE(tree_model);

    gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(f_model),
            &iter_a,
            f_iter_a);
    gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(f_model),
            &iter_b,
            f_iter_b);

    if (gnc_tree_model_price_iter_is_namespace (model, &iter_a))
    {
        ns_a = gnc_tree_model_price_get_namespace (model, &iter_a);
        ns_b = gnc_tree_model_price_get_namespace (model, &iter_b);
        return safe_utf8_collate (gnc_commodity_namespace_get_name (ns_a),
                                  gnc_commodity_namespace_get_name (ns_b));
    }

    comm_a = gnc_tree_model_price_get_commodity (model, &iter_a);
    comm_b = gnc_tree_model_price_get_commodity (model, &iter_b);
    return safe_utf8_collate (gnc_commodity_get_mnemonic (comm_a),
                              gnc_commodity_get_mnemonic (comm_b));
}
static gint
sort_namespace (GtkTreeModel *f_model,
                GtkTreeIter *f_iter_a,
                GtkTreeIter *f_iter_b)
{
    GncTreeModelCommodity *model;
    GtkTreeModel *tree_model;
    GtkTreeIter iter_a, iter_b;
    gnc_commodity_namespace *ns_a, *ns_b;

    tree_model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
    model = GNC_TREE_MODEL_COMMODITY(tree_model);

    gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(f_model),
            &iter_a,
            f_iter_a);
    gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(f_model),
            &iter_b,
            f_iter_b);

    ns_a = gnc_tree_model_commodity_get_namespace (model, &iter_a);
    ns_b = gnc_tree_model_commodity_get_namespace (model, &iter_b);
    return safe_utf8_collate (gnc_commodity_namespace_get_name (ns_a),
                              gnc_commodity_namespace_get_name (ns_b));
}
static gboolean
gnc_commodities_dialog_filter_ns_func (gnc_commodity_namespace *comm_namespace,
                                       gpointer data)
{
    CommoditiesDialog *cd = data;
    const gchar *name;
    GList *list;

    /* Never show the template list */
    name = gnc_commodity_namespace_get_name (comm_namespace);
    if (g_strcmp0 (name, "template") == 0)
        return FALSE;

    /* Check whether or not to show commodities */
    if (!cd->show_currencies && gnc_commodity_namespace_is_iso(name))
        return FALSE;

    /* Show any other namespace that has commodities */
    list = gnc_commodity_namespace_get_commodity_list(comm_namespace);
    return (list != NULL);
}