static void combo_box_changed (GtkComboBox *combo_box, struct _crit_data *data) { GNCSearchParam *param; GNCSearchCoreType *newelem; GtkTreeModel *model; GtkTreeIter iter; if (!gtk_combo_box_get_active_iter(combo_box, &iter)) return; model = gtk_combo_box_get_model(combo_box); gtk_tree_model_get(model, &iter, SEARCH_COL_POINTER, ¶m, -1); if (gnc_search_param_type_match (param, data->param)) { /* The param type is the same, just save the new param */ data->param = param; return; } data->param = param; /* OK, let's do a widget shuffle, throw away the old widget/element, * and create another one here. No need to change the crit_list -- * the pointer to data stays the same. */ if (data->elemwidget) gtk_container_remove (GTK_CONTAINER (data->container), data->elemwidget); g_object_unref (G_OBJECT (data->element)); newelem = gnc_search_core_type_new_type_name (gnc_search_param_get_param_type (param)); data->element = newelem; data->elemwidget = gnc_search_core_type_get_widget (newelem); if (data->elemwidget) { gtk_box_pack_start (GTK_BOX (data->container), data->elemwidget, FALSE, FALSE, 0); } /* Make sure it's visible */ gtk_widget_show_all (data->container); /* Make sure we widen up if necessary */ gtk_widget_queue_resize (GTK_WIDGET (data->dialog)); /* And grab focus */ gnc_search_core_type_grab_focus (newelem); gnc_search_core_type_editable_enters (newelem); }
/********************************************************************\ * gnc_query_list_set_query_sort * * sets the sorting order of entries in the list * * * * Args: list - list to change the sort order for * * new_column - is this a new column (so should we set the * * query sort order or just set the 'increasing' * * Returns: nothing * \********************************************************************/ static void gnc_query_list_set_query_sort (GNCQueryList *list, gboolean new_column) { gboolean sort_order = list->increasing; GList *node; GNCSearchParam *param; /* Find the column parameter definition */ node = g_list_nth(list->column_params, list->sort_column); param = node->data; /* If we're asked to invert numerics, and if this is a numeric or * debred column, then invert the sort order. */ if (list->numeric_inv_sort) { const char *type = gnc_search_param_get_param_type (param); if (!safe_strcmp(type, QOF_TYPE_NUMERIC) || !safe_strcmp(type, QOF_TYPE_DEBCRED)) sort_order = !sort_order; } /* Set the sort order for the engine, if the key changed */ if (new_column) { GSList *p1, *p2; p1 = gnc_search_param_get_param_path(param); p2 = g_slist_prepend(NULL, QUERY_DEFAULT_SORT); qof_query_set_sort_order (list->query, p1, p2, NULL); } qof_query_set_sort_increasing (list->query, sort_order, sort_order, sort_order); /* * Recompute the list. Is this really necessary? Why not just sort * the rows already in the clist? Answer: it would be an n-squared * algorithm to get the clist to match the resulting list. */ gnc_query_list_refresh(list); }
static void update_booleans (GNCQueryList *list, gint row) { GtkCList *clist = GTK_CLIST(list); gpointer entry; GList *node; gint i; gboolean result; entry = gtk_clist_get_row_data (clist, row); for (i = 0, node = list->column_params; node; node = node->next, i++) { GNCSearchParam *param = node->data; const char *type = gnc_search_param_get_param_type (param); /* if this is a boolean, ignore it now -- we'll use a checkmark later */ if (safe_strcmp (type, QOF_TYPE_BOOLEAN)) continue; result = (gboolean) GPOINTER_TO_INT(gnc_search_param_compute_value(param, entry)); gnc_clist_set_check (clist, row, i, result); } }
static void gnc_query_list_fill(GNCQueryList *list) { GNCQueryListPriv *priv; gchar *strings[list->num_columns + 1]; GList *entries, *item; const GncGUID *guid; gint i; /* Clear all watches */ priv = GNC_QUERY_LIST_GET_PRIVATE(list); gnc_gui_component_clear_watches (priv->component_id); /* Reverse the list now because 'append()' takes too long */ entries = qof_query_run(list->query); for (item = entries; item; item = item->next) { GList *node; gint row; const QofParam *gup; QofParam *qp = NULL; for (i = 0, node = list->column_params; node; node = node->next) { GNCSearchParam *param = node->data; GSList *converters = gnc_search_param_get_converters (param); const char *type = gnc_search_param_get_param_type (param); gpointer res = item->data; /* if this is a boolean, ignore it now -- we'll use a checkmark later */ if (!safe_strcmp (type, QOF_TYPE_BOOLEAN)) { strings[i++] = g_strdup(""); continue; } /* Do all the object conversions */ for (; converters; converters = converters->next) { qp = converters->data; if (converters->next) { res = (qp->param_getfcn)(res, qp); } } /* Now convert this to a text value for the row */ if (!safe_strcmp(type, QOF_TYPE_DEBCRED) || !safe_strcmp(type, QOF_TYPE_NUMERIC)) { gnc_numeric (*nfcn)(gpointer, QofParam *) = (gnc_numeric(*)(gpointer, QofParam *))(qp->param_getfcn); gnc_numeric value = nfcn(res, qp); if (list->numeric_abs) value = gnc_numeric_abs (value); strings[i++] = g_strdup(xaccPrintAmount(value, gnc_default_print_info(FALSE))); } else strings[i++] = qof_query_core_to_string (type, res, qp); } row = gtk_clist_append (GTK_CLIST(list), (gchar **) strings); gtk_clist_set_row_data (GTK_CLIST(list), row, item->data); /* Free up our strings */ for (i = 0; i < list->num_columns; i++) { if (strings[i]) g_free (strings[i]); } /* Now update any checkmarks */ update_booleans (list, row); /* and set a watcher on this item */ gup = priv->get_guid; guid = (const GncGUID*)((gup->param_getfcn)(item->data, gup)); gnc_gui_component_watch_entity (priv->component_id, guid, QOF_EVENT_MODIFY | QOF_EVENT_DESTROY); list->num_entries++; } }