picon dirs, new cinfinity picons, plugin info, rework text drawing, show msg, compres...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / interfaceprefs.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 "deleteallindexes.h"
23 #include "edl.h"
24 #include "edlsession.h"
25 #include "file.h"
26 #include "filesystem.h"
27 #include "language.h"
28 #include "mwindow.h"
29 #include "preferences.h"
30 #include "preferencesthread.h"
31 #include "interfaceprefs.h"
32 #include "shbtnprefs.h"
33 #include "theme.h"
34
35 #if 0
36 N_("Drag all following edits")
37 N_("Drag only one edit")
38 N_("Drag source only")
39 N_("No effect")
40 #endif
41
42 #define MOVE_ALL_EDITS_TITLE "Drag all following edits"
43 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
44 #define MOVE_NO_EDITS_TITLE "Drag source only"
45 #define MOVE_EDITS_DISABLED_TITLE "No effect"
46
47 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
48  : PreferencesDialog(mwindow, pwindow)
49 {
50         hms = 0;
51         hmsf = 0;
52         samples = 0;
53         frames = 0;
54         hex = 0;
55         feet = 0;
56         min_db = 0;
57         max_db = 0;
58 //      vu_db = 0;
59 //      vu_int = 0;
60         thumbnails = 0;
61         shbtn_dialog = 0;
62 }
63
64 InterfacePrefs::~InterfacePrefs()
65 {
66         delete hms;
67         delete hmsf;
68         delete samples;
69         delete frames;
70         delete hex;
71         delete feet;
72         delete min_db;
73         delete max_db;
74 //      delete vu_db;
75 //      delete vu_int;
76         delete thumbnails;
77         delete shbtn_dialog;
78 }
79
80
81 void InterfacePrefs::create_objects()
82 {
83         BC_Resources *resources = BC_WindowBase::get_resources();
84         int margin = mwindow->theme->widget_border;
85         char string[BCTEXTLEN];
86         int x0 = mwindow->theme->preferencesoptions_x;
87         int y0 = mwindow->theme->preferencesoptions_y;
88         int x = x0, y = y0;
89
90         add_subwindow(new BC_Title(x, y, _("Time Format"), LARGEFONT,
91                 resources->text_default));
92         int x1 = get_w()/2;
93         add_subwindow(new BC_Title(x1, y, _("Flags"), LARGEFONT,
94                 resources->text_default));
95
96         y += get_text_height(LARGEFONT) + 5;
97         int y1 = y;
98
99         add_subwindow(hms = new TimeFormatHMS(pwindow, this,
100                 pwindow->thread->edl->session->time_format == TIME_HMS,
101                 x, y));
102         y += 20;
103         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
104                 pwindow->thread->edl->session->time_format == TIME_HMSF,
105                 x, y));
106         y += 20;
107         add_subwindow(samples = new TimeFormatSamples(pwindow, this,
108                 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
109                 x, y));
110         y += 20;
111         add_subwindow(hex = new TimeFormatHex(pwindow, this,
112                 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
113                 x, y));
114         y += 20;
115         add_subwindow(frames = new TimeFormatFrames(pwindow, this,
116                 pwindow->thread->edl->session->time_format == TIME_FRAMES,
117                 x, y));
118         y += 20;
119         add_subwindow(feet = new TimeFormatFeet(pwindow, this,
120                 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
121                 x, y));
122         x += feet->get_w() + 15;
123         BC_Title *title;
124         add_subwindow(title = new BC_Title(x, y, _("Frames per foot:")));
125         x += title->get_w() + margin;
126         sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
127         add_subwindow(new TimeFormatFeetSetting(pwindow,
128                 x, y - 5,       string));
129         x = x0;
130         y += 20;
131         add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
132                 pwindow->thread->edl->session->time_format == TIME_SECONDS,
133                 x, y));
134         y += 35;
135
136         UseTipWindow *tip_win = new UseTipWindow(pwindow, x1, y1);
137         add_subwindow(tip_win);
138         y1 += tip_win->get_h() + 5;
139         UseWarnIndecies *idx_win = new UseWarnIndecies(pwindow, x1, y1);
140         add_subwindow(idx_win);
141         y1 += idx_win->get_h() + 5;
142         UseWarnVersion *ver_win = new UseWarnVersion(pwindow, x1, y1);
143         add_subwindow(ver_win);
144         y1 += ver_win->get_h() + 5;
145         BD_WarnRoot *bdwr_win = new BD_WarnRoot(pwindow, x1, y1);
146         add_subwindow(bdwr_win);
147         y1 += bdwr_win->get_h() + 5;
148         PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x1, y1);
149         add_subwindow(pop_win);
150         y1 += pop_win->get_h() + 5;
151         ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x1, y1);
152         add_subwindow(focus_activate);
153         y1 += focus_activate->get_h() + 5;
154         DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x1, y1);
155         add_subwindow(focus_deactivate);
156         y1 += focus_deactivate->get_h() + 5;
157
158         if( y < y1 ) y = y1;
159         y += 10;
160
161         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
162         y += 5;
163
164         add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
165         add_subwindow(ffmpeg_marker_files = new IndexFFMPEGMarkerFiles(this, x1, y));
166
167
168         y += 30;
169         add_subwindow(new BC_Title(x, y + 5,
170                 _("Index files go here:"), MEDIUMFONT, resources->text_default));
171         add_subwindow(ipathtext = new IndexPathText(x + 230, y,
172                 pwindow,
173                 pwindow->thread->preferences->index_directory));
174         add_subwindow(ipath = new BrowseButton(mwindow->theme, this, ipathtext,
175                 x1 = x + 230 + ipathtext->get_w(), y,
176                 pwindow->thread->preferences->index_directory,
177                 _("Index Path"),
178                 _("Select the directory for index files"),
179                 1));
180
181         y += 30;
182         add_subwindow(new BC_Title(x, y + 5,
183                 _("Size of index file:"),
184                 MEDIUMFONT,
185                 resources->text_default));
186         sprintf(string, "%jd", pwindow->thread->preferences->index_size);
187         add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
188         add_subwindow(new ScanCommercials(pwindow, 350,y));
189         y += 30;
190         add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
191         sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
192         add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
193         add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
194
195
196         y += 35;
197         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
198         y += 5;
199
200         add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
201
202         y1 = y + 5;
203         y += 35;
204         add_subwindow(title = new BC_Title(x, y, _("Keyframe reticle:")));
205         x1 = x + 140;
206         keyframe_reticle = new KeyframeReticle(x1, y, &pwindow->thread->preferences->keyframe_reticle);
207         add_subwindow(keyframe_reticle);
208         keyframe_reticle->create_objects();
209
210         int x2 = x + 400, y2 = y;
211         add_subwindow(thumbnails = new ViewThumbnails(x2, y1, pwindow));
212         AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y2);
213         add_subwindow(android_remote);
214         y2 += android_remote->get_h() + 10;
215         add_subwindow(title = new BC_Title(x2, y2, _("Port:")));
216         int x3 = x2 + title->get_w() + margin;
217         AndroidPort *android_port = new AndroidPort(pwindow, x3, y2);
218         add_subwindow(android_port);
219         y2 += title->get_h() + 10;
220         add_subwindow(title = new BC_Title(x2, y2, _("PIN:")));
221         AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y2);
222         add_subwindow(android_pin);
223
224         y2 += title->get_h() + 30;
225         ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y2);
226         add_subwindow(shbtn_prefs);
227
228         y2 += shbtn_prefs->get_h() + 30;
229         StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
230                 pwindow->thread->edl->session->si_useduration, x2, y2);
231         add_subwindow(use_stduration);
232         int tw = 0, th = 0;
233         BC_CheckBox::calculate_extents(this, &tw, &th, 0, 0);
234         x2 += tw + 3;
235         y2 += use_stduration->get_h() + 3;
236         StillImageDuration *stduration = new StillImageDuration(pwindow, x2, y2);
237         add_subwindow(stduration);
238         x2 += stduration->get_w() + 10;
239         y2 += 3;
240         add_subwindow(new BC_Title(x2, y2, _("Seconds")));
241
242         y += 35;
243         add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
244         y += 25;
245         add_subwindow(new BC_Title(x, y, _("Button 1:")));
246
247         x1 = x + 100;
248         ViewBehaviourText *text;
249         add_subwindow(text = new ViewBehaviourText(x1, y - 5,
250                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
251                         pwindow,
252                         &(pwindow->thread->edl->session->edit_handle_mode[0])));
253         text->create_objects();
254         y += 30;
255         add_subwindow(new BC_Title(x, y, _("Button 2:")));
256         add_subwindow(text = new ViewBehaviourText(x1,
257                 y - 5,
258                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
259                         pwindow,
260                         &(pwindow->thread->edl->session->edit_handle_mode[1])));
261         text->create_objects();
262         y += 30;
263         add_subwindow(new BC_Title(x, y, _("Button 3:")));
264         add_subwindow(text = new ViewBehaviourText(x1,
265                 y - 5,
266                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
267                         pwindow,
268                         &(pwindow->thread->edl->session->edit_handle_mode[2])));
269         text->create_objects();
270
271         y += 40;
272
273         add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
274         x += title->get_w() + 10;
275         sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
276         add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
277
278         x += min_db->get_w() + 10;
279         add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
280         x += title->get_w() + 10;
281         sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
282         add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
283
284         x = x0;
285         y += 30;
286         ViewTheme *theme;
287         add_subwindow(new BC_Title(x, y, _("Theme:")));
288         add_subwindow(theme = new ViewTheme(x1, y, pwindow));
289         theme->create_objects();
290
291         x = x0;
292         y += theme->get_h() + 5;
293         ViewPluginIcons *plugin_icons;
294         add_subwindow(new BC_Title(x, y, _("Plugin Icons:")));
295         add_subwindow(plugin_icons = new ViewPluginIcons(x1, y, pwindow));
296         plugin_icons->create_objects();
297 }
298
299 const char* InterfacePrefs::behavior_to_text(int mode)
300 {
301         switch(mode) {
302                 case MOVE_ALL_EDITS: return _(MOVE_ALL_EDITS_TITLE);
303                 case MOVE_ONE_EDIT:  return _(MOVE_ONE_EDIT_TITLE);
304                 case MOVE_NO_EDITS:  return _(MOVE_NO_EDITS_TITLE);
305                 case MOVE_EDITS_DISABLED: return _(MOVE_EDITS_DISABLED_TITLE);
306                 default: return "";
307         }
308 }
309
310 int InterfacePrefs::update(int new_value)
311 {
312         pwindow->thread->redraw_times = 1;
313         pwindow->thread->edl->session->time_format = new_value;
314         hms->update(new_value == TIME_HMS);
315         hmsf->update(new_value == TIME_HMSF);
316         samples->update(new_value == TIME_SAMPLES);
317         hex->update(new_value == TIME_SAMPLES_HEX);
318         frames->update(new_value == TIME_FRAMES);
319         feet->update(new_value == TIME_FEET_FRAMES);
320         seconds->update(new_value == TIME_SECONDS);
321         return 0;
322 }
323
324
325
326
327 IndexPathText::IndexPathText(int x,
328         int y,
329         PreferencesWindow *pwindow,
330         char *text)
331  : BC_TextBox(x, y, 240, 1, text)
332 {
333         this->pwindow = pwindow;
334 }
335
336 IndexPathText::~IndexPathText() {}
337
338 int IndexPathText::handle_event()
339 {
340         strcpy(pwindow->thread->preferences->index_directory, get_text());
341         return 1;
342 }
343
344
345
346
347 IndexSize::IndexSize(int x,
348         int y,
349         PreferencesWindow *pwindow,
350         char *text)
351  : BC_TextBox(x, y, 100, 1, text)
352 {
353         this->pwindow = pwindow;
354 }
355
356 int IndexSize::handle_event()
357 {
358         long result;
359
360         result = atol(get_text());
361         if(result < 64000) result = 64000;
362         //if(result < 500000) result = 500000;
363         pwindow->thread->preferences->index_size = result;
364         return 0;
365 }
366
367
368
369 IndexCount::IndexCount(int x,
370         int y,
371         PreferencesWindow *pwindow,
372         char *text)
373  : BC_TextBox(x, y, 100, 1, text)
374 {
375         this->pwindow = pwindow;
376 }
377
378 int IndexCount::handle_event()
379 {
380         long result;
381
382         result = atol(get_text());
383         if(result < 1) result = 1;
384         pwindow->thread->preferences->index_count = result;
385         return 0;
386 }
387
388
389
390 IndexFFMPEGMarkerFiles::IndexFFMPEGMarkerFiles(InterfacePrefs *iface_prefs, int x, int y)
391  : BC_CheckBox(x, y,
392         iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
393         _("build ffmpeg marker indexes"))
394 {
395         this->iface_prefs = iface_prefs;
396 }
397 IndexFFMPEGMarkerFiles::~IndexFFMPEGMarkerFiles()
398 {
399 }
400
401 int IndexFFMPEGMarkerFiles::handle_event()
402 {
403         iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
404         return 1;
405 }
406
407
408
409 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
410  : BC_Radial(x, y, value, TIME_HMS_TEXT)
411 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
412
413 int TimeFormatHMS::handle_event()
414 {
415         tfwindow->update(TIME_HMS);
416         return 1;
417 }
418
419 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
420  : BC_Radial(x, y, value, TIME_HMSF_TEXT)
421 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
422
423 int TimeFormatHMSF::handle_event()
424 {
425         tfwindow->update(TIME_HMSF);
426         return 1;
427 }
428
429 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
430  : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
431 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
432
433 int TimeFormatSamples::handle_event()
434 {
435         tfwindow->update(TIME_SAMPLES);
436         return 1;
437 }
438
439 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
440  : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
441 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
442
443 int TimeFormatFrames::handle_event()
444 {
445         tfwindow->update(TIME_FRAMES);
446         return 1;
447 }
448
449 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
450  : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
451 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
452
453 int TimeFormatHex::handle_event()
454 {
455         tfwindow->update(TIME_SAMPLES_HEX);
456         return 1;
457 }
458
459 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
460  : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
461 {
462         this->pwindow = pwindow;
463         this->tfwindow = tfwindow;
464 }
465
466 int TimeFormatSeconds::handle_event()
467 {
468         tfwindow->update(TIME_SECONDS);
469         return 1;
470 }
471
472 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
473  : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
474 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
475
476 int TimeFormatFeet::handle_event()
477 {
478         tfwindow->update(TIME_FEET_FRAMES);
479         return 1;
480 }
481
482 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
483  : BC_TextBox(x, y, 90, 1, string)
484 { this->pwindow = pwindow; }
485
486 int TimeFormatFeetSetting::handle_event()
487 {
488         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
489         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
490         return 0;
491 }
492
493
494
495
496 ViewBehaviourText::ViewBehaviourText(int x,
497         int y,
498         const char *text,
499         PreferencesWindow *pwindow,
500         int *output)
501  : BC_PopupMenu(x, y, 200, text)
502 {
503         this->output = output;
504 }
505
506 ViewBehaviourText::~ViewBehaviourText()
507 {
508 }
509
510 int ViewBehaviourText::handle_event()
511 {
512         return 0;
513 }
514
515 void ViewBehaviourText::create_objects()
516 {
517 // Video4linux versions are automatically detected
518         add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
519         add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
520         add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
521         add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
522 }
523
524
525 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
526  : BC_MenuItem(text)
527 {
528         this->popup = popup;
529         this->behaviour = behaviour;
530 }
531
532 ViewBehaviourItem::~ViewBehaviourItem()
533 {
534 }
535
536 int ViewBehaviourItem::handle_event()
537 {
538         popup->set_text(get_text());
539         *(popup->output) = behaviour;
540         return 1;
541 }
542
543
544
545
546 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
547  : BC_TextBox(x, y, 50, 1, text)
548 {
549         this->pwindow = pwindow;
550 }
551
552 int MeterMinDB::handle_event()
553 {
554         pwindow->thread->redraw_meters = 1;
555         pwindow->thread->edl->session->min_meter_db = atol(get_text());
556         return 0;
557 }
558
559
560
561
562 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
563  : BC_TextBox(x, y, 50, 1, text)
564 {
565         this->pwindow = pwindow;
566 }
567
568 int MeterMaxDB::handle_event()
569 {
570         pwindow->thread->redraw_meters = 1;
571         pwindow->thread->edl->session->max_meter_db = atol(get_text());
572         return 0;
573 }
574
575
576
577
578
579 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
580  : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
581 {
582         this->pwindow = pwindow;
583 }
584
585 int MeterVUDB::handle_event()
586 {
587         pwindow->thread->redraw_meters = 1;
588 //      vu_int->update(0);
589         pwindow->thread->edl->session->meter_format = METER_DB;
590         return 1;
591 }
592
593 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
594  : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
595 {
596         this->pwindow = pwindow;
597 }
598
599 int MeterVUInt::handle_event()
600 {
601         pwindow->thread->redraw_meters = 1;
602         vu_db->update(0);
603         pwindow->thread->edl->session->meter_format = METER_INT;
604         return 1;
605 }
606
607
608
609
610 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
611  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
612 {
613         this->pwindow = pwindow;
614 }
615 ViewTheme::~ViewTheme()
616 {
617 }
618
619 void ViewTheme::create_objects()
620 {
621         ArrayList<PluginServer*> themes;
622         MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
623
624         for(int i = 0; i < themes.total; i++) {
625                 add_item(new ViewThemeItem(this, themes.values[i]->title));
626         }
627 }
628
629 int ViewTheme::handle_event()
630 {
631         return 1;
632 }
633
634 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
635  : BC_MenuItem(text)
636 {
637         this->popup = popup;
638 }
639
640 int ViewThemeItem::handle_event()
641 {
642         popup->set_text(get_text());
643         strcpy(popup->pwindow->thread->preferences->theme, get_text());
644         popup->handle_event();
645         return 1;
646 }
647
648
649 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
650  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->plugin_icons, 1)
651 {
652         this->pwindow = pwindow;
653 }
654 ViewPluginIcons::~ViewPluginIcons()
655 {
656 }
657
658 void ViewPluginIcons::create_objects()
659 {
660         add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
661         FileSystem fs;
662         const char *plugin_path = File::get_plugin_path();
663         fs.update(plugin_path);
664         if( fs.update(plugin_path) ) return;
665         for( int i=0; i<fs.dir_list.total; ++i ) {
666                 char *fs_path = fs.dir_list[i]->path;
667                 if( !fs.is_dir(fs_path) ) continue;
668                 char *cp = strrchr(fs_path,'/');
669                 cp = !cp ? fs_path : cp+1;
670                 if( strncmp("picon_", cp, 6) ) continue;
671                 cp += 6;
672                 add_item(new ViewPluginIconItem(this, cp));
673         }
674 }
675
676 int ViewPluginIcons::handle_event()
677 {
678         return 1;
679 }
680
681 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
682  : BC_MenuItem(text)
683 {
684         this->popup = popup;
685 }
686
687 int ViewPluginIconItem::handle_event()
688 {
689         popup->set_text(get_text());
690         strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
691         popup->handle_event();
692         return 1;
693 }
694
695
696 ViewThumbnails::ViewThumbnails(int x,
697         int y,
698         PreferencesWindow *pwindow)
699  : BC_CheckBox(x,
700         y,
701         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
702 {
703         this->pwindow = pwindow;
704 }
705
706 int ViewThumbnails::handle_event()
707 {
708         pwindow->thread->preferences->use_thumbnails = get_value();
709         return 1;
710 }
711
712
713
714 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
715  : BC_CheckBox(x,
716         y,
717         pwindow->thread->preferences->use_tipwindow,
718         _("Show tip of the day"))
719 {
720         this->pwindow = pwindow;
721 }
722 int UseTipWindow::handle_event()
723 {
724         pwindow->thread->preferences->use_tipwindow = get_value();
725         return 1;
726 }
727
728
729 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
730  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
731         _("ffmpeg probe warns rebuild indexes"))
732 {
733         this->pwindow = pwindow;
734 }
735
736 int UseWarnIndecies::handle_event()
737 {
738         pwindow->thread->preferences->warn_indexes = get_value();
739         return 1;
740 }
741
742 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
743  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
744         _("EDL version warns if mismatched"))
745 {
746         this->pwindow = pwindow;
747 }
748
749 int UseWarnVersion::handle_event()
750 {
751         pwindow->thread->preferences->warn_version = get_value();
752         return 1;
753 }
754
755 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
756  : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
757         _("Create Bluray warns if not root"))
758 {
759         this->pwindow = pwindow;
760 }
761
762 int BD_WarnRoot::handle_event()
763 {
764         pwindow->thread->preferences->bd_warn_root = get_value();
765         return 1;
766 }
767
768 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
769  : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
770         _("Popups activate on button up"))
771 {
772         this->pwindow = pwindow;
773 }
774
775 int PopupMenuBtnup::handle_event()
776 {
777         pwindow->thread->preferences->popupmenu_btnup = get_value();
778         return 1;
779 }
780
781 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
782  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
783         _("Click to activate text focus"))
784 {
785         this->pwindow = pwindow;
786 }
787
788 int ActivateFocusPolicy::handle_event()
789 {
790         if( get_value() )
791                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
792         else
793                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
794         return 1;
795 }
796
797 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
798  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
799         _("Click to deactivate text focus"))
800 {
801         this->pwindow = pwindow;
802 }
803
804 int DeactivateFocusPolicy::handle_event()
805 {
806         if( get_value() )
807                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
808         else
809                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
810         return 1;
811 }
812
813
814
815 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
816  : BC_CheckBox(x,
817         y,
818         pwindow->thread->preferences->scan_commercials,
819         _("Scan for commercials during toc build"))
820 {
821         this->pwindow = pwindow;
822 }
823 int ScanCommercials::handle_event()
824 {
825         pwindow->thread->preferences->scan_commercials = get_value();
826         return 1;
827 }
828
829
830 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
831  : BC_CheckBox(x, y,
832         pwindow->thread->preferences->android_remote,
833         _("Android Remote Control"))
834 {
835         this->pwindow = pwindow;
836 }
837 int AndroidRemote::handle_event()
838 {
839         pwindow->thread->preferences->android_remote = get_value();
840         return 1;
841 }
842
843 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
844  : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
845 {
846         this->pwindow = pwindow;
847 }
848
849 int AndroidPIN::handle_event()
850 {
851         char *txt = pwindow->thread->preferences->android_pin;
852         int len = sizeof(pwindow->thread->preferences->android_pin);
853         strncpy(txt, get_text(), len);
854         return 1;
855 }
856
857
858 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
859  : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
860 {
861         this->pwindow = pwindow;
862 }
863
864 int AndroidPort::handle_event()
865 {
866         unsigned short port = atoi(get_text());
867         if( port < 1024 ) port = 1024;
868         pwindow->thread->preferences->android_port = port;
869         char str[BCSTRLEN];
870         sprintf(str,"%u",port);
871         update(str);
872         return 1;
873 }
874
875 int InterfacePrefs::start_shbtn_dialog()
876 {
877         if( !shbtn_dialog )
878                 shbtn_dialog = new ShBtnEditDialog(pwindow);
879         shbtn_dialog->start();
880         return 1;
881 }
882
883 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
884  : BC_GenericButton(x, y, _("Shell Commands"))
885 {
886         this->pwindow = pwindow;
887         this->iface_prefs = iface_prefs;
888         set_tooltip(_("Main Menu Shell Commands"));
889 }
890
891 int ShBtnPrefs::handle_event()
892 {
893         return iface_prefs->start_shbtn_dialog();
894 }
895
896
897 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
898  : BC_CheckBox(x, y, value, _("Import images with a duration of"))
899 {
900         this->pwindow = pwindow;
901 }
902
903 int StillImageUseDuration::handle_event()
904 {
905         pwindow->thread->edl->session->si_useduration = get_value();
906         return 1;
907 }
908
909 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
910  : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
911 {
912         this->pwindow = pwindow;
913 }
914 int StillImageDuration::handle_event()
915 {
916         pwindow->thread->edl->session->si_duration = atof(get_text());
917         return 1;
918 }
919
920
921 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
922  : BC_MenuItem(popup->hairline_to_string(hairline))
923 {
924         this->popup = popup;
925         this->hairline = hairline;
926 }
927
928 HairlineItem::~HairlineItem()
929 {
930 }
931
932 int HairlineItem::handle_event()
933 {
934         popup->set_text(get_text());
935         *(popup->output) = hairline;
936         return 1;
937 }
938
939
940 KeyframeReticle::KeyframeReticle(int x, int y, int *output)
941  : BC_PopupMenu(x, y, 175, hairline_to_string(*output))
942 {
943         this->output = output;
944 }
945
946 KeyframeReticle::~KeyframeReticle()
947 {
948 }
949
950 const char *KeyframeReticle::hairline_to_string(int type)
951 {
952         switch( type ) {
953         case HAIRLINE_NEVER:    return _("Never");
954         case HAIRLINE_DRAGGING: return _("Dragging");
955         case HAIRLINE_ALWAYS:   return _("Always");
956         }
957         return _("Unknown");
958 }
959
960 void KeyframeReticle::create_objects()
961 {
962         add_item(new HairlineItem(this, HAIRLINE_NEVER));
963         add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
964         add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
965 }
966