RafaMar + programmer friend Help button in Batch Render addition
[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         EDL *edl = mwindow->edl;
440         if( edl )
441                 edl->session->single_standalone = single_standalone;
442         if(plugin_type) {
443                 mwindow->gui->lock_window("PluginDialogThread::run 3");
444                 mwindow->undo->update_undo_before();
445                 if( is_mainmenu ) {
446                         mwindow->insert_effect(plugin_title, &shared_location,
447                                 data_type, plugin_type, single_standalone);
448                 }
449                 else if( (plugin=edl->tracks->plugin_exists(plugin_id)) != 0 ) {
450                         plugin->change_plugin(plugin_title,
451                                         &shared_location, plugin_type);
452                 }
453                 else if( edl->tracks->track_exists(track) ) {
454                         double start = edl->local_session->get_selectionstart(1);
455                         double end = edl->local_session->get_selectionend(1);
456                         if( start >= end ) {
457                                 start = 0;
458                                 end = track->get_length();
459                         }
460                         double length = end - start;
461                         mwindow->insert_effect(plugin_title, &shared_location,
462                                         track, 0, start, length, plugin_type);
463                 }
464
465                 mwindow->save_backup();
466                 mwindow->undo->update_undo_after(_("attach effect"), LOAD_EDITS | LOAD_PATCHES);
467                 mwindow->restart_brender();
468                 mwindow->update_plugin_states();
469                 mwindow->sync_parameters(CHANGE_EDL);
470                 mwindow->gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
471                 mwindow->gui->unlock_window();
472         }
473         plugin_id = -1;
474 }
475
476 PluginDialogApply::PluginDialogApply(PluginDialog *dialog, int x, int y)
477  : BC_GenericButton(x, y, _("Apply"))
478 {
479         this->dialog = dialog;
480 }
481
482 int PluginDialogApply::handle_event()
483 {
484         dialog->apply();
485         dialog->clear_selection();
486         return 1;
487 }
488
489
490
491
492
493
494 //
495 // PluginDialogTextBox::PluginDialogTextBox(PluginDialog *dialog, char *text, int x, int y)
496 //  : BC_TextBox(x, y, xS(200), 1, text)
497 // {
498 //      this->dialog = dialog;
499 // }
500 // PluginDialogTextBox::~PluginDialogTextBox()
501 // { }
502 // int PluginDialogTextBox::handle_event()
503 // { }
504 //
505 // PluginDialogDetach::PluginDialogDetach(MWindow *mwindow, PluginDialog *dialog, int x, int y)
506 //  : BC_GenericButton(x, y, _("Detach"))
507 // {
508 //      this->dialog = dialog;
509 // }
510 // PluginDialogDetach::~PluginDialogDetach()
511 // { }
512 // int PluginDialogDetach::handle_event()
513 // {
514 // //   dialog->title->update(_("None"));
515 //      dialog->thread->plugin_type = 0;         // type is none
516 //      dialog->thread->plugin_title[0] = 0;
517 //      return 1;
518 // }
519 //
520
521
522
523 PluginDialogNew::PluginDialogNew(PluginDialog *dialog,
524         ArrayList<BC_ListBoxItem*> *standalone_data,
525         int x, int y, int w, int h)
526  : BC_ListBox(x, y, w, h, LISTBOX_TEXT, standalone_data)
527 {
528         this->dialog = dialog;
529 }
530
531 PluginDialogNew::~PluginDialogNew() { }
532 int PluginDialogNew::handle_event()
533 {
534 //      dialog->attach_new(get_selection_number(0, 0));
535 //      deactivate();
536
537         set_done(0);
538         return 1;
539 }
540 int PluginDialogNew::selection_changed()
541 {
542         int no = get_selection_number(0, 0);
543         dialog->selected_available = no >= 0 && no < dialog->standalone_data.size() ?
544                 ((PluginDialogListItem *)dialog->standalone_data[no])->item_no : -1;
545         dialog->shared_list->set_all_selected(&dialog->shared_data, 0);
546         dialog->shared_list->draw_items(1);
547         dialog->selected_shared = -1;
548         dialog->module_list->set_all_selected(&dialog->module_data, 0);
549         dialog->module_list->draw_items(1);
550         dialog->selected_modules = -1;
551         return 1;
552 }
553
554 // PluginDialogAttachNew::PluginDialogAttachNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
555 //  : BC_GenericButton(x, y, _("Attach"))
556 // {
557 //      this->dialog = dialog;
558 // }
559 // PluginDialogAttachNew::~PluginDialogAttachNew()
560 // {
561 // }
562 // int PluginDialogAttachNew::handle_event()
563 // {
564 //      dialog->attach_new(dialog->selected_available);
565 //      set_done(0);
566 //      return 1;
567 // }
568 //
569 // PluginDialogChangeNew::PluginDialogChangeNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
570 //  : BC_GenericButton(x, y, _("Change"))
571 // {
572 //    this->dialog = dialog;
573 // }
574 // PluginDialogChangeNew::~PluginDialogChangeNew()
575 // {
576 // }
577 // int PluginDialogChangeNew::handle_event()
578 // {
579 //    dialog->attach_new(dialog->selected_available);
580 //    set_done(0);
581 //    return 1;
582 // }
583
584
585 PluginDialogShared::PluginDialogShared(PluginDialog *dialog,
586         ArrayList<BC_ListBoxItem*> *shared_data,
587         int x, int y, int w, int h)
588  : BC_ListBox(x, y, w, h, LISTBOX_TEXT, shared_data)
589 {
590         this->dialog = dialog;
591 }
592 PluginDialogShared::~PluginDialogShared() { }
593 int PluginDialogShared::handle_event()
594 {
595 //      dialog->attach_shared(get_selection_number(0, 0));
596 //      deactivate();
597         set_done(0);
598         return 1;
599 }
600 int PluginDialogShared::selection_changed()
601 {
602         dialog->selected_shared = get_selection_number(0, 0);
603
604
605         dialog->standalone_list->set_all_selected(&dialog->standalone_data, 0);
606         dialog->standalone_list->draw_items(1);
607         dialog->module_list->set_all_selected(&dialog->module_data, 0);
608         dialog->module_list->draw_items(1);
609         dialog->selected_available = -1;
610         dialog->selected_modules = -1;
611         return 1;
612 }
613
614 // PluginDialogAttachShared::PluginDialogAttachShared(MWindow *mwindow,
615 //      PluginDialog *dialog,
616 //      int x,
617 //      int y)
618 //  : BC_GenericButton(x, y, _("Attach"))
619 // {
620 //      this->dialog = dialog;
621 // }
622 // PluginDialogAttachShared::~PluginDialogAttachShared() { }
623 // int PluginDialogAttachShared::handle_event()
624 // {
625 //      dialog->attach_shared(dialog->selected_shared);
626 //      set_done(0);
627 //      return 1;
628 // }
629 //
630 // PluginDialogChangeShared::PluginDialogChangeShared(MWindow *mwindow,
631 //    PluginDialog *dialog,
632 //    int x,
633 //    int y)
634 //  : BC_GenericButton(x, y, _("Change"))
635 // {
636 //    this->dialog = dialog;
637 // }
638 // PluginDialogChangeShared::~PluginDialogChangeShared() { }
639 // int PluginDialogChangeShared::handle_event()
640 // {
641 //    dialog->attach_shared(dialog->selected_shared);
642 //    set_done(0);
643 //    return 1;
644 // }
645 //
646
647
648
649
650
651
652
653
654
655
656
657
658 PluginDialogModules::PluginDialogModules(PluginDialog *dialog,
659         ArrayList<BC_ListBoxItem*> *module_data,
660         int x, int y, int w, int h)
661  : BC_ListBox(x, y, w, h, LISTBOX_TEXT, module_data)
662 {
663         this->dialog = dialog;
664 }
665 PluginDialogModules::~PluginDialogModules() { }
666 int PluginDialogModules::handle_event()
667 {
668 //      dialog->attach_module(get_selection_number(0, 0));
669 //      deactivate();
670
671         set_done(0);
672         return 1;
673 }
674 int PluginDialogModules::selection_changed()
675 {
676         dialog->selected_modules = get_selection_number(0, 0);
677
678
679         dialog->standalone_list->set_all_selected(&dialog->standalone_data, 0);
680         dialog->standalone_list->draw_items(1);
681         dialog->shared_list->set_all_selected(&dialog->shared_data, 0);
682         dialog->shared_list->draw_items(1);
683         dialog->selected_available = -1;
684         dialog->selected_shared = -1;
685         return 1;
686 }
687
688 void PluginDialog::load_plugin_list(int redraw)
689 {
690         standalone_data.remove_all_objects();
691         const char *text = search_text->get_text();
692
693         for( int i=0; i<plugindb.total; ++i ) {
694                 const char *title = _(plugindb.values[i]->title);
695                 if( text && text[0] && !bstrcasestr(title, text) ) continue;
696                 standalone_data.append(new PluginDialogListItem(title, i));
697         }
698
699         if( redraw )
700                 standalone_list->draw_items(1);
701 }
702
703 PluginDialogSearchText::PluginDialogSearchText(PluginDialog *dialog, int x, int y, int w)
704  : BC_TextBox(x, y, w, 1, "")
705 {
706         this->dialog = dialog;
707 }
708
709 int PluginDialogSearchText::handle_event()
710 {
711         dialog->load_plugin_list(1);
712         return 1;
713 }
714
715 PluginDialogSingle::PluginDialogSingle(PluginDialog *dialog, int x, int y)
716  : BC_CheckBox(x, y, dialog->thread->single_standalone,
717         _("Attach single standalone and share others"))
718 {
719         this->dialog = dialog;
720 }
721
722 int PluginDialogSingle::handle_event()
723 {
724         dialog->thread->single_standalone = get_value();
725         return 1;
726 }
727
728
729 // PluginDialogAttachModule::PluginDialogAttachModule(MWindow *mwindow,
730 //      PluginDialog *dialog,
731 //      int x,
732 //      int y)
733 //  : BC_GenericButton(x, y, _("Attach"))
734 // {
735 //      this->dialog = dialog;
736 // }
737 // PluginDialogAttachModule::~PluginDialogAttachModule() { }
738 // int PluginDialogAttachModule::handle_event()
739 // {
740 //      dialog->attach_module(dialog->selected_modules);
741 //      set_done(0);
742 //      return 1;
743 // }
744 //
745 // PluginDialogChangeModule::PluginDialogChangeModule(MWindow *mwindow,
746 //    PluginDialog *dialog,
747 //    int x,
748 //    int y)
749 //  : BC_GenericButton(x, y, _("Change"))
750 // {
751 //    this->dialog = dialog;
752 // }
753 // PluginDialogChangeModule::~PluginDialogChangeModule() { }
754 // int PluginDialogChangeModule::handle_event()
755 // {
756 //    dialog->attach_module(dialog->selected_modules);
757 //    set_done(0);
758 //    return 1;
759 // }
760 //
761