static gchar * get_temp_name (const gchar *uri, gboolean *name_image) { gchar *basename; gchar *tmpname = NULL; if (name_image) *name_image = FALSE; basename = g_path_get_basename (uri); if (basename) { gchar *ext = strchr (basename, '.'); if (ext && strlen (ext)) { tmpname = gimp_temp_name (ext + 1); if (name_image) *name_image = TRUE; } g_free (basename); } if (! tmpname) tmpname = gimp_temp_name ("xxx"); return tmpname; }
static void make_preview (void) { destroy_preview (); if (jsvals.preview) { gchar *tn = gimp_temp_name ("jpeg"); if (! undo_touched) { /* we freeze undo saving so that we can avoid sucking up * tile cache with our unneeded preview steps. */ gimp_image_undo_freeze (preview_image_ID); undo_touched = TRUE; } save_image (tn, preview_image_ID, drawable_ID_global, orig_image_ID_global, TRUE, NULL); if (display_ID == -1) display_ID = gimp_display_new (preview_image_ID); } else { gtk_label_set_text (GTK_LABEL (preview_size), _("File size: unknown")); gimp_displays_flush (); } }
static GimpPDBStatusType save_image (const gchar *filename, gint32 image_ID, gint32 drawable_ID, gint32 run_mode) { GimpPDBStatusType status = GIMP_PDB_SUCCESS; gchar *ext; gchar *tmpname; gchar *mailcmd[3]; GPid mailpid; FILE *mailpipe; GError *error = NULL; ext = find_extension (filename); if (ext == NULL) return GIMP_PDB_CALLING_ERROR; /* get a temp name with the right extension and save into it. */ tmpname = gimp_temp_name (ext + 1); /* construct the "sendmail user@location" line */ mailcmd[0] = SENDMAIL; mailcmd[1] = mail_info.receipt; mailcmd[2] = NULL; /* create a pipe to sendmail */ mailpipe = sendmail_pipe (mailcmd, &mailpid); if (mailpipe == NULL) return GIMP_PDB_EXECUTION_ERROR; create_headers (mailpipe); fflush (mailpipe); if (! (gimp_file_save (run_mode, image_ID, drawable_ID, tmpname, tmpname) && valid_file (tmpname))) { goto error; } if (! to64 (tmpname, mailpipe, &error)) { g_message ("%s", error->message); g_error_free (error); goto error; } fprintf (mailpipe, "\n--GUMP-MIME-boundary--\n"); goto cleanup; error: /* stop sendmail from doing anything */ kill (mailpid, SIGINT); status = GIMP_PDB_EXECUTION_ERROR; cleanup: /* close out the sendmail process */ fclose (mailpipe); waitpid (mailpid, NULL, 0); g_spawn_close_pid (mailpid); /* delete the tmpfile that was generated */ g_unlink (tmpname); g_free (tmpname); return status; }
GimpPDBStatusType screenshot_osx_shoot (ScreenshotValues *shootvals, GdkScreen *screen, gint32 *image_ID, GError **error) { const gchar *mode = " "; const gchar *cursor = " "; gchar *delay = NULL; gchar *filename; gchar *quoted; gchar *command = NULL; switch (shootvals->shoot_type) { case SHOOT_REGION: mode = "-is"; break; case SHOOT_WINDOW: if (shootvals->decorate) mode = "-iwo"; else mode = "-iw"; break; case SHOOT_ROOT: mode = " "; if (shootvals->show_cursor) cursor = "-C"; break; default: g_return_val_if_reached (GIMP_PDB_CALLING_ERROR); break; } delay = g_strdup_printf ("-T %i", shootvals->select_delay); filename = gimp_temp_name ("png"); quoted = g_shell_quote (filename); command = g_strjoin (" ", "/usr/sbin/screencapture", mode, cursor, delay, quoted, NULL); g_free (quoted); g_free (delay); if (system ((const char *) command) == EXIT_SUCCESS) { *image_ID = gimp_file_load (GIMP_RUN_NONINTERACTIVE, filename, filename); gimp_image_set_filename (*image_ID, "screenshot.png"); g_unlink (filename); g_free (filename); g_free (command); return GIMP_PDB_SUCCESS; } g_free (command); g_free (filename); return GIMP_PDB_EXECUTION_ERROR; }