Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
4.9KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #include "const.h"
  19. #include <stdlib.h>
  20. #include <unistd.h>
  21. #include <sys/types.h>
  22. #include <sys/stat.h>
  23. #include <FL/Fl.H>
  24. #include <FL/Fl_Double_Window.H>
  25. #include <FL/Fl_Scroll.H>
  26. #include <FL/Fl_Tooltip.H>
  27. #include <FL/fl_ask.H>
  28. #include <FL/Fl_Shared_Image.H>
  29. #include <FL/Fl_Pack.H>
  30. #include <FL/Boxtypes.H>
  31. #include "util/Thread.H"
  32. #include "util/debug.h"
  33. #include "Mixer.H"
  34. #include "Project.H"
  35. #include "Loggable.H"
  36. /* for registration */
  37. #include "Module.H"
  38. #include "Gain_Module.H"
  39. #include "Plugin_Module.H"
  40. #include "JACK_Module.H"
  41. #include "Meter_Module.H"
  42. #include "Meter_Indicator_Module.H"
  43. #include "Controller_Module.H"
  44. #include "Mono_Pan_Module.H"
  45. #include "Chain.H"
  46. #include "Mixer_Strip.H"
  47. /* TODO: put these in a header */
  48. #define USER_CONFIG_DIR ".non-mixer/"
  49. char *user_config_dir;
  50. Mixer *mixer;
  51. const char *instance_name;
  52. #include <errno.h>
  53. static int
  54. ensure_dirs ( void )
  55. {
  56. asprintf( &user_config_dir, "%s/%s", getenv( "HOME" ), USER_CONFIG_DIR );
  57. int r = mkdir( user_config_dir, 0777 );
  58. return r == 0 || errno == EEXIST;
  59. }
  60. #include <signal.h>
  61. static void cb_main ( Fl_Double_Window *o, void *v )
  62. {
  63. if ( Fl::event_key() != FL_Escape )
  64. o->hide();
  65. }
  66. int
  67. main ( int argc, char **argv )
  68. {
  69. Thread::init();
  70. Thread thread( "UI" );
  71. thread.set();
  72. ensure_dirs();
  73. Fl_Tooltip::color( FL_BLACK );
  74. Fl_Tooltip::textcolor( FL_YELLOW );
  75. Fl_Tooltip::size( 14 );
  76. Fl_Tooltip::hoverdelay( 0.1f );
  77. Fl::visible_focus( 0 );
  78. fl_register_images();
  79. LOG_REGISTER_CREATE( Mixer_Strip );
  80. LOG_REGISTER_CREATE( Chain );
  81. LOG_REGISTER_CREATE( Plugin_Module );
  82. LOG_REGISTER_CREATE( Gain_Module );
  83. LOG_REGISTER_CREATE( Meter_Module );
  84. LOG_REGISTER_CREATE( JACK_Module );
  85. LOG_REGISTER_CREATE( Mono_Pan_Module );
  86. LOG_REGISTER_CREATE( Meter_Indicator_Module );
  87. LOG_REGISTER_CREATE( Controller_Module );
  88. init_boxtypes();
  89. signal( SIGPIPE, SIG_IGN );
  90. Fl::get_system_colors();
  91. Fl::scheme( "plastic" );
  92. Plugin_Module::spawn_discover_thread();
  93. Fl_Double_Window *main_window;
  94. {
  95. Fl_Double_Window *o = main_window = new Fl_Double_Window( 800, 600, "Mixer" );
  96. {
  97. main_window->xclass( APP_NAME );
  98. Fl_Widget *o = mixer = new Mixer( 0, 0, main_window->w(), main_window->h(), NULL );
  99. Fl_Group::current()->resizable(o);
  100. }
  101. o->end();
  102. o->callback( (Fl_Callback*)cb_main, main_window );
  103. o->show( argc, argv );
  104. }
  105. {
  106. int r = argc - 1;
  107. int i = 1;
  108. for ( ; i < argc; ++i, --r )
  109. {
  110. if ( !strcmp( argv[i], "--instance" ) )
  111. {
  112. if ( r > 1 )
  113. {
  114. MESSAGE( "Using instance name \"%s\"", argv[i+1] );
  115. instance_name = argv[i+1];
  116. ++i;
  117. }
  118. else
  119. {
  120. FATAL( "Missing instance name" );
  121. }
  122. }
  123. else if ( !strncmp( argv[i], "--", 2 ) )
  124. {
  125. WARNING( "Unrecognized option: %s", argv[i] );
  126. }
  127. else
  128. break;
  129. }
  130. if ( r >= 1 )
  131. {
  132. MESSAGE( "Loading \"%s\"", argv[i] );
  133. if ( ! mixer->command_load( argv[i] ) )
  134. {
  135. fl_alert( "Error opening project specified on commandline" );
  136. }
  137. }
  138. }
  139. Fl::run();
  140. delete main_window;
  141. main_window = NULL;
  142. MESSAGE( "Your fun is over" );
  143. }