X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fhomebank;a=blobdiff_plain;f=src%2Flist-operation.c;h=236900edd335576d9b6c0bdf1f949235db3bc7e8;hp=341fe9e48cfda47fa2806ace711f30a9a52aebcd;hb=461ad71822d907422deeabce0ffe5e506d0f5e3f;hpb=a6c6b0df5492c2160ed97e3a376bdb2fe7c5ebc4 diff --git a/src/list-operation.c b/src/list-operation.c index 341fe9e..236900e 100644 --- a/src/list-operation.c +++ b/src/list-operation.c @@ -62,8 +62,8 @@ static gint Transaction *ope1, *ope2; gdouble tmpval = 0; - gtk_tree_model_get(model, a, LST_DSPOPE_DATAS, &ope1, -1); - gtk_tree_model_get(model, b, LST_DSPOPE_DATAS, &ope2, -1); + gtk_tree_model_get(model, a, MODEL_TXN_POINTER, &ope1, -1); + gtk_tree_model_get(model, b, MODEL_TXN_POINTER, &ope2, -1); switch (sortcol) { @@ -238,7 +238,7 @@ static void list_txn_status_cell_data_function (GtkTreeViewColumn *col, GtkCellR Transaction *txn; gchar *iconname = NULL; - gtk_tree_model_get(model, iter, LST_DSPOPE_DATAS, &txn, -1); + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &txn, -1); /* stat[0] = ( entry->ope_Flags & OF_ADDED ) ? data->istatus[2] : data->istatus[0]; @@ -280,7 +280,7 @@ static void list_txn_account_cell_data_function (GtkTreeViewColumn *col, GtkCell Transaction *ope; Account *acc; - gtk_tree_model_get(model, iter, LST_DSPOPE_DATAS, &ope, -1); + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &ope, -1); acc = da_acc_get(ope->kacc); if( acc ) @@ -300,7 +300,7 @@ Transaction *ope; gchar buffer[256]; GDate date; - gtk_tree_model_get(model, iter, LST_DSPOPE_DATAS, &ope, -1); + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &ope, -1); list_txn_eval_future(renderer, ope); if(ope->date > 0) @@ -326,7 +326,7 @@ static void list_txn_info_cell_data_function (GtkTreeViewColumn *col, GtkCellRen { Transaction *ope; - gtk_tree_model_get(model, iter, LST_DSPOPE_DATAS, &ope, -1); + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &ope, -1); switch(GPOINTER_TO_INT(user_data)) { @@ -340,6 +340,23 @@ Transaction *ope; } } + +static void list_txn_payeexfer_cell_data_function (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) +{ +Transaction *ope; +gchar *direction = ""; + + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &ope, -1); + list_txn_eval_future(renderer, ope); + + if(ope->paymode == PAYMODE_INTXFER) + { + direction = ( ope->flags & OF_INCOME ) ? "<" : ">"; + } + g_object_set(renderer, "text", direction, NULL); +} + + /* ** payee cell function */ @@ -347,7 +364,7 @@ static void list_txn_payee_cell_data_function (GtkTreeViewColumn *col, GtkCellRe { Transaction *ope; - gtk_tree_model_get(model, iter, LST_DSPOPE_DATAS, &ope, -1); + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &ope, -1); list_txn_eval_future(renderer, ope); //#926782 @@ -374,7 +391,7 @@ static void list_txn_tags_cell_data_function (GtkTreeViewColumn *col, GtkCellRen Transaction *ope; gchar *str; - gtk_tree_model_get(model, iter, LST_DSPOPE_DATAS, &ope, -1); + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &ope, -1); list_txn_eval_future(renderer, ope); if(ope->tags != NULL) @@ -397,7 +414,7 @@ static void list_txn_memo_cell_data_function (GtkTreeViewColumn *col, GtkCellRen { Transaction *ope; - gtk_tree_model_get(model, iter, LST_DSPOPE_DATAS, &ope, -1); + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &ope, -1); list_txn_eval_future(renderer, ope); g_object_set(renderer, "text", ope->memo, NULL); @@ -413,7 +430,7 @@ Transaction *ope; gchar *iconname = NULL; //const gchar *c = ""; - gtk_tree_model_get(model, iter, LST_DSPOPE_DATAS, &ope, -1); + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &ope, -1); switch(ope->status) { /*case TXN_STATUS_CLEARED: c = "c"; break; @@ -436,15 +453,21 @@ gchar *iconname = NULL; */ static void list_txn_amount_cell_data_function (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) { +struct list_txn_data *data = NULL; +GtkWidget *widget; Transaction *ope; gint column = GPOINTER_TO_INT(user_data); gchar buf[G_ASCII_DTOSTR_BUF_SIZE]; gint type; -gdouble amount; +gdouble amount, samount; gchar *color; + widget = gtk_tree_view_column_get_tree_view(col); + if( widget ) + data = g_object_get_data(G_OBJECT(widget), "inst_data"); + // get the transaction - gtk_tree_model_get(model, iter, LST_DSPOPE_DATAS, &ope, -1); + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &ope, MODEL_TXN_SPLITAMT, &samount, -1); list_txn_eval_future(renderer, ope); if(column == LST_DSPOPE_BALANCE) @@ -452,6 +475,10 @@ gchar *color; else amount = ope->amount; + //for detail display the split part (if any) + if( data && (data->list_type == LIST_TXN_TYPE_DETAIL) ) + amount = samount; + if(column == LST_DSPOPE_INCOME || column == LST_DSPOPE_EXPENSE) { type = (ope->flags & OF_INCOME) ? LST_DSPOPE_INCOME : LST_DSPOPE_EXPENSE; @@ -490,7 +517,7 @@ static void list_txn_category_cell_data_function (GtkTreeViewColumn *col, GtkCel Transaction *ope; Category *cat; - gtk_tree_model_get(model, iter, LST_DSPOPE_DATAS, &ope, -1); + gtk_tree_model_get(model, iter, MODEL_TXN_POINTER, &ope, -1); list_txn_eval_future(renderer, ope); if(ope->flags & OF_SPLIT) @@ -516,6 +543,7 @@ Category *cat; GString *list_txn_to_string(GtkTreeView *treeview, gboolean clipboard) { +struct list_txn_data *data = NULL; GtkTreeModel *model; GtkTreeIter iter; gboolean valid; @@ -524,11 +552,14 @@ const gchar *format; Transaction *ope; gchar datebuf[16]; gchar *info, *payeename, *categoryname; +gdouble amount, samount; Payee *payee; Category *category; gchar *tags; char amountbuf[G_ASCII_DTOSTR_BUF_SIZE]; + data = g_object_get_data(G_OBJECT(treeview), "inst_data"); + node = g_string_new(NULL); //title line @@ -543,7 +574,8 @@ char amountbuf[G_ASCII_DTOSTR_BUF_SIZE]; while (valid) { gtk_tree_model_get (model, &iter, - LST_DSPOPE_DATAS, &ope, + MODEL_TXN_POINTER, &ope, + MODEL_TXN_SPLITAMT, &samount, -1); hb_sprint_date(datebuf, ope->date); @@ -556,13 +588,18 @@ char amountbuf[G_ASCII_DTOSTR_BUF_SIZE]; categoryname = (category->name == NULL) ? NULL : category->fullname; tags = tags_tostring(ope->tags); + amount = ope->amount; + //for detail display the split part (if any) + if( data && (data->list_type == LIST_TXN_TYPE_DETAIL) ) + amount = samount; + //#793719 //g_ascii_dtostr (amountbuf, sizeof (amountbuf), ope->amount); //#1750257 use locale numdigit //g_ascii_formatd (amountbuf, sizeof (amountbuf), "%.2f", ope->amount); - g_snprintf(amountbuf, sizeof (amountbuf), "%.2f", ope->amount); + g_snprintf(amountbuf, sizeof (amountbuf), "%.2f", amount); - DB( g_print("amount = %f '%s'\n", ope->amount, amountbuf) ); + DB( g_print("amount = %f '%s'\n", amount, amountbuf) ); 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"; g_string_append_printf(node, format, @@ -875,7 +912,8 @@ GtkTreeViewColumn *column = user_data; } -static gboolean list_txn_column_popup_callback ( GtkWidget *button, +static gboolean +list_txn_column_popup_callback ( GtkWidget *button, GdkEventButton *ev, gpointer user_data ) { @@ -969,14 +1007,27 @@ list_txn_column_text_create(gint list_type, gchar *title, gint sortcolumnid, Gtk GtkTreeViewColumn *column; GtkCellRenderer *renderer; + column = gtk_tree_view_column_new(); + gtk_tree_view_column_set_title(column, title); + + //5.3 add > < for internal xfer + if( sortcolumnid == LST_DSPOPE_PAYEE ) + { + renderer = gtk_cell_renderer_text_new (); + gtk_tree_view_column_pack_start(column, renderer, FALSE); + gtk_tree_view_column_set_cell_data_func(column, renderer, list_txn_payeexfer_cell_data_function, NULL, NULL); + } + renderer = gtk_cell_renderer_text_new (); g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, "ellipsize-set", TRUE, + //taken from nemo, not exactly a resize to content, but good compromise + "width-chars", 40, NULL); + gtk_tree_view_column_pack_start(column, renderer, FALSE); + gtk_tree_view_column_set_cell_data_func(column, renderer, func, NULL, NULL); - column = gtk_tree_view_column_new_with_attributes(title, renderer, NULL); - gtk_tree_view_column_set_alignment (column, 0.5); gtk_tree_view_column_set_resizable(column, TRUE); @@ -1007,10 +1058,12 @@ GtkCellRenderer *renderer; gtk_tree_view_column_set_cell_data_func(column, renderer, list_txn_info_cell_data_function, GINT_TO_POINTER(1), NULL); renderer = gtk_cell_renderer_text_new (); - /*g_object_set(renderer, + g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, "ellipsize-set", TRUE, - NULL);*/ + //taken from nemo, not exactly a resize to content, but good compromise + "width-chars", 40, + NULL); gtk_tree_view_column_pack_start(column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func(column, renderer, list_txn_info_cell_data_function, GINT_TO_POINTER(2), NULL); @@ -1062,7 +1115,7 @@ Transaction *ope; GtkTreeIter iter; gtk_tree_model_get_iter(model, &iter, list->data); - gtk_tree_model_get(model, &iter, LST_DSPOPE_DATAS, &ope, -1); + gtk_tree_model_get(model, &iter, MODEL_TXN_POINTER, &ope, -1); } g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); @@ -1093,7 +1146,8 @@ GtkTreeViewColumn *column, *col_acc = NULL, *col_status = NULL; /* create list store */ store = gtk_list_store_new( - 1, G_TYPE_POINTER /*only really used column */ + 2, G_TYPE_POINTER, // MODEL_TXN_POINTER + G_TYPE_DOUBLE // MODEL_TXN_SPLITAMT amount part of split for detail only ); //treeview