/******************************************************************** * update_report_list * * this procedure does the real work of displaying a sorted list of * available custom reports ********************************************************************/ static void update_report_list(GtkListStore *store, CustomReportDialog *crd) { SCM get_rpt_guids = scm_c_eval_string("gnc:custom-report-template-guids"); SCM template_menu_name = scm_c_eval_string("gnc:report-template-menu-name/report-guid"); SCM rpt_guids; int i; GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL (store); gboolean valid_iter; gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), COL_NAME, GTK_SORT_ASCENDING); crd->reportlist = scm_call_0(get_rpt_guids); rpt_guids = crd->reportlist; /* Empty current liststore */ valid_iter = gtk_tree_model_get_iter_first (model, &iter); while (valid_iter) { GValue value = { 0, }; GncGUID *row_guid; g_value_init ( &value, G_TYPE_POINTER); gtk_tree_model_get_value (model, &iter, COL_NUM, &value); row_guid = (GncGUID *) g_value_get_pointer (&value); guid_free (row_guid); g_value_unset (&value); valid_iter = gtk_tree_model_iter_next (model, &iter); } gtk_list_store_clear(store); if (scm_is_list(rpt_guids)) { /* for all the report guids in the list, store them, with a reference, in the gtkliststore */ for (i = 0; !scm_is_null(rpt_guids); i++) { GncGUID *guid = guid_malloc (); gchar *guid_str = scm_to_utf8_string (SCM_CAR(rpt_guids)); gchar *name = gnc_scm_to_utf8_string (scm_call_2(template_menu_name, SCM_CAR(rpt_guids), SCM_BOOL_F)); if (string_to_guid (guid_str, guid)) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, COL_NAME, name, COL_NUM, guid, -1); } g_free (name); g_free (guid_str); rpt_guids = SCM_CDR(rpt_guids); } } }
/*********************************************************** * gnc_ui_custom_report_edit_name * * open the custom report dialog and highlight the given * report's name for editing. ***********************************************************/ void gnc_ui_custom_report_edit_name (GncMainWindow * window, SCM scm_guid) { SCM is_custom_report; CustomReportDialog *crd = gnc_ui_custom_report_internal (window); GtkTreeModel *model; GtkTreeIter iter; GncGUID *guid; gchar *guid_str; gboolean valid_iter; is_custom_report = scm_c_eval_string ("gnc:report-template-is-custom/template-guid?"); if (scm_is_false (scm_call_1 (is_custom_report, scm_guid))) return; guid = guid_malloc (); guid_str = scm_to_utf8_string (scm_guid); if (!string_to_guid (guid_str, guid)) goto cleanup; /* Look up the row for the requested guid */ model = gtk_tree_view_get_model (GTK_TREE_VIEW (crd->reportview)); valid_iter = gtk_tree_model_get_iter_first (model, &iter); while (valid_iter) { GValue value = { 0, }; GncGUID *row_guid; gtk_tree_model_get_value (model, &iter, COL_NUM, &value); row_guid = (GncGUID *) g_value_get_pointer (&value); if (guid_equal (guid, row_guid)) { /* We found the row for the requested guid * Now let's set the report's name cell in edit mode * so the user can edit the name. */ GtkTreePath *path; GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (crd->reportview)); gtk_tree_selection_select_iter (selection, &iter); path = gtk_tree_model_get_path (model, &iter); g_object_set(G_OBJECT(crd->namerenderer), "editable", TRUE, NULL); gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (crd->reportview), path, crd->namecol, crd->namerenderer, TRUE); break; } g_value_unset (&value); valid_iter = gtk_tree_model_iter_next (model, &iter); } cleanup: guid_free (guid); }
static gboolean destroy_event_hash_helper (gpointer key, gpointer value, gpointer user_data) { GncGUID *guid = key; EventInfo *ei = value; guid_free (guid); g_free (ei); return TRUE; }
static void dqv_clear_booklist (DialogQueryView *dqv) { GList *node; g_return_if_fail (dqv); for (node = dqv->books; node; node = node->next) guid_free ((GncGUID*)node->data); g_list_free (dqv->books); dqv->books = NULL; }
static void test_null_guid(void) { GncGUID g; GncGUID *gp; g = guid_new_return(); gp = guid_new(); do_test(guid_equal(guid_null(), guid_null()), "null guids equal"); do_test(!guid_equal(&g, gp), "two guids equal"); guid_free(gp); }
static void add_event (ComponentEventInfo *cei, const GncGUID *entity, QofEventId event_mask, gboolean or_in) { GHashTable *hash; if (!cei || !cei->entity_events || !entity) return; hash = cei->entity_events; if (event_mask == 0) { gpointer key; gpointer value; if (or_in) return; if (g_hash_table_lookup_extended (hash, entity, &key, &value)) { g_hash_table_remove (hash, entity); guid_free (key); g_free (value); } } else { EventInfo *ei; ei = g_hash_table_lookup (hash, entity); if (ei == NULL) { GncGUID *key; key = guid_malloc (); *key = *entity; ei = g_new (EventInfo, 1); ei->event_mask = 0; g_hash_table_insert (hash, key, ei); } if (or_in) ei->event_mask |= event_mask; else ei->event_mask = event_mask; } }