503
503
/* = = = = = = = = = = = = = = = = */
504
gboolean list_txn_column_id_isvisible(GtkTreeView *treeview, gint sort_id)
506
GtkTreeViewColumn *column;
509
for(n=0; n < NUM_LST_DSPOPE-1 ; n++ ) // -1 cause account not to be processed
511
column = gtk_tree_view_get_column (treeview, n);
515
if( gtk_tree_view_column_get_visible(column) )
517
id = gtk_tree_view_column_get_sort_column_id (column);
506
527
static GtkTreeViewColumn *list_txn_get_column(GList *list, gint search_id)
750
list_txn_column_popup_menuitem_on_activate (GtkCheckMenuItem *checkmenuitem,
753
GtkTreeViewColumn *column = user_data;
755
DB( g_print("toggled\n") );
757
gtk_tree_view_column_set_visible(column, gtk_check_menu_item_get_active(checkmenuitem) );
761
static gboolean list_txn_column_popup_callback ( GtkWidget *button,
765
struct list_txn_data *data = user_data;
766
GtkWidget *menu, *menuitem;
768
GtkTreeViewColumn *column;
772
if( ev->button == 3 )
774
DB( g_print("should popup\n") );
776
menu = gtk_menu_new ();
778
//note: deactive this disable any menuitem action
779
g_signal_connect (menu, "selection-done", G_CALLBACK (gtk_widget_destroy), NULL);
781
for(i=0 ; i < NUM_LST_DSPOPE-1 ; i++ ) // -1 'caus: account and blank column
783
column = gtk_tree_view_get_column(GTK_TREE_VIEW(data->treeview), i);
786
col_id = gtk_tree_view_column_get_sort_column_id (column);
789
|| (col_id == LST_DSPOPE_STATUS)
790
|| (col_id == LST_DSPOPE_ACCOUNT)
791
|| (col_id == LST_DSPOPE_DATE)
792
|| (col_id == LST_DSPOPE_BALANCE)
795
//if( (data->tvc_is_visible == FALSE) && (col_id == LST_DSPOPE_BALANCE) )
798
if( (data->list_type == LIST_TXN_TYPE_DETAIL) &&
799
( (col_id == LST_DSPOPE_AMOUNT)
800
|| (col_id == LST_DSPOPE_EXPENSE)
801
|| (col_id == LST_DSPOPE_INCOME)
806
menuitem = gtk_check_menu_item_new_with_label ( gtk_tree_view_column_get_title (column) );
807
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
808
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), gtk_tree_view_column_get_visible (column) );
809
gtk_widget_show (menuitem);
811
g_signal_connect (menuitem, "activate",
812
G_CALLBACK (list_txn_column_popup_menuitem_on_activate), column);
817
gtk_menu_attach_to_widget (GTK_MENU (menu), button, NULL);
818
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
819
ev->button, ev->time);
729
827
static GtkTreeViewColumn *
730
828
list_txn_column_amount_create(gint list_type, gchar *title, gint sortcolumnid, GtkTreeCellDataFunc func)
934
Transaction *list_txn_get_active_transaction(GtkTreeView *treeview)
942
model = gtk_tree_view_get_model(treeview);
943
list = gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(treeview), &model);
949
gtk_tree_model_get_iter(model, &iter, list->data);
950
gtk_tree_model_get(model, &iter, LST_DSPOPE_DATAS, &ope, -1);
953
g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
836
961
** create our transaction list
837
962
** Status, Date, Info, Payee, Wording, (Amount), Expense, Income, Category
913
1039
column = list_txn_column_text_create(list_type, _("Account"), LST_DSPOPE_ACCOUNT, list_txn_account_cell_data_function, NULL);
914
1040
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
915
1041
col_acc = column;
1043
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1044
"button-press-event",
1045
G_CALLBACK ( list_txn_column_popup_callback ),
918
1049
/* column 2: Date */
925
1056
gtk_tree_view_column_set_sort_column_id (column, LST_DSPOPE_DATE);
926
1057
//gtk_tree_view_column_set_resizable(column, TRUE);
927
1058
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1060
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1061
"button-press-event",
1062
G_CALLBACK ( list_txn_column_popup_callback ),
930
1066
column = list_txn_column_info_create(list_type);
931
1067
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1069
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1070
"button-press-event",
1071
G_CALLBACK ( list_txn_column_popup_callback ),
933
1074
column = list_txn_column_text_create(list_type, _("Payee"), LST_DSPOPE_PAYEE, list_txn_payee_cell_data_function, NULL);
934
1075
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1077
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1078
"button-press-event",
1079
G_CALLBACK ( list_txn_column_popup_callback ),
936
1082
column = list_txn_column_text_create(list_type, _("Memo"), LST_DSPOPE_WORDING, list_txn_wording_cell_data_function, NULL);
937
1083
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1085
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1086
"button-press-event",
1087
G_CALLBACK ( list_txn_column_popup_callback ),
939
1090
/* column status CLR */
940
1091
column = gtk_tree_view_column_new();
949
1100
//gtk_tree_view_column_set_sort_indicator (column, FALSE);
950
1101
//gtk_tree_view_column_set_resizable(column, TRUE);
951
1102
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1104
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1105
"button-press-event",
1106
G_CALLBACK ( list_txn_column_popup_callback ),
954
1110
column = list_txn_column_amount_create(list_type, _("Amount"), LST_DSPOPE_AMOUNT, list_txn_amount_cell_data_function);
955
1111
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1113
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1114
"button-press-event",
1115
G_CALLBACK ( list_txn_column_popup_callback ),
957
1118
column = list_txn_column_amount_create(list_type, _("Expense"), LST_DSPOPE_EXPENSE, list_txn_amount_cell_data_function);
958
1119
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1121
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1122
"button-press-event",
1123
G_CALLBACK ( list_txn_column_popup_callback ),
960
1126
column = list_txn_column_amount_create(list_type, _("Income"), LST_DSPOPE_INCOME, list_txn_amount_cell_data_function);
961
1127
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1129
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1130
"button-press-event",
1131
G_CALLBACK ( list_txn_column_popup_callback ),
963
1134
column = list_txn_column_text_create(list_type, _("Category"), LST_DSPOPE_CATEGORY, list_txn_category_cell_data_function, NULL);
964
1135
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1137
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1138
"button-press-event",
1139
G_CALLBACK ( list_txn_column_popup_callback ),
966
1142
column = list_txn_column_text_create(list_type, _("Tags"), LST_DSPOPE_TAGS, list_txn_tags_cell_data_function, NULL);
967
1143
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1145
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1146
"button-press-event",
1147
G_CALLBACK ( list_txn_column_popup_callback ),
969
1150
if(list_type == LIST_TXN_TYPE_BOOK)
972
1153
data->tvc_balance = column;
973
1154
gtk_tree_view_column_set_clickable(column, FALSE);
974
1155
gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);
1157
g_signal_connect ( G_OBJECT (gtk_tree_view_column_get_button (column)),
1158
"button-press-event",
1159
G_CALLBACK ( list_txn_column_popup_callback ),
977
1163
/* column 9: empty */
994
1180
/* apply user preference for columns */
995
1181
list_txn_set_columns(GTK_TREE_VIEW(treeview), pref_columns);
997
/* force accoutn column for detail treeview */
1183
/* force account column for detail treeview */
998
1184
if(list_type == LIST_TXN_TYPE_DETAIL)
1000
gtk_tree_view_move_column_after(GTK_TREE_VIEW(treeview), col_acc, NULL);
1186
gtk_tree_view_move_column_after(GTK_TREE_VIEW(treeview), col_acc, col_status);
1003
1189
/* set initial sort order */