From 1779db5d895a98c3eb07099c32179f02e81f012b Mon Sep 17 00:00:00 2001 From: David Freese Date: Mon, 26 Mar 2012 17:46:24 -0500 Subject: [PATCH] Check for updates * Added check for updates when starting program * Configurable by user --- src/dialogs/confdialog.cxx | 27 ++++++++++++++++++++++----- src/dialogs/confdialog.fl | 22 +++++++++++++++++----- src/include/confdialog.h | 1 + src/include/configuration.h | 3 +++ src/include/fl_digi.h | 2 ++ src/main.cxx | 3 +++ 6 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/dialogs/confdialog.cxx b/src/dialogs/confdialog.cxx index 88de0a9a..b0851c33 100644 --- a/src/dialogs/confdialog.cxx +++ b/src/dialogs/confdialog.cxx @@ -420,6 +420,13 @@ progdefaults.NagMe=o->value(); progdefaults.changed = true; } +Fl_Check_Button *btn_check_for_updates=(Fl_Check_Button *)0; + +static void cb_btn_check_for_updates(Fl_Check_Button* o, void*) { + progdefaults.check_for_updates = o->value(); +progdefaults.changed = true; +} + Fl_Group *tabLogServer=(Fl_Group *)0; Fl_Input *xmllogServerAddress=(Fl_Input *)0; @@ -3804,33 +3811,43 @@ Fl_Double_Window* ConfigureDialog() { } // Fl_Check_Button* btn_rx_lowercase o->end(); } // Fl_Group* o - { Fl_Group* o = new Fl_Group(2, 195, 496, 171, _("Exit prompts")); + { Fl_Group* o = new Fl_Group(2, 195, 496, 114, _("Exit prompts")); o->box(FL_ENGRAVED_FRAME); o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE)); - { Fl_Check_Button* o = btn_save_config_on_exit = new Fl_Check_Button(118, 274, 329, 20, _("Prompt to save Configuration")); + { Fl_Check_Button* o = btn_save_config_on_exit = new Fl_Check_Button(37, 261, 233, 20, _("Prompt to save Configuration")); btn_save_config_on_exit->down_box(FL_DOWN_BOX); btn_save_config_on_exit->callback((Fl_Callback*)cb_btn_save_config_on_exit); o->value(progdefaults.SaveConfig); } // Fl_Check_Button* btn_save_config_on_exit - { Fl_Check_Button* o = btn2_save_macros_on_exit = new Fl_Check_Button(118, 300, 305, 20, _("Prompt to save macro file")); + { Fl_Check_Button* o = btn2_save_macros_on_exit = new Fl_Check_Button(37, 287, 233, 20, _("Prompt to save macro file")); btn2_save_macros_on_exit->tooltip(_("Write current macro set on program exit")); btn2_save_macros_on_exit->down_box(FL_DOWN_BOX); btn2_save_macros_on_exit->callback((Fl_Callback*)cb_btn2_save_macros_on_exit); o->value(progdefaults.SaveMacros); } // Fl_Check_Button* btn2_save_macros_on_exit - { Fl_Check_Button* o = btn2NagMe = new Fl_Check_Button(118, 326, 236, 20, _("Prompt to save log")); + { Fl_Check_Button* o = btn2NagMe = new Fl_Check_Button(279, 261, 166, 20, _("Prompt to save log")); btn2NagMe->tooltip(_("Bug me about saving log entries")); btn2NagMe->down_box(FL_DOWN_BOX); btn2NagMe->callback((Fl_Callback*)cb_btn2NagMe); o->value(progdefaults.NagMe); } // Fl_Check_Button* btn2NagMe - { Fl_Box* o = new Fl_Box(42, 219, 436, 47, _("Exit prompts active only when File/Exit menu item selected.\nNot active if wi\ + { Fl_Box* o = new Fl_Box(42, 211, 436, 47, _("Exit prompts active only when File/Exit menu item selected.\nNot active if wi\ ndow decoration close button pressed.")); o->box(FL_BORDER_BOX); o->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE)); } // Fl_Box* o o->end(); } // Fl_Group* o + { Fl_Group* o = new Fl_Group(2, 311, 496, 56, _("Check for updates")); + o->box(FL_ENGRAVED_FRAME); + o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE)); + { Fl_Check_Button* o = btn_check_for_updates = new Fl_Check_Button(37, 335, 324, 20, _("Check for updates when starting program")); + btn_check_for_updates->down_box(FL_DOWN_BOX); + btn_check_for_updates->callback((Fl_Callback*)cb_btn_check_for_updates); + o->value(progdefaults.check_for_updates); + } // Fl_Check_Button* btn_check_for_updates + o->end(); + } // Fl_Group* o tabUserInterface->end(); } // Fl_Group* tabUserInterface { tabLogServer = new Fl_Group(0, 50, 500, 320, _("Logging")); diff --git a/src/dialogs/confdialog.fl b/src/dialogs/confdialog.fl index e70a204d..4d1b0135 100644 --- a/src/dialogs/confdialog.fl +++ b/src/dialogs/confdialog.fl @@ -558,13 +558,13 @@ progdefaults.changed = true;} } Fl_Group {} { label {Exit prompts} open - xywh {2 195 496 171} box ENGRAVED_FRAME align 21 + xywh {2 195 496 114} box ENGRAVED_FRAME align 21 } { Fl_Check_Button btn_save_config_on_exit { label {Prompt to save Configuration} callback {progdefaults.SaveConfig = o->value(); progdefaults.changed = true;} - xywh {118 274 329 20} down_box DOWN_BOX + xywh {37 261 233 20} down_box DOWN_BOX code0 {o->value(progdefaults.SaveConfig);} } Fl_Check_Button btn2_save_macros_on_exit { @@ -572,7 +572,7 @@ progdefaults.changed = true;} callback {btn_save_macros_on_exit->value(o->value()); progdefaults.SaveMacros = o->value(); progdefaults.changed = true;} - tooltip {Write current macro set on program exit} xywh {118 300 305 20} down_box DOWN_BOX + tooltip {Write current macro set on program exit} xywh {37 287 233 20} down_box DOWN_BOX code0 {o->value(progdefaults.SaveMacros);} } Fl_Check_Button btn2NagMe { @@ -580,13 +580,25 @@ progdefaults.changed = true;} callback {btnNagMe->value(o->value()); progdefaults.NagMe=o->value(); progdefaults.changed = true;} - tooltip {Bug me about saving log entries} xywh {118 326 236 20} down_box DOWN_BOX + tooltip {Bug me about saving log entries} xywh {279 261 166 20} down_box DOWN_BOX code0 {o->value(progdefaults.NagMe);} } Fl_Box {} { label {Exit prompts active only when File/Exit menu item selected. Not active if window decoration close button pressed.} - xywh {42 219 436 47} box BORDER_BOX align 20 + xywh {42 211 436 47} box BORDER_BOX align 20 + } + } + Fl_Group {} { + label {Check for updates} open + xywh {2 311 496 56} box ENGRAVED_FRAME align 21 + } { + Fl_Check_Button btn_check_for_updates { + label {Check for updates when starting program} + callback {progdefaults.check_for_updates = o->value(); +progdefaults.changed = true;} + xywh {37 335 324 20} down_box DOWN_BOX + code0 {o->value(progdefaults.check_for_updates);} } } } diff --git a/src/include/confdialog.h b/src/include/confdialog.h index 9050014c..c622f9d8 100644 --- a/src/include/confdialog.h +++ b/src/include/confdialog.h @@ -73,6 +73,7 @@ extern Fl_Check_Button *btn_rx_lowercase; extern Fl_Check_Button *btn_save_config_on_exit; extern Fl_Check_Button *btn2_save_macros_on_exit; extern Fl_Check_Button *btn2NagMe; +extern Fl_Check_Button *btn_check_for_updates; extern Fl_Group *tabLogServer; #include extern Fl_Input *xmllogServerAddress; diff --git a/src/include/configuration.h b/src/include/configuration.h index 987277ad..42aaec3f 100644 --- a/src/include/configuration.h +++ b/src/include/configuration.h @@ -1257,6 +1257,9 @@ "Logbook server port", \ "8421") \ \ + ELEM_(bool, check_for_updates, "CHECK_FOR_UPDATES", \ + "Check for updates when starting program", \ + false) \ /* XML-RPC/ARQ servers */ \ ELEM_(std::string, xmlrpc_address, "", "", "127.0.0.1") \ ELEM_(std::string, xmlrpc_port, "", "", "7362") \ diff --git a/src/include/fl_digi.h b/src/include/fl_digi.h index 2ffae38f..a6a95250 100644 --- a/src/include/fl_digi.h +++ b/src/include/fl_digi.h @@ -319,4 +319,6 @@ extern void EQSL_close(void); extern Fl_Double_Window *notify_window; extern Fl_Double_Window *dxcc_window; +extern void cb_mnuCheckUpdate(Fl_Widget *, void *); + #endif diff --git a/src/main.cxx b/src/main.cxx index 95d4acf9..8f7f92ce 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -229,6 +229,9 @@ void delayed_startup(void *) if (progdefaults.usepskrep) if (!pskrep_start()) LOG_ERROR("Could not start PSK reporter: %s", pskrep_error()); + + if (progdefaults.check_for_updates) + cb_mnuCheckUpdate((Fl_Widget *)0, NULL); } int main(int argc, char ** argv)