CMakeSetupGUIImplementation.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. #include "CMakeSetupGUIImplementation.h"
  2. #include "Fl/fl_file_chooser.H"
  3. #include "Fl/filename.H"
  4. #include "Fl/fl_ask.H"
  5. #include "cstring"
  6. /**
  7. * Constructor
  8. */
  9. CMakeSetupGUIImplementation
  10. ::CMakeSetupGUIImplementation()
  11. {
  12. }
  13. /**
  14. * Destructor
  15. */
  16. CMakeSetupGUIImplementation
  17. ::~CMakeSetupGUIImplementation()
  18. {
  19. }
  20. /**
  21. * Show the graphic interface
  22. */
  23. void
  24. CMakeSetupGUIImplementation
  25. ::Show( void )
  26. {
  27. dialogWindow->show();
  28. }
  29. /**
  30. * Hide the graphic interface
  31. */
  32. void
  33. CMakeSetupGUIImplementation
  34. ::Close( void )
  35. {
  36. dialogWindow->hide();
  37. }
  38. /**
  39. * Browse for the path to the sources
  40. */
  41. void
  42. CMakeSetupGUIImplementation
  43. ::BrowseForSourcePath( void )
  44. {
  45. const char * path =
  46. fl_file_chooser(
  47. "Path to Sources",
  48. "",
  49. sourcePathTextInput->value() );
  50. if( !path )
  51. {
  52. return;
  53. }
  54. SetSourcePath( path );
  55. }
  56. /**
  57. * Browse for the path to the binaries
  58. */
  59. void
  60. CMakeSetupGUIImplementation
  61. ::BrowseForBinaryPath( void )
  62. {
  63. const char * path =
  64. fl_file_chooser(
  65. "Path to Binaries",
  66. "",
  67. binaryPathTextInput->value() );
  68. if( !path )
  69. {
  70. return;
  71. }
  72. binaryPathTextInput->value( path );
  73. }
  74. /**
  75. * Set the source path
  76. */
  77. void
  78. CMakeSetupGUIImplementation
  79. ::SetSourcePath( const char * path )
  80. {
  81. if( VerifySourcePath( path ) )
  82. {
  83. sourcePathTextInput->value( path );
  84. }
  85. }
  86. /**
  87. * Set the binary path
  88. */
  89. void
  90. CMakeSetupGUIImplementation
  91. ::SetBinaryPath( const char * path )
  92. {
  93. if( VerifyBinaryPath( path ) )
  94. {
  95. binaryPathTextInput->value( path );
  96. }
  97. }
  98. /**
  99. * Verify the path to binaries
  100. */
  101. bool
  102. CMakeSetupGUIImplementation
  103. ::VerifyBinaryPath( const char * path )
  104. {
  105. if( !path || strlen(path)==0 )
  106. {
  107. fl_alert("Please select the path to the binaries");
  108. return false;
  109. }
  110. if( !filename_isdir( path ) )
  111. {
  112. fl_alert("%s \n Doesn't exist or is not a directory",path);
  113. return false;
  114. }
  115. return true;
  116. }
  117. /**
  118. * Verify the path to sources
  119. */
  120. bool
  121. CMakeSetupGUIImplementation
  122. ::VerifySourcePath( const char * path )
  123. {
  124. if( !path || strlen(path)==0 )
  125. {
  126. fl_alert("Please select the path to the sources");
  127. return false;
  128. }
  129. if( !filename_isdir( path ) )
  130. {
  131. fl_alert("%s \n Doesn't exist or is not a directory",path);
  132. return false;
  133. }
  134. return true;
  135. }
  136. /**
  137. * Build the project files
  138. */
  139. void
  140. CMakeSetupGUIImplementation
  141. ::BuildProjectFiles( void )
  142. {
  143. // Verify that source path is a valid directory
  144. if( !VerifySourcePath( sourcePathTextInput->value() ) )
  145. {
  146. return;
  147. }
  148. // Verify that binary path is a valid directory
  149. if( !VerifyBinaryPath( binaryPathTextInput->value() ) )
  150. {
  151. return;
  152. }
  153. fl_message("Building project files ... please wait");
  154. }