/* HomeBank -- Free, easy, personal accounting for everyone.
- * Copyright (C) 1995-2014 Maxime DOYEN
+ * Copyright (C) 1995-2018 Maxime DOYEN
*
* This file is part of HomeBank.
*
#include "list_topspending.h"
#include "dsp_account.h"
-#include "import.h"
-#include "imp_qif.h"
+#include "ui-assist-import.h"
#include "ui-assist-start.h"
#include "ui-account.h"
+#include "ui-currency.h"
#include "ui-payee.h"
#include "ui-category.h"
#include "ui-archive.h"
#include "gtk-chart.h"
+//old url prior 2018
//#define HOMEBANK_URL_HELP "http://homebank.free.fr/help/"
+//#define HOMEBANK_URL_HELP_ONLINE "https://launchpad.net/homebank/+addquestion"
+//#define HOMEBANK_URL_HELP_PROBLEM "https://launchpad.net/homebank/+filebug"
+//#define HOMEBANK_URL_HELP_TRANSLATE "https://launchpad.net/homebank/+translations"
+
#define HOMEBANK_URL_HELP "index.html"
-#define HOMEBANK_URL_HELP_ONLINE "https://launchpad.net/homebank/+addquestion"
-#define HOMEBANK_URL_HELP_TRANSLATE "https://launchpad.net/homebank/+translations"
-#define HOMEBANK_URL_HELP_PROBLEM "https://launchpad.net/homebank/+filebug"
+#define HOMEBANK_URL_HELP_ONLINE "http://homebank.free.fr/support.php"
+#define HOMEBANK_URL_HELP_UPDATES "http://homebank.free.fr/downloads.php"
+#define HOMEBANK_URL_HELP_PROBLEM "http://homebank.free.fr/development.php#bug"
+#define HOMEBANK_URL_HELP_TRANSLATE "http://homebank.free.fr/development.php#translate"
/****************************************************************************/
/* Debug macros */
/****************************************************************************/
#define MYDEBUG 0
+
#if MYDEBUG
#define DB(x) (x);
#else
static void ui_mainwindow_action_close(void);
static void ui_mainwindow_action_quit(void);
+static void ui_mainwindow_action_defcurrency(void);
static void ui_mainwindow_action_defaccount(void);
static void ui_mainwindow_action_defpayee(void);
static void ui_mainwindow_action_defcategory(void);
static void ui_mainwindow_action_balance(void);
static void ui_mainwindow_action_vehiclecost(void);
-static void ui_mainwindow_action_import(void);
+static void ui_mainwindow_action_import(GtkAction *action);
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_help(void);
void ui_mainwindow_action_help_welcome(void);
static void ui_mainwindow_action_help_online(void);
+static void ui_mainwindow_action_help_updates(void);
+static void ui_mainwindow_action_help_releasenotes(void);
static void ui_mainwindow_action_help_translate(void);
static void ui_mainwindow_action_help_problem(void);
static void ui_mainwindow_action_about(void);
void ui_mainwindow_addtransactions(GtkWidget *widget, gpointer user_data);
void ui_mainwindow_recent_add (struct hbfile_data *data, const gchar *path);
+static void ui_panel_topspending_update(GtkWidget *widget, gpointer user_data);
+
static void ui_mainwindow_scheduled_populate(GtkWidget *widget, gpointer user_data);
void ui_mainwindow_scheduled_postall(GtkWidget *widget, gpointer user_data);
+void ui_mainwindow_recent_add (struct hbfile_data *data, const gchar *path);
+
+static void ui_panel_accounts_setup(struct hbfile_data *data);
extern gchar *CYA_ACC_TYPE[];
+gchar *CYA_CATSUBCAT[] = {
+ N_("Category"),
+ N_("Subcategory"),
+ NULL
+};
+
+
static GtkActionEntry entries[] = {
- /* name, stock id, label */
+ /* name, icon-name, label */
- { "FileMenu" , NULL, N_("_File"), NULL, NULL, NULL },
- { "EditMenu" , NULL, N_("_Edit"), NULL, NULL, NULL },
- { "ViewMenu" , NULL, N_("_View"), NULL, NULL, NULL },
- { "ManageMenu" , NULL, N_("_Manage"), NULL, NULL, NULL },
- { "TransactionMenu", NULL, N_("_Transactions"), NULL, NULL, NULL },
- { "ReportMenu" , NULL, N_("_Reports"), NULL, NULL, NULL },
- { "HelpMenu" , NULL, N_("_Help"), NULL, NULL, NULL },
+ { "FileMenu" , NULL, N_("_File"), NULL, NULL, NULL },
+ { "ImportMenu" , NULL, N_("_Import"), NULL, NULL, NULL },
+ { "EditMenu" , NULL, N_("_Edit"), NULL, NULL, NULL },
+ { "ViewMenu" , NULL, N_("_View"), NULL, NULL, NULL },
+ { "ManageMenu" , NULL, N_("_Manage"), NULL, NULL, NULL },
+ { "TxnMenu" , NULL, N_("_Transactions"), NULL, NULL, NULL },
+ { "ReportMenu" , NULL, N_("_Reports"), NULL, NULL, NULL },
+ { "ToolsMenu" , NULL, N_("_Tools"), NULL, NULL, NULL },
+ { "HelpMenu" , NULL, N_("_Help"), NULL, NULL, NULL },
// { "Import" , NULL, N_("Import") },
// { "Export" , NULL, N_("Export to") },
- /* name, stock id, label, accelerator, tooltip */
+ /* name, icon-name, label, accelerator, tooltip */
/* FileMenu */
- { "New" , GTK_STOCK_NEW , N_("_New") , NULL, N_("Create a new file"), G_CALLBACK (ui_mainwindow_action_new) },
- { "Open" , GTK_STOCK_OPEN , N_("_Open...") , NULL, N_("Open a file"), G_CALLBACK (ui_mainwindow_action_open) },
- { "Save" , GTK_STOCK_SAVE , N_("_Save") , NULL, N_("Save the current file"), G_CALLBACK (ui_mainwindow_action_save) },
- { "SaveAs" , GTK_STOCK_SAVE_AS , N_("Save As...") , "<shift><control>S", N_("Save the current file with a different name"), G_CALLBACK (ui_mainwindow_action_saveas) },
- { "Revert" , GTK_STOCK_REVERT_TO_SAVED, N_("Revert") , NULL, N_("Revert to a saved version of this file"), G_CALLBACK (ui_mainwindow_action_revert) },
+ { "New" , ICONNAME_NEW , N_("_New") , "<control>N", N_("Create a new file"), G_CALLBACK (ui_mainwindow_action_new) },
+ { "Open" , ICONNAME_OPEN , N_("_Open...") , "<control>O", N_("Open a file"), G_CALLBACK (ui_mainwindow_action_open) },
+ { "Save" , ICONNAME_SAVE , N_("_Save") , "<control>S", N_("Save the current file"), G_CALLBACK (ui_mainwindow_action_save) },
+ { "SaveAs" , ICONNAME_SAVE_AS , N_("Save _As...") , "<shift><control>S", N_("Save the current file with a different name"), G_CALLBACK (ui_mainwindow_action_saveas) },
+ { "Revert" , ICONNAME_REVERT , N_("Revert") , NULL, N_("Revert to a saved version of this file"), G_CALLBACK (ui_mainwindow_action_revert) },
- { "Properties" , GTK_STOCK_PROPERTIES , N_("_Properties..."), NULL, N_("Configure the file"), G_CALLBACK (ui_mainwindow_action_properties) },
- { "Close" , GTK_STOCK_CLOSE , N_("_Close") , NULL, N_("Close the current file"), G_CALLBACK (ui_mainwindow_action_close) },
- { "Quit" , GTK_STOCK_QUIT , N_("_Quit") , NULL, N_("Quit homebank"), G_CALLBACK (ui_mainwindow_action_quit) },
+ { "Properties" , ICONNAME_PROPERTIES , N_("Properties..."), NULL, N_("Configure the file"), G_CALLBACK (ui_mainwindow_action_properties) },
+ { "Close" , ICONNAME_CLOSE , N_("_Close") , "<control>W", N_("Close the current file"), G_CALLBACK (ui_mainwindow_action_close) },
+ { "Quit" , ICONNAME_QUIT , N_("_Quit") , "<control>Q", N_("Quit HomeBank"), G_CALLBACK (ui_mainwindow_action_quit) },
/* Exchange */
- { "FileImport" , "hb-file-import" , N_("Import QIF/OFX/CSV...") , NULL, N_("Open the import assistant"), G_CALLBACK (ui_mainwindow_action_import) },
- { "ExportQIF" , "hb-file-export" , N_("Export QIF...") , NULL, N_("Open the export to QIF assistant"), G_CALLBACK (ui_mainwindow_action_export) },
- { "Anonymize" , NULL , N_("Anonymize...") , NULL, NULL, G_CALLBACK (ui_mainwindow_action_anonymize) },
+ { "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 QIF file...") , NULL, N_("Export all account in a QIF file"), G_CALLBACK (ui_mainwindow_action_export) },
/* EditMenu */
- { "Preferences", GTK_STOCK_PREFERENCES, N_("Preferences..."), NULL, N_("Configure homebank"), G_CALLBACK (ui_mainwindow_action_preferences) },
+ { "Preferences", ICONNAME_PREFERENCES , N_("Preferences..."), NULL, N_("Configure HomeBank"), G_CALLBACK (ui_mainwindow_action_preferences) },
/* ManageMenu */
-// { "Currency" , "hb-currency" , N_("Currencies...") , NULL, N_("Configure the currencies"), G_CALLBACK (ui_mainwindow_action_defcurrency) },
- { "Account" , "hb-account" , N_("Acc_ounts...") , NULL, N_("Configure the accounts"), G_CALLBACK (ui_mainwindow_action_defaccount) },
- { "Payee" , "hb-payee" , N_("_Payees...") , NULL, N_("Configure the payees"), G_CALLBACK (ui_mainwindow_action_defpayee) },
- { "Category" , "hb-category" , N_("Categories...") , NULL, N_("Configure the categories"), G_CALLBACK (ui_mainwindow_action_defcategory) },
- { "Archive" , "hb-archive" , N_("Scheduled/Template...") , NULL, N_("Configure the scheduled/template transactions"), G_CALLBACK (ui_mainwindow_action_defarchive) },
- { "Budget" , "hb-budget" , N_("Budget...") , NULL, N_("Configure the budget"), G_CALLBACK (ui_mainwindow_action_defbudget) },
- { "Assign" , "hb-assign" , N_("Assignments..."), NULL, N_("Configure the automatic assignments"), G_CALLBACK (ui_mainwindow_action_defassign) },
-
- /* TransactionMenu */
- { "ShowOpe" , HB_STOCK_OPE_SHOW, N_("Show...") , NULL, N_("Shows selected account transactions"), G_CALLBACK (ui_mainwindow_action_showtransactions) },
- { "AddOpe" , HB_STOCK_OPE_ADD , N_("Add...") , NULL, N_("Add transaction"), G_CALLBACK (ui_mainwindow_action_addtransactions) },
- { "Scheduler" , NULL , N_("Set scheduler...") , NULL, N_("Configure the transaction scheduler"), G_CALLBACK (ui_mainwindow_action_properties) },
- { "AddScheduled" , NULL , N_("Process scheduled..."), NULL, N_("Insert pending scheduled transactions"), G_CALLBACK (ui_mainwindow_action_checkscheduled) },
+ { "Currency" , ICONNAME_HB_CURRENCY , N_("Currencies...") , NULL, N_("Configure the currencies"), G_CALLBACK (ui_mainwindow_action_defcurrency) },
+ { "Account" , ICONNAME_HB_ACCOUNT , N_("Acc_ounts...") , NULL, N_("Configure the accounts"), G_CALLBACK (ui_mainwindow_action_defaccount) },
+ { "Payee" , ICONNAME_HB_PAYEE , N_("_Payees...") , NULL, N_("Configure the payees"), G_CALLBACK (ui_mainwindow_action_defpayee) },
+ { "Category" , ICONNAME_HB_CATEGORY , N_("Categories...") , NULL, N_("Configure the categories"), G_CALLBACK (ui_mainwindow_action_defcategory) },
+ { "Archive" , ICONNAME_HB_ARCHIVE , N_("Scheduled/Template...") , NULL, N_("Configure the scheduled/template transactions"), G_CALLBACK (ui_mainwindow_action_defarchive) },
+ { "Budget" , ICONNAME_HB_BUDGET , N_("Budget...") , NULL, N_("Configure the budget"), G_CALLBACK (ui_mainwindow_action_defbudget) },
+ { "Assign" , ICONNAME_HB_ASSIGN , N_("Assignments..."), NULL, N_("Configure the automatic assignments"), G_CALLBACK (ui_mainwindow_action_defassign) },
+
+ /* TxnMenu */
+ { "ShowOpe" , ICONNAME_HB_OPE_SHOW , N_("Show...") , NULL, N_("Shows selected account transactions"), G_CALLBACK (ui_mainwindow_action_showtransactions) },
+ { "AddOpe" , ICONNAME_HB_OPE_ADD , N_("Add...") , NULL, N_("Add transactions"), G_CALLBACK (ui_mainwindow_action_addtransactions) },
+ { "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) },
/* ReportMenu */
- { "RStatistics" , HB_STOCK_REP_STATS , N_("_Statistics...") , NULL, N_("Open the Statistics report"), G_CALLBACK (ui_mainwindow_action_statistic) },
- { "RTrendTime" , HB_STOCK_REP_TIME , N_("_Trend Time...") , NULL, N_("Open the Trend Time report"), G_CALLBACK (ui_mainwindow_action_trendtime) },
- { "RBudget" , HB_STOCK_REP_BUDGET, N_("B_udget...") , NULL, N_("Open the Budget report"), G_CALLBACK (ui_mainwindow_action_budget) },
- { "RBalance" , HB_STOCK_REP_BALANCE, N_("Balance...") , NULL, N_("Open the Balance report"), G_CALLBACK (ui_mainwindow_action_balance) },
- { "RVehiculeCost" , HB_STOCK_REP_CAR , N_("_Vehicle cost...") , NULL, N_("Open the Vehicle cost report"), G_CALLBACK (ui_mainwindow_action_vehiclecost) },
-
+ { "RStatistics" , ICONNAME_HB_REP_STATS , N_("_Statistics...") , NULL, N_("Open the Statistics report"), G_CALLBACK (ui_mainwindow_action_statistic) },
+ { "RTrendTime" , ICONNAME_HB_REP_TIME , N_("_Trend Time...") , NULL, N_("Open the Trend Time report"), G_CALLBACK (ui_mainwindow_action_trendtime) },
+ { "RBudget" , ICONNAME_HB_REP_BUDGET , N_("B_udget...") , NULL, N_("Open the Budget report"), G_CALLBACK (ui_mainwindow_action_budget) },
+ { "RBalance" , ICONNAME_HB_REP_BALANCE, N_("Balance...") , NULL, N_("Open the Balance report"), G_CALLBACK (ui_mainwindow_action_balance) },
+ { "RVehiculeCost", ICONNAME_HB_REP_CAR , N_("_Vehicle cost...") , NULL, N_("Open the Vehicle cost report"), G_CALLBACK (ui_mainwindow_action_vehiclecost) },
+
+ /* Tools */
+ { "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) },
+
/* HelpMenu */
- { "Contents" , GTK_STOCK_HELP , N_("_Contents") , "F1", N_("Documentation about HomeBank"), G_CALLBACK (ui_mainwindow_action_help) },
- { "Welcome" , NULL , N_("Show welcome dialog...") , NULL, NULL , G_CALLBACK (ui_mainwindow_action_help_welcome) },
- { "Online" , "lpi-help" , N_("Get Help Online...") , NULL, N_("Connect to the LaunchPad website for online help"), G_CALLBACK (ui_mainwindow_action_help_online) },
- { "Translate" , "lpi-translate" , N_("Translate this Application..."), NULL, N_("Connect to the LaunchPad website to help translate this application"), G_CALLBACK (ui_mainwindow_action_help_translate) },
- { "Problem" , "lpi-bug" , N_("Report a Problem...") , NULL, N_("Connect to the LaunchPad website to help fix problems"), G_CALLBACK (ui_mainwindow_action_help_problem) },
+ { "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) },
+
+ { "Updates" , NULL , N_("Check for updates...") , NULL, N_("Visit HomeBank website to check for update"), G_CALLBACK (ui_mainwindow_action_help_updates) },
+ { "ReleaseNotes", NULL , N_("Release Notes") , NULL, N_("Display the release notes"), G_CALLBACK (ui_mainwindow_action_help_releasenotes) },
+ { "Problem" , "lpi-bug" , N_("Report a Problem...") , NULL, N_("Connect to the LaunchPad website to help fix problems"), G_CALLBACK (ui_mainwindow_action_help_problem) },
+ { "Translate" , "lpi-translate" , N_("Translate this Application..."), NULL, N_("Connect to the LaunchPad website to help translate this application"), G_CALLBACK (ui_mainwindow_action_help_translate) },
- { "About" , GTK_STOCK_ABOUT , N_("_About") , NULL, N_("About HomeBank") ,G_CALLBACK (ui_mainwindow_action_about) },
+ { "About" , ICONNAME_ABOUT , N_("_About") , NULL, N_("About HomeBank") ,G_CALLBACK (ui_mainwindow_action_about) },
};
static guint n_entries = G_N_ELEMENTS (entries);
static GtkToggleActionEntry toggle_entries[] = {
-/* name , stockid, label, accelerator, tooltip, callback, is_active */
+/* name , icon-name, label, accelerator, tooltip, callback, is_active */
{ "Toolbar" , NULL , N_("_Toolbar") , NULL, NULL, G_CALLBACK (ui_mainwindow_action_toggle_toolbar), TRUE },
{ "Spending" , NULL , N_("_Top spending") , NULL, NULL, G_CALLBACK (ui_mainwindow_action_toggle_topspending), TRUE },
{ "Upcoming" , NULL , N_("_Scheduled list") , NULL, NULL, G_CALLBACK (ui_mainwindow_action_toggle_upcoming), TRUE },
- { "AsMinor" , NULL , N_("Minor currency"), "<control>M", NULL, G_CALLBACK (ui_mainwindow_action_toggle_minor), FALSE },
+ { "AsMinor" , NULL , N_("Euro minor"), "<control>M", NULL, G_CALLBACK (ui_mainwindow_action_toggle_minor), FALSE },
};
static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);
" <menuitem action='SaveAs'/>"
" <menuitem action='Revert'/>"
" <separator/>"
-" <menuitem action='FileImport'/>"
+" <menuitem action='Properties'/>"
+" <separator/>"
+" <menu action='ImportMenu'>"
+" <menuitem action='ImportQIF'/>"
+" <menuitem action='ImportOFX'/>"
+" <menuitem action='ImportCSV'/>"
+" </menu>"
" <menuitem action='ExportQIF'/>"
//" <separator/>"
// print to come here
" <separator/>"
-" <menuitem action='Properties'/>"
-" <menuitem action='Anonymize'/>"
-" <separator/>"
" <menuitem action='Close'/>"
" <menuitem action='Quit'/>"
" </menu>"
" </menu>"
" <menu action='ViewMenu'>"
" <menuitem action='Toolbar'/>"
+" <separator/>"
" <menuitem action='Spending'/>"
" <menuitem action='Upcoming'/>"
" <separator/>"
" <menuitem action='AsMinor'/>"
" </menu>"
" <menu action='ManageMenu'>"
-//" <menuitem action='Currency'/>"
" <menuitem action='Account'/>"
" <menuitem action='Payee'/>"
" <menuitem action='Category'/>"
-" <menuitem action='Assign'/>"
" <menuitem action='Archive'/>"
" <menuitem action='Budget'/>"
+" <menuitem action='Assign'/>"
+" <menuitem action='Currency'/>"
" </menu>"
-" <menu action='TransactionMenu'>"
+" <menu action='TxnMenu'>"
" <menuitem action='ShowOpe'/>"
" <menuitem action='AddOpe'/>"
" <separator/>"
" <menuitem action='RBudget'/>"
" <menuitem action='RVehiculeCost'/>"
" </menu>"
-" <menu action='HelpMenu'>"
-" <menuitem action='Contents'/>"
-" <separator/>"
+" <menu action='ToolsMenu'>"
" <menuitem action='Welcome'/>"
+" <menuitem action='FileStats'/>"
" <separator/>"
+" <menuitem action='Anonymize'/>"
+" </menu>"
+" <menu action='HelpMenu'>"
+" <menuitem action='Contents'/>"
" <menuitem action='Online'/>"
-" <menuitem action='Translate'/>"
+" <separator/>"
+" <menuitem action='Updates'/>"
+" <menuitem action='ReleaseNotes'/>"
" <menuitem action='Problem'/>"
+" <menuitem action='Translate'/>"
" <separator/>"
" <menuitem action='About'/>"
" </menu>"
" <toolbar name='ToolBar'>"
" <toolitem action='New'/>"
+// here Open + recent is coded
" <toolitem action='Save'/>"
" <separator/>"
-//" <toolitem action='Currency'/>"
" <toolitem action='Account'/>"
" <toolitem action='Payee'/>"
" <toolitem action='Category'/>"
-" <toolitem action='Assign'/>"
" <toolitem action='Archive'/>"
" <toolitem action='Budget'/>"
+" <toolitem action='Assign'/>"
+" <toolitem action='Currency'/>"
" <separator/>"
" <toolitem action='ShowOpe'/>"
" <toolitem action='AddOpe'/>"
"</ui>";
+
/* TODO: a bouger */
void ui_mainwindow_revert(GtkWidget *widget, gpointer user_data)
{
//struct hbfile_data *data;
-GtkWidget *dialog;
gchar *basename;
+gchar *title;
+gchar *secondtext;
gint result;
DB( g_print("\n[ui-mainwindow] revert\n") );
//data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
- basename = g_path_get_basename(GLOBALS->xhb_filepath);
- dialog = gtk_message_dialog_new
- (
- GTK_WINDOW(GLOBALS->mainwindow),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("Revert to the previously saved file of '%s'?"),
- basename
- );
- g_free(basename);
+ basename = g_path_get_basename(GLOBALS->xhb_filepath);
+ title = g_strdup_printf (
+ _("Revert unsaved changes to file '%s'?"), basename);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("- Changes made to the file will be permanently lost\n"
- "- File will be restored to the last save (.xhb~)")
- );
+ secondtext =
+ _("- Changes made to the file will be permanently lost\n"
+ "- File will be reloaded from the last save (.xhb~)");
- gtk_dialog_add_buttons (GTK_DIALOG(dialog),
- GTK_STOCK_CANCEL, 0,
- GTK_STOCK_REVERT_TO_SAVED, 1,
- NULL);
+ result = ui_dialog_msg_confirm_alert(
+ GTK_WINDOW(GLOBALS->mainwindow),
+ title,
+ secondtext,
+ _("_Revert")
+ );
- result = gtk_dialog_run( GTK_DIALOG( dialog ) );
- gtk_widget_destroy( dialog );
+ g_free(title);
+ g_free(basename);
- if( result == 1)
+ if( result == GTK_RESPONSE_OK )
{
DB( g_print(" - should revert\n") );
- hbfile_change_filepath(hb_filename_new_with_extention(GLOBALS->xhb_filepath, "xhb~"));
+ 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_extention(GLOBALS->xhb_filepath, "xhb"));
-
+ hbfile_change_filepath(hb_filename_new_with_extension(GLOBALS->xhb_filepath, "xhb"));
}
}
+
static void
activate_url (GtkAboutDialog *about,
const gchar *link,
static void hbfile_about(void)
{
-GtkWidget *about;
-gchar *pathfilename;
+GtkWidget *dialog;
GdkPixbuf *pixbuf;
-
+gchar *pathfilename;
+gchar *version;
static const gchar *artists[] = {
"Maxime DOYEN",
};
*/
- static const gchar license[] =
- "This program is free software; you can redistribute it and/or modify\n"
- "it under the terms of the GNU General Public License as\n"
- "published by the Free Software Foundation; either version 2 of the\n"
- "License, or (at your option) any later version.\n\n"
- "This program is distributed in the hope that it will be useful,\n"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
- "GNU General Public License for more details.\n\n"
- "You should have received a copy of the GNU General Public License\n"
- "along with this program; if not, write to the Free Software\n"
- "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, "
- "MA 02110-1301, USA.";
+ static const gchar *copyright = "Copyright \xc2\xa9 1995-2018 - Maxime DOYEN";
- static const gchar *copyright = "Copyright \xc2\xa9 1995-2014 - Maxime DOYEN";
- pathfilename = g_build_filename(homebank_app_get_images_dir(), "splash.png", NULL);
- pixbuf = gdk_pixbuf_new_from_file(pathfilename, NULL);
- g_free(pathfilename);
+ version = g_strdup_printf (PACKAGE_VERSION "\n<small>Running against GTK+ %d.%d.%d</small>",
+ gtk_get_major_version (),
+ gtk_get_minor_version (),
+ gtk_get_micro_version ());
+
+ dialog = gtk_about_dialog_new();
- about = gtk_about_dialog_new();
- gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG(about), g_get_application_name ());
- gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about), PACKAGE_VERSION);
- gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about), copyright);
- gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about), _("Free, easy, personal accounting for everyone."));
- gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(about), license);
- //gtk_about_dialog_set_wrap_license(GTK_ABOUT_DIALOG(about), );
- gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about), "http://homebank.free.fr");
- gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(about), "Visit the HomeBank website");
- gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(about), authors);
- gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(about), artists);
- //gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(about), );
- //gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(about), );
- gtk_about_dialog_set_logo_icon_name(GTK_ABOUT_DIALOG(about), "homebank");
- gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(about), pixbuf);
+ gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(GLOBALS->mainwindow));
+ gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
- /*
- gtk_show_about_dialog(GTK_WINDOW(GLOBALS->mainwindow),
- "name", g_get_application_name (),
- "logo-icon-name", "homebank",
- "logo" , pixbuf,
- "artists" , artists,
- "authors" , authors,
- // "translator-credits" , "trans",
- "comments" , _("Free, easy, personal accounting for everyone."),
- "license" , license,
- "copyright" , copyright,
- "version" , PACKAGE_VERSION,
- "website" , "http://homebank.free.fr",
- "website-label", "Visit the HomeBank website",
- NULL);
- */
- g_signal_connect (about, "activate-link", G_CALLBACK (activate_url), NULL);
+ 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");
- gtk_dialog_run (GTK_DIALOG (about));
+ gtk_about_dialog_set_logo_icon_name(GTK_ABOUT_DIALOG(dialog), "homebank");
- gtk_widget_destroy (about);
+ pathfilename = g_build_filename(homebank_app_get_images_dir(), "splash.png", NULL);
+ pixbuf = gdk_pixbuf_new_from_file(pathfilename, NULL);
+ g_free(pathfilename);
- g_object_unref (pixbuf);
-}
+ if( pixbuf )
+ {
+ 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), );
+ //gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(dialog), );
+ g_signal_connect (dialog, "activate-link", G_CALLBACK (activate_url), NULL);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_free(version);
+
+}
/* hbfile action functions -------------------- */
//clear all, and init GLOBALS->xhb_filepath to default
ui_mainwindow_clear(widget, GINT_TO_POINTER(TRUE)); // GPOINTER_TO_INT(
ui_mainwindow_update(widget, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE+UF_REFRESHALL));
+
+ ui_start_assistant();
+ //ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL);
+ //ui_mainwindow_scheduled_populate(GLOBALS->mainwindow, NULL);
+ //ui_mainwindow_populate_topspending(GLOBALS->mainwindow, NULL);
}
}
{
gboolean result;
- //gtk_widget_destroy(GLOBALS->mainwindow);
-
+ //emulate the wm close button
g_signal_emit_by_name(GLOBALS->mainwindow, "delete-event", NULL, &result);
-
- //gtk_main_quit();
}
+static void ui_mainwindow_action_file_statistics(void)
+{
+ ui_dialog_file_statistics();
+}
static void ui_mainwindow_action_properties(void)
static void ui_mainwindow_action_anonymize(void)
{
gint result;
+gchar *title;
+gchar *secondtext;
- result = ui_dialog_msg_question(
- GTK_WINDOW(GLOBALS->mainwindow),
- _("Anonymize the file ?"),
- _("Proceeding will changes name/memo to anonymous datas,\n"
- "please confirm.")
+ title = _("Are you sure you want to anonymize the file?");
+
+ secondtext =
+ _("Proceeding will anonymize any text, \n"
+ "like 'account x', 'payee y', 'memo z', ...");
+
+ result = ui_dialog_msg_confirm_alert(
+ GTK_WINDOW(GLOBALS->mainwindow),
+ title,
+ secondtext,
+ _("_Anonymize")
);
- if( result == GTK_RESPONSE_NO )
- return;
-
- hbfile_anonymize();
- ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE+UF_REFRESHALL));
+ //#1707201
+ //if( result == GTK_RESPONSE_CANCEL )
+ // return;
+ if( result == GTK_RESPONSE_OK )
+ {
+ hbfile_anonymize();
+ ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE+UF_REFRESHALL));
+ }
}
-/*
+
static void ui_mainwindow_action_defcurrency(void)
{
- //ui_cur_manage_dialog();
- ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE));
+ ui_cur_manage_dialog();
+ ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE+UF_REFRESHALL));
}
-*/
+
static void ui_mainwindow_action_defaccount(void)
{
ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE));
}
-static void ui_mainwindow_action_defarchive(void)
+
+static void ui_mainwindow_defarchive(Archive *arc)
{
struct hbfile_data *data;
GtkTreeModel *model;
model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_upc));
gtk_list_store_clear (GTK_LIST_STORE(model));
- ui_arc_manage_dialog();
+ ui_arc_manage_dialog(arc);
ui_mainwindow_scheduled_populate(GLOBALS->mainwindow, NULL);
}
+static void ui_mainwindow_action_defarchive(void)
+{
+ ui_mainwindow_defarchive(NULL);
+}
+
+
static void ui_mainwindow_action_defbudget(void)
{
ui_bud_manage_dialog();
// top spending
gtk_chart_show_minor(GTK_CHART(data->RE_pie), GLOBALS->minor);
- hb_label_set_amount(GTK_LABEL(data->TX_topamount), data->toptotal, GLOBALS->minor);
+
+ ui_panel_topspending_update(data->window, data);
}
repcost_window_new();
}
-static void ui_mainwindow_action_import(void)
+static void ui_mainwindow_action_import(GtkAction *action)
{
- ui_import_window_new();
+const gchar *name;
+gint filetype = FILETYPE_UNKNOW;
+
+ name = gtk_action_get_name(action);
+
+ if( g_str_has_suffix (name, "QIF"))
+ filetype= FILETYPE_QIF;
+ else
+ if( g_str_has_suffix (name, "OFX"))
+ filetype= FILETYPE_OFX;
+ else
+ if( g_str_has_suffix (name, "CSV"))
+ filetype= FILETYPE_CSV_HB;
+
+ DB( g_print("action %s type=%d\n", name, filetype) );
+ ui_import_assistant_new(filetype);
}
}
+
static void ui_mainwindow_action_export(void)
{
gchar *filename;
}
}
+
static void ui_mainwindow_action_help(void)
{
gchar *link;
link = g_build_filename("file:///", homebank_app_get_help_dir(), HOMEBANK_URL_HELP, NULL );
homebank_util_url_show (link);
+ g_free(link);
+}
+
+
+static void ui_mainwindow_action_help_releasenotes(void)
+{
+gchar *link;
+ #ifdef G_OS_WIN32
+ link = g_build_filename("file:///", homebank_app_get_datas_dir(), "ChangeLog.txt", NULL );
+ #else
+ link = g_build_filename("file:///", homebank_app_get_datas_dir(), "ChangeLog", NULL );
+ #endif
+ homebank_util_url_show (link);
g_free(link);
}
void ui_mainwindow_action_help_welcome(void)
{
-GtkWidget *dialog, *content;
+GtkWidget *dialog, *content_area;
GtkWidget *mainvbox, *widget, *label;
dialog = gtk_dialog_new_with_buttons (_("Welcome to HomeBank"),
GTK_WINDOW(GLOBALS->mainwindow),
0,
- GTK_STOCK_CLOSE,
+ _("_Close"),
GTK_RESPONSE_ACCEPT,
NULL);
- content = gtk_dialog_get_content_area(GTK_DIALOG (dialog));
+ content_area = gtk_dialog_get_content_area(GTK_DIALOG (dialog));
- mainvbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (content), mainvbox, FALSE, FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER(mainvbox), HB_MAINBOX_SPACING);
+ 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);
label = make_label (_("HomeBank"), 0, 0);
gimp_label_set_attributes(GTK_LABEL(label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1);
gtk_box_pack_start (GTK_BOX (mainvbox), label, FALSE, FALSE, 0);
- label = make_label (_("Free, easy, personal accounting for everyone."), 0, 0);
+ label = make_label (_("Free, easy, personal accounting for everyone"), 0, 0);
gtk_box_pack_start (GTK_BOX (mainvbox), label, FALSE, FALSE, 0);
- widget = gtk_hseparator_new();
- gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
+ widget = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
+ gtk_box_pack_start (GTK_BOX (content_area), widget, FALSE, FALSE, 0);
- mainvbox = gtk_vbox_new (FALSE, HB_MAINBOX_SPACING);
- gtk_box_pack_start (GTK_BOX (content), mainvbox, TRUE, TRUE, 0);
- gtk_container_set_border_width (GTK_CONTAINER(mainvbox), HB_MAINBOX_SPACING);
+ mainvbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, SPACING_MEDIUM);
+ gtk_box_pack_start (GTK_BOX (content_area), mainvbox, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER(mainvbox), SPACING_MEDIUM);
label = make_label (_("What do you want to do:"), 0, 0);
gimp_label_set_attributes(GTK_LABEL(label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1);
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"));
+ 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);
}
+static void ui_mainwindow_action_help_updates(void)
+{
+const gchar *link = HOMEBANK_URL_HELP_UPDATES;
+
+ homebank_util_url_show (link);
+}
+
static void ui_mainwindow_action_help_online(void)
{
const gchar *link = HOMEBANK_URL_HELP_ONLINE;
homebank_util_url_show (link);
-
}
+
static void ui_mainwindow_action_help_translate(void)
{
const gchar *link = HOMEBANK_URL_HELP_TRANSLATE;
homebank_util_url_show (link);
-
}
+
static void ui_mainwindow_action_help_problem(void)
{
const gchar *link = HOMEBANK_URL_HELP_PROBLEM;
homebank_util_url_show (link);
-
}
-
-
/* hbfile functions -------------------- */
-
-
/*
**
*/
*/
void ui_mainwindow_clear(GtkWidget *widget, gpointer user_data)
{
-//struct hbfile_data *data;
+struct hbfile_data *data;
gboolean file_clear = GPOINTER_TO_INT(user_data);
DB( g_print("\n[ui-mainwindow] clear\n") );
- //data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
+ data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
// Close opened account window
// Clear TreeView
ui_mainwindow_close_openbooks();
- //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))));
+ 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_panel_accounts_setup(data);
hbfile_cleanup(file_clear);
hbfile_setup(file_clear);
- if(file_clear == TRUE)
- {
- ui_start_assistant();
- ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL);
- ui_mainwindow_scheduled_populate(GLOBALS->mainwindow, NULL);
- ui_mainwindow_populate_topspending(GLOBALS->mainwindow, NULL);
- }
-
}
GtkWidget *window;
gint result = 1;
guint32 date;
-gint account = 1, count;
+gint account, count;
DB( g_print("\n[ui-mainwindow] add transactions\n") );
/* init the transaction */
date = homebank_app_date_get_julian();
+
+ //#1656531
+ account = 0;
if(data->acc != NULL)
account = data->acc->key;
- window = create_deftransaction_window(GTK_WINDOW(data->window), TRANSACTION_EDIT_ADD);
+ window = create_deftransaction_window(GTK_WINDOW(data->window), TRANSACTION_EDIT_ADD, FALSE);
count = 0;
- while(result == GTK_RESPONSE_ADD)
+ while(result == GTK_RESPONSE_ADD || result == GTK_RESPONSE_ADDKEEP)
{
Transaction *ope;
/* fill in the transaction */
- ope = da_transaction_malloc();
- ope->date = date;
- ope->kacc = account;
+ if( result == GTK_RESPONSE_ADD )
+ {
+ ope = da_transaction_malloc();
+ ope->date = date;
+ ope->kacc = account;
+
+ if( PREFS->heritdate == FALSE ) //fix: 318733
+ ope->date = GLOBALS->today;
+ }
- if( PREFS->heritdate == FALSE ) //fix: 318733
- ope->date = GLOBALS->today;
+ // normally we can't be in addkeep without initialized ope with add
deftransaction_set_transaction(window, ope);
result = gtk_dialog_run (GTK_DIALOG (window));
- DB( g_print(" -> dialog result is %d\n", result) );
+ DB( g_print(" - dialog result is %d\n", result) );
- if(result == GTK_RESPONSE_ADD || result == GTK_RESPONSE_ACCEPT)
+ if(result == GTK_RESPONSE_ADD || result == GTK_RESPONSE_ADDKEEP || result == GTK_RESPONSE_ACCEPT)
{
deftransaction_get(window, NULL);
- transaction_add(ope, NULL, ope->kacc);
+ transaction_add(ope);
- DB( g_print(" -> added 1 transaction to %d\n", ope->kacc) );
+ DB( g_print(" - added 1 transaction to %d\n", ope->kacc) );
ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL);
count++;
- //store last date
+ //todo: still usefull ? store last date
date = ope->date;
}
- da_transaction_free(ope);
- ope = NULL;
+ if( result == GTK_RESPONSE_ADD )
+ {
+ da_transaction_free(ope);
+ ope = NULL;
+ }
}
gdouble value;
};
+
+#define MAX_TOPSPENDING 10
+
+
static gint tmptop_compare_func(struct tmptop *tt1, struct tmptop *tt2)
{
return tt1->value > tt2->value ? 1 : -1;
}
+static void ui_panel_topspending_update(GtkWidget *widget, gpointer user_data)
+{
+struct hbfile_data *data;
+GtkTreeModel *model;
+gchar *title;
+gchar strbuffer[G_ASCII_DTOSTR_BUF_SIZE];
+
+ DB( g_print("\n[ui-mainwindow] topspending_update\n") );
+
+ data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
+
+ hb_strfmon(strbuffer, G_ASCII_DTOSTR_BUF_SIZE-1, data->toptotal, GLOBALS->kcur, GLOBALS->minor);
+ //hb_label_set_amount(GTK_LABEL(data->TX_topamount), total, GLOBALS->kcur, GLOBALS->minor);
+ title = g_strdup_printf("%s %s", _("Top spending"), strbuffer);
+
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_top));
+
+ gtk_chart_set_color_scheme(GTK_CHART(data->RE_pie), PREFS->report_color_scheme);
+ gtk_chart_set_currency(GTK_CHART(data->RE_pie), GLOBALS->kcur);
+ gtk_chart_set_datas(GTK_CHART(data->RE_pie), model, LST_TOPSPEND_AMOUNT, title, NULL);
+
+ g_free(title);
+
+ //future usage
+ gchar *fu = _("Top %d spending"); title = fu;
+}
+
+
static void ui_mainwindow_populate_topspending(GtkWidget *widget, gpointer user_data)
{
struct hbfile_data *data;
GtkTreeModel *model;
GtkTreeIter iter;
GList *list;
-gint range;
+gint type, range;
guint n_result, i, n_items;
GArray *garray;
gdouble total, other;
-//Account *acc;
+Account *acc;
-#define MAX_TOPSPENDING 5
DB( g_print("\n[ui-mainwindow] populate_topspending\n") );
data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
+ type = radio_get_active(GTK_CONTAINER(data->RA_type));
range = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_range));
- DB( g_print(" - range=%d\n", range) );
+ DB( g_print(" - type=%d, range=%d\n", type, range) );
DB( g_print(" - pref range=%d\n", PREFS->date_range_wal) );
if(range == FLT_RANGE_OTHER)
return;
- filter_preset_daterange_set(data->filter, range);
+ filter_preset_daterange_set(data->filter, range, 0);
n_result = da_cat_get_max_key() + 1;
if(garray)
{
struct tmptop zero = { .key=0, .value=0.0 };
+ GQueue *txn_queue;
//DB( g_print(" - array length=%d\n", garray->len) );
//DB( g_print("\n - end array length=%d\n", garray->len) );
+ //todo: not ideal, has ot force to get_acc for each txn below
+ txn_queue = hbfile_transaction_get_partial(data->filter->mindate, data->filter->maxdate);
+
/* compute the results */
- list = g_list_first(GLOBALS->ope_list);
+ list = g_queue_peek_head_link(txn_queue);
while (list != NULL)
{
Transaction *ope = list->data;
- Account *acc;
- //debug
- //DB( g_print(" - eval txn: '%s', cat=%d ==> flt-test=%d\n", ope->wording, ope->kcat, filter_test(data->filter, ope)) );
- acc = da_acc_get(ope->kacc);
- if(acc == NULL) goto next1;
- if((acc->flags & (AF_CLOSED|AF_NOREPORT))) goto next1;
- if(ope->paymode == PAYMODE_INTXFER) goto next1;
-
- if( !(ope->flags & OF_REMIND) )
+
+ //DB( g_print(" - eval txn: '%s', cat=%d ==> flt-test=%d\n", ope->memo, ope->kcat, filter_test(data->filter, ope)) );
+
+ if( !(ope->paymode == PAYMODE_INTXFER) )
{
- if( (ope->date >= data->filter->mindate) && (ope->date <= data->filter->maxdate) )
- {
- guint32 pos = 0;
- gdouble trn_amount;
+ guint32 pos = 0;
+ gdouble trn_amount;
- //trn_amount = to_base_amount(ope->amount, acc->kcur);
- trn_amount = ope->amount;
+ //todo: optimize here
+ trn_amount = ope->amount;
+ acc = da_acc_get(ope->kacc);
+ if(acc)
+ trn_amount = hb_amount_base(ope->amount, acc->kcur);
- if( ope->flags & OF_SPLIT )
- {
- guint nbsplit = da_transaction_splits_count(ope);
- Split *split;
- struct tmptop *item;
-
- for(i=0;i<nbsplit;i++)
- {
- split = ope->splits[i];
- Category *catentry = da_cat_get(split->kcat);
- if(catentry)
- pos = (catentry->flags & GF_SUB) ? catentry->parent : catentry->key;
-
- //trn_amount = to_base_amount(split->amount, acc->kcur);
- trn_amount = split->amount;
- //#1297054 if( trn_amount < 0 ) {
- item = &g_array_index (garray, struct tmptop, pos);
- item->key = pos;
- item->value += trn_amount;
- DB( g_print(" - stored %.2f to item %d\n", trn_amount, pos) );
- //}
- }
- }
- else
+ if( ope->flags & OF_SPLIT )
+ {
+ guint nbsplit = da_splits_count(ope->splits);
+ Split *split;
+ struct tmptop *item;
+
+ for(i=0;i<nbsplit;i++)
{
- Category *catentry = da_cat_get(ope->kcat);
- struct tmptop *item;
+ split = ope->splits[i];
+ pos = category_report_id(split->kcat, type);
- if(catentry)
- pos = (catentry->flags & GF_SUB) ? catentry->parent : catentry->key;
-
+ trn_amount = hb_amount_base(split->amount, acc->kcur);
+ //trn_amount = split->amount;
//#1297054 if( trn_amount < 0 ) {
item = &g_array_index (garray, struct tmptop, pos);
item->key = pos;
item->value += trn_amount;
- DB( g_print(" - stored %.2f to item %d\n", trn_amount, pos) );
+ //DB( g_print(" - stored %.2f to item %d\n", trn_amount, pos) );
//}
}
+ }
+ else
+ {
+ struct tmptop *item;
+ pos = category_report_id(ope->kcat, type);
+
+ //#1297054 if( trn_amount < 0 ) {
+ item = &g_array_index (garray, struct tmptop, pos);
+ item->key = pos;
+ item->value += trn_amount;
+ //DB( g_print(" - stored %.2f to item %d\n", trn_amount, pos) );
+ //}
}
+
+
}
-next1:
+
list = g_list_next(list);
}
+ g_queue_free (txn_queue);
// we need to sort this and limit before
g_array_sort(garray, (GCompareFunc)tmptop_compare_func);
if(!item->value) continue;
- value = arrondi(item->value, 2);
+ value = hb_amount_round(item->value, 2);
entry = da_cat_get(item->key);
if(entry == NULL) continue;
- name = entry->key == 0 ? _("(no category)") : entry->name;
+ name = entry->key == 0 ? _("(no category)") : da_cat_get_fullname(entry);
// append test
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_top), model);
g_object_unref(model);
- data->toptotal = total;
- hb_label_set_amount(GTK_LABEL(data->TX_topamount), total, GLOBALS->minor);
-
- gtk_chart_set_color_scheme(GTK_CHART(data->RE_pie), PREFS->report_color_scheme);
- gtk_chart_set_datas(GTK_CHART(data->RE_pie), model, LST_TOPSPEND_AMOUNT, NULL);
- //gtk_chart_show_legend(GTK_CHART(data->RE_pie), FALSE);
-
- /* update info range text */
+
+ // update chart and widgets
{
gchar *daterange;
-
+
+ data->toptotal = total;
+ ui_panel_topspending_update(widget, data);
+
daterange = filter_daterange_text_get(data->filter);
gtk_widget_set_tooltip_markup(GTK_WIDGET(data->CY_range), daterange);
g_free(daterange);
}
+static void ui_mainwindow_scheduled_onRowActivated (GtkTreeView *treeview,
+ GtkTreePath *path,
+ GtkTreeViewColumn *col,
+ gpointer userdata)
+{
+//struct hbfile_data *data;
+Archive *arc;
+
+ DB( g_print ("\n[ui-mainwindow] A scheduled row has been double-clicked!\n") );
+
+ //data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(treeview, GTK_TYPE_WINDOW)), "inst_data");
+
+ arc = ui_mainwindow_scheduled_get_selected_item(treeview);
+ ui_mainwindow_defarchive(arc);
+}
+
+
+static void ui_mainwindow_scheduled_do_post(Archive *arc, gboolean doedit, gpointer user_data)
+{
+struct hbfile_data *data = user_data;
+GtkWidget *window;
+gint result;
+Transaction *txn;
+
+ window = create_deftransaction_window(GTK_WINDOW(data->window), TRANSACTION_EDIT_ADD, TRUE);
+
+ /* fill in the transaction */
+ txn = da_transaction_malloc();
+ da_transaction_init_from_template(txn, arc);
+ txn->date = scheduled_get_postdate(arc, arc->nextdate);
+
+ deftransaction_set_transaction(window, txn);
+
+ result = gtk_dialog_run (GTK_DIALOG (window));
+
+ DB( g_print(" - dialog result is %d\n", result) );
+
+ if(result == GTK_RESPONSE_ADD || result == GTK_RESPONSE_ACCEPT)
+ {
+ deftransaction_get(window, NULL);
+ transaction_add(txn);
+ GLOBALS->changes_count++;
+
+ scheduled_date_advance(arc);
+
+ DB( g_print(" - added 1 transaction to %d\n", txn->kacc) );
+ }
+
+ da_transaction_free(txn);
+
+ deftransaction_dispose(window, NULL);
+ gtk_widget_destroy (window);
+
+}
+
+
+static void ui_mainwindow_scheduled_editpost_cb(GtkWidget *widget, gpointer user_data)
+{
+struct hbfile_data *data = user_data;
+
+ Archive *arc = ui_mainwindow_scheduled_get_selected_item(GTK_TREE_VIEW(data->LV_upc));
+
+ if( (arc != NULL) )
+ {
+ ui_mainwindow_scheduled_do_post(arc, TRUE, data);
+ ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_SENSITIVE|UF_REFRESHALL));
+ }
+}
+
+
static void ui_mainwindow_scheduled_post_cb(GtkWidget *widget, gpointer user_data)
{
struct hbfile_data *data = user_data;
+ DB( g_print("\n[ui-mainwindow] scheduled post\n") );
+
Archive *arc = ui_mainwindow_scheduled_get_selected_item(GTK_TREE_VIEW(data->LV_upc));
if( (arc != NULL) )
da_transaction_init_from_template(txn, arc);
txn->date = scheduled_get_postdate(arc, arc->nextdate);
- transaction_add(txn, NULL, 0);
+ transaction_add(txn);
+
GLOBALS->changes_count++;
-
scheduled_date_advance(arc);
da_transaction_free (txn);
}
else
{
- GtkWidget *window = create_deftransaction_window(GTK_WINDOW(data->window), TRANSACTION_EDIT_ADD);
- gint result;
- Transaction *txn;
-
- /* fill in the transaction */
- txn = da_transaction_malloc();
- da_transaction_init_from_template(txn, arc);
- txn->date = scheduled_get_postdate(arc, arc->nextdate);
-
- deftransaction_set_transaction(window, txn);
-
- result = gtk_dialog_run (GTK_DIALOG (window));
-
- DB( g_print(" -> dialog result is %d\n", result) );
-
- if(result == GTK_RESPONSE_ADD || result == GTK_RESPONSE_ACCEPT)
- {
- deftransaction_get(window, NULL);
- transaction_add(txn, NULL, txn->kacc);
- GLOBALS->changes_count++;
-
- scheduled_date_advance(arc);
-
- DB( g_print(" -> added 1 transaction to %d\n", txn->kacc) );
- }
-
- da_transaction_free(txn);
-
- deftransaction_dispose(window, NULL);
- gtk_widget_destroy (window);
-
+ ui_mainwindow_scheduled_do_post(arc, FALSE, data);
}
- ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_REFRESHALL));
-
+ ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_SENSITIVE|UF_REFRESHALL));
}
-
-
-
}
Archive *arc = ui_mainwindow_scheduled_get_selected_item(GTK_TREE_VIEW(data->LV_upc));
if( (arc != NULL) && (arc->flags & OF_AUTO) )
{
+ GLOBALS->changes_count++;
scheduled_date_advance(arc);
ui_mainwindow_scheduled_populate(GLOBALS->mainwindow, NULL);
+ ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_SENSITIVE));
}
}
if(arc)
{
- DB( g_print("archive is %s\n", arc->wording) );
+ DB( g_print("archive is %s\n", arc->memo) );
- gtk_widget_set_sensitive(GTK_WIDGET(data->BT_sched_post), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(data->BT_sched_skip), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(data->BT_sched_post), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(data->BT_sched_editpost), TRUE);
}
else
{
- gtk_widget_set_sensitive(GTK_WIDGET(data->BT_sched_post), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(data->BT_sched_skip), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(data->BT_sched_post), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(data->BT_sched_editpost), FALSE);
}
}
while (list != NULL)
{
Archive *arc = list->data;
+ Account *acc;
+ gdouble inc, exp;
guint nbdays, nblate;
if((arc->flags & OF_AUTO) ) //&& arc->kacc > 0)
nbdays = arc->nextdate - maxpostdate;
nblate = scheduled_get_latepost_count(arc, GLOBALS->today);
- DB( g_print(" - append '%s' : %d\n", arc->wording, nbdays) );
+ DB( g_print(" - append '%s' : %d\n", arc->memo, nbdays) );
+
+ if(arc->flags & OF_INCOME)
+ {
+ inc = arc->amount;
+ exp = 0.0;
+ }
+ else
+ {
+ exp = arc->amount;
+ inc = 0.0;
+ }
+ /* insert normal txn */
+ acc = da_acc_get(arc->kacc);
+ if( acc)
+ {
+ totinc += hb_amount_base(inc, acc->kcur);
+ totexp += hb_amount_base(exp, acc->kcur);
+ }
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
gtk_list_store_set (GTK_LIST_STORE(model), &iter,
LST_DSPUPC_DATAS, arc,
- LST_DSPUPC_WORDING, arc->wording,
- LST_DSPUPC_EXPENSE, !(arc->flags & OF_INCOME) ? arc->amount : 0.0,
- LST_DSPUPC_INCOME, (arc->flags & OF_INCOME) ? arc->amount : 0.0,
+ LST_DSPUPC_ACCOUNT, acc,
+ LST_DSPUPC_MEMO, arc->memo,
+ LST_DSPUPC_EXPENSE, exp,
+ LST_DSPUPC_INCOME, inc,
LST_DSPUPC_REMAINING, nbdays,
LST_DSPUPC_NB_LATE, nblate,
-1);
- //acc = da_acc_get(arc->kacc);
- //total += to_base_amount(arc->amount, acc->kcur);
- if(arc->flags & OF_INCOME)
- totinc += arc->amount;
- else
- totexp += arc->amount;
+ /* insert internal xfer txn : 1378836 */
+ if(arc->paymode == PAYMODE_INTXFER)
+ {
+ acc = da_acc_get(arc->kxferacc);
+ if( acc)
+ {
+ totinc += hb_amount_base(-inc, acc->kcur);
+ totexp += hb_amount_base(-exp, acc->kcur);
+ }
+ gtk_list_store_append (GTK_LIST_STORE(model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE(model), &iter,
+ LST_DSPUPC_DATAS, arc,
+ LST_DSPUPC_ACCOUNT, acc,
+ LST_DSPUPC_MEMO, arc->memo,
+ LST_DSPUPC_EXPENSE, -inc,
+ LST_DSPUPC_INCOME, -exp,
+ LST_DSPUPC_REMAINING, nbdays,
+ LST_DSPUPC_NB_LATE, nblate,
+ -1);
+ }
}
list = g_list_next(list);
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
gtk_list_store_set (GTK_LIST_STORE(model), &iter,
LST_DSPUPC_DATAS, NULL,
- LST_DSPUPC_WORDING, _("Total"),
+ LST_DSPUPC_ACCOUNT, NULL,
+ LST_DSPUPC_MEMO, _("Total"),
LST_DSPUPC_EXPENSE, totexp,
LST_DSPUPC_INCOME, totinc,
-1);
}
-
ui_mainwindow_scheduled_update(widget, NULL);
}
+gboolean ui_mainwindow_open_backup_check_confirm(gchar *filepath)
+{
+gboolean retval = FALSE;
+gchar *basename, *secondtext;
+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);
+
+ result = ui_dialog_msg_confirm_alert(
+ GTK_WINDOW(GLOBALS->mainwindow),
+ _("Open a backup file ?"),
+ secondtext,
+ _("_Open backup")
+ );
+
+ g_free(secondtext);
+ g_free(basename);
+
+ if( result == GTK_RESPONSE_OK )
+ retval = TRUE;
+
+ return retval;
+}
/*
if( ui_dialog_msg_savechanges(widget,NULL) == TRUE )
{
- if(ui_file_chooser_xhb(GTK_FILE_CHOOSER_ACTION_OPEN, &filename) == TRUE)
+ if( ui_file_chooser_xhb(GTK_FILE_CHOOSER_ACTION_OPEN, &filename) == TRUE )
{
- hbfile_change_filepath(filename);
+ //#1710955 test for backup open
+ if( hbfile_file_isbackup(filename) )
+ {
+ if( ui_mainwindow_open_backup_check_confirm(filename) == TRUE )
+ {
+ GLOBALS->hbfile_is_bak = TRUE;
+ }
+ else
+ {
+ g_free(filename);
+ return;
+ }
+ }
+ hbfile_change_filepath(filename);
ui_mainwindow_open_internal(widget, NULL);
-
-
}
}
}
+
/*
* open the file stored in GLOBALS->xhb_filepath
*/
data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
- DB( g_print(" -> filename: '%s'\n", GLOBALS->xhb_filepath) );
-
if( GLOBALS->xhb_filepath != NULL )
{
+ DB( g_print(" - filename: '%s'\n", GLOBALS->xhb_filepath) );
+
ui_mainwindow_clear(GLOBALS->mainwindow, GINT_TO_POINTER(FALSE));
GLOBALS->hbfile_is_new = FALSE;
r = homebank_load_xml(GLOBALS->xhb_filepath);
if( r == XML_OK )
{
- DB( g_print(" -> file loaded ok : rcode=%d\n", r) );
+ DB( g_print(" - file loaded ok : rcode=%d\n", r) );
hbfile_file_hasbackup(GLOBALS->xhb_filepath);
if(PREFS->appendscheduled)
scheduled_post_all_pending();
+ if(PREFS->do_update_currency)
+ ui_cur_manage_dialog_update_currencies(GTK_WINDOW(GLOBALS->mainwindow));
+
homebank_lastopenedfiles_save();
- //todo: remove this after computing done at xml read
+ //todo: delete this after computing done at xml read
account_compute_balances();
ui_mainwindow_recent_add(data, GLOBALS->xhb_filepath);
- ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL);
- ui_mainwindow_scheduled_populate(GLOBALS->mainwindow, NULL);
- ui_mainwindow_populate_topspending(GLOBALS->mainwindow, NULL);
}
else
{
}
+ ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL);
+ ui_mainwindow_scheduled_populate(GLOBALS->mainwindow, NULL);
+ ui_mainwindow_populate_topspending(GLOBALS->mainwindow, NULL);
ui_mainwindow_update(GLOBALS->mainwindow, GINT_TO_POINTER(UF_TITLE+UF_SENSITIVE+UF_VISUAL));
}
}
+
/*
**
*/
if( GLOBALS->hbfile_is_new == TRUE )
saveas = 1;
+ //#1710955 test for backup open
+ if( GLOBALS->hbfile_is_bak == TRUE )
+ {
+ //todo: later for backup, should also remove datetime and .bak
+ hbfile_change_filepath(hb_filename_new_with_extension(GLOBALS->xhb_filepath, "xhb"));
+ saveas = 1;
+ }
+
if(saveas == 1)
{
if(ui_file_chooser_xhb(GTK_FILE_CHOOSER_ACTION_SAVE, &filename) == TRUE)
{
- DB( g_print(" + should save as %s\n", GLOBALS->xhb_filepath) );
- hbfile_change_filepath(filename);
- homebank_backup_current_file(GLOBALS->xhb_filepath);
- homebank_file_ensure_xhb();
+ DB( g_print(" + should save as '%s'\n", filename) );
+ homebank_file_ensure_xhb(filename);
+ homebank_backup_current_file();
r = homebank_save_xml(GLOBALS->xhb_filepath);
GLOBALS->hbfile_is_new = FALSE;
+ GLOBALS->hbfile_is_bak = FALSE;
}
else
return;
else
{
DB( g_print(" + should quick save %s\n", GLOBALS->xhb_filepath) );
- homebank_backup_current_file(GLOBALS->xhb_filepath);
- homebank_file_ensure_xhb();
+ homebank_file_ensure_xhb(NULL);
+ homebank_backup_current_file();
r = homebank_save_xml(GLOBALS->xhb_filepath);
}
}
else
{
- gchar *msg = _("I/O error for file %s.");
+ gchar *msg = _("I/O error for file '%s'.");
ui_dialog_msg_infoerror(GTK_WINDOW(data->window), GTK_MESSAGE_ERROR,
_("File error"),
}
+static void ui_panel_accounts_expand_all(GtkWidget *widget, gpointer user_data)
+{
+struct hbfile_data *data;
+
+ data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
+ gtk_tree_view_expand_all(GTK_TREE_VIEW(data->LV_acc));
+}
+
+
+static void ui_panel_accounts_collapse_all(GtkWidget *widget, gpointer user_data)
+{
+struct hbfile_data *data;
+
+ data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
+ gtk_tree_view_collapse_all(GTK_TREE_VIEW(data->LV_acc));
+}
+
+
+
+static GHashTable *ui_panel_accounts_groups_get(GList *lacc, gint groupby, gboolean showall)
+{
+GHashTable *hash;
+GList *elt;
+gchar *groupname;
+gint nballoc;
+
+ DB( g_print("\n[ui-mainwindow] accounts_groups_get\n") );
+
+ nballoc = da_acc_length ();
+
+ DB( g_print(" %d accounts\n", nballoc) );
+
+ hash = g_hash_table_new_full(g_str_hash, g_str_equal, (GDestroyNotify)g_free, NULL);
+ elt = g_list_first(lacc);
+ while (elt != NULL)
+ {
+ Account *acc = elt->data;
+ GPtrArray *group;
+
+ //#1674045 ony rely on nosummary
+ //if( showall || !(acc->flags & (AF_CLOSED|AF_NOSUMMARY)) )
+ if( showall || !(acc->flags & AF_NOSUMMARY) )
+ {
+ if( groupby == DSPACC_GROUP_BY_BANK )
+ {
+ groupname = _("(no institution)");
+ if( (acc->bankname != NULL) && strlen(acc->bankname) > 0 )
+ groupname = acc->bankname;
+ }
+ else
+ {
+ //pre 5.1.3 historical by type display
+ groupname = _(CYA_ACC_TYPE[acc->type]);
+ }
+
+ if( g_hash_table_contains(hash, groupname) == FALSE )
+ {
+ g_hash_table_insert(hash, g_strdup(groupname), g_ptr_array_sized_new(nballoc) );
+ //DB( g_print(" - type hash insert '%s' = %d\n", groupname, inserted) );
+ }
+
+ group = g_hash_table_lookup(hash, groupname);
+ if( group != NULL )
+ {
+ g_ptr_array_add(group, (gpointer)acc);
+ DB( g_print(" -- add '%s' to group '%s'\n", acc->name, groupname) );
+ }
+ }
+ elt = g_list_next(elt);
+ }
+
+ return hash;
+}
+
+
+
+
+
+
void ui_mainwindow_populate_accounts(GtkWidget *widget, gpointer user_data)
{
struct hbfile_data *data;
GtkTreeIter iter1, child_iter;
GList *lacc, *elt;
Account *acc;
-guint i, j, nbtype;
+guint j, nbtype;
gdouble gtbank, gttoday, gtfuture;
+GHashTable *h_group;
+GHashTableIter grp_iter;
+gpointer key, value;
+
DB( g_print("\n[ui-mainwindow] populate accounts\n") );
data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
/* here we create a count and a list of every account pointer by type */
-
- GPtrArray *typeacc[ACC_TYPE_MAXVALUE] = {0};
lacc = elt = g_hash_table_get_values(GLOBALS->h_acc);
- while (elt != NULL)
- {
- acc = elt->data;
- //#1339572
- if( !(acc->flags & (AF_CLOSED|AF_NOSUMMARY)) )
- {
- DB( g_print(" -> insert %d:%s\n", acc->key, acc->name) );
-
- if(typeacc[acc->type] == NULL)
- typeacc[acc->type] = g_ptr_array_sized_new(da_acc_length ());
-
- g_ptr_array_add(typeacc[acc->type], (gpointer)acc);
- }
- elt = g_list_next(elt);
- }
+
+ h_group = ui_panel_accounts_groups_get(lacc, PREFS->pnl_acc_show_by, data->showall);
g_list_free(lacc);
- gtbank = gttoday = gtfuture = 0;
- DB( g_print(" -> populate listview\n") );
+ gtbank = gttoday = gtfuture = 0;
+ DB( g_print(" - populate listview, %d group(s)\n", g_hash_table_size(h_group)) );
- /* then populate the listview */
model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_acc));
gtk_tree_store_clear (GTK_TREE_STORE(model));
nbtype = 0;
- for(i=0;i<ACC_TYPE_MAXVALUE;i++)
+ g_hash_table_iter_init (&grp_iter, h_group);
+ while (g_hash_table_iter_next (&grp_iter, &key, &value))
{
- GPtrArray *gpa = typeacc[i];
+ GPtrArray *gpa = value;
gdouble tbank, ttoday, tfuture;
+ gint position;
if(gpa != NULL)
{
nbtype++;
//1: Header: Bank, Cash, ...
- DB( g_print(" -> append type '%s'\n", CYA_ACC_TYPE[i]) );
+ DB( g_print(" - add group '%s'\n", (gchar *)key) );
+
+ //#1663399 keep type position like in dropdown
+ position = 0;
+ if( PREFS->pnl_acc_show_by == DSPACC_GROUP_BY_TYPE )
+ {
+ gint t = 0;
+
+ while(CYA_ACC_TYPE[t] != NULL && t < 15)
+ {
+ if( !strcmp(CYA_ACC_TYPE[t], key) )
+ break;
+ t++;
+ }
+
+ position = t;
+ }
gtk_tree_store_append (GTK_TREE_STORE(model), &iter1, NULL);
gtk_tree_store_set (GTK_TREE_STORE(model), &iter1,
+ LST_DSPACC_POS, position,
LST_DSPACC_DATATYPE, DSPACC_TYPE_HEADER,
- LST_DSPACC_NAME, _(CYA_ACC_TYPE[i]),
+ LST_DSPACC_NAME, key,
-1);
tbank = ttoday = tfuture = 0;
{
acc = g_ptr_array_index(gpa, j);
- //if(acc->kcur == GLOBALS->kcur)
- //{
- tbank += acc->bal_bank;
- ttoday += acc->bal_today;
- tfuture += acc->bal_future;
- /*}
- else
- {
- tbank += to_base_amount(acc->bal_bank, acc->kcur);
- ttoday += to_base_amount(acc->bal_today, acc->kcur);
- tfuture += to_base_amount(acc->bal_future, acc->kcur);
- }*/
+ //tbank += acc->bal_bank;
+ //ttoday += acc->bal_today;
+ //tfuture += acc->bal_future;
+ tbank += hb_amount_base(acc->bal_bank, acc->kcur);
+ ttoday += hb_amount_base(acc->bal_today, acc->kcur);
+ tfuture += hb_amount_base(acc->bal_future, acc->kcur);
- DB( g_print(" - insert '%s' :: %.2f %.2f %.2f\n", acc->name, acc->bal_bank, acc->bal_today, acc->bal_future) );
+ DB( g_print(" - add account '%s' :: %.2f %.2f %.2f\n", acc->name, acc->bal_bank, acc->bal_today, acc->bal_future) );
gtk_tree_store_append (GTK_TREE_STORE(model), &child_iter, &iter1);
gtk_tree_store_set (GTK_TREE_STORE(model), &child_iter,
if(gpa->len > 1)
{
- DB( g_print(" - type totals :: %.2f %.2f %.2f\n", tbank, ttoday, tfuture) );
+ DB( g_print(" - group total :: %.2f %.2f %.2f\n", tbank, ttoday, tfuture) );
// insert the total line
gtk_tree_store_append (GTK_TREE_STORE(model), &child_iter, &iter1);
}
/* set balance to header to display when collasped */
+ DB( g_print(" - enrich group total header :: %.2f %.2f %.2f\n", tbank, ttoday, tfuture) );
gtk_tree_store_set (GTK_TREE_STORE(model), &iter1,
LST_DSPACC_BANK, tbank,
LST_DSPACC_TODAY, ttoday,
}
- DB( g_print(" - grand totals :: %.2f %.2f %.2f\n", gtbank, gttoday, gtfuture) );
+ DB( g_print(" - grand total :: %.2f %.2f %.2f\n", gtbank, gttoday, gtfuture) );
// Grand total
if( nbtype > 1 )
gtk_tree_view_expand_all(GTK_TREE_VIEW(data->LV_acc));
- DB( g_print(" -> free ressources\n") );
-
+ DB( g_print(" - free ressources\n") );
- /* free all temp stuff */
- for(i=0;i<ACC_TYPE_MAXVALUE;i++)
+ g_hash_table_iter_init (&grp_iter, h_group);
+ while (g_hash_table_iter_next (&grp_iter, &key, &value))
{
- GPtrArray *gpa = typeacc[i];
-
- if(gpa != NULL)
- g_ptr_array_free (gpa, TRUE);
+ g_ptr_array_free (value, TRUE);
}
-
+ g_hash_table_destroy (h_group);
}
struct hbfile_data *data;
gint flags;
- DB( g_print("\n[ui-mainwindow] refresh_display\n") );
+ DB( g_print("\n[ui-mainwindow] update %p\n", user_data) );
data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
//data = INST_DATA(widget);
gchar *basename;
gchar *changed;
- DB( printf(" + 1: wintitle %x\n", (gint)data->wintitle) );
+ DB( g_print(" 1: wintitle %p\n", data->wintitle) );
basename = g_path_get_basename(GLOBALS->xhb_filepath);
- DB( printf(" global changes: %d\n", GLOBALS->changes_count) );
+ DB( g_print(" global changes: %d\n", GLOBALS->changes_count) );
g_free(data->wintitle);
GtkTreePath *path;
gboolean active,sensitive;
- DB( printf(" + 2: disabled, opelist count\n") );
+ DB( g_print(" 2: disabled, opelist count\n") );
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_acc));
+ //#1656531
+ data->acc = NULL;
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_acc));
active = gtk_tree_selection_get_selected(selection, &model, &iter);
if(active)
{
if( depth > 1 )
{
- DB( printf(" depth is %d\n", depth) );
+ DB( g_print(" depth is %d\n", depth) );
gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, LST_DSPACC_DATAS, &acc, -1);
data->acc = acc;
-
}
else
active = FALSE;
}
- else
- {
- //ensure data->acc will not be null
- data->acc = da_acc_get(1);
- }
// no change: disable save
- DB( printf(" changes %d - new %d\n", GLOBALS->changes_count, GLOBALS->hbfile_is_new) );
+ DB( g_print(" changes %d - new %d\n", GLOBALS->changes_count, GLOBALS->hbfile_is_new) );
sensitive = (GLOBALS->changes_count != 0 ) ? TRUE : FALSE;
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ManageMenu/Account"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ManageMenu/Payee"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ManageMenu/Category"), sensitive);
- //gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ManageMenu/Assign"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ManageMenu/Budget"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/EditMenu/Preferences"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/FileMenu/Close"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ManageMenu/Archive"), sensitive);
- gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TransactionMenu/AddOpe"), sensitive);
- gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TransactionMenu/ShowOpe"), sensitive);
+ gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TxnMenu/AddOpe"), sensitive);
+ gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TxnMenu/ShowOpe"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ReportMenu/RStatistics"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ReportMenu/RTrendTime"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ReportMenu/RBudget"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ReportMenu/RBalance"), sensitive);
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ReportMenu/RVehiculeCost"), sensitive);
- // empty category list: disable Budget & Budget report
+ // empty category list: disable Budget
sensitive = da_cat_length() > 1 ? TRUE : FALSE;
-
gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ManageMenu/Budget"), sensitive);
+ //#1501129 no need to disable, P & C can be created from assign dialog
+ //sensitive = ((da_cat_length() > 1) || (da_pay_length() > 1)) ? TRUE : FALSE;
+ //gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/ManageMenu/Assign"), sensitive);
+
// empty archive list: disable scheduled check
sensitive = g_list_length(GLOBALS->arc_list) > 0 ? TRUE : FALSE;
- gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TransactionMenu/AddScheduled"), sensitive);
+ 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;
if(data->acc && data->acc->window != NULL)
sensitive = FALSE;
- gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TransactionMenu/ShowOpe"), sensitive);
+ gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TxnMenu/ShowOpe"), sensitive);
}
/* update toolbar, list */
if(flags & UF_VISUAL)
{
- DB( printf(" + 8: visual\n") );
+ DB( g_print(" 8: visual\n") );
if(PREFS->toolbar_style == 0)
gtk_toolbar_unset_style(GTK_TOOLBAR(data->toolbar));
else
gtk_toolbar_set_style(GTK_TOOLBAR(data->toolbar), PREFS->toolbar_style-1);
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (data->LV_acc), PREFS->rules_hint);
+ gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (data->LV_acc), PREFS->grid_lines);
gtk_tree_view_columns_autosize (GTK_TREE_VIEW(data->LV_acc));
- DB( printf(" - show toolbar=%d\n", PREFS->wal_toolbar) );
+ gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (data->LV_upc), PREFS->grid_lines);
+ gtk_tree_view_columns_autosize (GTK_TREE_VIEW(data->LV_upc));
+
+ DB( g_print(" - show toolbar=%d\n", PREFS->wal_toolbar) );
if(PREFS->wal_toolbar)
gtk_widget_show(GTK_WIDGET(data->toolbar));
else
gtk_widget_hide(GTK_WIDGET(data->toolbar));
- DB( printf(" - show top_spending=%d\n", PREFS->wal_spending) );
+ 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);
- DB( printf(" - show upcoming=%d\n", PREFS->wal_upcoming) );
+ DB( g_print(" - show upcoming=%d\n", PREFS->wal_upcoming) );
if(PREFS->wal_upcoming)
gtk_widget_show(GTK_WIDGET(data->GR_upc));
else
gtk_widget_hide(GTK_WIDGET(data->GR_upc));
- DB( printf(" minor %d\n", PREFS->euro_active) );
+ DB( g_print(" minor %d\n", PREFS->euro_active) );
gtk_action_set_visible(gtk_ui_manager_get_action(data->manager, "/MenuBar/ViewMenu/AsMinor"), PREFS->euro_active);
}
if(flags & UF_BALANCE)
{
- DB( printf(" + 4: balances\n") );
+ DB( g_print(" 4: balances\n") );
gtk_tree_view_columns_autosize (GTK_TREE_VIEW(data->LV_acc));
if(flags & UF_REFRESHALL)
{
- DB( printf(" + 8: refreshall\n") );
+ DB( g_print(" 16: refreshall\n") );
ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL);
ui_mainwindow_populate_topspending(GLOBALS->mainwindow, NULL);
}
}
+
+static void ui_mainwindow_destroy(GtkTreeView *treeview, gpointer user_data)
+{
+ DB( g_print("\n[ui-mainwindow] destroy\n") );
+
+}
+
+
/*
**
*/
struct WinGeometry *wg;
gboolean retval = FALSE;
- DB( g_print("\n[ui-mainwindow] dispose\n") );
+ DB( g_print("\n[ui-mainwindow] delete-event\n") );
//store position and size
wg = &PREFS->wal_wg;
}
else
{
- DB( g_print(" free wintitle %x\n", (gint)data->wintitle) );
-
+ //todo: retval is useless and below should move to destroy
+ retval = TRUE;
gtk_widget_destroy(data->LV_top);
g_free(data->wintitle);
da_filter_free(data->filter);
g_free(user_data);
+
gtk_main_quit();
}
-
-
- //delete-event TRUE abort/FALSE destroy
+ //TRUE:stop other handlers from being invoked for the event | FALSE: propagate
return retval;
}
DB( g_print("\n[ui-mainwindow] recent_add\n") );
- DB( g_print(" - suffix xhb %d", g_str_has_suffix (path, ".xhb") ) );
+ DB( g_print(" - file has .xhb suffix = %d\n", g_str_has_suffix (path, ".xhb") ) );
if( g_str_has_suffix (path, ".xhb") == FALSE ) //ignore reverted file
return;
GtkSelectionData *selection_data,
guint info, guint time, GtkWindow *window)
{
- gchar **uris, **str;
- gchar *data;
- gint filetype, slen;
+gchar **uris, **str;
+gchar *newseldata;
+gint filetype, slen;
if (info != TARGET_URI_LIST)
return;
/* On MS-Windows, it looks like `selection_data->data' is not NULL terminated. */
slen = gtk_selection_data_get_length(selection_data);
- data = g_new (gchar, slen + 1);
- memcpy (data, gtk_selection_data_get_data(selection_data), slen);
- data[slen] = 0;
+ newseldata = g_new (gchar, slen + 1);
+ memcpy (newseldata, gtk_selection_data_get_data(selection_data), slen);
+ newseldata[slen] = 0;
+
+ uris = g_uri_list_extract_uris (newseldata);
- uris = g_uri_list_extract_uris (data);
+ DB( g_print(" - dragged %d %d files\n", slen, g_strv_length(uris) ) );
str = uris;
//for (str = uris; *str; str++)
if( filetype == FILETYPE_HOMEBANK)
{
- hbfile_change_filepath(path);
+ hbfile_change_filepath(g_strdup(path));
ui_mainwindow_open_internal(GTK_WIDGET(window), NULL);
}
else
{
//todo: future here to implement import for other filetype
+ // ui_import_assistant_new();
+ // + write a method into assistant to catch other filename
+
ui_dialog_msg_infoerror(GTK_WINDOW(window), GTK_MESSAGE_ERROR,
_("File error"),
g_free (path);
}
g_strfreev (uris);
+
+ g_free(newseldata);
}
GTK_RECENT_SORT_MRU);
//todo: add a user pref for this
gtk_recent_chooser_set_limit(GTK_RECENT_CHOOSER (toolbar_recent_menu),
- 5);
+ 10);
//gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (toolbar_recent_menu), FALSE);
static void ui_mainwindow_create_menu_bar_and_toolbar(struct hbfile_data *data, GtkWidget *mainvbox)
{
GtkUIManager *manager;
-GtkActionGroup *action_group;
+GtkActionGroup *actions;
GtkAction *action;
GError *error = NULL;
gtk_window_add_accel_group (GTK_WINDOW (data->window),
gtk_ui_manager_get_accel_group(manager));
- action_group = gtk_action_group_new ("MainWindow");
- gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE);
+ actions = gtk_action_group_new ("MainWindow");
+ gtk_action_group_set_translation_domain(actions, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
+ gtk_action_group_add_actions (actions,
entries,
n_entries,
NULL);
- gtk_action_group_add_toggle_actions (action_group,
+ gtk_action_group_add_toggle_actions (actions,
toggle_entries,
n_toggle_entries,
NULL);
- gtk_ui_manager_insert_action_group (data->manager, action_group, 0);
- g_object_unref (action_group);
- data->actions = action_group;
+ gtk_ui_manager_insert_action_group (data->manager, actions, 0);
+ g_object_unref (actions);
+ data->actions = actions;
/* set short labels to use in the toolbar */
- action = gtk_action_group_get_action(action_group, "Open");
+ action = gtk_action_group_get_action(actions, "Open");
g_object_set(action, "short_label", _("Open"), NULL);
- action = gtk_action_group_get_action(action_group, "Save");
- g_object_set(action, "is_important", TRUE, NULL);
+ //action = gtk_action_group_get_action(action_group, "Save");
+ //g_object_set(action, "is_important", TRUE, NULL);
- action = gtk_action_group_get_action(action_group, "Account");
+ action = gtk_action_group_get_action(actions, "Account");
g_object_set(action, "short_label", _("Account"), NULL);
- action = gtk_action_group_get_action(action_group, "Payee");
+ action = gtk_action_group_get_action(actions, "Payee");
g_object_set(action, "short_label", _("Payee"), NULL);
- action = gtk_action_group_get_action(action_group, "Category");
+ action = gtk_action_group_get_action(actions, "Category");
g_object_set(action, "short_label", _("Category"), NULL);
- action = gtk_action_group_get_action(action_group, "Archive");
+ action = gtk_action_group_get_action(actions, "Archive");
//TRANSLATORS: an archive is stored transaction buffers (kind of bookmark to prefill manual insertion)
g_object_set(action, "short_label", _("Archive"), NULL);
- action = gtk_action_group_get_action(action_group, "Budget");
+ action = gtk_action_group_get_action(actions, "Budget");
g_object_set(action, "short_label", _("Budget"), NULL);
- action = gtk_action_group_get_action(action_group, "ShowOpe");
+ action = gtk_action_group_get_action(actions, "ShowOpe");
g_object_set(action, "short_label", _("Show"), NULL);
- action = gtk_action_group_get_action(action_group, "AddOpe");
+ action = gtk_action_group_get_action(actions, "AddOpe");
g_object_set(action, "is_important", TRUE, "short_label", _("Add"), NULL);
- action = gtk_action_group_get_action(action_group, "RStatistics");
+ action = gtk_action_group_get_action(actions, "RStatistics");
g_object_set(action, "short_label", _("Statistics"), NULL);
- action = gtk_action_group_get_action(action_group, "RBudget");
+ action = gtk_action_group_get_action(actions, "RBudget");
g_object_set(action, "short_label", _("Budget"), NULL);
- action = gtk_action_group_get_action(action_group, "RBalance");
+ action = gtk_action_group_get_action(actions, "RBalance");
g_object_set(action, "short_label", _("Balance"), NULL);
- action = gtk_action_group_get_action(action_group, "RVehiculeCost");
+ action = gtk_action_group_get_action(actions, "RVehiculeCost");
g_object_set(action, "short_label", _("Vehicle cost"), NULL);
/* now load the UI definition */
g_error_free (error);
}
-
+ //todo: this generate a warning
data->menubar = gtk_ui_manager_get_widget (manager, "/MenuBar");
gtk_box_pack_start (GTK_BOX (mainvbox),
data->menubar,
/* recent files menu */
-
-
data->recent_manager = gtk_recent_manager_get_default ();
data->recent_menu = ui_mainwindow_create_recent_chooser_menu (data->recent_manager);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (widget), data->recent_menu);
*/
- /* testing */
- /* add the custom Open button to the toolbar */
- GtkToolItem *open_button = gtk_menu_tool_button_new_from_stock (GTK_STOCK_OPEN);
- gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (open_button),
- data->recent_menu);
+ /* test */
+ /* add the custom Open button to the toolbar */
+ GtkWidget *image = gtk_image_new_from_icon_name (ICONNAME_OPEN, GTK_ICON_SIZE_BUTTON);
- gtk_tool_item_set_tooltip_text (open_button, _("Open a file"));
- gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (open_button),
- _("Open a recently used file"));
+ GtkToolItem *open_button = gtk_menu_tool_button_new(image, _("_Open"));
+ gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (open_button), data->recent_menu);
+ gtk_tool_item_set_tooltip_text (open_button, _("Open a file"));
+ gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (open_button), _("Open a recently used file"));
action = gtk_action_group_get_action (data->actions, "Open");
- g_object_set (action,
- "short_label", _("Open"),
- NULL);
+ g_object_set (action, "short_label", _("Open"), NULL);
//gtk_action_connect_proxy (action, GTK_WIDGET (open_button));
gtk_activatable_set_related_action (GTK_ACTIVATABLE (open_button), action);
- gtk_toolbar_insert (GTK_TOOLBAR (data->toolbar),
- open_button,
- 1);
- /* end testing */
+ gtk_toolbar_insert (GTK_TOOLBAR (data->toolbar), open_button, 1);
+ /* end test */
}
-static GtkWidget *ui_mainwindow_create_youraccounts(struct hbfile_data *data)
+/* Callback function for the undo action */
+/*static void
+activate_action (GSimpleAction *action, GVariant *parameter, gpointer user_data)
+{
+ g_print ("Action %s activated\n", g_action_get_name (G_ACTION (action)));
+}*/
+
+static void
+activate_toggle (GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
-GtkWidget *mainvbox, *align, *label, *widget, *sw;
+struct hbfile_data *data = user_data;
+ GVariant *old_state, *new_state;
- mainvbox = gtk_vbox_new (FALSE, 0);
+ old_state = g_action_get_state (G_ACTION (action));
+ new_state = g_variant_new_boolean (!g_variant_get_boolean (old_state));
- label = make_label(_("Your accounts"), 0.0, 0.5);
- gimp_label_set_attributes(GTK_LABEL(label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1);
- gtk_misc_set_padding (GTK_MISC(label), HB_BOX_SPACING, HB_BOX_SPACING/2);
- gtk_box_pack_start (GTK_BOX (mainvbox), label, FALSE, FALSE, 0);
+ DB( g_print ("Toggle action %s activated, state changes from %d to %d\n",
+ g_action_get_name (G_ACTION (action)),
+ g_variant_get_boolean (old_state),
+ g_variant_get_boolean (new_state)) );
+
+ data->showall = g_variant_get_boolean (new_state);
+ ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL);
+
+ g_simple_action_set_state (action, new_state);
+ g_variant_unref (old_state);
+}
+
+static void
+activate_radio (GSimpleAction *action, GVariant *parameter, gpointer user_data)
+{
+//struct hbfile_data *data = user_data;
+GVariant *old_state, *new_state;
- align = gtk_alignment_new(0, 0, 1.0, 1.0);
- // top, bottom, left, right
- gtk_alignment_set_padding (GTK_ALIGNMENT(align), 0, HB_BOX_SPACING, 2*HB_BOX_SPACING, HB_BOX_SPACING);
- gtk_box_pack_start (GTK_BOX (mainvbox), align, TRUE, TRUE, 0);
+ old_state = g_action_get_state (G_ACTION (action));
+ new_state = g_variant_new_string (g_variant_get_string (parameter, NULL));
+
+ DB( g_print ("Radio action %s activated, state changes from %s to %s\n",
+ g_action_get_name (G_ACTION (action)),
+ g_variant_get_string (old_state, NULL),
+ g_variant_get_string (new_state, NULL)) );
+
+ PREFS->pnl_acc_show_by = DSPACC_GROUP_BY_TYPE;
+ if( !strcmp("bank", g_variant_get_string(new_state, NULL)) )
+ PREFS->pnl_acc_show_by = DSPACC_GROUP_BY_BANK;
+
+ ui_mainwindow_populate_accounts(GLOBALS->mainwindow, NULL);
+
+ g_simple_action_set_state (action, new_state);
+ g_variant_unref (old_state);
+}
+
+
+static const GActionEntry actions[] = {
+// { "paste", activate_action, NULL, NULL, NULL, {0,0,0} },
+ { "showall", activate_toggle, NULL, "false" , NULL, {0,0,0} },
+ { "groupby", activate_radio , "s", "'type'", NULL, {0,0,0} }
+};
+
+
+static void ui_panel_accounts_setup(struct hbfile_data *data)
+{
+GAction *action;
+GVariant *new_state;
+
+ if( !G_IS_SIMPLE_ACTION_GROUP(data->action_group_acc) )
+ return;
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (data->action_group_acc), "showall");
+ if( action )
+ {
+ new_state = g_variant_new_boolean (data->showall);
+ g_simple_action_set_state (G_SIMPLE_ACTION(action), new_state);
+ }
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (data->action_group_acc), "groupby");
+ if( action )
+ {
+ const gchar *value = (PREFS->pnl_acc_show_by == DSPACC_GROUP_BY_TYPE) ? "type" : "bank";
+ new_state = g_variant_new_string (value);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action), new_state);
+ }
+
+}
+
+
+static GtkWidget *ui_mainwindow_create_youraccounts(struct hbfile_data *data)
+{
+GtkWidget *panel, *label, *widget, *sw, *tbar, *hbox, *image;
+GtkToolItem *toolitem;
+
+ panel = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(panel), SPACING_SMALL);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add (GTK_CONTAINER (align), sw);
-
+ gtk_box_pack_start (GTK_BOX (panel), sw, TRUE, TRUE, 0);
widget = (GtkWidget *)create_list_account();
data->LV_acc = widget;
gtk_container_add (GTK_CONTAINER (sw), widget);
- return mainvbox;
-}
+ //list toolbar
+ tbar = gtk_toolbar_new();
+ gtk_toolbar_set_icon_size (GTK_TOOLBAR(tbar), GTK_ICON_SIZE_MENU);
+ gtk_toolbar_set_style(GTK_TOOLBAR(tbar), GTK_TOOLBAR_ICONS);
+ gtk_style_context_add_class (gtk_widget_get_style_context (tbar), GTK_STYLE_CLASS_INLINE_TOOLBAR);
+ gtk_box_pack_start (GTK_BOX (panel), tbar, FALSE, FALSE, 0);
+ label = make_label_group(_("Your accounts"));
+ toolitem = gtk_tool_item_new();
+ gtk_container_add (GTK_CONTAINER(toolitem), label);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
-static GtkWidget *ui_mainwindow_create_topspending(struct hbfile_data *data)
-{
-GtkWidget *mainvbox, *hbox, *vbox;
-GtkWidget *label, *align, *widget;
+ toolitem = gtk_separator_tool_item_new ();
+ gtk_tool_item_set_expand (toolitem, TRUE);
+ gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
- mainvbox = gtk_vbox_new (FALSE, 0);
- data->GR_top = mainvbox;
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ toolitem = gtk_tool_item_new();
+ gtk_container_add (GTK_CONTAINER(toolitem), hbox);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
+
+ widget = make_image_button(ICONNAME_HB_BUTTON_EXPAND, _("Expand all"));
+ data->BT_expandall = widget;
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
- label = make_label(_("Where your money goes"), 0.0, 0.5);
- gimp_label_set_attributes(GTK_LABEL(label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1);
- gtk_misc_set_padding (GTK_MISC(label), HB_BOX_SPACING, HB_BOX_SPACING/2);
- gtk_box_pack_start (GTK_BOX (mainvbox), label, FALSE, FALSE, 0);
+ widget = make_image_button(ICONNAME_HB_BUTTON_COLLAPSE, _("Collapse all"));
+ data->BT_collapseall = widget;
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
- align = gtk_alignment_new(0, 0, 1.0, 1.0);
- // top, bottom, left, right
- gtk_alignment_set_padding (GTK_ALIGNMENT(align), 0, HB_BOX_SPACING, 2*HB_BOX_SPACING, HB_BOX_SPACING);
- gtk_box_pack_start (GTK_BOX (mainvbox), align, TRUE, TRUE, 0);
+ toolitem = gtk_separator_tool_item_new ();
+ gtk_tool_item_set_expand (toolitem, FALSE);
+ gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
- vbox = gtk_vbox_new (FALSE, HB_BOX_SPACING);
- gtk_container_add (GTK_CONTAINER (align), vbox);
-
- /* total + date range */
- hbox = gtk_hbox_new (FALSE, HB_BOX_SPACING);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- label = make_label(_("Top 5 spending"), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- label = make_label(NULL, 0.0, 0.5);
- data->TX_topamount = label;
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- data->CY_range = make_daterange(label, FALSE);
- gtk_box_pack_end (GTK_BOX (hbox), data->CY_range, FALSE, FALSE, 0);
- /* pie + listview */
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+ //gmenu test (see test folder into gtk)
+GMenu *menu, *section;
- widget = gtk_chart_new(CHART_TYPE_PIE);
- data->RE_pie = widget;
- gtk_chart_set_minor_prefs(GTK_CHART(widget), PREFS->euro_value, PREFS->minor_cur.symbol);
- gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
+ menu = g_menu_new ();
+ //g_menu_append (menumodel, "About", "actions.undo");
+ //g_menu_append (menumodel, "Test", "actions.redo");
+ section = g_menu_new ();
+ g_menu_append (section, _("Show all"), "actions.showall");
+ g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
+ g_object_unref (section);
-/*
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start (GTK_BOX (hbox), sw, FALSE, FALSE, 0);
- */
-
- widget = (GtkWidget *)create_list_topspending();
- data->LV_top = widget;
+ section = g_menu_new ();
+ g_menu_append (section, _("By type"), "actions.groupby::type");
+ g_menu_append (section, _("By institition"), "actions.groupby::bank");
+ g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
+ g_object_unref (section);
- gtk_chart_show_legend(GTK_CHART(data->RE_pie), TRUE, TRUE);
-
-// gtk_container_add (GTK_CONTAINER (sw), widget);
- return mainvbox;
+ GSimpleActionGroup *group = g_simple_action_group_new ();
+ data->action_group_acc = group;
+ g_action_map_add_action_entries (G_ACTION_MAP (group), actions, G_N_ELEMENTS (actions), data);
+
+
+ widget = gtk_menu_button_new();
+ gtk_menu_button_set_direction (GTK_MENU_BUTTON(widget), GTK_ARROW_UP);
+ gtk_widget_set_halign (widget, GTK_ALIGN_END);
+ image = gtk_image_new_from_icon_name (ICONNAME_EMBLEM_SYSTEM, GTK_ICON_SIZE_MENU);
+ g_object_set (widget, "image", image, NULL);
+
+ toolitem = gtk_tool_item_new();
+ gtk_container_add (GTK_CONTAINER(toolitem), widget);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
+
+ gtk_widget_insert_action_group (widget, "actions", G_ACTION_GROUP(group));
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (widget), G_MENU_MODEL (menu));
+
+ return panel;
}
-static GtkWidget *ui_mainwindow_scheduled_create(struct hbfile_data *data)
+static GtkWidget *ui_mainwindow_create_topspending(struct hbfile_data *data)
{
-GtkWidget *mainvbox, *hbox, *vbox, *sw, *tbar;
-GtkWidget *label, *image, *align, *widget;
+GtkWidget *panel, *hbox, *tbar;
+GtkWidget *label, *widget;
GtkToolItem *toolitem;
+
+ widget = (GtkWidget *)create_list_topspending();
+ data->LV_top = widget;
+
+ panel = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(panel), SPACING_SMALL);
+ data->GR_top = panel;
+
+ /* chart + listview */
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start (GTK_BOX (panel), hbox, TRUE, TRUE, 0);
+
+ widget = gtk_chart_new(CHART_TYPE_PIE);
+ data->RE_pie = widget;
+ gtk_chart_set_minor_prefs(GTK_CHART(widget), PREFS->euro_value, PREFS->minor_cur.symbol);
+ gtk_chart_show_legend(GTK_CHART(data->RE_pie), TRUE, TRUE);
+ gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
+
+ //list toolbar
+ tbar = gtk_toolbar_new();
+ gtk_toolbar_set_icon_size (GTK_TOOLBAR(tbar), GTK_ICON_SIZE_MENU);
+ gtk_toolbar_set_style(GTK_TOOLBAR(tbar), GTK_TOOLBAR_ICONS);
+ gtk_style_context_add_class (gtk_widget_get_style_context (tbar), GTK_STYLE_CLASS_INLINE_TOOLBAR);
+ gtk_box_pack_start (GTK_BOX (panel), tbar, FALSE, FALSE, 0);
+
+ label = make_label_group(_("Where your money goes"));
+ toolitem = gtk_tool_item_new();
+ gtk_container_add (GTK_CONTAINER(toolitem), label);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
+
+ toolitem = gtk_separator_tool_item_new ();
+ gtk_tool_item_set_expand (toolitem, TRUE);
+ gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
+
+ /* total + date range */
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, SPACING_SMALL);
+ toolitem = gtk_tool_item_new();
+ gtk_container_add (GTK_CONTAINER(toolitem), hbox);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
- mainvbox = gtk_vbox_new (FALSE, 0);
- data->GR_upc = mainvbox;
+ data->CY_range = make_daterange(label, FALSE);
+ gtk_box_pack_end (GTK_BOX (hbox), data->CY_range, FALSE, FALSE, 0);
- hbox = gtk_hbox_new (FALSE, HB_BOX_SPACING);
- gtk_box_pack_start (GTK_BOX (mainvbox), hbox, FALSE, FALSE, 0);
+ widget = make_radio(CYA_CATSUBCAT, TRUE, GTK_ORIENTATION_HORIZONTAL);
+ data->RA_type = widget;
+ gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
- label = make_label(_("Scheduled transactions"), 0.0, 0.5);
- //gtk_label_set_angle(GTK_LABEL(label), 90.0);
- gimp_label_set_attributes(GTK_LABEL(label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1);
- gtk_misc_set_padding (GTK_MISC(label), HB_BOX_SPACING, HB_BOX_SPACING/2);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ return panel;
+}
- label = make_label(_("maximum post date"), 0.0, 0.7);
- gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- label = make_label(NULL, 0.0, 0.7);
- data->LB_maxpostdate = label;
- gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+static GtkWidget *ui_mainwindow_scheduled_create(struct hbfile_data *data)
+{
+GtkWidget *panel, *hbox, *vbox, *bbox, *sw, *tbar;
+GtkWidget *label, *widget;
+GtkToolItem *toolitem;
- align = gtk_alignment_new(0, 0, 1.0, 1.0);
- // top, bottom, left, right
- gtk_alignment_set_padding (GTK_ALIGNMENT(align), 0, HB_BOX_SPACING, 2*HB_BOX_SPACING, HB_BOX_SPACING);
- gtk_box_pack_start (GTK_BOX (mainvbox), align, TRUE, TRUE, 0);
+ panel = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(panel), SPACING_SMALL);
+ data->GR_upc = panel;
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (align), vbox);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ //gtk_widget_set_margin_top(GTK_WIDGET(vbox), 0);
+ //gtk_widget_set_margin_bottom(GTK_WIDGET(vbox), SPACING_SMALL);
+ //gtk_widget_set_margin_start(GTK_WIDGET(vbox), 2*SPACING_SMALL);
+ //gtk_widget_set_margin_end(GTK_WIDGET(vbox), SPACING_SMALL);
+ gtk_box_pack_start (GTK_BOX (panel), vbox, TRUE, TRUE, 0);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
tbar = gtk_toolbar_new();
gtk_toolbar_set_icon_size (GTK_TOOLBAR(tbar), GTK_ICON_SIZE_MENU);
gtk_toolbar_set_style(GTK_TOOLBAR(tbar), GTK_TOOLBAR_ICONS);
+ gtk_style_context_add_class (gtk_widget_get_style_context (tbar), GTK_STYLE_CLASS_INLINE_TOOLBAR);
gtk_box_pack_start (GTK_BOX (vbox), tbar, FALSE, FALSE, 0);
- /*widget = gtk_tool_item_new ();
- label = gtk_label_new("test");
- gtk_container_add(GTK_CONTAINER(widget), label);
- gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(widget), -1);*/
-
- image = gtk_image_new_from_icon_name ("media-skip-forward", GTK_ICON_SIZE_MENU);
- toolitem = gtk_tool_button_new(image, NULL);
- data->BT_sched_skip = toolitem;
+ label = make_label_group(_("Scheduled transactions"));
+ toolitem = gtk_tool_item_new();
+ gtk_container_add (GTK_CONTAINER(toolitem), label);
gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
- gtk_widget_set_tooltip_text(GTK_WIDGET(toolitem), _("Skip"));
- image = gtk_image_new_from_icon_name ("media-playback-start", GTK_ICON_SIZE_MENU);
- toolitem = gtk_tool_button_new(image, NULL);
- data->BT_sched_post = toolitem;
+ toolitem = gtk_separator_tool_item_new ();
+ gtk_tool_item_set_expand (toolitem, FALSE);
+ gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE);
gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
- gtk_widget_set_tooltip_text(GTK_WIDGET(toolitem), _("Post"));
-
- return mainvbox;
+ bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
+ toolitem = gtk_tool_item_new();
+ gtk_container_add (GTK_CONTAINER(toolitem), bbox);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
+
+ widget = gtk_button_new_with_label(_("Skip"));
+ data->BT_sched_skip = widget;
+ gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0);
+
+ widget = gtk_button_new_with_label(_("Edit & Post"));
+ data->BT_sched_editpost = widget;
+ gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0);
+
+ //TRANSLATORS: Posting a scheduled transaction is the action to materialize it into its target account.
+ //TRANSLATORS: Before that action the automated transaction occurrence is pending and not yet really existing.
+ widget = gtk_button_new_with_label (_("Post"));
+ data->BT_sched_post = widget;
+ gtk_box_pack_start (GTK_BOX (bbox), widget, FALSE, FALSE, 0);
+
+ toolitem = gtk_separator_tool_item_new ();
+ gtk_tool_item_set_expand (toolitem, FALSE);
+ gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
+
+ hbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_set_valign (hbox, GTK_ALIGN_CENTER);
+ toolitem = gtk_tool_item_new();
+ gtk_container_add (GTK_CONTAINER(toolitem), hbox);
+ gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
+
+ label = make_label(_("maximum post date"), 0.0, 0.7);
+ gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
+ gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ label = make_label(NULL, 0.0, 0.7);
+ data->LB_maxpostdate = label;
+ gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
+ gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_SCALE, PANGO_SCALE_SMALL, -1);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ return panel;
}
+
/*
** the window creation
*/
//store our window private data
g_object_set_data(G_OBJECT(window), "inst_data", (gpointer)data);
- DB( g_print(" - new window=%x, inst_data=%0x\n", (gint)window, (gint)data) );
+ DB( g_print(" - new window=%p, inst_data=%p\n", window, data) );
// this is our mainwindow, so store it to GLOBALS data
data->window = window;
GLOBALS->mainwindow = window;
- //setup, init and show window
- wg = &PREFS->wal_wg;
- if(wg->s == 0)
- {
- gtk_window_move(GTK_WINDOW(window), wg->l, wg->t);
- gtk_window_resize(GTK_WINDOW(window), wg->w, wg->h);
- }
- else
- gtk_window_maximize(GTK_WINDOW(window));
-
- gtk_widget_show (window);
-
- mainvbox = gtk_vbox_new (FALSE, 0);
+ mainvbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), mainvbox);
ui_mainwindow_create_menu_bar_and_toolbar (data, mainvbox);
-#if HB_UNSTABLE == TRUE
+#if HB_UNSTABLE_SHOW == TRUE
GtkWidget *bar, *label;
bar = gtk_info_bar_new ();
#endif
/* Add the main area */
- vbox = gtk_vbox_new (FALSE, 0);
- //gtk_container_set_border_width (GTK_CONTAINER(vbox), HB_MAINBOX_SPACING);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ //gtk_container_set_border_width (GTK_CONTAINER(vbox), SPACING_MEDIUM);
gtk_box_pack_start (GTK_BOX (mainvbox), vbox, TRUE, TRUE, 0);
- vpaned = gtk_vpaned_new();
+ vpaned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
data->vpaned = vpaned;
gtk_box_pack_start (GTK_BOX (vbox), vpaned, TRUE, TRUE, 0);
- hpaned = gtk_hpaned_new();
+ hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
data->hpaned = hpaned;
gtk_paned_pack1 (GTK_PANED(vpaned), hpaned, FALSE, FALSE);
widget = ui_mainwindow_scheduled_create(data);
- gtk_paned_pack2 (GTK_PANED(vpaned), widget, FALSE, FALSE);
+ gtk_paned_pack2 (GTK_PANED(vpaned), widget, TRUE, FALSE);
widget = ui_mainwindow_create_youraccounts(data);
+ //gtk_widget_set_size_request (widget, 100, -1);
gtk_paned_pack1 (GTK_PANED(hpaned), widget, FALSE, FALSE);
widget = ui_mainwindow_create_topspending(data);
- gtk_paned_pack2 (GTK_PANED(hpaned), widget, FALSE, FALSE);
+ //gtk_widget_set_size_request (widget, -1, 100);
+ gtk_paned_pack2 (GTK_PANED(hpaned), widget, TRUE, FALSE);
+ //setup, init and show window
+ wg = &PREFS->wal_wg;
+ if(wg->s == 0)
+ {
+ gtk_window_move(GTK_WINDOW(window), wg->l, wg->t);
+ gtk_window_resize(GTK_WINDOW(window), wg->w, wg->h);
+ }
+ else
+ gtk_window_maximize(GTK_WINDOW(window));
+
+ gtk_widget_show_all (window);
+
+ //#1662197/1660910 moved after resize/show
DB( g_print(" - vpaned=%d hpaned=%d\n", PREFS->wal_vpaned, PREFS->wal_hpaned) );
if(PREFS->wal_hpaned > 0)
if(PREFS->wal_vpaned > 0)
gtk_paned_set_position(GTK_PANED(data->vpaned), PREFS->wal_vpaned);
- gtk_widget_show_all (window);
-
//todo: move this elsewhere
DB( g_print(" - setup stuff\n") );
filter_default_all_set(data->filter);
gtk_combo_box_set_active(GTK_COMBO_BOX(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);
action = gtk_ui_manager_get_action(data->manager, "/MenuBar/ViewMenu/Spending");
g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_acc)), "changed", G_CALLBACK (ui_mainwindow_selection), NULL);
- g_signal_connect (GTK_TREE_VIEW(data->LV_acc), "row-activated", G_CALLBACK (ui_mainwindow_onRowActivated), GINT_TO_POINTER(2));
+ g_signal_connect (GTK_TREE_VIEW(data->LV_acc ), "row-activated", G_CALLBACK (ui_mainwindow_onRowActivated), GINT_TO_POINTER(2));
+ g_signal_connect (G_OBJECT (data->BT_expandall ), "clicked" , G_CALLBACK (ui_panel_accounts_expand_all), NULL);
+ g_signal_connect (G_OBJECT (data->BT_collapseall), "clicked" , G_CALLBACK (ui_panel_accounts_collapse_all), NULL);
g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_upc)), "changed", G_CALLBACK (ui_mainwindow_scheduled_selection_cb), NULL);
- g_signal_connect (G_OBJECT (data->BT_sched_post), "clicked", G_CALLBACK (ui_mainwindow_scheduled_post_cb), data);
+ g_signal_connect (GTK_TREE_VIEW(data->LV_upc), "row-activated", G_CALLBACK (ui_mainwindow_scheduled_onRowActivated), NULL);
g_signal_connect (G_OBJECT (data->BT_sched_skip), "clicked", G_CALLBACK (ui_mainwindow_scheduled_skip_cb), data);
+ g_signal_connect (G_OBJECT (data->BT_sched_editpost), "clicked", G_CALLBACK (ui_mainwindow_scheduled_editpost_cb), data);
+ g_signal_connect (G_OBJECT (data->BT_sched_post), "clicked", G_CALLBACK (ui_mainwindow_scheduled_post_cb), data);
+ widget = radio_get_nth_widget(GTK_CONTAINER(data->RA_type), 1);
+ if(widget)
+ g_signal_connect (widget, "toggled", G_CALLBACK (ui_mainwindow_populate_topspending), &data);
+
g_signal_connect (data->CY_range, "changed", G_CALLBACK (ui_mainwindow_populate_topspending), NULL);
/* GtkWindow events */
g_signal_connect (window, "delete-event", G_CALLBACK (ui_mainwindow_dispose), (gpointer)data);
+ g_signal_connect (window, "destroy", G_CALLBACK (ui_mainwindow_destroy), NULL);
g_signal_connect (window, "screen-changed",
//gtk_action_group_set_sensitive(data->actions, FALSE);
-
- return window;
+ return window;
}
-