1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2018 Maxime DOYEN
4 * This file is part of HomeBank.
6 * HomeBank is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * HomeBank is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "list_operation.h"
25 /****************************************************************************/
27 /****************************************************************************/
36 /* our global datas */
37 extern struct HomeBank
*GLOBALS
;
38 extern struct Preferences
*PREFS
;
42 //extern gboolean minor_active;
45 /* This is not pretty. Of course you can also use a
46 * separate compare function for each sort ID value */
48 static gint
list_txn_sort_iter_compare_strings(gchar
*s1
, gchar
*s2
)
50 return hb_string_utf8_compare(s1
, s2
);
55 list_txn_sort_iter_compare_func (GtkTreeModel
*model
,
60 gint sortcol
= GPOINTER_TO_INT(userdata
);
62 Transaction
*ope1
, *ope2
;
65 gtk_tree_model_get(model
, a
, LST_DSPOPE_DATAS
, &ope1
, -1);
66 gtk_tree_model_get(model
, b
, LST_DSPOPE_DATAS
, &ope2
, -1);
70 case LST_DSPOPE_STATUS
:
71 if(!(retval
= (ope1
->flags
& OF_ADDED
) - (ope2
->flags
& OF_ADDED
) ) )
73 retval
= (ope1
->flags
& OF_CHANGED
) - (ope2
->flags
& OF_CHANGED
);
78 if(! (retval
= ope1
->date
- ope2
->date
) )
80 //g_print("sort on balance d1=%d, d2=%d %f %f\n", ope1->date, ope2->date, ope1->balance , ope2->balance);
82 tmpval
= ope1
->pos
- ope2
->pos
;
83 retval
= tmpval
> 0 ? 1 : -1;
85 //g_print("ret=%d\n", ret);
88 case LST_DSPOPE_ACCOUNT
:
92 a1
= da_acc_get(ope1
->kacc
);
93 a2
= da_acc_get(ope2
->kacc
);
94 retval
= list_txn_sort_iter_compare_strings((a1
!= NULL
) ? a1
->name
: NULL
, (a2
!= NULL
) ? a2
->name
: NULL
);
99 if(!(retval
= ope1
->paymode
- ope2
->paymode
))
101 retval
= list_txn_sort_iter_compare_strings(ope1
->info
, ope2
->info
);
105 case LST_DSPOPE_PAYEE
:
107 if( ope1
->paymode
==PAYMODE_INTXFER
&& ope2
->paymode
==PAYMODE_INTXFER
)
111 a1
= da_acc_get(ope1
->kxferacc
);
112 a2
= da_acc_get(ope2
->kxferacc
);
113 retval
= list_txn_sort_iter_compare_strings((a1
!= NULL
) ? a1
->name
: NULL
, (a2
!= NULL
) ? a2
->name
: NULL
);
119 p1
= da_pay_get(ope1
->kpay
);
120 p2
= da_pay_get(ope2
->kpay
);
121 retval
= list_txn_sort_iter_compare_strings((p1
!= NULL
) ? p1
->name
: NULL
, (p2
!= NULL
) ? p2
->name
: NULL
);
126 case LST_DSPOPE_MEMO
:
127 retval
= list_txn_sort_iter_compare_strings(ope1
->memo
, ope2
->memo
);
131 retval
= ope1
->status
- ope2
->status
;
134 case LST_DSPOPE_AMOUNT
:
135 case LST_DSPOPE_EXPENSE
:
136 case LST_DSPOPE_INCOME
:
137 tmpval
= ope1
->amount
- ope2
->amount
;
138 retval
= tmpval
> 0 ? 1 : -1;
141 case LST_DSPOPE_CATEGORY
:
144 gchar
*name1
, *name2
;
146 c1
= da_cat_get(ope1
->kcat
);
147 c2
= da_cat_get(ope2
->kcat
);
148 if( c1
!= NULL
&& c2
!= NULL
)
150 name1
= da_cat_get_fullname(c1
);
151 name2
= da_cat_get_fullname(c2
);
152 retval
= list_txn_sort_iter_compare_strings(name1
, name2
);
159 case LST_DSPOPE_TAGS
:
163 t1
= transaction_tags_tostring(ope1
);
164 t2
= transaction_tags_tostring(ope2
);
165 retval
= list_txn_sort_iter_compare_strings(t1
, t2
);
172 g_return_val_if_reached(0);
179 static void list_txn_eval_future(GtkCellRenderer
*renderer
, Transaction
*txn
)
182 //it seems we are not able to get a valid GdkRGBA
183 //nor to set/use the alpha
185 g_object_get(renderer, "foreground-rgba", &rgba, NULL);
186 g_print("forcol: %p %f %f %f %f\n", rgba, rgba->red, rgba->green, rgba->blue, rgba->alpha);
189 g_object_set(renderer, "foreground-set", TRUE,
190 "foreground-rgba", rgba,
195 if(txn
->date
> GLOBALS
->today
)
197 g_object_set(renderer
,
201 "style", PANGO_STYLE_OBLIQUE
,
206 g_object_set(renderer
, "scale-set", FALSE
, "style-set", FALSE
,
213 ** date cell function
215 static void list_txn_status_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
218 gchar
*iconname
= NULL
;
220 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &entry
, -1);
223 stat[0] = ( entry->ope_Flags & OF_ADDED ) ? data->istatus[2] : data->istatus[0];
224 stat[1] = ( entry->ope_Flags & OF_CHANGED) ? data->istatus[3] : data->istatus[0];
225 stat[2] = ( entry->ope_Flags & OF_VALID ) ? data->istatus[4] : data->istatus[0];
226 if( entry->ope_Flags & OF_REMIND ) stat[2] = data->istatus[1];
229 switch(GPOINTER_TO_INT(user_data
))
232 iconname
= ( entry
->flags
& OF_AUTO
) ? ICONNAME_HB_OPE_AUTO
: ( entry
->flags
& OF_ADDED
) ? ICONNAME_NEW
: NULL
;
235 iconname
= ( entry
->flags
& OF_CHANGED
) ? ICONNAME_HB_OPE_EDIT
: NULL
;
238 if( entry->flags & OF_VALID )
239 iconname = ICONNAME_HB_OPE_VALID;
242 if( entry->flags & OF_REMIND )
243 iconname = ICONNAME_HB_OPE_REMIND;
247 g_object_set(renderer
, "icon-name", iconname
, NULL
);
252 ** account cell function
254 static void list_txn_account_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
259 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
261 acc
= da_acc_get(ope
->kacc
);
264 g_object_set(renderer
, "text", acc
->name
, NULL
);
267 g_object_set(renderer
, "text", "", NULL
);
271 ** date cell function
273 static void list_txn_date_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
279 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
280 list_txn_eval_future(renderer
, ope
);
284 g_date_set_julian (&date
, ope
->date
);
285 g_date_strftime (buffer
, 256-1, PREFS
->date_format
, &date
);
287 //g_snprintf(buf, sizeof(buf), "%d", ope->ope_Date);
289 g_object_set(renderer
, "text", buffer
, NULL
);
292 g_object_set(renderer
, "text", "????", NULL
);
296 ** info cell function
298 static void list_txn_info_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
302 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
304 switch(GPOINTER_TO_INT(user_data
))
307 g_object_set(renderer
, "icon-name", get_paymode_icon_name(ope
->paymode
), NULL
);
310 list_txn_eval_future(renderer
, ope
);
311 g_object_set(renderer
, "text", ope
->info
, NULL
);
317 ** payee cell function
319 static void list_txn_payee_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
323 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
324 list_txn_eval_future(renderer
, ope
);
327 if(ope
->paymode
== PAYMODE_INTXFER
)
329 Account
*acc
= da_acc_get(ope
->kxferacc
);
331 g_object_set(renderer
, "text", (acc
!= NULL
) ? acc
->name
: "", NULL
);
335 Payee
*pay
= da_pay_get(ope
->kpay
);
337 g_object_set(renderer
, "text", pay
!= NULL
? pay
->name
: "", NULL
);
343 ** tags cell function
345 static void list_txn_tags_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
350 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
351 list_txn_eval_future(renderer
, ope
);
353 if(ope
->tags
!= NULL
)
355 str
= transaction_tags_tostring(ope
);
356 g_object_set(renderer
, "text", str
, NULL
);
360 g_object_set(renderer
, "text", "", NULL
);
367 ** memo cell function
369 static void list_txn_memo_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
373 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
374 list_txn_eval_future(renderer
, ope
);
376 g_object_set(renderer
, "text", ope
->memo
, NULL
);
383 static void list_txn_clr_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
386 gchar
*iconname
= NULL
;
387 //const gchar *c = "";
389 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
392 /*case TXN_STATUS_CLEARED: c = "c"; break;
393 case TXN_STATUS_RECONCILED: c = "R"; break;
394 case TXN_STATUS_REMIND: c = "!"; break;*/
395 case TXN_STATUS_CLEARED
: iconname
= ICONNAME_HB_OPE_CLEARED
; break;
396 case TXN_STATUS_RECONCILED
: iconname
= ICONNAME_HB_OPE_RECONCILED
; break;
397 case TXN_STATUS_REMIND
: iconname
= ICONNAME_HB_OPE_REMIND
; break;
401 //g_object_set(renderer, "text", c, NULL);
402 g_object_set(renderer
, "icon-name", iconname
, NULL
);
408 ** amount cell function
410 static void list_txn_amount_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
413 gint column
= GPOINTER_TO_INT(user_data
);
414 gchar buf
[G_ASCII_DTOSTR_BUF_SIZE
];
419 // get the transaction
420 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
421 list_txn_eval_future(renderer
, ope
);
423 if(column
== LST_DSPOPE_BALANCE
)
424 amount
= ope
->balance
;
426 amount
= ope
->amount
;
428 if(column
== LST_DSPOPE_INCOME
|| column
== LST_DSPOPE_EXPENSE
)
430 type
= (ope
->flags
& OF_INCOME
) ? LST_DSPOPE_INCOME
: LST_DSPOPE_EXPENSE
;
433 g_object_set(renderer
, "markup", NULL
, NULL
);
440 hb_strfmon(buf
, G_ASCII_DTOSTR_BUF_SIZE
-1, amount
, ope
->kcur
, GLOBALS
->minor
);
442 color
= get_normal_color_amount(amount
);
443 if( (column
== LST_DSPOPE_BALANCE
) && (ope
->overdraft
== TRUE
) && (PREFS
->custom_colors
== TRUE
) )
445 color
= PREFS
->color_warn
;
448 g_object_set(renderer
,
459 ** category cell function
461 static void list_txn_category_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
467 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
468 list_txn_eval_future(renderer
, ope
);
470 if(ope
->flags
& OF_SPLIT
)
472 g_object_set(renderer
, "text", _("- split -"), NULL
);
476 cat
= da_cat_get(ope
->kcat
);
479 fullname
= da_cat_get_fullname(cat
);
480 g_object_set(renderer
, "text", fullname
, NULL
);
484 g_object_set(renderer
, "text", "", NULL
);
491 /* = = = = = = = = = = = = = = = = */
493 GString
*list_txn_to_string(GtkTreeView
*treeview
, gboolean clipboard
)
502 gchar
*info
, *payeename
, *categoryname
;
506 char amountbuf
[G_ASCII_DTOSTR_BUF_SIZE
];
508 node
= g_string_new(NULL
);
512 g_string_append (node
, "date\tpaymode\tinfo\tpayee\tmemo\tamount\tcategory\ttags\n");
514 g_string_append (node
, "date;paymode;info;payee;memo;amount;category;tags\n");
516 model
= gtk_tree_view_get_model(treeview
);
518 valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
521 gtk_tree_model_get (model
, &iter
,
522 LST_DSPOPE_DATAS
, &ope
,
525 hb_sprint_date(datebuf
, ope
->date
);
528 if(info
== NULL
) info
= "";
529 payee
= da_pay_get(ope
->kpay
);
530 payeename
= (payee
->name
== NULL
) ? "" : payee
->name
;
531 category
= da_cat_get(ope
->kcat
);
532 categoryname
= (category
->name
== NULL
) ? NULL
: da_cat_get_fullname(category
);
533 tags
= transaction_tags_tostring(ope
);
536 //g_ascii_dtostr (amountbuf, sizeof (amountbuf), ope->amount);
537 g_ascii_formatd (amountbuf
, sizeof (amountbuf
), "%.2f", ope
->amount
);
539 DB( g_print("amount = %f '%s'\n", ope
->amount
, amountbuf
) );
541 format
= (clipboard
== TRUE
) ? "%s\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n" : "%s;%d;%s;%s;%s;%s;%s;%s\n";
542 g_string_append_printf(node
, format
,
549 categoryname
!= NULL
? categoryname
: "",
550 tags
!= NULL
? tags
: ""
554 g_free(categoryname
);
557 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);
560 //DB( g_print("text is:\n%s", node->str) );
566 gboolean
list_txn_column_id_isvisible(GtkTreeView
*treeview
, gint sort_id
)
568 GtkTreeViewColumn
*column
;
571 for(n
=0; n
< NUM_LST_DSPOPE
-1 ; n
++ ) // -1 cause account not to be processed
573 column
= gtk_tree_view_get_column (treeview
, n
);
577 if( gtk_tree_view_column_get_visible(column
) )
579 id
= gtk_tree_view_column_get_sort_column_id (column
);
589 static GtkTreeViewColumn
*list_txn_get_column(GList
*list
, gint search_id
)
591 GtkTreeViewColumn
*column
= NULL
;
595 tmp
= g_list_first(list
);
598 id
= gtk_tree_view_column_get_sort_column_id(tmp
->data
);
599 if( search_id
== id
)
604 tmp
= g_list_next(tmp
);
610 guint
list_txn_get_quicksearch_column_mask(GtkTreeView
*treeview
)
612 GtkTreeViewColumn
*column
;
617 for(n
=0; n
< NUM_LST_DSPOPE
-1 ; n
++ ) // -1 cause account not to be processed
619 column
= gtk_tree_view_get_column (treeview
, n
);
623 if( gtk_tree_view_column_get_visible(column
) )
625 id
= gtk_tree_view_column_get_sort_column_id (column
);
628 case LST_DSPOPE_MEMO
: mask
|= FLT_QSEARCH_MEMO
; break;
629 case LST_DSPOPE_INFO
: mask
|= FLT_QSEARCH_INFO
; break;
630 case LST_DSPOPE_PAYEE
: mask
|= FLT_QSEARCH_PAYEE
; break;
631 case LST_DSPOPE_CATEGORY
: mask
|= FLT_QSEARCH_CATEGORY
; break;
632 case LST_DSPOPE_TAGS
: mask
|= FLT_QSEARCH_TAGS
; break;
633 case LST_DSPOPE_AMOUNT
:
634 case LST_DSPOPE_EXPENSE
:
635 case LST_DSPOPE_INCOME
: mask
|= FLT_QSEARCH_AMOUNT
; break;
644 void list_txn_set_save_column_width(GtkTreeView
*treeview
, gboolean save_column_width
)
646 struct list_txn_data
*data
;
648 data
= g_object_get_data(G_OBJECT(treeview
), "inst_data");
651 data
->save_column_width
= save_column_width
;
656 void list_txn_sort_force(GtkTreeSortable
*sortable
, gpointer user_data
)
661 DB( g_print("list_txn_sort_force\n") );
663 gtk_tree_sortable_get_sort_column_id(sortable
, &sort_column_id
, &order
);
664 DB( g_print(" - id %d order %d\n", sort_column_id
, order
) );
666 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable
), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID
, order
);
667 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable
), sort_column_id
, order
);
671 static void list_txn_get_columns(GtkTreeView
*treeview
)
673 struct list_txn_data
*data
;
674 GtkTreeViewColumn
*column
;
677 DB( g_print("\n[list_txn] get columns order/width\n") );
679 data
= g_object_get_data(G_OBJECT(treeview
), "inst_data");
681 DB( g_print(" nbcol=%d, nbsortid=%d\n", NUM_LST_DSPOPE
, gtk_tree_view_get_n_columns (treeview
)) );
683 for(i
=0 ; i
< NUM_LST_DSPOPE
-1 ; i
++ ) // -1 'caus: account and blank column
685 column
= gtk_tree_view_get_column(treeview
, i
);
688 col_id
= gtk_tree_view_column_get_sort_column_id (column
);
693 visible
= gtk_tree_view_column_get_visible (column
);
694 if( col_id
== LST_DSPOPE_BALANCE
) //keep initial state of balance
695 visible
= data
->tvc_is_visible
;
698 PREFS
->lst_ope_columns
[i
] = col_id
;
700 PREFS
->lst_ope_columns
[i
] = -col_id
;
702 PREFS
->lst_ope_col_size
[col_id
-1] = gtk_tree_view_column_get_width(column
);
704 DB( g_print(" col-%2d => %2d '%s' w=%d\n", i
, col_id
, gtk_tree_view_column_get_title(column
), PREFS
->lst_ope_col_size
[col_id
-1] ) );
706 else //should not occurs
707 PREFS
->lst_ope_columns
[i
] = 0;
713 static void list_txn_set_columns(GtkTreeView
*treeview
, gint
*col_id
)
715 struct list_txn_data
*data
;
716 GtkTreeViewColumn
*column
, *base
;
722 DB( g_print("\n[list_txn] set columns order/width\n") );
724 data
= g_object_get_data(G_OBJECT(treeview
), "inst_data");
727 DB( g_print("\n debug column sortid\n") );
729 for(i
=0; i
< NUM_LST_DSPOPE
-1 ; i
++ ) // -1 cause account not to be processed
731 DB( g_print(" - pos:%2d sortid:%2d\n", i
, col_id
[i
]) );
736 DB( g_print("\n apply column prefs\n") );
738 list
= gtk_tree_view_get_columns( treeview
);
742 for(i
=0; i
< NUM_LST_DSPOPE
-1 ; i
++ ) // -1 cause account not to be processed
744 /* hidden are stored as col_id negative */
746 column
= list_txn_get_column(list
, id
);
748 //DB( g_print(" - get column %d %p\n", id, column) );
752 DB( g_print(" - pos:%2d sortid:%2d (%s)\n", i
, col_id
[i
], gtk_tree_view_column_get_title(column
)) );
754 gtk_tree_view_move_column_after(treeview
, column
, base
);
757 visible
= col_id
[i
] < 0 ? FALSE
: TRUE
;
759 /* display exception for detail/import list */
760 if(data
->list_type
!= LIST_TXN_TYPE_BOOK
)
762 if( id
== LST_DSPOPE_AMOUNT
)
765 if( id
== LST_DSPOPE_STATUS
|| id
== LST_DSPOPE_EXPENSE
|| id
== LST_DSPOPE_INCOME
)
769 gtk_tree_view_column_set_visible (column
, visible
);
770 if( id
== LST_DSPOPE_BALANCE
)
772 data
->tvc_is_visible
= visible
;
775 if( id
== LST_DSPOPE_INFO
776 || id
== LST_DSPOPE_PAYEE
777 || id
== LST_DSPOPE_MEMO
778 || id
== LST_DSPOPE_CATEGORY
779 || id
== LST_DSPOPE_TAGS
780 || id
== LST_DSPOPE_ACCOUNT
)
782 gtk_tree_view_column_set_fixed_width( column
, PREFS
->lst_ope_col_size
[id
- 1]);
792 static void list_txn_sort_column_changed(GtkTreeSortable
*sortable
, gpointer user_data
)
794 struct list_txn_data
*data
= user_data
;
797 gboolean showBalance
;
799 gtk_tree_sortable_get_sort_column_id(sortable
, &id
, &order
);
801 DB( g_print("list_txn_columns_changed %d %d\n", id
, order
) );
803 //here save the transaction list columnid and sort order
804 PREFS
->lst_ope_sort_id
= id
;
805 PREFS
->lst_ope_sort_order
= order
;
807 //manage visibility of balance column
808 //showBalance = (id == LST_DSPOPE_DATE && order == GTK_SORT_ASCENDING) ? data->tvc_is_visible : FALSE;
809 showBalance
= (id
== LST_DSPOPE_DATE
) ? data
->tvc_is_visible
: FALSE
;
810 gtk_tree_view_column_set_visible (data
->tvc_balance
, showBalance
);
815 list_txn_column_popup_menuitem_on_activate (GtkCheckMenuItem
*checkmenuitem
,
818 GtkTreeViewColumn
*column
= user_data
;
820 DB( g_print("toggled\n") );
822 gtk_tree_view_column_set_visible(column
, gtk_check_menu_item_get_active(checkmenuitem
) );
826 static gboolean
list_txn_column_popup_callback ( GtkWidget
*button
,
830 struct list_txn_data
*data
= user_data
;
831 GtkWidget
*menu
, *menuitem
;
832 GtkTreeViewColumn
*column
;
836 if( ev
->button
== 3 )
838 DB( g_print("should popup\n") );
840 menu
= gtk_menu_new ();
842 //note: deactive this disable any menuitem action
843 g_signal_connect (menu
, "selection-done", G_CALLBACK (gtk_widget_destroy
), NULL
);
845 for(i
=0 ; i
< NUM_LST_DSPOPE
-1 ; i
++ ) // -1 'caus: account and blank column
847 column
= gtk_tree_view_get_column(GTK_TREE_VIEW(data
->treeview
), i
);
850 col_id
= gtk_tree_view_column_get_sort_column_id (column
);
853 || (col_id
== LST_DSPOPE_STATUS
)
854 || (col_id
== LST_DSPOPE_ACCOUNT
)
855 || (col_id
== LST_DSPOPE_DATE
)
856 || (col_id
== LST_DSPOPE_BALANCE
)
859 //if( (data->tvc_is_visible == FALSE) && (col_id == LST_DSPOPE_BALANCE) )
862 if( (data
->list_type
== LIST_TXN_TYPE_DETAIL
) &&
863 ( (col_id
== LST_DSPOPE_AMOUNT
)
864 || (col_id
== LST_DSPOPE_EXPENSE
)
865 || (col_id
== LST_DSPOPE_INCOME
)
870 menuitem
= gtk_check_menu_item_new_with_label ( gtk_tree_view_column_get_title (column
) );
871 gtk_menu_shell_append (GTK_MENU_SHELL (menu
), menuitem
);
872 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem
), gtk_tree_view_column_get_visible (column
) );
873 gtk_widget_show (menuitem
);
875 g_signal_connect (menuitem
, "activate",
876 G_CALLBACK (list_txn_column_popup_menuitem_on_activate
), column
);
881 gtk_menu_attach_to_widget (GTK_MENU (menu
), button
, NULL
);
882 gtk_menu_popup (GTK_MENU (menu
), NULL
, NULL
, NULL
, NULL
,
883 ev
->button
, ev
->time
);
890 static GtkTreeViewColumn
*
891 list_txn_column_amount_create(gint list_type
, gchar
*title
, gint sortcolumnid
, GtkTreeCellDataFunc func
)
893 GtkTreeViewColumn
*column
;
894 GtkCellRenderer
*renderer
;
896 renderer
= gtk_cell_renderer_text_new ();
897 g_object_set(renderer
, "xalign", 1.0, NULL
);
899 column
= gtk_tree_view_column_new_with_attributes(title
, renderer
, NULL
);
901 gtk_tree_view_column_set_alignment (column
, 0.5);
902 //gtk_tree_view_column_set_resizable(column, TRUE);
903 gtk_tree_view_column_set_sort_column_id (column
, sortcolumnid
);
904 if(list_type
== LIST_TXN_TYPE_BOOK
)
906 gtk_tree_view_column_set_reorderable(column
, TRUE
);
908 gtk_tree_view_column_set_cell_data_func(column
, renderer
, func
, GINT_TO_POINTER(sortcolumnid
), NULL
);
914 static GtkTreeViewColumn
*
915 list_txn_column_text_create(gint list_type
, gchar
*title
, gint sortcolumnid
, GtkTreeCellDataFunc func
, gpointer user_data
)
917 GtkTreeViewColumn
*column
;
918 GtkCellRenderer
*renderer
;
920 renderer
= gtk_cell_renderer_text_new ();
921 g_object_set(renderer
,
922 "ellipsize", PANGO_ELLIPSIZE_END
,
923 "ellipsize-set", TRUE
,
926 column
= gtk_tree_view_column_new_with_attributes(title
, renderer
, NULL
);
928 gtk_tree_view_column_set_alignment (column
, 0.5);
929 gtk_tree_view_column_set_resizable(column
, TRUE
);
931 gtk_tree_view_column_set_sort_column_id (column
, sortcolumnid
);
932 if(list_type
== LIST_TXN_TYPE_BOOK
)
934 gtk_tree_view_column_set_reorderable(column
, TRUE
);
935 gtk_tree_view_column_set_min_width (column
, HB_MINWIDTH_COLUMN
);
936 gtk_tree_view_column_set_sizing (column
, GTK_TREE_VIEW_COLUMN_FIXED
);
938 gtk_tree_view_column_set_cell_data_func(column
, renderer
, func
, user_data
, NULL
);
944 static GtkTreeViewColumn
*
945 list_txn_column_info_create(gint list_type
)
947 GtkTreeViewColumn
*column
;
948 GtkCellRenderer
*renderer
;
950 column
= gtk_tree_view_column_new();
951 gtk_tree_view_column_set_title(column
, _("Info"));
953 renderer
= gtk_cell_renderer_pixbuf_new ();
954 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
955 gtk_tree_view_column_set_cell_data_func(column
, renderer
, list_txn_info_cell_data_function
, GINT_TO_POINTER(1), NULL
);
957 renderer
= gtk_cell_renderer_text_new ();
958 /*g_object_set(renderer,
959 "ellipsize", PANGO_ELLIPSIZE_END,
960 "ellipsize-set", TRUE,
962 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
963 gtk_tree_view_column_set_cell_data_func(column
, renderer
, list_txn_info_cell_data_function
, GINT_TO_POINTER(2), NULL
);
965 gtk_tree_view_column_set_alignment (column
, 0.5);
966 gtk_tree_view_column_set_resizable(column
, TRUE
);
967 gtk_tree_view_column_set_sort_column_id (column
, LST_DSPOPE_INFO
);
968 if(list_type
== LIST_TXN_TYPE_BOOK
)
970 gtk_tree_view_column_set_reorderable(column
, TRUE
);
971 gtk_tree_view_column_set_min_width (column
, HB_MINWIDTH_COLUMN
);
972 gtk_tree_view_column_set_sizing (column
, GTK_TREE_VIEW_COLUMN_FIXED
);
979 static void list_txn_destroy( GtkWidget
*widget
, gpointer user_data
)
981 struct list_txn_data
*data
;
983 data
= g_object_get_data(G_OBJECT(widget
), "inst_data");
985 DB( g_print ("\n[list_transaction] destroy event occurred\n") );
987 if( data
->save_column_width
)
989 list_txn_get_columns(GTK_TREE_VIEW(data
->treeview
));
992 DB( g_print(" - view=%p, inst_data=%p\n", widget
, data
) );
997 Transaction
*list_txn_get_active_transaction(GtkTreeView
*treeview
)
1005 model
= gtk_tree_view_get_model(treeview
);
1006 list
= gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(treeview
), &model
);
1012 gtk_tree_model_get_iter(model
, &iter
, list
->data
);
1013 gtk_tree_model_get(model
, &iter
, LST_DSPOPE_DATAS
, &ope
, -1);
1016 g_list_foreach(list
, (GFunc
)gtk_tree_path_free
, NULL
);
1024 ** create our transaction list
1025 ** Status, Date, Info, Payee, Memo, (Amount), Expense, Income, Category
1027 GtkWidget
*create_list_transaction(gint list_type
, gboolean
*pref_columns
)
1029 struct list_txn_data
*data
;
1030 GtkListStore
*store
;
1031 GtkWidget
*treeview
;
1032 GtkCellRenderer
*renderer
;
1033 GtkTreeViewColumn
*column
, *col_acc
= NULL
, *col_status
= NULL
;
1036 data
= g_malloc0(sizeof(struct list_txn_data
));
1037 if(!data
) return NULL
;
1039 data
->list_type
= list_type
;
1040 data
->save_column_width
= FALSE
;
1042 /* create list store */
1043 store
= gtk_list_store_new(
1044 1, G_TYPE_POINTER
/*only really used column */
1048 treeview
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
1049 data
->treeview
= treeview
;
1050 g_object_unref(store
);
1052 //store our window private data
1053 g_object_set_data(G_OBJECT(treeview
), "inst_data", (gpointer
)data
);
1054 DB( g_print(" - treeview=%p, inst_data=%p\n", treeview
, data
) );
1056 // connect our dispose function
1057 g_signal_connect (treeview
, "destroy", G_CALLBACK (list_txn_destroy
), (gpointer
)data
);
1059 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (treeview
), PREFS
->grid_lines
);
1060 //gtk_tree_view_set_search_column (GTK_TREE_VIEW (treeview),
1061 // COLUMN_DESCRIPTION);
1063 if(list_type
== LIST_TXN_TYPE_BOOK
)
1064 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview
)), GTK_SELECTION_MULTIPLE
);
1066 /* column 1: Changes */
1067 column
= gtk_tree_view_column_new();
1068 //gtk_tree_view_column_set_title(column, _("Status"));
1069 col_status
= column
;
1071 renderer
= gtk_cell_renderer_pixbuf_new ();
1072 //gtk_cell_renderer_set_fixed_size(renderer, GLOBALS->lst_pixbuf_maxwidth, -1);
1073 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
1074 gtk_tree_view_column_set_cell_data_func(column
, renderer
, list_txn_status_cell_data_function
, GINT_TO_POINTER(1), NULL
);
1076 renderer
= gtk_cell_renderer_pixbuf_new ();
1077 //gtk_cell_renderer_set_fixed_size(renderer, GLOBALS->lst_pixbuf_maxwidth, -1);
1078 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
1079 gtk_tree_view_column_set_cell_data_func(column
, renderer
, list_txn_status_cell_data_function
, GINT_TO_POINTER(2), NULL
);
1081 renderer
= gtk_cell_renderer_pixbuf_new ();
1082 //gtk_cell_renderer_set_fixed_size(renderer, GLOBALS->lst_pixbuf_maxwidth, -1);
1083 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
1084 gtk_tree_view_column_set_cell_data_func(column
, renderer
, list_txn_status_cell_data_function
, GINT_TO_POINTER(3), NULL
);
1086 gtk_tree_view_column_set_sort_column_id (column
, LST_DSPOPE_STATUS
);
1087 //gtk_tree_view_column_set_resizable(column, TRUE);
1088 gtk_tree_view_column_set_alignment (column
, 0.5);
1089 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1091 if(list_type
== LIST_TXN_TYPE_DETAIL
)
1093 column
= list_txn_column_text_create(list_type
, _("Account"), LST_DSPOPE_ACCOUNT
, list_txn_account_cell_data_function
, NULL
);
1094 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1097 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1098 "button-press-event",
1099 G_CALLBACK ( list_txn_column_popup_callback
),
1103 /* column 2: Date */
1104 column
= gtk_tree_view_column_new();
1105 gtk_tree_view_column_set_title(column
, _("Date"));
1106 renderer
= gtk_cell_renderer_text_new ();
1107 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
1108 g_object_set(renderer
, "xalign", 1.0, NULL
);
1109 gtk_tree_view_column_set_cell_data_func(column
, renderer
, list_txn_date_cell_data_function
, NULL
, NULL
);
1110 gtk_tree_view_column_set_sort_column_id (column
, LST_DSPOPE_DATE
);
1111 //gtk_tree_view_column_set_resizable(column, TRUE);
1112 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1114 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1115 "button-press-event",
1116 G_CALLBACK ( list_txn_column_popup_callback
),
1120 column
= list_txn_column_info_create(list_type
);
1121 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1123 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1124 "button-press-event",
1125 G_CALLBACK ( list_txn_column_popup_callback
),
1128 column
= list_txn_column_text_create(list_type
, _("Payee"), LST_DSPOPE_PAYEE
, list_txn_payee_cell_data_function
, NULL
);
1129 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1131 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1132 "button-press-event",
1133 G_CALLBACK ( list_txn_column_popup_callback
),
1136 column
= list_txn_column_text_create(list_type
, _("Memo"), LST_DSPOPE_MEMO
, list_txn_memo_cell_data_function
, NULL
);
1137 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1139 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1140 "button-press-event",
1141 G_CALLBACK ( list_txn_column_popup_callback
),
1144 /* column status CLR */
1145 column
= gtk_tree_view_column_new();
1146 gtk_tree_view_column_set_title(column
, _("Status"));
1147 //renderer = gtk_cell_renderer_text_new ();
1148 renderer
= gtk_cell_renderer_pixbuf_new();
1149 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
1150 g_object_set(renderer
, "xalign", 1.0, NULL
);
1151 gtk_tree_view_column_set_cell_data_func(column
, renderer
, list_txn_clr_cell_data_function
, NULL
, NULL
);
1152 gtk_tree_view_column_set_reorderable(column
, TRUE
);
1153 gtk_tree_view_column_set_sort_column_id (column
, LST_DSPOPE_CLR
);
1154 //gtk_tree_view_column_set_sort_indicator (column, FALSE);
1155 //gtk_tree_view_column_set_resizable(column, TRUE);
1156 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1158 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1159 "button-press-event",
1160 G_CALLBACK ( list_txn_column_popup_callback
),
1164 column
= list_txn_column_amount_create(list_type
, _("Amount"), LST_DSPOPE_AMOUNT
, list_txn_amount_cell_data_function
);
1165 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1167 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1168 "button-press-event",
1169 G_CALLBACK ( list_txn_column_popup_callback
),
1172 column
= list_txn_column_amount_create(list_type
, _("Expense"), LST_DSPOPE_EXPENSE
, list_txn_amount_cell_data_function
);
1173 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1175 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1176 "button-press-event",
1177 G_CALLBACK ( list_txn_column_popup_callback
),
1180 column
= list_txn_column_amount_create(list_type
, _("Income"), LST_DSPOPE_INCOME
, list_txn_amount_cell_data_function
);
1181 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1183 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1184 "button-press-event",
1185 G_CALLBACK ( list_txn_column_popup_callback
),
1188 column
= list_txn_column_text_create(list_type
, _("Category"), LST_DSPOPE_CATEGORY
, list_txn_category_cell_data_function
, NULL
);
1189 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1191 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1192 "button-press-event",
1193 G_CALLBACK ( list_txn_column_popup_callback
),
1196 column
= list_txn_column_text_create(list_type
, _("Tags"), LST_DSPOPE_TAGS
, list_txn_tags_cell_data_function
, NULL
);
1197 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1199 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1200 "button-press-event",
1201 G_CALLBACK ( list_txn_column_popup_callback
),
1204 if(list_type
== LIST_TXN_TYPE_BOOK
)
1206 column
= list_txn_column_amount_create(list_type
, _("Balance"), LST_DSPOPE_BALANCE
, list_txn_amount_cell_data_function
);
1207 data
->tvc_balance
= column
;
1208 gtk_tree_view_column_set_clickable(column
, FALSE
);
1209 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1211 g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column
)),
1212 "button-press-event",
1213 G_CALLBACK ( list_txn_column_popup_callback
),
1217 /* column 9: empty */
1218 column
= gtk_tree_view_column_new();
1219 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1222 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_STATUS
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_STATUS
), NULL
);
1223 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_DATE
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_DATE
), NULL
);
1224 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_INFO
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_INFO
), NULL
);
1225 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_PAYEE
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_PAYEE
), NULL
);
1226 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_MEMO
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_MEMO
), NULL
);
1227 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_AMOUNT
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_AMOUNT
), NULL
);
1228 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_EXPENSE
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_EXPENSE
), NULL
);
1229 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_INCOME
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_INCOME
), NULL
);
1230 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_CATEGORY
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_CATEGORY
), NULL
);
1231 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_TAGS
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_TAGS
), NULL
);
1232 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_CLR
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_CLR
), NULL
);
1233 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DSPOPE_ACCOUNT
, list_txn_sort_iter_compare_func
, GINT_TO_POINTER(LST_DSPOPE_ACCOUNT
), NULL
);
1235 /* apply user preference for columns */
1236 list_txn_set_columns(GTK_TREE_VIEW(treeview
), pref_columns
);
1238 /* force account column for detail treeview */
1239 if(list_type
== LIST_TXN_TYPE_DETAIL
)
1241 gtk_tree_view_move_column_after(GTK_TREE_VIEW(treeview
), col_acc
, col_status
);
1244 /* set initial sort order */
1245 DB( g_print("set sort to %d %d\n", PREFS
->lst_ope_sort_id
, PREFS
->lst_ope_sort_order
) );
1246 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store
), PREFS
->lst_ope_sort_id
, PREFS
->lst_ope_sort_order
);
1250 if(list_type
== LIST_TXN_TYPE_BOOK
)
1251 g_signal_connect (GTK_TREE_SORTABLE(store
), "sort-column-changed", G_CALLBACK (list_txn_sort_column_changed
), data
);
1257 /* ---------------------------------------------- */
1258 /* import list : soon obsolete */
1259 /* ---------------------------------------------- */
1262 ** account cell function
1264 static void ope_importaccount_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
1267 Account
*acc
, *dacc
;
1269 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
1271 acc
= da_acc_get(ope
->kacc
);
1274 if(acc
->imp_key
> 0)
1276 dacc
= da_acc_get(acc
->imp_key
);
1278 g_object_set(renderer
, "text", dacc
->name
, NULL
);
1281 g_object_set(renderer
, "text", acc
->name
, NULL
);
1287 ** amount cell function
1289 static void ope_importamount_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
1292 gchar formatd_buf
[G_ASCII_DTOSTR_BUF_SIZE
];
1295 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
1297 //mystrfnum(buf, G_ASCII_DTOSTR_BUF_SIZE-1, ope->amount, GLOBALS->minor);
1298 //hb_strfmon(buf, G_ASCII_DTOSTR_BUF_SIZE-1, ope->amount, GLOBALS->minor);
1299 g_ascii_formatd(formatd_buf
, G_ASCII_DTOSTR_BUF_SIZE
-1, "%.2f", ope
->amount
);
1301 color
= get_normal_color_amount(ope
->amount
);
1303 g_object_set(renderer
,
1304 "foreground", color
,
1305 "text", formatd_buf
,
1311 static void ope_importstatus_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
1314 gchar
*iconname
= NULL
;
1316 // get the transaction
1317 gtk_tree_model_get(model
, iter
, LST_DSPOPE_DATAS
, &ope
, -1);
1319 iconname
= ( ope
->same
!= NULL
) ? ICONNAME_WARNING
: NULL
;
1321 g_object_set(renderer
, "icon-name", iconname
, NULL
);
1326 ope_importfixed_toggled (GtkCellRendererToggle
*cell
,
1330 GtkTreeModel
*model
= (GtkTreeModel
*)data
;
1332 GtkTreePath
*path
= gtk_tree_path_new_from_string (path_str
);
1335 /* get toggled iter */
1336 gtk_tree_model_get_iter (model
, &iter
, path
);
1337 gtk_tree_model_get (model
, &iter
, LST_OPE_IMPTOGGLE
, &fixed
, -1);
1339 /* do something with the value */
1343 gtk_list_store_set (GTK_LIST_STORE (model
), &iter
, LST_OPE_IMPTOGGLE
, fixed
, -1);
1346 gtk_tree_path_free (path
);
1350 ** create our transaction list
1352 GtkWidget
*create_list_import_transaction(gboolean enable_choose
)
1354 GtkListStore
*store
;
1355 GtkWidget
*treeview
;
1356 GtkCellRenderer
*renderer
;
1357 GtkTreeViewColumn
*column
;
1359 /* create list store */
1360 store
= gtk_list_store_new(
1375 treeview
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
1376 g_object_unref(store
);
1378 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (treeview
), PREFS
->grid_lines
);
1379 //gtk_tree_view_set_search_column (GTK_TREE_VIEW (treeview),
1380 // COLUMN_DESCRIPTION);
1382 //gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), GTK_SELECTION_MULTIPLE);
1384 /* column: Selection */
1387 renderer
= gtk_cell_renderer_toggle_new ();
1389 g_signal_connect (renderer
, "toggled", G_CALLBACK (ope_importfixed_toggled
), store
);
1392 column
= gtk_tree_view_column_new_with_attributes (NULL
,
1394 "active", LST_OPE_IMPTOGGLE
,
1397 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1399 /* column: Duplicate */
1400 column
= gtk_tree_view_column_new();
1401 //gtk_tree_view_column_set_title(column, _("Import ?"));
1402 renderer
= gtk_cell_renderer_pixbuf_new ();
1403 //gtk_cell_renderer_set_fixed_size(renderer, GLOBALS->lst_pixbuf_maxwidth, -1);
1404 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
1405 gtk_tree_view_column_set_cell_data_func(column
, renderer
, ope_importstatus_cell_data_function
, NULL
, NULL
);
1406 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1410 /* column: Account */
1411 column
= gtk_tree_view_column_new();
1412 gtk_tree_view_column_set_title(column
, _("Account"));
1413 renderer
= gtk_cell_renderer_text_new ();
1414 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
1415 gtk_tree_view_column_set_cell_data_func(column
, renderer
, ope_importaccount_cell_data_function
, NULL
, NULL
);
1416 //gtk_tree_view_column_set_sort_column_id (column, LST_DSPOPE_DATE);
1417 gtk_tree_view_column_set_resizable(column
, TRUE
);
1418 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1422 column
= gtk_tree_view_column_new();
1423 gtk_tree_view_column_set_title(column
, _("Date"));
1424 renderer
= gtk_cell_renderer_text_new ();
1425 g_object_set(renderer
, "xalign", 1.0, NULL
);
1426 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
1427 gtk_tree_view_column_set_cell_data_func(column
, renderer
, list_txn_date_cell_data_function
, NULL
, NULL
);
1428 //gtk_tree_view_column_set_sort_column_id (column, LST_DSPOPE_DATE);
1429 gtk_tree_view_column_set_resizable(column
, TRUE
);
1430 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1432 column
= list_txn_column_text_create(LIST_TXN_TYPE_IMPORT
, _("Memo"), -1, list_txn_memo_cell_data_function
, NULL
);
1433 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1435 column
= list_txn_column_amount_create(LIST_TXN_TYPE_IMPORT
, _("Amount"), -1, ope_importamount_cell_data_function
);
1436 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1438 column
= list_txn_column_info_create(LIST_TXN_TYPE_IMPORT
);
1439 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1441 column
= list_txn_column_text_create(LIST_TXN_TYPE_IMPORT
, _("Payee"), -1, list_txn_payee_cell_data_function
, NULL
);
1442 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1444 column
= list_txn_column_text_create(LIST_TXN_TYPE_IMPORT
, _("Category"), -1, list_txn_category_cell_data_function
, NULL
);
1445 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);
1447 column
= gtk_tree_view_column_new();
1448 gtk_tree_view_append_column (GTK_TREE_VIEW(treeview
), column
);