add master/armed_gang track operations, tweak appearanceprefs layout, fix vicon video...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / plugindialog.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "condition.h"
23 #include "cstrdup.h"
24 #include "edl.h"
25 #include "edlsession.h"
26 #include "language.h"
27 #include "localsession.h"
28 #include "mainsession.h"
29 #include "mainundo.h"
30 #include "mwindow.h"
31 #include "mwindowgui.h"
32 #include "module.h"
33 #include "mutex.h"
34 #include "plugin.h"
35 #include "plugindialog.h"
36 #include "pluginserver.h"
37 #include "theme.h"
38 #include "track.h"
39 #include "tracks.h"
40 #include "transition.h"
41
42
43 PluginDialogThread::PluginDialogThread(MWindow *mwindow)
44  : BC_DialogThread()
45 {
46         this->mwindow = mwindow;
47         this->plugin_id = -1;
48         this->plugin_type = PLUGIN_NONE;
49 }
50
51 PluginDialogThread::~PluginDialogThread()
52 {
53         close_window();
54 }
55
56 void PluginDialogThread::start_window(Track *track,
57         Plugin *plugin, const char *title, int is_mainmenu, int data_type)
58 {
59         if(!BC_DialogThread::is_running())
60         {
61 // At this point, the caller should hold the main window mutex.
62 //              mwindow->gui->lock_window("PluginDialogThread::start_window");
63                 this->track = track;
64                 this->data_type = data_type;
65                 this->is_mainmenu = is_mainmenu;
66                 single_standalone = mwindow->edl->session->single_standalone;
67
68                 if(plugin)
69                 {
70                         plugin->calculate_title(plugin_title, 0);
71                         this->shared_location = plugin->shared_location;
72                         this->plugin_type = plugin->plugin_type;
73                         this->plugin_id = plugin->orig_id;
74                 }
75                 else
76                 {
77                         this->plugin_title[0] = 0;
78                         this->shared_location.plugin = -1;
79                         this->shared_location.module = -1;
80                         this->plugin_type = PLUGIN_NONE;
81                         this->plugin_id = -1;
82                 }
83
84                 strcpy(this->window_title, title);
85                 mwindow->gui->unlock_window();
86
87                 BC_DialogThread::start();
88                 mwindow->gui->lock_window("PluginDialogThread::start_window");
89         }
90 }
91
92 BC_Window* PluginDialogThread::new_gui()
93 {
94         mwindow->gui->lock_window("PluginDialogThread::new_gui");
95         int x = mwindow->gui->get_abs_cursor_x(0) -
96                 mwindow->session->plugindialog_w / 2;
97         int y = mwindow->gui->get_abs_cursor_y(0) -
98                 mwindow->session->plugindialog_h / 2;
99         plugin_type = PLUGIN_NONE;
100         PluginDialog *window = new PluginDialog(mwindow,
101                 this,
102                 window_title,
103                 x,
104                 y);
105         window->create_objects();
106         mwindow->gui->unlock_window();
107         return window;
108 }
109
110 void PluginDialogThread::handle_done_event(int result)
111 {
112         if( !result ) {
113                 PluginDialog *dialog = (PluginDialog *)get_gui();
114                 dialog->apply();
115         }
116 }
117
118
119 void PluginDialogThread::handle_close_event(int result)
120 {
121 }
122
123
124
125
126
127 PluginDialog::PluginDialog(MWindow *mwindow,
128         PluginDialogThread *thread,
129         const char *window_title,
130         int x,
131         int y)
132  : BC_Window(window_title, x, y,
133         mwindow->session->plugindialog_w,
134         mwindow->session->plugindialog_h,
135         xS(510), yS(415), 1, 0, 1)
136 {
137         this->mwindow = mwindow;
138         this->thread = thread;
139         single_standalone = 0;
140 }
141
142 PluginDialog::~PluginDialog()
143 {
144         lock_window("PluginDialog::~PluginDialog");
145         standalone_data.remove_all_objects();
146
147         shared_data.remove_all_objects();
148
149         module_data.remove_all_objects();
150
151         plugin_locations.remove_all_objects();
152
153         module_locations.remove_all_objects();
154
155         delete standalone_list;
156         delete shared_list;
157         delete module_list;
158         unlock_window();
159 }
160
161 void PluginDialog::create_objects()
162 {
163         int xs10 = xS(10);
164         int ys10 = yS(10), ys20 = yS(20);
165 //      int use_default = 1;
166         mwindow->theme->get_plugindialog_sizes();
167         lock_window("PluginDialog::create_objects");
168
169 // GET A LIST OF ALL THE PLUGINS AVAILABLE
170         mwindow->search_plugindb(thread->data_type == TRACK_AUDIO,
171                 thread->data_type == TRACK_VIDEO,
172                 1, 0, 0, plugindb);
173
174         mwindow->edl->get_shared_plugins(thread->track,
175                 &plugin_locations,
176                 thread->is_mainmenu,
177                 thread->data_type);
178         mwindow->edl->get_shared_tracks(thread->track,
179                 &module_locations,
180                 thread->is_mainmenu,
181                 thread->data_type);
182
183 // Construct listbox items
184         for(int i = 0; i < plugin_locations.total; )
185         {
186                 Track *track = mwindow->edl->tracks->number(plugin_locations.values[i]->module);
187                 char *track_title = track->title;
188                 int number = plugin_locations.values[i]->plugin;
189                 double start = mwindow->edl->local_session->get_selectionstart(1);
190                 Plugin *plugin = track->get_current_plugin(start, number, PLAY_FORWARD, 1, 0);
191                 if( !plugin ) { plugin_locations.remove_object_number(i);  continue; }
192                 char string[BCTEXTLEN];
193                 const char *plugin_title = _(plugin->title);
194                 snprintf(string, sizeof(string), "%s: %s", track_title, plugin_title);
195                 shared_data.append(new BC_ListBoxItem(string));
196                 ++i;
197         }
198         for(int i = 0; i < module_locations.total; i++)
199         {
200                 Track *track = mwindow->edl->tracks->number(module_locations.values[i]->module);
201                 module_data.append(new BC_ListBoxItem(track->title));
202         }
203
204 // Create widgets
205         add_subwindow(standalone_title = new BC_Title(mwindow->theme->plugindialog_new_x,
206                 mwindow->theme->plugindialog_new_y - ys20,
207                 _("Plugins:")));
208         int x1 = mwindow->theme->plugindialog_new_x, y1 = mwindow->theme->plugindialog_new_y;
209         int w1 = mwindow->theme->plugindialog_new_w, h1 = mwindow->theme->plugindialog_new_h;
210         add_subwindow(search_text = new PluginDialogSearchText(this, x1, y1, w1));
211         int dy = search_text->get_h() + ys10;
212         y1 += dy;  h1 -= dy;
213         load_plugin_list(0);
214
215         add_subwindow(standalone_list = new PluginDialogNew(this,
216                 &standalone_data, x1, y1, w1, h1));
217 //
218 //      if(thread->plugin)
219 //              add_subwindow(standalone_change = new PluginDialogChangeNew(mwindow,
220 //                      this,
221 //                      mwindow->theme->plugindialog_newattach_x,
222 //                      mwindow->theme->plugindialog_newattach_y));
223 //      else
224 //              add_subwindow(standalone_attach = new PluginDialogAttachNew(mwindow,
225 //                      this,
226 //                      mwindow->theme->plugindialog_newattach_x,
227 //                      mwindow->theme->plugindialog_newattach_y));
228 //
229
230         add_subwindow(shared_title = new BC_Title(mwindow->theme->plugindialog_shared_x,
231                 mwindow->theme->plugindialog_shared_y - ys20,
232                 _("Shared effects:")));
233         add_subwindow(shared_list = new PluginDialogShared(this,
234                 &shared_data,
235                 mwindow->theme->plugindialog_shared_x,
236                 mwindow->theme->plugindialog_shared_y,
237                 mwindow->theme->plugindialog_shared_w,
238                 mwindow->theme->plugindialog_shared_h));
239 //      if(thread->plugin)
240 //       add_subwindow(shared_change = new PluginDialogChangeShared(mwindow,
241 //          this,
242 //          mwindow->theme->plugindialog_sharedattach_x,
243 //          mwindow->theme->plugindialog_sharedattach_y));
244 //    else
245 //              add_subwindow(shared_attach = new PluginDialogAttachShared(mwindow,
246 //                      this,
247 //                      mwindow->theme->plugindialog_sharedattach_x,
248 //                      mwindow->theme->plugindialog_sharedattach_y));
249 //
250
251         add_subwindow(module_title = new BC_Title(mwindow->theme->plugindialog_module_x,
252                 mwindow->theme->plugindialog_module_y - ys20,
253                 _("Shared tracks:")));
254         add_subwindow(module_list = new PluginDialogModules(this,
255                 &module_data,
256                 mwindow->theme->plugindialog_module_x,
257                 mwindow->theme->plugindialog_module_y,
258                 mwindow->theme->plugindialog_module_w,
259                 mwindow->theme->plugindialog_module_h));
260 //      if(thread->plugin)
261 //       add_subwindow(module_change = new PluginDialogChangeModule(mwindow,
262 //          this,
263 //          mwindow->theme->plugindialog_moduleattach_x,
264 //          mwindow->theme->plugindialog_moduleattach_y));
265 //    else
266 //              add_subwindow(module_attach = new PluginDialogAttachModule(mwindow,
267 //                      this,
268 //                      mwindow->theme->plugindialog_moduleattach_x,
269 //                      mwindow->theme->plugindialog_moduleattach_y));
270 //
271
272
273 // Add option for the menu invocation
274 //      add_subwindow(file_title = new BC_Title(
275 //              mwindow->theme->menueffect_file_x,
276 //              mwindow->theme->menueffect_file_y,
277 //              _("One standalone effect is attached to the first track.\n"
278 //              "Shared effects are attached to the remaining tracks.")));
279
280         if(thread->is_mainmenu)
281                 add_subwindow(single_standalone = new PluginDialogSingle(this,
282                         mwindow->theme->plugindialog_new_x + BC_OKButton::calculate_w() + xs10,
283                         mwindow->theme->plugindialog_new_y + mwindow->theme->plugindialog_new_h +
284                                 get_text_height(MEDIUMFONT)));
285
286         add_subwindow(ok_btn = new BC_OKButton(this));
287         add_subwindow(can_btn = new BC_CancelButton(this));
288         int aw = PluginDialogApply::calculate_w(this, _("Apply"));
289         int ax = (ok_btn->get_x()+can_btn->get_x()-aw) / 2;
290         int ay = ok_btn->get_y() + ok_btn->get_h() - PluginDialogApply::calculate_h();
291         add_subwindow(apy_btn = new PluginDialogApply(this, ax, ay));
292         selected_available = -1;
293         selected_shared = -1;
294         selected_modules = -1;
295
296         show_window();
297         flush();
298         unlock_window();
299 }
300
301 int PluginDialog::resize_event(int w, int h)
302 {
303         int ys10 = yS(10), ys20 = yS(20);
304         mwindow->session->plugindialog_w = w;
305         mwindow->session->plugindialog_h = h;
306         mwindow->theme->get_plugindialog_sizes();
307
308         standalone_title->reposition_window(mwindow->theme->plugindialog_new_x,
309                 mwindow->theme->plugindialog_new_y - ys20);
310         int x1 = mwindow->theme->plugindialog_new_x, y1 = mwindow->theme->plugindialog_new_y;
311         int w1 = mwindow->theme->plugindialog_new_w, h1 = mwindow->theme->plugindialog_new_h;
312         search_text->reposition_window(x1, y1, w1);
313         int dy = search_text->get_h() + ys10;
314         y1 += dy;  h1 -= dy;
315         standalone_list->reposition_window(x1, y1, w1, h1);
316
317 //      if(standalone_attach)
318 //              standalone_attach->reposition_window(mwindow->theme->plugindialog_newattach_x,
319 //                      mwindow->theme->plugindialog_newattach_y);
320 //      else
321 //              standalone_change->reposition_window(mwindow->theme->plugindialog_newattach_x,
322 //                      mwindow->theme->plugindialog_newattach_y);
323
324         shared_title->reposition_window(mwindow->theme->plugindialog_shared_x,
325                 mwindow->theme->plugindialog_shared_y - ys20);
326         shared_list->reposition_window(mwindow->theme->plugindialog_shared_x,
327                 mwindow->theme->plugindialog_shared_y,
328                 mwindow->theme->plugindialog_shared_w,
329                 mwindow->theme->plugindialog_shared_h);
330 //      if(shared_attach)
331 //              shared_attach->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
332 //                      mwindow->theme->plugindialog_sharedattach_y);
333 //      else
334 //              shared_change->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
335 //                      mwindow->theme->plugindialog_sharedattach_y);
336 //
337
338
339
340
341         module_title->reposition_window(mwindow->theme->plugindialog_module_x,
342                 mwindow->theme->plugindialog_module_y - ys20);
343         module_list->reposition_window(mwindow->theme->plugindialog_module_x,
344                 mwindow->theme->plugindialog_module_y,
345                 mwindow->theme->plugindialog_module_w,
346                 mwindow->theme->plugindialog_module_h);
347 //      if(module_attach)
348 //              module_attach->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
349 //                      mwindow->theme->plugindialog_moduleattach_y);
350 //      else
351 //              module_change->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
352 //                      mwindow->theme->plugindialog_moduleattach_y);
353
354
355         if(single_standalone)
356                 single_standalone->reposition_window(
357                         mwindow->theme->plugindialog_new_x + BC_OKButton::calculate_w() + ys10,
358                         mwindow->theme->plugindialog_new_y + mwindow->theme->plugindialog_new_h +
359                                 get_text_height(MEDIUMFONT));
360
361         int aw = PluginDialogApply::calculate_w(this, _("Apply"));
362         int ax = (ok_btn->get_x()+can_btn->get_x()-aw) / 2;
363         int ay = ok_btn->get_y() + ok_btn->get_h() - PluginDialogApply::calculate_h();
364         apy_btn->reposition_window(ax, ay);
365
366         flush();
367         return 0;
368 }
369
370 int PluginDialog::attach_new(int number)
371 {
372         if(number >= 0 && number < plugindb.size())
373         {
374                 strcpy(thread->plugin_title, plugindb.values[number]->title);
375                 thread->plugin_type = PLUGIN_STANDALONE;         // type is plugin
376         }
377         return 0;
378 }
379
380 int PluginDialog::attach_shared(int number)
381 {
382         if(number >= 0 && number < plugin_locations.size())
383         {
384                 thread->plugin_type = PLUGIN_SHAREDPLUGIN;         // type is shared plugin
385                 thread->shared_location = *(plugin_locations.values[number]); // copy location
386         }
387         return 0;
388 }
389
390 int PluginDialog::attach_module(int number)
391 {
392         if(number >= 0 && number < module_locations.size())
393         {
394 //              title->update(module_data.values[number]->get_text());
395                 thread->plugin_type = PLUGIN_SHAREDMODULE;         // type is module
396                 thread->shared_location = *(module_locations.values[number]); // copy location
397         }
398         return 0;
399 }
400
401 void PluginDialog::save_settings()
402 {
403 }
404
405
406 void PluginDialog::clear_selection()
407 {
408         standalone_list->set_all_selected(&standalone_data, 0);
409         standalone_list->draw_items(1);
410         shared_list->set_all_selected(&shared_data, 0);
411         shared_list->draw_items(1);
412         module_list->set_all_selected(&module_data, 0);
413         module_list->draw_items(1);
414         selected_available = -1;
415         selected_shared = -1;
416         selected_modules = -1;
417         thread->plugin_id = -1;
418         thread->plugin_type = PLUGIN_NONE;
419 }
420
421 void PluginDialog::apply()
422 {
423         if( selected_available >= 0 ) {
424                 attach_new(selected_available);
425         }
426         else if( selected_shared >= 0 ) {
427                 attach_shared(selected_shared);
428         }
429         else if( selected_modules >= 0 ) {
430                 attach_module(selected_modules);
431         }
432
433         thread->apply();
434 }
435
436 void PluginDialogThread::apply()
437 {
438         Plugin *plugin = 0;
439         if( mwindow->edl )
440                 mwindow->edl->session->single_standalone = single_standalone;
441         if(plugin_type) {
442                 mwindow->gui->lock_window("PluginDialogThread::run 3");
443                 mwindow->undo->update_undo_before();
444                 if( is_mainmenu ) {
445                         mwindow->insert_effect(plugin_title, &shared_location,
446                                 data_type, plugin_type, single_standalone);
447                 }
448                 else if( (plugin=mwindow->edl->tracks->plugin_exists(plugin_id)) != 0 ) {
449                         plugin->change_plugin(plugin_title,
450                                         &shared_location, plugin_type);
451                 }
452                 else if( mwindow->edl->tracks->track_exists(track) ) {
453                         mwindow->insert_effect(plugin_title, &shared_location,
454                                         track, 0, 0, 0, plugin_type);
455                 }
456
457                 mwindow->save_backup();
458                 mwindow->undo->update_undo_after(_("attach effect"), LOAD_EDITS | LOAD_PATCHES);
459                 mwindow->restart_brender();
460                 mwindow->update_plugin_states();
461                 mwindow->sync_parameters(CHANGE_EDL);
462                 mwindow->gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
463                 mwindow->gui->unlock_window();
464         }
465         plugin_id = -1;
466 }
467
468 PluginDialogApply::PluginDialogApply(PluginDialog *dialog, int x, int y)
469  : BC_GenericButton(x, y, _("Apply"))
470 {
471         this->dialog = dialog;
472 }
473
474 int PluginDialogApply::handle_event()
475 {
476         dialog->apply();
477         dialog->clear_selection();
478         return 1;
479 }
480
481
482
483
484
485
486 //
487 // PluginDialogTextBox::PluginDialogTextBox(PluginDialog *dialog, char *text, int x, int y)
488 //  : BC_TextBox(x, y, xS(200), 1, text)
489 // {
490 //      this->dialog = dialog;
491 // }
492 // PluginDialogTextBox::~PluginDialogTextBox()
493 // { }
494 // int PluginDialogTextBox::handle_event()
495 // { }
496 //
497 // PluginDialogDetach::PluginDialogDetach(MWindow *mwindow, PluginDialog *dialog, int x, int y)
498 //  : BC_GenericButton(x, y, _("Detach"))
499 // {
500 //      this->dialog = dialog;
501 // }
502 // PluginDialogDetach::~PluginDialogDetach()
503 // { }
504 // int PluginDialogDetach::handle_event()
505 // {
506 // //   dialog->title->update(_("None"));
507 //      dialog->thread->plugin_type = 0;         // type is none
508 //      dialog->thread->plugin_title[0] = 0;
509 //      return 1;
510 // }
511 //
512
513
514
515 PluginDialogNew::PluginDialogNew(PluginDialog *dialog,
516         ArrayList<BC_ListBoxItem*> *standalone_data,
517         int x, int y, int w, int h)
518  : BC_ListBox(x, y, w, h, LISTBOX_TEXT, standalone_data)
519 {
520         this->dialog = dialog;
521 }
522
523 PluginDialogNew::~PluginDialogNew() { }
524 int PluginDialogNew::handle_event()
525 {
526 //      dialog->attach_new(get_selection_number(0, 0));
527 //      deactivate();
528
529         set_done(0);
530         return 1;
531 }
532 int PluginDialogNew::selection_changed()
533 {
534         int no = get_selection_number(0, 0);
535         dialog->selected_available = no >= 0 && no < dialog->standalone_data.size() ?
536                 ((PluginDialogListItem *)dialog->standalone_data[no])->item_no : -1;
537         dialog->shared_list->set_all_selected(&dialog->shared_data, 0);
538         dialog->shared_list->draw_items(1);
539         dialog->selected_shared = -1;
540         dialog->module_list->set_all_selected(&dialog->module_data, 0);
541         dialog->module_list->draw_items(1);
542         dialog->selected_modules = -1;
543         return 1;
544 }
545
546 // PluginDialogAttachNew::PluginDialogAttachNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
547 //  : BC_GenericButton(x, y, _("Attach"))
548 // {
549 //      this->dialog = dialog;
550 // }
551 // PluginDialogAttachNew::~PluginDialogAttachNew()
552 // {
553 // }
554 // int PluginDialogAttachNew::handle_event()
555 // {
556 //      dialog->attach_new(dialog->selected_available);
557 //      set_done(0);
558 //      return 1;
559 // }
560 //
561 // PluginDialogChangeNew::PluginDialogChangeNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
562 //  : BC_GenericButton(x, y, _("Change"))
563 // {
564 //    this->dialog = dialog;
565 // }
566 // PluginDialogChangeNew::~PluginDialogChangeNew()
567 // {
568 // }
569 // int PluginDialogChangeNew::handle_event()
570 // {
571 //    dialog->attach_new(dialog->selected_available);
572 //    set_done(0);
573 //    return 1;
574 // }
575
576
577 PluginDialogShared::PluginDialogShared(PluginDialog *dialog,
578         ArrayList<BC_ListBoxItem*> *shared_data,
579         int x, int y, int w, int h)
580  : BC_ListBox(x, y, w, h, LISTBOX_TEXT, shared_data)
581 {
582         this->dialog = dialog;
583 }
584 PluginDialogShared::~PluginDialogShared() { }
585 int PluginDialogShared::handle_event()
586 {
587 //      dialog->attach_shared(get_selection_number(0, 0));
588 //      deactivate();
589         set_done(0);
590         return 1;
591 }
592 int PluginDialogShared::selection_changed()
593 {
594         dialog->selected_shared = get_selection_number(0, 0);
595
596
597         dialog->standalone_list->set_all_selected(&dialog->standalone_data, 0);
598         dialog->standalone_list->draw_items(1);
599         dialog->module_list->set_all_selected(&dialog->module_data, 0);
600         dialog->module_list->draw_items(1);
601         dialog->selected_available = -1;
602         dialog->selected_modules = -1;
603         return 1;
604 }
605
606 // PluginDialogAttachShared::PluginDialogAttachShared(MWindow *mwindow,
607 //      PluginDialog *dialog,
608 //      int x,
609 //      int y)
610 //  : BC_GenericButton(x, y, _("Attach"))
611 // {
612 //      this->dialog = dialog;
613 // }
614 // PluginDialogAttachShared::~PluginDialogAttachShared() { }
615 // int PluginDialogAttachShared::handle_event()
616 // {
617 //      dialog->attach_shared(dialog->selected_shared);
618 //      set_done(0);
619 //      return 1;
620 // }
621 //
622 // PluginDialogChangeShared::PluginDialogChangeShared(MWindow *mwindow,
623 //    PluginDialog *dialog,
624 //    int x,
625 //    int y)
626 //  : BC_GenericButton(x, y, _("Change"))
627 // {
628 //    this->dialog = dialog;
629 // }
630 // PluginDialogChangeShared::~PluginDialogChangeShared() { }
631 // int PluginDialogChangeShared::handle_event()
632 // {
633 //    dialog->attach_shared(dialog->selected_shared);
634 //    set_done(0);
635 //    return 1;
636 // }
637 //
638
639
640
641
642
643
644
645
646
647
648
649
650 PluginDialogModules::PluginDialogModules(PluginDialog *dialog,
651         ArrayList<BC_ListBoxItem*> *module_data,
652         int x, int y, int w, int h)
653  : BC_ListBox(x, y, w, h, LISTBOX_TEXT, module_data)
654 {
655         this->dialog = dialog;
656 }
657 PluginDialogModules::~PluginDialogModules() { }
658 int PluginDialogModules::handle_event()
659 {
660 //      dialog->attach_module(get_selection_number(0, 0));
661 //      deactivate();
662
663         set_done(0);
664         return 1;
665 }
666 int PluginDialogModules::selection_changed()
667 {
668         dialog->selected_modules = get_selection_number(0, 0);
669
670
671         dialog->standalone_list->set_all_selected(&dialog->standalone_data, 0);
672         dialog->standalone_list->draw_items(1);
673         dialog->shared_list->set_all_selected(&dialog->shared_data, 0);
674         dialog->shared_list->draw_items(1);
675         dialog->selected_available = -1;
676         dialog->selected_shared = -1;
677         return 1;
678 }
679
680 void PluginDialog::load_plugin_list(int redraw)
681 {
682         standalone_data.remove_all_objects();
683         const char *text = search_text->get_text();
684
685         for( int i=0; i<plugindb.total; ++i ) {
686                 const char *title = _(plugindb.values[i]->title);
687                 if( text && text[0] && !bstrcasestr(title, text) ) continue;
688                 standalone_data.append(new PluginDialogListItem(title, i));
689         }
690
691         if( redraw )
692                 standalone_list->draw_items(1);
693 }
694
695 PluginDialogSearchText::PluginDialogSearchText(PluginDialog *dialog, int x, int y, int w)
696  : BC_TextBox(x, y, w, 1, "")
697 {
698         this->dialog = dialog;
699 }
700
701 int PluginDialogSearchText::handle_event()
702 {
703         dialog->load_plugin_list(1);
704         return 1;
705 }
706
707 PluginDialogSingle::PluginDialogSingle(PluginDialog *dialog, int x, int y)
708  : BC_CheckBox(x, y, dialog->thread->single_standalone,
709         _("Attach single standalone and share others"))
710 {
711         this->dialog = dialog;
712 }
713
714 int PluginDialogSingle::handle_event()
715 {
716         dialog->thread->single_standalone = get_value();
717         return 1;
718 }
719
720
721 // PluginDialogAttachModule::PluginDialogAttachModule(MWindow *mwindow,
722 //      PluginDialog *dialog,
723 //      int x,
724 //      int y)
725 //  : BC_GenericButton(x, y, _("Attach"))
726 // {
727 //      this->dialog = dialog;
728 // }
729 // PluginDialogAttachModule::~PluginDialogAttachModule() { }
730 // int PluginDialogAttachModule::handle_event()
731 // {
732 //      dialog->attach_module(dialog->selected_modules);
733 //      set_done(0);
734 //      return 1;
735 // }
736 //
737 // PluginDialogChangeModule::PluginDialogChangeModule(MWindow *mwindow,
738 //    PluginDialog *dialog,
739 //    int x,
740 //    int y)
741 //  : BC_GenericButton(x, y, _("Change"))
742 // {
743 //    this->dialog = dialog;
744 // }
745 // PluginDialogChangeModule::~PluginDialogChangeModule() { }
746 // int PluginDialogChangeModule::handle_event()
747 // {
748 //    dialog->attach_module(dialog->selected_modules);
749 //    set_done(0);
750 //    return 1;
751 // }
752 //
753