1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2016 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/>.
22 #include "ui-dialogs.h"
23 #include "list_operation.h"
25 #include "hb-currency.h"
26 #include "ui-currency.h"
29 /* = = = = = = = = = = */
30 /* = = = = = = = = = = = = = = = = = = = = */
31 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
32 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
34 /****************************************************************************/
36 /****************************************************************************/
45 /* our global datas */
46 extern struct HomeBank
*GLOBALS
;
47 extern struct Preferences
*PREFS
;
51 /* = = = = = = = = = = = = = = = = = = = = */
53 /* Confirmation Alert dialog */
55 gint
ui_dialog_msg_confirm_alert(GtkWindow
*parent
, gchar
*title
, gchar
*secondtext
, gchar
*actionverb
)
60 dialog
= gtk_message_dialog_new (GTK_WINDOW(parent
),
61 GTK_DIALOG_MODAL
| GTK_DIALOG_DESTROY_WITH_PARENT
,
68 gtk_dialog_add_buttons (GTK_DIALOG(dialog
),
69 _("_Cancel"), GTK_RESPONSE_CANCEL
,
70 actionverb
, GTK_RESPONSE_OK
,
76 g_object_set(GTK_MESSAGE_DIALOG (dialog
), "secondary-text", secondtext
, NULL
);
77 //gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), secondtext);
80 gtk_dialog_set_default_response(GTK_DIALOG (dialog
), GTK_RESPONSE_CANCEL
);
82 retval
= gtk_dialog_run (GTK_DIALOG (dialog
));
84 gtk_widget_destroy (dialog
);
97 gint
ui_dialog_msg_question(GtkWindow
*parent
, gchar
*title
, gchar
*message_format
, ...)
104 dialog
= gtk_message_dialog_new (GTK_WINDOW(parent
),
105 GTK_DIALOG_MODAL
| GTK_DIALOG_DESTROY_WITH_PARENT
,
106 GTK_MESSAGE_QUESTION
,
114 va_start (args
, message_format
);
115 msg
= g_strdup_vprintf (message_format
, args
);
118 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog
), "%s", msg
);
123 gtk_dialog_set_default_response(GTK_DIALOG (dialog
), GTK_RESPONSE_NO
);
125 retval
= gtk_dialog_run (GTK_DIALOG (dialog
));
127 gtk_widget_destroy (dialog
);
133 ** open a info/error dialog for user information purpose
135 void ui_dialog_msg_infoerror(GtkWindow
*parent
, GtkMessageType type
, gchar
*title
, gchar
*message_format
, ...)
142 dialog
= gtk_message_dialog_new (GTK_WINDOW(parent
),
143 GTK_DIALOG_DESTROY_WITH_PARENT
,
152 va_start (args
, message_format
);
153 msg
= g_strdup_vprintf (message_format
, args
);
156 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog
), "%s", msg
);
161 gtk_dialog_run (GTK_DIALOG (dialog
));
162 gtk_widget_destroy (dialog
);
166 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
169 void ui_dialog_file_statistics(void)
171 GtkWidget
*dialog
, *content_area
, *content_grid
, *group_grid
;
172 GtkWidget
*label
, *widget
;
174 gint crow
, row
, count
;
176 dialog
= gtk_dialog_new_with_buttons (_("File statistics"),
177 GTK_WINDOW (GLOBALS
->mainwindow
),
183 gtk_window_set_default_size (GTK_WINDOW(dialog
), HB_MINWIDTH_LIST
, -1);
185 content_area
= gtk_dialog_get_content_area(GTK_DIALOG (dialog
));
187 content_grid
= gtk_grid_new();
188 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
189 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
190 gtk_container_set_border_width (GTK_CONTAINER(content_grid
), SPACING_MEDIUM
);
191 gtk_box_pack_start (GTK_BOX (content_area
), content_grid
, TRUE
, TRUE
, 0);
194 // group :: file title
195 group_grid
= gtk_grid_new ();
196 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_SMALL
);
197 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
198 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
200 label
= make_label_group(NULL
);
201 tmpstr
= g_path_get_basename(GLOBALS
->xhb_filepath
);
202 gtk_label_set_text(GTK_LABEL(label
), tmpstr
);
204 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, 0, 3, 1);
207 label
= make_label_widget(_("Account"));
208 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
209 widget
= make_label(NULL
, 1.0, 0.5);
210 count
= da_acc_length ();
211 ui_label_set_integer(GTK_LABEL(widget
), count
);
212 gtk_widget_set_hexpand(widget
, TRUE
);
213 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
216 label
= make_label_widget(_("Transaction"));
217 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
218 widget
= make_label(NULL
, 1.0, 0.5);
219 count
= da_transaction_length();
220 ui_label_set_integer(GTK_LABEL(widget
), count
);
221 gtk_widget_set_hexpand(widget
, TRUE
);
222 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
225 label
= make_label_widget(_("Payee"));
226 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
227 widget
= make_label(NULL
, 1.0, 0.5);
228 count
= da_pay_length ();
229 ui_label_set_integer(GTK_LABEL(widget
), count
);
230 gtk_widget_set_hexpand(widget
, TRUE
);
231 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
234 label
= make_label_widget(_("Category"));
235 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
236 widget
= make_label(NULL
, 1.0, 0.5);
237 count
= da_cat_length ();
238 ui_label_set_integer(GTK_LABEL(widget
), count
);
239 gtk_widget_set_hexpand(widget
, TRUE
);
240 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
243 label
= make_label_widget(_("Assignment"));
244 gtk_grid_attach (GTK_GRID (group_grid
), label
, 1, row
, 1, 1);
245 widget
= make_label(NULL
, 1.0, 0.5);
246 count
= da_asg_length ();
247 ui_label_set_integer(GTK_LABEL(widget
), count
);
248 gtk_widget_set_hexpand(widget
, TRUE
);
249 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
251 gtk_widget_show_all(content_grid
);
254 gint result
= gtk_dialog_run (GTK_DIALOG (dialog
));
256 if(result
== GTK_RESPONSE_ACCEPT
)
261 // cleanup and destroy
262 gtk_widget_destroy (dialog
);
267 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
269 struct dialog_currency_data
272 GtkWidget
*LB_currency
;
273 GtkWidget
*BT_change
;
274 Currency4217
*curfmt
;
277 static void ui_dialog_upgrade_choose_currency_change_action(GtkWidget
*widget
, gpointer user_data
)
279 struct dialog_currency_data
*data
= user_data
;
280 Currency4217
*curfmt
;
284 curfmt
= ui_cur_select_dialog_new(GTK_WINDOW(data
->window
), CUR_SELECT_MODE_BASE
);
290 DB( g_printf("- user selected: '%s' '%s'\n", curfmt
->curr_iso_code
, curfmt
->name
) );
292 data
->curfmt
= curfmt
;
296 g_snprintf(label
, 127, "%s - %s", curfmt
->curr_iso_code
, name
);
297 gtk_label_set_text (GTK_LABEL(data
->LB_currency
), label
);
302 static void ui_dialog_upgrade_choose_currency_fill(struct dialog_currency_data
*data
)
309 cur
= da_cur_get (GLOBALS
->kcur
);
311 g_snprintf(label
, 127, "%s - %s", cur
->iso_code
, cur
->name
);
312 gtk_label_set_text (GTK_LABEL(data
->LB_currency
), label
);
317 void ui_dialog_upgrade_choose_currency(void)
319 struct dialog_currency_data data
;
320 GtkWidget
*dialog
, *content_area
, *content_grid
, *group_grid
;
321 GtkWidget
*label
, *widget
;
324 dialog
= gtk_dialog_new_with_buttons (_("Upgrade"),
325 GTK_WINDOW (GLOBALS
->mainwindow
),
327 _("_Cancel"), GTK_RESPONSE_CANCEL
,
328 _("_OK"), GTK_RESPONSE_ACCEPT
,
331 data
.window
= dialog
;
333 content_area
= gtk_dialog_get_content_area(GTK_DIALOG (dialog
));
335 content_grid
= gtk_grid_new();
336 gtk_grid_set_row_spacing (GTK_GRID (content_grid
), SPACING_LARGE
);
337 gtk_orientable_set_orientation(GTK_ORIENTABLE(content_grid
), GTK_ORIENTATION_VERTICAL
);
338 gtk_container_set_border_width (GTK_CONTAINER(content_grid
), SPACING_MEDIUM
);
339 gtk_box_pack_start (GTK_BOX (content_area
), content_grid
, TRUE
, TRUE
, 0);
342 // group :: file title
343 group_grid
= gtk_grid_new ();
344 gtk_grid_set_row_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
345 gtk_grid_set_column_spacing (GTK_GRID (group_grid
), SPACING_MEDIUM
);
346 gtk_grid_attach (GTK_GRID (content_grid
), group_grid
, 0, crow
++, 1, 1);
349 label
= make_label(_("Select a base currency"), 0, 0);
350 gimp_label_set_attributes(GTK_LABEL(label
),
351 PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
,
352 PANGO_ATTR_SCALE
, PANGO_SCALE_LARGE
,
354 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 3, 1);
358 _("Starting v5.1, HomeBank can manage several currencies\n" \
359 "if the currency below is not correct, please change it:"), 0, 0);
360 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 3, 1);
363 label
= make_label_widget(_("Currency:"));
364 gtk_grid_attach (GTK_GRID (group_grid
), label
, 0, row
, 1, 1);
365 widget
= make_label (NULL
, 0, 0.5);
366 data
.LB_currency
= widget
;
367 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 1, row
, 1, 1);
368 widget
= gtk_button_new_with_mnemonic (_("_Change"));
369 data
.BT_change
= widget
;
370 gtk_grid_attach (GTK_GRID (group_grid
), widget
, 2, row
, 1, 1);
372 g_signal_connect (G_OBJECT (data
.BT_change
), "clicked", G_CALLBACK (ui_dialog_upgrade_choose_currency_change_action
), &data
);
375 ui_dialog_upgrade_choose_currency_fill(&data
);
377 gtk_widget_show_all(content_grid
);
380 gint result
= gtk_dialog_run (GTK_DIALOG (dialog
));
382 if(result
== GTK_RESPONSE_ACCEPT
)
385 if( data
.curfmt
!= NULL
)
387 hbfile_replace_basecurrency(data
.curfmt
);
391 // in any case set every accounts to base currency
393 list
= g_hash_table_get_values(GLOBALS
->h_acc
);
396 Account
*acc
= list
->data
;
398 account_set_currency(acc
, GLOBALS
->kcur
);
399 list
= g_list_next(list
);
403 // cleanup and destroy
404 gtk_widget_destroy (dialog
);
409 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
414 static void ui_file_chooser_add_filter(GtkFileChooser
*chooser
, gchar
*name
, gchar
*pattern
)
416 GtkFileFilter
*filter
= gtk_file_filter_new ();
417 gtk_file_filter_set_name (filter
, name
);
418 gtk_file_filter_add_pattern (filter
, pattern
);
419 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(chooser
), filter
);
423 gboolean
ui_file_chooser_qif(GtkWindow
*parent
, gchar
**storage_ptr
)
428 DB( g_print("(homebank) chooser save qif\n") );
430 chooser
= gtk_file_chooser_dialog_new (
433 GTK_FILE_CHOOSER_ACTION_SAVE
,
434 _("_Cancel"), GTK_RESPONSE_CANCEL
,
435 _("_Save"), GTK_RESPONSE_ACCEPT
,
438 //todo: change this ?
439 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(chooser
), PREFS
->path_export
);
440 ui_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser
), _("QIF files"), "*.[Qq][Ii][Ff]");
441 ui_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser
), _("All files"), "*");
444 if (gtk_dialog_run (GTK_DIALOG (chooser
)) == GTK_RESPONSE_ACCEPT
)
446 gchar
*tmpfilename
= gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser
));
448 *storage_ptr
= hb_util_filename_new_with_extension(tmpfilename
, "qif");
453 gtk_widget_destroy (chooser
);
461 ** open a file chooser dialog and store filename to GLOBALS if OK
463 gboolean
ui_file_chooser_csv(GtkWindow
*parent
, GtkFileChooserAction action
, gchar
**storage_ptr
, gchar
*name
)
471 DB( g_print("(hombank) csvfile chooser csv %d\n", action
) );
473 if( action
== GTK_FILE_CHOOSER_ACTION_OPEN
)
475 title
= _("Import from CSV");
477 path
= PREFS
->path_import
;
481 title
= _("Export as CSV");
483 path
= PREFS
->path_export
;
486 chooser
= gtk_file_chooser_dialog_new (title
,
488 action
, //GTK_FILE_CHOOSER_ACTION_OPEN,
489 _("_Cancel"), GTK_RESPONSE_CANCEL
,
490 button
, GTK_RESPONSE_ACCEPT
,
493 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(chooser
), path
);
496 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(chooser
), name
);
498 ui_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser
), _("CSV files"), "*.[Cc][Ss][Vv]");
499 ui_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser
), _("All files"), "*");
502 if (gtk_dialog_run (GTK_DIALOG (chooser
)) == GTK_RESPONSE_ACCEPT
)
504 gchar
*tmpfilename
= gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser
));
506 if( action
== GTK_FILE_CHOOSER_ACTION_SAVE
)
508 *storage_ptr
= hb_util_filename_new_with_extension(tmpfilename
, "csv");
513 *storage_ptr
= tmpfilename
;
518 gtk_widget_destroy (chooser
);
524 ** open a file chooser dialog and store filename to GLOBALS if OK
526 gboolean
ui_file_chooser_xhb(GtkFileChooserAction action
, gchar
**storage_ptr
)
533 DB( g_print("(ui-dialog) file chooser xhb %d\n", action
) );
535 if( action
== GTK_FILE_CHOOSER_ACTION_OPEN
)
537 title
= _("Open HomeBank file");
542 title
= _("Save HomeBank file as");
546 chooser
= gtk_file_chooser_dialog_new (title
,
547 GTK_WINDOW(GLOBALS
->mainwindow
),
548 action
, //GTK_FILE_CHOOSER_ACTION_OPEN,
549 _("_Cancel"), GTK_RESPONSE_CANCEL
,
550 button
, GTK_RESPONSE_ACCEPT
,
553 ui_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser
), _("HomeBank files"), "*.[Xx][Hh][Bb]");
554 ui_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser
), _("All files"), "*");
556 if( action
== GTK_FILE_CHOOSER_ACTION_OPEN
)
558 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(chooser
), PREFS
->path_hbfile
);
562 gchar
*basename
, *dirname
;
564 basename
= g_path_get_basename(GLOBALS
->xhb_filepath
);
565 dirname
= g_path_get_dirname (GLOBALS
->xhb_filepath
);
566 //gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(chooser), GLOBALS->xhb_filepath);
568 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(chooser
), dirname
);
569 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(chooser
), basename
);
576 if (gtk_dialog_run (GTK_DIALOG (chooser
)) == GTK_RESPONSE_ACCEPT
)
578 *storage_ptr
= gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser
));
582 gtk_widget_destroy (chooser
);
590 gboolean
ui_file_chooser_folder(GtkWindow
*parent
, gchar
*title
, gchar
**storage_ptr
)
595 DB( g_print("(ui-dialog) folder chooser\n") );
597 chooser
= gtk_file_chooser_dialog_new (title
,
599 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
,
600 _("_Cancel"), GTK_RESPONSE_CANCEL
,
601 _("_Open"), GTK_RESPONSE_ACCEPT
,
604 DB( g_print(" - set folder %s\n", *storage_ptr
) );
606 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(chooser
), *storage_ptr
);
609 if (gtk_dialog_run (GTK_DIALOG (chooser
)) == GTK_RESPONSE_ACCEPT
)
613 //nb: filename must be freed with g_free
614 filename
= gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser
));
616 DB( g_print("- folder %s\n", filename
) );
618 //todo: dangerous to do this here, review please !
619 g_free(*storage_ptr
);
620 *storage_ptr
= filename
;
622 DB( g_print("- folder stored: %s\n", *storage_ptr
) );
628 gtk_widget_destroy (chooser
);
636 ** request the user to save last change
638 gboolean
ui_dialog_msg_savechanges(GtkWidget
*widget
, gpointer user_data
)
640 gboolean retval
= TRUE
;
641 GtkWidget
*dialog
= NULL
;
644 if(GLOBALS
->changes_count
)
648 dialog
= gtk_message_dialog_new
650 GTK_WINDOW(GLOBALS
->mainwindow
),
651 GTK_DIALOG_MODAL
| GTK_DIALOG_DESTROY_WITH_PARENT
,
655 _("Save changes to the file before closing?")
658 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog
),
659 _("If you don't save, changes will be permanently lost.\nNumber of changes: %d."),
660 GLOBALS
->changes_count
663 gtk_dialog_add_buttons (GTK_DIALOG(dialog
),
664 _("Close _without saving"), 0,
669 gtk_dialog_set_default_response(GTK_DIALOG( dialog
), 2);
671 result
= gtk_dialog_run( GTK_DIALOG( dialog
) );
672 gtk_widget_destroy( dialog
);
674 if(result
== 1 || result
== GTK_RESPONSE_DELETE_EVENT
)
682 DB( g_print(" + should quick save %s\n", GLOBALS
->xhb_filepath
) );
683 homebank_save_xml(GLOBALS
->xhb_filepath
);
694 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
700 GtkWidget
*srctreeview
;
705 static void ui_dialog_transaction_xfer_select_child_cb(GtkWidget
*radiobutton
, gpointer user_data
)
707 struct xfer_data
*data
;
708 GtkTreeSelection
*selection
;
709 gboolean btnew
, sensitive
;
713 data
= g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(radiobutton
), GTK_TYPE_WINDOW
)), "inst_data");
715 DB( g_print("(import) account type toggle\n") );
717 btnew
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
->radio
[0]));
718 gtk_widget_set_sensitive(data
->treeview
, btnew
^1);
720 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(data
->treeview
));
721 count
= gtk_tree_selection_count_selected_rows(selection
);
724 sensitive
= (btnew
|| count
> 0) ? TRUE
: FALSE
;
726 DB( g_print("test count %d btnew %d sensitive %d\n", count
, btnew
, sensitive
) );
729 gtk_dialog_set_response_sensitive(GTK_DIALOG(data
->window
), GTK_RESPONSE_ACCEPT
, sensitive
);
733 static void ui_dialog_transaction_xfer_select_child_selection_cb(GtkTreeSelection
*treeselection
, gpointer user_data
)
735 ui_dialog_transaction_xfer_select_child_cb(GTK_WIDGET(gtk_tree_selection_get_tree_view (treeselection
)), NULL
);
739 Transaction
*ui_dialog_transaction_xfer_select_child(Transaction
*stxn
, GList
*matchlist
)
741 struct xfer_data data
;
742 GtkWidget
*window
, *content
, *mainvbox
, *vbox
, *sw
, *label
, *LB_several
;
743 GtkTreeModel
*newmodel
;
745 Transaction
*retval
= NULL
;
747 window
= gtk_dialog_new_with_buttons (
748 _("Select among possible transactions..."),
749 GTK_WINDOW (GLOBALS
->mainwindow
),
757 g_object_set_data(G_OBJECT(window
), "inst_data", (gpointer
)&data
);
758 data
.window
= window
;
760 //gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE);
761 gtk_window_set_default_size (GTK_WINDOW (window
), 800, 494);
763 content
= gtk_dialog_get_content_area(GTK_DIALOG (window
));
764 mainvbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, 0);
765 gtk_box_pack_start (GTK_BOX (content
), mainvbox
, TRUE
, TRUE
, 0);
766 gtk_container_set_border_width (GTK_CONTAINER (mainvbox
), SPACING_SMALL
);
769 sw
= gtk_scrolled_window_new (NULL
, NULL
);
770 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
771 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
772 //gtk_widget_set_size_request(sw, -1, HB_MINWIDTH_LIST/2);
774 data
.srctreeview
= create_list_transaction(LIST_TXN_TYPE_DETAIL
, PREFS
->lst_ope_columns
);
775 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.srctreeview
)), GTK_SELECTION_NONE
);
776 gtk_container_add (GTK_CONTAINER (sw
), data
.srctreeview
);
777 gtk_box_pack_start (GTK_BOX (mainvbox
), sw
, TRUE
, TRUE
, 0);
781 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, SPACING_SMALL
);
782 gtk_box_pack_start (GTK_BOX (mainvbox
), vbox
, FALSE
, TRUE
, SPACING_SMALL
);
784 label
= make_label(_("Select an action:"), 0.0, 0.5);
785 gimp_label_set_attributes(GTK_LABEL(label
), PANGO_ATTR_WEIGHT
, PANGO_WEIGHT_BOLD
, -1);
786 gtk_box_pack_start (GTK_BOX (vbox
), label
, FALSE
, FALSE
, 0);
788 data
.radio
[0] = gtk_radio_button_new_with_label (NULL
, _("create a new transaction"));
789 gtk_box_pack_start (GTK_BOX (vbox
), data
.radio
[0], FALSE
, FALSE
, 0);
791 data
.radio
[1] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (data
.radio
[0]), _("select an existing transaction"));
792 gtk_box_pack_start (GTK_BOX (vbox
), data
.radio
[1], FALSE
, FALSE
, 0);
795 label
= make_label(_(
796 "HomeBank has found some transaction that may be " \
797 "the associated transaction for the internal transfer."), 0.0, 0.5
800 gimp_label_set_attributes (GTK_LABEL (label
),
801 PANGO_ATTR_SCALE
, PANGO_SCALE_SMALL
,
803 gtk_box_pack_start (GTK_BOX (mainvbox
), label
, FALSE
, FALSE
, SPACING_SMALL
);
806 sw
= gtk_scrolled_window_new (NULL
, NULL
);
807 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw
), GTK_SHADOW_ETCHED_IN
);
808 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
810 data
.treeview
= create_list_transaction(LIST_TXN_TYPE_DETAIL
, PREFS
->lst_ope_columns
);
811 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.treeview
)), GTK_SELECTION_SINGLE
);
812 gtk_container_add (GTK_CONTAINER (sw
), data
.treeview
);
813 gtk_box_pack_start (GTK_BOX (mainvbox
), sw
, TRUE
, TRUE
, 0);
815 /* populate source */
818 newmodel
= gtk_tree_view_get_model(GTK_TREE_VIEW(data
.srctreeview
));
819 gtk_list_store_clear (GTK_LIST_STORE(newmodel
));
821 gtk_list_store_append (GTK_LIST_STORE(newmodel
), &newiter
);
823 gtk_list_store_set (GTK_LIST_STORE(newmodel
), &newiter
,
824 LST_DSPOPE_DATAS
, stxn
,
828 /* populate target */
829 newmodel
= gtk_tree_view_get_model(GTK_TREE_VIEW(data
.treeview
));
830 gtk_list_store_clear (GTK_LIST_STORE(newmodel
));
832 GList
*tmplist
= g_list_first(matchlist
);
833 while (tmplist
!= NULL
)
835 Transaction
*tmp
= tmplist
->data
;
837 /* append to our treeview */
838 gtk_list_store_append (GTK_LIST_STORE(newmodel
), &newiter
);
840 gtk_list_store_set (GTK_LIST_STORE(newmodel
), &newiter
,
841 LST_DSPOPE_DATAS
, tmp
,
844 //DB( g_print(" - fill: %s %.2f %x\n", item->wording, item->amount, (unsigned int)item->same) );
846 tmplist
= g_list_next(tmplist
);
850 g_signal_connect (data
.radio
[0], "toggled", G_CALLBACK (ui_dialog_transaction_xfer_select_child_cb
), NULL
);
851 g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.treeview
)), "changed", G_CALLBACK (ui_dialog_transaction_xfer_select_child_selection_cb
), NULL
);
853 gtk_widget_show_all(mainvbox
);
856 gtk_widget_set_sensitive (data
.radio
[1], TRUE
);
857 if( g_list_length (matchlist
) <= 0 )
859 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.radio
[0]), TRUE
);
860 gtk_widget_set_sensitive (data
.radio
[1], FALSE
);
861 gtk_widget_set_visible (LB_several
, FALSE
);
865 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data
.radio
[1]), TRUE
);
866 gtk_widget_set_visible (LB_several
, TRUE
);
869 ui_dialog_transaction_xfer_select_child_cb(data
.radio
[0], NULL
);
872 gint result
= gtk_dialog_run (GTK_DIALOG (window
));
874 if(result
== GTK_RESPONSE_ACCEPT
)
878 bnew
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data
.radio
[0]));
881 GtkTreeSelection
*selection
;
885 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(data
.treeview
));
886 if (gtk_tree_selection_get_selected(selection
, &model
, &iter
))
888 gtk_tree_model_get(model
, &iter
, LST_DSPOPE_DATAS
, &retval
, -1);
894 // cleanup and destroy
895 gtk_widget_destroy (window
);