/** \fn runOne \brief Run one job */ void jobsWindow::RunOne(bool b) { int sel = ui.tableWidget->currentRow(); printf("Selected %d\n", sel); if(sel >= 0 && sel < _nbJobs) { if(desc[sel].status == STATUS_SUCCEED) GUI_Info_HIG(ADM_LOG_INFO,QT_TR_NOOP("Already done"),QT_TR_NOOP("This script has already been successfully executed.")); else { desc[sel].status=STATUS_RUNNING; updateRows(); GUI_Quiet(); TLK_getDate(&(desc[sel].startDate)); if(parseECMAScript(_jobsName[sel])) desc[sel].status=STATUS_SUCCEED; else desc[sel].status=STATUS_FAILED; TLK_getDate(&(desc[sel].endDate)); updateRows(); GUI_Verbose(); } } }
void printJSError(JSContext *cx, const char *message, JSErrorReport *report) {// begin printJSError int quiet=isQuiet(); char buf[4]; FILE *fd = fopen(report->filename,"rb"); if(quiet) GUI_Verbose(); if( fd ){ fread(buf,1,4,fd); fclose(fd); } if( strncmp(buf,"//AD",4) ){ GUI_Error_HIG("Spidermonkey ECMAScript Error", "Not an ECMAScript file. Try open it with 'File' -> 'Open...'"); }else{ GUI_Error_HIG("Spidermonkey ECMAScript Error", "file: %s: line %d:\n Msg:%s\n", report->filename, report->lineno, message); } if(quiet) GUI_Quiet(); }// end printJSError
JSBool displayInfo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {// begin displayInfo // default return value if(argc != 1) return JS_FALSE; if(JSVAL_IS_STRING(argv[0]) == false) return JS_FALSE; char *stringa = JS_GetStringBytes(JSVAL_TO_STRING(argv[0])); GUI_Verbose(); GUI_Info(stringa); GUI_Quiet(); return JS_TRUE; }// end displayInfo
/** \fn RunAll \brief Run all jobs */ void jobsWindow::RunAll(bool b) { for(int sel=0;sel<_nbJobs;sel++) { if(desc[sel].status == STATUS_SUCCEED || desc[sel].status == STATUS_DELETED) continue; desc[sel].status=STATUS_RUNNING; updateRows(); GUI_Quiet(); TLK_getDate(&(desc[sel].startDate)); if(parseECMAScript(_jobsName[sel])) desc[sel].status=STATUS_SUCCEED; else desc[sel].status=STATUS_FAILED; TLK_getDate(&(desc[sel].endDate)); updateRows(); GUI_Verbose(); } }
//void automation(int argc, char **argv) int automation(void ) { static char **argv; static int argc; static int cur; static int myargc; static three_arg_type three; static two_arg_type two; static int index; argv=global_argv; argc=global_argc; usleep(100000); // let gtk start GUI_Quiet(); printf("\n *** Automated : %d entries*************\n",NB_AUTO); // we need to process argc-=1; cur=1; myargc=argc; while(myargc>0) { if(( *argv[cur]!='-') || (*(argv[cur]+1)!='-')) { if(cur==1) { A_openAvi(argv[cur]); } else printf("\n Found garbage %s\n",argv[cur]); cur+=1;myargc-=1; continue; } // else it begins with -- index= searchReactionTable(argv[cur]+2); if(index==-1) // not found { printf("\n Unknown command :%s\n",argv[cur] ); cur+=1;myargc-=1; } else { printf("%s-->%d\n", reaction_table[index].string,reaction_table[index].have_arg); switch( reaction_table[index].have_arg) { case 3: three=( three_arg_type) reaction_table[index].callback; three( argv[cur+1],argv[cur+2],argv[cur+3]); printf("\n arg: %d index %d\n",myargc,index); break; case 2: two=( two_arg_type) reaction_table[index].callback; two( argv[cur+1],argv[cur+2]); break; case 1: reaction_table[index].callback(argv[cur+1]); break; case 0: reaction_table[index].callback(NULL); break; default: ADM_assert(0); break; } cur+=1+reaction_table[index].have_arg; myargc-=1+reaction_table[index].have_arg; } } // end while GUI_Verbose(); printf("\n ********** Automation ended***********\n"); return 0; }
/** * \fn automation * @return */ int automation(void ) { static char **argv; static int argc; static int cur; static int myargc; static int index; static three_arg_type three; static two_arg_type two; argc=global_argc; argv = global_argv; //the port change has to be done before the video load for( int runParaSearch=2 ; runParaSearch < argc ; ){ if(*argv[runParaSearch] == '-' && *(argv[runParaSearch]+1) == '-') { index = searchReactionTable(argv[runParaSearch]+2); if(index != -1) { if(!strcmp(avs_port_change, argv[runParaSearch] +2 )) { A_set_avisynth_port(argv[runParaSearch+1]); break; } runParaSearch += reaction_table[index].have_arg +1; } else runParaSearch += 1; } else runParaSearch += 1; } printf("\n *** Automated : %" PRIu32" entries*************\n",(uint32_t)NB_AUTO); // we need to process argc-=1; cur=1; myargc=argc; while(myargc>0) { if(( *argv[cur]!='-') || (*(argv[cur]+1)!='-')) { if(cur==1) { loadCB(argv[cur]); } else printf("\n Found garbage %s\n",argv[cur]); cur+=1;myargc-=1; continue; } // else it begins with -- if(!strcmp(argv[cur]+2,"portable")) // portable mode switch has been already taken care of, ignore { cur++; myargc--; continue; } index= searchReactionTable(argv[cur]+2); if(index==-1) // not found { printf("\n Unknown command :%s\n",argv[cur] ); cur+=1;myargc-=1; } else { printf("%s-->%d\n", reaction_table[index].string,reaction_table[index].have_arg); one_arg_type call=reaction_table[index].callback; switch( reaction_table[index].have_arg) { case 3: three=(three_arg_type)call; three( argv[cur+1],argv[cur+2],argv[cur+3]); break; case 2: two=(two_arg_type)call; two( argv[cur+1],argv[cur+2]); break; case 1: call(argv[cur+1]); break; case 0: call(NULL); break; default: ADM_assert(0); break; } cur+=1+reaction_table[index].have_arg; myargc-=1+reaction_table[index].have_arg; } } // end while GUI_Verbose(); printf("\n ********** Automation ended***********\n"); return 0; // Do not call me anymore }
uint8_t DIA_job(uint32_t nb, char **name) { GtkListStore *store; GtkTreeViewColumn *column,*column2,*column3; GtkCellRenderer *renderer; int ret=0; GtkWidget *dialog; dialog=create_dialog1(); gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gtk_register_dialog(dialog); store=gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING,G_TYPE_STRING); // initialize our job structure jobs.dialog=dialog; jobs.nb=nb; jobs.name=name; jobs.status=new ADM_Job_Descriptor[nb]; jobs.store=store; memset(jobs.status,0,jobs.nb*sizeof(ADM_Job_Descriptor)); gtk_tree_view_set_model(GTK_TREE_VIEW(WID(treeview1)),GTK_TREE_MODEL (store)); gtk_tree_view_columns_autosize(GTK_TREE_VIEW(WID(treeview1))); // Add columns renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (QT_TR_NOOP(" Job Name "), renderer, "markup", (GdkModifierType) 0, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (WID(treeview1)), column); column2 = gtk_tree_view_column_new_with_attributes (QT_TR_NOOP("Started at"), renderer, "markup", (GdkModifierType) 1, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (WID(treeview1)), column2); column3 = gtk_tree_view_column_new_with_attributes (QT_TR_NOOP("Finished at"), renderer, "markup", (GdkModifierType) 2, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (WID(treeview1)), column3); // #define ASSOCIATE(x,y) gtk_dialog_add_action_widget (GTK_DIALOG (dialog), WID(x),y) ASSOCIATE(buttonDelete,COMMAND_DELETE); ASSOCIATE(buttonDeleteAll,COMMAND_DELETE_ALL); ASSOCIATE(buttonRunAll,COMMAND_RUN_ALL); ASSOCIATE(buttonRun,COMMAND_RUN); // int running=1; gtk_widget_set_usize(WID(treeview1), 180, 300); while(running) { int sel=0,event; updateStatus(); switch(event=gtk_dialog_run(GTK_DIALOG(dialog))) { case GTK_RESPONSE_OK : running=0;break; case GTK_RESPONSE_APPLY : running=0;break; case GTK_RESPONSE_CANCEL : case GTK_RESPONSE_DELETE_EVENT: running=0;break; case COMMAND_DELETE_ALL: if(GUI_Confirmation_HIG(QT_TR_NOOP("Sure!"),QT_TR_NOOP("Delete ALL jobs"),QT_TR_NOOP("Are you sure you want to delete all jobs ?"))) { for(int i=0;i<jobs.nb;i++) jobs.status[i].status=STATUS_DELETED; } break; case COMMAND_RUN: sel=getSelection(jobs.dialog); if(sel>=jobs.nb) break; jobs.status[sel].status=STATUS_RUNNING; updateStatus(); GUI_Quiet(); TLK_getDate(&(jobs.status[sel].startDate)); if(parseECMAScript(jobs.name[sel])) jobs.status[sel].status=STATUS_SUCCEED; else jobs.status[sel].status=STATUS_FAILED; TLK_getDate(&(jobs.status[sel].endDate)); updateStatus(); GUI_Verbose(); break; case COMMAND_RUN_ALL: GUI_Quiet(); for(int i=0;i<jobs.nb;i++) { if(jobs.status[i].status==STATUS_DELETED) continue; if(jobs.status[i].status==STATUS_SUCCEED) continue; jobs.status[i].status=STATUS_RUNNING; TLK_getDate(&(jobs.status[i].startDate)); updateStatus(); if(parseECMAScript(jobs.name[i])) jobs.status[i].status=STATUS_SUCCEED; else jobs.status[i].status=STATUS_FAILED; TLK_getDate(&(jobs.status[i].endDate)); } updateStatus(); GUI_Verbose(); break; case COMMAND_DELETE: sel=getSelection(jobs.dialog); if(sel>=jobs.nb) break; if(GUI_Confirmation_HIG(QT_TR_NOOP("Sure!"),QT_TR_NOOP("Delete job"),QT_TR_NOOP("Are you sure you want to delete %s job ?"),ADM_GetFileName(jobs.name[sel]))) { jobs.status[sel].status=STATUS_DELETED; } break; default: printf("Event:%d\n",event); GUI_Error_HIG("Jobs",QT_TR_NOOP("Unknown event"));break; } } gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); // Now delete the "deleted" jobs for(int i=0;i<jobs.nb;i++) { if(jobs.status[i].status==STATUS_DELETED) { unlink(jobs.name[i]); } } delete [] jobs.status; return ret; }