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.

886 lines
21KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2009 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 "Module.H"
  19. #include <FL/fl_draw.H>
  20. #include <FL/fl_ask.H>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <stdio.h>
  24. #include "Module_Parameter_Editor.H"
  25. #include "Chain.H"
  26. #include "JACK_Module.H"
  27. #include "Gain_Module.H"
  28. #include "Mono_Pan_Module.H"
  29. #include "Meter_Module.H"
  30. #include "Plugin_Module.H"
  31. #include <FL/Fl_Menu_Button.H>
  32. #include "FL/test_press.H"
  33. #include "FL/menu_popup.H"
  34. #include "Mixer.H"
  35. #include "OSC/Endpoint.H"
  36. #include "string_util.h"
  37. Module *Module::_copied_module_empty = 0;
  38. char *Module::_copied_module_settings = 0;
  39. Module::Module ( int W, int H, const char *L ) : Fl_Group( 0, 0, W, H, L )
  40. {
  41. init();
  42. log_create();
  43. }
  44. Module::Module ( bool is_default, int W, int H, const char *L ) : Fl_Group( 0, 0, W, H, L ), Loggable( !is_default )
  45. {
  46. this->is_default( is_default );
  47. init();
  48. log_create();
  49. }
  50. Module::Module ( ) : Fl_Group( 0, 0, 50, 50, "Unnamed" )
  51. {
  52. init();
  53. log_create();
  54. }
  55. Module::~Module ( )
  56. {
  57. /* we assume that the engine for this chain is already locked */
  58. if ( _editor )
  59. {
  60. delete _editor;
  61. _editor = NULL;
  62. }
  63. for ( unsigned int i = 0; i < audio_input.size(); ++i )
  64. audio_input[i].disconnect();
  65. for ( unsigned int i = 0; i < audio_output.size(); ++i )
  66. audio_output[i].disconnect();
  67. for ( unsigned int i = 0; i < control_input.size(); ++i )
  68. {
  69. /* destroy connected Controller_Module */
  70. if ( control_input[i].connected() )
  71. {
  72. Module *o = (Module*)control_input[i].connected_port()->module();
  73. control_input[i].disconnect();
  74. delete o;
  75. }
  76. control_input[i].destroy_osc_port();
  77. }
  78. for ( unsigned int i = 0; i < control_output.size(); ++i )
  79. control_output[i].disconnect();
  80. audio_input.clear();
  81. audio_output.clear();
  82. control_input.clear();
  83. control_output.clear();
  84. if ( parent() )
  85. parent()->remove( this );
  86. }
  87. void
  88. Module::init ( void )
  89. {
  90. _is_default = false;
  91. _editor = 0;
  92. _chain = 0;
  93. _instances = 1;
  94. _bypass = 0;
  95. box( FL_UP_BOX );
  96. labeltype( FL_NO_LABEL );
  97. set_visible_focus();
  98. selection_color( FL_RED );
  99. color( fl_color_average( FL_WHITE, FL_CYAN, 0.40 ) );
  100. }
  101. void
  102. Module::get ( Log_Entry &e ) const
  103. {
  104. // e.add( ":name", label() );
  105. // e.add( ":color", (unsigned long)color());
  106. {
  107. char *s = get_parameters();
  108. if ( strlen( s ) )
  109. e.add( ":parameter_values", s );
  110. delete[] s;
  111. }
  112. e.add( ":is_default", is_default() );
  113. e.add( ":chain", chain() );
  114. e.add( ":active", ! bypass() );
  115. }
  116. void
  117. Module::copy ( void ) const
  118. {
  119. Module *m = clone_empty();
  120. if ( ! m )
  121. {
  122. DMESSAGE( "Module \"%s\" doesn't support cloning", name() );
  123. }
  124. Log_Entry *ne = new Log_Entry();
  125. _copied_module_empty = m;
  126. {
  127. Log_Entry e;
  128. get( e );
  129. for ( int i = 0; i < e.size(); ++i )
  130. {
  131. const char *s, *v;
  132. e.get( i, &s, &v );
  133. /* we don't want this module to get added to the current
  134. chain... */
  135. if ( !( !strcmp( s, ":chain" ) ||
  136. !strcmp( s, ":is_default" ) ) )
  137. {
  138. DMESSAGE( "%s = %s", s, v );
  139. ne->add_raw( s, v );
  140. }
  141. }
  142. }
  143. _copied_module_settings = ne->print();
  144. }
  145. void
  146. Module::paste_before ( void )
  147. {
  148. Module *m = _copied_module_empty;
  149. Log_Entry le( _copied_module_settings );
  150. le.remove( ":chain" );
  151. char *print = le.print();
  152. DMESSAGE( "Pasting settings: %s", print );
  153. free( print );
  154. m->set( le );
  155. if ( ! chain()->insert( this, m ) )
  156. {
  157. fl_alert( "Copied module cannot be inserted at this point in the chain" );
  158. }
  159. free( _copied_module_settings );
  160. _copied_module_settings = NULL;
  161. _copied_module_empty = NULL;
  162. /* set up for another paste */
  163. m->copy();
  164. }
  165. void
  166. Module::handle_control_changed ( Port *p )
  167. {
  168. if ( _editor )
  169. _editor->handle_control_changed ( p );
  170. }
  171. bool
  172. Module::Port::connected_osc ( void ) const
  173. {
  174. return _scaled_signal->connected();
  175. }
  176. char *
  177. Module::Port::generate_osc_path ()
  178. {
  179. const Port *p = this;
  180. char *path = NULL;
  181. // /strip/STRIPNAME/MODULENAME/CONTROLNAME
  182. if ( ! module()->allows_external_control() )
  183. {
  184. /* Don't create signals for the default modules other than Gain */
  185. return NULL;
  186. }
  187. int n = module()->chain()->get_module_instance_number( module() );
  188. if ( n > 0 )
  189. asprintf( &path, "/strip/%s/%s.%i/%s", module()->chain()->name(), p->module()->label(), n, p->name() );
  190. else
  191. asprintf( &path, "/strip/%s/%s/%s", module()->chain()->name(), p->module()->label(), p->name() );
  192. char *s = escape_url( path );
  193. free( path );
  194. path = s;
  195. return path;
  196. }
  197. void
  198. Module::Port::handle_signal_connection_state_changed ( OSC::Signal *, void *o )
  199. {
  200. ((Module::Port*)o)->module()->redraw();
  201. }
  202. void
  203. Module::Port::change_osc_path ( char *path )
  204. {
  205. if ( path )
  206. {
  207. char *scaled_path = path;
  208. char *unscaled_path = NULL;
  209. asprintf( &unscaled_path, "%s/unscaled", path );
  210. if ( NULL == _scaled_signal )
  211. {
  212. float scaled_default = 0.5f;
  213. if ( hints.ranged )
  214. {
  215. float scale = hints.maximum - hints.minimum;
  216. float offset = hints.minimum;
  217. scaled_default = ( hints.default_value - offset ) / scale;
  218. }
  219. _scaled_signal = mixer->osc_endpoint->add_signal( scaled_path,
  220. OSC::Signal::Input,
  221. 0.0, 1.0, scaled_default,
  222. &Module::Port::osc_control_change_cv, this );
  223. _scaled_signal->connection_state_callback( handle_signal_connection_state_changed, this );
  224. _unscaled_signal = mixer->osc_endpoint->add_signal( unscaled_path,
  225. OSC::Signal::Input,
  226. hints.minimum, hints.maximum, hints.default_value,
  227. &Module::Port::osc_control_change_exact, this );
  228. }
  229. else
  230. {
  231. DMESSAGE( "Renaming OSC signals" );
  232. _scaled_signal->rename( scaled_path );
  233. _unscaled_signal->rename( unscaled_path );
  234. }
  235. free( unscaled_path );
  236. /* this was path, it's ok to free because it was malloc()'d in generate_osc_path */
  237. free( scaled_path );
  238. }
  239. }
  240. int
  241. Module::Port::osc_control_change_exact ( float v, void *user_data )
  242. {
  243. Module::Port *p = (Module::Port*)user_data;
  244. Fl::lock();
  245. float f = v;
  246. if ( p->hints.ranged )
  247. {
  248. if ( f > p->hints.maximum )
  249. f = p->hints.maximum;
  250. else if ( f < p->hints.minimum )
  251. f = p->hints.minimum;
  252. }
  253. p->control_value( f );
  254. Fl::unlock();
  255. // mixer->osc_endpoint->send( lo_message_get_source( msg ), "/reply", path, f );
  256. return 0;
  257. }
  258. int
  259. Module::Port::osc_control_change_cv ( float v, void *user_data )
  260. {
  261. Module::Port *p = (Module::Port*)user_data;
  262. float f = v;
  263. Fl::lock();
  264. // clamp value to control voltage range.
  265. if ( f > 1.0 )
  266. f = 1.0;
  267. else if ( f < 0.0 )
  268. f = 0.0;
  269. if ( p->hints.ranged )
  270. {
  271. // scale value to range.
  272. float scale = p->hints.maximum - p->hints.minimum;
  273. float offset = p->hints.minimum;
  274. f = ( f * scale ) + offset;
  275. }
  276. p->control_value( f );
  277. Fl::unlock();
  278. // mixer->osc_endpoint->send( lo_message_get_source( msg ), "/reply", path, f );
  279. return 0;
  280. }
  281. void
  282. Module::set ( Log_Entry &e )
  283. {
  284. for ( int i = 0; i < e.size(); ++i )
  285. {
  286. const char *s, *v;
  287. e.get( i, &s, &v );
  288. if ( ! strcmp( s, ":chain" ) )
  289. {
  290. /* This trickiness is because we may need to know the name of
  291. our chain before we actually get added to it. */
  292. int i;
  293. sscanf( v, "%X", &i );
  294. Chain *t = (Chain*)Loggable::find( i );
  295. assert( t );
  296. chain( t );
  297. }
  298. }
  299. for ( int i = 0; i < e.size(); ++i )
  300. {
  301. const char *s, *v;
  302. e.get( i, &s, &v );
  303. /* if ( ! strcmp( s, ":name" ) ) */
  304. /* label( v ); */
  305. if ( ! strcmp( s, ":parameter_values" ) )
  306. {
  307. set_parameters( v );
  308. }
  309. else if ( ! ( strcmp( s, ":is_default" ) ) )
  310. {
  311. is_default( atoi( v ) );
  312. }
  313. else if ( ! ( strcmp( s, ":active" ) ) )
  314. {
  315. bypass( ! atoi( v ) );
  316. }
  317. else if ( ! strcmp( s, ":chain" ) )
  318. {
  319. int i;
  320. sscanf( v, "%X", &i );
  321. Chain *t = (Chain*)Loggable::find( i );
  322. assert( t );
  323. t->add( this );
  324. }
  325. }
  326. }
  327. void
  328. Module::chain ( Chain *v )
  329. {
  330. if ( _chain != v )
  331. {
  332. DMESSAGE( "Adding module %s in to chain %s", label(), v ? v->name() : "NULL" );
  333. _chain = v;
  334. for ( int i = 0; i < ncontrol_inputs(); ++i )
  335. {
  336. control_input[i].update_osc_port();
  337. }
  338. }
  339. else
  340. {
  341. DMESSAGE( "Module %s already belongs to chain %s", label(), v ? v->name() : "NULL" );
  342. }
  343. }
  344. /* return a string serializing this module's parameter settings. The
  345. format is 1.0:2.0:... Where 1.0 is the value of the first control
  346. input, 2.0 is the value of the second control input etc.
  347. */
  348. char *
  349. Module::get_parameters ( void ) const
  350. {
  351. char *s = new char[1024];
  352. s[0] = 0;
  353. char *sp = s;
  354. if ( control_input.size() )
  355. {
  356. for ( unsigned int i = 0; i < control_input.size(); ++i )
  357. sp += snprintf( sp, 1024 - (sp - s),"%f:", control_input[i].control_value() );
  358. *(sp - 1) = '\0';
  359. }
  360. return s;
  361. }
  362. void
  363. Module::set_parameters ( const char *parameters )
  364. {
  365. char *s = strdup( parameters );
  366. char *start = s;
  367. unsigned int i = 0;
  368. for ( char *sp = s; ; ++sp )
  369. {
  370. if ( ':' == *sp || '\0' == *sp )
  371. {
  372. char was = *sp;
  373. *sp = '\0';
  374. DMESSAGE( start );
  375. if ( i < control_input.size() )
  376. control_input[i].control_value( atof( start ) );
  377. else
  378. {
  379. WARNING( "Module has no parameter at index %i", i );
  380. break;
  381. }
  382. i++;
  383. if ( '\0' == was )
  384. break;
  385. start = sp + 1;
  386. }
  387. }
  388. free( s );
  389. }
  390. void
  391. Module::draw_box ( void )
  392. {
  393. fl_color( fl_contrast( FL_FOREGROUND_COLOR, color() ) );
  394. int tw, th, tx, ty;
  395. tw = w();
  396. th = h();
  397. ty = y();
  398. tx = x();
  399. fl_push_clip( tx, ty, tw, th );
  400. Fl_Color c = color();
  401. c = active() && ! bypass() ? c : FL_GRAY;
  402. int spacing = w() / instances();
  403. for ( int i = instances(); i--; )
  404. {
  405. fl_draw_box( box(), tx + (spacing * i), ty, tw / instances(), th, c );
  406. }
  407. if ( this == Fl::focus() )
  408. {
  409. fl_draw_box( FL_UP_FRAME, x(), y(), w(), h(), selection_color() );
  410. }
  411. if ( audio_input.size() && audio_output.size() )
  412. {
  413. /* maybe draw control indicators */
  414. if ( control_input.size() )
  415. {
  416. fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + 4, 5, 5, is_being_controlled() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );
  417. fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + th - 8, 5, 5, is_being_controlled_osc() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );
  418. }
  419. if ( control_output.size() )
  420. fl_draw_box( FL_ROUNDED_BOX, tx + tw - 8, ty + 4, 5, 5, is_controlling() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );
  421. }
  422. Fl_Group::draw_children();
  423. fl_pop_clip();
  424. }
  425. void
  426. Module::draw_label ( void )
  427. {
  428. int tw, th, tx, ty;
  429. bbox( tx, ty, tw, th );
  430. const char *lp = label();
  431. fl_color( fl_contrast( FL_FOREGROUND_COLOR, bypass() ? FL_BLACK : color() ) );
  432. fl_font( FL_HELVETICA, 12 );
  433. int LW = fl_width( lp );
  434. char *s = NULL;
  435. if ( LW > tw )
  436. {
  437. s = new char[strlen(lp)];
  438. char *sp = s;
  439. for ( ; *lp; ++lp )
  440. switch ( *lp )
  441. {
  442. case 'i': case 'e': case 'o': case 'u': case 'a':
  443. break;
  444. default:
  445. *(sp++) = *lp;
  446. }
  447. *sp = '\0';
  448. }
  449. fl_draw( s ? s : lp, tx, ty, tw, th, (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP ) );
  450. if ( s )
  451. delete[] s;
  452. }
  453. void
  454. Module::insert_menu_cb ( const Fl_Menu_ *m )
  455. {
  456. if ( ! m->mvalue() || m->mvalue()->flags & FL_SUBMENU_POINTER || m->mvalue()->flags & FL_SUBMENU )
  457. return;
  458. void * v = m->mvalue()->user_data();
  459. if ( v )
  460. {
  461. unsigned long id = *((unsigned long *)v);
  462. Module *mod = NULL;
  463. switch ( id )
  464. {
  465. case 1:
  466. mod = new JACK_Module();
  467. break;
  468. case 2:
  469. mod = new Gain_Module();
  470. break;
  471. case 3:
  472. mod = new Meter_Module();
  473. break;
  474. case 4:
  475. mod = new Mono_Pan_Module();
  476. break;
  477. default:
  478. {
  479. Plugin_Module *m = new Plugin_Module();
  480. m->load( id );
  481. mod = m;
  482. }
  483. }
  484. if ( mod )
  485. {
  486. if ( !strcmp( mod->name(), "JACK" ) )
  487. {
  488. DMESSAGE( "Special casing JACK module" );
  489. JACK_Module *jm = (JACK_Module*)mod;
  490. jm->chain( chain() );
  491. jm->configure_inputs( ninputs() );
  492. jm->configure_outputs( ninputs() );
  493. }
  494. if ( ! chain()->insert( this, mod ) )
  495. {
  496. fl_alert( "Cannot insert this module at this point in the chain" );
  497. delete mod;
  498. return;
  499. }
  500. redraw();
  501. }
  502. }
  503. }
  504. void
  505. Module::insert_menu_cb ( Fl_Widget *w, void *v )
  506. {
  507. ((Module*)v)->insert_menu_cb( (Fl_Menu_*) w );
  508. }
  509. void
  510. Module::menu_cb ( const Fl_Menu_ *m )
  511. {
  512. char picked[256];
  513. if ( ! m->mvalue() || m->mvalue()->flags & FL_SUBMENU_POINTER || m->mvalue()->flags & FL_SUBMENU )
  514. return;
  515. strncpy( picked, m->mvalue()->label(), sizeof( picked ) );
  516. // m->item_pathname( picked, sizeof( picked ) );
  517. DMESSAGE( "%s", picked );
  518. Logger log( this );
  519. if ( ! strcmp( picked, "Edit Parameters" ) )
  520. command_open_parameter_editor();
  521. else if ( ! strcmp( picked, "Bypass" ) )
  522. if ( ! bypassable() )
  523. {
  524. fl_alert( "Due to its channel configuration, this module cannot be bypassed." );
  525. }
  526. else
  527. {
  528. bypass( ! ( m->mvalue()->flags & FL_MENU_VALUE ) );
  529. }
  530. else if ( ! strcmp( picked, "Cut" ) )
  531. {
  532. copy();
  533. chain()->remove( this );
  534. Fl::delete_widget( this );
  535. }
  536. else if ( ! strcmp( picked, "Copy" ) )
  537. {
  538. copy();
  539. }
  540. else if ( ! strcmp( picked, "Paste" ) )
  541. {
  542. paste_before();
  543. }
  544. else if ( ! strcmp( picked, "Remove" ) )
  545. command_remove();
  546. }
  547. void
  548. Module::menu_cb ( Fl_Widget *w, void *v )
  549. {
  550. ((Module*)v)->menu_cb( (Fl_Menu_*) w );
  551. }
  552. /** build the context menu */
  553. Fl_Menu_Button &
  554. Module::menu ( void ) const
  555. {
  556. static Fl_Menu_Button m( 0, 0, 0, 0, "Module" );
  557. static Fl_Menu_Button *insert_menu = NULL;
  558. if ( ! insert_menu )
  559. {
  560. insert_menu = new Fl_Menu_Button( 0, 0, 0, 0 );
  561. insert_menu->add( "Gain", 0, 0, new unsigned long(2) );
  562. insert_menu->add( "Meter", 0, 0, new unsigned long(3) );
  563. insert_menu->add( "Mono Pan", 0, 0, new unsigned long(4) );
  564. Plugin_Module::add_plugins_to_menu( insert_menu );
  565. // menu_set_callback( insert_menu, &Module::insert_menu_cb, (void*)this );
  566. insert_menu->callback( &Module::insert_menu_cb, (void*)this );
  567. }
  568. m.clear();
  569. m.add( "Insert", 0, &Module::menu_cb, (void*)this, 0);
  570. m.add( "Insert", 0, &Module::menu_cb, const_cast< Fl_Menu_Item *>( insert_menu->menu() ), FL_SUBMENU_POINTER );
  571. m.add( "Edit Parameters", ' ', &Module::menu_cb, (void*)this, 0 );
  572. m.add( "Bypass", 'b', &Module::menu_cb, (void*)this, FL_MENU_TOGGLE | ( bypass() ? FL_MENU_VALUE : 0 ) );
  573. m.add( "Cut", FL_CTRL + 'x', &Module::menu_cb, (void*)this, is_default() ? FL_MENU_INACTIVE : 0 );
  574. m.add( "Copy", FL_CTRL + 'c', &Module::menu_cb, (void*)this, is_default() ? FL_MENU_INACTIVE : 0 );
  575. m.add( "Paste", FL_CTRL + 'v', &Module::menu_cb, (void*)this, _copied_module_empty ? 0 : FL_MENU_INACTIVE );
  576. m.add( "Remove", FL_Delete, &Module::menu_cb, (void*)this );
  577. // menu_set_callback( menu, &Module::menu_cb, (void*)this );
  578. m.callback( &Module::insert_menu_cb, (void*)this );
  579. return m;
  580. }
  581. void
  582. Module::handle_chain_name_changed ( )
  583. {
  584. // pass it along to our connected Controller_Modules, if any.
  585. for ( int i = 0; i < ncontrol_inputs(); ++i )
  586. {
  587. if ( control_input[i].connected() )
  588. control_input[i].connected_port()->module()->handle_chain_name_changed();
  589. control_input[i].update_osc_port();
  590. }
  591. }
  592. int
  593. Module::handle ( int m )
  594. {
  595. switch ( m )
  596. {
  597. case FL_KEYBOARD:
  598. {
  599. if ( Fl_Group::handle( m ) )
  600. return 1;
  601. if ( Fl::event_key() == FL_Menu )
  602. {
  603. menu_popup( &menu(), x(), y() );
  604. return 1;
  605. }
  606. else
  607. return menu().test_shortcut() != 0;
  608. }
  609. case FL_PUSH:
  610. {
  611. take_focus();
  612. if ( Fl_Group::handle( m ) )
  613. return 1;
  614. else if ( test_press( FL_BUTTON3 ) )
  615. {
  616. menu_popup( &menu() );
  617. return 1;
  618. }
  619. else if ( test_press( FL_BUTTON1 ) )
  620. {
  621. command_open_parameter_editor();
  622. return 1;
  623. }
  624. else if ( test_press( FL_BUTTON3 | FL_CTRL ) )
  625. {
  626. command_remove();
  627. return 1;
  628. }
  629. else if ( test_press( FL_BUTTON2 ) )
  630. {
  631. if ( !bypassable() )
  632. {
  633. fl_alert( "Due to its channel configuration, this module cannot be bypassed." );
  634. }
  635. else
  636. {
  637. bypass( !bypass() );
  638. redraw();
  639. }
  640. return 1;
  641. }
  642. return 0;
  643. }
  644. case FL_FOCUS:
  645. case FL_UNFOCUS:
  646. redraw();
  647. return 1;
  648. }
  649. return Fl_Group::handle( m );
  650. }
  651. /************/
  652. /* Commands */
  653. /************/
  654. void
  655. Module::command_open_parameter_editor ( void )
  656. {
  657. if ( _editor )
  658. {
  659. _editor->show();
  660. }
  661. else if ( ncontrol_inputs() )
  662. {
  663. DMESSAGE( "Opening module parameters for \"%s\"", label() );
  664. _editor = new Module_Parameter_Editor( this );
  665. _editor->show();
  666. }
  667. }
  668. void
  669. Module::command_activate ( void )
  670. {
  671. bypass( false );
  672. }
  673. void
  674. Module::command_deactivate ( void )
  675. {
  676. bypass( true );
  677. }
  678. void
  679. Module::command_remove ( void )
  680. {
  681. if ( is_default() )
  682. fl_alert( "Default modules may not be deleted." );
  683. else
  684. {
  685. chain()->remove( this );
  686. Fl::delete_widget( this );
  687. }
  688. }