]> Dogcows Code - chaz/homebank/blobdiff - src/dsp-mainwindow.c
revert whitespace fixes
[chaz/homebank] / src / dsp-mainwindow.c
index 1f53410322aea8c6b5a33953f9ad1f7d86eb8c68..f9dd0ea41be059bde8a7db7b5d3ef72010949793 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "dsp-mainwindow.h"
 
+#include "ext.h"
+
 #include "list-account.h"
 
 #include "hub-account.h"
@@ -108,8 +110,7 @@ static void ui_mainwindow_action_toggle_upcoming(GtkToggleAction *action);
 static void ui_mainwindow_action_toggle_topspending(GtkToggleAction *action);
 static void ui_mainwindow_action_toggle_minor(GtkToggleAction *action);
 
-static void ui_mainwindow_action_showtransactions(void);
-static void ui_mainwindow_action_showalltransactions(void);
+static void ui_mainwindow_action_showtransactions(GtkAction *action);
 
 static void ui_mainwindow_action_addtransactions(void);
 static void ui_mainwindow_action_checkscheduled(void);
@@ -125,6 +126,8 @@ static void ui_mainwindow_action_export(void);
 static void ui_mainwindow_action_anonymize(void);
 static void ui_mainwindow_action_file_statistics(void);
 
+static void ui_mainwindow_action_pluginprefs(void);
+
 static void ui_mainwindow_action_help(void);
 void ui_mainwindow_action_help_welcome(void);
 static void ui_mainwindow_action_help_online(void);
@@ -151,6 +154,7 @@ void ui_mainwindow_recent_add (struct hbfile_data *data, const gchar *path);
 
 void ui_mainwindow_recent_add (struct hbfile_data *data, const gchar *path);
 
+static void ui_mainwindow_showprefs(gint page);
 
 static GtkActionEntry entries[] = {
 
@@ -165,6 +169,7 @@ static GtkActionEntry entries[] = {
   { "TxnMenu"    , NULL, N_("_Transactions"), NULL, NULL, NULL },
   { "ReportMenu" , NULL, N_("_Reports"), NULL, NULL, NULL  },
   { "ToolsMenu"  , NULL, N_("_Tools"), NULL, NULL, NULL },
+  { "PluginMenu" , NULL, N_("_Plugins"), NULL, NULL, NULL },
   { "HelpMenu"   , NULL, N_("_Help"), NULL, NULL, NULL },
 
 //  { "Import"       , NULL, N_("Import") },
@@ -208,7 +213,8 @@ static GtkActionEntry entries[] = {
   /* TxnMenu */
   { "AddTxn"      , ICONNAME_HB_OPE_ADD    , N_("Add...")              , NULL, N_("Add transactions"),    G_CALLBACK (ui_mainwindow_action_addtransactions) },
   { "ShowTxn"     , ICONNAME_HB_OPE_SHOW   , N_("Show...")             , NULL, N_("Shows selected account transactions"),    G_CALLBACK (ui_mainwindow_action_showtransactions) },
-  { "ShowAllTxn"  , ICONNAME_HB_OPE_SHOW   , N_("Show all...")         , NULL, N_("Shows all account transactions"),    G_CALLBACK (ui_mainwindow_action_showalltransactions) },
+  //beware ShowAllTxn is used to detect showall
+  { "ShowAllTxn"  , ICONNAME_HB_OPE_SHOW   , N_("Show all...")         , NULL, N_("Shows all account transactions"),    G_CALLBACK (ui_mainwindow_action_showtransactions) },
   { "Scheduler"   , NULL                   , N_("Set scheduler...")    , NULL, N_("Configure the transaction scheduler"),    G_CALLBACK (ui_mainwindow_action_properties) },
   { "AddScheduled", NULL                   , N_("Post scheduled"), NULL, N_("Post pending scheduled transactions"),    G_CALLBACK (ui_mainwindow_action_checkscheduled) },
 
@@ -223,7 +229,10 @@ static GtkActionEntry entries[] = {
   { "Welcome"     , NULL              , N_("Show welcome dialog...")  , NULL, NULL, G_CALLBACK (ui_mainwindow_action_help_welcome) },
   { "FileStats"   , NULL              , N_("File statistics...")  , NULL, NULL,    G_CALLBACK (ui_mainwindow_action_file_statistics) },
   { "Anonymize"   , NULL              , N_("Anonymize...")  , NULL, NULL,    G_CALLBACK (ui_mainwindow_action_anonymize) },
-       
+
+  /* Plugins */
+  { "PluginPreferences", "prf-plugins", N_("_Plugins..."), "<control>U", N_("Configure plugin preferences"), G_CALLBACK(ui_mainwindow_action_pluginprefs) },
+
   /* HelpMenu */
   { "Contents"    , ICONNAME_HELP     , N_("_Contents")                    , "F1", N_("Documentation about HomeBank"), G_CALLBACK (ui_mainwindow_action_help) },
   { "Online"      , "lpi-help"        , N_("Get Help Online...")           , NULL, N_("Connect to the LaunchPad website for online help"), G_CALLBACK (ui_mainwindow_action_help_online) },
@@ -321,6 +330,11 @@ static const gchar *ui_info =
 "        <separator/>"
 "      <menuitem action='Anonymize'/>"
 "    </menu>"
+"    <menu action='PluginMenu'>"
+"      <separator/>"
+"      <menuitem action='PluginPreferences'/>"
+"      <separator/>"
+"    </menu>"
 "    <menu action='HelpMenu'>"
 "      <menuitem action='Contents'/>"
 "      <menuitem action='Online'/>"
@@ -355,6 +369,7 @@ static const gchar *ui_info =
 "    <toolitem action='RBalance'/>"
 "    <toolitem action='RBudget'/>"
 "    <toolitem action='RVehiculeCost'/>"
+"      <separator/>"
 "  </toolbar>"
 
 "</ui>";
@@ -434,7 +449,8 @@ gchar *version;
   static const gchar *authors[] = {
     "Lead developer:\n" \
     "Maxime DOYEN",
-    "\nContributor:\n" \
+    "\nContributors:\n" \
+    "Charles MCGARVEY (Plugin system, Perl support)\n" \
     "Ga\xc3\xabtan LORIDANT (Maths formulas for charts)\n",
     NULL
   };
@@ -570,6 +586,12 @@ static void ui_mainwindow_action_file_statistics(void)
 }
 
 
+static void ui_mainwindow_action_pluginprefs(void)
+{
+       ui_mainwindow_showprefs(PREF_PLUGINS);
+}
+
+
 static void ui_mainwindow_action_properties(void)
 {
        create_defhbfile_dialog();
@@ -692,10 +714,15 @@ static void ui_mainwindow_action_deftag(void)
 
 
 static void ui_mainwindow_action_preferences(void)
+{
+       ui_mainwindow_showprefs(PREF_GENERAL);
+}
+
+static void ui_mainwindow_showprefs(gint page)
 {
 struct hbfile_data *data = g_object_get_data(G_OBJECT(GLOBALS->mainwindow), "inst_data");
 
-       defpref_dialog_new();
+       defpref_dialog_new(page);
        if(!PREFS->euro_active)
        {
        GtkToggleAction *action = (GtkToggleAction *)gtk_ui_manager_get_action(data->manager, "/MenuBar/ViewMenu/AsMinor");
@@ -748,13 +775,21 @@ struct hbfile_data *data = g_object_get_data(G_OBJECT(GLOBALS->mainwindow), "ins
 
 }
 
-static void ui_mainwindow_action_showtransactions(void)
+static void ui_mainwindow_action_showtransactions(GtkAction *action)
 {
 struct hbfile_data *data = g_object_get_data(G_OBJECT(GLOBALS->mainwindow), "inst_data");
 GtkWidget *window;
+gboolean showall = FALSE;
 
-       //todo:change this
-       if( data->acc )
+       if( action != NULL )
+       {
+               DB( g_print(" actioname=%s\n", gtk_action_get_name(action)) );
+               if( hb_string_compare((gchar *)gtk_action_get_name(action), "ShowAllTxn" ) == 0 )
+                       showall = TRUE;
+       }
+               
+       //TODO: change this
+       if( data->acc && showall == FALSE )
        {
                if( data->acc->window == NULL )
                {
@@ -765,27 +800,21 @@ GtkWidget *window;
                {
                        if(GTK_IS_WINDOW(data->acc->window))
                                gtk_window_present(GTK_WINDOW(data->acc->window));
-
                }
        }
-}
-
-
-static void ui_mainwindow_action_showalltransactions(void)
-{
-GtkWidget *window;
-
-       if( GLOBALS->alltxnwindow == NULL )
-       {
-               window = register_panel_window_new(NULL);
-               register_panel_window_init(window, NULL);
-       }
        else
        {
-               if(GTK_IS_WINDOW(GLOBALS->alltxnwindow))
-                       gtk_window_present(GTK_WINDOW(GLOBALS->alltxnwindow));
+               if( GLOBALS->alltxnwindow == NULL )
+               {
+                       window = register_panel_window_new(NULL);
+                       register_panel_window_init(window, NULL);
+               }
+               else
+               {
+                       if(GTK_IS_WINDOW(GLOBALS->alltxnwindow))
+                               gtk_window_present(GTK_WINDOW(GLOBALS->alltxnwindow));
+               }
        }
-
 }
 
 
@@ -1317,7 +1346,7 @@ gint r;
                                case XML_FILE_ERROR:
                                        msg = _("The file '%s' is not a valid HomeBank file.");
                                        break;
-                               case XML_VERSION_ERROR: 
+                               case XML_VERSION_ERROR:
                                        msg = _("The file '%s' was saved with a higher version of HomeBank\nand cannot be loaded by the current version.");
                                        break;
                        }
@@ -1547,10 +1576,12 @@ gint flags;
                gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TxnMenu/AddScheduled"), sensitive);
 
        // no active account: disable Edit, Over
-               sensitive = (active == TRUE ) ? TRUE : FALSE;
+       //disabled 5.2.6
+       /*      sensitive = (active == TRUE ) ? TRUE : FALSE;
                if(data->acc && data->acc->window != NULL)
                        sensitive = FALSE;
                gtk_action_set_sensitive(gtk_ui_manager_get_action(data->manager, "/MenuBar/TxnMenu/ShowTxn"), sensitive);
+       */
        }
 
        /* update toolbar, list */
@@ -1578,7 +1609,7 @@ gint flags;
 
                DB( g_print(" - show top_spending=%d\n", PREFS->wal_spending) );
 
-               gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_range), PREFS->date_range_wal);
+               hbtk_combo_box_set_active_id(GTK_COMBO_BOX_TEXT(data->CY_range), PREFS->date_range_wal);
 
                if(PREFS->wal_spending)
                        gtk_widget_show(GTK_WIDGET(data->GR_top));
@@ -1653,7 +1684,7 @@ static void
 
        DB( g_print ("Double-clicked row contains name %s\n", acc->name) );
 
-               ui_mainwindow_action_showtransactions();
+               ui_mainwindow_action_showtransactions(NULL);
 
        //g_free(name);
        }
@@ -1677,6 +1708,9 @@ struct hbfile_data *data = user_data;
 struct WinGeometry *wg;
 gboolean retval = FALSE;
 
+       GValue widget_value = G_VALUE_INIT;
+       ext_hook("main_window_disposal", EXT_OBJECT(&widget_value, widget), NULL);
+
        DB( g_print("\n[ui-mainwindow] delete-event\n") );
 
        //store position and size
@@ -2180,7 +2214,7 @@ GtkWidget *bar, *label;
 
        data->filter = da_flt_malloc();
        filter_reset(data->filter);
-       gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_range), PREFS->date_range_wal);
+       hbtk_combo_box_set_active_id(GTK_COMBO_BOX_TEXT(data->CY_range), PREFS->date_range_wal);
 
        action = gtk_ui_manager_get_action(data->manager, "/MenuBar/ViewMenu/Toolbar");
        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), PREFS->wal_toolbar);
This page took 0.025787 seconds and 4 git commands to generate.