6 #include "channelinfo.h"
11 #include "devicedvbinput.h"
13 #include "edlsession.h"
15 #include "mainerror.h"
17 #include "mainsession.h"
19 #include "mwindowgui.h"
21 #include "bcmenuitem.h"
23 #include "recordconfig.h"
25 #include "videodevice.h"
26 #include "videoconfig.h"
27 #include "videodevice.h"
28 #include "libzmpeg3.h"
32 static inline int min(int a,int b) { return a<b ? a : b; }
34 static inline int max(int a,int b) { return a>b ? a : b; }
37 ChanSearch::ChanSearch(ChannelInfo *iwindow)
40 this->iwindow = iwindow;
41 window_lock = new Mutex("ChanSearch::window_lock");
45 ChanSearch::~ChanSearch()
52 void ChanSearch::start()
54 window_lock->lock("ChanSearch::start1");
55 if( Thread::running() ) {
56 gui->lock_window("ChanSearch::start2");
62 gui = new ChanSearchGUI(this);
65 window_lock->unlock();
68 void ChanSearch::stop()
70 if( Thread::running() ) {
71 window_lock->lock("ChanSearch::stop");
72 if( gui ) gui->set_done(1);
73 window_lock->unlock();
79 void ChanSearch::run()
81 gui->lock_window("ChanSearch::run");
82 gui->create_objects();
85 window_lock->lock("ChanSearch::stop");
87 window_lock->unlock();
91 ChanSearchTitleText::ChanSearchTitleText(ChanSearchGUI *gui, int x, int y)
92 : BC_CheckBox(x, y, &gui->title_text_enable, _("titles"))
97 ChanSearchTitleText::~ChanSearchTitleText()
101 int ChanSearchTitleText::handle_event()
103 gui->title_text_enable = get_value();
104 if( !gui->title_text_enable ) gui->info_text->update(1);
109 ChanSearchInfoText::ChanSearchInfoText(ChanSearchGUI *gui, int x, int y)
110 : BC_CheckBox(x, y, &gui->info_text_enable, _("info"))
115 ChanSearchInfoText::~ChanSearchInfoText()
119 int ChanSearchInfoText::handle_event()
121 gui->info_text_enable = get_value();
122 if( !gui->info_text_enable ) gui->title_text->update(1);
127 ChanSearchMatchCase::ChanSearchMatchCase(ChanSearchGUI *gui, int x, int y)
128 : BC_CheckBox(x, y, &gui->match_case_enable, _("match case"))
133 ChanSearchMatchCase::~ChanSearchMatchCase()
137 int ChanSearchMatchCase::handle_event()
139 gui->match_case_enable = get_value();
144 ChanSearchText::ChanSearchText(ChanSearchGUI *gui, int x, int y, int w)
145 : BC_TextBox(x, y, w, 1, "")
150 ChanSearchText::~ChanSearchText()
155 int ChanSearchText::handle_event()
160 int ChanSearchText::keypress_event()
162 switch(get_keypress())
169 return BC_TextBox::keypress_event();
173 ChanSearchStart::ChanSearchStart(ChanSearchGUI *gui, int x, int y)
174 : BC_GenericButton(x, y, _("Search"))
179 ChanSearchStart::~ChanSearchStart()
183 int ChanSearchStart::handle_event()
190 ChanSearchCancel::ChanSearchCancel(ChanSearchGUI *gui, int x, int y)
191 : BC_CancelButton(x, y)
196 ChanSearchCancel::~ChanSearchCancel()
200 int ChanSearchCancel::handle_event()
207 ChanSearchList::ChanSearchList(ChanSearchGUI *gui, int x, int y, int w, int h)
208 : BC_ListBox(x, y, w, h, LISTBOX_TEXT, &gui->search_items[0],
209 &gui->search_column_titles[0], &gui->search_column_widths[0],
210 lengthof(gui->search_items))
213 set_sort_column(gui->sort_column);
214 set_sort_order(gui->sort_order);
215 set_allow_drag_column(1);
218 ChanSearchList::~ChanSearchList()
222 int ChanSearchList::handle_event()
224 if( get_double_click() ) {
225 ChannelPanel *panel = gui->panel;
226 panel->lock_window("ChanSearchList::handle_event");
227 ChannelEvent *item = gui->highlighted_event;
229 item->text_color(-1);
232 int i = get_highlighted_item();
233 item = gui->search_results.get(i);
234 int x = item->x0-panel->x0 - panel->frame_w/2 + item->get_w()/2;
236 int w = panel->x1 - panel->x0;
238 panel->time_line_scroll->update_value(x);
239 panel->set_x_scroll(x);
240 item->text_color(YELLOW);
242 gui->highlighted_event = item;
243 panel->unlock_window();
248 int ChanSearchList::sort_order_event()
250 gui->sort_events(get_sort_column(), get_sort_order());
254 int ChanSearchList::move_column_event()
256 gui->move_column(get_from_column(), get_to_column());
260 void ChanSearchGUI::create_objects()
262 int pady = BC_TextBox::calculate_h(this, MEDIUMFONT, 0, 1) + 5;
263 int padx = BC_Title::calculate_w(this, (char*)"X", MEDIUMFONT);
264 int x = padx/2, y = pady/4;
265 BC_Title *title = new BC_Title(text_x, text_y, _("Text:"), MEDIUMFONT, YELLOW);
266 add_subwindow(title); x += title->get_w();
267 text_x = x; text_y = y;
268 search_text = new ChanSearchText(this, x, y, get_w()-x-10);
269 add_subwindow(search_text);
270 x = padx; y += pady + 5;
271 title_text = new ChanSearchTitleText(this, x, y);
272 add_subwindow(title_text); x += title_text->get_w() + padx;
273 info_text = new ChanSearchInfoText(this, x, y);
274 add_subwindow(info_text); x += title_text->get_w() + padx;
275 match_case = new ChanSearchMatchCase(this, x, y);
276 add_subwindow(match_case); x += match_case->get_w() + padx;
277 results_x = x + 20; results_y = y + 5;
278 results = new BC_Title(results_x, results_y, " ", MEDIUMFONT, YELLOW);
279 add_subwindow(results);
280 x = padx; y += pady + 5;
282 search_y = get_h() - BC_GenericButton::calculate_h() - 10;
283 search_start = new ChanSearchStart(this, search_x, search_y);
284 add_subwindow(search_start);
285 cancel_w = ChanSearchCancel::calculate_w();
286 cancel_h = ChanSearchCancel::calculate_h();
287 cancel_x = get_w() - cancel_w - 10;
288 cancel_y = get_h() - cancel_h - 10;
289 cancel = new ChanSearchCancel(this, cancel_x, cancel_y);
290 add_subwindow(cancel);
291 list_x = x; list_y = y;
292 int list_w = get_w()-10 - list_x;
293 int list_h = min(search_y, cancel_y)-10 - list_y;
294 search_list = new ChanSearchList(this, list_x, list_y, list_w, list_h);
295 add_subwindow(search_list);
296 search_list->show_window();
297 int clktip_x = list_x;
298 int clktip_y = list_y + list_h + 5;
299 click_tip = new BC_Title(clktip_x, clktip_y, _("dbl clk row to find title"));
300 add_subwindow(click_tip);
302 set_icon(iwindow->mwindow->theme->get_image("record_icon"));
303 search_text->activate();
306 ChanSearchGUI::ChanSearchGUI(ChanSearch *cswindow)
307 : BC_Window(_(PROGRAM_NAME ": ChanSearch"),
308 cswindow->iwindow->gui->get_abs_cursor_x(1) - 500 / 2,
309 cswindow->iwindow->gui->get_abs_cursor_y(1) - 300 / 2,
312 this->cswindow = cswindow;
313 this->iwindow = cswindow->iwindow;
314 this->panel = cswindow->iwindow->gui->panel;
325 search_x = search_y = text_x = text_y = 0;
326 cancel_x = cancel_y = cancel_w = cancel_h = 0;
327 list_x = list_y = list_w = list_h = 0;
328 results_x = results_y = 0;
329 sort_column = sort_order = 0;
331 title_text_enable = 1;
332 info_text_enable = 0;
333 match_case_enable = 0;
334 highlighted_event = 0;
336 search_columns[0] = 0;
337 search_columns[1] = 1;
338 search_columns[2] = 2;
339 search_column_titles[0] = _("Source");
340 search_column_titles[1] = C_("Title");
341 search_column_titles[2] = _("Start time");
342 search_column_widths[0] = 120;
343 search_column_widths[2] = 120;
344 search_column_widths[1] = get_w()-search_column_widths[0]-search_column_widths[2]-32;
347 ChanSearchGUI::~ChanSearchGUI()
350 ChannelEvent *item = highlighted_event;
352 panel->lock_window("ChanSearchGUI::~ChanSearchGUI");
353 item->text_color(-1);
355 panel->unlock_window();
357 for( int i=0; i<lengthof(search_items); ++i )
358 search_items[i].remove_all_objects();
361 int ChanSearchGUI::resize_event(int w, int h)
363 search_text->reposition_window(text_x, text_y, w-text_x-10);
364 int cancel_x = w - BC_CancelButton::calculate_w() - 10;
365 int cancel_y = h - BC_CancelButton::calculate_h() - 10;
366 cancel->reposition_window(cancel_x, cancel_y);
368 search_y = h - BC_GenericButton::calculate_h() - 10;
369 search_start->reposition_window(search_x, search_y);
370 int list_w = w-10 - list_x;
371 int list_h = min(search_y, cancel_y)-10 - list_y;
372 search_column_widths[1] = w-search_column_widths[0]-search_column_widths[2]-32;
373 search_list->reposition_window(list_x, list_y, list_w, list_h);
374 int clktip_x = list_x;
375 int clktip_y = list_y + list_h + 5;
376 click_tip->reposition_window(clktip_x, clktip_y);
381 int ChanSearchGUI::close_event()
387 int ChanSearchGUI::search(const char *sp)
389 char const *tp = search_text->get_text();
391 for( const char *cp=sp; *cp!=0; ++cp ) {
392 if( match_case_enable ? !strncmp(tp, cp, n) :
393 !strncasecmp(tp, cp, n) ) return 1;
398 void ChanSearchGUI::search()
400 search_results.remove_all();
402 int n = panel->channel_event_items.size();
403 for( int i=0; i<n; ++i ) {
404 ChannelEvent *item = panel->channel_event_items.get(i);
405 if( (title_text_enable && search(item->get_text())) ||
406 (info_text_enable && search(item->get_tooltip()) ) )
407 search_results.append(item);
413 void ChanSearchGUI::update()
416 for( int i=0; i<lengthof(search_items); ++i )
417 search_items[i].remove_all_objects();
419 char text[BCTEXTLEN];
420 int n = search_results.size();
421 for( int i=0; i<n; ++i ) {
422 ChannelEvent *item = search_results.get(i);
423 for( int k=0; k<lengthof(search_columns); ++k ) {
425 switch( search_columns[k] ) {
426 case 0: cp = item->channel->title; break;
427 case 1: cp = item->get_text(); break;
429 struct tm stm; localtime_r(&item->start_time,&stm);
430 double seconds = stm.tm_hour*3600 + stm.tm_min*60 + stm.tm_sec;
431 Units::totext(text, seconds, TIME_HMS3);
434 if( cp ) search_items[k].append(new BC_ListBoxItem(cp, LTYELLOW));
438 search_list->update(search_items, &search_column_titles[0],
439 &search_column_widths[0], lengthof(search_items));
440 sprintf(text, _("%d found"), n);
441 results->update(text);
445 #define CmprFn(nm,key) int ChanSearchGUI:: \
446 cmpr_##nm(const void *a, const void *b) { \
447 ChannelEvent *&ap = *(ChannelEvent **)a; \
448 ChannelEvent *&bp = *(ChannelEvent **)b; \
449 int n = key; if( !n ) n = ap->no-bp->no; \
453 CmprFn(Text_dn, strcasecmp(ap->get_text(), bp->get_text()))
454 CmprFn(text_dn, strcmp(ap->get_text(), bp->get_text()))
455 CmprFn(Text_up, strcasecmp(bp->get_text(), ap->get_text()))
456 CmprFn(text_up, strcmp(bp->get_text(), ap->get_text()))
457 CmprFn(time_dn, ap->start_time - bp->start_time)
458 CmprFn(time_up, bp->start_time - ap->start_time)
459 CmprFn(Title_dn, strcasecmp(ap->channel->title, bp->channel->title))
460 CmprFn(title_dn, strcmp(ap->channel->title, bp->channel->title))
461 CmprFn(Title_up, strcasecmp(bp->channel->title, ap->channel->title))
462 CmprFn(title_up, strcmp(bp->channel->title, ap->channel->title))
465 void ChanSearchGUI::sort_events(int column, int order)
467 sort_column = column; sort_order = order;
468 int n = search_results.size();
470 ChannelEvent **events = &search_results.values[0];
471 for( int i=0; i<n; ++i ) events[i]->no = i;
473 int(*cmpr)(const void *, const void *) = 0;
474 switch( search_columns[sort_column] ) {
475 case 0: cmpr = match_case_enable ?
476 (sort_order ? cmpr_Title_up : cmpr_Title_dn) :
477 (sort_order ? cmpr_title_up : cmpr_title_dn) ;
479 case 1: cmpr = match_case_enable ?
480 (sort_order ? cmpr_Text_up : cmpr_Text_dn) :
481 (sort_order ? cmpr_text_up : cmpr_text_dn) ;
483 case 2: cmpr = sort_order ? cmpr_time_up : cmpr_time_dn;
488 ChannelEvent **events = &search_results.values[0];
489 qsort(events, n, sizeof(*events), cmpr);
494 void ChanSearchGUI::move_column(int src, int dst)
496 if( src == dst ) return;
497 int src_column = search_columns[src];
498 const char *src_column_title = search_column_titles[src];
499 int src_column_width = search_column_widths[src];
501 for( int i=src; i<dst; ++i ) {
502 search_columns[i] = search_columns[i+1];
503 search_column_titles[i] = search_column_titles[i+1];
504 search_column_widths[i] = search_column_widths[i+1];
508 for( int i=src; i>dst; --i ) {
509 search_columns[i] = search_columns[i-1];
510 search_column_titles[i] = search_column_titles[i-1];
511 search_column_widths[i] = search_column_widths[i-1];
514 search_columns[dst] = src_column;
515 search_column_titles[dst] = src_column_title;
516 search_column_widths[dst] = src_column_width;
521 ChannelProgress::ChannelProgress(ChannelInfoGUI *gui,
522 int x, int y, int w, int h, int len)
524 BC_SubWindow(x, y, w, h)
533 eta_timer = new Timer;
536 ChannelProgress::~ChannelProgress()
542 void ChannelProgress::create_objects()
544 int w = BC_Title::calculate_w(gui, (char*)"XXXXX", MEDIUMFONT);
545 eta = new BC_Title(0, 0, "+0:00", MEDIUMFONT, -1, 0, w);
547 int x = eta->get_w();
548 bar = new BC_ProgressBar(x, 0, get_w()-x, length);
553 void ChannelProgress::start()
560 void ChannelProgress::stop()
562 if( Thread::running() ) {
569 void ChannelProgress::run()
573 if( update() ) break;
580 int ChannelProgress::update()
582 double elapsed = (double)eta_timer->get_scaled_difference(1000) / 1000.;
583 double estimate = value < 1 ? 0 : (length/value-1)*elapsed;
584 char text[BCTEXTLEN], *cp = &text[0];
585 Units::totext(cp, estimate, TIME_MS1);
586 gui->lock_window("ChannelProgress::update");
589 gui->unlock_window();
590 return value < length ? 0 : 1;
595 TimeLineItem::TimeLineItem(ChannelPanel *panel, int x, int y, char *text)
596 : BC_Title(x-panel->x_scroll, 0, text, MEDIUMFONT,
597 x==panel->x_now ? GREEN : YELLOW)
603 TimeLineItem::~TimeLineItem()
608 TimeLine::TimeLine(ChannelPanel *panel)
609 : BC_SubWindow(panel->frame_x, 0, panel->frame_w, panel->path_h)
614 TimeLine::~TimeLine()
618 int TimeLine::resize_event(int w, int h)
625 ChannelDataItem::ChannelDataItem(ChannelPanel *panel, int x, int y, int w,
626 int color, const char *text)
627 : BC_Title(x, y-panel->y_scroll, text, MEDIUMFONT, color)
632 set_force_tooltip(1);
635 ChannelDataItem::~ChannelDataItem()
640 int ChannelDataItem::repeat_event(int64_t duration)
642 if( tip_info && cursor_above() &&
643 duration == get_resources()->tooltip_delay ) {
650 void ChannelDataItem::set_tooltip(const char *tip)
652 BC_Title::set_tooltip(tip_info = tip ? cstrdup(tip) : 0);
656 ChannelData::ChannelData(ChannelPanel *panel, int x, int y, int w, int h)
657 : BC_SubWindow(x, y, w, h, LTBLACK)
662 ChannelData::~ChannelData()
666 int ChannelData::resize_event(int w, int h)
673 ChannelScroll::ChannelScroll(ChannelPanel *panel, int x, int y, int h)
674 : BC_ScrollBar(x, y, SCROLL_VERT, h, 0, 0, 0)
679 ChannelScroll::~ChannelScroll()
683 int ChannelScroll::handle_event()
685 panel->set_y_scroll(get_value());
690 TimeLineScroll::TimeLineScroll(ChannelPanel *panel, int x, int y, int w)
691 : BC_ScrollBar(x, y, SCROLL_HORIZ, w, 0, 0, 0)
696 TimeLineScroll::~TimeLineScroll()
700 int TimeLineScroll::handle_event()
702 panel->set_x_scroll(get_value());
707 ChannelEventLine::ChannelEventLine(ChannelPanel *panel,
708 int x, int y, int w, int h, int color)
709 : BC_SubWindow(0, y, w, h, color)
715 ChannelEventLine::~ChannelEventLine()
719 void ChannelEventLine::resize(int w, int h)
725 ChannelEvent::ChannelEvent(ChannelEventLine *channel_line, Channel *channel,
726 time_t start_time, time_t end_time, int x, int y, int w, const char *text)
727 : BC_GenericButton( x-channel_line->panel->x_scroll,
728 y-channel_line->panel->y_scroll, w, text)
730 this->channel_line = channel_line;
731 this->channel = channel;
732 this->start_time = start_time;
733 this->end_time = end_time;
734 x0 = x; y0 = y; no = 0;
736 set_force_tooltip(1);
739 ChannelEvent::~ChannelEvent()
744 int ChannelEvent::handle_event()
746 ChannelInfoGUI *gui = channel_line->panel->gui;
747 Batch *batch = gui->batch_bay->get_editing_batch();
748 char *path = batch->asset->path;
749 int len = sizeof(batch->asset->path)-1;
750 const char *text = get_text();
751 const char *dir = gui->channel_dir->get_directory();
753 while( i<len && *dir ) path[i++] = *dir++;
754 if( i > 0 && dir[i-1] != '/' ) path[i++] = '/';
755 while( i<len && *text ) {
757 if( !isalnum(ch) ) ch = '_';
760 if( i < len ) path[i++] = '.';
761 if( i < len ) path[i++] = 't';
762 if( i < len ) path[i++] = 's';
764 int early = (int)gui->early_time->get_time();
765 int late = (int)gui->late_time->get_time();
766 time_t st = start_time + early;
767 struct tm stm; localtime_r(&st,&stm);
768 batch->record_mode = RECORD_TIMED;
770 batch->start_day = stm.tm_wday;
771 batch->start_time = stm.tm_hour*3600 + stm.tm_min*60 + stm.tm_sec;
772 batch->duration = end_time - start_time - early + late;
773 batch->channel = channel;
774 gui->batch_bay->update_batches();
775 gui->update_channel_tools();
779 void ChannelEvent::set_tooltip(const char *tip)
781 BC_GenericButton::set_tooltip(tip_info = tip ? cstrdup(tip) : 0);
785 ChannelFrame::ChannelFrame(ChannelPanel *panel)
786 : BC_SubWindow(panel->frame_x, panel->frame_y,
787 panel->frame_w, panel->frame_h, BLACK)
792 ChannelFrame::~ChannelFrame()
797 void ChannelPanel::create_objects()
799 iwd = BC_ScrollBar::get_span(SCROLL_VERT);
800 iht = BC_ScrollBar::get_span(SCROLL_HORIZ);
802 frame_x = path_w; frame_y = path_h;
803 frame_w = iwindow_w-frame_x - iwd;
804 frame_h = iwindow_h-frame_y - iht;
806 time_line = new TimeLine(this);
807 add_subwindow(time_line);
808 time_line_scroll = new TimeLineScroll(this, frame_x, iwindow_h-iht, frame_w);
809 add_subwindow(time_line_scroll);
810 channel_data = new ChannelData(this, 0, frame_y, path_w, frame_h);
811 add_subwindow(channel_data);
812 channel_frame = new ChannelFrame(this);
813 add_subwindow(channel_frame);
814 channel_scroll = new ChannelScroll(this, iwindow_w-iwd, frame_y, frame_h);
815 add_subwindow(channel_scroll);
818 ChannelPanel::ChannelPanel(ChannelInfoGUI *gui,
819 int x, int y, int w, int h)
820 : BC_SubWindow(x, y, w, h)
823 gettimeofday(&tv, &tz);
824 st_org = ((tv.tv_sec+1800-1) / 1800) * 1800 - 1800;
825 x_now = (tv.tv_sec-st_org)/1800 * hhr_w;
826 path_w = gui->path_w; path_h = gui->path_h;
827 x0 = y0 = x1 = y1 = t0 = t1 = 0;
828 x_scroll = y_scroll = 0;
829 x_moved = y_moved = 0;
830 iwindow_w = w; iwindow_h = h;
831 hhr_w = BC_GenericButton::calculate_w(gui, (char*)"XXXXXXXX") + 5;
834 ChannelPanel::~ChannelPanel()
838 ChannelEventLine *ChannelPanel::NewChannelLine(int y, int h, int color)
840 ChannelEventLine *channel_line =
841 new ChannelEventLine(this, 0, y, frame_w, h, color);
842 channel_frame->add_subwindow(channel_line);
843 channel_line_items.append(channel_line);
847 void ChannelPanel::resize(int w, int h)
849 frame_w = (iwindow_w=w) - frame_x - iwd;
850 frame_h = (iwindow_h=h) - frame_y - iht;
851 time_line->resize_window(frame_w, path_h);
852 time_line_scroll->reposition_window(frame_x, frame_y+frame_h, frame_w);
853 time_line_scroll->update_length(x1-x0, x_scroll-x0, frame_w,0);
854 time_line_scroll->update_value(-x0);
855 channel_data->resize_window(path_w, frame_h);
856 channel_frame->resize_window(frame_w, frame_h);
857 int nitems = channel_line_items.size();
858 for( int i=0; i<nitems; ++i )
859 channel_line_items.values[i]->resize_window(frame_w, path_h);
860 channel_scroll->reposition_window(frame_x+frame_w, frame_y, frame_h);
861 channel_scroll->update_length(y1-y0, y_scroll-y0, frame_h,0);
865 int ChannelPanel::button_press_event()
867 if(get_buttonpress() == 3 && cursor_inside()) {
868 gui->lock_window("ChannelPanel::button_press_event");
869 gui->channel_search->start();
870 gui->unlock_window();
876 void ChannelPanel::bounding_box(int ix0, int iy0, int ix1, int iy1)
878 int x_changed = 0, y_changed = 0;
879 if( ix0 < x0 ) { x0 = ix0; x_changed = 1; }
880 if( iy0 < y0 ) { y0 = iy0; y_changed = 1; }
881 if( ix1 > x1 ) { x1 = ix1; x_changed = 1; }
882 if( iy1 > y1 ) { y1 = iy1; y_changed = 1; }
884 time_line_update(x0, x1);
885 time_line_scroll->update_length(x1-x0, x_scroll-x0, frame_w, 0);
886 if( !x_moved ) time_line_scroll->update_value(-x0);
889 channel_scroll->update_length(y1-y0, y_scroll-y0, frame_h, 0);
890 if( x_changed || y_changed ) flush();
893 void ChannelPanel::set_x_scroll(int v)
900 void ChannelPanel::set_y_scroll(int v)
907 void ChannelPanel::reposition()
910 n = time_line_items.size();
911 for( i=0; i<n; ++i ) {
912 TimeLineItem *item = time_line_items[i];
913 if( item->get_x() == item->x0-x_scroll &&
914 item->get_y() == item->y0-y_scroll) continue;
915 item->reposition_window(item->x0-x_scroll, item->y0);
917 n = channel_data_items.size();
918 for( i=0; i<n; ++i ) {
919 ChannelDataItem *item = channel_data_items[i];
920 if( item->get_x() == item->x0-x_scroll &&
921 item->get_y() == item->y0-y_scroll) continue;
922 item->reposition_window(item->x0, item->y0-y_scroll);
924 n = channel_line_items.size();
925 for( i=0; i<n; ++i ) {
926 ChannelEventLine *item = channel_line_items[i];
927 if( item->get_x() == item->x0-x_scroll &&
928 item->get_y() == item->y0-y_scroll) continue;
929 item->reposition_window(item->x0, item->y0-y_scroll);
931 n = channel_event_items.size();
932 for( i=0; i<n; ++i ) {
933 ChannelEvent *item = channel_event_items[i];
934 if( item->get_x() == item->x0-x_scroll &&
935 item->get_y() == item->y0-y_scroll) continue;
936 item->reposition_window(item->x0-x_scroll, item->y0);
940 void ChannelPanel::get_xtime(int x, char *cp)
942 time_t xt = st_org + (x/hhr_w) * 1800;
943 if( !strcmp(tzname[0],"UTC") ) xt -= tz.tz_minuteswest*60;
944 struct tm xtm; localtime_r(&xt,&xtm);
945 cp += sprintf(cp,"%02d:%02d",xtm.tm_hour, xtm.tm_min);
946 if( !xtm.tm_hour && !xtm.tm_min ) {
947 sprintf(cp,"(%3.3s) ",&_("sunmontuewedthufrisat")[xtm.tm_wday*3]);
951 void ChannelPanel::time_line_update(int ix0, int ix1)
953 int x; char text[BCTEXTLEN];
954 for( x=t0; x>=ix0; x-=hhr_w ) {
955 get_xtime(x, text); t0 = x;
956 TimeLineItem *time_line_item = new TimeLineItem(this, t0, 0, text);
957 time_line->add_subwindow(time_line_item);
958 time_line_items.insert(time_line_item,0);
960 for( x=t1; x<ix1; x+=hhr_w ) {
961 get_xtime(x, text); t1 = x;
962 TimeLineItem *time_line_item = new TimeLineItem(this, t1, 0, text);
963 time_line->add_subwindow(time_line_item);
964 time_line_items.append(time_line_item);
969 ChannelInfoCron(ChannelInfoGUI *gui, int x, int y, int *value)
970 : BC_CheckBox(x, y, value, gui->cron_caption)
973 set_tooltip(_("activate batch record when ok pressed"));
981 int ChannelInfoCron::
984 gui->iwindow->cron_enable = get_value();
989 ChannelInfoPowerOff::ChannelInfoPowerOff(ChannelInfoGUI *gui, int x, int y, int *value)
990 : BC_CheckBox(x, y , value, gui->power_caption)
993 set_tooltip(_("poweroff system when batch record done"));
996 ChannelInfoPowerOff::~ChannelInfoPowerOff()
1000 int ChannelInfoPowerOff::handle_event()
1002 gui->iwindow->poweroff_enable = get_value();
1007 ChannelInfoFind::ChannelInfoFind(ChannelInfoGUI *gui, int x, int y)
1008 : BC_GenericButton(x, y, _("Find"))
1011 set_tooltip(_("search event titles/info"));
1014 ChannelInfoFind::~ChannelInfoFind()
1018 int ChannelInfoFind::handle_event()
1020 gui->lock_window("ChannelInfoFind::handle_event");
1021 gui->channel_search->start();
1022 gui->unlock_window();
1026 void ChannelThread::start()
1028 if( !Thread::running() ) {
1034 void ChannelThread::stop()
1036 if( Thread::running() ) {
1043 ChannelThread::ChannelThread(ChannelInfoGUI *gui)
1047 this->iwindow = gui->iwindow;
1048 this->panel = gui->panel;
1054 ChannelThread::~ChannelThread()
1059 int ChannelThread::load_ident(int n, int y, char *ident)
1061 ChannelDataItem *data_item = new ChannelDataItem(panel, 0, y,
1062 panel->path_w, !n ? YELLOW : LTYELLOW, ident);
1063 panel->channel_data->add_subwindow(data_item);
1064 panel->channel_data_items.append(data_item);
1066 char info[BCTEXTLEN];
1067 int i = mpeg3_dvb_get_chan_info(fd, n, -1, 0, info, sizeof(info)-1);
1068 while( --i >= 0 && (info[i]=='\n' || info[i]==' ') ) info[i] = 0;
1069 if( info[0] ) data_item->set_tooltip(info);
1074 int ChannelThread::load_info(Channel *channel, ChannelEventLine *channel_line)
1076 int n = channel->element;
1079 while( ord < 0x80 ) {
1080 char info[65536], *cp = &info[0];
1081 int len = mpeg3_dvb_get_chan_info(fd,n,ord,i++,cp,sizeof(info)-1);
1082 if( len < 0 ) { i = 0; ++ord; continue; }
1083 char *bp = cp; cp += len;
1084 struct tm stm; memset(&stm,0,sizeof(stm));
1085 struct tm etm; memset(&etm,0,sizeof(etm));
1086 int k, l = sscanf(bp,"%d:%d:%d-%d:%d:%d %n",
1087 &stm.tm_hour, &stm.tm_min, &stm.tm_sec,
1088 &etm.tm_hour, &etm.tm_min, &etm.tm_sec,
1091 printf(_("bad scan time: %s\n"),info);
1094 char *title = (bp += k);
1095 while( bp<cp && *bp!='\n' ) ++bp;
1096 char *dp = bp; *bp++ = 0;
1098 printf(_("bad title: %s\n"),info);
1101 char stm_wday[4]; memset(&stm_wday,0,sizeof(stm_wday));
1102 l = sscanf(bp, "(%3s) %d/%d/%d", &stm_wday[0],
1103 &stm.tm_year, &stm.tm_mon, &stm.tm_mday);
1105 printf(_("bad scan date: %s\n"),info);
1108 while( bp<cp && *bp!='\n' ) ++bp;
1110 etm.tm_year = (stm.tm_year -= 1900);
1111 etm.tm_mon = --stm.tm_mon;
1112 etm.tm_mday = stm.tm_mday;
1113 stm.tm_isdst = etm.tm_isdst = -1;
1114 time_t st = mktime(&stm);
1115 time_t et = mktime(&etm);
1116 if( et < st ) et += 24*3600;
1118 printf(_("end before start: %s\n"),info);
1121 if( panel->st_org - et > 24*3600*2) {
1122 printf(_("end time early: %s\n"),info);
1125 if( st - panel->st_org > 24*3600*12 ) {
1126 printf(_("start time late: %s\n"),info);
1129 time_t st_min = (st - panel->st_org)/60;
1130 time_t et_min = (et - panel->st_org)/60;
1131 int dt = et_min - st_min;
1133 printf(_("zero duration: %s\n"),info);
1137 int w = (dt * panel->hhr_w) / 30;
1138 int x = (st_min * panel->hhr_w) / 30;
1139 int y = channel_line->y0;
1140 panel->bounding_box(x, y, x+w, y+panel->path_h);
1141 ChannelEvent *channel_event =
1142 new ChannelEvent(channel_line, channel,
1143 st, et, x, 0, w, title);
1144 channel_line->add_subwindow(channel_event);
1145 panel->channel_event_items.append(channel_event);
1147 *dp = '\n'; *bp++ = '\n';
1148 for( char *lp=bp; bp<cp; ++bp ) {
1149 if( *bp == '\n' || ((bp-lp)>=60 && *bp==' ') )
1153 for( bp=&info[0]; --cp>=bp && (*cp=='\n' || *cp==' '); *cp=0 );
1154 if( info[0] ) channel_event->set_tooltip(info);
1159 void ChannelThread::run()
1162 Channel *channel = 0;
1164 int nchannels = total_channels();
1167 for(int ch=0; !done && ch<nchannels; gui->update_progress(++ch) ) {
1168 Channel *chan = get_channel(ch);
1169 if( !chan ) continue;
1171 iwindow->vdevice_lock->lock("ChannelThread::run");
1172 DeviceDVBInput *dvb_input = iwindow->dvb_input;
1173 if( !channel || chan->entry != channel->entry ) {
1175 while( dvb_input->set_channel(chan) && --retry >= 0 );
1180 y += panel->separator(y);
1181 gui->unlock_window();
1187 else if( chan->element == channel->element )
1191 if( !done && chan && channel && (fd=dvb_input->get_src()) ) {
1193 load_ident(chan->element, y, chan->title);
1194 ChannelEventLine *channel_line = panel->NewChannelLine(y);
1195 load_info(chan, channel_line);
1196 channel_line->show_window();
1197 gui->unlock_window();
1198 dvb_input->put_src();
1201 iwindow->vdevice_lock->unlock();
1205 gui->lock_window("ChannelProgress::run");
1206 gui->channel_status->hide_window();
1207 gui->unlock_window();
1210 iwindow->close_vdevice();
1214 ChannelInfoOK::ChannelInfoOK(ChannelInfoGUI *gui, int x, int y)
1218 set_tooltip(_("end channel info, start record"));
1221 ChannelInfoOK::~ChannelInfoOK()
1225 int ChannelInfoOK::button_press_event()
1227 if(get_buttonpress() == 1 && is_event_win() && cursor_inside()) {
1234 int ChannelInfoOK::keypress_event()
1240 ChannelInfoCancel::ChannelInfoCancel(ChannelInfoGUI *gui, int x, int y)
1241 : BC_CancelButton(x, y)
1246 ChannelInfoCancel::~ChannelInfoCancel()
1250 int ChannelInfoCancel::button_press_event()
1252 if(get_buttonpress() == 1 && is_event_win() && cursor_inside()) {
1260 ChannelInfoGUIBatches::ChannelInfoGUIBatches(ChannelInfoGUI *gui,
1261 int x, int y, int w, int h)
1262 : RecordBatchesGUI(gui->iwindow->record_batches, x, y, w, h)
1267 ChannelInfoGUIBatches::~ChannelInfoGUIBatches()
1271 int ChannelInfoGUIBatches::selection_changed()
1273 return RecordBatchesGUI::selection_changed();
1276 int ChannelInfoGUIBatches::handle_event()
1278 if( get_double_click() )
1279 gui->update_channel_tools();
1284 void ChannelInfoGUI::create_objects()
1286 panel = new ChannelPanel(this,0,0,panel_w,panel_h);
1287 add_subwindow(panel);
1288 panel->create_objects();
1289 int items = iwindow->channeldb->size();
1290 if( items < 1 ) items = 1;
1291 progress = new ChannelProgress(this, 0, 0, path_w, path_h, items);
1292 add_subwindow(progress);
1293 progress->create_objects();
1294 ok = new ChannelInfoOK(this, ok_x, ok_y);
1296 channel_cron = new ChannelInfoCron(this, cron_x, cron_y, &iwindow->cron_enable);
1297 add_subwindow(channel_cron);
1298 channel_poweroff = new ChannelInfoPowerOff(this,
1299 power_x, power_y, &iwindow->poweroff_enable);
1300 add_subwindow(channel_poweroff);
1301 channel_find = new ChannelInfoFind(this, find_x, find_y);
1302 add_subwindow(channel_find);
1303 cancel = new ChannelInfoCancel(this, cancel_x, cancel_y);
1304 add_subwindow(cancel);
1305 batch_bay = new ChannelInfoGUIBatches(this,bay_x, bay_y, bay_w, bay_h);
1306 add_subwindow(batch_bay);
1307 iwindow->record_batches.gui = batch_bay;
1308 batch_bay->set_current_batch(-1);
1309 batch_bay->update_batches(-1);
1311 pad = BC_TextBox::calculate_h(this, MEDIUMFONT, 0, 1) + 5;
1312 x0 = bay_x+bay_w + 10;
1318 add_subwindow(directory_title = new BC_Title(x, y, _("Directory:")));
1319 ww = max(directory_title->get_w(), ww); y += pad;
1320 add_subwindow(path_title = new BC_Title(x, y, _("Path:")));
1321 ww = max(path_title->get_w(), ww); y += pad;
1322 add_subwindow(start_title = new BC_Title(x, y, _("Start:")));
1323 ww = max(start_title->get_w(), ww); y += pad;
1324 add_subwindow(duration_title = new BC_Title(x, y, _("Duration:")));
1325 ww = max(duration_title->get_w(), ww); y += pad;
1326 add_subwindow(source_title = new BC_Title(x, y, _("Source:")));
1327 ww = max(source_title->get_w(), ww); y += pad;
1330 int x1 = x0 + title_w + pad;
1331 x = x1; y = y0; ww = 0;
1333 char *dir = iwindow->record_batches.get_default_directory();
1334 add_subwindow(channel_dir = new ChannelDir(this, dir, x, y));
1335 ww = max(channel_dir->get_w(), ww); y += pad;
1336 add_subwindow(channel_path = new ChannelPath(this, x, y));
1337 ww = max(channel_path->get_w(), ww); y += pad;
1338 channel_start = new ChannelStart(this, x, y);
1339 channel_start->create_objects();
1340 ww = max(channel_start->get_w(), ww); y += pad;
1341 int w = BC_Title::calculate_w(this, (char*)"+00:00:00+", MEDIUMFONT);
1342 channel_duration = new ChannelDuration(this, x, y, w);
1343 channel_duration->create_objects();
1344 int x2 = x + channel_duration->get_w();
1345 double *early_margin = iwindow->record_batches.get_early_margin();
1346 early_time = new ChannelEarlyTime(this, x2, y, early_margin);
1347 early_time->create_objects();
1348 x2 += early_time->get_w();
1349 double *late_margin = iwindow->record_batches.get_late_margin();
1350 late_time = new ChannelLateTime(this, x2, y, late_margin);
1351 late_time->create_objects();
1352 x2 += late_time->get_w();
1353 ww = max(x2-x1, ww); y += pad;
1354 channel_source = new ChannelSource(this, x, y);
1355 channel_source->create_objects();
1356 ww = max(channel_source->get_w(), ww); y += pad;
1357 data_w = x1-x0 + ww;
1360 add_subwindow(channel_clear_batch = new ChannelClearBatch(this, x, y));
1361 x += channel_clear_batch->get_w() + 10;
1362 add_subwindow(channel_new_batch = new ChannelNewBatch(this, x, y));
1363 x += channel_new_batch->get_w() + 10;
1364 add_subwindow(channel_delete_batch = new ChannelDeleteBatch(this, x, y));
1365 x += channel_delete_batch->get_w();
1367 data_w = max(ww, data_w);
1369 channel_status = new ChannelStatus(this, x0+data_w, y0);
1370 add_subwindow(channel_status);
1371 channel_status->create_objects();
1372 status_w = channel_status->get_w();
1374 channel_search = new ChanSearch(iwindow);
1378 ChannelInfoGUI::ChannelInfoGUI(ChannelInfo *iwindow,
1379 int x, int y, int w, int h)
1380 : BC_Window(_(PROGRAM_NAME ": Channel Info"), x, y, w, h, 600, 400,
1381 1, 0, 0 , -1, iwindow->mwindow->get_cwindow_display())
1383 this->iwindow = iwindow;
1389 channel_duration = 0;
1391 channel_clear_batch = 0;
1392 channel_new_batch = 0;
1393 channel_delete_batch = 0;
1394 early_time = late_time = 0;
1395 directory_title = 0;
1400 cron_caption = _("Start Cron");
1401 power_caption = _("Poweroff");
1405 path_w = 16*BC_Title::calculate_w(this, (char*)"X", MEDIUMFONT);
1406 path_h = BC_TextBox::calculate_h(this, MEDIUMFONT, 0, 1);
1407 x0 = y0 = title_w = data_w = status_w = pad = 0;
1408 ok_w = BC_OKButton::calculate_w();
1409 ok_h = BC_OKButton::calculate_h();
1411 ok_y = h - ok_h - 10;
1412 BC_CheckBox::calculate_extents(this, &cron_w, &cron_h, cron_caption);
1414 cron_y = ok_y - cron_h - 10;
1415 BC_CheckBox::calculate_extents(this, &power_w, &power_h, power_caption);
1417 power_y = cron_y - power_h - 5;
1418 find_h = BC_GenericButton::calculate_h();
1420 find_y = power_y - find_h - 10;
1421 cancel_w = BC_CancelButton::calculate_w();
1422 cancel_h = BC_CancelButton::calculate_h();
1423 cancel_x = w - cancel_w - 10,
1424 cancel_y = h - cancel_h - 10;
1428 int x1 = cron_x+cron_w + 10;
1429 if( x1 > bay_x ) bay_x = x1;
1430 x1 = power_x+power_w + 10;
1431 if( x1 > bay_x ) bay_x = x1;
1433 // data_w,status_w zero, updated in create_objects
1434 bay_w = (w-bay_x) - (data_w+10) - (max(cancel_w, status_w)+20);
1435 if( bay_w > max_bay_w ) bay_w = max_bay_w;
1437 panel_h = h - bay_h;
1440 ChannelInfoGUI::~ChannelInfoGUI()
1443 channel_search->stop();
1445 delete channel_status;
1446 delete channel_search;
1447 delete channel_start;
1448 delete channel_duration;
1451 delete channel_source;
1454 void ChannelInfoGUI::stop(int v)
1456 if( !iwindow->gui_done ) {
1457 iwindow->gui_done = 1;
1462 int ChannelInfoGUI::translation_event()
1464 iwindow->mwindow->session->cswindow_x = get_x();
1465 iwindow->mwindow->session->cswindow_y = get_y();
1469 int ChannelInfoGUI::resize_event(int w, int h)
1471 iwindow->mwindow->session->cswindow_w = w;
1472 iwindow->mwindow->session->cswindow_h = h;
1474 panel_h = h - bay_h;
1475 panel->resize(panel_w,panel_h);
1476 panel->reposition_window(0,0,panel_w,panel_h);
1478 ok_y = h - ok_h - 10;
1479 ok->reposition_window(ok_x, ok_y);
1481 cron_y = ok_y - cron_h - 10;
1482 channel_cron->reposition_window(cron_x, cron_y);
1484 power_y = cron_y - power_h - 5;
1485 channel_poweroff->reposition_window(power_x, power_y);
1487 find_y = power_y - find_h - 10;
1488 channel_find->reposition_window(find_x, find_y);
1489 cancel_x = w - cancel_w - 10,
1490 cancel_y = h - cancel_h - 10;
1491 cancel->reposition_window(cancel_x, cancel_y);
1493 int x1 = cron_x+cron_w + 10;
1494 if( x1 > bay_x ) bay_x = x1;
1495 x1 = power_x+power_w + 10;
1496 if( x1 > bay_x ) bay_x = x1;
1498 bay_w = (w-bay_x) - (data_w+10) - (max(cancel_w, status_w)+20);
1499 if( bay_w > max_bay_w ) bay_w = max_bay_w;
1500 batch_bay->reposition_window(bay_x, bay_y, bay_w, bay_h);
1502 int x0 = bay_x+bay_w + 10;
1507 directory_title->reposition_window(x, y); y += pad;
1508 path_title->reposition_window(x, y); y += pad;
1509 start_title->reposition_window(x, y); y += pad;
1510 duration_title->reposition_window(x, y); y += pad;
1511 source_title->reposition_window(x, y);
1513 x = x0 + title_w + pad;
1516 channel_dir->reposition_window(x, y); y += pad;
1517 channel_path->reposition_window(x, y); y += pad;
1518 channel_start->reposition_window(x, y); y += pad;
1519 channel_duration->reposition_window(x, y);
1520 int x2 = x + channel_duration->get_w();
1521 early_time->reposition_window(x2, y);
1522 x2 += early_time->get_w();
1523 late_time->reposition_window(x2, y); y += pad;
1524 channel_source->reposition_window(x, y); y += pad;
1527 channel_clear_batch->reposition_window(x, y);
1528 x += channel_clear_batch->get_w() + 10;
1529 channel_new_batch->reposition_window(x, y);
1530 x += channel_new_batch->get_w() + 10;
1531 channel_delete_batch->reposition_window(x, y);
1535 channel_status->reposition_window(x, y);
1539 int ChannelInfoGUI::close_event()
1545 void ChannelInfoGUI::update_channel_tools()
1547 Batch *batch = batch_bay->get_editing_batch();
1548 channel_path->update(batch->asset->path);
1549 channel_start->update(&batch->start_day, &batch->start_time);
1550 channel_duration->update(0, &batch->duration);
1551 channel_source->update(batch->get_source_text());
1555 void ChannelInfoGUI::incr_event(int start_time_incr, int duration_incr)
1557 Batch *batch = batch_bay->get_editing_batch();
1558 batch->start_time += start_time_incr;
1559 batch->duration += duration_incr;
1560 batch_bay->update_batches();
1561 update_channel_tools();
1565 ChannelInfo::ChannelInfo(MWindow *mwindow)
1567 record_batches(mwindow)
1569 this->mwindow = mwindow;
1570 this->record = mwindow->gui->record;
1571 scan_lock = new Condition(0,"ChannelInfo::scan_lock");
1572 window_lock = new Mutex("ChannelInfo::window_lock");
1573 vdevice_lock = new Mutex("ChannelInfo::vdevice_lock");
1574 progress_lock = new Mutex("ChannelInfo::progress_lock");
1582 poweroff_enable = 0;
1590 ChannelInfo::~ChannelInfo()
1594 delete gui; gui = 0;
1596 record_batches.clear();
1600 delete vdevice_lock;
1601 delete progress_lock;
1604 void ChannelInfo::run_scan()
1606 window_lock->lock("ChannelInfo::run_scan");
1608 gui->lock_window("ChannelInfo::run_scan");
1609 gui->raise_window();
1610 gui->unlock_window();
1613 scan_lock->unlock();
1614 window_lock->unlock();
1617 void ChannelInfo::toggle_scan()
1619 window_lock->lock("ChannelInfo::toggle_scan");
1623 scan_lock->unlock();
1624 window_lock->unlock();
1627 void ChannelInfo::start()
1629 if( !Thread::running() ) {
1635 void ChannelInfo::stop()
1637 if( Thread::running() ) {
1639 scan_lock->unlock();
1640 window_lock->lock("ChannelInfo::stop");
1641 if( gui ) gui->stop(1);
1642 window_lock->unlock();
1648 void ChannelInfo::run()
1650 int root_w = mwindow->gui->get_root_w(1);
1651 int root_h = mwindow->gui->get_root_h(1);
1657 if( record->Thread::running() ) {
1658 char string[BCTEXTLEN];
1659 sprintf(string,_("Recording in progress\n"));
1660 MainError::show_error(string);
1663 EDLSession *session = mwindow->edl->session;
1664 VideoInConfig *vconfig_in = session->vconfig_in;
1665 if( vconfig_in->driver != CAPTURE_DVB ) {
1666 char string[BCTEXTLEN];
1667 sprintf(string,_("capture driver not dvb\n"));
1668 MainError::show_error(string);
1671 int x = mwindow->session->cswindow_x;
1672 int y = mwindow->session->cswindow_y;
1673 int w = mwindow->session->cswindow_w;
1674 int h = mwindow->session->cswindow_h;
1675 if( w < 600 ) w = 600;
1676 if( h < 400 ) h = 400;
1677 int scr_x = mwindow->gui->get_screen_x(1, -1);
1678 int scr_w = mwindow->gui->get_screen_w(1, -1);
1679 if( x < scr_x ) x = scr_x;
1680 if( x > scr_x+scr_w ) x = scr_x+scr_w;
1681 if( x+w > root_w ) x = root_w - w;
1682 if( x < 0 ) { x = 0; w = scr_w; }
1683 if( y+h > root_h ) y = root_h - h;
1684 if( y < 0 ) { y = 0; h = root_h; }
1685 if( y+h > root_h ) h = root_h-y;
1686 mwindow->session->cswindow_x = x;
1687 mwindow->session->cswindow_y = y;
1688 mwindow->session->cswindow_w = w;
1689 mwindow->session->cswindow_h = h;
1691 poweroff_enable = 0;
1692 vdevice = new VideoDevice(mwindow);
1693 int result = vdevice->open_input(vconfig_in, 0, 0, 1., vconfig_in->in_framerate);
1694 dvb_input = result ? 0 : (DeviceDVBInput *)vdevice->mpeg_device();
1696 channeldb = new ChannelDB;
1697 VideoDevice::load_channeldb(channeldb, vconfig_in);
1698 record_batches.load_defaults(channeldb);
1700 window_lock->lock("ChannelInfo::run 0");
1702 gui = new ChannelInfoGUI(this, x, y, w, h);
1703 gui->lock_window("ChannelInfo::gui_create_objects");
1704 gui->create_objects();
1705 gui->set_icon(mwindow->theme->get_image("record_icon"));
1706 gui->reposition_window(x, y);
1707 gui->resize_event(w, h);
1708 dvb_input->set_signal_status(gui->channel_status);
1709 gui->unlock_window();
1710 thread = new ChannelThread(gui);
1712 window_lock->unlock();
1713 result = gui->run_window();
1714 delete thread; thread = 0;
1717 gui->unlock_window();
1718 window_lock->lock("ChannelInfo::run 1");
1719 delete gui; gui = 0;
1720 window_lock->unlock();
1721 record_batches.save_defaults(channeldb);
1723 record_batches.save_default_channel(channeldb);
1725 record->init_lock->lock();
1727 record->set_power_off(poweroff_enable);
1728 record->start_cron_thread();
1731 record_batches.clear();
1732 delete channeldb; channeldb = 0;
1736 char string[BCTEXTLEN];
1737 sprintf(string,_("cannot open dvb video device\n"));
1738 MainError::show_error(string);
1743 void ChannelInfo::close_vdevice()
1745 vdevice_lock->lock("ChannelInfo::close_vdevice");
1746 progress_lock->lock("ChannelInfo::close_vdevice");
1748 vdevice->close_all();
1749 delete vdevice; vdevice = 0;
1751 progress_lock->unlock();
1752 vdevice_lock->unlock();
1755 Batch *ChannelInfo::new_batch()
1757 Batch *batch = new Batch(gui->iwindow->mwindow, 0);
1758 batch->create_objects();
1759 batch->calculate_news();
1760 gui->iwindow->record_batches.append(batch);
1764 void ChannelInfo::delete_batch()
1766 // Abort if one batch left
1767 int edit_batch = editing_batch();
1768 int total_batches = record_batches.total();
1769 if( total_batches > 1 && edit_batch < total_batches ) {
1770 Batch *batch = record_batches[edit_batch];
1771 record_batches.remove(batch); delete batch;
1775 ChannelScan::ChannelScan(MWindow *mwindow)
1776 : BC_MenuItem(_("Scan..."), _("Ctrl-Alt-s"), 's')
1780 this->mwindow = mwindow;
1783 ChannelScan::~ChannelScan()
1787 int ChannelScan::handle_event()
1789 mwindow->gui->channel_info->run_scan();
1794 ChannelDir::ChannelDir(ChannelInfoGUI *gui, const char *dir, int x, int y)
1795 : RecordBatchesGUI::Dir(gui->iwindow->record_batches, dir, x, y)
1801 ChannelPath::ChannelPath(ChannelInfoGUI *gui, int x, int y)
1802 : RecordBatchesGUI::Path(gui->iwindow->record_batches, x, y)
1808 ChannelStart::ChannelStart(ChannelInfoGUI *gui, int x, int y)
1809 : RecordBatchesGUI::StartTime(gui, gui->iwindow->record_batches, x, y)
1815 ChannelDuration::ChannelDuration(ChannelInfoGUI *gui, int x, int y, int w)
1816 : RecordBatchesGUI::Duration(gui, gui->iwindow->record_batches, x, y, w)
1822 ChannelEarlyTime::ChannelEarlyTime(ChannelInfoGUI *gui, int x, int y,
1823 double *output_time)
1824 : TimeEntryTumbler(gui, x, y, 0, output_time, 15, TIME_MS2, 75)
1829 int ChannelEarlyTime::handle_up_event()
1831 gui->incr_event(incr,-incr);
1832 return TimeEntryTumbler::handle_up_event();
1835 int ChannelEarlyTime::handle_down_event()
1837 gui->incr_event(-incr,incr);
1838 return TimeEntryTumbler::handle_down_event();
1842 ChannelLateTime::ChannelLateTime(ChannelInfoGUI *gui, int x, int y,
1843 double *output_time)
1844 : TimeEntryTumbler(gui, x, y, 0, output_time, 15, TIME_MS2, 75)
1849 int ChannelLateTime::handle_up_event()
1851 gui->incr_event(0,incr);
1852 return TimeEntryTumbler::handle_up_event();
1855 int ChannelLateTime::handle_down_event()
1857 gui->incr_event(0,-incr);
1858 return TimeEntryTumbler::handle_down_event();
1862 ChannelSource::ChannelSource(ChannelInfoGUI *gui, int x, int y)
1863 : RecordBatchesGUI::Source(gui, gui->iwindow->record_batches, x, y)
1868 void ChannelSource::create_objects()
1870 RecordBatchesGUI::Source::create_objects();
1871 ChannelDB *channeldb = gui->iwindow->channeldb;
1872 sources.remove_all_objects();
1873 for(int i = 0; i < channeldb->size(); i++) {
1874 sources.append(new BC_ListBoxItem(channeldb->get(i)->title));
1876 update_list(&sources);
1879 int ChannelSource::handle_event()
1881 int chan_no = get_number();
1882 Channel *channel = gui->iwindow->channeldb->get(chan_no);
1884 Batch *batch = batches.get_editing_batch();
1885 if( batch ) batch->channel = channel;
1886 update(channel->title);
1888 return RecordBatchesGUI::Source::handle_event();
1892 ChannelClearBatch::ChannelClearBatch(ChannelInfoGUI *gui, int x, int y)
1893 : RecordBatchesGUI::ClearBatch(gui->iwindow->record_batches, x, y)
1896 set_tooltip(_("Delete all clips."));
1899 int ChannelClearBatch::handle_event()
1901 gui->iwindow->record_batches.clear();
1902 gui->iwindow->new_batch();
1903 gui->batch_bay->set_current_batch(-1);
1904 gui->batch_bay->set_editing_batch(0);
1905 gui->batch_bay->update_batches(0);
1906 return RecordBatchesGUI::ClearBatch::handle_event();
1910 ChannelNewBatch::ChannelNewBatch(ChannelInfoGUI *gui, int x, int y)
1911 : RecordBatchesGUI::NewBatch(gui->iwindow->record_batches, x, y)
1914 set_tooltip(_("Create new clip."));
1916 int ChannelNewBatch::handle_event()
1918 gui->iwindow->new_batch();
1919 return RecordBatchesGUI::NewBatch::handle_event();
1923 ChannelDeleteBatch::ChannelDeleteBatch(ChannelInfoGUI *gui, int x, int y)
1924 : RecordBatchesGUI::DeleteBatch(gui->iwindow->record_batches, x, y)
1927 set_tooltip(_("Delete clip."));
1930 int ChannelDeleteBatch::handle_event()
1932 gui->iwindow->delete_batch();
1933 return RecordBatchesGUI::DeleteBatch::handle_event();