[Gnucash-changes] r13937 - gnucash/branches/deprecated-cleanup -
First cleanup pass. Mostly conversions from GtkCList to
David Hampton
hampton at cvs.gnucash.org
Sat May 6 20:38:47 EDT 2006
Author: hampton
Date: 2006-05-06 20:38:45 -0400 (Sat, 06 May 2006)
New Revision: 13937
Trac: http://svn.gnucash.org/trac/changeset/13937
Modified:
gnucash/branches/deprecated-cleanup/ChangeLog
gnucash/branches/deprecated-cleanup/src/business/business-gnome/dialog-billterms.c
gnucash/branches/deprecated-cleanup/src/business/business-gnome/glade/billterms.glade
gnucash/branches/deprecated-cleanup/src/business/dialog-tax-table/dialog-tax-table.c
gnucash/branches/deprecated-cleanup/src/business/dialog-tax-table/tax-tables.glade
gnucash/branches/deprecated-cleanup/src/gnome-utils/dialog-account.c
gnucash/branches/deprecated-cleanup/src/gnome-utils/dialog-utils.h
gnucash/branches/deprecated-cleanup/src/gnome-utils/glade/druid-provider-multifile.glade
gnucash/branches/deprecated-cleanup/src/gnome-utils/gnc-druid-provider-multifile-gnome.c
gnucash/branches/deprecated-cleanup/src/gnome-utils/gnc-druid-provider-multifile-gnome.h
gnucash/branches/deprecated-cleanup/src/gnome-utils/gw-gnome-utils-spec.scm
gnucash/branches/deprecated-cleanup/src/gnome/druid-loan.c
gnucash/branches/deprecated-cleanup/src/gnome/druid-stock-split.c
gnucash/branches/deprecated-cleanup/src/gnome/glade/account.glade
gnucash/branches/deprecated-cleanup/src/gnome/glade/stocks.glade
gnucash/branches/deprecated-cleanup/src/import-export/hbci/druid-hbci-initial.c
gnucash/branches/deprecated-cleanup/src/import-export/hbci/glade/hbci.glade
gnucash/branches/deprecated-cleanup/src/import-export/qif-import/dialog-account-picker.c
gnucash/branches/deprecated-cleanup/src/import-export/qif-import/druid-qif-import.c
gnucash/branches/deprecated-cleanup/src/import-export/qif-import/qif.glade
gnucash/branches/deprecated-cleanup/src/report/report-gnome/dialog-column-view.c
gnucash/branches/deprecated-cleanup/src/report/report-gnome/report.glade
Log:
First cleanup pass. Mostly conversions from GtkCList to
GtkTreeView/GtkTreeStore.
Modified: gnucash/branches/deprecated-cleanup/ChangeLog
===================================================================
--- gnucash/branches/deprecated-cleanup/ChangeLog 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/ChangeLog 2006-05-07 00:38:45 UTC (rev 13937)
@@ -1,5 +1,34 @@
2006-05-06 David Hampton <hampton at employees.org>
+ * src/import-export/qif-import/dialog-account-picker.c:
+ * src/import-export/qif-import/qif.glade:
+ * src/import-export/qif-import/druid-qif-import.c:
+ * src/import-export/hbci/druid-hbci-initial.c:
+ * src/import-export/hbci/glade/hbci.glade:
+ * src/report/report-gnome/dialog-column-view.c:
+ * src/report/report-gnome/report.glade:
+ * src/business/business-gnome/dialog-billterms.c:
+ * src/business/business-gnome/glade/billterms.glade:
+ * src/business/dialog-tax-table/dialog-tax-table.c:
+ * src/business/dialog-tax-table/tax-tables.glade:
+ * src/gnome-utils/gnc-druid-provider-multifile-gnome.[ch]:
+ * src/gnome-utils/gw-gnome-utils-spec.scm:
+ * src/gnome-utils/dialog-account.c:
+ * src/gnome-utils/glade/druid-provider-multifile.glade:
+ * src/gnome-utils/dialog-utils.h:
+ * src/gnome/druid-loan.c:
+ * src/gnome/glade/stocks.glade:
+ * src/gnome/glade/account.glade:
+ * src/gnome/druid-stock-split.c: First cleanup pass. Mostly
+ conversions from GtkCList to GtkTreeView/GtkTreeStore.
+
+********************
+* Above this line is the deprecated-cleanup branch ChangeLog.
+* Below this line is the Trunk ChangeLog
+********************
+
+2006-05-06 David Hampton <hampton at employees.org>
+
* src/register/register-gnome/gnucash-header.c:
* src/gnome-utils/dialog-transfer.c: Trivial replacements for
deprecated functions.
Modified: gnucash/branches/deprecated-cleanup/src/business/business-gnome/dialog-billterms.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/business/business-gnome/dialog-billterms.c 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/business/business-gnome/dialog-billterms.c 2006-05-07 00:38:45 UTC (rev 13937)
@@ -2,6 +2,7 @@
* dialog-billterms.c -- Dialog to create and edit billing terms
* Copyright (C) 2002 Derek Atkins
* Author: Derek Atkins <warlord at MIT.EDU>
+ * Copyright (c) 2006 David Hampton <hampton at employees.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -39,8 +40,9 @@
#define DIALOG_BILLTERMS_CM_CLASS "billterms-dialog"
-void billterms_row_selected (GtkCList *clist, gint row, gint column,
- GdkEventButton *event, gpointer user_data);
+#define TERM_NAME 0
+#define TERM_TERM 1
+
void billterms_new_term_cb (GtkButton *button, BillTermsWindow *btw);
void billterms_delete_term_cb (GtkButton *button, BillTermsWindow *btw);
void billterms_edit_term_cb (GtkButton *button, BillTermsWindow *btw);
@@ -68,7 +70,7 @@
struct _billterms_window {
GtkWidget * dialog;
- GtkWidget * terms_clist;
+ GtkWidget * terms_view;
GtkWidget * desc_entry;
GtkWidget * type_label;
GtkWidget * term_vbox;
@@ -509,27 +511,26 @@
billterms_window_refresh (BillTermsWindow *btw)
{
GList *list, *node;
- GtkAdjustment *vadjustment;
- GtkCList *clist;
- gfloat save_value = 0.0;
+ GncBillTerm *term;
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeSelection *selection;
+ GtkTreeRowReference *reference = NULL;
g_return_if_fail (btw);
- clist = GTK_CLIST (btw->terms_clist);
+ view = GTK_TREE_VIEW (btw->terms_view);
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
- vadjustment = gtk_clist_get_vadjustment (clist);
- if (vadjustment)
- save_value = vadjustment->value;
-
/* Clear the list */
- gtk_clist_freeze (clist);
- gtk_clist_clear (clist);
-
+ gtk_list_store_clear (store);
gnc_gui_component_clear_watches (btw->component_id);
/* Add the items to the list */
list = gncBillTermGetTerms (btw->book);
- /* If there are no erms, clear the term display */
+ /* If there are no terms, clear the term display */
if (list == NULL) {
btw->current_term = NULL;
billterms_term_refresh (btw);
@@ -538,20 +539,21 @@
}
for ( node = list; node; node = node->next) {
- char *row_text[2];
- gint row;
- GncBillTerm *term = node->data;
-
+ term = node->data;
gnc_gui_component_watch_entity (btw->component_id,
gncBillTermGetGUID (term),
QOF_EVENT_MODIFY);
- row_text[0] = (char *)gncBillTermGetName (term);
- row_text[1] = NULL;
-
- row = gtk_clist_prepend (clist, row_text);
- gtk_clist_set_row_data (clist, row, term);
- gtk_clist_set_selectable (clist, row, TRUE);
+ gtk_list_store_prepend(store, &iter);
+ gtk_list_store_set(store, &iter,
+ TERM_NAME, gncBillTermGetName(term),
+ TERM_TERM, term,
+ -1);
+ if (term == btw->current_term) {
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
+ reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
+ gtk_tree_path_free(path);
+ }
}
g_list_free (list);
@@ -560,49 +562,46 @@
GNC_BILLTERM_MODULE_NAME,
QOF_EVENT_CREATE | QOF_EVENT_DESTROY);
- if (vadjustment) {
- save_value = CLAMP (save_value, vadjustment->lower,
- vadjustment->upper - vadjustment->page_size);
- gtk_adjustment_set_value (vadjustment, save_value);
+ if (reference) {
+ path = gtk_tree_row_reference_get_path(reference);
+ gtk_tree_row_reference_free(reference);
+ if (path) {
+ selection = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_view_scroll_to_cell(view, path, NULL, TRUE, 0.5, 0.0);
+ gtk_tree_path_free(path);
+ }
}
-
- gtk_clist_thaw (clist);
-
- {
- gint row = gtk_clist_find_row_from_data (clist, btw->current_term);
-
- if (row < 0)
- row = 0;
-
- gtk_clist_select_row (clist, row, 0);
-
- /* If this row isn't visible, move it to the center */
- if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_FULL)
- gtk_clist_moveto (clist, row, 0, 0.5, 0);
- }
- /* select_row() above will refresh the term display */
}
-void
-billterms_row_selected (GtkCList *clist, gint row, gint column,
- GdkEventButton *event, gpointer user_data)
+static void
+billterm_selection_changed (GtkTreeSelection *selection,
+ BillTermsWindow *btw)
{
- BillTermsWindow *btw = user_data;
- GncBillTerm *term = gtk_clist_get_row_data (clist, row);
+ GncBillTerm *term = NULL;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
g_return_if_fail (btw);
- g_return_if_fail (term);
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ gtk_tree_model_get(model, &iter, TERM_TERM, &term, -1);
+
/* If we've changed, then reset the term list */
if (term != btw->current_term)
btw->current_term = term;
/* And force a refresh of the entries */
billterms_term_refresh (btw);
+}
- /* If the user double-clicked on the item, pop up the edit window */
- if (event && event->type == GDK_2BUTTON_PRESS)
- new_billterm_dialog (btw, term, NULL);
+static void
+billterm_selection_activated (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ BillTermsWindow *btw)
+{
+ new_billterm_dialog (btw, btw->current_term, NULL);
}
void
@@ -702,6 +701,11 @@
BillTermsWindow *btw;
GladeXML *xml;
GtkWidget *widget;
+ GtkTreeView *view;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkListStore *store;
+ GtkTreeSelection *selection;
if (!book) return NULL;
@@ -724,11 +728,28 @@
/* Open and read the XML */
xml = gnc_glade_xml_new ("billterms.glade", "Terms Window");
btw->dialog = glade_xml_get_widget (xml, "Terms Window");
- btw->terms_clist = glade_xml_get_widget (xml, "terms_clist");
+ btw->terms_view = glade_xml_get_widget (xml, "terms_view");
btw->desc_entry = glade_xml_get_widget (xml, "desc_entry");
btw->type_label = glade_xml_get_widget (xml, "type_label");
btw->term_vbox = glade_xml_get_widget (xml, "term_vbox");
+ /* Initialize the view */
+ view = GTK_TREE_VIEW(btw->terms_view);
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
+ gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("", renderer,
+ "text", TERM_NAME,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ g_signal_connect(view, "row-activated",
+ G_CALLBACK(billterm_selection_activated), btw);
+ selection = gtk_tree_view_get_selection(view);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(billterm_selection_changed), btw);
+
/* Initialize the notebook widgets */
init_notebook_widgets (&btw->notebook, TRUE,
GTK_DIALOG (btw->dialog), btw);
Modified: gnucash/branches/deprecated-cleanup/src/business/business-gnome/glade/billterms.glade
===================================================================
--- gnucash/branches/deprecated-cleanup/src/business/business-gnome/glade/billterms.glade 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/business/business-gnome/glade/billterms.glade 2006-05-07 00:38:45 UTC (rev 13937)
@@ -107,30 +107,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="terms_clist">
+ <widget class="GtkTreeView" id="terms_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">1</property>
- <property name="column_widths">80</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">False</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <signal name="select_row" handler="billterms_row_selected" last_modification_time="Mon, 08 Sep 2003 02:00:56 GMT"/>
-
- <child>
- <widget class="GtkLabel" id="label23">
- <property name="label" translatable="yes"></property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
Modified: gnucash/branches/deprecated-cleanup/src/business/dialog-tax-table/dialog-tax-table.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/business/dialog-tax-table/dialog-tax-table.c 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/business/dialog-tax-table/dialog-tax-table.c 2006-05-07 00:38:45 UTC (rev 13937)
@@ -43,23 +43,26 @@
#define DIALOG_TAX_TABLE_CM_CLASS "tax-table-dialog"
#define GCONF_SECTION "dialogs/business/tax_tables"
+#define TABLE_NAME 0
+#define TABLE_POINTER 1
+
+#define ENTRY_NAME 0
+#define ENTRY_POINTER 1
+#define ENTRY_AMOUNT 2
+
void tax_table_new_table_cb (GtkButton *button, TaxTableWindow *ttw);
void tax_table_delete_table_cb (GtkButton *button, TaxTableWindow *ttw);
void tax_table_new_entry_cb (GtkButton *button, TaxTableWindow *ttw);
void tax_table_edit_entry_cb (GtkButton *button, TaxTableWindow *ttw);
void tax_table_delete_entry_cb (GtkButton *button, TaxTableWindow *ttw);
-void tax_table_row_selected (GtkCList *clist, gint row, gint column,
- GdkEventButton *event, gpointer user_data);
-void tax_table_entry_row_selected (GtkCList *clist, gint row, gint column,
- GdkEventButton *event, gpointer user_data);
void tax_table_window_close (GtkWidget *widget, gpointer data);
void tax_table_window_destroy_cb (GtkWidget *widget, gpointer data);
struct _taxtable_window {
GtkWidget * dialog;
- GtkWidget * names_clist;
- GtkWidget * entries_clist;
+ GtkWidget * names_view;
+ GtkWidget * entries_view;
GncTaxTable * current_table;
GncTaxTableEntry * current_entry;
@@ -332,26 +335,27 @@
/***********************************************************************/
static void
-tax_table_entries_refresh (TaxTableWindow *ttw, gboolean new_table)
+tax_table_entries_refresh (TaxTableWindow *ttw)
{
GList *list, *node;
- GtkAdjustment *vadjustment = NULL;
- GtkCList *clist;
- gfloat save_value = 0.0;
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeSelection *selection;
+ GtkTreeRowReference *reference = NULL;
+ GncTaxTableEntry *selected_entry;
g_return_if_fail (ttw);
- clist = GTK_CLIST (ttw->entries_clist);
+ view = GTK_TREE_VIEW (ttw->entries_view);
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
- if (!new_table) {
- vadjustment = gtk_clist_get_vadjustment (clist);
- if (vadjustment)
- save_value = vadjustment->value;
- }
-
/* Clear the list */
- gtk_clist_freeze (clist);
- gtk_clist_clear (clist);
+ selected_entry = ttw->current_entry;
+ gtk_list_store_clear (store);
+ if (ttw->current_table == NULL)
+ return;
/* Add the items to the list */
list = gncTaxTableGetEntries (ttw->current_table);
@@ -360,7 +364,6 @@
for (node = list ; node; node = node->next) {
char *row_text[3];
- gint row;
GncTaxTableEntry *entry = node->data;
Account *acc = gncTaxTableEntryGetAccount (entry);
gnc_numeric amount = gncTaxTableEntryGetAmount (entry);
@@ -380,126 +383,115 @@
gnc_default_print_info (TRUE)));
break;
}
- row_text[2] = NULL;
- row = gtk_clist_prepend (clist, row_text);
- gtk_clist_set_row_data (clist, row, entry);
- gtk_clist_set_selectable (clist, row, TRUE);
+ gtk_list_store_prepend(store, &iter);
+ gtk_list_store_set(store, &iter,
+ ENTRY_NAME, row_text[0],
+ ENTRY_POINTER, entry,
+ ENTRY_AMOUNT, row_text[1],
+ -1);
+ if (entry == selected_entry) {
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
+ reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
+ gtk_tree_path_free(path);
+ }
g_free (row_text[0]);
g_free (row_text[1]);
}
- g_list_free (list);
-
- if (!new_table) {
- if (vadjustment) {
- save_value = CLAMP (save_value, vadjustment->lower,
- vadjustment->upper - vadjustment->page_size);
- gtk_adjustment_set_value (vadjustment, save_value);
+ if (reference) {
+ path = gtk_tree_row_reference_get_path(reference);
+ gtk_tree_row_reference_free(reference);
+ if (path) {
+ selection = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_view_scroll_to_cell(view, path, NULL, TRUE, 0.5, 0.0);
+ gtk_tree_path_free(path);
}
}
-
- gtk_clist_thaw (clist);
-
- {
- gint row = gtk_clist_find_row_from_data (clist, ttw->current_entry);
-
- if (row < 0)
- row = 0;
-
- gtk_clist_select_row (clist, row, 0);
-
- /* If this row isn't visible, move it to the center */
- if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_FULL)
- gtk_clist_moveto (clist, row, 0, 0.5, 0);
- }
}
static void
tax_table_window_refresh (TaxTableWindow *ttw)
{
GList *list, *node;
- GtkAdjustment *vadjustment;
- GtkCList *clist;
- gfloat save_value = 0.0;
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeSelection *selection;
+ GtkTreeRowReference *reference = NULL;
g_return_if_fail (ttw);
- clist = GTK_CLIST (ttw->names_clist);
+ view = GTK_TREE_VIEW (ttw->names_view);
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
- vadjustment = gtk_clist_get_vadjustment (clist);
- if (vadjustment)
- save_value = vadjustment->value;
-
/* Clear the list */
- gtk_clist_freeze (clist);
- gtk_clist_clear (clist);
+ gtk_list_store_clear(store);
gnc_gui_component_clear_watches (ttw->component_id);
/* Add the items to the list */
list = gncTaxTableGetTables (ttw->book);
-
- /* If there are no tables, clear the entries list */
- if (list == NULL)
- gtk_clist_clear (GTK_CLIST (ttw->entries_clist));
- else
+ if (list)
list = g_list_reverse (g_list_copy (list));
for (node = list; node; node = node->next) {
- char *row_text[2];
- gint row;
GncTaxTable *table = node->data;
gnc_gui_component_watch_entity (ttw->component_id,
gncTaxTableGetGUID (table),
QOF_EVENT_MODIFY);
- row_text[0] = (char *)gncTaxTableGetName (table);
- row_text[1] = NULL;
-
- row = gtk_clist_prepend (clist, row_text);
- gtk_clist_set_row_data (clist, row, table);
- gtk_clist_set_selectable (clist, row, TRUE);
+ gtk_list_store_prepend(store, &iter);
+ gtk_list_store_set(store, &iter,
+ TABLE_NAME, gncTaxTableGetName (table),
+ TABLE_POINTER, table,
+ -1);
+ if (table == ttw->current_table) {
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
+ reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
+ gtk_tree_path_free(path);
+ }
}
- g_list_free (list);
+ if (list)
+ g_list_free (list);
gnc_gui_component_watch_entity_type (ttw->component_id,
GNC_TAXTABLE_MODULE_NAME,
QOF_EVENT_CREATE | QOF_EVENT_DESTROY);
- if (vadjustment) {
- save_value = CLAMP (save_value, vadjustment->lower,
- vadjustment->upper - vadjustment->page_size);
- gtk_adjustment_set_value (vadjustment, save_value);
+ if (reference) {
+ path = gtk_tree_row_reference_get_path(reference);
+ gtk_tree_row_reference_free(reference);
+ if (path) {
+ selection = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_view_scroll_to_cell(view, path, NULL, TRUE, 0.5, 0.0);
+ gtk_tree_path_free(path);
+ }
}
-
- gtk_clist_thaw (clist);
-
- {
- gint row = gtk_clist_find_row_from_data (clist, ttw->current_table);
-
- if (row < 0)
- row = 0;
-
- gtk_clist_select_row (clist, row, 0);
-
- /* If this row isn't visible, move it to the center */
- if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_FULL)
- gtk_clist_moveto (clist, row, 0, 0.5, 0);
- }
+ ;; tax_table_entries_refresh (ttw);
/* select_row() above will refresh the entries window */
}
-void
-tax_table_row_selected (GtkCList *clist, gint row, gint column,
- GdkEventButton *event, gpointer user_data)
+static void
+tax_table_selection_changed (GtkTreeSelection *selection,
+ gpointer user_data)
{
TaxTableWindow *ttw = user_data;
- GncTaxTable *table = gtk_clist_get_row_data (clist, row);
+ GncTaxTable *table;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
g_return_if_fail (ttw);
+
+ if (!gtk_tree_selection_get_selected(selection, &model, &iter))
+ return;
+
+ gtk_tree_model_get(model, &iter, TABLE_POINTER, &table, -1);
g_return_if_fail (table);
/* If we've changed, then reset the entry list */
@@ -508,26 +500,38 @@
ttw->current_entry = NULL;
}
/* And force a refresh of the entries */
- tax_table_entries_refresh (ttw, TRUE);
+ tax_table_entries_refresh (ttw);
}
-void
-tax_table_entry_row_selected (GtkCList *clist, gint row, gint column,
- GdkEventButton *event, gpointer user_data)
+static void
+tax_table_entry_selection_changed (GtkTreeSelection *selection,
+ gpointer user_data)
{
TaxTableWindow *ttw = user_data;
- GncTaxTableEntry *entry = gtk_clist_get_row_data (clist, row);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
g_return_if_fail (ttw);
- g_return_if_fail (entry);
- ttw->current_entry = entry;
+ if (!gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ ttw->current_entry = NULL;
+ return;
+ }
- /* If we double-click an item, then pop up an 'edit' window */
- if (event && event->type == GDK_2BUTTON_PRESS)
- new_tax_table_dialog (ttw, FALSE, entry, NULL);
+ gtk_tree_model_get(model, &iter, ENTRY_POINTER, &ttw->current_entry, -1);
}
+static void
+tax_table_entry_row_activated (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer user_data)
+{
+ TaxTableWindow *ttw = user_data;
+
+ new_tax_table_dialog (ttw, FALSE, ttw->current_entry, NULL);
+}
+
void
tax_table_new_table_cb (GtkButton *button, TaxTableWindow *ttw)
{
@@ -665,6 +669,11 @@
{
TaxTableWindow *ttw;
GladeXML *xml;
+ GtkTreeView *view;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkListStore *store;
+ GtkTreeSelection *selection;
if (!book) return NULL;
@@ -687,9 +696,43 @@
/* Open and read the XML */
xml = gnc_glade_xml_new ("tax-tables.glade", "Tax Table Window");
ttw->dialog = glade_xml_get_widget (xml, "Tax Table Window");
- ttw->names_clist = glade_xml_get_widget (xml, "tax_tables_clist");
- ttw->entries_clist = glade_xml_get_widget (xml, "tax_table_entries");
+ ttw->names_view = glade_xml_get_widget (xml, "tax_tables_view");
+ ttw->entries_view = glade_xml_get_widget (xml, "tax_table_entries");
+ /* Create the tax tables view */
+ view = GTK_TREE_VIEW(ttw->names_view);
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
+ gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("", renderer,
+ "text", TABLE_NAME,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ selection = gtk_tree_view_get_selection(view);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(tax_table_selection_changed), ttw);
+
+
+ /* Create the tax table entries view */
+ view = GTK_TREE_VIEW(ttw->entries_view);
+ store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING);
+ gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("", renderer,
+ "text", ENTRY_NAME,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ selection = gtk_tree_view_get_selection(view);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(tax_table_entry_selection_changed), ttw);
+ g_signal_connect(view, "row-activated",
+ G_CALLBACK(tax_table_entry_row_activated), ttw);
+
+
/* Setup signals */
glade_xml_signal_autoconnect_full( xml,
gnc_glade_autoconnect_full_func,
Modified: gnucash/branches/deprecated-cleanup/src/business/dialog-tax-table/tax-tables.glade
===================================================================
--- gnucash/branches/deprecated-cleanup/src/business/dialog-tax-table/tax-tables.glade 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/business/dialog-tax-table/tax-tables.glade 2006-05-07 00:38:45 UTC (rev 13937)
@@ -107,30 +107,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="tax_tables_clist">
+ <widget class="GtkTreeView" id="tax_tables_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">1</property>
- <property name="column_widths">80</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">False</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <signal name="select_row" handler="tax_table_row_selected" last_modification_time="Mon, 08 Sep 2003 03:31:16 GMT"/>
-
- <child>
- <widget class="GtkLabel" id="label23">
- <property name="label" translatable="yes"></property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
@@ -250,30 +234,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="tax_table_entries">
+ <widget class="GtkTreeView" id="tax_table_entries">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">1</property>
- <property name="column_widths">80</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">False</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <signal name="select_row" handler="tax_table_entry_row_selected" last_modification_time="Mon, 08 Sep 2003 03:31:06 GMT"/>
-
- <child>
- <widget class="GtkLabel" id="label23">
- <property name="label" translatable="yes"></property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
Modified: gnucash/branches/deprecated-cleanup/src/gnome/druid-loan.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome/druid-loan.c 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/gnome/druid-loan.c 2006-05-07 00:38:45 UTC (rev 13937)
@@ -2,6 +2,7 @@
* druid-loan.c : A Gnome Druid for setting up loan-repayment *
* scheduled transactions. *
* Copyright (C) 2002 Joshua Sled <jsled at asynchronous.org> *
+ * Copyright (C) 2006 David Hampton <hampton at employees.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@@ -98,6 +99,11 @@
#define OPT_VBOX_SPACING 2
+#define COLUMN_DATE 0
+#define COLUMN_PAYMENT 1
+#define COLUMN_PRINCIPAL 2
+#define COLUMN_INTEREST 3
+
typedef enum {
CURRENT_YEAR,
NOW_PLUS_ONE,
@@ -300,7 +306,7 @@
GNCDateEdit *revStartDate;
GNCDateEdit *revEndDate;
GtkScrolledWindow *revScrollWin;
- GtkCList *revCL;
+ GtkTreeView *revView;
} LoanDruidData;
/**
@@ -354,12 +360,9 @@
static void ld_rev_get_dates( LoanDruidData *ldd,
GDate *start,
GDate *end );
-static void ld_rev_update_clist( LoanDruidData *ldd,
+static void ld_rev_update_view( LoanDruidData *ldd,
GDate *start,
GDate *end );
-static void ld_rev_clist_allocate_col_widths( GtkWidget *w,
- GtkAllocation *alloc,
- gpointer user_data );
static void ld_rev_sched_list_free( gpointer data, gpointer user_data );
static void ld_rev_hash_to_list( gpointer key,
gpointer val,
@@ -1749,16 +1752,18 @@
/* 3, here, does not include the Date column. */
const static int BASE_COLS = 3;
LoanDruidData *ldd;
- gchar **titles;
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GType *types;
int i;
ldd = (LoanDruidData*)ud;
- /* Cleanup old clist */
- if ( ldd->revCL != NULL ) {
- gtk_container_remove( GTK_CONTAINER(ldd->revScrollWin),
- GTK_WIDGET(ldd->revCL) );
- ldd->revCL = NULL;
+ /* Cleanup old view */
+ if ( ldd->revView != NULL ) {
+ gtk_widget_destroy( GTK_WIDGET(ldd->revView) );
+ ldd->revView = NULL;
}
ldd->ld.revNumPmts = BASE_COLS;
@@ -1775,40 +1780,58 @@
}
/* '+1' for leading date col */
- titles = g_new0( gchar*, ldd->ld.revNumPmts + 1 );
- titles[0] = _( "Date" );
- titles[1] = _( "Payment" );
- titles[2] = _( "Principal" );
- titles[3] = _( "Interest" );
+ types = g_new( GType, ldd->ld.revNumPmts + 1 );
+ for ( i=0; i < ldd->ld.revNumPmts + 1; i++ )
+ types[i] = G_TYPE_STRING;
+ store = gtk_list_store_newv(ldd->ld.revNumPmts + 1, types);
+ g_free(types);
+
+ ldd->revView = GTK_TREE_VIEW(
+ gtk_tree_view_new_with_model( GTK_TREE_MODEL(store) ));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Date"), renderer,
+ "text", COLUMN_DATE,
+ NULL);
+ gtk_tree_view_append_column(ldd->revView, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Payment"), renderer,
+ "text", COLUMN_PAYMENT,
+ NULL);
+ gtk_tree_view_append_column(ldd->revView, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Principal"), renderer,
+ "text", COLUMN_PRINCIPAL,
+ NULL);
+ gtk_tree_view_append_column(ldd->revView, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Interest"), renderer,
+ "text", COLUMN_INTEREST,
+ NULL);
+ gtk_tree_view_append_column(ldd->revView, column);
+
/* move the appropriate names over into the title array */
{
for ( i=0; i < ldd->ld.repayOptCount; i++ ) {
if ( ldd->ld.revRepayOptToColMap[i] == -1 ) {
continue;
}
- /* '+1' offset for the "Date" title */
- titles[ ldd->ld.revRepayOptToColMap[i] + 1 ] =
- ldd->ld.repayOpts[i]->name;
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes
+ (ldd->ld.repayOpts[i]->name, renderer,
+ "text", COLUMN_INTEREST + i,
+ NULL);
+ gtk_tree_view_append_column(ldd->revView, column);
}
}
- ldd->revCL = GTK_CLIST(
- gtk_clist_new_with_titles( ldd->ld.revNumPmts+1,
- titles ) );
- g_free( titles );
-
- for( i=0; i < ldd->ld.revNumPmts+1; i++ ) {
- gtk_clist_set_column_resizeable( ldd->revCL, i, TRUE );
-
- }
-
- g_signal_connect( ldd->revCL, "size-allocate",
- G_CALLBACK(ld_rev_clist_allocate_col_widths),
- ldd );
-
gtk_container_add( GTK_CONTAINER(ldd->revScrollWin),
- GTK_WIDGET(ldd->revCL) );
- gtk_widget_show_all( GTK_WIDGET(ldd->revCL) );
+ GTK_WIDGET(ldd->revView) );
+ gtk_widget_show( GTK_WIDGET(ldd->revView) );
ld_rev_recalc_schedule( ldd );
@@ -1817,7 +1840,7 @@
g_date_clear( &start, 1 );
g_date_clear( &end, 1 );
ld_rev_get_dates( ldd, &start, &end );
- ld_rev_update_clist( ldd, &start, &end );
+ ld_rev_update_view( ldd, &start, &end );
}
}
@@ -2522,7 +2545,7 @@
g_date_clear( &start, 1 );
g_date_clear( &end, 1 );
ld_rev_get_dates( ldd, &start, &end );
- ld_rev_update_clist( ldd, &start, &end );
+ ld_rev_update_view( ldd, &start, &end );
}
}
@@ -2536,7 +2559,7 @@
g_date_clear( &start, 1 );
g_date_clear( &end, 1 );
ld_rev_get_dates( ldd, &start, &end );
- ld_rev_update_clist( ldd, &start, &end );
+ ld_rev_update_view( ldd, &start, &end );
}
}
@@ -2801,20 +2824,21 @@
static
void
-ld_rev_update_clist( LoanDruidData *ldd, GDate *start, GDate *end )
+ld_rev_update_view( LoanDruidData *ldd, GDate *start, GDate *end )
{
static gchar *NO_AMT_CELL_TEXT = " ";
GList *l;
GNCPrintAmountInfo pai;
- /* '+1' for the date cell */
- gchar *rowText[ ldd->ld.revNumPmts + 1 ];
+ GtkListStore *store;
+ GtkTreeIter iter;
pai = gnc_default_price_print_info();
pai.min_decimal_places = 2;
- gtk_clist_clear( ldd->revCL );
- gtk_clist_freeze( ldd->revCL );
+ store = GTK_LIST_STORE(gtk_tree_view_get_model( ldd->revView ));
+ gtk_list_store_clear( store );
+
for ( l = ldd->ld.revSchedule; l != NULL; l = l->next )
{
int i;
@@ -2826,54 +2850,31 @@
if ( g_date_compare( &rrr->date, end ) > 0 )
continue; /* though we can probably return, too. */
- qof_print_gdate( tmpBuf, MAX_DATE_LENGTH, &rrr->date );
- rowText[0] = g_strdup( tmpBuf );
+ gtk_list_store_append(store, &iter);
+ qof_print_gdate( tmpBuf, MAX_DATE_LENGTH, &rrr->date );
+ gtk_list_store_set( store, &iter, COLUMN_DATE, tmpBuf, -1 );
+
for ( i=0; i<ldd->ld.revNumPmts; i++ )
{
int numPrinted;
if ( gnc_numeric_check( rrr->numCells[i] )
== GNC_ERROR_ARG )
{
- rowText[i+1] = NO_AMT_CELL_TEXT;
+ /* '+1' for the date cell */
+ gtk_list_store_set( store, &iter,
+ i+1, NO_AMT_CELL_TEXT,
+ -1);
continue;
}
numPrinted = xaccSPrintAmount( tmpBuf, rrr->numCells[i], pai );
g_assert( numPrinted < 50 );
- rowText[i+1] = g_strdup( tmpBuf );
+ /* '+1' for the date cell */
+ gtk_list_store_set( store, &iter,
+ i+1, tmpBuf,
+ -1);
}
- gtk_clist_append( ldd->revCL, rowText );
-
- for ( i=ldd->ld.revNumPmts-1; i>=0; i-- )
- {
- if ( strcmp( rowText[i], NO_AMT_CELL_TEXT ) == 0 )
- continue;
- g_free( rowText[i] );
- }
}
- gtk_clist_thaw( ldd->revCL );
}
-
-static
-void
-ld_rev_clist_allocate_col_widths( GtkWidget *w,
- GtkAllocation *alloc,
- gpointer user_data )
-{
- LoanDruidData *ldd = (LoanDruidData*)user_data;
- gint i, evenWidth, width;
-
- width = alloc->width;
- /* The '-10' is to account for misc widget noise not accounted for by
- * the simple division. */
- evenWidth = (gint)(width / (ldd->ld.revNumPmts+1) ) - 10;
- gtk_clist_freeze( ldd->revCL );
- for ( i=0; i<ldd->ld.revNumPmts+1; i++ )
- {
- gtk_clist_set_column_width( ldd->revCL,
- i, evenWidth );
- }
- gtk_clist_thaw( ldd->revCL );
-}
Modified: gnucash/branches/deprecated-cleanup/src/gnome/druid-stock-split.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome/druid-stock-split.c 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/gnome/druid-stock-split.c 2006-05-07 00:38:45 UTC (rev 13937)
@@ -47,6 +47,11 @@
#define DRUID_STOCK_SPLIT_CM_CLASS "druid-stock-split"
+#define COLUMN_ACCOUNT 0
+#define COLUMN_FULLNAME 1
+#define COLUMN_MNEMONIC 2
+#define COLUMN_SHARES 3
+
/** structures *********************************************************/
typedef struct
{
@@ -54,7 +59,7 @@
GtkWidget * druid;
/* account page data */
- GtkWidget * account_list;
+ GtkWidget * account_view;
Account * acct;
/* info page data */
@@ -107,19 +112,23 @@
}
static int
-fill_account_list (StockSplitInfo *info, Account *account)
+fill_account_list (StockSplitInfo *info, Account *selected_account)
{
- GtkCList *clist;
+ GtkTreeRowReference *reference = NULL;
+ GtkTreeView *view;
+ GtkListStore *list;
+ GtkTreeIter iter;
+ GtkTreePath *path;
GList *accounts;
GList *node;
gint rows = 0;
+ gchar *full_name;
- clist = GTK_CLIST (info->account_list);
+ view = GTK_TREE_VIEW(info->account_view);
+ list = GTK_LIST_STORE(gtk_tree_view_get_model(view));
- gtk_clist_freeze (clist);
+ gtk_list_store_clear (list);
- gtk_clist_clear (clist);
-
accounts = xaccGroupGetSubAccountsSorted (gnc_get_current_group ());
for (node = accounts; node; node = node->next)
{
@@ -127,8 +136,6 @@
GNCPrintAmountInfo print_info;
const gnc_commodity *commodity;
gnc_numeric balance;
- char *strings[4];
- gint row;
if (!xaccAccountIsPriced(account))
continue;
@@ -142,59 +149,56 @@
commodity = xaccAccountGetCommodity (account);
+ full_name = xaccAccountGetFullName (account);
print_info = gnc_account_print_info (account, FALSE);
- strings[0] = xaccAccountGetFullName (account);
- strings[1] = (char *) gnc_commodity_get_mnemonic (commodity);
- strings[2] = (char *) xaccPrintAmount (balance, print_info);
- strings[3] = NULL;
+ gtk_list_store_append(list, &iter);
+ gtk_list_store_set(list, &iter,
+ COLUMN_ACCOUNT, account,
+ COLUMN_FULLNAME, full_name,
+ COLUMN_MNEMONIC, gnc_commodity_get_mnemonic(commodity),
+ COLUMN_SHARES, xaccPrintAmount(balance, print_info),
+ -1);
- row = gtk_clist_append (clist, strings);
+ if (account == selected_account) {
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(list), &iter);
+ reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(list), path);
+ gtk_tree_path_free(path);
+ }
- gtk_clist_set_row_data (clist, row, account);
+ g_free (full_name);
- g_free (strings[0]);
-
rows++;
}
g_list_free(accounts);
- {
- gint row = 0;
-
- if (account)
- row = gtk_clist_find_row_from_data (clist, account);
-
- if (row < 0)
- row = 0;
-
- gtk_clist_select_row (GTK_CLIST (info->account_list), row, 0);
+ if (reference) {
+ GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
+ path = gtk_tree_row_reference_get_path(reference);
+ gtk_tree_row_reference_free(reference);
+ if (path) {
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_view_scroll_to_cell(view, path, NULL, TRUE, 0.5, 0.0);
+ gtk_tree_path_free(path);
+ }
}
- gtk_clist_columns_autosize (clist);
-
- gtk_clist_thaw (clist);
-
return rows;
}
static void
-clist_select_row (GtkCList *clist,
- gint row,
- gint column,
- GdkEventButton *event,
- gpointer user_data)
+selection_changed (GtkTreeSelection *selection,
+ gpointer user_data)
{
StockSplitInfo *info = user_data;
- Account *account;
+ GtkTreeModel *list;
+ GtkTreeIter iter;
- account = gtk_clist_get_row_data (clist, row);
-
- /* Happens when the first row is inserted, before the row data can be added */
- if (account == NULL)
+ if (!gtk_tree_selection_get_selected(selection, &list, &iter))
return;
-
- info->acct = account;
+ gtk_tree_model_get(list, &iter,
+ COLUMN_ACCOUNT, &info->acct,
+ -1);
}
static void
@@ -583,16 +587,42 @@
/* account list */
{
- GtkCList *clist;
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeSelection *selection;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
- info->account_list = glade_xml_get_widget (xml, "account_clist");
+ info->account_view = glade_xml_get_widget (xml, "account_view");
- clist = GTK_CLIST (info->account_list);
+ view = GTK_TREE_VIEW(info->account_view);
- gtk_clist_set_selection_mode (clist, GTK_SELECTION_BROWSE);
+ store = gtk_list_store_new(4, G_TYPE_POINTER, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING);
+ gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
- g_signal_connect (clist, "select_row",
- G_CALLBACK (clist_select_row), info);
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Account"), renderer,
+ "text", COLUMN_FULLNAME,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Symbol"), renderer,
+ "text", COLUMN_MNEMONIC,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Shares"), renderer,
+ "text", COLUMN_SHARES,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ selection = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (selection_changed), info);
}
/* info widgets */
Modified: gnucash/branches/deprecated-cleanup/src/gnome/glade/account.glade
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome/glade/account.glade 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/gnome/glade/account.glade 2006-05-07 00:38:45 UTC (rev 13937)
@@ -294,7 +294,6 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="mnemonic_widget">account_scu</property>
</widget>
<packing>
<property name="left_attach">0</property>
@@ -463,93 +462,6 @@
</child>
<child>
- <widget class="GtkOptionMenu" id="account_scu">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Smallest fraction of this commodity that can be referenced.</property>
- <property name="can_focus">True</property>
- <property name="history">0</property>
-
- <child internal-child="menu">
- <widget class="GtkMenu" id="convertwidget1">
- <property name="visible">True</property>
-
- <child>
- <widget class="GtkMenuItem" id="convertwidget2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Use Commodity Value</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="convertwidget3">
- <property name="visible">True</property>
- <property name="label" translatable="yes">1</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="convertwidget4">
- <property name="visible">True</property>
- <property name="label" translatable="yes">1/10</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="convertwidget5">
- <property name="visible">True</property>
- <property name="label" translatable="yes">1/100</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="convertwidget6">
- <property name="visible">True</property>
- <property name="label" translatable="yes">1/1000</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="convertwidget7">
- <property name="visible">True</property>
- <property name="label" translatable="yes">1/10000</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="convertwidget8">
- <property name="visible">True</property>
- <property name="label" translatable="yes">1/100000</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="convertwidget9">
- <property name="visible">True</property>
- <property name="label" translatable="yes">1/1000000</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- <property name="x_options">fill</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
<widget class="GtkScrolledWindow" id="scrolledwindow9">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
@@ -586,6 +498,38 @@
<property name="y_options">fill</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkEventBox" id="eventbox1">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Smallest fraction of this commodity that can be referenced.</property>
+ <property name="visible_window">True</property>
+ <property name="above_child">False</property>
+
+ <child>
+ <widget class="GtkComboBox" id="account_scu">
+ <property name="visible">True</property>
+ <property name="items" translatable="yes">Use Commodity Value
+1
+1/10
+1/100
+1/1000
+1/10000
+1/100000
+1/1000000</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="left_attach">1</property>
Modified: gnucash/branches/deprecated-cleanup/src/gnome/glade/stocks.glade
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome/glade/stocks.glade 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/gnome/glade/stocks.glade 2006-05-07 00:38:45 UTC (rev 13937)
@@ -78,82 +78,23 @@
</child>
<child>
- <widget class="GtkAlignment" id="alignment1">
+ <widget class="GtkScrolledWindow" id="scrolledwindow22">
<property name="visible">True</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xscale">1</property>
- <property name="yscale">1</property>
- <property name="top_padding">0</property>
- <property name="bottom_padding">0</property>
- <property name="left_padding">0</property>
- <property name="right_padding">0</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
+ <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow21">
+ <widget class="GtkTreeView" id="account_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
- <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkCList" id="account_clist">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="n_columns">3</property>
- <property name="column_widths">80,80,80</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">True</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
-
- <child>
- <widget class="GtkLabel" id="label847718">
- <property name="label" translatable="yes">Account</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847719">
- <property name="label" translatable="yes">Symbol</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847720">
- <property name="label" translatable="yes">Shares</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_RIGHT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">1</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
- </widget>
- </child>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">False</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
Modified: gnucash/branches/deprecated-cleanup/src/gnome-utils/dialog-account.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-utils/dialog-account.c 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/gnome-utils/dialog-account.c 2006-05-07 00:38:45 UTC (rev 13937)
@@ -54,6 +54,11 @@
#define DIALOG_EDIT_ACCOUNT_CM_CLASS "dialog-edit-account"
#define GCONF_SECTION "dialogs/account"
+#define COLUMN_FULLNAME 0
+#define COLUMN_FIELDNAME 1
+#define COLUMN_OLD_VALUE 2
+#define COLUMN_NEW_VALUE 3
+
typedef enum
{
NEW_ACCOUNT,
@@ -211,7 +216,7 @@
} else {
index = 0;
}
- gtk_option_menu_set_history(GTK_OPTION_MENU(aw->account_scu), index);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(aw->account_scu), index);
string = xaccAccountGetCode (account);
if (string == NULL) string = "";
@@ -338,7 +343,7 @@
old_scu = xaccAccountGetCommoditySCU(account);
}
- index = gnc_option_menu_get_active(aw->account_scu);
+ index = gtk_combo_box_get_active(GTK_COMBO_BOX(aw->account_scu));
nonstd = (index != 0);
if (nonstd != xaccAccountGetNonStdSCU(account))
xaccAccountSetNonStdSCU(account, nonstd);
@@ -556,7 +561,7 @@
typedef struct
{
Account *account;
- GtkCList *list;
+ GtkListStore *list;
guint count;
} FillStruct;
@@ -566,49 +571,32 @@
Account *account = key;
FillStruct *fs = data;
gchar *full_name;
- gchar *account_field_name;
- gchar *account_field_value;
- gchar *value_str;
+ const gchar *account_field_name;
+ const gchar *account_field_value;
+ const gchar *value_str;
+ GtkTreeIter iter;
if (fs == NULL) return;
if (fs->account == account) return;
full_name = xaccAccountGetFullName(account);
- if(!full_name)
- full_name = g_strdup("");
+ account_field_name = "Type";
+ account_field_value = xaccAccountGetTypeStr(xaccAccountGetType(account));
+ value_str = xaccAccountGetTypeStr(GPOINTER_TO_INT(value));
- account_field_name = g_strdup("Type");
- if (!account_field_name)
- account_field_name = g_strdup("");
-
- account_field_value =
- g_strdup (xaccAccountGetTypeStr(xaccAccountGetType(account)));
- if (!account_field_value)
- account_field_value = g_strdup("");
-
- value_str = g_strdup(xaccAccountGetTypeStr(GPOINTER_TO_INT(value)));
-
- {
- gchar *strings[5];
-
- strings[0] = full_name;
- strings[1] = account_field_name;
- strings[2] = account_field_value;
- strings[3] = value_str;
- strings[4] = NULL;
-
- gtk_clist_append(fs->list, strings);
- }
-
+ gtk_list_store_append(fs->list, &iter);
+ gtk_list_store_set(fs->list, &iter,
+ COLUMN_FULLNAME, full_name,
+ COLUMN_FIELDNAME, account_field_name,
+ COLUMN_OLD_VALUE, account_field_value,
+ COLUMN_NEW_VALUE, value_str,
+ -1);
g_free(full_name);
- g_free(account_field_name);
- g_free(account_field_value);
- g_free(value_str);
fs->count++;
}
static guint
-fill_list(Account *account, GtkCList *list,
+fill_list(Account *account, GtkListStore *list,
GHashTable *change)
{
FillStruct fs;
@@ -632,8 +620,10 @@
GHashTable *change_type)
{
Account *account;
- GtkCList *list;
- gchar *titles[5];
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeView *view;
+ GtkListStore *store;
gboolean result;
guint size;
@@ -644,28 +634,47 @@
if (!account)
return FALSE;
- titles[0] = _("Account");
- titles[1] = _("Field");
- titles[2] = _("Old Value");
- titles[3] = _("New Value");
- titles[4] = NULL;
+ store = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING);
- list = GTK_CLIST(gtk_clist_new_with_titles(4, titles));
-
size = 0;
- size += fill_list(account, list, change_type);
+ size += fill_list(account, GTK_LIST_STORE(store), change_type);
if (size == 0)
{
- gtk_widget_destroy(GTK_WIDGET(list));
+ gtk_widget_destroy(GTK_WIDGET(store));
return TRUE;
}
- gtk_clist_column_titles_passive(list);
- gtk_clist_set_sort_column(list, 0);
- gtk_clist_sort(list);
- gtk_clist_columns_autosize(list);
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
+ COLUMN_FULLNAME,
+ GTK_SORT_ASCENDING);
+ view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)));
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Account"), renderer,
+ "text", COLUMN_FULLNAME,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Field"), renderer,
+ "text", COLUMN_FIELDNAME,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Old Value"), renderer,
+ "text", COLUMN_OLD_VALUE,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("New Value"), renderer,
+ "text", COLUMN_NEW_VALUE,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
{
GtkWidget *dialog;
GtkWidget *scroll;
@@ -699,7 +708,7 @@
gtk_container_add(GTK_CONTAINER(frame), scroll);
gtk_container_set_border_width(GTK_CONTAINER(scroll), 5);
- gtk_container_add(GTK_CONTAINER(scroll), GTK_WIDGET(list));
+ gtk_container_add(GTK_CONTAINER(scroll), GTK_WIDGET(view));
gtk_widget_show_all(vbox);
@@ -1277,7 +1286,6 @@
G_CALLBACK (commodity_changed_cb), aw);
aw->account_scu = glade_xml_get_widget (xml, "account_scu");
- gnc_option_menu_init(aw->account_scu);
box = glade_xml_get_widget (xml, "parent_scroll");
Modified: gnucash/branches/deprecated-cleanup/src/gnome-utils/dialog-utils.h
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-utils/dialog-utils.h 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/gnome-utils/dialog-utils.h 2006-05-07 00:38:45 UTC (rev 13937)
@@ -113,8 +113,10 @@
* place. Stick to gtk_clist_append, or use gnc_clist_set_check
* after you have built the list. This only applies to unrealized
* widgets. */
+#ifdef __GTK_CLIST_H__
void gnc_clist_set_check (GtkCList *list, int row, int col,
gboolean checked);
+#endif
GladeXML * gnc_glade_xml_new (const char *filename, const char *root);
GtkWidget * gnc_glade_lookup_widget (GtkWidget *widget, const char *name);
Modified: gnucash/branches/deprecated-cleanup/src/gnome-utils/glade/druid-provider-multifile.glade
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-utils/glade/druid-provider-multifile.glade 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/gnome-utils/glade/druid-provider-multifile.glade 2006-05-07 00:38:45 UTC (rev 13937)
@@ -72,30 +72,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="file_list">
+ <widget class="GtkTreeView" id="file_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">1</property>
- <property name="column_widths">80</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">False</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <signal name="select_row" handler="gnc_ui_qif_import_select_loaded_file_cb"/>
-
- <child>
- <widget class="GtkLabel" id="label827">
- <property name="label" translatable="no">labe82l7</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
Modified: gnucash/branches/deprecated-cleanup/src/gnome-utils/gnc-druid-provider-multifile-gnome.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-utils/gnc-druid-provider-multifile-gnome.c 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/gnome-utils/gnc-druid-provider-multifile-gnome.c 2006-05-07 00:38:45 UTC (rev 13937)
@@ -11,6 +11,9 @@
#include "gnc-ui.h"
#include "gnc-gui-query.h"
+#define FILE_FILENAME 0
+#define FILE_POINTER 1
+
static void gnc_druid_provider_multifile_gnome_class_init (GNCDruidProviderMultifileGnomeClass *class);
static void gnc_druid_provider_multifile_gnome_finalize (GObject *obj);
@@ -52,13 +55,19 @@
}
static void
-gnc_dpmfg_select_file_cb(GtkCList *clist, int row, int column, GdkEvent *event,
- gpointer user_data)
+gnc_dpmfg_select_file_cb(GtkTreeSelection *selection,
+ GNCDruidProviderMultifileGnome *prov_mf)
{
- GNCDruidProviderMultifileGnome *prov_mf = user_data;
- gpointer file = gtk_clist_get_row_data(clist, row);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- prov_mf->selected_file = file;
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ gtk_tree_model_get(model, &iter,
+ FILE_POINTER, &prov_mf->selected_file,
+ -1);
+ } else {
+ prov_mf->selected_file = NULL;
+ }
}
static void
@@ -66,35 +75,46 @@
{
GNCDruidProviderDescMultifile *desc_mf =
GNC_DRUID_PROVIDER_DESC_MULTIFILE(prov_mf->parent.desc);
- GtkCList *clist = GTK_CLIST(prov_mf->list);
+ GtkTreeView *view = GTK_TREE_VIEW(prov_mf->file_view);
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeSelection *selection;
+ GtkTreeRowReference *reference = NULL;
GList *list;
const gchar* filename;
- gint row = 0;
- gint sel_row = -1;
gpointer be_ctx = prov_mf->parent.druid->be_ctx;
- gtk_clist_freeze(clist);
- gtk_clist_clear(clist);
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
+ gtk_list_store_clear(store);
for (list = desc_mf->get_files(be_ctx); list; list = list->next) {
filename = desc_mf->get_filename(be_ctx, list->data);
- row = gtk_clist_append(clist, (char**)&filename);
- gtk_clist_set_row_data(clist, row, list->data);
-
- if (prov_mf->selected_file == list->data)
- sel_row = row;
+ gtk_list_store_prepend(store, &iter);
+ gtk_list_store_set(store, &iter,
+ FILE_FILENAME, filename,
+ FILE_POINTER, list->data,
+ -1);
+ if (prov_mf->selected_file == list->data) {
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
+ reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
+ gtk_tree_path_free(path);
+ }
}
- gtk_clist_thaw(clist);
-
- if(sel_row >= 0)
- gtk_clist_select_row(clist, sel_row, 0);
- else
+ if (reference) {
+ path = gtk_tree_row_reference_get_path(reference);
+ gtk_tree_row_reference_free(reference);
+ if (path) {
+ selection = gtk_tree_view_get_selection(view);
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_view_scroll_to_cell(view, path, NULL, TRUE, 0.5, 0.0);
+ gtk_tree_path_free(path);
+ }
+ } else {
prov_mf->selected_file = NULL;
-
- /* hopefully we don't need to queue the actual window */
- gtk_widget_queue_resize(GTK_WIDGET(prov_mf->page));
+ }
}
static GNCDruidPage*
@@ -188,8 +208,12 @@
GNCDruidProviderMultifileGnome *prov;
GNCDruidProviderDescMultifile *desc_mf;
GNCDruidCB *cb;
- GtkWidget *window, *page, *list, *button1, *button2, *label;
+ GtkWidget *window, *page, *view, *button1, *button2, *label;
GladeXML *xml;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkListStore *store;
+ GtkTreeSelection *selection;
/* verify that this is the correct provider descriptor */
g_return_val_if_fail(IS_GNC_DRUID_PROVIDER_DESC_MULTIFILE(desc), NULL);
@@ -218,7 +242,7 @@
g_assert(xml);
window = glade_xml_get_widget(xml, "Multifile Provider Window");
page = glade_xml_get_widget(xml, "Multifile Provider Page");
- list = glade_xml_get_widget(xml, "file_list");
+ view = glade_xml_get_widget(xml, "file_view");
button1 = glade_xml_get_widget(xml, "load_button");
button2 = glade_xml_get_widget(xml, "unload_button");
label = glade_xml_get_widget(xml, "instruction_label");
@@ -233,11 +257,23 @@
g_assert(page);
prov->page = GNOME_DRUID_PAGE(page);
prov_base->pages = g_list_prepend(NULL, page);
- prov->list = list;
+ prov->file_view = view;
+ /* Set up the file view */
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
+ gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("", renderer,
+ "text", FILE_FILENAME,
+ NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+ g_signal_connect(selection, "changed",
+ (GCallback)gnc_dpmfg_select_file_cb, prov);
+
/* Set the page properties */
- g_signal_connect(G_OBJECT(list), "select-row",
- (GCallback)gnc_dpmfg_select_file_cb, prov);
g_signal_connect(G_OBJECT(button1), "clicked",
(GCallback)gnc_dpmfg_load_another_cb, prov);
g_signal_connect(G_OBJECT(button2), "clicked",
Modified: gnucash/branches/deprecated-cleanup/src/gnome-utils/gnc-druid-provider-multifile-gnome.h
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-utils/gnc-druid-provider-multifile-gnome.h 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/gnome-utils/gnc-druid-provider-multifile-gnome.h 2006-05-07 00:38:45 UTC (rev 13937)
@@ -41,7 +41,7 @@
GNCDruidProvider parent;
GnomeDruidPage* page;
- GtkWidget* list;
+ GtkWidget* file_view;
GNCDruidCB* cb;
gpointer selected_file;
Modified: gnucash/branches/deprecated-cleanup/src/gnome-utils/gw-gnome-utils-spec.scm
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-utils/gw-gnome-utils-spec.scm 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/gnome-utils/gw-gnome-utils-spec.scm 2006-05-07 00:38:45 UTC (rev 13937)
@@ -392,21 +392,8 @@
;; dialog-utils.h
- (gw:wrap-as-wct ws '<gnc:GtkCList> "GtkCList*" "const GtkCList*")
-
(gw:wrap-function
ws
- 'gnc:clist-set-check
- '<gw:void>
- "gnc_clist_set_check"
- '((<gnc:GtkCList> clist)
- (<gw:int> row)
- (<gw:int> col)
- (<gw:bool> checked))
- "Set the check status of a clist cell.")
-
- (gw:wrap-function
- ws
'gnc:set-busy-cursor
'<gw:void>
"gnc_set_busy_cursor"
Modified: gnucash/branches/deprecated-cleanup/src/import-export/hbci/druid-hbci-initial.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/import-export/hbci/druid-hbci-initial.c 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/import-export/hbci/druid-hbci-initial.c 2006-05-07 00:38:45 UTC (rev 13937)
@@ -50,6 +50,12 @@
/* #define DEFAULT_HBCI_VERSION 201 */
+#define COLUMN_INDEX 0
+#define COLUMN_HBCI_NAME 1
+#define COLUMN_HBCI_ACCT 2
+#define COLUMN_GNC_NAME 3
+#define COLUMN_CHECKED 4
+
typedef enum _infostate {
INI_UPDATE_ACCOUNTS,
INI_MATCH_ACCOUNTS,
@@ -67,14 +73,13 @@
/* account match page */
GtkWidget *accountpage;
- GtkWidget *accountlist;
+ GtkTreeView *accountview;
+ GtkListStore *accountstore;
/* OpenHBCI stuff */
AB_BANKING *api;
GNCInteractor *interactor;
- /* account match: row_number (int) -> hbci_account */
- GHashTable *hbci_hash;
/* hbci_account (direct) -> gnucash_account -- DO NOT DELETE THE KEYS! */
GHashTable *gnc_hash;
@@ -83,22 +88,7 @@
};
-static gboolean
-hash_remove (gpointer key, gpointer value, gpointer user_data)
-{
- free (key);
- return TRUE;
-}
-
static void
-delete_hash (GHashTable *hash)
-{
- if (hash != NULL) {
- g_hash_table_foreach_remove (hash, &hash_remove, NULL);
- g_hash_table_destroy (hash);
- }
-}
-static void
reset_initial_info (HBCIInitialInfo *info)
{
if (info == NULL) return;
@@ -108,8 +98,6 @@
}
info->api = NULL;
- delete_hash (info->hbci_hash);
- info->hbci_hash = NULL;
if (info->gnc_hash != NULL)
g_hash_table_destroy (info->gnc_hash);
info->gnc_hash = NULL;
@@ -159,48 +147,47 @@
update_accountlist_acc_cb (AB_ACCOUNT *hacc, gpointer user_data)
{
HBCIInitialInfo *info = user_data;
- gchar *row_text[3];
+ gchar *gnc_name, *hbci_name;
Account *gacc;
- int row;
- gint *row_key;
+ GtkTreeIter iter;
g_assert(hacc);
g_assert(info);
- row_text[2] = "";
-
- row_text[0] = gnc_hbci_account_longname(hacc);
+
+ hbci_name = gnc_hbci_account_longname(hacc);
/* Get corresponding gnucash account */
gacc = g_hash_table_lookup (info->gnc_hash, hacc);
/* Build the text for the gnucash account. */
if (gacc == NULL)
- row_text[1] = "";
+ gnc_name = g_strdup("");
else
- row_text[1] = xaccAccountGetFullName (gacc);
+ gnc_name = xaccAccountGetFullName (gacc);
- /* Add this row to the list */
- row = gtk_clist_append (GTK_CLIST (info->accountlist), row_text);
+ gtk_list_store_append(info->accountstore, &iter);
+ gtk_list_store_set(info->accountstore, &iter,
+ COLUMN_HBCI_NAME, hbci_name,
+ COLUMN_HBCI_ACCT, hacc,
+ COLUMN_GNC_NAME, gnc_name,
+ COLUMN_CHECKED, FALSE,
+ -1);
- /* Set the "new" checkbox. */
- gnc_clist_set_check (GTK_CLIST (info->accountlist), row, 2,
- FALSE);
-
- /* Store the row_number -> hbci_account hash reference. */
- row_key = g_new(gint, 1);
- *row_key = row;
- g_hash_table_insert (info->hbci_hash, row_key, (AB_ACCOUNT*)hacc);
-
+ g_free(gnc_name);
+ g_free(hbci_name);
return NULL;
}
-/* Update the account list GtkCList widget */
+/* Update the account list GtkListStore widget */
static void
update_accountlist (HBCIInitialInfo *info)
{
- int sel_row = 0;
AB_BANKING *banking;
AB_ACCOUNT_LIST2 *acclist;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreePath *path = NULL;
g_assert(info);
banking = info->api;
@@ -208,15 +195,12 @@
g_assert(info->gnc_hash);
/* Store old selected row here. */
- sel_row = (GTK_CLIST(info->accountlist))->focus_row;
+ selection = gtk_tree_view_get_selection(info->accountview);
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ path = gtk_tree_model_get_path(model, &iter);
/* Delete old list */
- gtk_clist_freeze (GTK_CLIST (info->accountlist));
- gtk_clist_clear (GTK_CLIST (info->accountlist));
-
- /* Delete old hash with row_number -> hbci_account */
- delete_hash (info->hbci_hash);
- info->hbci_hash = g_hash_table_new (&g_int_hash, &g_int_equal);
+ gtk_list_store_clear(info->accountstore);
/* Go through all HBCI accounts */
acclist = AB_Banking_GetAccounts(banking);
@@ -227,14 +211,13 @@
else
printf("update_accountlist: Oops, account list from AB_Banking is NULL.\n");
- /* printf("update_accountlist: HBCI hash has %d entries.\n", g_hash_table_size(info->hbci_hash)); */
/* printf("update_accountlist: GNC hash has %d entries.\n", g_hash_table_size(info->gnc_hash)); */
-
- gtk_clist_thaw (GTK_CLIST (info->accountlist));
- /* move to the old selected row */
- (GTK_CLIST(info->accountlist))->focus_row = sel_row;
- gtk_clist_moveto(GTK_CLIST(info->accountlist), sel_row, 0, 0.0, 0.0);
+ if (path) {
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_view_scroll_to_cell(info->accountview, path, NULL, FALSE, 0.0, 0.0);
+ gtk_tree_path_free(path);
+ }
}
/*
* end update_accountlist
@@ -372,17 +355,24 @@
static void
-on_accountlist_select_row (GtkCList *clist, gint row,
- gint column, GdkEvent *event,
- gpointer user_data)
+on_accountlist_changed (GtkTreeSelection *selection,
+ gpointer user_data)
{
HBCIInitialInfo *info = user_data;
AB_ACCOUNT *hbci_acc;
Account *gnc_acc, *old_value;
- gchar *longname;
+ gchar *longname, *gnc_name;
gnc_commodity *currency = NULL;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- hbci_acc = g_hash_table_lookup (info->hbci_hash, &row);
+ if (!gtk_tree_selection_get_selected(selection, &model, &iter))
+ return;
+ gtk_tree_selection_unselect_iter(selection, &iter);
+ gtk_tree_model_get(model, &iter,
+ COLUMN_HBCI_ACCT, &hbci_acc,
+ -1);
+
if (hbci_acc) {
old_value = g_hash_table_lookup (info->gnc_hash, hbci_acc);
@@ -406,12 +396,17 @@
if (gnc_acc) {
if (old_value)
g_hash_table_remove (info->gnc_hash, hbci_acc);
-
g_hash_table_insert (info->gnc_hash, hbci_acc, gnc_acc);
+ gnc_name = xaccAccountGetFullName (gnc_acc);
+ gtk_list_store_set(info->accountstore, &iter,
+ COLUMN_GNC_NAME, gnc_name,
+ -1);
+ g_free(gnc_name);
+ } else {
+ gtk_list_store_set(info->accountstore, &iter,
+ COLUMN_GNC_NAME, "",
+ -1);
}
-
- /* update display */
- update_accountlist(info);
} /* hbci_acc */
}
@@ -648,6 +643,9 @@
HBCIInitialInfo *info;
GladeXML *xml;
GtkWidget *page;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
info = g_new0 (HBCIInitialInfo, 1);
@@ -679,9 +677,38 @@
{
page = glade_xml_get_widget(xml, "account_match_page");
info->accountpage = page;
- info->accountlist = glade_xml_get_widget(xml, "account_page_list");
- g_signal_connect (info->accountlist, "select_row",
- G_CALLBACK (on_accountlist_select_row), info);
+ info->accountview =
+ GTK_TREE_VIEW(glade_xml_get_widget(xml, "account_page_view"));
+ info->accountstore = gtk_list_store_new(5, G_TYPE_INT, G_TYPE_STRING,
+ G_TYPE_POINTER, G_TYPE_STRING,
+ G_TYPE_BOOLEAN);
+ gtk_tree_view_set_model(info->accountview, GTK_TREE_MODEL(info->accountstore));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("HBCI account name"),
+ renderer,
+ "text", COLUMN_HBCI_NAME,
+ NULL);
+ gtk_tree_view_append_column(info->accountview, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("GnuCash account name"),
+ renderer,
+ "text", COLUMN_GNC_NAME,
+ NULL);
+ gtk_tree_view_append_column(info->accountview, column);
+ gtk_tree_view_column_set_expand(column, TRUE);
+
+ renderer = gtk_cell_renderer_toggle_new();
+ column = gtk_tree_view_column_new_with_attributes(_("New?"),
+ renderer,
+ "active", COLUMN_CHECKED,
+ NULL);
+ gtk_tree_view_append_column(info->accountview, column);
+
+ selection = gtk_tree_view_get_selection(info->accountview);
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (on_accountlist_changed), info);
g_signal_connect (glade_xml_get_widget (xml, "aqhbci_again_button"),
"clicked",
G_CALLBACK (on_aqhbci_button), info);
Modified: gnucash/branches/deprecated-cleanup/src/import-export/hbci/glade/hbci.glade
===================================================================
--- gnucash/branches/deprecated-cleanup/src/import-export/hbci/glade/hbci.glade 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/import-export/hbci/glade/hbci.glade 2006-05-07 00:38:45 UTC (rev 13937)
@@ -205,59 +205,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="account_page_list">
+ <widget class="GtkTreeView" id="account_page_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">3</property>
- <property name="column_widths">281,242,53</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">True</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
-
- <child>
- <widget class="GtkLabel" id="label834">
- <property name="label" translatable="yes">HBCI account name</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label835">
- <property name="label" translatable="yes">GnuCash account name</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label836">
- <property name="label" translatable="yes">New?</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
@@ -1519,6 +1474,7 @@
<property name="response_id">0</property>
</widget>
</child>
+
<child>
<widget class="GtkButton" id="close_button">
<property name="visible">True</property>
@@ -1531,7 +1487,6 @@
<property name="response_id">0</property>
</widget>
</child>
-
</widget>
<packing>
<property name="padding">0</property>
@@ -1888,6 +1843,7 @@
<property name="response_id">2</property>
</widget>
</child>
+
<child>
<widget class="GtkButton" id="ok_button">
<property name="visible">True</property>
@@ -1900,7 +1856,6 @@
<property name="response_id">1</property>
</widget>
</child>
-
</widget>
<packing>
<property name="padding">0</property>
@@ -2251,6 +2206,7 @@
<property name="response_id">0</property>
</widget>
</child>
+
<child>
<widget class="GtkButton" id="button2">
<property name="visible">True</property>
@@ -2263,7 +2219,6 @@
<property name="response_id">0</property>
</widget>
</child>
-
</widget>
<packing>
<property name="padding">0</property>
Modified: gnucash/branches/deprecated-cleanup/src/import-export/qif-import/dialog-account-picker.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/import-export/qif-import/dialog-account-picker.c 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/import-export/qif-import/dialog-account-picker.c 2006-05-07 00:38:45 UTC (rev 13937)
@@ -2,6 +2,7 @@
* dialog-account-picker.c -- window for picking a Gnucash account *
* from the QIF importer. *
* Copyright (C) 2000-2001 Bill Gribble <grib at billgribble.com> *
+ * Copyright (c) 2006 David Hampton <hampton at employees.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@@ -34,31 +35,33 @@
#include "gnc-gui-query.h"
#include "gnc-ui-util.h"
+#define ACCOUNT_NAME 0
+#define ACCOUNT_FULLNAME 1
+#define ACCOUNT_CHECK 2
+
struct _accountpickerdialog {
GtkWidget * dialog;
- GtkWidget * treeview;
+ GtkTreeView * treeview;
QIFImportWindow * qif_wind;
SCM map_entry;
gchar * selected_name;
};
static void
-row_data_destroy_cb(gpointer data) {
- g_free(data);
-}
-
-static void
-acct_tree_add_accts(SCM accts, GtkCTree * tree, GtkCTreeNode * parent,
- char * base_name, int *row)
+acct_tree_add_accts(SCM accts,
+ GtkTreeStore *store,
+ GtkTreeIter *parent,
+ const char *base_name,
+ const char *selected_name,
+ GtkTreeRowReference **reference)
{
- char * acctinfo[2];
+ GtkTreeIter iter;
+ char * compname;
char * acctname;
- GtkCTreeNode * node;
gboolean leafnode;
SCM current;
+ gboolean checked;
- acctinfo[1] = "";
-
while(!SCM_NULLP(accts)) {
current = SCM_CAR(accts);
@@ -69,9 +72,9 @@
}
if (SCM_STRINGP(SCM_CAR(current)))
- acctinfo[0] = g_strdup(SCM_STRING_CHARS(SCM_CAR(current)));
+ compname = SCM_STRING_CHARS(SCM_CAR(current));
else
- acctinfo[0] = g_strdup("");
+ compname = "";
if(!SCM_NULLP(SCM_CADDR(current))) {
leafnode = FALSE;
@@ -79,72 +82,68 @@
else {
leafnode = TRUE;
}
-
- node = gtk_ctree_insert_node(tree, parent, NULL,
- acctinfo, 2,
- NULL, NULL, NULL, NULL,
- leafnode, TRUE);
- gnc_clist_set_check (GTK_CLIST (tree), (*row)++, 1,
- SCM_CADR (current) == SCM_BOOL_T);
-
- /* set some row data */
- if(base_name && (strlen(base_name) > 0)) {
+ /* compute full name */
+ if(base_name && *base_name) {
acctname = g_strjoin(gnc_get_account_separator_string(),
- base_name, acctinfo[0], (char *)NULL);
+ base_name, compname, (char *)NULL);
}
else {
- acctname = g_strdup(acctinfo[0]);
+ acctname = g_strdup(compname);
}
- gtk_ctree_node_set_row_data_full(tree, node,
- acctname,
- row_data_destroy_cb);
+
+ checked = (SCM_CADR (current) == SCM_BOOL_T);
+
+ gtk_tree_store_append(store, &iter, parent);
+ gtk_tree_store_set(store, &iter,
+ ACCOUNT_NAME, compname,
+ ACCOUNT_FULLNAME, acctname,
+ ACCOUNT_CHECK, checked,
+ -1);
+
+ if (reference && !*reference &&
+ selected_name && (g_utf8_collate(selected_name, acctname) == 0)) {
+ GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
+ *reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
+ gtk_tree_path_free(path);
+ }
+
if(!leafnode) {
- acct_tree_add_accts(SCM_CADDR(current), tree, node, acctname, row);
+ acct_tree_add_accts(SCM_CADDR(current), store, &iter, acctname,
+ selected_name, reference);
}
-
+
+ g_free(acctname);
+
accts = SCM_CDR(accts);
}
}
-static gint
-test_str_cmp(gconstpointer a, gconstpointer b)
-{
- return strcmp(a, b);
-}
-
static void
build_acct_tree(QIFAccountPickerDialog * picker, QIFImportWindow * import)
{
SCM get_accts = scm_c_eval_string("qif-import:get-all-accts");
SCM acct_tree = scm_call_1(get_accts,
gnc_ui_qif_import_druid_get_mappings(import));
- GtkCTreeNode * new_sel;
- int row = 0;
+ GtkTreeStore *store;
+ GtkTreePath *path;
+ GtkTreeSelection* selection;
+ GtkTreeRowReference *reference = NULL;
- gtk_clist_freeze(GTK_CLIST(picker->treeview));
- gtk_clist_clear(GTK_CLIST(picker->treeview));
- gtk_clist_set_column_justification (GTK_CLIST(picker->treeview),
- 1, GTK_JUSTIFY_CENTER);
+ store = GTK_TREE_STORE(gtk_tree_view_get_model(picker->treeview));
+ gtk_tree_store_clear(store);
- acct_tree_add_accts(acct_tree, GTK_CTREE(picker->treeview),
- NULL, NULL, &row);
+ acct_tree_add_accts(acct_tree, store, NULL, NULL, picker->selected_name, &reference);
- if(picker->selected_name) {
- new_sel =
- gtk_ctree_find_by_row_data_custom(GTK_CTREE(picker->treeview),
- NULL,
- picker->selected_name,
- &test_str_cmp);
-
- gtk_ctree_select(GTK_CTREE(picker->treeview), new_sel);
- gtk_ctree_node_moveto(GTK_CTREE(picker->treeview), new_sel, 0,
- 0.5, 0.0);
+ if (reference) {
+ selection = gtk_tree_view_get_selection(picker->treeview);
+ path = gtk_tree_row_reference_get_path(reference);
+ if (path) {
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_path_free(path);
+ }
+ gtk_tree_row_reference_free(reference);
}
-
- gtk_clist_columns_autosize (GTK_CLIST (picker->treeview));
- gtk_clist_column_titles_passive (GTK_CLIST (picker->treeview));
- gtk_clist_thaw(GTK_CLIST(picker->treeview));
}
static void
@@ -189,35 +188,26 @@
}
static void
-gnc_ui_qif_account_picker_select_cb(GtkCTree * tree,
- GtkCTreeNode * node,
- gint column,
- gpointer user_data)
+gnc_ui_qif_account_picker_changed_cb (GtkTreeSelection *selection,
+ gpointer user_data)
{
QIFAccountPickerDialog * wind = user_data;
SCM name_setter = scm_c_eval_string("qif-map-entry:set-gnc-name!");
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar *name;
g_free(wind->selected_name);
- wind->selected_name =
- g_strdup(gtk_ctree_node_get_row_data(tree, node));
-
- scm_call_2(name_setter, wind->map_entry, scm_makfrom0str(wind->selected_name));
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ gtk_tree_model_get(model, &iter, ACCOUNT_FULLNAME, &name, -1);
+ wind->selected_name = g_strdup(name);
+ scm_call_2(name_setter, wind->map_entry, scm_makfrom0str(wind->selected_name));
+ } else {
+ wind->selected_name = NULL;
+ }
}
-static void
-gnc_ui_qif_account_picker_unselect_cb(GtkCTree * tree,
- GtkCTreeNode * node,
- gint column,
- gpointer user_data)
-{
- QIFAccountPickerDialog * wind = user_data;
-
- g_free(wind->selected_name);
- wind->selected_name = NULL;
-}
-
-
static int
gnc_ui_qif_account_picker_map_cb(GtkWidget * w, gpointer user_data)
{
@@ -259,7 +249,7 @@
G_CALLBACK (gnc_ui_qif_account_picker_new_cb), wind);
wind->dialog = glade_xml_get_widget (xml, "QIF Import Account Picker");
- wind->treeview = glade_xml_get_widget (xml, "account_tree");
+ wind->treeview = GTK_TREE_VIEW(glade_xml_get_widget (xml, "account_tree"));
wind->qif_wind = qif_wind;
wind->map_entry = map_entry;
@@ -269,14 +259,34 @@
scm_gc_protect_object(wind->map_entry);
- g_signal_connect(wind->treeview, "tree_select_row",
- G_CALLBACK(gnc_ui_qif_account_picker_select_cb),
- wind);
+ {
+ GtkTreeStore *store;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
- g_signal_connect(wind->treeview, "tree_unselect_row",
- G_CALLBACK(gnc_ui_qif_account_picker_unselect_cb),
- wind);
+ store = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ gtk_tree_view_set_model(wind->treeview, GTK_TREE_MODEL(store));
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Account"), renderer,
+ "text", ACCOUNT_NAME,
+ NULL);
+ g_object_set(column, "expand", TRUE, NULL);
+ gtk_tree_view_append_column(wind->treeview, column);
+
+ renderer = gtk_cell_renderer_toggle_new();
+ g_object_set(renderer, "activatable", FALSE, NULL);
+ column = gtk_tree_view_column_new_with_attributes(_("New?"), renderer,
+ "active", ACCOUNT_CHECK,
+ NULL);
+ gtk_tree_view_append_column(wind->treeview, column);
+
+ selection = gtk_tree_view_get_selection(wind->treeview);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(gnc_ui_qif_account_picker_changed_cb), wind);
+ }
+
g_signal_connect_after(wind->dialog, "map",
G_CALLBACK(gnc_ui_qif_account_picker_map_cb),
wind);
Modified: gnucash/branches/deprecated-cleanup/src/import-export/qif-import/druid-qif-import.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/import-export/qif-import/druid-qif-import.c 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/import-export/qif-import/druid-qif-import.c 2006-05-07 00:38:45 UTC (rev 13937)
@@ -1,7 +1,8 @@
/********************************************************************\
- * druid-qif-import.c -- window for importing QIF files *
+ * druid-qif-import.c -- window for importing QIF files *
* (GnuCash) *
* Copyright (C) 2000 Bill Gribble <grib at billgribble.com> *
+ * Copyright (c) 2006 David Hampton <hampton at employees.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@@ -53,6 +54,22 @@
#define DRUID_QIF_IMPORT_CM_CLASS "druid-qif-import"
#define GCONF_SECTION "dialogs/import/qif"
+#define PREV_ROW "prev_row"
+
+#define FILENAME_INDEX 0
+#define FILENAME_NAME 1
+
+#define ACCOUNT_INDEX 0
+#define ACCOUNT_QIF_NAME 1
+#define ACCOUNT_GNC_NAME 2
+#define ACCOUNT_NEW 3
+
+#define QIF_TRANS_INDEX 0
+#define QIF_TRANS_DATE 1
+#define QIF_TRANS_DESCRIPTION 2
+#define QIF_TRANS_AMOUNT 3
+#define QIF_TRANS_CHECKED 4
+
struct _qifimportwindow {
GtkWidget * window;
GtkWidget * druid;
@@ -60,14 +77,14 @@
GtkWidget * acct_entry;
GtkWidget * date_format_combo;
GtkWidget * date_format_entry;
- GtkWidget * selected_file_list;
- GtkWidget * acct_list;
- GtkWidget * cat_list;
- GtkWidget * memo_list;
+ GtkWidget * selected_file_view;
+ GtkWidget * acct_view;
+ GtkWidget * cat_view;
+ GtkWidget * memo_view;
GtkWidget * currency_picker;
GtkWidget * currency_entry;
- GtkWidget * new_transaction_list;
- GtkWidget * old_transaction_list;
+ GtkWidget * new_transaction_view;
+ GtkWidget * old_transaction_view;
GList * pre_comm_pages;
GList * commodity_pages;
@@ -115,7 +132,7 @@
static void update_memo_page(QIFImportWindow * win);
static void update_account_picker_page(QIFImportWindow * wind,
- SCM make_display, GtkWidget *list,
+ SCM make_display, GtkWidget *view,
SCM map_info, SCM * display_info);
static void gnc_ui_qif_import_commodity_prepare_cb(GnomeDruidPage * page,
@@ -659,20 +676,28 @@
****************************************************************/
static void
-gnc_ui_qif_import_select_loaded_file_cb(GtkCList * list,
- int row, int column,
- GdkEvent * event,
- gpointer user_data)
+gnc_ui_qif_import_select_loaded_file_cb (GtkTreeSelection *selection,
+ gpointer user_data)
{
QIFImportWindow * wind = user_data;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gint row;
- if(SCM_LISTP(wind->imported_files) &&
- (scm_ilength(wind->imported_files) > row)) {
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ gtk_tree_model_get(model, &iter, FILENAME_INDEX, &row, -1);
+ if(SCM_LISTP(wind->imported_files) &&
+ (scm_ilength(wind->imported_files) > row)) {
+ scm_gc_unprotect_object(wind->selected_file);
+ wind->selected_file = scm_list_ref(wind->imported_files,
+ scm_int2num(row));
+ scm_gc_protect_object(wind->selected_file);
+ }
+ } else {
scm_gc_unprotect_object(wind->selected_file);
- wind->selected_file = scm_list_ref(wind->imported_files,
- scm_int2num(row));
+ wind->selected_file = SCM_BOOL_F;
scm_gc_protect_object(wind->selected_file);
- }
+ }
}
/********************************************************************
@@ -757,38 +782,47 @@
SCM loaded_file_list = wind->imported_files;
SCM scm_qiffile = SCM_BOOL_F;
SCM qif_file_path;
- int row;
- int sel_item=-1;
+ int row = 0;
char * row_text;
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeRowReference *reference = NULL;
/* clear the list */
- gtk_clist_clear(GTK_CLIST(wind->selected_file_list));
+ view = GTK_TREE_VIEW(wind->selected_file_view);
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
+ gtk_list_store_clear(store);
qif_file_path = scm_c_eval_string("qif-file:path");
- /* iterate over all the imported files */
- gtk_clist_freeze(GTK_CLIST(wind->selected_file_list));
-
while(!SCM_NULLP(loaded_file_list)) {
scm_qiffile = SCM_CAR(loaded_file_list);
row_text = SCM_STRING_CHARS(scm_call_1(qif_file_path, scm_qiffile));
- row = gtk_clist_append(GTK_CLIST(wind->selected_file_list),
- &row_text);
-
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ FILENAME_INDEX, row++,
+ FILENAME_NAME, row_text,
+ -1);
if(scm_qiffile == wind->selected_file) {
- sel_item = row;
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
+ reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
+ gtk_tree_path_free(path);
}
loaded_file_list = SCM_CDR(loaded_file_list);
}
- gtk_clist_thaw(GTK_CLIST(wind->selected_file_list));
- if(sel_item >= 0) {
- gtk_clist_select_row(GTK_CLIST(wind->selected_file_list), sel_item, 0);
+ if (reference) {
+ GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
+ path = gtk_tree_row_reference_get_path(reference);
+ if (path) {
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_path_free(path);
+ }
+ gtk_tree_row_reference_free(reference);
}
-
- /* Wheee! Look at me! I'm a little one-line hack to make stuff work! */
- gtk_widget_queue_resize (wind->window);
}
@@ -857,28 +891,32 @@
* update_account_picker_page
* Generic function to update an account_picker page. This
* generalizes the code shared whenever any QIF -> GNC mapper is
- * updating it's CLIST. It asks the Scheme side to guess some account
+ * updating it's LIST STORE. It asks the Scheme side to guess some account
* translations and then shows the account name and suggested
- * translation in the Accounts page clist (acount picker list).
+ * translation in the Accounts page view (acount picker list).
****************************************************************/
static void
update_account_picker_page(QIFImportWindow * wind, SCM make_display,
- GtkWidget *list, SCM map_info, SCM * display_info)
+ GtkWidget *view, SCM map_info, SCM * display_info)
{
SCM get_qif_name = scm_c_eval_string("qif-map-entry:qif-name");
SCM get_gnc_name = scm_c_eval_string("qif-map-entry:gnc-name");
SCM get_new = scm_c_eval_string("qif-map-entry:new-acct?");
SCM accts_left;
- int sel_row=0;
- char * row_text[3];
- int row;
+ const gchar *qif_name, *gnc_name;
+ gboolean checked;
+ gint row = 0;
+ gint prev_row;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeSelection *selection;
- /* get the old selection row */
- sel_row = (GTK_CLIST(list))->focus_row;
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(view)));
- /* now get the list of strings to display in the clist widget */
+ /* now get the list of strings to display in the gtk_list_store widget */
accts_left = scm_call_3(make_display,
wind->imported_files,
map_info,
@@ -888,37 +926,32 @@
*display_info = accts_left;
scm_gc_protect_object(*display_info);
- gtk_clist_column_titles_passive (GTK_CLIST(list));
-
/* clear the list */
- gtk_clist_clear(GTK_CLIST(list));
+ gtk_list_store_clear(store);
- /* update the text in the boxes */
- gtk_clist_freeze(GTK_CLIST(list));
-
- gtk_clist_set_column_justification(GTK_CLIST(list),
- 2,
- GTK_JUSTIFY_CENTER);
-
- row_text[2] = "";
-
while(!SCM_NULLP(accts_left)) {
- row_text[0] = SCM_STRING_CHARS(scm_call_1(get_qif_name, SCM_CAR(accts_left)));
- row_text[1] = SCM_STRING_CHARS(scm_call_1(get_gnc_name, SCM_CAR(accts_left)));
-
- row = gtk_clist_append(GTK_CLIST(list), row_text);
+ qif_name = SCM_STRING_CHARS(scm_call_1(get_qif_name, SCM_CAR(accts_left)));
+ gnc_name = SCM_STRING_CHARS(scm_call_1(get_gnc_name, SCM_CAR(accts_left)));
+ checked = (scm_call_1(get_new, SCM_CAR(accts_left)) == SCM_BOOL_T);
- gnc_clist_set_check (GTK_CLIST(list), row, 2,
- scm_call_1(get_new, SCM_CAR(accts_left)) == SCM_BOOL_T);
-
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ ACCOUNT_INDEX, row++,
+ ACCOUNT_QIF_NAME, qif_name,
+ ACCOUNT_GNC_NAME, gnc_name,
+ ACCOUNT_NEW, checked,
+ -1);
accts_left = SCM_CDR(accts_left);
}
- gtk_clist_thaw(GTK_CLIST(list));
-
/* move to the old selected row */
- (GTK_CLIST(list))->focus_row = sel_row;
- gtk_clist_moveto(GTK_CLIST(list), sel_row, 0, 0.0, 0.0);
+ prev_row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(store), PREV_ROW));
+ if (prev_row != -1) {
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+ path = gtk_tree_path_new_from_indices (prev_row, -1);
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_path_free(path);
+ }
}
@@ -933,7 +966,7 @@
SCM make_account_display = scm_c_eval_string("qif-dialog:make-account-display");
- update_account_picker_page (wind, make_account_display, wind->acct_list,
+ update_account_picker_page (wind, make_account_display, wind->acct_view,
wind->acct_map_info, &(wind->acct_display_info));
}
@@ -947,7 +980,7 @@
{
SCM make_category_display = scm_c_eval_string("qif-dialog:make-category-display");
- update_account_picker_page (wind, make_category_display, wind->cat_list,
+ update_account_picker_page (wind, make_category_display, wind->cat_view,
wind->cat_map_info, &(wind->cat_display_info));
}
@@ -961,11 +994,56 @@
{
SCM make_memo_display = scm_c_eval_string("qif-dialog:make-memo-display");
- update_account_picker_page (wind, make_memo_display, wind->memo_list,
+ update_account_picker_page (wind, make_memo_display, wind->memo_view,
wind->memo_map_info, &(wind->memo_display_info));
}
+
/********************************************************************
+ ********************************************************************/
+
+static void
+create_account_picker_view(GtkWidget *widget,
+ const gchar *col_name,
+ GCallback callback,
+ gpointer user_data)
+{
+ GtkTreeView *view = GTK_TREE_VIEW(widget);
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
+
+ store = gtk_list_store_new(4, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(col_name, renderer,
+ "text", ACCOUNT_QIF_NAME,
+ NULL);
+ g_object_set(column, "expand", TRUE, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("GnuCash account name"), renderer,
+ "text", ACCOUNT_GNC_NAME,
+ NULL);
+ g_object_set(column, "expand", TRUE, NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_toggle_new();
+ g_object_set(renderer, "activatable", FALSE, NULL);
+ column = gtk_tree_view_column_new_with_attributes(_("New?"), renderer,
+ "active", ACCOUNT_NEW,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ g_object_set_data(G_OBJECT(store), PREV_ROW, GINT_TO_POINTER(-1));
+ selection = gtk_tree_view_get_selection(view);
+ g_signal_connect(selection, "changed", callback, user_data);
+}
+
+/********************************************************************
* select_line
* generic function to process the selection when a user tries to edit
* an account mapping in one of the "map QIF * to GNC" pages. This
@@ -974,12 +1052,24 @@
* function.
********************************************************************/
static void
-select_line (QIFImportWindow *wind, gint row, SCM display_info, SCM map_info,
+select_line (QIFImportWindow *wind, GtkTreeSelection *selection,
+ SCM display_info, SCM map_info,
void (*update_page)(QIFImportWindow *))
{
SCM get_name = scm_c_eval_string("qif-map-entry:qif-name");
SCM selected_acct;
-
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gint row, prev_row;
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+ gtk_tree_model_get(model, &iter, ACCOUNT_INDEX, &row, -1);
+ prev_row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(model), PREV_ROW));
+ g_object_set_data(G_OBJECT(model), PREV_ROW, GINT_TO_POINTER(row));
+ if ((row == -1) || (row == prev_row))
+ return;
+
/* find the <qif-map-entry> corresponding to the selected row */
selected_acct = scm_list_ref(display_info, scm_int2num(row));
@@ -999,13 +1089,11 @@
********************************************************************/
static void
-gnc_ui_qif_import_account_line_select_cb(GtkCList * clist, gint row,
- gint column, GdkEvent * event,
- gpointer user_data)
+gnc_ui_qif_import_account_line_select_cb(GtkTreeSelection *selection,
+ gpointer user_data)
{
QIFImportWindow * wind = user_data;
-
- select_line (wind, row, wind->acct_display_info, wind->acct_map_info,
+ select_line (wind, selection, wind->acct_display_info, wind->acct_map_info,
update_accounts_page);
}
@@ -1016,13 +1104,11 @@
********************************************************************/
static void
-gnc_ui_qif_import_category_line_select_cb(GtkCList * clist, gint row,
- gint column, GdkEvent * event,
- gpointer user_data)
+gnc_ui_qif_import_category_line_select_cb(GtkTreeSelection *selection,
+ gpointer user_data)
{
QIFImportWindow * wind = user_data;
-
- select_line (wind, row, wind->cat_display_info, wind->cat_map_info,
+ select_line (wind, selection, wind->acct_display_info, wind->acct_map_info,
update_categories_page);
}
@@ -1033,13 +1119,11 @@
********************************************************************/
static void
-gnc_ui_qif_import_memo_line_select_cb(GtkCList * clist, gint row,
- gint column, GdkEvent * event,
- gpointer user_data)
+gnc_ui_qif_import_memo_line_select_cb(GtkTreeSelection *selection,
+ gpointer user_data)
{
QIFImportWindow * wind = user_data;
-
- select_line (wind, row, wind->memo_display_info, wind->memo_map_info,
+ select_line (wind, selection, wind->acct_display_info, wind->acct_map_info,
update_memo_page);
}
@@ -1117,12 +1201,17 @@
Transaction * gnc_xtn;
Split * gnc_split;
gnc_commodity * old_commodity;
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeSelection* selection;
const char * mnemonic = NULL;
const char * namespace = NULL;
const char * fullname = NULL;
- const gchar * row_text[4] = { NULL, NULL, NULL, NULL };
- int rownum;
+ const gchar * amount_str;
+ int rownum = 0;
/* get the default currency */
const char * currname = gtk_entry_get_text(GTK_ENTRY(wind->currency_entry));
@@ -1201,42 +1290,44 @@
return FALSE;
}
- gtk_clist_column_titles_passive (GTK_CLIST(wind->new_transaction_list));
-
/* otherwise, make up the display for the duplicates page */
- gtk_clist_clear(GTK_CLIST(wind->new_transaction_list));
- gtk_clist_freeze(GTK_CLIST(wind->new_transaction_list));
+ view = GTK_TREE_VIEW(wind->new_transaction_view);
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
+ gtk_list_store_clear(store);
while(!SCM_NULLP(retval)) {
current_xtn = SCM_CAAR(retval);
gnc_xtn = (Transaction *)gw_wcp_get_ptr(current_xtn);
- gnc_split = xaccTransGetSplit(gnc_xtn, 0);
- row_text[0] = gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn));
- row_text[1] = xaccTransGetDescription(gnc_xtn);
-
if(xaccTransCountSplits(gnc_xtn) > 2) {
- row_text[2] = g_strdup(_("(split)"));
+ amount_str = _("(split)");
}
else {
- row_text[2] =
+ gnc_split = xaccTransGetSplit(gnc_xtn, 0);
+ amount_str =
xaccPrintAmount(gnc_numeric_abs(xaccSplitGetValue(gnc_split)),
gnc_account_print_info
(xaccSplitGetAccount(gnc_split), TRUE));
}
- rownum = gtk_clist_append(GTK_CLIST(wind->new_transaction_list),
- (gchar **) row_text);
-
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set
+ (store, &iter,
+ QIF_TRANS_INDEX, rownum++,
+ QIF_TRANS_DATE, gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn)),
+ QIF_TRANS_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
+ QIF_TRANS_AMOUNT, amount_str,
+ -1);
+
retval = SCM_CDR(retval);
}
- gtk_clist_columns_autosize(GTK_CLIST(wind->new_transaction_list));
+ selection = gtk_tree_view_get_selection(view);
+ path = gtk_tree_path_new_from_indices (0, -1);
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_path_free(path);
+ }
- gtk_clist_thaw(GTK_CLIST(wind->new_transaction_list));
- gtk_clist_select_row(GTK_CLIST(wind->new_transaction_list), 0, 0);
- }
-
gnc_resume_gui_refresh();
return TRUE;
}
@@ -1630,77 +1721,102 @@
SCM selected;
Transaction * gnc_xtn;
Split * gnc_split;
- const gchar * row_text[4] = { NULL, NULL, NULL, NULL };
- int rownum;
+ const gchar * amount_str;
+ int rownum = 0;
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeIter iter;
- gtk_clist_column_titles_passive (GTK_CLIST(wind->old_transaction_list));
+ view = GTK_TREE_VIEW(wind->old_transaction_view);
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
+ gtk_list_store_clear(store);
- gtk_clist_clear(GTK_CLIST(wind->old_transaction_list));
- gtk_clist_freeze(GTK_CLIST(wind->old_transaction_list));
-
- gtk_clist_set_column_justification(GTK_CLIST(wind->old_transaction_list),
- 3,
- GTK_JUSTIFY_CENTER);
-
if(wind->match_transactions != SCM_BOOL_F) {
possible_matches = SCM_CDR(scm_list_ref(wind->match_transactions,
scm_int2num(wind->selected_transaction)));
scm_call_2(scm_c_eval_string("qif-import:refresh-match-selection"),
possible_matches, scm_int2num(selection));
- row_text[3] = "";
-
while(!SCM_NULLP(possible_matches)) {
current_xtn = SCM_CAR(possible_matches);
gnc_xtn = (Transaction *)gw_wcp_get_ptr(SCM_CAR(current_xtn));
selected = SCM_CDR(current_xtn);
- gnc_split = xaccTransGetSplit(gnc_xtn, 0);
- row_text[0] = gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn));
- row_text[1] = xaccTransGetDescription(gnc_xtn);
-
if(xaccTransCountSplits(gnc_xtn) > 2) {
- row_text[2] = _("(split)");
+ amount_str = _("(split)");
}
else {
- row_text[2] =
+ gnc_split = xaccTransGetSplit(gnc_xtn, 0);
+ amount_str =
xaccPrintAmount(gnc_numeric_abs(xaccSplitGetValue(gnc_split)),
gnc_account_print_info
(xaccSplitGetAccount(gnc_split), TRUE));
}
-
- rownum = gtk_clist_append(GTK_CLIST(wind->old_transaction_list),
- (gchar **) row_text);
- gnc_clist_set_check (GTK_CLIST(wind->old_transaction_list),
- rownum, 3, selected != SCM_BOOL_F);
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set
+ (store, &iter,
+ QIF_TRANS_INDEX, rownum++,
+ QIF_TRANS_DATE, gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn)),
+ QIF_TRANS_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
+ QIF_TRANS_AMOUNT, amount_str,
+ QIF_TRANS_CHECKED, selected != SCM_BOOL_F,
+ -1);
possible_matches = SCM_CDR(possible_matches);
}
}
-
- gtk_clist_columns_autosize (GTK_CLIST(wind->old_transaction_list));
-
- gtk_clist_thaw(GTK_CLIST(wind->old_transaction_list));
}
static void
-gnc_ui_qif_import_duplicate_new_select_cb(GtkCList * clist, int row, int col,
- GdkEvent * ev, gpointer user_data)
+gnc_ui_qif_import_duplicate_new_select_cb (GtkTreeSelection *selection,
+ QIFImportWindow *wind)
{
- QIFImportWindow * wind = user_data;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- wind->selected_transaction = row;
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ gtk_tree_model_get(model, &iter,
+ QIF_TRANS_INDEX, &wind->selected_transaction,
+ -1);
refresh_old_transactions(wind, -1);
}
+static gboolean
+reset_ignore_old_select(gboolean *ignore)
+{
+ *ignore = FALSE;
+ return FALSE;
+}
static void
-gnc_ui_qif_import_duplicate_old_select_cb(GtkCList * clist, int row, int col,
- GdkEvent * ev, gpointer user_data)
+gnc_ui_qif_import_duplicate_old_select_cb (GtkTreeSelection *selection,
+ QIFImportWindow *wind)
{
- QIFImportWindow * wind = user_data;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gint row;
+ static gboolean ignore_old_select = FALSE;
+ /* Get the current selection then clear it. We're about to clear
+ * the entire list store and rebuild it so this prevents errors. */
+ if (!gtk_tree_selection_get_selected(selection, &model, &iter))
+ return;
+ gtk_tree_selection_unselect_all(selection);
+
+ /* Getting a weird double call the first time a line is clicked.
+ * Once via gtk_tree_view_button_press and then again via
+ * gtk_tree_view_grab_focus. */
+ if (ignore_old_select)
+ return;
+ ignore_old_select = TRUE;
+ g_idle_add((GSourceFunc)reset_ignore_old_select, &ignore_old_select);
+
+ /* Get the row the user clicked on and update the scheme
+ * code/rebuild the list store. */
+ gtk_tree_model_get(model, &iter,
+ QIF_TRANS_INDEX, &row,
+ -1);
refresh_old_transactions(wind, row);
}
@@ -1797,7 +1913,13 @@
SCM mapping_info;
SCM create_ticker_map;
int i;
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
+
char * pre_page_names[NUM_PRE_PAGES] = {
"start_page", "load_file_page", "date_format_page", "account_name_page",
"loaded_files_page", "account_doc_page", "account_match_page",
@@ -1847,10 +1969,6 @@
G_CALLBACK (gnc_ui_qif_import_date_format_next_cb), retval);
glade_xml_signal_connect_data
- (xml, "gnc_ui_qif_import_select_loaded_file_cb",
- G_CALLBACK (gnc_ui_qif_import_select_loaded_file_cb), retval);
-
- glade_xml_signal_connect_data
(xml, "gnc_ui_qif_import_loaded_files_prepare_cb",
G_CALLBACK (gnc_ui_qif_import_loaded_files_prepare_cb), retval);
@@ -1871,18 +1989,6 @@
G_CALLBACK (gnc_ui_qif_import_default_acct_back_cb), retval);
glade_xml_signal_connect_data
- (xml, "gnc_ui_qif_import_account_line_select_cb",
- G_CALLBACK (gnc_ui_qif_import_account_line_select_cb), retval);
-
- glade_xml_signal_connect_data
- (xml, "gnc_ui_qif_import_category_line_select_cb",
- G_CALLBACK (gnc_ui_qif_import_category_line_select_cb), retval);
-
- glade_xml_signal_connect_data
- (xml, "gnc_ui_qif_import_memo_line_select_cb",
- G_CALLBACK (gnc_ui_qif_import_memo_line_select_cb), retval);
-
- glade_xml_signal_connect_data
(xml, "gnc_ui_qif_import_accounts_prepare_cb",
G_CALLBACK (gnc_ui_qif_import_accounts_prepare_cb), retval);
@@ -1907,14 +2013,6 @@
G_CALLBACK (gnc_ui_qif_import_commodity_prepare_cb), retval);
glade_xml_signal_connect_data
- (xml, "gnc_ui_qif_import_duplicate_new_select_cb",
- G_CALLBACK (gnc_ui_qif_import_duplicate_new_select_cb), retval);
-
- glade_xml_signal_connect_data
- (xml, "gnc_ui_qif_import_duplicate_old_select_cb",
- G_CALLBACK (gnc_ui_qif_import_duplicate_old_select_cb), retval);
-
- glade_xml_signal_connect_data
(xml, "gnc_ui_qif_import_finish_cb",
G_CALLBACK (gnc_ui_qif_import_finish_cb), retval);
@@ -1941,16 +2039,16 @@
retval->acct_entry = glade_xml_get_widget (xml, "qif_account_entry");
retval->date_format_combo = glade_xml_get_widget (xml, "date_format_combo");
retval->date_format_entry = glade_xml_get_widget (xml, "date_format_entry");
- retval->selected_file_list = glade_xml_get_widget(xml, "selected_file_list");
+ retval->selected_file_view = glade_xml_get_widget(xml, "selected_file_view");
retval->currency_picker = glade_xml_get_widget (xml, "currency_combo");
retval->currency_entry = glade_xml_get_widget (xml, "currency_entry");
- retval->acct_list = glade_xml_get_widget (xml, "account_page_list");
- retval->cat_list = glade_xml_get_widget (xml, "category_page_list");
- retval->memo_list = glade_xml_get_widget (xml, "memo_page_list");
- retval->new_transaction_list =
- glade_xml_get_widget (xml, "new_transaction_list");
- retval->old_transaction_list =
- glade_xml_get_widget (xml, "old_transaction_list");
+ retval->acct_view = glade_xml_get_widget (xml, "account_page_view");
+ retval->cat_view = glade_xml_get_widget (xml, "category_page_view");
+ retval->memo_view = glade_xml_get_widget (xml, "memo_page_view");
+ retval->new_transaction_view =
+ glade_xml_get_widget (xml, "new_transaction_view");
+ retval->old_transaction_view =
+ glade_xml_get_widget (xml, "old_transaction_view");
retval->pre_comm_pages = NULL;
retval->post_comm_pages = NULL;
@@ -1976,6 +2074,101 @@
glade_xml_get_widget (xml, doc_page_names[i]));
}
+ /* Set up the selected file view */
+ view = GTK_TREE_VIEW(retval->selected_file_view);
+ store = gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING);
+ gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Account"), renderer,
+ "text", FILENAME_NAME,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ selection = gtk_tree_view_get_selection(view);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(gnc_ui_qif_import_select_loaded_file_cb),
+ retval);
+
+ create_account_picker_view(retval->acct_view, _("QIF account name"),
+ G_CALLBACK(gnc_ui_qif_import_account_line_select_cb),
+ retval);
+ create_account_picker_view(retval->cat_view, _("QIF category name"),
+ G_CALLBACK(gnc_ui_qif_import_category_line_select_cb),
+ retval);
+ create_account_picker_view(retval->memo_view, _("QIF payee/memo"),
+ G_CALLBACK(gnc_ui_qif_import_memo_line_select_cb),
+ retval);
+
+ /* Set up the new transaction view */
+ view = GTK_TREE_VIEW(retval->new_transaction_view);
+ store = gtk_list_store_new(4, G_TYPE_INT, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING);
+ gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Date"), renderer,
+ "text", QIF_TRANS_DATE,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Description"), renderer,
+ "text", QIF_TRANS_DESCRIPTION,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+ gtk_tree_view_column_set_expand(column, TRUE);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Amount"), renderer,
+ "text", QIF_TRANS_AMOUNT,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ selection = gtk_tree_view_get_selection(view);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(gnc_ui_qif_import_duplicate_new_select_cb),
+ retval);
+
+
+ /* Set up the old transaction view */
+ view = GTK_TREE_VIEW(retval->old_transaction_view);
+ store = gtk_list_store_new(5, G_TYPE_INT, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_BOOLEAN);
+ gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Date"), renderer,
+ "text", QIF_TRANS_DATE,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Description"), renderer,
+ "text", QIF_TRANS_DESCRIPTION,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+ gtk_tree_view_column_set_expand(column, TRUE);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Amount"), renderer,
+ "text", QIF_TRANS_AMOUNT,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ renderer = gtk_cell_renderer_toggle_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Dup?"), renderer,
+ "active", QIF_TRANS_CHECKED,
+ NULL);
+ gtk_tree_view_append_column(view, column);
+
+ selection = gtk_tree_view_get_selection(view);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(gnc_ui_qif_import_duplicate_old_select_cb),
+ retval);
+
+
/* load the saved-state of the mappings from Quicken accounts and
* categories to gnucash accounts */
load_map_prefs = scm_c_eval_string("qif-import:load-map-prefs");
Modified: gnucash/branches/deprecated-cleanup/src/import-export/qif-import/qif.glade
===================================================================
--- gnucash/branches/deprecated-cleanup/src/import-export/qif-import/qif.glade 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/import-export/qif-import/qif.glade 2006-05-07 00:38:45 UTC (rev 13937)
@@ -102,44 +102,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCTree" id="account_tree">
+ <widget class="GtkTreeView" id="account_tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">2</property>
- <property name="column_widths">214,48</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">True</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
-
- <child>
- <widget class="GtkLabel" id="label847711">
- <property name="label" translatable="yes">Account</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847712">
- <property name="label" translatable="yes">New?</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
@@ -569,38 +539,23 @@
<property name="spacing">4</property>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow10">
+ <widget class="GtkScrolledWindow" id="scrolledwindow26">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="selected_file_list">
+ <widget class="GtkTreeView" id="selected_file_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">1</property>
- <property name="column_widths">80</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">False</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <signal name="select_row" handler="gnc_ui_qif_import_select_loaded_file_cb"/>
-
- <child>
- <widget class="GtkLabel" id="label827">
- <property name="label" translatable="no">labe82l7</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
@@ -737,66 +692,21 @@
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow11">
<property name="visible">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="account_page_list">
+ <widget class="GtkTreeView" id="account_page_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">3</property>
- <property name="column_widths">281,242,53</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">True</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <signal name="select_row" handler="gnc_ui_qif_import_account_line_select_cb"/>
-
- <child>
- <widget class="GtkLabel" id="label834">
- <property name="label" translatable="yes">QIF account name</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label835">
- <property name="label" translatable="yes">GnuCash account name</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label836">
- <property name="label" translatable="yes">New?</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
@@ -901,60 +811,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="category_page_list">
+ <widget class="GtkTreeView" id="category_page_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">3</property>
- <property name="column_widths">243,250,72</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">True</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <signal name="select_row" handler="gnc_ui_qif_import_category_line_select_cb"/>
-
- <child>
- <widget class="GtkLabel" id="label837">
- <property name="label" translatable="yes">QIF category name</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label838">
- <property name="label" translatable="yes">GnuCash account name</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label839">
- <property name="label" translatable="yes">New?</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
@@ -1049,7 +913,7 @@
<property name="spacing">0</property>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow25">
+ <widget class="GtkScrolledWindow" id="scrolledwindow12">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
@@ -1057,60 +921,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="memo_page_list">
+ <widget class="GtkTreeView" id="memo_page_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">3</property>
- <property name="column_widths">285,228,72</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">True</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <signal name="select_row" handler="gnc_ui_qif_import_memo_line_select_cb"/>
-
- <child>
- <widget class="GtkLabel" id="label847708">
- <property name="label" translatable="yes">QIF payee/memo</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847709">
- <property name="label" translatable="yes">GnuCash account name</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847710">
- <property name="label" translatable="yes">New?</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
@@ -1358,7 +1176,7 @@
<child>
<widget class="GtkHBox" id="hbox94">
<property name="visible">True</property>
- <property name="homogeneous">True</property>
+ <property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
@@ -1377,60 +1195,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="new_transaction_list">
+ <widget class="GtkTreeView" id="new_transaction_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">3</property>
- <property name="column_widths">53,172,56</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">True</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <signal name="select_row" handler="gnc_ui_qif_import_duplicate_new_select_cb"/>
-
- <child>
- <widget class="GtkLabel" id="label847700">
- <property name="label" translatable="yes">Date</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847700">
- <property name="label" translatable="yes">Description</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847702">
- <property name="label" translatable="yes">Amount</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
@@ -1478,75 +1250,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="old_transaction_list">
+ <widget class="GtkTreeView" id="old_transaction_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">4</property>
- <property name="column_widths">50,133,55,32</property>
- <property name="selection_mode">GTK_SELECTION_SINGLE</property>
- <property name="show_titles">True</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <signal name="select_row" handler="gnc_ui_qif_import_duplicate_old_select_cb"/>
-
- <child>
- <widget class="GtkLabel" id="label847703">
- <property name="label" translatable="yes">Date</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847704">
- <property name="label" translatable="yes">Description</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847705">
- <property name="label" translatable="yes">Amount</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847706">
- <property name="label" translatable="yes">Dup?</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
Modified: gnucash/branches/deprecated-cleanup/src/report/report-gnome/dialog-column-view.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/report/report-gnome/dialog-column-view.c 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/report/report-gnome/dialog-column-view.c 2006-05-07 00:38:45 UTC (rev 13937)
@@ -1,6 +1,7 @@
/********************************************************************
* dialog-column-view.c -- editor for simple column view of reports *
* Copyright (C) 2001 Bill Gribble <grib at billgribble.com> *
+ * Copyright (c) 2006 David Hampton <hampton at employees.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@@ -34,10 +35,18 @@
#include "guile-mappings.h"
#include "gnc-report.h"
+#define AVAILABLE_NAME 0
+#define AVAILABLE_ROW 1
+
+#define CONTENTS_NAME 0
+#define CONTENTS_ROW 1
+#define CONTENTS_REPORT_ROWS 2
+#define CONTENTS_REPORT_COLS 3
+
struct gncp_column_view_edit {
GNCOptionWin * optwin;
- GtkCList * available;
- GtkCList * contents;
+ GtkTreeView * available;
+ GtkTreeView * contents;
SCM options;
SCM view;
@@ -99,10 +108,14 @@
SCM contents =
gnc_option_db_lookup_option(view->odb, "__general", "report-list",
SCM_BOOL_F);
- SCM this_report, this_name;
+ SCM this_report;
SCM selection;
- char * name[3];
+ const gchar *name;
int row, i, id;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeSelection *tree_selection;
/* Update the list of available reports (left selection box). */
row = view->available_selected;
@@ -119,18 +132,26 @@
view->available_list = names;
scm_gc_protect_object(view->available_list);
- gtk_clist_freeze(view->available);
- gtk_clist_clear(view->available);
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(view->available));
+ gtk_list_store_clear(store);
if(SCM_LISTP(names)) {
for(i = 0; !SCM_NULLP(names); names = SCM_CDR(names), i++) {
if (SCM_EQUALP (SCM_CAR(names), selection))
row = i;
- name[0] = SCM_STRING_CHARS(scm_call_1(template_menu_name, SCM_CAR(names)));
- gtk_clist_append(view->available, name);
+ name = SCM_STRING_CHARS(scm_call_1(template_menu_name, SCM_CAR(names)));
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ AVAILABLE_NAME, name,
+ AVAILABLE_ROW, i,
+ -1);
}
}
- gtk_clist_select_row(view->available, row, 0);
- gtk_clist_thaw(view->available);
+
+ tree_selection = gtk_tree_view_get_selection(view->available);
+ path = gtk_tree_path_new_from_indices(row, -1);
+ gtk_tree_selection_select_path(tree_selection, path);
+ // gtk_tree_view_scroll_to_cell(view->available, path, NULL, TRUE, 0.5, 0.0);
+ gtk_tree_path_free(path);
/* Update the list of selected reports (right selection box). */
@@ -148,8 +169,8 @@
view->contents_list = contents;
scm_gc_protect_object(view->contents_list);
- gtk_clist_freeze(view->contents);
- gtk_clist_clear(view->contents);
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(view->contents));
+ gtk_list_store_clear(store);
if(SCM_LISTP(contents)) {
for(i = 0; !SCM_NULLP(contents); contents = SCM_CDR(contents), i++) {
if (SCM_EQUALP (SCM_CAR(contents), selection))
@@ -157,37 +178,52 @@
id = scm_num2int(SCM_CAAR(contents), SCM_ARG1, __FUNCTION__);
this_report = gnc_report_find(id);
- /* this_name = scm_call_1(report_name, this_report); */
- this_name = scm_call_1(report_menu_name, this_report);
- name[0] = g_strdup(SCM_STRING_CHARS(this_name));
- name[1] = g_strdup_printf("%d", scm_num2int(SCM_CADR(SCM_CAR(contents)),
- SCM_ARG1, __FUNCTION__));
- name[2] = g_strdup_printf("%d", scm_num2int(SCM_CADDR(SCM_CAR(contents)),
- SCM_ARG1, __FUNCTION__));
- gtk_clist_append(view->contents, name);
- g_free(name[0]);
- g_free(name[1]);
- g_free(name[2]);
+
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set
+ (store, &iter,
+ CONTENTS_NAME, SCM_STRING_CHARS(scm_call_1(report_menu_name,
+ this_report)),
+ CONTENTS_ROW, i,
+ CONTENTS_REPORT_COLS, scm_num2int(SCM_CADR(SCM_CAR(contents)),
+ SCM_ARG1, __FUNCTION__),
+ CONTENTS_REPORT_ROWS, scm_num2int(SCM_CADDR(SCM_CAR(contents)),
+ SCM_ARG1, __FUNCTION__),
+ -1);
}
}
- gtk_clist_select_row(view->contents, row, 0);
- gtk_clist_thaw(view->contents);
+
+ tree_selection = gtk_tree_view_get_selection(view->contents);
+ path = gtk_tree_path_new_from_indices(row, -1);
+ gtk_tree_selection_select_path(tree_selection, path);
+ // gtk_tree_view_scroll_to_cell(view->contents, path, NULL, TRUE, 0.5, 0.0);
+ gtk_tree_path_free(path);
}
static void
-gnc_column_view_select_avail_cb(GtkCList * clist, gint row, gint col,
- GdkEvent * ev, gpointer data)
+gnc_column_view_select_avail_cb(GtkTreeSelection *selection,
+ gnc_column_view_edit *r)
{
- gnc_column_view_edit * r = data;
- r->available_selected = row;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ gtk_tree_model_get(model, &iter,
+ AVAILABLE_ROW, &r->available_selected,
+ -1);
}
static void
-gnc_column_view_select_contents_cb(GtkCList * clist, gint row, gint col,
- GdkEvent * ev, gpointer data)
+gnc_column_view_select_contents_cb(GtkTreeSelection *selection,
+ gnc_column_view_edit *r)
{
- gnc_column_view_edit * r = data;
- r->contents_selected = row;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ gtk_tree_model_get(model, &iter,
+ AVAILABLE_ROW, &r->contents_selected,
+ -1);
}
static void
@@ -223,6 +259,10 @@
SCM get_editor = scm_c_eval_string("gnc:report-editor-widget");
SCM ptr;
GtkWidget * editor;
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
ptr = scm_call_1(get_editor, view);
if(ptr != SCM_BOOL_F) {
@@ -268,8 +308,8 @@
G_CALLBACK (gnc_column_view_edit_size_cb), r);
editor = glade_xml_get_widget (xml, "view_contents_table");
- r->available = GTK_CLIST (glade_xml_get_widget (xml, "available_list"));
- r->contents = GTK_CLIST (glade_xml_get_widget (xml, "contents_list"));
+ r->available = GTK_TREE_VIEW (glade_xml_get_widget (xml, "available_view"));
+ r->contents = GTK_TREE_VIEW (glade_xml_get_widget (xml, "contents_view"));
r->options = options;
r->view = view;
r->available_selected = 0;
@@ -278,11 +318,6 @@
r->contents_list = SCM_EOL;
r->odb = gnc_option_db_new(r->options);
- gtk_clist_set_column_auto_resize(r->available, 0, TRUE);
- gtk_clist_set_column_auto_resize(r->contents, 0, TRUE);
- gtk_clist_set_column_auto_resize(r->contents, 1, TRUE);
- gtk_clist_set_column_auto_resize(r->contents, 2, TRUE);
-
gnc_build_options_dialog_contents(r->optwin, r->odb);
gtk_notebook_append_page(GTK_NOTEBOOK(gnc_options_dialog_notebook
@@ -295,16 +330,48 @@
scm_gc_protect_object(r->available_list);
scm_gc_protect_object(r->contents_list);
- g_signal_connect(G_OBJECT(r->available), "select_row",
- G_CALLBACK (gnc_column_view_select_avail_cb), (gpointer)r);
- g_signal_connect(G_OBJECT(r->contents), "select_row",
- G_CALLBACK (gnc_column_view_select_contents_cb), (gpointer)r);
+ /* Build the 'available' view */
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
+ gtk_tree_view_set_model(r->available, GTK_TREE_MODEL(store));
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("", renderer,
+ "text", AVAILABLE_NAME,
+ NULL);
+ gtk_tree_view_append_column(r->available, column);
+
+ selection = gtk_tree_view_get_selection(r->available);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(gnc_column_view_select_avail_cb), r);
+
+ /* Build the 'contents' view */
+ store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
+ gtk_tree_view_set_model(r->contents, GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Report"), renderer,
+ "text", CONTENTS_NAME,
+ NULL);
+ gtk_tree_view_append_column(r->contents, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Cols"), renderer,
+ "text", CONTENTS_REPORT_COLS,
+ NULL);
+ gtk_tree_view_append_column(r->contents, column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Rows"), renderer,
+ "text", CONTENTS_REPORT_ROWS,
+ NULL);
+ gtk_tree_view_append_column(r->contents, column);
+
+ selection = gtk_tree_view_get_selection(r->contents);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK(gnc_column_view_select_contents_cb), r);
+
update_display_lists(r);
- gtk_clist_column_titles_passive (r->available);
- gtk_clist_column_titles_passive (r->contents);
-
gnc_options_dialog_set_apply_cb(r->optwin,
gnc_column_view_edit_apply_cb, r);
gnc_options_dialog_set_close_cb(r->optwin,
Modified: gnucash/branches/deprecated-cleanup/src/report/report-gnome/report.glade
===================================================================
--- gnucash/branches/deprecated-cleanup/src/report/report-gnome/report.glade 2006-05-07 00:14:02 UTC (rev 13936)
+++ gnucash/branches/deprecated-cleanup/src/report/report-gnome/report.glade 2006-05-07 00:38:45 UTC (rev 13937)
@@ -269,59 +269,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="contents_list">
+ <widget class="GtkTreeView" id="contents_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">3</property>
- <property name="column_widths">150,34,25</property>
- <property name="selection_mode">GTK_SELECTION_BROWSE</property>
- <property name="show_titles">True</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
-
- <child>
- <widget class="GtkLabel" id="label847725">
- <property name="label" translatable="yes">Report</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847726">
- <property name="label" translatable="yes">Cols</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label847727">
- <property name="label" translatable="yes">Rows</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
@@ -342,11 +297,11 @@
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
- <property name="xalign">0.5</property>
+ <property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="mnemonic_widget">available_list</property>
+ <property name="mnemonic_widget">available_view</property>
</widget>
<packing>
<property name="left_attach">0</property>
@@ -371,7 +326,7 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="mnemonic_widget">contents_list</property>
+ <property name="mnemonic_widget">contents_view</property>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -577,29 +532,14 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkCList" id="available_list">
+ <widget class="GtkTreeView" id="available_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="n_columns">1</property>
- <property name="column_widths">80</property>
- <property name="selection_mode">GTK_SELECTION_BROWSE</property>
- <property name="show_titles">False</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
-
- <child>
- <widget class="GtkLabel" id="label847735">
- <property name="label" translatable="yes">label847735</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- </child>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
</widget>
</child>
</widget>
More information about the gnucash-changes
mailing list