7 #include "filesystem.h"
9 #include "localsession.h"
10 #include "mainerror.h"
12 #include "mainsession.h"
15 #include "mwindowgui.h"
30 SWindowOK::SWindowOK(SWindowGUI *gui, int x, int y)
36 SWindowOK::~SWindowOK()
40 int SWindowOK::button_press_event()
42 if(get_buttonpress() == 1 && is_event_win() && cursor_inside()) {
49 int SWindowOK::keypress_event()
55 SWindowCancel::SWindowCancel(SWindowGUI *gui, int x, int y)
56 : BC_CancelButton(x, y)
61 SWindowCancel::~SWindowCancel()
65 int SWindowCancel::button_press_event()
67 if(get_buttonpress() == 1 && is_event_win() && cursor_inside()) {
75 SWindowLoadPath::SWindowLoadPath(SWindowGUI *gui, int x, int y, char *path)
76 : BC_TextBox(x, y, 200, 1, path)
80 file_entries = new ArrayList<BC_ListBoxItem*>;
81 FileSystem fs; char string[BCTEXTLEN];
82 // Load current directory
83 fs.update(getcwd(string, BCTEXTLEN));
84 int total_files = fs.total_files();
85 for(int i = 0; i < total_files; i++) {
86 const char *name = fs.get_entry(i)->get_name();
87 file_entries->append(new BC_ListBoxItem(name));
91 SWindowLoadPath::~SWindowLoadPath()
93 file_entries->remove_all_objects();
97 int SWindowLoadPath::handle_event()
99 calculate_suggestions(file_entries);
100 strcpy(sw_gui->script_path, get_text());
105 SWindowLoadFile::SWindowLoadFile(SWindowGUI *gui, int x, int y)
106 : BC_GenericButton(x, y, _("Load"))
111 SWindowLoadFile::~SWindowLoadFile()
115 int SWindowLoadFile::handle_event()
117 if( sw_gui->script_path[0] ) {
118 sw_gui->load_path->set_suggestions(0,0);
119 sw_gui->load_script();
120 sw_gui->set_script_pos(0);
123 eprintf(_("script text file path required"));
128 SWindowSaveFile::SWindowSaveFile(SWindowGUI *gui, int x, int y)
129 : BC_GenericButton(x, y, _("Save"))
134 SWindowSaveFile::~SWindowSaveFile()
138 int SWindowSaveFile::handle_event()
140 if( sw_gui->script_path[0] ) {
141 sw_gui->save_spumux_data();
144 eprintf(_("script microdvd file path required"));
152 void SWindowGUI::create_objects()
155 BC_Title *title = new BC_Title(x, y, _("Path:"));
156 add_subwindow(title);
157 int x1 = x + title->get_w() + pad, y1 = y;
158 load_path = new SWindowLoadPath(this, x1, y1, script_path);
159 add_subwindow(load_path);
160 x1 += load_path->get_w() + 2*pad;
161 add_subwindow(load_file = new SWindowLoadFile(this, x1, y1));
162 x1 += load_file->get_w() + 2*pad;
163 add_subwindow(save_file = new SWindowSaveFile(this, x1, y1));
164 y += max(load_path->get_h(), load_file->get_h()) + pad;
165 x1 = x + pad, y1 = y;
166 BC_Title *title1, *title2;
167 add_subwindow(title1 = new BC_Title(x1, y1, _("File Size:")));
168 y += title1->get_h() + pad;
170 add_subwindow(title2 = new BC_Title(x1, y2, _("Entries:")));
171 int x2 = x1 + max(title1->get_w(), title2->get_w()) + pad;
172 add_subwindow(script_filesz = new BC_Title(x2, y1, "0", MEDIUMFONT, YELLOW));
173 add_subwindow(script_entries = new BC_Title(x2, y2, "0", MEDIUMFONT, YELLOW));
174 int x3 = x2 + max(script_entries->get_w()*8, script_filesz->get_w()*8) + pad;
175 add_subwindow(title1 = new BC_Title(x3, y1, _("Lines:")));
176 add_subwindow(title2 = new BC_Title(x3, y2, _("Texts:")));
177 int x4 = x3 + max(title1->get_w(), title2->get_w()) + pad;
178 add_subwindow(script_lines = new BC_Title(x4, y1, "0", MEDIUMFONT, YELLOW));
179 add_subwindow(script_texts = new BC_Title(x4, y2, "0", MEDIUMFONT, YELLOW));
180 int x5 = x4 + max(script_lines->get_w()*8, script_texts->get_w()*8) + 2*pad;
181 add_subwindow(prev_script = new ScriptPrev(this, x5, y1));
182 add_subwindow(next_script = new ScriptNext(this, x5, y2));
183 int x6 = x5 + max(prev_script->get_w(), next_script->get_w()) + 2*pad;
184 add_subwindow(paste_script = new ScriptPaste(this, x6, y1));
185 add_subwindow(clear_script = new ScriptClear(this, x6, y2));
186 y += max(title1->get_h(), title2->get_h()) + 2*pad;
188 script_position = new ScriptPosition(this, x, y, 100);
189 script_position->create_objects();
190 x1 = x + script_position->get_w() + pad;
191 add_subwindow(script_scroll = new ScriptScroll(this, x1, y, get_w()-x1-pad));
192 y += script_scroll->get_h() + 2*pad;
194 blank_line = new char[2];
195 blank_line[0] = ' '; blank_line[1] = 0;
196 add_subwindow(script_title = new BC_Title(x1, y, _("Script Text:")));
197 y += script_title->get_h() + pad;
198 int rows = (ok_y - y - BC_Title::calculate_h(this,_("Line Text:")) -
199 4*pad) / text_rowsz - 3;
200 int w1 = get_w() - x1 - pad;
201 script_entry = new ScriptEntry(this, x1, y, w1, rows, blank_line);
202 script_entry->create_objects();
203 y += script_entry->get_h() + pad;
204 add_subwindow(line_title = new BC_Title(x1, y, _("Line Text:")));
205 y += line_title->get_h() + pad;
206 line_entry = new ScriptEntry(this, x1, y, w1, 3);
207 line_entry->create_objects();
208 ok = new SWindowOK(this, ok_x, ok_y);
210 cancel = new SWindowCancel(this, cancel_x, cancel_y);
211 add_subwindow(cancel);
214 void SWindowGUI::load()
216 const char *script_text =
217 _("Adding Subtitles: quick \"How To\" (= or * indicates comment)\n"
218 "*2345678901234567890123456789012345678901234567890123456789\n"
219 "For regular DVD subtitles, put script in a text file. "
220 "Lines can be any length but they will be broken up "
221 "to fit according to some criteria below.\n"
222 "Running text used as script lines will be broken into multilple lines.\n"
223 "The target line length is 60 characters.\n"
224 "Punctuation may be flagged to create an early line break.\n"
225 "Single carriage return ends an individual script line.\n"
226 "Double carriage return indicates the end of an entry.\n"
227 "Whitespace at beginning or end of line is removed.\n"
228 "You can edit the active line in the Line Text box.\n"
230 "== A new entry is here for illustration purposes.\n"
232 "This is the second entry.\n");
234 if( script_path[0] && !access(script_path,R_OK) ) {
239 load_path->update(script_path);
240 FILE *fp = fmemopen((void *)script_text, strlen(script_text), "r");
243 int text_no = script_text_no;
245 load_selection(script_entry_no, text_no);
248 SWindowGUI::SWindowGUI(SWindow *swindow, int x, int y, int w, int h)
249 : BC_Window(_(PROGRAM_NAME ": Subtitle"), x, y, w, h, 600, 500,
250 1, 0, 0 , -1, swindow->mwindow->get_cwindow_display())
252 this->swindow = swindow;
256 ok_w = BC_OKButton::calculate_w();
257 ok_h = BC_OKButton::calculate_h();
259 ok_y = h - ok_h - 10;
261 cancel_w = BC_CancelButton::calculate_w();
262 cancel_h = BC_CancelButton::calculate_h();
263 cancel_x = w - cancel_w - 10,
264 cancel_y = h - cancel_h - 10;
276 script_text_lines = 0;
286 text_font = MEDIUMFONT;
287 text_rowsz = get_text_ascent(text_font)+1 + get_text_descent(text_font)+1;
290 SWindowGUI::~SWindowGUI()
294 delete script_position;
295 delete [] blank_line;
298 void SWindowGUI::stop(int v)
300 if( !swindow->gui_done ) {
301 swindow->gui_done = 1;
306 int SWindowGUI::translation_event()
308 swindow->mwindow->session->swindow_x = get_x();
309 swindow->mwindow->session->swindow_y = get_y();
313 int SWindowGUI::resize_event(int w, int h)
315 swindow->mwindow->session->swindow_w = w;
316 swindow->mwindow->session->swindow_h = h;
319 ok_y = h - ok_h - 10;
320 ok->reposition_window(ok_x, ok_y);
321 cancel_x = w - cancel_w - 10,
322 cancel_y = h - cancel_h - 10;
323 cancel->reposition_window(cancel_x, cancel_y);
325 int x = script_position->get_x();
326 int y = script_position->get_y();
327 int hh = script_position->get_h();
328 int ww = script_position->get_w();
329 int x1 = x + ww + pad;
330 int w1 = w - x1 - pad;
331 script_scroll->reposition_window(x1, y, w1);
333 script_title->reposition_window(x, y);
334 y += script_title->get_h() + pad;
336 int rows = (ok_y - y - line_title->get_h() - 4*pad) / text_rowsz - 3;
337 script_entry->reposition_window(x, y, w1, rows);
338 y += script_entry->get_h() + 2*pad;
339 line_title->reposition_window(x, y);
340 y += line_title->get_h() + pad;
341 line_entry->reposition_window(x, y, w1, 3);
345 void SWindowGUI::load_defaults()
347 BC_Hash *defaults = swindow->mwindow->defaults;
348 defaults->get("SUBTTL_SCRIPT_PATH", script_path);
349 script_entry_no = defaults->get("SUBTTL_SCRIPT_ENTRY_NO", script_entry_no);
350 script_text_no = defaults->get("SUBTTL_SCRIPT_TEXT_NO", script_text_no);
353 void SWindowGUI::save_defaults()
355 BC_Hash *defaults = swindow->mwindow->defaults;
356 defaults->update("SUBTTL_SCRIPT_PATH", script_path);
357 defaults->update("SUBTTL_SCRIPT_ENTRY_NO", script_entry_no);
358 defaults->update("SUBTTL_SCRIPT_TEXT_NO", script_text_no);
361 void SWindowGUI::set_script_pos(int64_t entry_no, int text_no)
363 script_entry_no = entry_no<0 ? 0 :
364 entry_no>script.size()-1 ? script.size()-1 : entry_no;
365 script_text_no = text_no-1;
366 load_next_selection();
369 int SWindowGUI::load_selection(int pos, int row)
371 ScriptLines *texts = script[pos];
372 char *rp = texts->get_text_row(row);
373 if( !rp || *rp == '=' || *rp == '*' || *rp=='\n' ) return 1;
374 if( pos != script_entry_no || script_text_no < 0 ) {
375 script_entry_no = pos;
376 script_scroll->update_value(script_entry_no);
377 script_position->update(script_entry_no);
378 script_entry->set_text(texts->text);
379 script_entry->set_text_row(0);
381 script_text_no = row;
382 char line[BCTEXTLEN], *bp = line;
383 char *ep = bp+sizeof(line)-1, *cp = rp;
384 while( bp < ep && *cp && *cp!='\n' ) *bp++ = *cp++;
385 *bp = 0; bp = texts->text;
386 int char1 = rp-bp, char2 = cp-bp;
387 script_entry->set_selection(char1, char2, char2);
388 int rows = script_entry->get_rows();
389 int rows2 = rows / 2;
390 int rows1 = texts->lines+1 - rows;
391 if( (row-=rows2) > rows1 ) row = rows1;
392 if( row < 0 ) row = 0;
393 script_entry->set_text_row(row);
394 line_entry->update(line);
395 line_entry->set_text_row(0);
399 int SWindowGUI::load_prev_selection()
401 int pos = script_entry_no, row = script_text_no;
402 if( pos < 0 || pos >= script.size() ) return 1;
405 if( --pos < 0 ) break;
406 row = script[pos]->lines;
409 if( !load_selection(pos, row) )
415 int SWindowGUI::load_next_selection()
417 int pos = script_entry_no, row = script_text_no;
418 if( pos < 0 || pos >= script.size() ) return 1;
420 if( ++row >= script[pos]->lines ) {
421 if( ++pos >= script.size() ) break;
425 if( !load_selection(pos, row) )
431 int SWindowGUI::update_selection()
433 EDL *edl = swindow->mwindow->edl;
434 LocalSession *lsn = edl->local_session;
435 double position = lsn->get_selectionstart();
437 Tracks *tracks = edl->tracks;
438 for( Track *track=tracks->first; track && !edit; track=track->next ) {
439 if( !track->record ) continue;
440 if( track->data_type != TRACK_SUBTITLE ) continue;
441 int64_t pos = track->to_units(position,0);
442 edit = track->edits->editof(pos, PLAY_FORWARD, 0);
444 if( !edit ) return 1;
445 SEdit *sedit = (SEdit *)edit;
446 line_entry->update(sedit->get_text());
447 line_entry->set_text_row(0);
451 int MWindow::paste_subtitle_text(char *text, double start, double end)
453 gui->lock_window("MWindow::paste_subtitle_text 1");
454 undo->update_undo_before();
456 Tracks *tracks = edl->tracks;
457 for( Track *track=tracks->first; track; track=track->next ) {
458 if( track->data_type != TRACK_SUBTITLE ) continue;
459 if( !track->record ) continue;
460 int64_t start_i = track->to_units(start, 0);
461 int64_t end_i = track->to_units(end, 1);
462 track->edits->clear(start_i,end_i);
463 SEdit *sedit = (SEdit *)track->edits->create_silence(start_i,end_i);
464 strcpy(sedit->get_text(),text);
465 track->edits->optimize();
469 undo->update_undo_after(_("paste subttl"), LOAD_EDITS | LOAD_PATCHES);
471 sync_parameters(CHANGE_EDL);
473 gui->update(0, 1, 1, 0, 0, 0, 0);
474 gui->unlock_window();
479 int SWindowGUI::paste_text(const char *text, double start, double end)
481 char stext[BCTEXTLEN], *cp = stext;
482 if( text ) { // remap charset, reformat if needed
483 for( const char *bp=text; *bp!=0; ++bp,++cp ) {
485 case '\n': *cp = '|'; break;
486 default: *cp = *bp; break;
490 if( cp > stext && *(cp-1) == '|' ) --cp;
492 return swindow->mwindow->paste_subtitle_text(stext, start, end);
495 int SWindowGUI::paste_selection()
497 EDL *edl = swindow->mwindow->edl;
498 LocalSession *lsn = edl->local_session;
499 double start = lsn->get_selectionstart();
500 double end = lsn->get_selectionend();
501 if( start >= end ) return 1;
502 if( lsn->inpoint_valid() && lsn->outpoint_valid() ) {
503 lsn->set_inpoint(lsn->get_outpoint());
504 lsn->unset_outpoint();
506 paste_text(line_entry->get_text(), start, end);
507 load_next_selection();
511 int SWindowGUI::clear_selection()
513 EDL *edl = swindow->mwindow->edl;
514 double start = edl->local_session->get_selectionstart();
515 double end = edl->local_session->get_selectionend();
517 paste_text(0, start, end);
522 ScriptPrev::ScriptPrev(SWindowGUI *gui, int x, int y)
523 : BC_GenericButton(x, y, _("Prev"))
528 ScriptPrev::~ScriptPrev()
532 int ScriptPrev::handle_event()
534 sw_gui->load_prev_selection();
538 ScriptNext::ScriptNext(SWindowGUI *gui, int x, int y)
539 : BC_GenericButton(x, y, _("Next"))
544 ScriptNext::~ScriptNext()
548 int ScriptNext::handle_event()
550 sw_gui->load_next_selection();
554 ScriptPaste::ScriptPaste(SWindowGUI *gui, int x, int y)
555 : BC_GenericButton(x, y, _("Paste"))
560 ScriptPaste::~ScriptPaste()
564 int ScriptPaste::handle_event()
566 sw_gui->paste_selection();
570 ScriptClear::ScriptClear(SWindowGUI *gui, int x, int y)
571 : BC_GenericButton(x, y, _("Clear"))
576 ScriptClear::~ScriptClear()
580 int ScriptClear::handle_event()
582 sw_gui->clear_selection();
587 ScriptLines::ScriptLines()
591 text = new char[allocated = 256];
595 ScriptLines::~ScriptLines()
600 void ScriptLines::append(char *cp)
602 int len = strlen(cp);
603 if( allocated-used < len+1 ) {
604 int isz = allocated + used + len;
605 char *new_text = new char[isz];
607 memcpy(new_text, text, used);
608 delete [] text; text = new_text;
610 memcpy(text+used, cp, len);
611 text[used += len] = 0;
615 int ScriptLines::break_lines()
618 int limit2 = line_limit/2;
619 int limit4 = line_limit/4-2;
620 char *cp = text, *dp = cp+used;
621 int n; char *bp, *ep, *pp, *sp;
622 for( lines=0; cp<dp; ++lines ) {
623 // find end of line/buffer
624 for( ep=cp; ep<dp && *ep!='\n'; ++ep );
625 // delete trailing spaces
626 for( sp=ep; sp>=cp && (!*sp || isspace(*sp)); --sp);
628 if( (n=ep-sp) > 0 ) {
629 memmove(sp,ep,dp+1-ep);
630 used -= n; dp -= n; ep -= n;
633 // skip, if comment or title line
634 if( *cp == '*' || *cp == '=' ) {
637 // delete leading spaces
638 for( sp=cp; sp<ep && isspace(*sp); ++sp);
639 if( (n=sp-cp) > 0 ) {
640 memmove(cp,sp,dp+1-sp);
641 used -= n; dp -= n; ep -= n;
643 // target about half remaining line, constrain line_limit
644 if( (n=(ep-1-cp)/2) < limit2 || n > line_limit )
646 // search for last punct, last space before line_limit
647 for( bp=cp, pp=sp=0; --n>=0 && cp<ep; ++cp ) {
648 if( ispunct(*cp) && isspace(*(cp+1)) ) pp = cp;
649 else if( isspace(*cp) ) sp = cp;
653 // first, after punctuation
654 if( pp && pp-bp >= limit4 )
660 // last, on next space
662 while( cp<dp && !isspace(*cp) ) ++cp;
672 int ScriptLines::get_text_rows()
675 for( char *cp=text; --i>=0; ++cp )
676 if( *cp == '\n' ) ++ret;
680 char *ScriptLines::get_text_row(int n)
684 for( int i=used; --i>=0; ) {
685 if( *cp++ != '\n' ) continue;
686 if( --n <= 0 ) return cp;
691 ScriptScroll::ScriptScroll(SWindowGUI *gui, int x, int y, int w)
692 : BC_ScrollBar(x, y, SCROLL_HORIZ, w, 0, 0, 0)
697 ScriptScroll::~ScriptScroll()
701 int ScriptScroll::handle_event()
703 int64_t pos = get_value();
704 sw_gui->set_script_pos(pos);
705 sw_gui->script_position->update(pos);
710 ScriptPosition::ScriptPosition(SWindowGUI *gui, int x, int y, int w, int v, int mn, int mx)
711 : BC_TumbleTextBox(gui, v, mn, mx, x, y, w-BC_Tumbler::calculate_w())
716 ScriptPosition::~ScriptPosition()
720 int ScriptPosition::handle_event()
722 int64_t pos = atol(get_text());
723 sw_gui->set_script_pos(pos);
724 sw_gui->script_scroll->update_value(pos);
729 ScriptEntry::ScriptEntry(SWindowGUI *gui, int x, int y, int w, int rows, char *text)
730 : BC_ScrollTextBox(gui, x, y, w, rows, text, -strlen(text))
736 ScriptEntry::ScriptEntry(SWindowGUI *gui, int x, int y, int w, int rows)
737 : BC_ScrollTextBox(gui, x, y, w, rows,(char*)0, BCTEXTLEN)
743 ScriptEntry::~ScriptEntry()
747 void ScriptEntry::set_text(char *text, int isz)
749 if( !text || !*text ) return;
750 if( isz < 0 ) isz = strlen(text)+1;
751 BC_ScrollTextBox::set_text(text, isz);
755 int ScriptEntry::handle_event()
757 if( sw_gui->get_button_down() &&
758 sw_gui->get_buttonpress() == 1 &&
759 sw_gui->get_triple_click() ) {
760 int ibeam = get_ibeam_letter(), row = 0;
761 const char *tp = ttext;
762 while( *tp && tp-ttext < ibeam ) {
763 if( *tp++ == '\n' ) ++row;
765 int pos = sw_gui->script_entry_no;
766 sw_gui->load_selection(pos, row);
771 int SWindowGUI::load_script_line(FILE *fp)
774 for(;;) { // skip blank lines
775 char *cp = fgets(line,sizeof(line),fp);
778 while( *cp && isspace(*cp) ) ++cp;
782 ScriptLines *entry = new ScriptLines();
783 script.append(entry);
785 for(;;) { // load non-blank lines
786 //int len = strlen(line);
787 //if( line[len-1] == '\n' ) line[len-1] = ' ';
789 char *cp = fgets(line,sizeof(line),fp);
792 while( *cp && isspace(*cp) ) ++cp;
795 script_text_lines += entry->break_lines();
799 void SWindowGUI::load_script()
801 FILE *fp = fopen(script_path,"r");
803 char string[BCTEXTLEN];
804 sprintf(string,_("cannot open: \"%s\"\n%s"),script_path,strerror(errno));
805 MainError::show_error(string);
811 void SWindowGUI::load_script(FILE *fp)
813 script.remove_all_objects();
815 script_text_lines = 0;
816 while( !load_script_line(fp) );
818 sprintf(value,"%ld",ftell(fp));
819 script_filesz->update(value);
820 sprintf(value,"%jd",script_line_no);
821 script_lines->update(value);
822 sprintf(value,"%d",script.size());
823 script_entries->update(value);
824 sprintf(value,"%jd",script_text_lines);
825 script_texts->update(value);
826 int hw = 2*script_scroll->get_h();
827 script_scroll->update_length(script.size(), script_entry_no, hw, 0);
828 script_position->update(script_entry_no);
829 script_position->set_boundaries((int64_t)0, (int64_t)script.size()-1);
834 void SWindowGUI::save_spumux_data()
836 char filename[BCTEXTLEN], track_title[BCTEXTLEN];
837 snprintf(filename,sizeof(filename),"%s",script_path);
838 filename[sizeof(filename)-1] = 0;
839 char *bp = strrchr(filename,'/');
840 if( !bp ) bp = filename; else ++bp;
841 char *ext = strrchr(bp, '.');
842 if( !ext ) ext = bp + strlen(bp);
843 int len = sizeof(filename)-1 - (ext-filename);
845 Tracks *tracks = swindow->mwindow->edl->tracks;
846 for( Track *track=tracks->first; track; track=track->next ) {
847 if( track->data_type != TRACK_SUBTITLE ) continue;
848 if( !track->record ) continue;
849 char *cp = track_title;
850 for( char *bp=track->title; *bp; ++bp,++cp )
851 *cp = !isalnum(*bp) ? '_' : *bp;
853 snprintf(ext,len,"-%s.udvd",track_title);
854 FILE *fp = fopen(filename, "w");
856 eprintf(_("Unable to open %s:\n%m"), filename);
860 for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
861 SEdit *sedit = (SEdit *)edit;
862 if( sedit->length > 0 ) {
863 int64_t end = start + sedit->length;
864 char *text = sedit->get_text();
866 fprintf(fp, "{%jd}{%jd}%s\n", start, end-1, text);
877 SWindow::SWindow(MWindow *mwindow)
880 this->mwindow = mwindow;
881 window_lock = new Mutex("SWindow::window_lock");
882 swin_lock = new Condition(0,"SWindow::swin_lock");
899 void SWindow::start()
901 if( !Thread::running() ) {
909 if( Thread::running() ) {
912 window_lock->lock("SWindow::stop");
913 if( gui ) gui->stop(1);
914 window_lock->unlock();
922 int root_w = mwindow->gui->get_root_w(1);
923 int root_h = mwindow->gui->get_root_h(1);
929 int x = mwindow->session->swindow_x;
930 int y = mwindow->session->swindow_y;
931 int w = mwindow->session->swindow_w;
932 int h = mwindow->session->swindow_h;
933 if( w < 600 ) w = 600;
934 if( h < 500 ) h = 500;
935 int scr_x = mwindow->gui->get_screen_x(1, -1);
936 int scr_w = mwindow->gui->get_screen_w(1, -1);
937 if( x < scr_x ) x = scr_x;
938 if( x > scr_x+scr_w ) x = scr_x+scr_w;
939 if( x+w > root_w ) x = root_w - w;
940 if( x < 0 ) { x = 0; w = scr_w; }
941 if( y+h > root_h ) y = root_h - h;
942 if( y < 0 ) { y = 0; h = root_h; }
943 if( y+h > root_h ) h = root_h-y;
944 mwindow->session->swindow_x = x;
945 mwindow->session->swindow_y = y;
946 mwindow->session->swindow_w = w;
947 mwindow->session->swindow_h = h;
950 gui = new SWindowGUI(this, x, y, w, h);
951 gui->lock_window("ChannelInfo::gui_create_objects");
952 gui->load_defaults();
953 gui->create_objects();
954 gui->set_icon(mwindow->theme->get_image("record_icon"));
955 gui->reposition_window(x, y);
956 gui->resize_event(w, h);
959 gui->unlock_window();
961 int result = gui->run_window();
963 gui->save_spumux_data();
966 window_lock->lock("ChannelInfo::run 1");
967 gui->save_defaults();
969 window_lock->unlock();
976 void SWindow::run_swin()
978 window_lock->lock("SWindow::run_swin");
980 gui->lock_window("SWindow::run_swin");
982 gui->unlock_window();
986 window_lock->unlock();
989 void SWindow::paste_subttl()
991 window_lock->lock("SWindow::paste_subttl 1");
993 gui->lock_window("SWindow::paste_subttl 2");
994 gui->paste_selection();
995 gui->unlock_window();
997 window_lock->unlock();
1000 int SWindow::update_selection()
1002 window_lock->lock("SWindow::update_selection 1");
1004 gui->lock_window("SWindow::update_selection 2");
1005 gui->update_selection();
1006 gui->unlock_window();
1008 window_lock->unlock();
1014 SubttlSWin::SubttlSWin(MWindow *mwindow)
1015 : BC_MenuItem(_("SubTitle..."), _("Alt-y"), 'y')
1018 this->mwindow = mwindow;
1021 SubttlSWin::~SubttlSWin()
1025 int SubttlSWin::handle_event()
1027 mwindow->gui->swindow->run_swin();