From d977f42524b3b6029c1c64066ba00a8ec89b46bb Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 10 May 2013 11:27:59 +0000
Subject: [PATCH] make restore options easier to find (directly in Help menu)

---
 Fltk/graphicWindow.cpp | 16 +++++++------
 Fltk/optionWindow.cpp  | 53 ++++++++++++++++++++++--------------------
 Fltk/optionWindow.h    |  1 +
 3 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp
index 0a0792a470..bf22def402 100644
--- a/Fltk/graphicWindow.cpp
+++ b/Fltk/graphicWindow.cpp
@@ -1960,8 +1960,9 @@ static Fl_Menu_Item bar_table[] = {
     {0},
   {"&Help", 0, 0, 0, FL_SUBMENU},
     {"On&line Documentation", 0, (Fl_Callback *)help_online_cb, 0, FL_MENU_DIVIDER},
-    {"&Keyboard and Mouse Usage",    0, (Fl_Callback *)help_basic_cb, 0},
-    {"&Current Options",      0, (Fl_Callback *)status_options_cb, (void*)"?", FL_MENU_DIVIDER},
+    {"&Keyboard and Mouse Usage",    0, (Fl_Callback *)help_basic_cb, 0, FL_MENU_DIVIDER},
+    {"&Current Options",      0, (Fl_Callback *)status_options_cb, (void*)"?", 0},
+    {"&Restore all Options to Default Settings", 0, (Fl_Callback *)options_restore_defaults_cb, 0, FL_MENU_DIVIDER},
     {"&About Gmsh",           0, (Fl_Callback *)help_about_cb, 0},
     {0},
   {0}
@@ -2023,8 +2024,9 @@ static Fl_Menu_Item sysbar_table[] = {
     {0},
   {"Help", 0, 0, 0, FL_SUBMENU},
     {"Online Documentation", 0, (Fl_Callback *)help_online_cb, 0, FL_MENU_DIVIDER},
-    {"Keyboard and Mouse Usage",        0, (Fl_Callback *)help_basic_cb, 0},
+    {"Keyboard and Mouse Usage",        0, (Fl_Callback *)help_basic_cb, 0, FL_MENU_DIVIDER},
     {"Current Options",      0, (Fl_Callback *)status_options_cb, (void*)"?"},
+    {"Restore all Options to Default Settings", 0, (Fl_Callback *)options_restore_defaults_cb, 0},
     {0},
   {0}
 };
@@ -2891,13 +2893,13 @@ void graphicWindow::setStereo(bool st)
 {
   openglWindow::setLastHandled(0);
   for(unsigned int i = 0; i < gl.size(); i++){
-    if (st) { 
+    if (st) {
       gl[i]->mode(FL_RGB | FL_DEPTH | FL_DOUBLE | FL_STEREO);
     }
-    else{  
+    else{
       gl[i]->mode(FL_RGB | FL_DEPTH | FL_DOUBLE );
-    }  
-    gl[i]->show(); 
+    }
+    gl[i]->show();
   }
   Msg::Info("new gl window for stereo vision!");
 }
diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp
index 1b268618a3..553e1f2ae8 100644
--- a/Fltk/optionWindow.cpp
+++ b/Fltk/optionWindow.cpp
@@ -189,14 +189,17 @@ static void options_show_file_cb(Fl_Widget *w, void *data)
   fl_message("File path: %s", file.c_str());
 }
 
-static void options_restore_defaults_cb(Fl_Widget *w, void *data)
+void options_restore_defaults_cb(Fl_Widget *w, void *data)
 {
-  UnlinkFile(CTX::instance()->homeDir + CTX::instance()->sessionFileName);
-  UnlinkFile(CTX::instance()->homeDir + CTX::instance()->optionsFileName);
-  ReInitOptions(0);
-  InitOptionsGUI(0);
-  FlGui::instance()->rebuildTree();
-  drawContext::global()->draw();
+  if(fl_choice("Do you really want to reset all options to their default values?",
+               "Cancel", "Restore", 0)){
+    UnlinkFile(CTX::instance()->homeDir + CTX::instance()->sessionFileName);
+    UnlinkFile(CTX::instance()->homeDir + CTX::instance()->optionsFileName);
+    ReInitOptions(0);
+    InitOptionsGUI(0);
+    FlGui::instance()->rebuildTree();
+    drawContext::global()->draw();
+  }
 }
 
 void general_options_cb(Fl_Widget *w, void *data)
@@ -353,14 +356,14 @@ static void general_options_ok_cb(Fl_Widget *w, void *data)
   opt_general_axes(0, GMSH_SET, o->general.choice[4]->value());
   opt_general_background_gradient(0, GMSH_SET, o->general.choice[5]->value());
 
-  
-  if( (opt_general_gamepad(0, GMSH_GET, 0) !=  o->general.butt[19]->value() ) 
-      || ( opt_general_camera_mode(0, GMSH_GET, 0) !=  o->general.butt[18]->value() )){    
-    if((opt_general_gamepad(0, GMSH_GET, 0) == 1 ) 
+
+  if( (opt_general_gamepad(0, GMSH_GET, 0) !=  o->general.butt[19]->value() )
+      || ( opt_general_camera_mode(0, GMSH_GET, 0) !=  o->general.butt[18]->value() )){
+    if((opt_general_gamepad(0, GMSH_GET, 0) == 1 )
        && (o->general.butt[18]->value() == 0) ) {
       o->general.butt[19]->value(0) ;
-    }   
-    if((opt_general_camera_mode(0, GMSH_GET, 0) == 0 ) 
+    }
+    if((opt_general_camera_mode(0, GMSH_GET, 0) == 0 )
        && ( o->general.butt[19]->value() ==1) ) {
       o->general.butt[18]->value(1);
     }
@@ -368,7 +371,7 @@ static void general_options_ok_cb(Fl_Widget *w, void *data)
   opt_general_gamepad(0, GMSH_SET, o->general.butt[19]->value() );
   opt_general_camera_mode(0, GMSH_SET, o->general.butt[18]->value());
   o->activate((const char*)data);
-  
+
 
   opt_general_eye_sep_ratio(0, GMSH_SET, o->general.value[29]->value());
   opt_general_focallength_ratio(0, GMSH_SET, o->general.value[30]->value());
@@ -377,7 +380,7 @@ static void general_options_ok_cb(Fl_Widget *w, void *data)
     opt_general_stereo_mode(0, GMSH_SET, o->general.butt[17]->value());
     for(unsigned int i = 0; i < FlGui::instance()->graph.size(); i++) FlGui::instance()->graph[i]->setStereo((bool)CTX::instance()->stereo);
   }
-  
+
 
   if(CTX::instance()->fastRedraw)
     CTX::instance()->post.draw = CTX::instance()->mesh.draw = 0;
@@ -1469,7 +1472,7 @@ optionWindow::optionWindow(int deltaFontSize)
       b1->callback(options_show_file_cb, (void*)"option");
 
       Fl_Button *b2 = new Fl_Button
-        (L + 2 * WB, 2 * WB + 9 * BH, BW, BH, "Restore all options to default values");
+        (L + 2 * WB, 2 * WB + 9 * BH, BW, BH, "Restore all options to default settings");
       b2->callback(options_restore_defaults_cb);
       b2->labelcolor(FL_DARK_RED);
 
@@ -1847,7 +1850,7 @@ optionWindow::optionWindow(int deltaFontSize)
         (L + 2 * WB, 2 * WB + 8 * BH, BW, BH, "Configure Gamepad");
       general.gamepadconfig->callback(general_gmpdcf_cb);
 
-  
+
       if( opt_general_camera_mode(0, GMSH_GET, 0) == 0 ){
 	general.value[30]->deactivate();
 	general.value[31]->deactivate();
@@ -1855,7 +1858,7 @@ optionWindow::optionWindow(int deltaFontSize)
 
       if( opt_general_stereo_mode(0, GMSH_GET, 0) == 0 )
 	general.value[29]->deactivate();
-       
+
       if(CTX::instance()->gamepad && CTX::instance()->gamepad->active)  {
 	general.gamepadconfig->activate();
 	opt_general_camera_mode(0, GMSH_SET, 1);
@@ -3841,25 +3844,25 @@ void optionWindow::activate(const char *what)
     else{
       general.gamepadconfig->deactivate();
     }
-   
+
     if(general.butt[17]->value()==0){
       general.value[29]->deactivate();
     }
     else{
       general.value[29]->activate();
-    } 
-    
+    }
+
     if(general.butt[18]->value()==0 ){
       general.value[30]->deactivate();
       general.value[31]->deactivate();
-    } 
+    }
     else{
       general.value[30]->activate();
-      general.value[31]->activate();   
+      general.value[31]->activate();
     }
-    
+
   }
-   
+
   else if(!strcmp(what, "geo_transform")){
     if(geo.choice[3]->value() == 1){
       for(int i = 7; i <= 18; i++)
diff --git a/Fltk/optionWindow.h b/Fltk/optionWindow.h
index f41524e48a..bec9bb6c4d 100644
--- a/Fltk/optionWindow.h
+++ b/Fltk/optionWindow.h
@@ -97,6 +97,7 @@ class optionWindow{
 };
 
 void options_cb(Fl_Widget *w, void *data);
+void options_restore_defaults_cb(Fl_Widget *w, void *data);
 void general_options_cb(Fl_Widget *w, void *data);
 void geometry_options_cb(Fl_Widget *w, void *data);
 void mesh_options_cb(Fl_Widget *w, void *data);
-- 
GitLab