void widget_add_framedraw(LiVESVBox *box, int start, int end, boolean add_preview_button, int width, int height) { // adds the frame draw widget to box // the redraw button should be connected to an appropriate redraw function // after calling this function // an example of this is in 'trim frames' LiVESWidget *vseparator; LiVESWidget *vbox; LiVESWidget *hbox; LiVESWidget *label; LiVESAdjustment *spinbutton_adj; LiVESWidget *frame; lives_rfx_t *rfx; double fd_scale; b1_held=FALSE; mainw->framedraw_reset=NULL; vseparator = lives_vseparator_new(); lives_box_pack_start(LIVES_BOX(lives_widget_get_parent(LIVES_WIDGET(box))), vseparator, FALSE, FALSE, 0); lives_widget_show(vseparator); vbox = lives_vbox_new(FALSE, 0); lives_box_pack_start(LIVES_BOX(lives_widget_get_parent(LIVES_WIDGET(box))), vbox, FALSE, FALSE, 0); lives_container_set_border_width(LIVES_CONTAINER(vbox), widget_opts.border_width); fd_scale=calc_fd_scale(width,height); width/=fd_scale; height/=fd_scale; hbox = lives_hbox_new(FALSE, 0); lives_box_pack_start(LIVES_BOX(vbox), hbox, FALSE, FALSE, 0); fbord_eventbox=lives_event_box_new(); lives_container_set_border_width(LIVES_CONTAINER(fbord_eventbox),widget_opts.border_width); frame = lives_frame_new(NULL); lives_box_pack_start(LIVES_BOX(hbox), frame, FALSE, FALSE, 0); if (palette->style&STYLE_1) { lives_widget_set_bg_color(fbord_eventbox, LIVES_WIDGET_STATE_NORMAL, &palette->normal_fore); lives_widget_set_bg_color(frame, LIVES_WIDGET_STATE_NORMAL, &palette->normal_back); lives_widget_set_fg_color(frame, LIVES_WIDGET_STATE_NORMAL, &palette->normal_fore); } mainw->fd_frame=frame; label = lives_standard_label_new(_("Preview")); lives_frame_set_label_widget(LIVES_FRAME(frame), label); lives_frame_set_shadow_type(LIVES_FRAME(frame), LIVES_SHADOW_NONE); mainw->framedraw=lives_event_box_new(); lives_widget_set_size_request(mainw->framedraw, width, height); lives_container_set_border_width(LIVES_CONTAINER(mainw->framedraw),1); lives_widget_set_events(mainw->framedraw, LIVES_BUTTON1_MOTION_MASK | LIVES_BUTTON_RELEASE_MASK | LIVES_BUTTON_PRESS_MASK| LIVES_ENTER_NOTIFY_MASK | LIVES_LEAVE_NOTIFY_MASK); mainw->framedraw_frame=start; lives_container_add(LIVES_CONTAINER(frame), fbord_eventbox); lives_container_add(LIVES_CONTAINER(fbord_eventbox), mainw->framedraw); if (palette->style&STYLE_1) { lives_widget_set_bg_color(mainw->framedraw, LIVES_WIDGET_STATE_NORMAL, &palette->normal_back); lives_widget_set_fg_color(mainw->framedraw, LIVES_WIDGET_STATE_NORMAL, &palette->normal_fore); } lives_signal_connect_after(LIVES_GUI_OBJECT(mainw->framedraw), LIVES_WIDGET_EXPOSE_EVENT, LIVES_GUI_CALLBACK(expose_fd_event), NULL); hbox = lives_hbox_new(FALSE, 2); lives_box_pack_start(LIVES_BOX(vbox), hbox, FALSE, FALSE, 0); mainw->framedraw_spinbutton = lives_standard_spin_button_new(_("_Frame"), TRUE,start,start,end,1.,10.,0,LIVES_BOX(hbox),NULL); spinbutton_adj=lives_spin_button_get_adjustment(LIVES_SPIN_BUTTON(mainw->framedraw_spinbutton)); mainw->framedraw_scale=lives_hscale_new(LIVES_ADJUSTMENT(spinbutton_adj)); lives_box_pack_start(LIVES_BOX(hbox), mainw->framedraw_scale, TRUE, TRUE, 0); lives_scale_set_draw_value(LIVES_SCALE(mainw->framedraw_scale),FALSE); rfx=(lives_rfx_t *)lives_widget_object_get_data(LIVES_WIDGET_OBJECT(lives_widget_get_toplevel(LIVES_WIDGET(box))),"rfx"); mainw->framedraw_preview = lives_button_new_from_stock(LIVES_STOCK_REFRESH,_("_Preview")); lives_box_pack_start(LIVES_BOX(hbox), mainw->framedraw_preview, TRUE, FALSE, 0); lives_widget_set_sensitive(mainw->framedraw_spinbutton,FALSE); lives_widget_set_sensitive(mainw->framedraw_scale,FALSE); lives_signal_connect(mainw->framedraw_preview, LIVES_WIDGET_CLICKED_SIGNAL,LIVES_GUI_CALLBACK(start_preview),rfx); lives_widget_show_all(vbox); if (!add_preview_button) { lives_widget_hide(mainw->framedraw_preview); } }
void on_live_tvcard_activate(LiVESMenuItem *menuitem, livespointer user_data) { int cardno=0; int new_file=mainw->first_free_file; int response; char *com,*tmp; char *fifofile=lives_strdup_printf("%s/tvpic.%d",prefs->tmpdir,capable->mainpid); char *chanstr; char *devstr; char *fname; LiVESWidget *card_dialog; lives_tvcardw_t *tvcardw; mainw->open_deint=FALSE; card_dialog=create_cdtrack_dialog(4,NULL); tvcardw=(lives_tvcardw_t *)lives_widget_object_get_data(LIVES_WIDGET_OBJECT(card_dialog),"tvcard_data"); response=lives_dialog_run(LIVES_DIALOG(card_dialog)); if (response==LIVES_RESPONSE_CANCEL) { lives_widget_destroy(card_dialog); lives_free(fifofile); lives_free(tvcardw); return; } cardno=(int)mainw->fx1_val; chanstr=lives_strdup_printf("%d",(int)mainw->fx2_val); if (lives_list_find(mainw->videodevs,LIVES_INT_TO_POINTER(cardno))) { lives_widget_destroy(card_dialog); do_card_in_use_error(); lives_free(chanstr); lives_free(fifofile); lives_free(tvcardw); return; } fname=lives_strdup_printf(_("TV card %d"),cardno); if (!get_new_handle(new_file,fname)) { lives_widget_destroy(card_dialog); lives_free(chanstr); lives_free(fifofile); lives_free(fname); lives_free(tvcardw); return; } devstr=lives_strdup_printf("/dev/video%d",cardno); if (!check_dev_busy(devstr)) { lives_widget_destroy(card_dialog); do_dev_busy_error(fname); lives_free(devstr); lives_free(chanstr); lives_free(fifofile); lives_free(fname); lives_free(tvcardw); return; } mainw->videodevs=lives_list_append(mainw->videodevs,LIVES_INT_TO_POINTER(cardno)); mainw->current_file=new_file; cfile->deinterlace=mainw->open_deint; unlink(fifofile); mkfifo(fifofile,S_IRUSR|S_IWUSR); if (!tvcardw->use_advanced) { com=lives_strdup_printf("%s open_tv_card \"%s\" \"%s\" \"%s\" \"%s\"",prefs->backend,cfile->handle,chanstr, devstr,fifofile); } else { double fps=0.; char *driver=NULL,*outfmt=NULL; int width=0,height=0; int input=lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(tvcardw->spinbuttoni)); if (!lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(tvcardw->radiobuttond))) { width=lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(tvcardw->spinbuttonw)); height=lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(tvcardw->spinbuttonh)); fps=lives_spin_button_get_value(LIVES_SPIN_BUTTON(tvcardw->spinbuttonf)); } driver=lives_combo_get_active_text(LIVES_COMBO(tvcardw->combod)); outfmt=lives_combo_get_active_text(LIVES_COMBO(tvcardw->comboo)); com=lives_strdup_printf("%s open_tv_card \"%s\" \"%s\" \"%s\" \"%s\" %d %d %d %.3f \"%s\" \"%s\"", prefs->backend,cfile->handle,chanstr, devstr,fifofile,input,width,height,fps,driver,outfmt); lives_free(driver); lives_free(outfmt); } lives_widget_destroy(card_dialog); lives_free(tvcardw); mainw->com_failed=FALSE; lives_system(com,FALSE); lives_free(com); if (mainw->com_failed) { mainw->com_failed=FALSE; lives_free(fname); lives_free(chanstr); lives_free(fifofile); lives_free(devstr); return; } if (!open_yuv4m_inner(fifofile,fname,new_file,YUV4_TYPE_TV,cardno)) { lives_free(fname); lives_free(chanstr); lives_free(fifofile); lives_free(devstr); return; } lives_snprintf(cfile->type,40,"%s",fname); d_print((tmp=lives_strdup_printf(_("Opened TV card %d (%s)"),cardno,devstr))); lives_free(tmp); lives_free(fname); lives_free(chanstr); lives_free(devstr); lives_free(fifofile); }