summaryrefslogtreecommitdiff
path: root/Source/FLTKDialog
diff options
context:
space:
mode:
authorLuis Ibanez <luis.ibanez@kitware.com>2001-07-19 14:31:24 -0400
committerLuis Ibanez <luis.ibanez@kitware.com>2001-07-19 14:31:24 -0400
commit2f76c425efc2c9d968d3e6f21f464a9c7e7ea931 (patch)
tree3cfaeaa59b097b106cf684dd684bd170d581695b /Source/FLTKDialog
parent01363294822f35a66312e58743de4aeadaf8de6f (diff)
downloadcmake-2f76c425efc2c9d968d3e6f21f464a9c7e7ea931.tar.gz
ENH: Save and Load of recent Source and Binary directories added.
Diffstat (limited to 'Source/FLTKDialog')
-rw-r--r--Source/FLTKDialog/CMakeSetupGUI.cxx74
-rw-r--r--Source/FLTKDialog/CMakeSetupGUI.fl40
-rw-r--r--Source/FLTKDialog/CMakeSetupGUI.h25
-rw-r--r--Source/FLTKDialog/CMakeSetupGUIImplementation.cxx207
-rw-r--r--Source/FLTKDialog/CMakeSetupGUIImplementation.h12
-rw-r--r--Source/FLTKDialog/FLTKDialog.cxx1
6 files changed, 349 insertions, 10 deletions
diff --git a/Source/FLTKDialog/CMakeSetupGUI.cxx b/Source/FLTKDialog/CMakeSetupGUI.cxx
index 7855d36343..62e761980e 100644
--- a/Source/FLTKDialog/CMakeSetupGUI.cxx
+++ b/Source/FLTKDialog/CMakeSetupGUI.cxx
@@ -2,6 +2,14 @@
#include "CMakeSetupGUI.h"
+inline void CMakeSetupGUI::cb_dialogWindow_i(Fl_Window*, void*) {
+ recentSourceDirectoriesBrowser->hide();
+recentBinaryDirectoriesBrowser->hide();
+}
+void CMakeSetupGUI::cb_dialogWindow(Fl_Window* o, void* v) {
+ ((CMakeSetupGUI*)(o->user_data()))->cb_dialogWindow_i(o,v);
+}
+
inline void CMakeSetupGUI::cb_sourcePathTextInput_i(Fl_Input*, void*) {
SetSourcePath( sourcePathTextInput->value() );
}
@@ -44,18 +52,46 @@ void CMakeSetupGUI::cb_Build(Fl_Button* o, void* v) {
((CMakeSetupGUI*)(o->parent()->user_data()))->cb_Build_i(o,v);
}
+inline void CMakeSetupGUI::cb_2_i(Fl_Button*, void*) {
+ ShowRecentSourceDirectories();
+}
+void CMakeSetupGUI::cb_2(Fl_Button* o, void* v) {
+ ((CMakeSetupGUI*)(o->parent()->user_data()))->cb_2_i(o,v);
+}
+
+inline void CMakeSetupGUI::cb_21_i(Fl_Button*, void*) {
+ ShowRecentBinaryDirectories();
+}
+void CMakeSetupGUI::cb_21(Fl_Button* o, void* v) {
+ ((CMakeSetupGUI*)(o->parent()->user_data()))->cb_21_i(o,v);
+}
+
+inline void CMakeSetupGUI::cb_recentSourceDirectoriesBrowser_i(Fl_Browser*, void*) {
+ SelectOneRecentSourceDirectory();
+}
+void CMakeSetupGUI::cb_recentSourceDirectoriesBrowser(Fl_Browser* o, void* v) {
+ ((CMakeSetupGUI*)(o->parent()->user_data()))->cb_recentSourceDirectoriesBrowser_i(o,v);
+}
+
+inline void CMakeSetupGUI::cb_recentBinaryDirectoriesBrowser_i(Fl_Browser*, void*) {
+ SelectOneRecentBinaryDirectory();
+}
+void CMakeSetupGUI::cb_recentBinaryDirectoriesBrowser(Fl_Browser* o, void* v) {
+ ((CMakeSetupGUI*)(o->parent()->user_data()))->cb_recentBinaryDirectoriesBrowser_i(o,v);
+}
+
CMakeSetupGUI::CMakeSetupGUI() {
Fl_Window* w;
{ Fl_Window* o = dialogWindow = new Fl_Window(563, 363, "CMakeSetupDialog");
w = o;
- o->user_data((void*)(this));
+ o->callback((Fl_Callback*)cb_dialogWindow, (void*)(this));
{ Fl_Input* o = sourcePathTextInput = new Fl_Input(219, 15, 200, 20, "Where is the source code: ");
o->labelsize(11);
o->textsize(11);
o->callback((Fl_Callback*)cb_sourcePathTextInput);
o->when(FL_WHEN_ENTER_KEY);
}
- { Fl_Button* o = new Fl_Button(426, 14, 65, 22, "Browse...");
+ { Fl_Button* o = new Fl_Button(453, 14, 65, 22, "Browse...");
o->shortcut(0x80073);
o->labelsize(11);
o->callback((Fl_Callback*)cb_Browse);
@@ -66,7 +102,7 @@ CMakeSetupGUI::CMakeSetupGUI() {
o->callback((Fl_Callback*)cb_binaryPathTextInput);
o->when(FL_WHEN_ENTER_KEY);
}
- { Fl_Button* o = new Fl_Button(426, 50, 65, 22, "Browse...");
+ { Fl_Button* o = new Fl_Button(453, 49, 65, 22, "Browse...");
o->shortcut(0x80062);
o->labelsize(11);
o->callback((Fl_Callback*)cb_Browse1);
@@ -104,6 +140,26 @@ CMakeSetupGUI::CMakeSetupGUI() {
{ Fl_Box* o = new Fl_Box(141, 305, 275, 25, "Right click on cache entries for additional options");
o->labelsize(11);
}
+ { Fl_Button* o = new Fl_Button(420, 15, 22, 21, "@#2>");
+ o->labeltype(FL_SYMBOL_LABEL);
+ o->callback((Fl_Callback*)cb_2);
+ }
+ { Fl_Button* o = new Fl_Button(420, 50, 22, 21, "@#2>");
+ o->labeltype(FL_SYMBOL_LABEL);
+ o->callback((Fl_Callback*)cb_21);
+ }
+ { Fl_Browser* o = recentSourceDirectoriesBrowser = new Fl_Browser(15, 35, 535, 115);
+ o->type(2);
+ o->box(FL_BORDER_BOX);
+ o->callback((Fl_Callback*)cb_recentSourceDirectoriesBrowser);
+ o->hide();
+ }
+ { Fl_Browser* o = recentBinaryDirectoriesBrowser = new Fl_Browser(15, 70, 535, 115);
+ o->type(2);
+ o->box(FL_BORDER_BOX);
+ o->callback((Fl_Callback*)cb_recentBinaryDirectoriesBrowser);
+ o->hide();
+ }
o->end();
}
}
@@ -131,3 +187,15 @@ bool CMakeSetupGUI::SetBinaryPath(const char *) {
bool CMakeSetupGUI::SetSourcePath(const char *) {
}
+
+void CMakeSetupGUI::ShowRecentBinaryDirectories(void) {
+}
+
+void CMakeSetupGUI::ShowRecentSourceDirectories(void) {
+}
+
+void CMakeSetupGUI::SelectOneRecentBinaryDirectory(void) {
+}
+
+void CMakeSetupGUI::SelectOneRecentSourceDirectory(void) {
+}
diff --git a/Source/FLTKDialog/CMakeSetupGUI.fl b/Source/FLTKDialog/CMakeSetupGUI.fl
index 1c6dc1e136..ab24bc8cdd 100644
--- a/Source/FLTKDialog/CMakeSetupGUI.fl
+++ b/Source/FLTKDialog/CMakeSetupGUI.fl
@@ -7,11 +7,13 @@ gridy 5
snap 3
class CMakeSetupGUI {open
} {
- Function {CMakeSetupGUI()} {open selected
+ Function {CMakeSetupGUI()} {open
} {
Fl_Window dialogWindow {
label CMakeSetupDialog
- xywh {190 106 563 363} resizable visible
+ callback {recentSourceDirectoriesBrowser->hide();
+recentBinaryDirectoriesBrowser->hide();} open selected
+ xywh {645 144 563 363} resizable visible
} {
Fl_Input sourcePathTextInput {
label {Where is the source code: }
@@ -21,7 +23,7 @@ class CMakeSetupGUI {open
Fl_Button {} {
label {Browse...}
callback {BrowseForSourcePath();}
- xywh {426 14 65 22} shortcut 0x80073 labelsize 11
+ xywh {453 14 65 22} shortcut 0x80073 labelsize 11
}
Fl_Input binaryPathTextInput {
label {Where do you want to build the binaries: }
@@ -31,11 +33,11 @@ class CMakeSetupGUI {open
Fl_Button {} {
label {Browse...}
callback {BrowseForBinaryPath();}
- xywh {426 50 65 22} shortcut 0x80062 labelsize 11
+ xywh {453 49 65 22} shortcut 0x80062 labelsize 11
}
Fl_Button {} {
label Close
- callback {Close()}
+ callback {Close();}
xywh {345 331 77 23} shortcut 0x80071 labelsize 11
}
Fl_Button {} {
@@ -43,7 +45,7 @@ class CMakeSetupGUI {open
callback {BuildProjectFiles();}
xywh {123 332 101 23} shortcut 0x8006d labelsize 11
}
- Fl_Group {} {open
+ Fl_Group {} {
xywh {25 80 515 222} box ENGRAVED_BOX labelsize 11 align 0 resizable
} {
Fl_Scroll cacheValuesScroll {
@@ -59,6 +61,24 @@ class CMakeSetupGUI {open
label {Right click on cache entries for additional options}
xywh {141 305 275 25} labelsize 11
}
+ Fl_Button {} {
+ label {@\#2>}
+ callback {ShowRecentSourceDirectories();}
+ xywh {420 15 22 21} labeltype SYMBOL_LABEL
+ }
+ Fl_Button {} {
+ label {@\#2>}
+ callback {ShowRecentBinaryDirectories();}
+ xywh {420 50 22 21} labeltype SYMBOL_LABEL
+ }
+ Fl_Browser recentSourceDirectoriesBrowser {
+ callback {SelectOneRecentSourceDirectory();}
+ xywh {15 35 535 115} type Hold box BORDER_BOX hide
+ }
+ Fl_Browser recentBinaryDirectoriesBrowser {
+ callback {SelectOneRecentBinaryDirectory();}
+ xywh {15 70 535 115} type Hold box BORDER_BOX hide
+ }
}
}
Function {~CMakeSetupGUI()} {} {}
@@ -76,4 +96,12 @@ class CMakeSetupGUI {open
} {}
Function {SetSourcePath(const char *)} {return_type {virtual bool}
} {}
+ Function {ShowRecentBinaryDirectories(void)} {return_type {virtual void}
+ } {}
+ Function {ShowRecentSourceDirectories(void)} {return_type {virtual void}
+ } {}
+ Function {SelectOneRecentBinaryDirectory(void)} {return_type {virtual void}
+ } {}
+ Function {SelectOneRecentSourceDirectory(void)} {return_type {virtual void}
+ } {}
}
diff --git a/Source/FLTKDialog/CMakeSetupGUI.h b/Source/FLTKDialog/CMakeSetupGUI.h
index 1a35110ecc..e28e8e3c89 100644
--- a/Source/FLTKDialog/CMakeSetupGUI.h
+++ b/Source/FLTKDialog/CMakeSetupGUI.h
@@ -10,11 +10,16 @@
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Pack.H>
#include <FL/Fl_Box.H>
+#include <FL/Fl_Browser.H>
class CMakeSetupGUI {
public:
CMakeSetupGUI();
Fl_Window *dialogWindow;
+private:
+ inline void cb_dialogWindow_i(Fl_Window*, void*);
+ static void cb_dialogWindow(Fl_Window*, void*);
+public:
Fl_Input *sourcePathTextInput;
private:
inline void cb_sourcePathTextInput_i(Fl_Input*, void*);
@@ -35,6 +40,22 @@ private:
public:
Fl_Scroll *cacheValuesScroll;
Fl_Pack *propertyListPack;
+private:
+ inline void cb_2_i(Fl_Button*, void*);
+ static void cb_2(Fl_Button*, void*);
+ inline void cb_21_i(Fl_Button*, void*);
+ static void cb_21(Fl_Button*, void*);
+public:
+ Fl_Browser *recentSourceDirectoriesBrowser;
+private:
+ inline void cb_recentSourceDirectoriesBrowser_i(Fl_Browser*, void*);
+ static void cb_recentSourceDirectoriesBrowser(Fl_Browser*, void*);
+public:
+ Fl_Browser *recentBinaryDirectoriesBrowser;
+private:
+ inline void cb_recentBinaryDirectoriesBrowser_i(Fl_Browser*, void*);
+ static void cb_recentBinaryDirectoriesBrowser(Fl_Browser*, void*);
+public:
~CMakeSetupGUI();
virtual void Close(void);
virtual void BuildProjectFiles(void);
@@ -43,5 +64,9 @@ public:
virtual void Show(void);
virtual bool SetBinaryPath(const char *);
virtual bool SetSourcePath(const char *);
+ virtual void ShowRecentBinaryDirectories(void);
+ virtual void ShowRecentSourceDirectories(void);
+ virtual void SelectOneRecentBinaryDirectory(void);
+ virtual void SelectOneRecentSourceDirectory(void);
};
#endif
diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
index 7754ba44c2..170a37d46d 100644
--- a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
+++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
@@ -55,6 +55,7 @@ void
CMakeSetupGUIImplementation
::Close( void )
{
+ SaveRecentDirectories();
dialogWindow->hide();
}
@@ -120,7 +121,6 @@ void
CMakeSetupGUIImplementation
::SetPathToExecutable( const char * path )
{
- m_PathToExecutable = path;
char expandedPath[1024];
filename_expand( expandedPath, path );
@@ -333,6 +333,9 @@ CMakeSetupGUIImplementation
// Make sure we are working from the cache on disk
this->LoadCacheFromDiskToGUI();
+ UpdateListOfRecentDirectories();
+ SaveRecentDirectories();
+
// create a cmake object
cmake make;
// create the arguments for the cmake object
@@ -358,6 +361,7 @@ CMakeSetupGUIImplementation
// path is up-to-date now
m_BuildPathChanged = false;
+
// put the cursor back
fl_cursor(FL_CURSOR_DEFAULT,FL_BLACK,FL_WHITE);
fl_message("Done !");
@@ -515,3 +519,204 @@ CMakeSetupGUIImplementation
}
+
+
+/**
+ * Load Recent Directories
+ */
+void
+CMakeSetupGUIImplementation
+::LoadRecentDirectories( void )
+{
+ std::string home = getenv("HOME");
+ std::string filename = home + "/.cmakerc";
+
+ std::ifstream input;
+ input.open(filename.c_str());
+
+ if( input.fail() )
+ {
+ // probably the file doesn't exist
+ return;
+ }
+
+ m_RecentBinaryDirectories.clear();
+ m_RecentSourceDirectories.clear();
+
+ std::string key;
+ std::string onedirectory;
+
+ while( !input.eof() )
+ {
+ input >> key;
+
+ if( input.eof() ) break;
+
+ if( key == "MostRecentSource" )
+ {
+ input >> onedirectory;
+ m_WhereSource = onedirectory;
+ sourcePathTextInput->value( m_WhereSource.c_str() );
+ } else
+ if( key == "MostRecentBinary" )
+ {
+ input >> onedirectory;
+ m_WhereBuild = onedirectory;
+ binaryPathTextInput->value( m_WhereBuild.c_str() );
+ } else
+ if( key == "Binary" )
+ {
+ input >> onedirectory;
+ // insert is only done if the directory doesn't exist
+ m_RecentBinaryDirectories.insert( onedirectory );
+ recentBinaryDirectoriesBrowser->add(
+ (onedirectory.c_str()),
+ (void*)(onedirectory.c_str()) );
+ } else
+ if( key == "Source" )
+ {
+ input >> onedirectory;
+ // insert is only done if the directory doesn't exist
+ m_RecentSourceDirectories.insert( onedirectory );
+ recentSourceDirectoriesBrowser->add(
+ (onedirectory.c_str()),
+ (void*)(onedirectory.c_str()) );
+ }
+
+ }
+
+ input.close();
+}
+
+
+
+/**
+ * Save Recent Directories
+ */
+void
+CMakeSetupGUIImplementation
+::SaveRecentDirectories( void )
+{
+ std::string home = getenv("HOME");
+
+ if( home.empty() )
+ {
+ return;
+ }
+
+ std::string filename = home + "/.cmakerc";
+
+ std::ofstream output;
+ output.open(filename.c_str());
+
+ output << "MostRecentBinary " << m_WhereBuild << std::endl;
+ output << "MostRecentSource " << m_WhereSource << std::endl;
+
+ // Save Recent binary directories
+ std::set< std::string >::iterator bindir =
+ m_RecentBinaryDirectories.begin();
+
+ while( bindir != m_RecentBinaryDirectories.end() )
+ {
+ output << "Binary " << *bindir << std::endl;
+ bindir++;
+ }
+
+
+ // Save Recent source directories
+ std::set< std::string >::iterator srcdir =
+ m_RecentSourceDirectories.begin();
+
+ while( srcdir != m_RecentSourceDirectories.end() )
+ {
+ output << "Source " << *srcdir << std::endl;
+ srcdir++;
+ }
+
+}
+
+
+/**
+ * Show Recent Binary Directories
+ */
+void
+CMakeSetupGUIImplementation
+::ShowRecentBinaryDirectories( void )
+{
+ recentBinaryDirectoriesBrowser->Fl_Widget::show();
+}
+
+
+/**
+ * Show Recent Source Directories
+ */
+void
+CMakeSetupGUIImplementation
+::ShowRecentSourceDirectories( void )
+{
+ recentSourceDirectoriesBrowser->Fl_Widget::show();
+}
+
+
+/**
+ * Select one Recent Binary Directory
+ */
+void
+CMakeSetupGUIImplementation
+::SelectOneRecentBinaryDirectory( void )
+{
+ const int selected = recentBinaryDirectoriesBrowser->value();
+ if( selected == 0 )
+ {
+ return;
+ }
+
+ m_WhereBuild = static_cast<char *>(
+ recentBinaryDirectoriesBrowser->data( selected ));
+ binaryPathTextInput->value( m_WhereBuild.c_str() );
+ recentBinaryDirectoriesBrowser->Fl_Widget::hide();
+}
+
+
+/**
+ * Select one Recent Source Directory
+ */
+void
+CMakeSetupGUIImplementation
+::SelectOneRecentSourceDirectory( void )
+{
+ const int selected = recentSourceDirectoriesBrowser->value();
+ if( selected == 0 )
+ {
+ return;
+ }
+ m_WhereSource = static_cast< char * >(
+ recentSourceDirectoriesBrowser->data( selected ));
+ sourcePathTextInput->value( m_WhereSource.c_str() );
+ recentSourceDirectoriesBrowser->Fl_Widget::hide();
+}
+
+
+
+/**
+ * Update List of Recent Directories
+ */
+void
+CMakeSetupGUIImplementation
+::UpdateListOfRecentDirectories( void )
+{
+
+ // Update Recent binary directories
+ // insert is only done if the directory doesn't exist
+ m_RecentBinaryDirectories.insert( m_WhereBuild );
+
+ // Update Recent source directories
+ // insert is only done if the directory doesn't exist
+ m_RecentSourceDirectories.insert( m_WhereSource );
+
+}
+
+
+
+
+
diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.h b/Source/FLTKDialog/CMakeSetupGUIImplementation.h
index 9720125d95..273ac168f4 100644
--- a/Source/FLTKDialog/CMakeSetupGUIImplementation.h
+++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.h
@@ -4,6 +4,7 @@
#include "CMakeSetupGUI.h"
#include "FLTKPropertyList.h"
+#include <set>
/**
@@ -33,6 +34,13 @@ public:
virtual void FillCacheGUIFromCacheManager( void );
virtual void FillCacheManagerFromCacheGUI( void );
virtual void SetPathToExecutable( const char * path );
+ virtual void LoadRecentDirectories(void);
+ virtual void SaveRecentDirectories(void);
+ virtual void ShowRecentBinaryDirectories(void);
+ virtual void ShowRecentSourceDirectories(void);
+ virtual void SelectOneRecentSourceDirectory(void);
+ virtual void SelectOneRecentBinaryDirectory(void);
+ virtual void UpdateListOfRecentDirectories(void);
private:
virtual bool VerifyBinaryPath( const std::string & path ) const;
@@ -45,6 +53,10 @@ private:
std::string m_WhereSource;
std::string m_PathToExecutable;
bool m_BuildPathChanged;
+
+ std::set< std::string > m_RecentBinaryDirectories;
+ std::set< std::string > m_RecentSourceDirectories;
+
};
diff --git a/Source/FLTKDialog/FLTKDialog.cxx b/Source/FLTKDialog/FLTKDialog.cxx
index 39a3c38f13..6ceed77f5c 100644
--- a/Source/FLTKDialog/FLTKDialog.cxx
+++ b/Source/FLTKDialog/FLTKDialog.cxx
@@ -13,6 +13,7 @@ int main(int argc, char * argv[] )
gui->SetPathToExecutable( argv[0] );
gui->Show();
+ gui->LoadRecentDirectories();
gui->LoadCacheFromDiskToGUI();
Fl::run();