drag edit contraints relaxed for ripples, cwdw gui/tool deadlock fix, vpatchgui fader...
[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 = 0;
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->plugin = plugin;
66                 this->is_mainmenu = is_mainmenu;
67                 single_standalone = mwindow->edl->session->single_standalone;
68
69                 if(plugin)
70                 {
71                         plugin->calculate_title(plugin_title, 0);
72                         this->shared_location = plugin->shared_location;
73                         this->plugin_type = plugin->plugin_type;
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                 }
82
83                 strcpy(this->window_title, title);
84                 mwindow->gui->unlock_window();
85
86                 BC_DialogThread::start();
87                 mwindow->gui->lock_window("PluginDialogThread::start_window");
88         }
89 }
90
91 BC_Window* PluginDialogThread::new_gui()
92 {
93         mwindow->gui->lock_window("PluginDialogThread::new_gui");
94         int x = mwindow->gui->get_abs_cursor_x(0) -
95                 mwindow->session->plugindialog_w / 2;
96         int y = mwindow->gui->get_abs_cursor_y(0) -
97                 mwindow->session->plugindialog_h / 2;
98         plugin_type = PLUGIN_NONE;
99         PluginDialog *window = new PluginDialog(mwindow,
100                 this,
101                 window_title,
102                 x,
103                 y);
104         window->create_objects();
105         mwindow->gui->unlock_window();
106         return window;
107 }
108
109 void PluginDialogThread::handle_done_event(int result)
110 {
111         if( !result ) {
112                 PluginDialog *dialog = (PluginDialog *)get_gui();
113                 dialog->apply();
114         }
115 }
116
117
118 void PluginDialogThread::handle_close_event(int result)
119 {
120 }
121
122
123
124
125
126 PluginDialog::PluginDialog(MWindow *mwindow,
127         PluginDialogThread *thread,
128         const char *window_title,
129         int x,
130         int y)
131  : BC_Window(window_title,
132         x,
133         y,
134         mwindow->session->plugindialog_w,
135         mwindow->session->plugindialog_h,
136         510,
137         415,
138         1,
139         0,
140         1)
141 {
142         this->mwindow = mwindow;
143         this->thread = thread;
144         single_standalone = 0;
145 }
146
147 PluginDialog::~PluginDialog()
148 {
149         lock_window("PluginDialog::~PluginDialog");
150         standalone_data.remove_all_objects();
151
152         shared_data.remove_all_objects();
153
154         module_data.remove_all_objects();
155
156         plugin_locations.remove_all_objects();
157
158         module_locations.remove_all_objects();
159
160         delete standalone_list;
161         delete shared_list;
162         delete module_list;
163         unlock_window();
164 }
165
166 void PluginDialog::create_objects()
167 {
168 //      int use_default = 1;
169         mwindow->theme->get_plugindialog_sizes();
170         lock_window("PluginDialog::create_objects");
171
172 // GET A LIST OF ALL THE PLUGINS AVAILABLE
173         mwindow->search_plugindb(thread->data_type == TRACK_AUDIO,
174                 thread->data_type == TRACK_VIDEO,
175                 1, 0, 0, plugindb);
176
177         mwindow->edl->get_shared_plugins(thread->track,
178                 &plugin_locations,
179                 thread->is_mainmenu,
180                 thread->data_type);
181         mwindow->edl->get_shared_tracks(thread->track,
182                 &module_locations,
183                 thread->is_mainmenu,
184                 thread->data_type);
185
186 // Construct listbox items
187         for(int i = 0; i < plugin_locations.total; )
188         {
189                 Track *track = mwindow->edl->tracks->number(plugin_locations.values[i]->module);
190                 char *track_title = track->title;
191                 int number = plugin_locations.values[i]->plugin;
192                 double start = mwindow->edl->local_session->get_selectionstart(1);
193                 Plugin *plugin = track->get_current_plugin(start, number, PLAY_FORWARD, 1, 0);
194                 if( !plugin ) { plugin_locations.remove_object_number(i);  continue; }
195                 char string[BCTEXTLEN];
196                 const char *plugin_title = _(plugin->title);
197                 snprintf(string, sizeof(string), "%s: %s", track_title, plugin_title);
198                 shared_data.append(new BC_ListBoxItem(string));
199                 ++i;
200         }
201         for(int i = 0; i < module_locations.total; i++)
202         {
203                 Track *track = mwindow->edl->tracks->number(module_locations.values[i]->module);
204                 module_data.append(new BC_ListBoxItem(track->title));
205         }
206
207
208
209
210
211 // Create widgets
212         add_subwindow(standalone_title = new BC_Title(mwindow->theme->plugindialog_new_x,
213                 mwindow->theme->plugindialog_new_y - 20,
214                 _("Plugins:")));
215         int x1 = mwindow->theme->plugindialog_new_x, y1 = mwindow->theme->plugindialog_new_y;
216         int w1 = mwindow->theme->plugindialog_new_w, h1 = mwindow->theme->plugindialog_new_h;
217         add_subwindow(search_text = new PluginDialogSearchText(this, x1, y1, w1));
218         int dy = search_text->get_h() + 10;
219         y1 += dy;  h1 -= dy;
220         load_plugin_list(0);
221
222         add_subwindow(standalone_list = new PluginDialogNew(this,
223                 &standalone_data, x1, y1, w1, h1));
224 //
225 //      if(thread->plugin)
226 //              add_subwindow(standalone_change = new PluginDialogChangeNew(mwindow,
227 //                      this,
228 //                      mwindow->theme->plugindialog_newattach_x,
229 //                      mwindow->theme->plugindialog_newattach_y));
230 //      else
231 //              add_subwindow(standalone_attach = new PluginDialogAttachNew(mwindow,
232 //                      this,
233 //                      mwindow->theme->plugindialog_newattach_x,
234 //                      mwindow->theme->plugindialog_newattach_y));
235 //
236
237         add_subwindow(shared_title = new BC_Title(mwindow->theme->plugindialog_shared_x,
238                 mwindow->theme->plugindialog_shared_y - 20,
239                 _("Shared effects:")));
240         add_subwindow(shared_list = new PluginDialogShared(this,
241                 &shared_data,
242                 mwindow->theme->plugindialog_shared_x,
243                 mwindow->theme->plugindialog_shared_y,
244                 mwindow->theme->plugindialog_shared_w,
245                 mwindow->theme->plugindialog_shared_h));
246 //      if(thread->plugin)
247 //       add_subwindow(shared_change = new PluginDialogChangeShared(mwindow,
248 //          this,
249 //          mwindow->theme->plugindialog_sharedattach_x,
250 //          mwindow->theme->plugindialog_sharedattach_y));
251 //    else
252 //              add_subwindow(shared_attach = new PluginDialogAttachShared(mwindow,
253 //                      this,
254 //                      mwindow->theme->plugindialog_sharedattach_x,
255 //                      mwindow->theme->plugindialog_sharedattach_y));
256 //
257
258         add_subwindow(module_title = new BC_Title(mwindow->theme->plugindialog_module_x,
259                 mwindow->theme->plugindialog_module_y - 20,
260                 _("Shared tracks:")));
261         add_subwindow(module_list = new PluginDialogModules(this,
262                 &module_data,
263                 mwindow->theme->plugindialog_module_x,
264                 mwindow->theme->plugindialog_module_y,
265                 mwindow->theme->plugindialog_module_w,
266                 mwindow->theme->plugindialog_module_h));
267 //      if(thread->plugin)
268 //       add_subwindow(module_change = new PluginDialogChangeModule(mwindow,
269 //          this,
270 //          mwindow->theme->plugindialog_moduleattach_x,
271 //          mwindow->theme->plugindialog_moduleattach_y));
272 //    else
273 //              add_subwindow(module_attach = new PluginDialogAttachModule(mwindow,
274 //                      this,
275 //                      mwindow->theme->plugindialog_moduleattach_x,
276 //                      mwindow->theme->plugindialog_moduleattach_y));
277 //
278
279
280 // Add option for the menu invocation
281 //      add_subwindow(file_title = new BC_Title(
282 //              mwindow->theme->menueffect_file_x,
283 //              mwindow->theme->menueffect_file_y,
284 //              _("One standalone effect is attached to the first track.\n"
285 //              "Shared effects are attached to the remaining tracks.")));
286
287         if(thread->is_mainmenu)
288                 add_subwindow(single_standalone = new PluginDialogSingle(this,
289                         mwindow->theme->plugindialog_new_x + BC_OKButton::calculate_w() + 10,
290                         mwindow->theme->plugindialog_new_y +
291                                 mwindow->theme->plugindialog_new_h +
292                                 get_text_height(MEDIUMFONT)));
293
294
295
296         add_subwindow(ok_btn = new BC_OKButton(this));
297         add_subwindow(can_btn = new BC_CancelButton(this));
298         int aw = PluginDialogApply::calculate_w(this, _("Apply"));
299         int ax = (ok_btn->get_x()+can_btn->get_x()-aw) / 2;
300         int ay = ok_btn->get_y() + ok_btn->get_h() - PluginDialogApply::calculate_h();
301         add_subwindow(apy_btn = new PluginDialogApply(this, ax, ay));
302         selected_available = -1;
303         selected_shared = -1;
304         selected_modules = -1;
305
306         show_window();
307         flush();
308         unlock_window();
309 }
310
311 int PluginDialog::resize_event(int w, int h)
312 {
313         mwindow->session->plugindialog_w = w;
314         mwindow->session->plugindialog_h = h;
315         mwindow->theme->get_plugindialog_sizes();
316
317
318         standalone_title->reposition_window(mwindow->theme->plugindialog_new_x,
319                 mwindow->theme->plugindialog_new_y - 20);
320         int x1 = mwindow->theme->plugindialog_new_x, y1 = mwindow->theme->plugindialog_new_y;
321         int w1 = mwindow->theme->plugindialog_new_w, h1 = mwindow->theme->plugindialog_new_h;
322         search_text->reposition_window(x1, y1, w1);
323         int dy = search_text->get_h() + 10;
324         y1 += dy;  h1 -= dy;
325         standalone_list->reposition_window(x1, y1, w1, h1);
326
327 //      if(standalone_attach)
328 //              standalone_attach->reposition_window(mwindow->theme->plugindialog_newattach_x,
329 //                      mwindow->theme->plugindialog_newattach_y);
330 //      else
331 //              standalone_change->reposition_window(mwindow->theme->plugindialog_newattach_x,
332 //                      mwindow->theme->plugindialog_newattach_y);
333
334         shared_title->reposition_window(mwindow->theme->plugindialog_shared_x,
335                 mwindow->theme->plugindialog_shared_y - 20);
336         shared_list->reposition_window(mwindow->theme->plugindialog_shared_x,
337                 mwindow->theme->plugindialog_shared_y,
338                 mwindow->theme->plugindialog_shared_w,
339                 mwindow->theme->plugindialog_shared_h);
340 //      if(shared_attach)
341 //              shared_attach->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
342 //                      mwindow->theme->plugindialog_sharedattach_y);
343 //      else
344 //              shared_change->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
345 //                      mwindow->theme->plugindialog_sharedattach_y);
346 //
347
348
349
350
351         module_title->reposition_window(mwindow->theme->plugindialog_module_x,
352                 mwindow->theme->plugindialog_module_y - 20);
353         module_list->reposition_window(mwindow->theme->plugindialog_module_x,
354                 mwindow->theme->plugindialog_module_y,
355                 mwindow->theme->plugindialog_module_w,
356                 mwindow->theme->plugindialog_module_h);
357 //      if(module_attach)
358 //              module_attach->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
359 //                      mwindow->theme->plugindialog_moduleattach_y);
360 //      else
361 //              module_change->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
362 //                      mwindow->theme->plugindialog_moduleattach_y);
363
364
365         if(single_standalone)
366                 single_standalone->reposition_window(
367                         mwindow->theme->plugindialog_new_x + BC_OKButton::calculate_w() + 10,
368                         mwindow->theme->plugindialog_new_y + mwindow->theme->plugindialog_new_h +
369                                 get_text_height(MEDIUMFONT));
370
371         int aw = PluginDialogApply::calculate_w(this, _("Apply"));
372         int ax = (ok_btn->get_x()+can_btn->get_x()-aw) / 2;
373         int ay = ok_btn->get_y() + ok_btn->get_h() - PluginDialogApply::calculate_h();
374         apy_btn->reposition_window(ax, ay);
375
376         flush();
377         return 0;
378 }
379
380 int PluginDialog::attach_new(int number)
381 {
382         if(number >= 0 && number < plugindb.size())
383         {
384                 strcpy(thread->plugin_title, plugindb.values[number]->title);
385                 thread->plugin_type = PLUGIN_STANDALONE;         // type is plugin
386         }
387         return 0;
388 }
389
390 int PluginDialog::attach_shared(int number)
391 {
392         if(number >= 0 && number < plugin_locations.size())
393         {
394                 thread->plugin_type = PLUGIN_SHAREDPLUGIN;         // type is shared plugin
395                 thread->shared_location = *(plugin_locations.values[number]); // copy location
396         }
397         return 0;
398 }
399
400 int PluginDialog::attach_module(int number)
401 {
402         if(number >= 0 && number < module_locations.size())
403         {
404 //              title->update(module_data.values[number]->get_text());
405                 thread->plugin_type = PLUGIN_SHAREDMODULE;         // type is module
406                 thread->shared_location = *(module_locations.values[number]); // copy location
407         }
408         return 0;
409 }
410
411 void PluginDialog::save_settings()
412 {
413 }
414
415
416 void PluginDialog::clear_selection()
417 {
418         standalone_list->set_all_selected(&standalone_data, 0);
419         standalone_list->draw_items(1);
420         shared_list->set_all_selected(&shared_data, 0);
421         shared_list->draw_items(1);
422         module_list->set_all_selected(&module_data, 0);
423         module_list->draw_items(1);
424         selected_available = -1;
425         selected_shared = -1;
426         selected_modules = -1;
427         thread->plugin = 0;
428         thread->plugin_type = PLUGIN_NONE;
429 }
430
431 void PluginDialog::apply()
432 {
433         if( selected_available >= 0 ) {
434                 attach_new(selected_available);
435         }
436         else if( selected_shared >= 0 ) {
437                 attach_shared(selected_shared);
438         }
439         else if( selected_modules >= 0 ) {
440                 attach_module(selected_modules);
441         }
442
443         thread->apply();
444 }
445
446 void PluginDialogThread::apply()
447 {
448         if( mwindow->edl )
449                 mwindow->edl->session->single_standalone = single_standalone;
450         if(plugin_type) {
451                 mwindow->gui->lock_window("PluginDialogThread::run 3");
452                 mwindow->undo->update_undo_before();
453                 if( is_mainmenu ) {
454                         mwindow->insert_effect(plugin_title, &shared_location,
455                                 data_type, plugin_type, single_standalone);
456                 }
457                 else {
458                         if( plugin ) {
459                                 if( mwindow->edl->tracks->plugin_exists(plugin) ) {
460                                         plugin->change_plugin(plugin_title,
461                                                 &shared_location, plugin_type);
462                                 }
463                         }
464                         else {
465                                 if( mwindow->edl->tracks->track_exists(track) ) {
466                                         mwindow->insert_effect(plugin_title, &shared_location,
467                                                 track, 0, 0, 0, plugin_type);
468                                 }
469                         }
470                 }
471
472                 mwindow->save_backup();
473                 mwindow->undo->update_undo_after(_("attach effect"), LOAD_EDITS | LOAD_PATCHES);
474                 mwindow->restart_brender();
475                 mwindow->update_plugin_states();
476                 mwindow->sync_parameters(CHANGE_EDL);
477                 mwindow->gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
478                 mwindow->gui->unlock_window();
479         }
480         plugin = 0;
481 }
482
483 PluginDialogApply::PluginDialogApply(PluginDialog *dialog, int x, int y)
484  : BC_GenericButton(x, y, _("Apply"))
485 {
486         this->dialog = dialog;
487 }
488
489 int PluginDialogApply::handle_event()
490 {
491         dialog->apply();
492         dialog->clear_selection();
493         return 1;
494 }
495
496
497
498
499
500
501 //
502 // PluginDialogTextBox::PluginDialogTextBox(PluginDialog *dialog, char *text, int x, int y)
503 //  : BC_TextBox(x, y, 200, 1, text)
504 // {
505 //      this->dialog = dialog;
506 // }
507 // PluginDialogTextBox::~PluginDialogTextBox()
508 // { }
509 // int PluginDialogTextBox::handle_event()
510 // { }
511 //
512 // PluginDialogDetach::PluginDialogDetach(MWindow *mwindow, PluginDialog *dialog, int x, int y)
513 //  : BC_GenericButton(x, y, _("Detach"))
514 // {
515 //      this->dialog = dialog;
516 // }
517 // PluginDialogDetach::~PluginDialogDetach()
518 // { }
519 // int PluginDialogDetach::handle_event()
520 // {
521 // //   dialog->title->update(_("None"));
522 //      dialog->thread->plugin_type = 0;         // type is none
523 //      dialog->thread->plugin_title[0] = 0;
524 //      return 1;
525 // }
526 //
527
528
529
530
531
532
533
534
535
536
537
538
539
540 PluginDialogNew::PluginDialogNew(PluginDialog *dialog,
541         ArrayList<BC_ListBoxItem*> *standalone_data,
542         int x, int y, int w, int h)
543  : BC_ListBox(x, y, w, h, LISTBOX_TEXT, standalone_data)
544 {
545         this->dialog = dialog;
546 }
547
548 PluginDialogNew::~PluginDialogNew() { }
549 int PluginDialogNew::handle_event()
550 {
551 //      dialog->attach_new(get_selection_number(0, 0));
552 //      deactivate();
553
554         set_done(0);
555         return 1;
556 }
557 int PluginDialogNew::selection_changed()
558 {
559         int no = get_selection_number(0, 0);
560         dialog->selected_available = no >= 0 && no < dialog->standalone_data.size() ?
561                 ((PluginDialogListItem *)dialog->standalone_data[no])->item_no : -1;
562         dialog->shared_list->set_all_selected(&dialog->shared_data, 0);
563         dialog->shared_list->draw_items(1);
564         dialog->selected_shared = -1;
565         dialog->module_list->set_all_selected(&dialog->module_data, 0);
566         dialog->module_list->draw_items(1);
567         dialog->selected_modules = -1;
568         return 1;
569 }
570
571 // PluginDialogAttachNew::PluginDialogAttachNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
572 //  : BC_GenericButton(x, y, _("Attach"))
573 // {
574 //      this->dialog = dialog;
575 // }
576 // PluginDialogAttachNew::~PluginDialogAttachNew()
577 // {
578 // }
579 // int PluginDialogAttachNew::handle_event()
580 // {
581 //      dialog->attach_new(dialog->selected_available);
582 //      set_done(0);
583 //      return 1;
584 // }
585 //
586 // PluginDialogChangeNew::PluginDialogChangeNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
587 //  : BC_GenericButton(x, y, _("Change"))
588 // {
589 //    this->dialog = dialog;
590 // }
591 // PluginDialogChangeNew::~PluginDialogChangeNew()
592 // {
593 // }
594 // int PluginDialogChangeNew::handle_event()
595 // {
596 //    dialog->attach_new(dialog->selected_available);
597 //    set_done(0);
598 //    return 1;
599 // }
600
601
602
603
604
605
606
607
608
609
610 PluginDialogShared::PluginDialogShared(PluginDialog *dialog,
611         ArrayList<BC_ListBoxItem*> *shared_data,
612         int x,
613         int y,
614         int w,
615         int h)
616  : BC_ListBox(x,
617         y,
618         w,
619         h,
620         LISTBOX_TEXT,
621         shared_data)
622 {
623         this->dialog = dialog;
624 }
625 PluginDialogShared::~PluginDialogShared() { }
626 int PluginDialogShared::handle_event()
627 {
628 //      dialog->attach_shared(get_selection_number(0, 0));
629 //      deactivate();
630         set_done(0);
631         return 1;
632 }
633 int PluginDialogShared::selection_changed()
634 {
635         dialog->selected_shared = get_selection_number(0, 0);
636
637
638         dialog->standalone_list->set_all_selected(&dialog->standalone_data, 0);
639         dialog->standalone_list->draw_items(1);
640         dialog->module_list->set_all_selected(&dialog->module_data, 0);
641         dialog->module_list->draw_items(1);
642         dialog->selected_available = -1;
643         dialog->selected_modules = -1;
644         return 1;
645 }
646
647 // PluginDialogAttachShared::PluginDialogAttachShared(MWindow *mwindow,
648 //      PluginDialog *dialog,
649 //      int x,
650 //      int y)
651 //  : BC_GenericButton(x, y, _("Attach"))
652 // {
653 //      this->dialog = dialog;
654 // }
655 // PluginDialogAttachShared::~PluginDialogAttachShared() { }
656 // int PluginDialogAttachShared::handle_event()
657 // {
658 //      dialog->attach_shared(dialog->selected_shared);
659 //      set_done(0);
660 //      return 1;
661 // }
662 //
663 // PluginDialogChangeShared::PluginDialogChangeShared(MWindow *mwindow,
664 //    PluginDialog *dialog,
665 //    int x,
666 //    int y)
667 //  : BC_GenericButton(x, y, _("Change"))
668 // {
669 //    this->dialog = dialog;
670 // }
671 // PluginDialogChangeShared::~PluginDialogChangeShared() { }
672 // int PluginDialogChangeShared::handle_event()
673 // {
674 //    dialog->attach_shared(dialog->selected_shared);
675 //    set_done(0);
676 //    return 1;
677 // }
678 //
679
680
681
682
683
684
685
686
687
688
689
690
691 PluginDialogModules::PluginDialogModules(PluginDialog *dialog,
692         ArrayList<BC_ListBoxItem*> *module_data,
693         int x,
694         int y,
695         int w,
696         int h)
697  : BC_ListBox(x,
698         y,
699         w,
700         h,
701         LISTBOX_TEXT,
702         module_data)
703 {
704         this->dialog = dialog;
705 }
706 PluginDialogModules::~PluginDialogModules() { }
707 int PluginDialogModules::handle_event()
708 {
709 //      dialog->attach_module(get_selection_number(0, 0));
710 //      deactivate();
711
712         set_done(0);
713         return 1;
714 }
715 int PluginDialogModules::selection_changed()
716 {
717         dialog->selected_modules = get_selection_number(0, 0);
718
719
720         dialog->standalone_list->set_all_selected(&dialog->standalone_data, 0);
721         dialog->standalone_list->draw_items(1);
722         dialog->shared_list->set_all_selected(&dialog->shared_data, 0);
723         dialog->shared_list->draw_items(1);
724         dialog->selected_available = -1;
725         dialog->selected_shared = -1;
726         return 1;
727 }
728
729 void PluginDialog::load_plugin_list(int redraw)
730 {
731         standalone_data.remove_all_objects();
732         const char *text = search_text->get_text();
733
734         for( int i=0; i<plugindb.total; ++i ) {
735                 const char *title = _(plugindb.values[i]->title);
736                 if( text && text[0] && !bstrcasestr(title, text) ) continue;
737                 standalone_data.append(new PluginDialogListItem(title, i));
738         }
739
740         if( redraw )
741                 standalone_list->draw_items(1);
742 }
743
744 PluginDialogSearchText::PluginDialogSearchText(PluginDialog *dialog, int x, int y, int w)
745  : BC_TextBox(x, y, w, 1, "")
746 {
747         this->dialog = dialog;
748 }
749
750 int PluginDialogSearchText::handle_event()
751 {
752         dialog->load_plugin_list(1);
753         return 1;
754 }
755
756 PluginDialogSingle::PluginDialogSingle(PluginDialog *dialog, int x, int y)
757  : BC_CheckBox(x,
758         y,
759         dialog->thread->single_standalone,
760         _("Attach single standalone and share others"))
761 {
762         this->dialog = dialog;
763 }
764
765 int PluginDialogSingle::handle_event()
766 {
767         dialog->thread->single_standalone = get_value();
768         return 1;
769 }
770
771
772 // PluginDialogAttachModule::PluginDialogAttachModule(MWindow *mwindow,
773 //      PluginDialog *dialog,
774 //      int x,
775 //      int y)
776 //  : BC_GenericButton(x, y, _("Attach"))
777 // {
778 //      this->dialog = dialog;
779 // }
780 // PluginDialogAttachModule::~PluginDialogAttachModule() { }
781 // int PluginDialogAttachModule::handle_event()
782 // {
783 //      dialog->attach_module(dialog->selected_modules);
784 //      set_done(0);
785 //      return 1;
786 // }
787 //
788 // PluginDialogChangeModule::PluginDialogChangeModule(MWindow *mwindow,
789 //    PluginDialog *dialog,
790 //    int x,
791 //    int y)
792 //  : BC_GenericButton(x, y, _("Change"))
793 // {
794 //    this->dialog = dialog;
795 // }
796 // PluginDialogChangeModule::~PluginDialogChangeModule() { }
797 // int PluginDialogChangeModule::handle_event()
798 // {
799 //    dialog->attach_module(dialog->selected_modules);
800 //    set_done(0);
801 //    return 1;
802 // }
803 //
804
805
806
807
808
809
810
811
812
813
814
815
816