void fn_macro_p() /* play a macro */ { if (macro_mode != 0) alert_box(macro_already); else if (macro_size <= 0) alert_box("No macro recorded"); else { macro_mode = MACRO_PLAY; macro_pos = 0; } }
/* Return 1 if changed directory, 0 if directory was the same, -1 if tried * to change but failed */ static int fpick_enter_dirname(fpick_dd *dt, const char *name, int l) { char txt[PATHBUF], *ctxt; int res = 0; if (name) name = g_strndup(name, l); else { cmd_read(dt->combo, dt); name = g_strdup(dt->cdir); } gtkncpy(txt, name, PATHBUF); fpick_cleanse_path(txt); // Path might have been entered manually if (strcmp(txt, dt->txt_directory) && // Only do something if the directory is new ((res = fpick_scan_directory(dt, txt, NULL)) <= 0)) { // Directory doesn't exist so tell user ctxt = g_strdup_printf(__("Could not access directory %s"), name); alert_box(_("Error"), ctxt, NULL); g_free(ctxt); res = res < 0 ? 1 : -1; } g_free((char *)name); return (res); }
void fn_macro_e() /* end recording a macro */ { if (macro_mode == 0) { alert_box("Not recording a macro"); } else { if (macro_mode == MACRO_RECORD) { strcpy(message,"Macro recorded"); display_message(MESSAGE_KEY); } macro_mode = 0; } }
KEYPRESS input_char() { KEYPRESS c; /* all keyboard input should come through this function instead of calling gch() directly. This function normally just calls getc(), but will insert codes from the macro buffer instead if a macro is being executed */ if (macro_mode == MACRO_FINISHED) macro_mode = 0; #if (defined TARGET_CURSES) || (defined TARGET_WIN) if (macro_mode) nosleep = TRUE; else nosleep = FALSE; #endif if (macro_mode == MACRO_PLAY) { c = macro[macro_pos++]; if (macro_pos >= macro_size) macro_mode = MACRO_FINISHED; } else { if (unget_count > 0) { int l; c.key = _unget[0]; c.flags = 0; unget_count--; for (l=0; l<unget_count; l++) _unget[l] = _unget[l+1]; } else { c.key = gch(); c.flags = modifiers(); } } if (macro_mode == MACRO_RECORD) { if (macro_size >= MACRO_LENGTH) { macro_mode = 0; clear_keybuf(); alert_box("Macro too long"); } else macro[macro_size++] = c; } return c; }
int run_def_action(int action, char *sname, char *dname, int delay) { char *msg, *c8, *command = NULL; int res, code; switch (action) { case DA_GIF_CREATE: c8 = quote_spaces(sname); command = g_strdup_printf(CMD_GIF_CREATE, delay, c8, dname); free(c8); break; case DA_GIF_PLAY: #if (GTK_MAJOR_VERSION == 1) || defined GDK_WINDOWING_X11 /* 'gifviev' and 'animate' both are X-only */ command = g_strdup_printf(CMD_GIF_PLAY, sname); break; #else return (-1); #endif case DA_GIF_EDIT: command = g_strdup_printf("mtpaint -g %d -w \"%s.???\" -w \"%s.????\"" CMD_DETACH, delay, sname, sname); break; } res = system(command); if (res) { if (res > 0) code = WEXITSTATUS(res); else code = res; c8 = gtkuncpy(NULL, command, 0); msg = g_strdup_printf(__("Error %i reported when trying to run %s"), code, c8); alert_box(_("Error"), msg, NULL); g_free(msg); g_free(c8); } g_free(command); return (res); }
int show_html(char *browser, char *docs) { char buf[PATHBUF + 2], buf2[PATHBUF]; int i=-1; #ifdef WIN32 char *r; if (!docs || !docs[0]) { /* Use default path relative to installdir */ docs = buf + 1; i = GetModuleFileNameA(NULL, docs, PATHBUF); if (!i) return (-1); r = strrchr(docs, '\\'); if (!r) return (-1); r[1] = 0; strnncat(docs, HANDBOOK_LOCATION_WIN, PATHBUF); } #else /* Linux */ char *argv[5]; if (!docs || !docs[0]) { docs = HANDBOOK_LOCATION2; //FIXME // if (valid_file(docs) < 0) docs = HANDBOOK_LOCATION2; } #endif else docs = gtkncpy(buf + 1, docs, PATHBUF); if ((valid_file(docs) < 0)) { alert_box( _("Error"), _("I am unable to find the documentation. Either you need to download the mtPaint Handbook from the web site and install it, or you need to set the correct location in the Preferences window."), NULL); return (-1); } #ifdef WIN32 if (browser && !browser[0]) browser = NULL; if (browser) { /* Quote the filename */ i = strlen(docs); buf[0] = docs[i] = '"'; docs[i + 1] = '\0'; /* Rearrange parameters */ docs = gtkncpy(buf2, browser, PATHBUF); browser = buf; } if ((unsigned int)ShellExecuteA(NULL, "open", docs, browser, NULL, SW_SHOW) <= 32) i = -1; else i = 0; #else argv[1] = docs; argv[2] = NULL; /* Try to use default browser */ if (!browser || !browser[0]) { argv[0] = "xdg-open"; i = spawn_process(argv, NULL); if (!i) return (0); // System has xdg-utils installed // No xdg-utils - try "BROWSER" variable then browser = getenv("BROWSER"); } else browser = gtkncpy(buf2, browser, PATHBUF); if (!browser) browser = HANDBOOK_BROWSER; argv[0] = browser; i = spawn_process(argv, NULL); #endif if (i) alert_box( _("Error"), _("There was a problem running the HTML browser. You need to set the correct program name in the Preferences window."), NULL); return (i); }