void on_callback_font(GtkButton * button, gpointer user_data) { UNUSED_ARG(button); UNUSED_ARG(user_data); GUI_FileSelRead("TTF font to use", fontCB); }
void on_callback_mpeg(GtkButton * button, gpointer user_data) { UNUSED_ARG(button); UNUSED_ARG(user_data); GUI_FileSelRead("Mpeg to scan", mpegCB) ; }
void GUI_FileSelRead(const char *label, SELFILE_CB cb) { char *name; GUI_FileSelRead(label, &name); if (name) { cb(name); ADM_dealloc(name); } }
void on_callback_requant(GtkButton * button, gpointer user_data) { char *lame=NULL; GUI_FileSelRead("Where is M2VRequantizer ?", &lame); if(lame) { gtk_write_entry_string(WID(entryRequant), lame); } }
void on_callback_lvemux(GtkButton * button, gpointer user_data) { char *lame=NULL; gint r; GUI_FileSelRead("Where is lvemux ?", &lame); if(lame) { gtk_write_entry_string(WID(entryLvemux), lame); } }
JSBool fileReadSelect(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {// begin fileReadSelect char *name; // default return value if(argc != 0) return JS_FALSE; if(!name) return JS_FALSE; GUI_FileSelRead("Open file (Read mode)", &name); *rval=STRING_TO_JSVAL(JS_NewStringCopyZ(cx,name)); ADM_dealloc(name); return JS_TRUE; }// end fileReadSelect
uint8_t DIA_v2v(char **vobname, char **ifoname,char **vobsubname) { uint8_t ret=0; char *tmp=NULL,*tmp2=NULL,*tmp3=NULL; GtkWidget *dialog; dialog=create_dialog1(); gtk_register_dialog(dialog); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), WID(buttonVob),actionVOB); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), WID(buttonIfo),actionIFO); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), WID(buttonVobSub),actionVOBSUB); #define ENTRY_SET(x,y) {gtk_write_entry_string(WID(x),*y);} ENTRY_SET(entryIfo,ifoname); ENTRY_SET(entryVob,vobname); ENTRY_SET(entryVobSub,vobsubname); while(1) { switch(gtk_dialog_run(GTK_DIALOG(dialog))) { case actionVOB: { int r; GUI_FileSelRead(_("Select Vob file to scan"),&tmp); if(!tmp) continue; gtk_editable_delete_text(GTK_EDITABLE(WID(entryVob)), 0,-1); gtk_editable_insert_text(GTK_EDITABLE(WID(entryVob)), tmp, strlen(tmp), &r); ADM_dealloc(tmp); } break; case actionIFO: { int r; GUI_FileSelRead(_("Select ifo file to use"),&tmp); if(!tmp) continue; gtk_editable_delete_text(GTK_EDITABLE(WID(entryIfo)), 0,-1); gtk_editable_insert_text(GTK_EDITABLE(WID(entryIfo)), tmp, strlen(tmp), &r); ADM_dealloc(tmp); } break; case actionVOBSUB: { int r; GUI_FileSelWrite(_("Select vobsub to write"),&tmp); if(!tmp) continue; gtk_editable_delete_text(GTK_EDITABLE(WID(entryVobSub)), 0,-1); gtk_editable_insert_text(GTK_EDITABLE(WID(entryVobSub)), tmp, strlen(tmp), &r); ADM_dealloc(tmp); } break; break; case GTK_RESPONSE_OK: { tmp=gtk_editable_get_chars(GTK_EDITABLE (WID(entryVob)), 0, -1); if(!tmp || !*tmp) { GUI_Error_HIG(_("Invalid vobname"),_("Please select or enter a valid vob name")); continue; } tmp2=gtk_editable_get_chars(GTK_EDITABLE (WID(entryIfo)), 0, -1); if(!tmp2 || !*tmp2) { GUI_Error_HIG(_("Invalid ifo"),_("Please select or enter a valid ifo file")); continue; } tmp3=gtk_editable_get_chars(GTK_EDITABLE (WID(entryVobSub)), 0, -1); if(!tmp3 || !*tmp3 ) { GUI_Error_HIG(_("Invalid vobsubname"),_("Please select or enter a valid vobsub file")); continue; } if(*vobname) ADM_dealloc(*vobname); if(*ifoname) ADM_dealloc(*ifoname); if(*vobsubname) ADM_dealloc(*vobsubname); *vobname=*ifoname=*vobsubname=NULL; *vobname=ADM_strdup(tmp); *ifoname=ADM_strdup(tmp2); *vobsubname=(char *)ADM_alloc(strlen(tmp3)+5); //ADM_strdup(tmp3); strcpy(*vobsubname,tmp3); if(tmp3[strlen(tmp3)-1]!='x') strcat(*vobsubname,".idx"); ret=1; } default: goto _nxt; } } _nxt: gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); return ret; }
void HandleAction (Action action) { uint32_t nf = 0; uint32_t old; admScopedMutex autolock(&singleThread); // make sure only one thread at a time calls this ADM_warning("************ %s **************\n",getActionName(action)); // handle out of band actions // independant load not loaded //------------------------------------------------ if(action==ACT_RUN_SCRIPT) { GUI_FileSelRead("Select script/project to run", A_RunScript); return; } if (action >= ACT_SCRIPT_ENGINE_FIRST && action < ACT_SCRIPT_ENGINE_LAST) { int engineIndex = (action - ACT_SCRIPT_ENGINE_FIRST) / 3; int actionId = (action - ACT_SCRIPT_ENGINE_FIRST) % 3; tempEngine = getScriptEngines()[engineIndex]; switch (actionId) { case 0: GUI_FileSelRead("Select script to run", RunScript); break; case 1: GUI_FileSelRead("Select script to debug", DebugScript); break; case 2: GUI_FileSelWrite(QT_TRANSLATE_NOOP("adm","Select script to save"), SaveScript); UI_refreshCustomMenu(); break; } return; } if (action >= ACT_SCRIPT_ENGINE_SHELL_FIRST && action < ACT_SCRIPT_ENGINE_SHELL_LAST) { IScriptEngine *shellEngine = getScriptEngines()[action - ACT_SCRIPT_ENGINE_SHELL_FIRST]; if ((shellEngine->capabilities() & IScriptEngine::DebuggerShell) == IScriptEngine::DebuggerShell) { shellEngine->openDebuggerShell(); } else { interactiveScript(shellEngine); } return; } switch (action) { case ACT_TimeShift: A_TimeShift(); return; case ACT_Goto: brokenAct(); return; case ACT_AVS_PROXY: GUI_avsProxy(); return; case ACT_BUILT_IN: DIA_builtin(); return; case ACT_RECENT0: case ACT_RECENT1: case ACT_RECENT2: case ACT_RECENT3: { const char **name; int rank; name=prefs->get_lastfiles(); rank=(int)action-ACT_RECENT0; ADM_assert(name[rank]); A_openAvi (name[rank]); return; } case ACT_RECENT_PROJECT0: case ACT_RECENT_PROJECT1: case ACT_RECENT_PROJECT2: case ACT_RECENT_PROJECT3: { const char **name = prefs->get_lastprojectfiles(); int rank = (int)action - ACT_RECENT_PROJECT0; ADM_assert(name[rank]); call_scriptEngine(name[rank]); return; } case ACT_VIDEO_CODEC_CONFIGURE: videoEncoder6Configure(); return; case ACT_ContainerConfigure: { int index=UI_GetCurrentFormat(); ADM_mux_configure(index); return; } case ACT_VIDEO_CODEC_CHANGED: { int nw=UI_getCurrentVCodec(); videoEncoder6_SetCurrentEncoder(nw); return; } case ACT_AUDIO_CODEC_CHANGED: { int nw=UI_getCurrentACodec(); audioCodecSetByIndex(0,nw); return; } case ACT_PLUGIN_INFO: DIA_pluginsInfo(); return; case ACT_OPEN_APP_LOG: GUI_OpenApplicationLog(); return; case ACT_OPEN_APP_FOLDER: GUI_OpenApplicationDataFolder(); return; case ACT_ABOUT : DIA_about( ); return; case ACT_AUDIO_CODEC_CONFIGURE: audioCodecConfigure(0); return; case ACT_AUDIO_FILTERS: { EditableAudioTrack *ed=video_body->getDefaultEditableAudioTrack(); if(ed) ed->audioEncodingConfig.audioFilterConfigure(); } return; case ACT_PREFERENCES: if(playing) return; if(DIA_Preferences()) { ADM_info("Saving prefs\n"); prefs->save (); } return; case ACT_SavePref: prefs->save (); return; case ACT_EXIT: if(playing) { ADM_info("Stopping playback...\n"); GUI_PlayAvi(); } ADM_info("Closing ui\n"); UI_closeGui(); return; break; default: break; } if (playing) // only allow some action { switch (action) { case ACT_PlayAvi: case ACT_StopAvi: break; default: return; } } // not playing, // restict disabled uncoded actions if ((int) action >= ACT_DUMMY) { GUI_Error_HIG (QT_TRANSLATE_NOOP("adm","Not coded in this version"), NULL); return; } // allow only if avi loaded if (!avifileinfo) { switch (action) { case ACT_JOG: break; case ACT_OPEN_VIDEO: GUI_FileSelRead (QT_TRANSLATE_NOOP("adm","Select Video File..."), (SELFILE_CB *)A_openAvi); break; default: break; } return; } // Dispatch actions, we have a file loaded if(action>ACT_NAVIGATE_BEGIN && action < ACT_NAVIGATE_END) { return HandleAction_Navigate(action); } if(action>ACT_SAVE_BEGIN && action < ACT_SAVE_END) { return HandleAction_Save(action); } switch (action) { case ACT_SAVE_PY_SCRIPT: { IScriptEngine *engine=getPythonScriptEngine(); if(!engine) { GUI_Error_HIG("No engine","tinyPy script is not enabled in this build"); break; } char fileName[1024]; if(FileSel_SelectWrite("Saving tinypy project",fileName,1000, NULL)) { int l=strlen(fileName); if(l>3) { char *tail=fileName+l-3; if(tail[0]!='.'|| tail[1]!='p'|| tail[2]!='y') strcat(fileName,".py"); } A_saveScript(engine, fileName); } break; } break; case ACT_JOG: A_jog(); break; case ACT_CLOSE: GUI_close(); break; case ACT_ZOOM_1_4: case ACT_ZOOM_1_2: case ACT_ZOOM_1_1: case ACT_ZOOM_2_1: case ACT_ZOOM_4_1: currentZoom=(renderZoom)((action-ACT_ZOOM_1_4)+ZOOM_1_4); changePreviewZoom(currentZoom); admPreview::samePicture(); break; case ACT_AUDIO_SELECT_TRACK: A_audioTrack(); break; case ACT_OPEN_VIDEO: GUI_FileSelRead (QT_TRANSLATE_NOOP("adm","Select Video File..."),(SELFILE_CB *) A_openAvi); break; case ACT_APPEND_VIDEO: GUI_FileSelRead (QT_TRANSLATE_NOOP("adm","Select Video File to Append..."),(SELFILE_CB *) A_appendAvi); break; case ACT_VIDEO_PROPERTIES: DIA_properties (); break; case ACT_PlayAvi: GUI_PlayAvi (); break; #define TOGGLE_PREVIEW ADM_PREVIEW_OUTPUT case ACT_PreviewChanged: { ADM_PREVIEW_MODE oldpreview=getPreviewMode(),newpreview=(ADM_PREVIEW_MODE)UI_getCurrentPreview(); printf("Old preview %d, New preview mode : %d\n",oldpreview,newpreview); if(oldpreview==newpreview) { return; } admPreview::stop(); setPreviewMode(newpreview); admPreview::start(); // admPreview::update(curframe); } break; case ACT_StopAvi: if (playing) GUI_PlayAvi (); break; case ACT_SetPostProcessing: A_setPostproc(); break; case ACT_MarkA: case ACT_MarkB: { bool swapit=0; uint64_t markA,markB; uint64_t pts=admPreview::getCurrentPts(); if( prefs->get(FEATURES_SWAP_IF_A_GREATER_THAN_B, &swapit) != RC_OK ) swapit = 1; markA=video_body->getMarkerAPts(); markB=video_body->getMarkerBPts(); if (action == ACT_MarkA) markA=pts; else markB=pts; if (markA>markB && swapit ) // auto swap { uint64_t y; y = markA; markA=markB; markB=y; } video_body->setMarkerAPts(markA); video_body->setMarkerBPts(markB); UI_setMarkers (markA, markB); break; } case ACT_Copy: { uint64_t markA,markB; markA=video_body->getMarkerAPts(); markB=video_body->getMarkerBPts(); if(markA>markB) { uint64_t p=markA; markA=markB; markB=p; } video_body->copyToClipBoard (markA,markB); break; } case ACT_Paste: { uint64_t currentPts=video_body->getCurrentFramePts(); video_body->pasteFromClipBoard(currentPts); video_body->getVideoInfo (avifileinfo); A_ResetMarkers(); ReSync (); } break; break; case ACT_Undo: if (avifileinfo) { uint64_t currentPts=video_body->getCurrentFramePts(); if(video_body->undo()) { video_body->getVideoInfo(avifileinfo); ReSync(); A_ResetMarkers(); A_Rewind(); if(currentPts<=video_body->getVideoDuration()) GUI_GoToTime(currentPts); } } break; case ACT_ResetSegments: if(avifileinfo) if(GUI_Question(QT_TRANSLATE_NOOP("adm","Are you sure?"))) { video_body->resetSeg(); video_body->getVideoInfo (avifileinfo); A_ResetMarkers(); ReSync (); // forget last project file video_body->setProjectName(""); } break; case ACT_Delete: case ACT_Cut: { uint64_t a=video_body->getMarkerAPts(); uint64_t b=video_body->getMarkerBPts(); if(false==video_body->remove(a,b)) { GUI_Error_HIG("Cutting","Error while cutting out."); } else { A_ResetMarkers(); A_Resync(); // total duration & stuff // Rewind to first frame... //A_Rewind(); GUI_GoToTime(a); } } break; // set decoder option (post processing ...) case ACT_DecoderOption: video_body->setDecodeParam ( admPreview::getCurrentPts()); break; case ACT_VIDEO_FILTERS: GUI_handleVFilter(); break; case ACT_HEX_DUMP: GUI_showCurrentFrameHex(); break; case ACT_SIZE_DUMP: GUI_showSize(); break; case ACT_TimeShift: A_TimeShift(); break; default: printf ("\n unhandled action %d\n", action); ADM_assert (0); return; } }
uint8_t DIA_vobsub(vobSubParam *param) { char *name=NULL; int32_t shift; int ret,ext,r; ret=0; ext=0; if(param->subname) name=ADM_strdup(param->subname); shift=param->subShift; while(!ext) { dialog=create_dialog1(); gtk_register_dialog(dialog); //gtk_transient(dialog); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), WID(buttonSelect), GTK_RESPONSE_APPLY); fq=new GtkWidget*[ADM_MAX_LANGUAGE]; // Upload if any if(name) { update(name,param->index); } else { gtk_label_set_text(GTK_LABEL(WID(labelVobsub)),QT_TR_NOOP("none")); } gtk_write_entry(WID(entryShift),shift); r=gtk_dialog_run(GTK_DIALOG(dialog)); shift=gtk_read_entry(WID(entryShift)); switch(r) { case GTK_RESPONSE_APPLY: { char *file; GUI_FileSelRead(QT_TR_NOOP("Select .idx file"),&file); if(file) { if(name) ADM_dealloc(name); name=NULL; name=ADM_strdup(file); // Leak ? } } break; case GTK_RESPONSE_OK: ret=1; ext=1; if(name) { ADM_dealloc(name); } name=ADM_strdup(gtk_label_get_text(GTK_LABEL(WID(labelVobsub)))); if(param->subname) ADM_dealloc(param->subname); param->subname=name; // param->index=indeces[getRangeInMenu(WID(optionmenu1))]; param->subShift=shift; break; case GTK_RESPONSE_CANCEL: ret=0; ext=1; break; default: break; } delete [] fq; gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); } return ret; }
// // One of the button of the main dialog was pressed // Retrieve also the associated filter and handle // the action //______________________________________________________ void on_action (gui_act action) { uint32_t action_parameter; VF_FILTERS tag = VF_INVALID; action_parameter = 0; if (nb_active_filter > 1) if (getSelectionNumber(nb_active_filter - 1, WID(treeview0), stores[0], &action_parameter)) action_parameter++; switch (action) { case A_ADD: tag = getFilterFromSelection(); if (tag == VF_INVALID) break; CONFcouple *coup; videofilters[nb_active_filter].filter = filterCreateFromTag (tag, NULL, videofilters[nb_active_filter - 1].filter); videofilters[nb_active_filter].tag = tag; if(!videofilters[nb_active_filter].filter-> configure (videofilters[nb_active_filter - 1].filter)) { delete videofilters[nb_active_filter].filter; break; } videofilters[nb_active_filter].filter->getCoupledConf (&coup); videofilters[nb_active_filter].conf = coup; nb_active_filter++; updateFilterList (); setSelectionNumber(nb_active_filter-1, WID(treeview0), stores[0], nb_active_filter-2); break; case A_VCD: setVCD (); updateFilterList (); setSelectionNumber(nb_active_filter-1, WID(treeview0), stores[0], nb_active_filter-2); break; case A_SVCD: setSVCD (); updateFilterList (); setSelectionNumber(nb_active_filter-1, WID(treeview0), stores[0], nb_active_filter-2); break; case A_DVD: setDVD (); updateFilterList (); setSelectionNumber(nb_active_filter-1, WID(treeview0), stores[0], nb_active_filter-2); break; case A_HALFD1: setHalfD1 (); updateFilterList (); setSelectionNumber(nb_active_filter-1, WID(treeview0), stores[0], nb_active_filter-2); break; default: case A_DOUBLECLICK: printf ("Double clicked.."); case A_CONFIGURE: if(!action_parameter) break; if(!videofilters[action_parameter].filter-> configure (videofilters[action_parameter - 1].filter)) break; CONFcouple *couple; videofilters[action_parameter].filter->getCoupledConf (&couple); videofilters[action_parameter].conf = couple; getFirstVideoFilter (); updateFilterList (); setSelectionNumber(nb_active_filter-1, WID(treeview0), stores[0], action_parameter-1); break; case A_PARTIAL: if (!action_parameter) break; AVDMGenericVideoStream *replace; CONFcouple *conf; conf = videofilters[action_parameter].conf; if (videofilters[action_parameter].tag == VF_PARTIAL_FILTER) // cannot recurse { GUI_Error_HIG (QT_TR_NOOP("The filter is already partial"), NULL); break; } replace = new ADMVideoPartial (videofilters[action_parameter - 1]. filter, videofilters[action_parameter].tag, conf); if(replace->configure (videofilters[action_parameter - 1].filter)) { delete videofilters[action_parameter].filter; if (conf) delete conf; videofilters[action_parameter].filter = replace; replace->getCoupledConf (&conf); videofilters[action_parameter].conf = conf; videofilters[action_parameter].tag = VF_PARTIAL_FILTER; getFirstVideoFilter (); updateFilterList (); setSelectionNumber(nb_active_filter-1, WID(treeview0), stores[0], action_parameter-1); } else delete replace; break; case A_UP: if (action_parameter < 2) break; // swap action parameter & action parameter -1 FILTER tmp; memcpy (&tmp, &videofilters[action_parameter - 1], sizeof (FILTER)); memcpy (&videofilters[action_parameter - 1], &videofilters[action_parameter], sizeof (FILTER)); memcpy (&videofilters[action_parameter], &tmp, sizeof (FILTER)); getFirstVideoFilter (); // select action_parameter -1 updateFilterList (); setSelectionNumber (nb_active_filter - 1, WID(treeview0), stores[0], action_parameter - 2); break; case A_DOWN: if (((int) action_parameter < (int) (nb_active_filter - 1)) && (action_parameter)) { // swap action parameter & action parameter -1 FILTER tmp; memcpy (&tmp, &videofilters[action_parameter + 1], sizeof (FILTER)); memcpy (&videofilters[action_parameter + 1], &videofilters[action_parameter], sizeof (FILTER)); memcpy (&videofilters[action_parameter], &tmp, sizeof (FILTER)); getFirstVideoFilter (); updateFilterList (); setSelectionNumber (nb_active_filter - 1, WID(treeview0), stores[0], action_parameter); } break; case A_REMOVE: VF_FILTERS tag; AVDMGenericVideoStream *old; // we store the one we will delete if (action_parameter < 1) break; if (videofilters[action_parameter].conf) { delete videofilters[action_parameter].conf; videofilters[action_parameter].conf = NULL; } // recreate derivated filters for (uint32_t i = action_parameter + 1; i < nb_active_filter; i++) { delete videofilters[i - 1].filter; videofilters[i - 1].filter = filterCreateFromTag(videofilters[i].tag, videofilters[i].conf, videofilters[i - 2].filter); videofilters[i - 1].conf = videofilters[i].conf; videofilters[i - 1].tag = videofilters[i].tag; } delete videofilters[nb_active_filter - 1].filter; videofilters[nb_active_filter - 1].filter = NULL; nb_active_filter--; updateFilterList (); if(!setSelectionNumber(nb_active_filter-1, WID(treeview0), stores[0], action_parameter-1)) setSelectionNumber(nb_active_filter-1, WID(treeview0), stores[0], action_parameter-2); break; case A_DONE: break; case A_PREVIEW: if (!action_parameter) break; extern uint32_t curframe; DIA_filterPreview(QT_TR_NOOP("Preview"), videofilters[action_parameter].filter, curframe); break; case A_LOAD: #ifdef USE_LIBXML2 GUI_FileSelRead (QT_TR_NOOP("Load set of filters"), filterLoadXml); #else GUI_FileSelRead (QT_TR_NOOP("Load set of filters"), filterLoad); #endif updateFilterList (); setSelectionNumber(nb_active_filter-1, WID(treeview0), stores[0], 0); break; case A_CLOSE: //gtk_widget_destroy(dialog); gtk_signal_emit_by_name(GTK_OBJECT(dialog),"delete-event"); break; case A_SAVE: if (nb_active_filter < 2) { GUI_Error_HIG (QT_TR_NOOP("Nothing to save"), NULL); } else #ifdef USE_LIBXML2 GUI_FileSelWrite (QT_TR_NOOP("Save set of filters"), filterSaveXml); #else GUI_FileSelWrite (QT_TR_NOOP("Save set of filters"), filterSave); #endif break; #if 0 default: printf ("Unknown action :%d, action param %d\n", action, action_parameter); ADM_assert (0); #endif } //end of switch }
uint8_t DIA_animated(ANIMATED_PARAM *param) { uint8_t ret=0; GtkWidget *dialog; const char *entries[MAX_VIGNETTE]={"spinbuttonTC0","spinbuttonTC1","spinbuttonTC2", "spinbuttonTC3","spinbuttonTC4","spinbuttonTC5" }; dialog=create_dialog1(); gtk_register_dialog(dialog); CHECK_SET(checkbuttonStd,isNTSC); SPIN_SET(spinbuttonvignetteW,vignetteW); SPIN_SET(spinbuttonvignetteH,vignetteH); if(param->backgroundImg) ENTRY_SET(entryBgd,param->backgroundImg); for(int i=0;i<MAX_VIGNETTE;i++) { gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(dialog,entries[i])), (gfloat)param->timecode[i]) ; } ASSOCIATE(button1,LOAD_BGD); //gtk_widget_show(dialog); int action; while(1) { action=gtk_dialog_run(GTK_DIALOG(dialog)); if(action==LOAD_BGD) { char *nw; GUI_FileSelRead(_("Select background picture"), &nw); if(nw) { ENTRY_SET(entryBgd,nw); ADM_dealloc(nw); } continue; } break; } if(action==GTK_RESPONSE_OK) { CHECK_GET(checkbuttonStd,isNTSC); SPIN_GET(spinbuttonvignetteW,vignetteW); SPIN_GET(spinbuttonvignetteH,vignetteH); if(param->backgroundImg) ADM_dealloc(param->backgroundImg); param->backgroundImg=NULL; ENTRY_GET(entryBgd,param->backgroundImg); for(int i=0;i<MAX_VIGNETTE;i++) { param->timecode[i]=(uint32_t)gtk_spin_button_get_value(GTK_SPIN_BUTTON(lookup_widget(dialog,entries[i]))) ; } ret=1; } gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); return ret; }
uint8_t DIA_vobsub(vobSubParam *param) { char *name; int32_t shift; int ret,ext; ret = 0; ext = 0; name = param->subname; shift = param->subShift; while(!ext) { dialog = create_dialog1(); gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gtk_register_dialog(dialog); gtk_dialog_add_action_widget(GTK_DIALOG(dialog),WID(buttonSelect),GTK_RESPONSE_APPLY); fq = new GtkWidget*[ADM_MAX_LANGUAGE]; // update if any if(name) { update(name,param->index); gtk_label_set_text(GTK_LABEL(WID(labelVobsub)),name); } else { gtk_label_set_text(GTK_LABEL(WID(labelVobsub)),QT_TR_NOOP("none")); } gtk_write_entry(WID(entryShift),shift); switch(gtk_dialog_run(GTK_DIALOG(dialog))) { case GTK_RESPONSE_APPLY: char *file; GUI_FileSelRead(QT_TR_NOOP("Select .idx file"),&file); if(file) { ADM_dealloc(name); name = file; } shift = gtk_read_entry(WID(entryShift)); break; case GTK_RESPONSE_OK: if(!name) { GUI_Error_HIG(QT_TR_NOOP("Wrong VobSub parametering"),QT_TR_NOOP("The idx/sub file does not set.")); } else { param->subname = name; param->index = indeces[getRangeInMenu(WID(optionmenu1))]; param->subShift = gtk_read_entry(WID(entryShift)); ret = 1; ext = 1; } break; case GTK_RESPONSE_CANCEL: default: if(name != param->subname) { ADM_dealloc(name); } ret=0; ext=1; break; } delete [] fq; gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); } return ret; }
uint8_t DIA_ass(ASSParams *param) { uint8_t r=0; GtkWidget *dialog=create_dialog1(); gtk_register_dialog(dialog); SPIN_SET(spinbuttonScale,font_scale); SPIN_SET(spinbuttonSpacing,line_spacing); SPIN_SET(spinbuttonTop,top_margin); SPIN_SET(spinbuttonBottom,bottom_margin); if(param->subfile) { int r; char *s=(char *)(param->subfile); gtk_editable_delete_text(GTK_EDITABLE(WID(entrySub)), 0,-1); gtk_editable_insert_text(GTK_EDITABLE(WID(entrySub)), s, strlen(s), &r); } ASSOCIATE(button1,LOADSUB); /* Upload */ int x=0,d; while(!x) { d=gtk_dialog_run(GTK_DIALOG(dialog)); switch(d) { case LOADSUB: { char *name=NULL; GUI_FileSelRead("Select ASS/SSA file",&name); if(name) { int r; gtk_editable_delete_text(GTK_EDITABLE(WID(entrySub)), 0,-1); gtk_editable_insert_text(GTK_EDITABLE(WID(entrySub)), name, strlen(name), &r); ADM_dealloc(name); } } break; case GTK_RESPONSE_OK: case GTK_RESPONSE_APPLY: { SPIN_GET(spinbuttonScale,font_scale); SPIN_GET(spinbuttonSpacing,line_spacing); SPIN_GETI(spinbuttonTop,top_margin); SPIN_GETI(spinbuttonBottom,bottom_margin); char *n; if(param->subfile) { ADM_dealloc(param->subfile); param->subfile=NULL; } n=gtk_editable_get_chars(GTK_EDITABLE (WID(entrySub)), 0, -1); printf("Name :%s\n",n); param->subfile=(ADM_filename *)ADM_strdup(n); r=1; x=1; break; } default: r=0; x=1; break; } } gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); return r; }
/****************************************************************************************** Setup (input/output files etc..) *****************************************************************************************/ ReplyType setup(void) { int sel; char text[1024]; while(1) { //gtk_widget_set_sensitive(WID(buttonAccept),0); //gtk_widget_set_sensitive(WID(buttonSkip),0); //gtk_widget_set_sensitive(WID(entryEntry),0); GTK_PURGE; // Main loop : Only accept glyph load/save // Sub & srt select & start ocr gtk_widget_set_sensitive(WID(frameGlyph),1); gtk_widget_set_sensitive(WID(frameLoad),1); gtk_widget_set_sensitive(WID(buttonStart),1); gtk_widget_set_sensitive(WID(frameBitmap),0); //gtk_widget_set_sensitive(WID(Current_Glyph),0); switch(sel=gtk_dialog_run(GTK_DIALOG(dialog))) { case actionLoadVob: { subparam.index=lang_index; subparam.subname=NULL; if(DIA_vobsub(&subparam)) { lang_index=subparam.index; gtk_label_set_text(GTK_LABEL(WID(labelVobsub)),subparam.subname); } } break; case actionSaveSub: { char *srt=NULL; GUI_FileSelWrite(_("Select SRT to save"), &srt); if(srt) { gtk_label_set_text(GTK_LABEL(WID(labelSrt)),srt); } } break; case actionLoadGlyph: { char *gly=NULL; GUI_FileSelRead(_("Select Glyoh to save"), &gly); if(gly) { loadGlyph(gly); sprintf(text,"%03d",nbGlyphs); gtk_label_set_text(GTK_LABEL(WID(labelNbGlyphs)),text); } } break; case actionSaveGlyph: if(!nbGlyphs) { GUI_Error_HIG(_("No glyphs to save"), NULL); break; } saveGlyph(); break; case GTK_RESPONSE_CLOSE: printf("Close req\n"); return ReplyClose; default: printf("Other input:%d\n",sel); } // Everything selected, check if(sel==actionGo) return ReplyOk; } }
void on_callback_sub(GtkButton * button, gpointer user_data) { UNUSED_ARG(button); UNUSED_ARG(user_data); GUI_FileSelRead("Subtitle to load", indexSUB) ; }
/** \fn DIA_glyphEdit \brief Dialog to edit glyph */ uint8_t DIA_glyphEdit(void) { char *glyphName; admGlyph head(1,1); uint32_t nbGlyph=0; uint8_t ret=0; // First select a file GUI_FileSelRead(QT_TR_NOOP("Select GlyphFile to edit"), &glyphName); if(!glyphName) return 0; // Try to load it if(!loadGlyph(glyphName,&head,&nbGlyph) || !nbGlyph) { destroyGlyphTree(&head); return 0; } // Convert the linear glyph to glyph array admGlyph *glyphArray[nbGlyph]; admGlyph *cur=head.next; uint32_t idx=0; while(cur) { glyphArray[idx++]=cur; cur=cur->next; } ADM_assert(idx<=nbGlyph); nbGlyph=idx; // Glyph loaded, here we go currentGlyph=head.next; dialog=create_dialog1 (); gtk_register_dialog(dialog); // Register callbacks #define ASSOCIATE(x,y) gtk_dialog_add_action_widget (GTK_DIALOG (dialog), WID(x),y) #define CONNECT(x,y,z) gtk_signal_connect(GTK_OBJECT(WID(x)), #y,GTK_SIGNAL_FUNC(z), NULL); #define ACTION_PREV 10 #define ACTION_NEXT 20 #define ACTION_PREV_EMPTY 30 #define ACTION_NEXT_EMPTY 40 #define ACTION_SAVE 50 #define ACTION_DELETE 60 #define ACTION_ACTIVATE 70 #define ACTION_SEARCH 80 #define ACTION_REWIND 90 ASSOCIATE(buttonPrev,ACTION_PREV); ASSOCIATE(buttonNext,ACTION_NEXT); ASSOCIATE(buttonEmptyPrev,ACTION_PREV_EMPTY); ASSOCIATE(buttonNextEmpty,ACTION_NEXT_EMPTY); ASSOCIATE(buttonSave,ACTION_SAVE); ASSOCIATE(buttonDelete,ACTION_DELETE); ASSOCIATE(buttonSearch,ACTION_SEARCH); ASSOCIATE(buttonRewind,ACTION_REWIND); CONNECT(drawingarea1,expose_event,glyphDraw); CONNECT(entry1,activate,glyphActivate); gtk_widget_show(dialog); glyphUpdate(); while(1) { gint b=gtk_dialog_run(GTK_DIALOG(dialog)); switch(b) { case ACTION_REWIND: currentGlyph=head.next; glyphUpdate(); continue; case ACTION_SEARCH: { char *tomatch=NULL; { // Dialog Factory to the rescue ! diaElemText txt(&tomatch,QT_TR_NOOP("String"),NULL); diaElem *elems[]={&txt}; if(!diaFactoryRun(QT_TR_NOOP("Search string"),1,elems)) { continue; break; } } printf("Searched string <%s>\n",tomatch); while(currentGlyph->next) { currentGlyph=currentGlyph->next; glyphUpdate(); if(currentGlyph->code) { printf("%s vs %s\n",currentGlyph->code,tomatch); if(!strcmp(currentGlyph->code,tomatch)) { glyphUpdate(); break; } } } ADM_dezalloc(tomatch); if(!currentGlyph->next) GUI_Error_HIG(QT_TR_NOOP("End reached"),QT_TR_NOOP("No more glyphs")); } continue; break; ; case ACTION_PREV: printf("PREV\n"); if(currentGlyph!=head.next) { admGlyph *father; father=glyphSearchFather(currentGlyph,&head); if(father) { currentGlyph=father; glyphUpdate(); } } continue;break; case ACTION_NEXT: printf("NEXT\n"); if(currentGlyph->next) { currentGlyph=currentGlyph->next; glyphUpdate(); } continue;break; case ACTION_NEXT_EMPTY: printf("NEXT EMPTY\n"); while(1) { if(currentGlyph->next) { currentGlyph=currentGlyph->next; glyphUpdate(); if(!currentGlyph->code || !*(currentGlyph->code)) { break; } } else { GUI_Error_HIG(QT_TR_NOOP("End reached"),QT_TR_NOOP("No more glyphs")); break; } } continue;break; case ACTION_PREV_EMPTY: printf("PREV EMPTY\n"); while(1) { if(currentGlyph!=head.next) { admGlyph *father; father=glyphSearchFather(currentGlyph,&head); if(father) { currentGlyph=father; glyphUpdate(); if(!currentGlyph->code || !*(currentGlyph->code)) { break; } continue; } } GUI_Error_HIG(QT_TR_NOOP("Head reached"),QT_TR_NOOP("No more glyphs")); break; } continue;break; case ACTION_SAVE: saveGlyph(glyphName,&head,nbGlyph); continue;break; case ACTION_DELETE: { admGlyph *father; father=glyphSearchFather(currentGlyph,&head); ADM_assert(father); father->next=currentGlyph->next; delete currentGlyph; currentGlyph=father; if(father==&head && head.next) currentGlyph=head.next; nbGlyph--; glyphUpdate(); continue;break; } case ACTION_ACTIVATE: { const gchar *old; if(currentGlyph->code) delete [] currentGlyph->code; currentGlyph->code=NULL; // Retrieve new one old=gtk_entry_get_text (GTK_ENTRY (WID(entry1))); if(old && strlen(old)) { currentGlyph->code=new char[strlen(old)+1]; strcpy(currentGlyph->code,old); } } continue;break; } break; // exit while(1) } gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); destroyGlyphTree(&head); return ret; }