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