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