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