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)
81 SWindowLoadPath::~SWindowLoadPath()
85 int SWindowLoadPath::handle_event()
87 calculate_suggestions();
88 strcpy(sw_gui->script_path, get_text());
93 SWindowLoadFile::SWindowLoadFile(SWindowGUI *gui, int x, int y)
94 : BC_GenericButton(x, y, _("Load"))
99 SWindowLoadFile::~SWindowLoadFile()
103 int SWindowLoadFile::handle_event()
105 if( sw_gui->script_path[0] ) {
106 sw_gui->load_path->set_suggestions(0,0);
107 sw_gui->load_script();
108 sw_gui->set_script_pos(0);
111 eprintf(_("script text file path required"));
116 SWindowSaveFile::SWindowSaveFile(SWindowGUI *gui, int x, int y)
117 : BC_GenericButton(x, y, _("Save"))
122 SWindowSaveFile::~SWindowSaveFile()
126 int SWindowSaveFile::handle_event()
128 if( sw_gui->script_path[0] ) {
129 sw_gui->save_spumux_data();
132 eprintf(_("script microdvd file path required"));
140 void SWindowGUI::create_objects()
142 lock_window("SWindowGUI::create_objects");
144 BC_Title *title = new BC_Title(x, y, _("Path:"));
145 add_subwindow(title);
146 int x1 = x + title->get_w() + pad, y1 = y;
147 load_path = new SWindowLoadPath(this, x1, y1, script_path);
148 add_subwindow(load_path);
149 x1 += load_path->get_w() + 2*pad;
150 add_subwindow(load_file = new SWindowLoadFile(this, x1, y1));
151 x1 += load_file->get_w() + 2*pad;
152 add_subwindow(save_file = new SWindowSaveFile(this, x1, y1));
153 y += max(load_path->get_h(), load_file->get_h()) + pad;
154 x1 = x + pad, y1 = y;
155 BC_Title *title1, *title2;
156 add_subwindow(title1 = new BC_Title(x1, y1, _("File Size:")));
157 y += title1->get_h() + pad;
159 add_subwindow(title2 = new BC_Title(x1, y2, _("Entries:")));
160 int x2 = x1 + max(title1->get_w(), title2->get_w()) + pad;
161 add_subwindow(script_filesz = new BC_Title(x2, y1, "0", MEDIUMFONT, YELLOW));
162 add_subwindow(script_entries = new BC_Title(x2, y2, "0", MEDIUMFONT, YELLOW));
163 int x3 = x2 + max(script_entries->get_w()*8, script_filesz->get_w()*8) + pad;
164 add_subwindow(title1 = new BC_Title(x3, y1, _("Lines:")));
165 add_subwindow(title2 = new BC_Title(x3, y2, _("Texts:")));
166 int x4 = x3 + max(title1->get_w(), title2->get_w()) + pad;
167 add_subwindow(script_lines = new BC_Title(x4, y1, "0", MEDIUMFONT, YELLOW));
168 add_subwindow(script_texts = new BC_Title(x4, y2, "0", MEDIUMFONT, YELLOW));
169 int x5 = x4 + max(script_lines->get_w()*8, script_texts->get_w()*8) + 2*pad;
170 add_subwindow(prev_script = new ScriptPrev(this, x5, y1));
171 add_subwindow(next_script = new ScriptNext(this, x5, y2));
172 int x6 = x5 + max(prev_script->get_w(), next_script->get_w()) + 2*pad;
173 add_subwindow(paste_script = new ScriptPaste(this, x6, y1));
174 add_subwindow(clear_script = new ScriptClear(this, x6, y2));
175 y += max(title1->get_h(), title2->get_h()) + 2*pad;
177 script_position = new ScriptPosition(this, x, y, 100);
178 script_position->create_objects();
179 x1 = x + script_position->get_w() + pad;
180 add_subwindow(script_scroll = new ScriptScroll(this, x1, y, get_w()-x1-pad));
181 y += script_scroll->get_h() + 2*pad;
183 blank_line = new char[2];
184 blank_line[0] = ' '; blank_line[1] = 0;
185 add_subwindow(script_title = new BC_Title(x1, y, _("Script Text:")));
186 y += script_title->get_h() + pad;
187 int rows = (ok_y - y - BC_Title::calculate_h(this,_("Line Text:")) -
188 4*pad) / text_rowsz - 4;
189 int w1 = get_w() - x1 - pad;
190 script_entry = new ScriptEntry(this, x1, y, w1, rows, blank_line);
191 script_entry->create_objects();
192 y += script_entry->get_h() + pad;
193 add_subwindow(line_title = new BC_Title(x1, y, _("Line Text:")));
194 y += line_title->get_h() + pad;
195 line_entry = new ScriptEntry(this, x1, y, w1, 4);
196 line_entry->create_objects();
197 ok = new SWindowOK(this, ok_x, ok_y);
199 cancel = new SWindowCancel(this, cancel_x, cancel_y);
200 add_subwindow(cancel);
204 void SWindowGUI::load()
206 const char *script_text =
207 _("Adding Subtitles: quick \"How To\" (= or * indicates comment)\n"
208 "*2345678901234567890123456789012345678901234567890123456789\n"
209 "For regular DVD subtitles, put script in a text file. "
210 "Lines can be any length but they will be broken up "
211 "to fit according to some criteria below.\n"
212 "Running text used as script lines will be broken into multilple lines.\n"
213 "The target line length is 60 characters.\n"
214 "Punctuation may be flagged to create an early line break.\n"
215 "Single carriage return ends an individual script line.\n"
216 "Double carriage return indicates the end of an entry.\n"
217 "Whitespace at beginning or end of line is removed.\n"
218 "You can edit the active line in the Line Text box.\n"
220 "== A new entry is here for illustration purposes.\n"
222 "This is the second entry.\n");
224 if( script_path[0] && !access(script_path,R_OK) ) {
229 load_path->update(script_path);
230 FILE *fp = fmemopen((void *)script_text, strlen(script_text), "r");
233 int text_no = script_text_no;
235 load_selection(script_entry_no, text_no);
238 SWindowGUI::SWindowGUI(SWindow *swindow, int x, int y, int w, int h)
239 : BC_Window(_(PROGRAM_NAME ": Subtitle"), x, y, w, h, 600, 500,
240 1, 0, 0 , -1, swindow->mwindow->get_cwindow_display())
242 this->swindow = swindow;
246 ok_w = BC_OKButton::calculate_w();
247 ok_h = BC_OKButton::calculate_h();
249 ok_y = h - ok_h - 10;
251 cancel_w = BC_CancelButton::calculate_w();
252 cancel_h = BC_CancelButton::calculate_h();
253 cancel_x = w - cancel_w - 10,
254 cancel_y = h - cancel_h - 10;
266 script_text_lines = 0;
276 text_font = MEDIUMFONT;
277 text_rowsz = get_text_ascent(text_font)+1 + get_text_descent(text_font)+1;
280 SWindowGUI::~SWindowGUI()
284 delete script_position;
285 delete [] blank_line;
288 void SWindowGUI::stop(int v)
290 if( !swindow->gui_done ) {
291 swindow->gui_done = 1;
296 int SWindowGUI::translation_event()
298 swindow->mwindow->session->swindow_x = get_x();
299 swindow->mwindow->session->swindow_y = get_y();
303 int SWindowGUI::resize_event(int w, int h)
305 swindow->mwindow->session->swindow_w = w;
306 swindow->mwindow->session->swindow_h = h;
309 ok_y = h - ok_h - 10;
310 ok->reposition_window(ok_x, ok_y);
311 cancel_x = w - cancel_w - 10,
312 cancel_y = h - cancel_h - 10;
313 cancel->reposition_window(cancel_x, cancel_y);
315 int x = script_position->get_x();
316 int y = script_position->get_y();
317 int hh = script_position->get_h();
318 int ww = script_position->get_w();
319 int x1 = x + ww + pad;
320 int w1 = w - x1 - pad;
321 script_scroll->reposition_window(x1, y, w1);
323 script_title->reposition_window(x, y);
324 y += script_title->get_h() + pad;
326 int rows = (ok_y - y - line_title->get_h() - 4*pad) / text_rowsz - 4;
327 script_entry->reposition_window(x, y, w1, rows);
328 y += script_entry->get_h() + 2*pad;
329 line_title->reposition_window(x, y);
330 y += line_title->get_h() + pad;
331 line_entry->reposition_window(x, y, w1, 4);
335 void SWindowGUI::load_defaults()
337 BC_Hash *defaults = swindow->mwindow->defaults;
338 defaults->get("SUBTTL_SCRIPT_PATH", script_path);
339 script_entry_no = defaults->get("SUBTTL_SCRIPT_ENTRY_NO", script_entry_no);
340 script_text_no = defaults->get("SUBTTL_SCRIPT_TEXT_NO", script_text_no);
343 void SWindowGUI::save_defaults()
345 BC_Hash *defaults = swindow->mwindow->defaults;
346 defaults->update("SUBTTL_SCRIPT_PATH", script_path);
347 defaults->update("SUBTTL_SCRIPT_ENTRY_NO", script_entry_no);
348 defaults->update("SUBTTL_SCRIPT_TEXT_NO", script_text_no);
351 void SWindowGUI::set_script_pos(int64_t entry_no, int text_no)
353 script_entry_no = entry_no<0 ? 0 :
354 entry_no>script.size()-1 ? script.size()-1 : entry_no;
355 script_text_no = text_no-1;
356 load_next_selection();
359 int SWindowGUI::load_selection(int pos, int row)
361 if( pos < 0 || pos >= script.size() ) return 1;
362 ScriptLines *texts = script[pos];
363 char *rp = texts->get_text_row(row);
364 if( !rp || *rp == '=' || *rp == '*' || *rp=='\n' ) return 1;
365 if( pos != script_entry_no || script_text_no < 0 ) {
366 script_entry_no = pos;
367 script_scroll->update_value(script_entry_no);
368 script_position->update(script_entry_no);
369 script_entry->set_text(texts->text);
370 script_entry->set_text_row(0);
372 script_text_no = row;
373 char line[BCTEXTLEN], *bp = line;
374 char *ep = bp+sizeof(line)-1, *cp = rp;
375 while( bp < ep && *cp && *cp!='\n' ) *bp++ = *cp++;
376 *bp = 0; bp = texts->text;
377 int char1 = rp-bp, char2 = cp-bp;
378 script_entry->set_selection(char1, char2, char2);
379 int rows = script_entry->get_rows();
380 int rows2 = rows / 2;
381 int rows1 = texts->lines+1 - rows;
382 if( (row-=rows2) > rows1 ) row = rows1;
383 if( row < 0 ) row = 0;
384 script_entry->set_text_row(row);
385 line_entry->update(line);
386 line_entry->set_text_row(0);
390 int SWindowGUI::load_prev_selection()
392 int pos = script_entry_no, row = script_text_no;
393 if( pos < 0 || pos >= script.size() ) return 1;
396 if( --pos < 0 ) break;
397 row = script[pos]->lines;
400 if( !load_selection(pos, row) )
406 int SWindowGUI::load_next_selection()
408 int pos = script_entry_no, row = script_text_no;
409 if( pos < 0 || pos >= script.size() ) return 1;
411 if( ++row >= script[pos]->lines ) {
412 if( ++pos >= script.size() ) break;
416 if( !load_selection(pos, row) )
422 int SWindowGUI::update_selection()
424 EDL *edl = swindow->mwindow->edl;
425 LocalSession *lsn = edl->local_session;
426 double position = lsn->get_selectionstart();
428 Tracks *tracks = edl->tracks;
429 for( Track *track=tracks->first; track && !edit; track=track->next ) {
430 if( !track->record ) continue;
431 if( track->data_type != TRACK_SUBTITLE ) continue;
432 int64_t pos = track->to_units(position,0);
433 edit = track->edits->editof(pos, PLAY_FORWARD, 0);
435 if( !edit ) return 1;
436 SEdit *sedit = (SEdit *)edit;
437 line_entry->update(sedit->get_text());
438 line_entry->set_text_row(0);
442 int MWindow::paste_subtitle_text(char *text, double start, double end)
444 gui->lock_window("MWindow::paste_subtitle_text 1");
445 undo->update_undo_before();
447 Tracks *tracks = edl->tracks;
448 for( Track *track=tracks->first; track; track=track->next ) {
449 if( track->data_type != TRACK_SUBTITLE ) continue;
450 if( !track->record ) continue;
451 int64_t start_i = track->to_units(start, 0);
452 int64_t end_i = track->to_units(end, 1);
453 track->edits->clear(start_i,end_i);
454 SEdit *sedit = (SEdit *)track->edits->create_silence(start_i,end_i);
455 strcpy(sedit->get_text(),text);
456 track->edits->optimize();
460 undo->update_undo_after(_("paste subttl"), LOAD_EDITS | LOAD_PATCHES);
462 sync_parameters(CHANGE_EDL);
464 gui->update(0, NORMAL_DRAW, 1, 0, 0, 0, 0);
465 gui->unlock_window();
470 int SWindowGUI::paste_text(const char *text, double start, double end)
472 char stext[BCTEXTLEN], *cp = stext;
473 if( text ) { // remap charset, reformat if needed
474 for( const char *bp=text; *bp!=0; ++bp,++cp ) {
476 case '\n': *cp = '|'; break;
477 default: *cp = *bp; break;
481 if( cp > stext && *(cp-1) == '|' ) --cp;
483 return swindow->mwindow->paste_subtitle_text(stext, start, end);
486 int SWindowGUI::paste_selection()
488 EDL *edl = swindow->mwindow->edl;
489 LocalSession *lsn = edl->local_session;
490 double start = lsn->get_selectionstart();
491 double end = lsn->get_selectionend();
492 if( start >= end ) return 1;
493 if( lsn->inpoint_valid() && lsn->outpoint_valid() ) {
494 lsn->set_inpoint(lsn->get_outpoint());
495 lsn->unset_outpoint();
497 paste_text(line_entry->get_text(), start, end);
498 load_next_selection();
502 int SWindowGUI::clear_selection()
504 EDL *edl = swindow->mwindow->edl;
505 double start = edl->local_session->get_selectionstart();
506 double end = edl->local_session->get_selectionend();
508 paste_text(0, start, end);
513 ScriptPrev::ScriptPrev(SWindowGUI *gui, int x, int y)
514 : BC_GenericButton(x, y, _("Prev"))
519 ScriptPrev::~ScriptPrev()
523 int ScriptPrev::handle_event()
525 sw_gui->load_prev_selection();
529 ScriptNext::ScriptNext(SWindowGUI *gui, int x, int y)
530 : BC_GenericButton(x, y, _("Next"))
535 ScriptNext::~ScriptNext()
539 int ScriptNext::handle_event()
541 sw_gui->load_next_selection();
545 ScriptPaste::ScriptPaste(SWindowGUI *gui, int x, int y)
546 : BC_GenericButton(x, y, _("Paste"))
551 ScriptPaste::~ScriptPaste()
555 int ScriptPaste::handle_event()
557 sw_gui->paste_selection();
561 ScriptClear::ScriptClear(SWindowGUI *gui, int x, int y)
562 : BC_GenericButton(x, y, _("Clear"))
567 ScriptClear::~ScriptClear()
571 int ScriptClear::handle_event()
573 sw_gui->clear_selection();
578 ScriptLines::ScriptLines()
582 text = new char[allocated = 256];
586 ScriptLines::~ScriptLines()
591 void ScriptLines::append(char *cp)
593 int len = strlen(cp);
594 if( allocated-used < len+1 ) {
595 int isz = allocated + used + len;
596 char *new_text = new char[isz];
598 memcpy(new_text, text, used);
599 delete [] text; text = new_text;
601 memcpy(text+used, cp, len);
602 text[used += len] = 0;
606 int ScriptLines::break_lines()
609 int limit2 = line_limit/2;
610 int limit4 = line_limit/4-2;
611 char *cp = text, *dp = cp+used;
612 int n; char *bp, *ep, *pp, *sp;
613 for( lines=0; cp<dp; ++lines ) {
614 // find end of line/buffer
615 for( ep=cp; ep<dp && *ep!='\n'; ++ep );
616 // delete trailing spaces
617 for( sp=ep; sp>=cp && (!*sp || isspace(*sp)); --sp);
619 if( (n=ep-sp) > 0 ) {
620 memmove(sp,ep,dp+1-ep);
621 used -= n; dp -= n; ep -= n;
624 // skip, if comment or title line
625 if( *cp == '*' || *cp == '=' ) {
628 // delete leading spaces
629 for( sp=cp; sp<ep && isspace(*sp); ++sp);
630 if( (n=sp-cp) > 0 ) {
631 memmove(cp,sp,dp+1-sp);
632 used -= n; dp -= n; ep -= n;
634 // target about half remaining line, constrain line_limit
635 if( (n=(ep-1-cp)/2) < limit2 || n > line_limit )
637 // search for last punct, last space before line_limit
638 for( bp=cp, pp=sp=0; --n>=0 && cp<ep; ++cp ) {
639 if( ispunct(*cp) && isspace(*(cp+1)) ) pp = cp;
640 else if( isspace(*cp) ) sp = cp;
644 // first, after punctuation
645 if( pp && pp-bp >= limit4 )
651 // last, on next space
653 while( cp<dp && !isspace(*cp) ) ++cp;
663 int ScriptLines::get_text_rows()
666 for( char *cp=text; --i>=0; ++cp )
667 if( *cp == '\n' ) ++ret;
671 char *ScriptLines::get_text_row(int n)
675 for( int i=used; --i>=0; ) {
676 if( *cp++ != '\n' ) continue;
677 if( --n <= 0 ) return cp;
682 ScriptScroll::ScriptScroll(SWindowGUI *gui, int x, int y, int w)
683 : BC_ScrollBar(x, y, SCROLL_HORIZ + SCROLL_STRETCH, w, 0, 0, 0)
688 ScriptScroll::~ScriptScroll()
692 int ScriptScroll::handle_event()
694 int64_t pos = get_value();
695 sw_gui->set_script_pos(pos);
696 sw_gui->script_position->update(pos);
701 ScriptPosition::ScriptPosition(SWindowGUI *gui, int x, int y, int w, int v, int mn, int mx)
702 : BC_TumbleTextBox(gui, v, mn, mx, x, y, w-BC_Tumbler::calculate_w())
707 ScriptPosition::~ScriptPosition()
711 int ScriptPosition::handle_event()
713 int64_t pos = atol(get_text());
714 sw_gui->set_script_pos(pos);
715 sw_gui->script_scroll->update_value(pos);
720 ScriptEntry::ScriptEntry(SWindowGUI *gui, int x, int y, int w, int rows, char *text)
721 : BC_ScrollTextBox(gui, x, y, w, rows, text, -strlen(text))
727 ScriptEntry::ScriptEntry(SWindowGUI *gui, int x, int y, int w, int rows)
728 : BC_ScrollTextBox(gui, x, y, w, rows,(char*)0, BCTEXTLEN)
734 ScriptEntry::~ScriptEntry()
738 void ScriptEntry::set_text(char *text, int isz)
740 if( !text || !*text ) return;
741 if( isz < 0 ) isz = strlen(text)+1;
742 BC_ScrollTextBox::set_text(text, isz);
746 int ScriptEntry::handle_event()
748 if( ttext && sw_gui->get_button_down() &&
749 sw_gui->get_buttonpress() == 1 &&
750 sw_gui->get_triple_click() ) {
751 int ibeam = get_ibeam_letter(), row = 0;
752 const char *tp = ttext;
753 while( *tp && tp-ttext < ibeam ) {
754 if( *tp++ == '\n' ) ++row;
756 int pos = sw_gui->script_entry_no;
757 sw_gui->load_selection(pos, row);
762 int SWindowGUI::load_script_line(FILE *fp)
765 for(;;) { // skip blank lines
766 char *cp = fgets(line,sizeof(line),fp);
769 while( *cp && isspace(*cp) ) ++cp;
773 ScriptLines *entry = new ScriptLines();
774 script.append(entry);
776 for(;;) { // load non-blank lines
777 //int len = strlen(line);
778 //if( line[len-1] == '\n' ) line[len-1] = ' ';
780 char *cp = fgets(line,sizeof(line),fp);
783 while( *cp && isspace(*cp) ) ++cp;
786 script_text_lines += entry->break_lines();
790 void SWindowGUI::load_script()
792 FILE *fp = fopen(script_path,"r");
794 char string[BCTEXTLEN];
795 sprintf(string,_("cannot open: \"%s\"\n%s"),script_path,strerror(errno));
796 MainError::show_error(string);
801 load_selection(script_entry_no=0, 0);
804 void SWindowGUI::load_script(FILE *fp)
806 script.remove_all_objects();
808 script_text_lines = 0;
809 while( !load_script_line(fp) );
811 sprintf(value,"%ld",ftell(fp));
812 script_filesz->update(value);
813 sprintf(value,"%jd",script_line_no);
814 script_lines->update(value);
815 sprintf(value,"%d",script.size());
816 script_entries->update(value);
817 sprintf(value,"%jd",script_text_lines);
818 script_texts->update(value);
819 int hw = script_scroll->get_h();
820 script_scroll->update_length(script.size(), script_entry_no, hw, 0);
821 script_position->update(script_entry_no);
822 script_position->set_boundaries((int64_t)0, (int64_t)script.size()-1);
826 void SWindowGUI::save_spumux_data()
828 char filename[BCTEXTLEN], track_title[BCTEXTLEN];
829 snprintf(filename,sizeof(filename),"%s",script_path);
830 filename[sizeof(filename)-1] = 0;
831 char *bp = strrchr(filename,'/');
832 if( !bp ) bp = filename; else ++bp;
833 char *ext = strrchr(bp, '.');
834 if( !ext ) ext = bp + strlen(bp);
835 int len = sizeof(filename)-1 - (ext-filename);
837 Tracks *tracks = swindow->mwindow->edl->tracks;
838 for( Track *track=tracks->first; track; track=track->next ) {
839 if( track->data_type != TRACK_SUBTITLE ) continue;
840 if( !track->record ) continue;
841 char *cp = track_title, *ep = cp+sizeof(track_title)-6;
842 for( const char *bp=track->title; cp<ep && *bp!=0; ) {
843 int b = butf8(bp), c = !iswalnum(b) ? '_' : b;
847 snprintf(ext,len,"-%s.udvd",track_title);
848 FILE *fp = fopen(filename, "w");
850 eprintf(_("Unable to open %s:\n%m"), filename);
854 for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
855 SEdit *sedit = (SEdit *)edit;
856 if( sedit->length > 0 ) {
857 int64_t end = start + sedit->length;
858 char *text = sedit->get_text();
860 fprintf(fp, "{%jd}{%jd}%s\n", start, end-1, text);
871 SWindow::SWindow(MWindow *mwindow)
874 this->mwindow = mwindow;
875 window_lock = new Mutex("SWindow::window_lock");
876 swin_lock = new Condition(0,"SWindow::swin_lock");
893 void SWindow::start()
895 if( !Thread::running() ) {
903 if( Thread::running() ) {
906 window_lock->lock("SWindow::stop");
907 if( gui ) gui->stop(1);
908 window_lock->unlock();
916 int root_w = mwindow->gui->get_root_w(1);
917 int root_h = mwindow->gui->get_root_h(1);
923 int x = mwindow->session->swindow_x;
924 int y = mwindow->session->swindow_y;
925 int w = mwindow->session->swindow_w;
926 int h = mwindow->session->swindow_h;
927 if( w < 600 ) w = 600;
928 if( h < 500 ) h = 500;
929 int scr_x = mwindow->gui->get_screen_x(1, -1);
930 int scr_w = mwindow->gui->get_screen_w(1, -1);
931 if( x < scr_x ) x = scr_x;
932 if( x > scr_x+scr_w ) x = scr_x+scr_w;
933 if( x+w > root_w ) x = root_w - w;
934 if( x < 0 ) { x = 0; w = scr_w; }
935 if( y+h > root_h ) y = root_h - h;
936 if( y < 0 ) { y = 0; h = root_h; }
937 if( y+h > root_h ) h = root_h-y;
938 mwindow->session->swindow_x = x;
939 mwindow->session->swindow_y = y;
940 mwindow->session->swindow_w = w;
941 mwindow->session->swindow_h = h;
944 gui = new SWindowGUI(this, x, y, w, h);
945 gui->lock_window("ChannelInfo::gui_create_objects");
946 gui->load_defaults();
947 gui->create_objects();
948 gui->set_icon(mwindow->theme->get_image("record_icon"));
949 gui->reposition_window(x, y);
950 gui->resize_event(w, h);
953 gui->unlock_window();
955 int result = gui->run_window();
957 gui->save_spumux_data();
960 window_lock->lock("ChannelInfo::run 1");
961 gui->save_defaults();
963 window_lock->unlock();
970 void SWindow::run_swin()
972 window_lock->lock("SWindow::run_swin");
974 gui->lock_window("SWindow::run_swin");
976 gui->unlock_window();
980 window_lock->unlock();
983 void SWindow::paste_subttl()
985 window_lock->lock("SWindow::paste_subttl 1");
987 gui->lock_window("SWindow::paste_subttl 2");
988 gui->paste_selection();
989 gui->unlock_window();
991 window_lock->unlock();
994 int SWindow::update_selection()
996 window_lock->lock("SWindow::update_selection 1");
998 gui->lock_window("SWindow::update_selection 2");
999 gui->update_selection();
1000 gui->unlock_window();
1002 window_lock->unlock();
1008 SubttlSWin::SubttlSWin(MWindow *mwindow)
1009 : BC_MenuItem(_("SubTitle..."), _("Alt-y"), 'y')
1012 this->mwindow = mwindow;
1015 SubttlSWin::~SubttlSWin()
1019 int SubttlSWin::handle_event()
1021 mwindow->gui->swindow->run_swin();