X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fdsp-mainwindow.c;h=927ebaa60f637a8c543bbc763633c246ebab4260;hb=cb3f5fd6fce35d2a18f21246c7be123c18f01f97;hp=1f53410322aea8c6b5a33953f9ad1f7d86eb8c68;hpb=236cb5e47660876f46488ea8f76ecd5bebfa1fac;p=chaz%2Fhomebank diff --git a/src/dsp-mainwindow.c b/src/dsp-mainwindow.c index 1f53410..927ebaa 100644 --- a/src/dsp-mainwindow.c +++ b/src/dsp-mainwindow.c @@ -22,6 +22,8 @@ #include "dsp-mainwindow.h" +#include "ext.h" + #include "list-account.h" #include "hub-account.h" @@ -108,8 +110,7 @@ static void ui_mainwindow_action_toggle_upcoming(GtkToggleAction *action); static void ui_mainwindow_action_toggle_topspending(GtkToggleAction *action); static void ui_mainwindow_action_toggle_minor(GtkToggleAction *action); -static void ui_mainwindow_action_showtransactions(void); -static void ui_mainwindow_action_showalltransactions(void); +static void ui_mainwindow_action_showtransactions(GtkAction *action); static void ui_mainwindow_action_addtransactions(void); static void ui_mainwindow_action_checkscheduled(void); @@ -125,6 +126,8 @@ static void ui_mainwindow_action_export(void); static void ui_mainwindow_action_anonymize(void); static void ui_mainwindow_action_file_statistics(void); +static void ui_mainwindow_action_pluginprefs(void); + static void ui_mainwindow_action_help(void); void ui_mainwindow_action_help_welcome(void); static void ui_mainwindow_action_help_online(void); @@ -151,6 +154,7 @@ void ui_mainwindow_recent_add (struct hbfile_data *data, const gchar *path); void ui_mainwindow_recent_add (struct hbfile_data *data, const gchar *path); +static void ui_mainwindow_showprefs(gint page); static GtkActionEntry entries[] = { @@ -165,6 +169,7 @@ static GtkActionEntry entries[] = { { "TxnMenu" , NULL, N_("_Transactions"), NULL, NULL, NULL }, { "ReportMenu" , NULL, N_("_Reports"), NULL, NULL, NULL }, { "ToolsMenu" , NULL, N_("_Tools"), NULL, NULL, NULL }, + { "PluginMenu" , NULL, N_("_Plugins"), NULL, NULL, NULL }, { "HelpMenu" , NULL, N_("_Help"), NULL, NULL, NULL }, // { "Import" , NULL, N_("Import") }, @@ -189,7 +194,7 @@ static GtkActionEntry entries[] = { //{ "ImportQIF" , ICONNAME_HB_FILE_IMPORT , N_("QIF file...") , NULL, N_("Open the import assistant"), G_CALLBACK (ui_mainwindow_action_import) }, //{ "ImportOFX" , ICONNAME_HB_FILE_IMPORT , N_("OFX/QFX file...") , NULL, N_("Open the import assistant"), G_CALLBACK (ui_mainwindow_action_import) }, //{ "ImportCSV" , ICONNAME_HB_FILE_IMPORT , N_("CSV file...") , NULL, N_("Open the import assistant"), G_CALLBACK (ui_mainwindow_action_import) }, - + { "ExportQIF" , ICONNAME_HB_FILE_EXPORT , N_("Export as QIF...") , NULL, N_("Export all account in a QIF file"), G_CALLBACK (ui_mainwindow_action_export) }, /* EditMenu */ @@ -208,7 +213,8 @@ static GtkActionEntry entries[] = { /* TxnMenu */ { "AddTxn" , ICONNAME_HB_OPE_ADD , N_("Add...") , NULL, N_("Add transactions"), G_CALLBACK (ui_mainwindow_action_addtransactions) }, { "ShowTxn" , ICONNAME_HB_OPE_SHOW , N_("Show...") , NULL, N_("Shows selected account transactions"), G_CALLBACK (ui_mainwindow_action_showtransactions) }, - { "ShowAllTxn" , ICONNAME_HB_OPE_SHOW , N_("Show all...") , NULL, N_("Shows all account transactions"), G_CALLBACK (ui_mainwindow_action_showalltransactions) }, + //beware ShowAllTxn is used to detect showall + { "ShowAllTxn" , ICONNAME_HB_OPE_SHOW , N_("Show all...") , NULL, N_("Shows all account transactions"), G_CALLBACK (ui_mainwindow_action_showtransactions) }, { "Scheduler" , NULL , N_("Set scheduler...") , NULL, N_("Configure the transaction scheduler"), G_CALLBACK (ui_mainwindow_action_properties) }, { "AddScheduled", NULL , N_("Post scheduled"), NULL, N_("Post pending scheduled transactions"), G_CALLBACK (ui_mainwindow_action_checkscheduled) }, @@ -223,7 +229,10 @@ static GtkActionEntry entries[] = { { "Welcome" , NULL , N_("Show welcome dialog...") , NULL, NULL, G_CALLBACK (ui_mainwindow_action_help_welcome) }, { "FileStats" , NULL , N_("File statistics...") , NULL, NULL, G_CALLBACK (ui_mainwindow_action_file_statistics) }, { "Anonymize" , NULL , N_("Anonymize...") , NULL, NULL, G_CALLBACK (ui_mainwindow_action_anonymize) }, - + + /* Plugins */ + { "PluginPreferences", "prf-plugins", N_("_Plugins..."), "U", N_("Configure plugin preferences"), G_CALLBACK(ui_mainwindow_action_pluginprefs) }, + /* HelpMenu */ { "Contents" , ICONNAME_HELP , N_("_Contents") , "F1", N_("Documentation about HomeBank"), G_CALLBACK (ui_mainwindow_action_help) }, { "Online" , "lpi-help" , N_("Get Help Online...") , NULL, N_("Connect to the LaunchPad website for online help"), G_CALLBACK (ui_mainwindow_action_help_online) }, @@ -321,6 +330,11 @@ static const gchar *ui_info = " " " " " " +" " +" " +" " +" " +" " " " " " " " @@ -355,6 +369,7 @@ static const gchar *ui_info = " " " " " " +" " " " ""; @@ -383,7 +398,7 @@ gint result; title = g_strdup_printf ( _("Revert unsaved changes to file '%s'?"), basename); - secondtext = + secondtext = _("- Changes made to the file will be permanently lost\n" "- File will be reloaded from the last save (.xhb~)"); @@ -400,7 +415,7 @@ gint result; if( result == GTK_RESPONSE_OK ) { DB( g_print(" - should revert\n") ); - + hbfile_change_filepath(hb_filename_new_with_extension(GLOBALS->xhb_filepath, "xhb~")); ui_mainwindow_open_internal(widget, NULL); hbfile_change_filepath(hb_filename_new_with_extension(GLOBALS->xhb_filepath, "xhb")); @@ -415,7 +430,7 @@ activate_url (GtkAboutDialog *about, gpointer data) { DB( g_print("activate url %s\n", link) ); - + homebank_util_url_show (link); } @@ -434,7 +449,8 @@ gchar *version; static const gchar *authors[] = { "Lead developer:\n" \ "Maxime DOYEN", - "\nContributor:\n" \ + "\nContributors:\n" \ + "Charles MCGARVEY (Plugin system, Perl support)\n" \ "Ga\xc3\xabtan LORIDANT (Maths formulas for charts)\n", NULL }; @@ -454,18 +470,18 @@ gchar *version; gtk_get_major_version (), gtk_get_minor_version (), gtk_get_micro_version ()); - + dialog = gtk_about_dialog_new(); gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(GLOBALS->mainwindow)); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); - + gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG(dialog), g_get_application_name ()); gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), version); gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog), copyright); gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog), _("Free, easy, personal accounting for everyone")); gtk_about_dialog_set_license_type (GTK_ABOUT_DIALOG(dialog), GTK_LICENSE_GPL_2_0); - + //gtk_about_dialog_set_wrap_license(GTK_ABOUT_DIALOG(dialog), ); gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dialog), "http://homebank.free.fr"); gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(dialog), "Visit the HomeBank website"); @@ -481,7 +497,7 @@ gchar *version; gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), pixbuf); g_object_unref (pixbuf); } - + gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(dialog), authors); gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(dialog), artists); //gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(dialog), ); @@ -494,7 +510,7 @@ gchar *version; gtk_widget_destroy (dialog); g_free(version); - + } @@ -570,6 +586,12 @@ static void ui_mainwindow_action_file_statistics(void) } +static void ui_mainwindow_action_pluginprefs(void) +{ + ui_mainwindow_showprefs(PREF_PLUGINS); +} + + static void ui_mainwindow_action_properties(void) { create_defhbfile_dialog(); @@ -584,7 +606,7 @@ gchar *secondtext; title = _("Are you sure you want to anonymize the file?"); - secondtext = + secondtext = _("Proceeding will anonymize any text, \n" "like 'account x', 'payee y', 'memo z', ..."); @@ -597,7 +619,7 @@ gchar *secondtext; //#1707201 //if( result == GTK_RESPONSE_CANCEL ) - // return; + // return; if( result == GTK_RESPONSE_OK ) { hbfile_anonymize(); @@ -692,10 +714,15 @@ static void ui_mainwindow_action_deftag(void) static void ui_mainwindow_action_preferences(void) +{ + ui_mainwindow_showprefs(PREF_GENERAL); +} + +static void ui_mainwindow_showprefs(gint page) { struct hbfile_data *data = g_object_get_data(G_OBJECT(GLOBALS->mainwindow), "inst_data"); - defpref_dialog_new(); + defpref_dialog_new(page); if(!PREFS->euro_active) { GtkToggleAction *action = (GtkToggleAction *)gtk_ui_manager_get_action(data->manager, "/MenuBar/ViewMenu/AsMinor"); @@ -743,18 +770,26 @@ struct hbfile_data *data = g_object_get_data(G_OBJECT(GLOBALS->mainwindow), "ins // top spending gtk_chart_show_minor(GTK_CHART(data->RE_pie), GLOBALS->minor); - + ui_hub_spending_update(data->window, data); } -static void ui_mainwindow_action_showtransactions(void) +static void ui_mainwindow_action_showtransactions(GtkAction *action) { struct hbfile_data *data = g_object_get_data(G_OBJECT(GLOBALS->mainwindow), "inst_data"); GtkWidget *window; +gboolean showall = FALSE; - //todo:change this - if( data->acc ) + if( action != NULL ) + { + DB( g_print(" actioname=%s\n", gtk_action_get_name(action)) ); + if( hb_string_compare((gchar *)gtk_action_get_name(action), "ShowAllTxn" ) == 0 ) + showall = TRUE; + } + + //TODO: change this + if( data->acc && showall == FALSE ) { if( data->acc->window == NULL ) { @@ -765,27 +800,21 @@ GtkWidget *window; { if(GTK_IS_WINDOW(data->acc->window)) gtk_window_present(GTK_WINDOW(data->acc->window)); - } } -} - - -static void ui_mainwindow_action_showalltransactions(void) -{ -GtkWidget *window; - - if( GLOBALS->alltxnwindow == NULL ) - { - window = register_panel_window_new(NULL); - register_panel_window_init(window, NULL); - } else { - if(GTK_IS_WINDOW(GLOBALS->alltxnwindow)) - gtk_window_present(GTK_WINDOW(GLOBALS->alltxnwindow)); + if( GLOBALS->alltxnwindow == NULL ) + { + window = register_panel_window_new(NULL); + register_panel_window_init(window, NULL); + } + else + { + if(GTK_IS_WINDOW(GLOBALS->alltxnwindow)) + gtk_window_present(GTK_WINDOW(GLOBALS->alltxnwindow)); + } } - } @@ -807,7 +836,7 @@ static void ui_mainwindow_action_statistic(void) static void ui_mainwindow_action_trendtime(void) { struct hbfile_data *data = g_object_get_data(G_OBJECT(GLOBALS->mainwindow), "inst_data"); - + ui_reptime_window_new(data->acc != NULL ? data->acc->key : 0); } @@ -935,7 +964,7 @@ GtkWidget *mainvbox, *widget, *label; NULL); content_area = gtk_dialog_get_content_area(GTK_DIALOG (dialog)); - + mainvbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (content_area), mainvbox, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER(mainvbox), SPACING_MEDIUM); @@ -961,11 +990,11 @@ GtkWidget *mainvbox, *widget, *label; widget = gtk_button_new_with_mnemonic(_("Read HomeBank _Manual")); gtk_box_pack_start (GTK_BOX (mainvbox), widget, FALSE, FALSE, 0); g_signal_connect (widget, "clicked", G_CALLBACK (ui_mainwindow_action_help_welcome1), dialog); - + widget = gtk_button_new_with_mnemonic(_("Configure _preferences")); gtk_box_pack_start (GTK_BOX (mainvbox), widget, FALSE, FALSE, 0); g_signal_connect (widget, "clicked", G_CALLBACK (ui_mainwindow_action_help_welcome2), dialog); - + widget = gtk_button_new_with_mnemonic(_("Create a _new file")); gtk_box_pack_start (GTK_BOX (mainvbox), widget, FALSE, FALSE, 0); g_signal_connect (widget, "clicked", G_CALLBACK (ui_mainwindow_action_help_welcome3), dialog); @@ -1100,10 +1129,10 @@ gboolean file_clear = GPOINTER_TO_INT(user_data); gtk_tree_store_clear(GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_acc)))); gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_upc)))); gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_top)))); - + data->showall = FALSE; ui_hub_account_setup(data); - + hbfile_cleanup(file_clear); hbfile_setup(file_clear); @@ -1148,7 +1177,7 @@ gint account, count; if( PREFS->heritdate == FALSE ) //fix: 318733 ope->date = GLOBALS->today; - + da_transaction_set_default_template(ope); } @@ -1168,7 +1197,7 @@ gint account, count; DB( g_print(" - added 1 transaction to %d\n", ope->kacc) ); ui_hub_account_populate(GLOBALS->mainwindow, NULL); - + count++; //todo: still usefull ? store last date date = ope->date; @@ -1203,21 +1232,21 @@ gboolean result; basename = g_path_get_basename(filepath); secondtext = g_strdup_printf ( - _("Your are about to open the backup file '%s'.\n\nAre you sure you want to do this ?"), basename); + _("Your are about to open the backup file '%s'.\n\nAre you sure you want to do this ?"), basename); result = ui_dialog_msg_confirm_alert( GTK_WINDOW(GLOBALS->mainwindow), _("Open the backup file ?"), secondtext, _("_Open backup") - ); + ); g_free(secondtext); g_free(basename); if( result == GTK_RESPONSE_OK ) retval = TRUE; - + return retval; } @@ -1256,7 +1285,7 @@ gchar *filename = NULL; g_free(filename); return; } - } + } hbfile_change_filepath(filename); ui_mainwindow_open_internal(widget, NULL); @@ -1291,7 +1320,7 @@ gint r; GLOBALS->xhb_timemodified = hbfile_file_get_time_modified(GLOBALS->xhb_filepath); hbfile_file_hasrevert(GLOBALS->xhb_filepath); - + if(PREFS->appendscheduled) scheduled_post_all_pending(); @@ -1317,7 +1346,7 @@ gint r; case XML_FILE_ERROR: msg = _("The file '%s' is not a valid HomeBank file."); break; - case XML_VERSION_ERROR: + case XML_VERSION_ERROR: msg = _("The file '%s' was saved with a higher version of HomeBank\nand cannot be loaded by the current version."); break; } @@ -1336,7 +1365,7 @@ gint r; ui_hub_scheduled_populate(GLOBALS->mainwindow, NULL); ui_hub_spending_populate(GLOBALS->mainwindow, NULL); ui_hub_transaction_populate(data); - + ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE+UF_VISUAL)); } @@ -1398,7 +1427,7 @@ gint r = XML_UNSET; _("If you save it, all the external changes could be lost. Save it anyway?"), _("S_ave Anyway") ); - + if( result != GTK_RESPONSE_OK ) return; } @@ -1462,7 +1491,7 @@ gint flags; #else data->wintitle = g_strdup_printf("%s%s - %s - " PROGNAME, changed, basename, GLOBALS->owner); #endif - + gtk_window_set_title (GTK_WINDOW (gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), data->wintitle); g_free(basename); @@ -1547,10 +1576,12 @@ gint flags; gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TxnMenu/AddScheduled"), sensitive); // no active account: disable Edit, Over - sensitive = (active == TRUE ) ? TRUE : FALSE; + //disabled 5.2.6 + /* sensitive = (active == TRUE ) ? TRUE : FALSE; if(data->acc && data->acc->window != NULL) sensitive = FALSE; gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TxnMenu/ShowTxn"), sensitive); + */ } /* update toolbar, list */ @@ -1578,7 +1609,7 @@ gint flags; DB( g_print(" - show top_spending=%d\n", PREFS->wal_spending) ); - gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_range), PREFS->date_range_wal); + hbtk_combo_box_set_active_id(GTK_COMBO_BOX_TEXT(data->CY_range), PREFS->date_range_wal); if(PREFS->wal_spending) gtk_widget_show(GTK_WIDGET(data->GR_top)); @@ -1586,7 +1617,7 @@ gint flags; gtk_widget_hide(GTK_WIDGET(data->GR_top)); - + DB( g_print(" - show upcoming=%d\n", PREFS->wal_upcoming) ); if(PREFS->wal_upcoming) gtk_widget_show(GTK_WIDGET(data->GR_upc)); @@ -1653,7 +1684,7 @@ static void DB( g_print ("Double-clicked row contains name %s\n", acc->name) ); - ui_mainwindow_action_showtransactions(); + ui_mainwindow_action_showtransactions(NULL); //g_free(name); } @@ -1677,6 +1708,9 @@ struct hbfile_data *data = user_data; struct WinGeometry *wg; gboolean retval = FALSE; + GValue widget_value = G_VALUE_INIT; + ext_hook("main_window_disposal", EXT_OBJECT(&widget_value, widget), NULL); + DB( g_print("\n[ui-mainwindow] delete-event\n") ); //store position and size @@ -1695,7 +1729,7 @@ gboolean retval = FALSE; if(PREFS->pnl_list_tab) g_free(PREFS->pnl_list_tab); PREFS->pnl_list_tab = g_strdup(gtk_stack_get_visible_child_name(GTK_STACK(data->stack))); - + //todo if(ui_dialog_msg_savechanges(widget, NULL) == FALSE) { @@ -1710,7 +1744,7 @@ gboolean retval = FALSE; g_free(data->wintitle); da_flt_free(data->filter); g_free(user_data); - + gtk_main_quit(); } @@ -1824,7 +1858,7 @@ gchar **uris, **str; gchar *newseldata; gint n_uris, filetype, slen; GError *error = NULL; - + if (info != TARGET_URI_LIST) return; @@ -1837,7 +1871,7 @@ GError *error = NULL; newseldata[slen] = 0; //DB( g_print(" - seldata ='%s'\n", gtk_selection_data_get_data(selection_data) ) ); //DB( g_print(" - newseldata ='%s'\n", newseldata ) ); - + uris = g_uri_list_extract_uris (newseldata); n_uris = g_strv_length(uris); DB( g_print(" - dragged %d files (len=%d)\n", n_uris, slen ) ); @@ -1846,7 +1880,7 @@ GError *error = NULL; //single file: check for xhb if(n_uris == 1) - { + { filetype = hb_filename_type_get_by_extension(*uris); DB( g_print(" - filetype is homebank (%d)\n", filetype) ); @@ -1879,7 +1913,7 @@ GError *error = NULL; //collect known filetype to import DB( g_print(" - collect %d files\n", n_uris) ); - + gchar **paths = g_new (gchar *, n_uris + 1); slen = 0; for (str = uris; *str; str++) @@ -1894,7 +1928,7 @@ GError *error = NULL; DB( g_print(" - append %d '%s'\n", slen, path ) ); paths[slen++] = path; } - } + } } paths[slen] = NULL; @@ -1902,8 +1936,8 @@ GError *error = NULL; { ui_import_assistant_new( paths ); } - - + + end_drop: g_strfreev (uris); } @@ -2105,7 +2139,7 @@ GtkWidget *bar, *label; gtk_label_set_markup (GTK_LABEL(label), "Unstable Development Version"); gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE, 0); #endif - + /* Add the main area */ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); //gtk_container_set_border_width (GTK_CONTAINER(vbox), SPACING_MEDIUM); @@ -2139,7 +2173,7 @@ GtkWidget *bar, *label; gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), GTK_STACK (stack)); data->stack = stack; gtk_box_pack_start (GTK_BOX (box), stack, TRUE, TRUE, 0); - + page = ui_hub_scheduled_create(data); gtk_stack_add_titled (GTK_STACK (stack), page, "sched", _("Scheduled")); //gtk_paned_pack2 (GTK_PANED(vpaned), widget, TRUE, FALSE); @@ -2149,7 +2183,7 @@ GtkWidget *bar, *label; page = ui_hub_transaction_create(data, HUB_TXN_TYPE_REMIND); gtk_stack_add_titled (GTK_STACK (stack), page, "remin", _("Remind")); - + //setup, init and show window wg = &PREFS->wal_wg; @@ -2174,13 +2208,13 @@ GtkWidget *bar, *label; if( PREFS->pnl_list_tab != NULL ) gtk_stack_set_visible_child_name (GTK_STACK(data->stack), PREFS->pnl_list_tab); - + //todo: move this elsewhere DB( g_print(" - setup stuff\n") ); data->filter = da_flt_malloc(); filter_reset(data->filter); - gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_range), PREFS->date_range_wal); + hbtk_combo_box_set_active_id(GTK_COMBO_BOX_TEXT(data->CY_range), PREFS->date_range_wal); action = gtk_ui_manager_get_action(data->manager, "/MenuBar/ViewMenu/Toolbar"); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), PREFS->wal_toolbar);