1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2017 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 "ui-archive.h"
24 #include "ui-account.h"
25 #include "ui-category.h"
29 #include "gtk-dateentry.h"
31 /****************************************************************************/
33 /****************************************************************************/
42 /* our global datas */
43 extern struct HomeBank
*GLOBALS
;
44 extern struct Preferences
*PREFS
;
47 gchar
*CYA_ARCHIVE_TYPE
[] = {
54 gchar
*CYA_UNIT
[] = { N_("Day"), N_("Week"), N_("Month"), N_("Year"), NULL
};
56 gchar
*CYA_SCHED_WEEKEND
[] = { N_("Possible"), N_("Before"), N_("After"), NULL
};
58 extern gchar
*CYA_TXN_STATUS
[];
60 static GtkWidget
*ui_arc_listview_new(void);
65 static void ui_arc_listview_populate(GtkWidget
*view
, gint type
)
72 DB( g_print("ui_arc_listview_populate()\n") );
74 DB( g_print(" - type=%d\n", type
) );
77 //insert all glist item into treeview
78 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(view
));
81 gtk_list_store_clear (GTK_LIST_STORE(model
));
84 list
= g_list_first(GLOBALS
->arc_list
);
87 Archive
*item
= list
->data
;
89 if( (type
== ARC_TYPE_SCHEDULED
) && !(item
->flags
& OF_AUTO
) )
92 if( (type
== ARC_TYPE_TEMPLATE
) && (item
->flags
& OF_AUTO
) )
95 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
96 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
97 LST_DEFARC_DATAS
, item
, //data struct
98 LST_DEFARC_OLDPOS
, i
, //oldpos
101 //DB( g_print(" populate_treeview: %d %08x\n", i, list->data) );
103 i
++; list
= g_list_next(list
);
109 static void ui_arc_listview_select_by_pointer(GtkTreeView
*treeview
, gpointer user_data
)
113 GtkTreeSelection
*selection
;
115 Archive
*arc
= user_data
;
117 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(treeview
));
118 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview
));
120 valid
= gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model
), &iter
);
125 gtk_tree_model_get (model
, &iter
, LST_DEFARC_DATAS
, &tmp_arc
, -1);
128 gtk_tree_selection_select_iter (selection
, &iter
);
132 valid
= gtk_tree_model_iter_next(GTK_TREE_MODEL(model
), &iter
);
139 ** The function should return:
140 ** a negative integer if the first value comes before the second,
141 ** 0 if they are equal,
142 ** or a positive integer if the first value comes after the second.
144 static gint
ui_arc_listview_compare_func (GtkTreeModel
*model
, GtkTreeIter
*a
, GtkTreeIter
*b
, gpointer userdata
)
146 gint sortcol
= GPOINTER_TO_INT(userdata
);
147 Archive
*entry1
, *entry2
;
150 gtk_tree_model_get(model
, a
, LST_DEFARC_DATAS
, &entry1
, -1);
151 gtk_tree_model_get(model
, b
, LST_DEFARC_DATAS
, &entry2
, -1);
155 case LST_DEFARC_SORT_MEMO
:
156 retval
= (entry1
->flags
& GF_INCOME
) - (entry2
->flags
& GF_INCOME
);
159 retval
= hb_string_utf8_compare(entry1
->wording
, entry2
->wording
);
162 case LST_DEFARC_SORT_PAYEE
:
166 p1
= da_pay_get(entry1
->kpay
);
167 p2
= da_pay_get(entry2
->kpay
);
168 if( p1
!= NULL
&& p2
!= NULL
)
170 retval
= hb_string_utf8_compare(p1
->name
, p2
->name
);
175 g_return_val_if_reached(0);
184 static void ui_arc_listview_auto_cell_data_function (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
187 gchar
*iconname
= NULL
;
189 // get the transaction
190 gtk_tree_model_get(model
, iter
, LST_DEFARC_DATAS
, &item
, -1);
192 iconname
= ( item
->flags
& OF_AUTO
) ? ICONNAME_HB_OPE_AUTO
: NULL
;
194 g_object_set(renderer
, "icon-name", iconname
, NULL
);
199 ** draw some text from the stored data structure
201 static void ui_arc_listview_cell_data_function_memo (GtkTreeViewColumn
*col
,
202 GtkCellRenderer
*renderer
,
210 gtk_tree_model_get(model
, iter
, LST_DEFARC_DATAS
, &item
, -1);
212 name
= item
->wording
;
214 g_object_set(renderer
, "text", name
, NULL
);
219 static void ui_arc_listview_cell_data_function_payee (GtkTreeViewColumn
*col
, GtkCellRenderer
*renderer
, GtkTreeModel
*model
, GtkTreeIter
*iter
, gpointer user_data
)
224 gtk_tree_model_get(model
, iter
,
225 LST_DEFARC_DATAS
, &arc
,
231 pay
= da_pay_get(arc
->kpay
);
234 g_object_set(renderer
, "text", pay
->name
, NULL
);
237 g_object_set(renderer
, "text", NULL
, NULL
);
244 static GtkWidget
*ui_arc_listview_new(void)
248 GtkCellRenderer
*renderer
;
249 GtkTreeViewColumn
*column
;
252 store
= gtk_list_store_new (
260 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(store
));
261 g_object_unref(store
);
263 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view
), PREFS
->grid_lines
);
266 renderer
= gtk_cell_renderer_text_new ();
267 g_object_set(renderer
,
268 "ellipsize", PANGO_ELLIPSIZE_END
,
269 "ellipsize-set", TRUE
,
272 column
= gtk_tree_view_column_new();
273 gtk_tree_view_column_set_title(column
, _("Memo"));
274 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
275 gtk_tree_view_column_set_cell_data_func(column
, renderer
, ui_arc_listview_cell_data_function_memo
, GINT_TO_POINTER(LST_DEFARC_SORT_MEMO
), NULL
);
276 gtk_tree_view_column_set_sort_column_id (column
, LST_DEFARC_SORT_MEMO
);
277 gtk_tree_view_column_set_alignment (column
, 0.5);
278 gtk_tree_view_column_set_min_width(column
, HB_MINWIDTH_LIST
);
279 gtk_tree_view_column_set_resizable(column
, TRUE
);
280 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
283 renderer
= gtk_cell_renderer_text_new ();
284 g_object_set(renderer
,
285 "ellipsize", PANGO_ELLIPSIZE_END
,
286 "ellipsize-set", TRUE
,
288 column
= gtk_tree_view_column_new();
289 gtk_tree_view_column_set_title(column
, _("Payee"));
290 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
291 gtk_tree_view_column_set_cell_data_func(column
, renderer
, ui_arc_listview_cell_data_function_payee
, GINT_TO_POINTER(LST_DEFARC_SORT_PAYEE
), NULL
);
292 gtk_tree_view_column_set_resizable(column
, TRUE
);
293 //gtk_tree_view_column_add_attribute(column, renderer, "text", 1);
294 gtk_tree_view_column_set_sort_column_id (column
, LST_DEFARC_SORT_PAYEE
);
295 gtk_tree_view_column_set_alignment (column
, 0.5);
296 gtk_tree_view_column_set_min_width(column
, HB_MINWIDTH_LIST
);
297 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
300 /* column: Scheduled icon */
301 column
= gtk_tree_view_column_new();
302 renderer
= gtk_cell_renderer_pixbuf_new ();
303 //gtk_cell_renderer_set_fixed_size(renderer, GLOBALS->lst_pixbuf_maxwidth, -1);
304 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
305 gtk_tree_view_column_set_cell_data_func(column
, renderer
, ui_arc_listview_auto_cell_data_function
, NULL
, NULL
);
306 gtk_tree_view_append_column (GTK_TREE_VIEW(view
), column
);
310 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DEFARC_SORT_MEMO
, ui_arc_listview_compare_func
, GINT_TO_POINTER(LST_DEFARC_SORT_MEMO
), NULL
);
311 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store
), LST_DEFARC_SORT_PAYEE
, ui_arc_listview_compare_func
, GINT_TO_POINTER(LST_DEFARC_SORT_PAYEE
), NULL
);
314 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store
), LST_DEFARC_SORT_MEMO
, GTK_SORT_ASCENDING
);
316 //gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
317 //gtk_tree_view_set_reorderable (GTK_TREE_VIEW(view), TRUE);
323 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
328 ** add an empty new account to our temp GList and treeview
330 static void ui_arc_manage_add(GtkWidget
*widget
, gpointer user_data
)
332 struct ui_arc_manage_data
*data
;
338 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
339 DB( g_print("\n[ui_scheduled] add\n") );
341 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(data
->LV_arc
));
343 item
= da_archive_malloc();
344 item
->wording
= g_strdup_printf(_("(template %d)"), g_list_length(GLOBALS
->arc_list
) + 1);
347 type
= radio_get_active(GTK_CONTAINER(data
->RA_type
)) == 1 ? ARC_TYPE_TEMPLATE
: ARC_TYPE_SCHEDULED
;
348 if( type
== ARC_TYPE_SCHEDULED
)
349 item
->flags
|= OF_AUTO
;
351 GLOBALS
->arc_list
= g_list_append(GLOBALS
->arc_list
, item
);
353 gtk_list_store_append (GTK_LIST_STORE(model
), &iter
);
354 gtk_list_store_set (GTK_LIST_STORE(model
), &iter
,
355 LST_DEFARC_DATAS
, item
,
356 LST_DEFARC_OLDPOS
, 0,
359 gtk_tree_selection_select_iter (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
->LV_arc
)), &iter
);
365 ** delete the selected account to our treeview and temp GList
367 static void ui_arc_manage_delete(GtkWidget
*widget
, gpointer user_data
)
369 struct ui_arc_manage_data
*data
;
370 GtkTreeSelection
*selection
;
376 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
377 DB( g_print("\n[ui_scheduled] delete (data=%p)\n", data
) );
379 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(data
->LV_arc
));
380 //if true there is a selected node
381 if (gtk_tree_selection_get_selected(selection
, &model
, &iter
))
386 gtk_tree_model_get(model
, &iter
, LST_DEFARC_DATAS
, &item
, -1);
388 title
= g_strdup_printf (
389 _("Are you sure you want to permanently delete '%s'?"), item
->wording
);
391 secondtext
= _("If you delete a scheduled/template, it will be permanently lost.");
393 result
= ui_dialog_msg_confirm_alert(
394 GTK_WINDOW(data
->window
),
402 if( result
== GTK_RESPONSE_OK
)
404 gtk_list_store_remove(GTK_LIST_STORE(model
), &iter
);
406 GLOBALS
->arc_list
= g_list_remove(GLOBALS
->arc_list
, item
);
411 //DB( g_print(" delete =%08x (pos=%d)\n", entry, g_list_index(data->tmp_list, entry) ) );
417 ** update the archive name everytime it changes
419 static void ui_arc_manage_rename(GtkWidget
*widget
, gpointer user_data
)
421 struct ui_arc_manage_data
*data
;
422 GtkTreeSelection
*selection
;
428 DB( g_print("\n[ui_scheduled] rename\n") );
430 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
432 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(data
->LV_arc
));
433 //if true there is a selected node
434 if (gtk_tree_selection_get_selected(selection
, &model
, &iter
))
436 gtk_tree_model_get(model
, &iter
, LST_DEFARC_DATAS
, &item
, -1);
438 DB( g_print(" -> %s\n", item
->wording
) );
440 txt
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_word
));
441 // ignore if entry is empty
444 g_free(item
->wording
);
445 item
->wording
= g_strdup(txt
);
448 gtk_tree_view_columns_autosize (GTK_TREE_VIEW(data
->LV_arc
));
458 ** set widgets contents from the selected account
460 static void ui_arc_manage_set(GtkWidget
*widget
, gpointer user_data
)
462 struct ui_arc_manage_data
*data
;
463 GtkTreeSelection
*selection
;
469 DB( g_print("\n[ui_scheduled] set\n") );
471 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
473 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(data
->LV_arc
));
474 //if true there is a selected node
475 if (gtk_tree_selection_get_selected(selection
, &model
, &iter
))
477 gtk_tree_model_get(model
, &iter
, LST_DEFARC_DATAS
, &item
, -1);
479 g_signal_handler_block(data
->ST_word
, data
->handler_id
[HID_ARC_MEMO
]);
480 gtk_entry_set_text(GTK_ENTRY(data
->ST_word
), item
->wording
);
481 g_signal_handler_unblock(data
->ST_word
, data
->handler_id
[HID_ARC_MEMO
]);
483 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_amount
), item
->amount
);
487 radio_set_active(GTK_CONTAINER(data
->RA_status
), item
->status
);
490 /*g_signal_handler_block(data->CM_valid, data->handler_id[HID_ARC_VALID]);
491 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_valid), (item->flags & OF_VALID) ? 1 : 0);
492 g_signal_handler_unblock(data->CM_valid, data->handler_id[HID_ARC_VALID]);
494 g_signal_handler_block(data->CM_remind, data->handler_id[HID_ARC_REMIND]);
495 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_remind), (item->flags & OF_REMIND) ? 1 : 0);
496 g_signal_handler_unblock(data->CM_remind, data->handler_id[HID_ARC_REMIND]);
499 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->NU_mode
), item
->paymode
);
501 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_cheque
), (item
->flags
& OF_CHEQ2
) ? 1 : 0);
503 ui_cat_comboboxentry_set_active(GTK_COMBO_BOX(data
->PO_grp
), item
->kcat
);
505 DB( g_print(" -> set payee %d\n", item
->kpay
) );
506 ui_pay_comboboxentry_set_active(GTK_COMBO_BOX(data
->PO_pay
), item
->kpay
);
508 DB( g_print(" -> PO_acc %d\n", item
->kacc
) );
509 ui_acc_comboboxentry_set_active(GTK_COMBO_BOX(data
->PO_acc
), item
->kacc
);
511 DB( g_print(" -> PO_accto %d\n", item
->kxferacc
) );
512 ui_acc_comboboxentry_set_active(GTK_COMBO_BOX(data
->PO_accto
), item
->kxferacc
);
514 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_auto
), (item
->flags
& OF_AUTO
) ? 1 : 0);
516 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_every
), item
->every
);
518 gtk_combo_box_set_active(GTK_COMBO_BOX(data
->CY_unit
), item
->unit
);
520 gtk_date_entry_set_date(GTK_DATE_ENTRY(data
->PO_next
), item
->nextdate
);
522 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
->CM_limit
), (item
->flags
& OF_LIMIT
) ? 1 : 0);
525 DB( g_print("nb_limit = %d %g\n", item
->limit
, (gdouble
)item
->limit
) );
527 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->NB_limit
), (gdouble
)item
->limit
);
529 radio_set_active(GTK_CONTAINER(data
->CY_weekend
), item
->weekend
);
536 ** get widgets contents to the selected account
538 static void ui_arc_manage_getlast(struct ui_arc_manage_data
*data
)
546 DB( g_print("\n[ui_scheduled] getlast\n") );
548 item
= data
->lastarcitem
;
552 DB( g_print(" -> %s\n", item
->wording
) );
554 gtk_tree_view_columns_autosize (GTK_TREE_VIEW(data
->LV_arc
));
556 txt
= (gchar
*)gtk_entry_get_text(GTK_ENTRY(data
->ST_word
));
557 // ignore if entry is empty
560 g_free(item
->wording
);
561 item
->wording
= g_strdup(txt
);
564 gtk_spin_button_update(GTK_SPIN_BUTTON(data
->ST_amount
));
565 value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_amount
));
566 item
->amount
= value
;
568 item
->paymode
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->NU_mode
));
569 item
->kcat
= ui_cat_comboboxentry_get_key_add_new(GTK_COMBO_BOX(data
->PO_grp
));
570 item
->kpay
= ui_pay_comboboxentry_get_key_add_new(GTK_COMBO_BOX(data
->PO_pay
));
571 item
->kacc
= ui_acc_comboboxentry_get_key(GTK_COMBO_BOX(data
->PO_acc
));
572 item
->kxferacc
= ui_acc_comboboxentry_get_key(GTK_COMBO_BOX(data
->PO_accto
));
574 item
->status
= radio_get_active(GTK_CONTAINER(data
->RA_status
));
576 //#1615245: moved here, after get combo entry key
577 if( item
->paymode
!= PAYMODE_INTXFER
)
579 //#677351: revert kxferacc to 0
585 item
->flags
&= (OF_SPLIT
); //(split is set in hb_archive)
587 active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_cheque
));
588 if(active
== 1) item
->flags
|= OF_CHEQ2
;
590 //active = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_amount));
591 active
= item
->amount
> 0 ? TRUE
: FALSE
;
592 if(active
== TRUE
) item
->flags
|= OF_INCOME
;
595 /* -- automated -- */
597 active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_auto
));
598 if(active
== 1) item
->flags
|= OF_AUTO
;
600 gtk_spin_button_update(GTK_SPIN_BUTTON(data
->NB_every
));
601 item
->every
= gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data
->NB_every
));
602 item
->unit
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->CY_unit
));
603 item
->nextdate
= gtk_date_entry_get_date(GTK_DATE_ENTRY(data
->PO_next
));
605 active
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_limit
));
606 if(active
== 1) item
->flags
|= OF_LIMIT
;
608 gtk_spin_button_update(GTK_SPIN_BUTTON(data
->NB_limit
));
609 item
->limit
= gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data
->NB_limit
));
611 item
->weekend
= radio_get_active(GTK_CONTAINER(data
->CY_weekend
));
618 static void ui_arc_manage_update_accto(GtkWidget
*widget
, gpointer user_data
)
620 struct ui_arc_manage_data
*data
;
623 DB( g_print("\n\n[ui_scheduled] update accto\n") );
625 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
627 kacc
= ui_acc_comboboxentry_get_key(GTK_COMBO_BOX(data
->PO_acc
));
628 kdst
= ui_acc_comboboxentry_get_key(GTK_COMBO_BOX(data
->PO_accto
));
630 DB( g_print(" ksrc=%d, kdst=%d\n", kacc
, kdst
) );
632 ui_acc_comboboxentry_populate_except(GTK_COMBO_BOX(data
->PO_accto
), GLOBALS
->h_acc
, kacc
, ACC_LST_INSERT_NORMAL
);
634 if( (kacc
== 0) || (kacc
== kdst
) )
636 ui_acc_comboboxentry_set_active(GTK_COMBO_BOX(data
->PO_accto
), 0);
645 static void ui_arc_manage_paymode(GtkWidget
*widget
, gpointer user_data
)
647 struct ui_arc_manage_data
*data
;
652 DB( g_print("\n[ui_scheduled] paymode\n") );
654 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
656 //DB( g_print(" widget=%p, data=%p\n", widget, data) );
659 payment
= gtk_combo_box_get_active(GTK_COMBO_BOX(data
->NU_mode
));
662 if(payment
== PAYMODE_CHECK
)
665 sensitive
= page
== 1 ? TRUE
: FALSE
;
666 hb_widget_visible(data
->CM_cheque
, sensitive
);
668 if(payment
== PAYMODE_INTXFER
)
671 ui_arc_manage_update_accto(widget
, user_data
);
674 DB( g_print(" payment: %d, page: %d\n", payment
, page
) );
676 sensitive
= page
== 2 ? TRUE
: FALSE
;
677 hb_widget_visible(data
->LB_accto
, sensitive
);
678 hb_widget_visible(data
->PO_accto
, sensitive
);
680 DB( g_print(" visible: %d\n", sensitive
) );
687 static void ui_arc_manage_scheduled(GtkWidget
*widget
, gpointer user_data
)
689 struct ui_arc_manage_data
*data
;
694 gboolean selected
, sensitive
;
696 DB( g_print("\n[ui_scheduled] scheduled\n") );
698 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
703 selected
= gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(data
->LV_arc
)), &model
, &iter
);
706 gtk_tree_model_get(model
, &iter
, LST_DEFARC_DATAS
, &arcitem
, -1);
708 arcitem
->flags
&= ~(OF_AUTO
);
709 sensitive
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_auto
)) ? TRUE
: FALSE
;
711 arcitem
->flags
|= OF_AUTO
;
716 gtk_widget_set_sensitive(data
->LB_next
, sensitive
);
717 gtk_widget_set_sensitive(data
->PO_next
, sensitive
);
719 gtk_widget_set_sensitive(data
->LB_every
, sensitive
);
720 gtk_widget_set_sensitive(data
->NB_every
, sensitive
);
722 gtk_widget_set_sensitive(data
->LB_weekend
, sensitive
);
723 gtk_widget_set_sensitive(data
->CY_weekend
, sensitive
);
725 gtk_widget_set_sensitive(data
->CY_unit
, sensitive
);
726 gtk_widget_set_sensitive(data
->CM_limit
, sensitive
);
728 gtk_widget_set_sensitive(data
->LB_posts
, sensitive
);
731 sensitive
= (sensitive
== TRUE
) ? gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->CM_limit
)) : sensitive
;
732 gtk_widget_set_sensitive(data
->NB_limit
, sensitive
);
736 /* redraw the row to display/hide the icon */
737 path
= gtk_tree_model_get_path(model
, &iter
);
738 gtk_tree_model_row_changed(model
, path
, &iter
);
739 gtk_tree_path_free (path
);
741 // gtk_tree_view_columns_autosize (GTK_TREE_VIEW(data->LV_arc));
742 //gtk_widget_queue_draw (GTK_WIDGET(data->LV_arc));
747 static void ui_arc_manage_update_post_split(GtkWidget
*widget
, gdouble amount
)
749 struct ui_arc_manage_data
*data
;
750 gboolean sensitive
= TRUE
;
752 DB( g_print("(ui_arc_manage) update _post_split\n") );
754 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
756 DB( g_print("- amount=%.2f\n", amount
) );
758 data
->lastarcitem
->amount
= amount
;
759 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_amount
), amount
);
761 data
->lastarcitem
->flags
&= ~(OF_SPLIT
); //First set flag that Splits are cleared
763 if (da_splits_count(data
->lastarcitem
->splits
) > 0)
765 /* disable category if split is set */
766 data
->lastarcitem
->flags
|= OF_SPLIT
; //Then set flag that Splits are active
768 ui_cat_comboboxentry_set_active(GTK_COMBO_BOX(data
->PO_grp
), 0);
770 gtk_widget_set_sensitive(data
->ST_amount
, sensitive
);
772 //# 1416624 empty category when split
773 if( (data
->lastarcitem
->flags
& (OF_SPLIT
)) )
774 ui_cat_comboboxentry_set_active(GTK_COMBO_BOX(data
->PO_grp
), 0);
775 gtk_widget_set_sensitive(data
->PO_grp
, sensitive
);
779 ** update the widgets status and contents from action/selection value
781 static void ui_arc_manage_update(GtkWidget
*widget
, gpointer user_data
)
783 struct ui_arc_manage_data
*data
;
786 gboolean selected
, sensitive
;
787 gboolean split_sensitive
= TRUE
;
791 DB( g_print("\n[ui_scheduled] update\n") );
793 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
794 //window = gtk_widget_get_ancestor(GTK_WIDGET(treeview), GTK_TYPE_WINDOW);
795 //DB( g_print("\n[ui_scheduled] widget=%08lx, window=%08lx, inst_data=%08lx\n", treeview, window, data) );
797 //if true there is a selected node
798 selected
= gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(data
->LV_arc
)), &model
, &iter
);
800 DB( g_print(" selected = %d\n", selected
) );
802 sensitive
= (selected
== TRUE
) ? TRUE
: FALSE
;
804 gtk_widget_set_sensitive(data
->GR_txnleft
, sensitive
);
806 gtk_widget_set_sensitive(data
->CM_auto
, sensitive
);
808 gtk_widget_set_sensitive(data
->BT_rem
, sensitive
);
812 gtk_tree_model_get(model
, &iter
, LST_DEFARC_DATAS
, &arcitem
, -1);
814 if(data
->lastarcitem
!= NULL
&& arcitem
!= data
->lastarcitem
)
816 DB( g_print(" -> should do a get for last selected (%s)\n", data
->lastarcitem
->wording
) );
817 ui_arc_manage_getlast(data
);
819 data
->lastarcitem
= arcitem
;
821 if (da_splits_count(data
->lastarcitem
->splits
) > 0)
824 data
->lastarcitem
->flags
|= OF_SPLIT
; //Then set flag that Splits are active
825 split_sensitive
= FALSE
;
826 ui_cat_comboboxentry_set_active(GTK_COMBO_BOX(data
->PO_grp
), 0);
829 gtk_widget_set_sensitive(data
->ST_amount
, split_sensitive
);
830 gtk_widget_set_sensitive(data
->PO_grp
, split_sensitive
);
832 DB( g_print(" - call set\n") );
833 ui_arc_manage_set(widget
, NULL
);
837 data
->lastarcitem
= NULL
;
840 //gtk_widget_set_sensitive(data->LB_schedinsert, sensitive);
843 DB( g_print(" - call scheduled\n") );
844 ui_arc_manage_scheduled(widget
, NULL
);
845 DB( g_print(" - call paymode\n") );
846 ui_arc_manage_paymode(widget
,NULL
);
856 static void ui_arc_manage_toggleamount(GtkWidget
*widget
, GtkEntryIconPosition icon_pos
, GdkEvent
*event
, gpointer user_data
)
858 struct ui_arc_manage_data
*data
;
861 DB( g_print("\n[ui_scheduled] toggleamount\n") );
863 if(icon_pos
== GTK_ENTRY_ICON_PRIMARY
)
866 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
868 gtk_spin_button_update(GTK_SPIN_BUTTON(data
->ST_amount
));
870 value
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_amount
));
872 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data
->ST_amount
), value
);
875 value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->ST_amount));
876 type = gtk_widget_get_sensitive(data->CY_amount);
878 gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->ST_amount), value * type);
885 static void defarchive_button_split_cb(GtkWidget
*widget
, gpointer user_data
)
887 struct ui_arc_manage_data
*data
;
890 DB( g_print("\n[ui_scheduled] doing split\n") );
892 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget
, GTK_TYPE_WINDOW
)), "inst_data");
894 amount
= gtk_spin_button_get_value(GTK_SPIN_BUTTON(data
->ST_amount
));
896 ui_split_dialog(data
->window
, data
->lastarcitem
->splits
, amount
, &ui_arc_manage_update_post_split
);
901 static void ui_arc_manage_selection(GtkTreeSelection
*treeselection
, gpointer user_data
)
903 DB( g_print("\n[ui_scheduled] selection\n") );
905 DB( g_print(" - call update\n") );
906 ui_arc_manage_update(GTK_WIDGET(gtk_tree_selection_get_tree_view (treeselection
)), NULL
);
910 static void ui_arc_manage_populate_listview(struct ui_arc_manage_data
*data
)
914 DB( g_print("\n[ui_scheduled] populate listview\n") );
916 type
= radio_get_active(GTK_CONTAINER(data
->RA_type
)) == 1 ? ARC_TYPE_TEMPLATE
: ARC_TYPE_SCHEDULED
;
917 ui_arc_listview_populate(data
->LV_arc
, type
);
918 gtk_tree_view_expand_all (GTK_TREE_VIEW(data
->LV_arc
));
924 static gboolean
ui_arc_manage_cleanup(struct ui_arc_manage_data
*data
, gint result
)
926 gboolean doupdate
= FALSE
;
928 DB( g_print("\n[ui_scheduled] cleanup\n") );
931 if(data
->lastarcitem
!= NULL
)
933 DB( g_print(" -> should do a get for last selected (%s)\n", data
->lastarcitem
->wording
) );
934 ui_arc_manage_getlast(data
);
937 GLOBALS
->arc_list
= da_archive_sort(GLOBALS
->arc_list
);
939 GLOBALS
->changes_count
+= data
->change
;
947 static void ui_arc_manage_setup(struct ui_arc_manage_data
*data
)
950 DB( g_print("\n[ui_scheduled] setup\n") );
953 data
->tmp_list
= NULL
; //hb-glist_clone_list(GLOBALS->arc_list, sizeof(struct _Archive));
955 data
->lastarcitem
= NULL
;
957 //hb-glist_populate_treeview(data->tmp_list, data->LV_arc, LST_DEFARC_DATAS, LST_DEFARC_OLDPOS);
959 //insert all glist item into treeview
960 ui_arc_manage_populate_listview(data
);
962 DB( g_print(" - populate boxentries\n") );
964 ui_pay_comboboxentry_populate(GTK_COMBO_BOX(data
->PO_pay
) , GLOBALS
->h_pay
);
965 ui_cat_comboboxentry_populate(GTK_COMBO_BOX(data
->PO_grp
) , GLOBALS
->h_cat
);
966 ui_acc_comboboxentry_populate(GTK_COMBO_BOX(data
->PO_acc
) , GLOBALS
->h_acc
, ACC_LST_INSERT_NORMAL
);
967 ui_acc_comboboxentry_populate(GTK_COMBO_BOX(data
->PO_accto
), GLOBALS
->h_acc
, ACC_LST_INSERT_NORMAL
);
971 static GtkWidget
*ui_arc_manage_create_left_txn(struct ui_arc_manage_data
*data
)
973 GtkWidget
*group_grid
, *hbox
, *label
, *widget
, *image
;
976 // group :: Transaction detail
977 group_grid
= gtk_grid_new ();
978 data
->GR_txnleft
= group_grid
;
979 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
980 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
983 label
= make_label_widget(_("_Amount:"));
984 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 1, 1);
985 hbox
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, 0);
986 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 1, row
, 1, 1);
988 widget
= make_amount(label
);
989 data
->ST_amount
= widget
;
990 gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widget
), GTK_ENTRY_ICON_PRIMARY
, ICONNAME_HB_TOGGLE_SIGN
);
991 gtk_entry_set_icon_tooltip_text(GTK_ENTRY(widget
), GTK_ENTRY_ICON_PRIMARY
, _("Toggle amount sign"));
992 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
994 image
= gtk_image_new_from_icon_name (ICONNAME_HB_BUTTON_SPLIT
, GTK_ICON_SIZE_MENU
);
995 widget
= gtk_button_new();
996 g_object_set (widget
, "image", image
, NULL
);
997 data
->BT_split
= widget
;
998 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
999 gtk_widget_set_tooltip_text(widget
, _("Transaction splits"));
1002 label
= make_label_widget(_("Pay_ment:"));
1003 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 1, 1);
1004 widget
= make_paymode(label
);
1005 data
->NU_mode
= widget
;
1006 gtk_widget_set_halign (widget
, GTK_ALIGN_START
);
1007 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1010 widget
= gtk_check_button_new_with_mnemonic(_("Of notebook _2"));
1011 data
->CM_cheque
= widget
;
1012 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1014 /* info should be here some day */
1017 label
= make_label_widget(_("A_ccount:"));
1018 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 1, 1);
1019 widget
= ui_acc_comboboxentry_new(label
);
1020 data
->PO_acc
= widget
;
1021 gtk_widget_set_hexpand (widget
, TRUE
);
1022 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1025 label
= make_label_widget(_("_To account:"));
1026 data
->LB_accto
= label
;
1027 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 1, 1);
1028 widget
= ui_acc_comboboxentry_new(label
);
1029 data
->PO_accto
= widget
;
1030 gtk_widget_set_hexpand (widget
, TRUE
);
1031 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1034 label
= make_label_widget(_("_Payee:"));
1035 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 1, 1);
1036 widget
= ui_pay_comboboxentry_new(label
);
1037 data
->PO_pay
= widget
;
1038 gtk_widget_set_hexpand (widget
, TRUE
);
1039 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1042 label
= make_label_widget(_("_Category:"));
1043 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 1, 1);
1044 widget
= ui_cat_comboboxentry_new(label
);
1045 data
->PO_grp
= widget
;
1046 gtk_widget_set_hexpand (widget
, TRUE
);
1047 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1050 label
= make_label_widget(_("_Status:"));
1051 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 1, 1);
1052 widget
= make_radio(CYA_TXN_STATUS
, TRUE
, GTK_ORIENTATION_HORIZONTAL
);
1053 data
->RA_status
= widget
;
1054 gtk_widget_set_halign (widget
, GTK_ALIGN_START
);
1055 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1058 label
= make_label_widget(_("_Memo:"));
1059 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 1, 1);
1060 widget
= make_string(label
);
1061 gtk_widget_set_hexpand (widget
, TRUE
);
1062 data
->ST_word
= widget
;
1063 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
1065 /* tags should be here some day */
1072 static GtkWidget
*ui_arc_manage_create_scheduling(struct ui_arc_manage_data
*data
)
1074 GtkWidget
*group_grid
, *hbox
, *label
, *widget
;
1077 // group :: Scheduled insertion
1078 group_grid
= gtk_grid_new ();
1079 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
1080 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
1082 label
= make_label_group(_("Scheduled insertion"));
1083 data
->LB_schedinsert
= label
;
1084 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
1087 widget
= gtk_check_button_new_with_mnemonic(_("_Activate"));
1088 data
->CM_auto
= widget
;
1089 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 2, 1);
1092 label
= gtk_label_new_with_mnemonic (_("Next _date:"));
1093 data
->LB_next
= label
;
1094 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1095 widget
= gtk_date_entry_new();
1096 data
->PO_next
= widget
;
1097 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1100 label
= make_label_widget(_("Ever_y:"));
1101 data
->LB_every
= label
;
1102 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1104 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1105 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 2, row
, 1, 1);
1106 widget
= make_numeric(label
, 1, 100);
1107 data
->NB_every
= widget
;
1108 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1109 //label = gtk_label_new_with_mnemonic (_("_Unit:"));
1110 //gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1111 widget
= make_cycle(label
, CYA_UNIT
);
1112 data
->CY_unit
= widget
;
1113 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1116 label
= make_label_widget(_("Week end:"));
1117 data
->LB_weekend
= label
;
1118 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
1120 widget
= make_radio(CYA_SCHED_WEEKEND
, FALSE
, GTK_ORIENTATION_HORIZONTAL
);
1121 data
->CY_weekend
= widget
;
1122 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
1125 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, SPACING_SMALL
);
1126 gtk_grid_attach (GTK_GRID (group_grid
), hbox
, 1, row
, 3, 1);
1128 widget
= gtk_check_button_new_with_mnemonic(_("_Stop after:"));
1129 data
->CM_limit
= widget
;
1130 gtk_box_pack_start (GTK_BOX (hbox
), widget
, FALSE
, FALSE
, 0);
1132 widget
= make_numeric(label
, 1, 366);
1133 data
->NB_limit
= widget
;
1134 gtk_box_pack_start (GTK_BOX (hbox
), widget
, TRUE
, TRUE
, 0);
1136 label
= gtk_label_new_with_mnemonic (_("posts"));
1137 data
->LB_posts
= label
;
1138 gtk_box_pack_start (GTK_BOX (hbox
), label
, FALSE
, FALSE
, 0);
1143 static void ui_arc_manage_type_changed_cb (GtkToggleButton
*button
, gpointer user_data
)
1145 ui_arc_manage_populate_listview(user_data
);
1146 //g_print(" toggle type=%d\n", gtk_toggle_button_get_active(button));
1150 GtkWidget
*ui_arc_manage_dialog (Archive
*ext_arc
)
1152 struct ui_arc_manage_data data
;
1153 GtkWidget
*dialog
, *content_area
, *table
, *bbox
;
1154 GtkWidget
*content_grid
, *group_grid
, *hgrid
, *treeview
, *scrollwin
;
1155 GtkWidget
*widget
, *hpaned
;
1158 dialog
= gtk_dialog_new_with_buttons (_("Manage scheduled/template transactions"),
1159 GTK_WINDOW(GLOBALS
->mainwindow
),
1162 GTK_RESPONSE_ACCEPT
,
1165 data
.window
= dialog
;
1167 gtk_window_set_icon_name(GTK_WINDOW (dialog
), ICONNAME_HB_ARCHIVE
);
1169 //set a nice dialog size
1170 gtk_window_get_size(GTK_WINDOW(GLOBALS
->mainwindow
), &w
, &h
);
1171 gtk_window_set_default_size (GTK_WINDOW(dialog
), -1, h
/PHI
);
1174 //store our dialog private data
1175 g_object_set_data(G_OBJECT(dialog
), "inst_data", (gpointer
)&data
);
1176 DB( g_print("\n[ui_scheduled] dialog=%p, inst_data=%p\n", dialog
, &data
) );
1179 content_area
= gtk_dialog_get_content_area(GTK_DIALOG (dialog
)); // return a vbox
1182 table
= gtk_grid_new ();
1183 gtk_grid_set_row_spacing (GTK_GRID (table
), SPACING_MEDIUM
);
1184 gtk_grid_set_column_spacing (GTK_GRID (table
), SPACING_MEDIUM
);
1185 g_object_set(table
, "margin", SPACING_MEDIUM
, NULL
);
1186 gtk_box_pack_start (GTK_BOX (content_area
), table
, TRUE
, TRUE
, 0);
1189 bbox
= make_radio(CYA_ARCHIVE_TYPE
, TRUE
, GTK_ORIENTATION_HORIZONTAL
);
1190 data
.RA_type
= bbox
;
1191 gtk_widget_set_halign (bbox
, GTK_ALIGN_CENTER
);
1192 gtk_grid_attach (GTK_GRID (table
), bbox
, 0, row
, 2, 1);
1194 widget
= radio_get_nth_widget(GTK_CONTAINER(bbox
), 1);
1196 g_signal_connect (widget
, "toggled", G_CALLBACK (ui_arc_manage_type_changed_cb
), &data
);
1199 hpaned
= gtk_paned_new(GTK_ORIENTATION_HORIZONTAL
);
1200 //gtk_container_set_border_width (GTK_CONTAINER(hpaned), SPACING_MEDIUM);
1201 gtk_grid_attach (GTK_GRID (table
), hpaned
, 0, row
, 2, 1);
1205 hgrid
= gtk_grid_new ();
1206 gtk_grid_set_row_spacing (GTK_GRID (hgrid
), SPACING_SMALL
);
1207 gtk_grid_set_column_spacing (GTK_GRID (hgrid
), SPACING_MEDIUM
);
1208 gtk_widget_set_margin_right(hgrid
, SPACING_SMALL
);
1209 gtk_paned_pack1 (GTK_PANED(hpaned
), hgrid
, FALSE
, FALSE
);
1212 scrollwin
= gtk_scrolled_window_new(NULL
,NULL
);
1213 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwin
), GTK_SHADOW_ETCHED_IN
);
1214 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
1215 treeview
= (GtkWidget
*)ui_arc_listview_new();
1216 data
.LV_arc
= treeview
;
1217 gtk_widget_set_size_request(treeview
, HB_MINWIDTH_LIST
, -1);
1218 gtk_container_add(GTK_CONTAINER(scrollwin
), treeview
);
1219 gtk_widget_set_hexpand (scrollwin
, TRUE
);
1220 gtk_widget_set_vexpand (scrollwin
, TRUE
);
1221 gtk_grid_attach (GTK_GRID (hgrid
), scrollwin
, 0, 0, 2, 1);
1223 widget
= gtk_button_new_with_mnemonic(_("_Add"));
1224 data
.BT_add
= widget
;
1225 gtk_grid_attach (GTK_GRID (hgrid
), widget
, 0, 1, 1, 1);
1227 widget
= gtk_button_new_with_mnemonic(_("_Delete"));
1228 data
.BT_rem
= widget
;
1229 gtk_grid_attach (GTK_GRID (hgrid
), widget
, 1, 1, 1, 1);
1233 content_grid
= gtk_grid_new();
1234 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
1235 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
1236 //gtk_container_set_border_width (GTK_CONTAINER(content_grid), SPACING_MEDIUM);
1237 gtk_widget_set_margin_left(content_grid
, SPACING_SMALL
);
1238 gtk_paned_pack2 (GTK_PANED(hpaned
), content_grid
, FALSE
, FALSE
);
1240 group_grid
= ui_arc_manage_create_left_txn(&data
);
1241 //gtk_widget_set_hexpand (GTK_WIDGET(group_grid), FALSE);
1242 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, 0, 1, 1);
1245 group_grid
= ui_arc_manage_create_scheduling(&data
);
1246 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, 1, 1, 1);
1248 /* set default periodicity to month */
1249 //todo: move elsewhere
1250 gtk_combo_box_set_active(GTK_COMBO_BOX(data
.CY_unit
), 2);
1252 gtk_widget_show_all(content_area
);
1253 gtk_widget_hide(data
.CM_cheque
);
1254 gtk_widget_hide(data
.PO_accto
);
1256 //connect all our signals
1257 g_signal_connect (dialog
, "destroy", G_CALLBACK (gtk_widget_destroyed
), &dialog
);
1259 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.LV_arc
)), "changed", G_CALLBACK (ui_arc_manage_selection
), NULL
);
1260 g_signal_connect (G_OBJECT (data
.ST_amount
), "icon-release", G_CALLBACK (ui_arc_manage_toggleamount
), NULL
);
1262 g_signal_connect (G_OBJECT (data
.BT_add
), "clicked", G_CALLBACK (ui_arc_manage_add
), NULL
);
1263 g_signal_connect (G_OBJECT (data
.BT_rem
), "clicked", G_CALLBACK (ui_arc_manage_delete
), NULL
);
1265 data
.handler_id
[HID_ARC_MEMO
] = g_signal_connect (G_OBJECT (data
.ST_word
), "changed", G_CALLBACK (ui_arc_manage_rename
), NULL
);
1266 g_signal_connect (data
.NU_mode
, "changed", G_CALLBACK (ui_arc_manage_paymode
), NULL
);
1267 g_signal_connect (data
.PO_acc
, "changed", G_CALLBACK (ui_arc_manage_update_accto
), NULL
);
1268 //data.handler_id[HID_ARC_VALID] = g_signal_connect (data.CM_valid , "toggled", G_CALLBACK (ui_arc_manage_togglestatus), GINT_TO_POINTER(HID_ARC_VALID));
1269 //data.handler_id[HID_ARC_REMIND] = g_signal_connect (data.CM_remind, "toggled", G_CALLBACK (ui_arc_manage_togglestatus), GINT_TO_POINTER(HID_ARC_REMIND));
1271 g_signal_connect (data
.CM_auto
, "toggled", G_CALLBACK (ui_arc_manage_scheduled
), NULL
);
1272 g_signal_connect (data
.CM_limit
, "toggled", G_CALLBACK (ui_arc_manage_scheduled
), NULL
);
1274 g_signal_connect (G_OBJECT (data
.BT_split
), "clicked", G_CALLBACK (defarchive_button_split_cb
), NULL
);
1276 //setup, init and show dialog
1277 ui_arc_manage_setup(&data
);
1278 ui_arc_manage_update(data
.LV_arc
, NULL
);
1280 gtk_widget_show (dialog
);
1283 ui_arc_listview_select_by_pointer(GTK_TREE_VIEW(data
.LV_arc
), ext_arc
);
1286 gint result
= gtk_dialog_run (GTK_DIALOG (dialog
));
1290 case GTK_RESPONSE_ACCEPT
:
1291 //do_application_specific_something ();
1294 //do_nothing_since_dialog_was_cancelled ();
1298 // cleanup and destroy
1299 ui_arc_manage_cleanup(&data
, result
);
1300 gtk_widget_destroy (dialog
);