4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "deleteallindexes.h"
24 #include "edlsession.h"
26 #include "filesystem.h"
29 #include "preferences.h"
30 #include "preferencesthread.h"
31 #include "probeprefs.h"
32 #include "interfaceprefs.h"
33 #include "shbtnprefs.h"
37 N_("Drag all following edits")
38 N_("Drag only one edit")
39 N_("Drag source only")
43 #define MOVE_ALL_EDITS_TITLE N_("Drag all following edits")
44 #define MOVE_ONE_EDIT_TITLE N_("Drag only one edit")
45 #define MOVE_NO_EDITS_TITLE N_("Drag source only")
46 #define MOVE_EDITS_DISABLED_TITLE N_("No effect")
48 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
49 : PreferencesDialog(mwindow, pwindow)
54 file_probe_dialog = 0;
57 InterfacePrefs::~InterfacePrefs()
62 delete file_probe_dialog;
66 void InterfacePrefs::create_objects()
68 BC_Resources *resources = BC_WindowBase::get_resources();
69 int margin = mwindow->theme->widget_border;
70 char string[BCTEXTLEN];
71 int x0 = mwindow->theme->preferencesoptions_x;
72 int y0 = mwindow->theme->preferencesoptions_y;
75 add_subwindow(new BC_Title(x, y, _("Editing:"), LARGEFONT,
76 resources->text_default));
79 int x2 = get_w()/2, y2 = y;
82 add_subwindow(title = new BC_Title(x, y, _("Keyframe reticle:")));
83 y += title->get_h() + 5;
84 keyframe_reticle = new KeyframeReticle(pwindow, this, x, y,
85 &pwindow->thread->preferences->keyframe_reticle);
86 add_subwindow(keyframe_reticle);
87 keyframe_reticle->create_objects();
90 add_subwindow(title = new BC_Title(x, y, _("Snapshot path:")));
91 y += title->get_h() + 5;
92 add_subwindow(snapshot_path = new SnapshotPathText(pwindow, this, x, y, get_w()-x-30));
95 add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
97 add_subwindow(new BC_Title(x, y, _("Button 1:")));
100 ViewBehaviourText *text;
101 add_subwindow(text = new ViewBehaviourText(x1, y - 5,
102 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
104 &(pwindow->thread->edl->session->edit_handle_mode[0])));
105 text->create_objects();
107 add_subwindow(new BC_Title(x, y, _("Button 2:")));
108 add_subwindow(text = new ViewBehaviourText(x1,
110 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
112 &(pwindow->thread->edl->session->edit_handle_mode[1])));
113 text->create_objects();
115 add_subwindow(new BC_Title(x, y, _("Button 3:")));
116 add_subwindow(text = new ViewBehaviourText(x1, y - 5,
117 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
119 &(pwindow->thread->edl->session->edit_handle_mode[2])));
120 text->create_objects();
121 y += text->get_h() + 30;
124 add_subwindow(new BC_Bar(5, y, get_w() - 10));
126 add_subwindow(new BC_Title(x, y, _("Operation:"), LARGEFONT,
127 resources->text_default));
132 AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y);
133 add_subwindow(android_remote);
134 y += android_remote->get_h() + 10;
135 add_subwindow(title = new BC_Title(x2, y, _("Port:")));
136 int x3 = x2 + title->get_w() + margin;
137 AndroidPort *android_port = new AndroidPort(pwindow, x3, y);
138 add_subwindow(android_port);
139 y += title->get_h() + 10;
140 add_subwindow(title = new BC_Title(x2, y, _("PIN:")));
141 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y);
142 add_subwindow(android_pin);
143 y += title->get_h() + 20;
145 ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y);
146 add_subwindow(shbtn_prefs);
147 y += shbtn_prefs->get_h() + 20;
149 add_subwindow(reload_plugins = new PrefsReloadPlugins(pwindow, this, x2, y));
150 y += reload_plugins->get_h() + 10;
152 add_subwindow(title = new BC_Title(x2, y, _("Default LV2_PATH:")));
153 y += title->get_h() + 10;
154 PrefsLV2PathText *lv2_path_text = new PrefsLV2PathText(pwindow, this, x2, y, get_w()-x2-30);
155 add_subwindow(lv2_path_text);
160 add_subwindow(file_probes = new PrefsFileProbes(pwindow, this, x, y));
163 PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x, y);
164 add_subwindow(trap_segv);
165 x1 = x + trap_segv->get_w() + 10;
166 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
169 PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x, y);
170 add_subwindow(trap_intr);
171 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
174 yuv420p_dvdlace = new PrefsYUV420P_DVDlace(pwindow, this, x, y);
175 add_subwindow(yuv420p_dvdlace);
178 add_subwindow(title = new BC_Title(x1=x, y + 5, _("Min DB for meter:")));
179 x1 += title->get_w() + 4;
180 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
181 add_subwindow(min_db = new MeterMinDB(pwindow, string, x1, y));
182 x1 += min_db->get_w() + 4;
183 add_subwindow(title = new BC_Title(x1, y + 5, _("Max:")));
184 x1 += title->get_w() + 4;
185 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
186 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x1, y));
189 StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
190 pwindow->thread->edl->session->si_useduration, x, y);
191 add_subwindow(use_stduration);
192 x1 = x + use_stduration->get_w() + 10;
193 StillImageDuration *stduration = new StillImageDuration(pwindow, x1, y);
194 add_subwindow(stduration);
195 x1 += stduration->get_w() + 10;
196 add_subwindow(new BC_Title(x1, y, _("Seconds")));
199 PrefsAutostartLV2UI *autostart_lv2ui = new PrefsAutostartLV2UI(x, y,pwindow);
200 add_subwindow(autostart_lv2ui);
201 y += autostart_lv2ui->get_h() + 10;
205 add_subwindow(new BC_Bar(5, y, get_w() - 10));
208 add_subwindow(new BC_Title(x, y, _("Index files:"), LARGEFONT, resources->text_default));
211 add_subwindow(new BC_Title(x, y + 5,
212 _("Index files go here:"), MEDIUMFONT, resources->text_default));
214 add_subwindow(ipathtext = new IndexPathText(x1, y, pwindow,
215 pwindow->thread->preferences->index_directory));
216 x1 += ipathtext->get_w();
217 add_subwindow(ipath = new BrowseButton(mwindow->theme, this, ipathtext, x1, y,
218 pwindow->thread->preferences->index_directory,
219 _("Index Path"), _("Select the directory for index files"), 1));
222 add_subwindow(new BC_Title(x, y + 5, _("Size of index file:"),
223 MEDIUMFONT, resources->text_default));
224 sprintf(string, "%jd", pwindow->thread->preferences->index_size);
225 add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
226 add_subwindow(new ScanCommercials(pwindow, 400,y));
229 add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"),
230 MEDIUMFONT, resources->text_default));
231 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
232 add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
233 add_subwindow(del_indexes = new DeleteAllIndexes(mwindow, pwindow, 400, y,
234 _("Delete existing indexes"), "[*.idx][*.toc][*.mkr]"));
236 add_subwindow(ffmpeg_marker_files = new IndexFFMPEGMarkerFiles(this, x, y));
237 add_subwindow(del_clipngs = new DeleteAllIndexes(mwindow, pwindow, 400, y,
238 _("Delete clip thumbnails"), "clip_*.png"));
241 const char* InterfacePrefs::behavior_to_text(int mode)
244 case MOVE_ALL_EDITS: return _(MOVE_ALL_EDITS_TITLE);
245 case MOVE_ONE_EDIT: return _(MOVE_ONE_EDIT_TITLE);
246 case MOVE_NO_EDITS: return _(MOVE_NO_EDITS_TITLE);
247 case MOVE_EDITS_DISABLED: return _(MOVE_EDITS_DISABLED_TITLE);
252 IndexPathText::IndexPathText(int x, int y, PreferencesWindow *pwindow, char *text)
253 : BC_TextBox(x, y, 240, 1, text)
255 this->pwindow = pwindow;
258 IndexPathText::~IndexPathText() {}
260 int IndexPathText::handle_event()
262 strcpy(pwindow->thread->preferences->index_directory, get_text());
269 IndexSize::IndexSize(int x, int y, PreferencesWindow *pwindow, char *text)
270 : BC_TextBox(x, y, 100, 1, text)
272 this->pwindow = pwindow;
275 int IndexSize::handle_event()
279 result = atol(get_text());
280 if(result < 64000) result = 64000;
281 //if(result < 500000) result = 500000;
282 pwindow->thread->preferences->index_size = result;
288 IndexCount::IndexCount(int x, int y, PreferencesWindow *pwindow, char *text)
289 : BC_TextBox(x, y, 100, 1, text)
291 this->pwindow = pwindow;
294 int IndexCount::handle_event()
298 result = atol(get_text());
299 if(result < 1) result = 1;
300 pwindow->thread->preferences->index_count = result;
306 IndexFFMPEGMarkerFiles::IndexFFMPEGMarkerFiles(InterfacePrefs *iface_prefs, int x, int y)
308 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
309 _("build ffmpeg marker indexes"))
311 this->iface_prefs = iface_prefs;
313 IndexFFMPEGMarkerFiles::~IndexFFMPEGMarkerFiles()
317 int IndexFFMPEGMarkerFiles::handle_event()
319 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
324 ViewBehaviourText::ViewBehaviourText(int x, int y, const char *text, PreferencesWindow *pwindow,
326 : BC_PopupMenu(x, y, 200, text)
328 this->output = output;
331 ViewBehaviourText::~ViewBehaviourText()
335 int ViewBehaviourText::handle_event()
340 void ViewBehaviourText::create_objects()
342 add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
343 add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
344 add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
345 add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
349 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
353 this->behaviour = behaviour;
356 ViewBehaviourItem::~ViewBehaviourItem()
360 int ViewBehaviourItem::handle_event()
362 popup->set_text(get_text());
363 *(popup->output) = behaviour;
368 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
369 : BC_TextBox(x, y, 50, 1, text)
371 this->pwindow = pwindow;
374 int MeterMinDB::handle_event()
376 pwindow->thread->redraw_meters = 1;
377 pwindow->thread->edl->session->min_meter_db = atol(get_text());
382 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
383 : BC_TextBox(x, y, 50, 1, text)
385 this->pwindow = pwindow;
388 int MeterMaxDB::handle_event()
390 pwindow->thread->redraw_meters = 1;
391 pwindow->thread->edl->session->max_meter_db = atol(get_text());
396 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
399 pwindow->thread->preferences->scan_commercials,
400 _("Scan for commercials during toc build"))
402 this->pwindow = pwindow;
404 int ScanCommercials::handle_event()
406 pwindow->thread->preferences->scan_commercials = get_value();
411 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
413 pwindow->thread->preferences->android_remote,
414 _("Android Remote Control"))
416 this->pwindow = pwindow;
418 int AndroidRemote::handle_event()
420 pwindow->thread->preferences->android_remote = get_value();
424 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
425 : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
427 this->pwindow = pwindow;
430 int AndroidPIN::handle_event()
432 char *txt = pwindow->thread->preferences->android_pin;
433 int len = sizeof(pwindow->thread->preferences->android_pin);
434 strncpy(txt, get_text(), len);
439 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
440 : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
442 this->pwindow = pwindow;
445 int AndroidPort::handle_event()
447 unsigned short port = atoi(get_text());
448 if( port < 1024 ) port = 1024;
449 pwindow->thread->preferences->android_port = port;
451 sprintf(str,"%u",port);
456 int InterfacePrefs::start_shbtn_dialog()
459 shbtn_dialog = new ShBtnEditDialog(pwindow);
460 shbtn_dialog->start();
464 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
465 : BC_GenericButton(x, y, _("Shell Commands"))
467 this->pwindow = pwindow;
468 this->iface_prefs = iface_prefs;
469 set_tooltip(_("Main Menu Shell Commands"));
472 int ShBtnPrefs::handle_event()
474 return iface_prefs->start_shbtn_dialog();
478 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
479 : BC_CheckBox(x, y, value, _("Import images with a duration of"))
481 this->pwindow = pwindow;
484 int StillImageUseDuration::handle_event()
486 pwindow->thread->edl->session->si_useduration = get_value();
490 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
491 : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
493 this->pwindow = pwindow;
495 int StillImageDuration::handle_event()
497 pwindow->thread->edl->session->si_duration = atof(get_text());
502 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
503 : BC_MenuItem(popup->hairline_to_string(hairline))
506 this->hairline = hairline;
509 HairlineItem::~HairlineItem()
513 int HairlineItem::handle_event()
515 popup->pwindow->thread->redraw_overlays = 1;
516 popup->set_text(get_text());
517 *(popup->output) = hairline;
522 KeyframeReticle::KeyframeReticle(PreferencesWindow *pwindow,
523 InterfacePrefs *iface_prefs, int x, int y, int *output)
524 : BC_PopupMenu(x, y, 220, hairline_to_string(*output))
526 this->pwindow = pwindow;
527 this->iface_prefs = iface_prefs;
528 this->output = output;
531 KeyframeReticle::~KeyframeReticle()
535 const char *KeyframeReticle::hairline_to_string(int type)
538 case HAIRLINE_NEVER: return _("Never");
539 case HAIRLINE_DRAGGING: return _("Dragging");
540 case HAIRLINE_ALWAYS: return _("Always");
545 void KeyframeReticle::create_objects()
547 add_item(new HairlineItem(this, HAIRLINE_NEVER));
548 add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
549 add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
552 PrefsTrapSigSEGV::PrefsTrapSigSEGV(InterfacePrefs *subwindow, int x, int y)
554 subwindow->pwindow->thread->preferences->trap_sigsegv,
557 this->subwindow = subwindow;
559 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
562 int PrefsTrapSigSEGV::handle_event()
564 subwindow->pwindow->thread->preferences->trap_sigsegv = get_value();
568 PrefsTrapSigINTR::PrefsTrapSigINTR(InterfacePrefs *subwindow, int x, int y)
570 subwindow->pwindow->thread->preferences->trap_sigintr,
573 this->subwindow = subwindow;
575 PrefsTrapSigINTR::~PrefsTrapSigINTR()
578 int PrefsTrapSigINTR::handle_event()
580 subwindow->pwindow->thread->preferences->trap_sigintr = get_value();
585 void InterfacePrefs::start_probe_dialog()
587 if( !file_probe_dialog )
588 file_probe_dialog = new FileProbeDialog(pwindow);
589 file_probe_dialog->start();
592 PrefsFileProbes::PrefsFileProbes(PreferencesWindow *pwindow,
593 InterfacePrefs *subwindow, int x, int y)
594 : BC_GenericButton(x, y, _("Probe Order"))
596 this->pwindow = pwindow;
597 this->subwindow = subwindow;
598 set_tooltip(_("File Open Probe Ordering"));
601 int PrefsFileProbes::handle_event()
603 subwindow->start_probe_dialog();
608 PrefsYUV420P_DVDlace::PrefsYUV420P_DVDlace(PreferencesWindow *pwindow,
609 InterfacePrefs *subwindow, int x, int y)
610 : BC_CheckBox(x, y, pwindow->thread->preferences->dvd_yuv420p_interlace,
611 _("Use yuv420p dvd interlace format"))
613 this->pwindow = pwindow;
614 this->subwindow = subwindow;
617 int PrefsYUV420P_DVDlace::handle_event()
619 pwindow->thread->preferences->dvd_yuv420p_interlace = get_value();
624 SnapshotPathText::SnapshotPathText(PreferencesWindow *pwindow,
625 InterfacePrefs *subwindow, int x, int y, int w)
626 : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->snapshot_path)
628 this->pwindow = pwindow;
629 this->subwindow = subwindow;
632 SnapshotPathText::~SnapshotPathText()
636 int SnapshotPathText::handle_event()
638 strcpy(pwindow->thread->preferences->snapshot_path, get_text());
642 PrefsAutostartLV2UI::PrefsAutostartLV2UI(int x, int y, PreferencesWindow *pwindow)
644 pwindow->thread->preferences->autostart_lv2ui, _("Auto start lv2 gui"))
646 this->pwindow = pwindow;
648 int PrefsAutostartLV2UI::handle_event()
650 pwindow->thread->preferences->autostart_lv2ui = get_value();
654 PrefsReloadPlugins::PrefsReloadPlugins(PreferencesWindow *pwindow,
655 InterfacePrefs *iface_prefs, int x, int y)
656 : BC_GenericButton(x, y, _("Reload plugin index"))
658 this->pwindow = pwindow;
659 this->iface_prefs = iface_prefs;
662 int PrefsReloadPlugins::handle_event()
664 pwindow->thread->reload_plugins = 1;
665 text_color(get_resources()->button_highlighted);
670 PrefsLV2PathText::PrefsLV2PathText(PreferencesWindow *pwindow,
671 InterfacePrefs *subwindow, int x, int y, int w)
672 : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->lv2_path)
674 this->pwindow = pwindow;
675 this->subwindow = subwindow;
678 PrefsLV2PathText::~PrefsLV2PathText()
682 int PrefsLV2PathText::handle_event()
684 strcpy(pwindow->thread->preferences->lv2_path, get_text());