void file_actions_update (GimpActionGroup *group, gpointer data) { Gimp *gimp = action_data_get_gimp (data); GimpImage *image = action_data_get_image (data); GimpDrawable *drawable = NULL; const gchar *source = NULL; const gchar *export = NULL; gboolean show_overwrite = FALSE; if (image) { drawable = gimp_image_get_active_drawable (image); source = gimp_image_get_imported_uri (image); export = gimp_image_get_exported_uri (image); }
void file_save_cmd_callback (GtkAction *action, gint value, gpointer data) { Gimp *gimp; GimpDisplay *display; GimpImage *image; GtkWidget *widget; GimpSaveMode save_mode; const gchar *uri; gboolean saved = FALSE; return_if_no_gimp (gimp, data); return_if_no_display (display, data); return_if_no_widget (widget, data); image = gimp_display_get_image (display); save_mode = (GimpSaveMode) value; if (! gimp_image_get_active_drawable (image)) return; uri = gimp_image_get_uri (image); switch (save_mode) { case GIMP_SAVE_MODE_SAVE: case GIMP_SAVE_MODE_SAVE_AND_CLOSE: /* Only save if the image has been modified, or if it is new. */ if ((gimp_image_is_dirty (image) || ! GIMP_GUI_CONFIG (image->gimp->config)->trust_dirty_flag) || uri == NULL) { GimpPlugInProcedure *save_proc = gimp_image_get_save_proc (image); if (uri && ! save_proc) { save_proc = file_procedure_find (image->gimp->plug_in_manager->save_procs, uri, NULL); } if (uri && save_proc) { saved = file_save_dialog_save_image (GIMP_PROGRESS (display), gimp, image, uri, save_proc, GIMP_RUN_WITH_LAST_VALS, TRUE, FALSE, FALSE, TRUE); break; } /* fall thru */ } else { gimp_message_literal (image->gimp, G_OBJECT (display), GIMP_MESSAGE_INFO, _("No changes need to be saved")); saved = TRUE; break; } case GIMP_SAVE_MODE_SAVE_AS: file_save_dialog_show (gimp, image, widget, _("Save Image"), FALSE, save_mode == GIMP_SAVE_MODE_SAVE_AND_CLOSE, display); break; case GIMP_SAVE_MODE_SAVE_A_COPY: file_save_dialog_show (gimp, image, widget, _("Save a Copy of the Image"), TRUE, FALSE, display); break; case GIMP_SAVE_MODE_EXPORT: file_export_dialog_show (gimp, image, widget); break; case GIMP_SAVE_MODE_EXPORT_TO: case GIMP_SAVE_MODE_OVERWRITE: { const gchar *uri = NULL; GimpPlugInProcedure *export_proc; gboolean overwrite; if (save_mode == GIMP_SAVE_MODE_EXPORT_TO) { uri = gimp_image_get_exported_uri (image); if (! uri) { /* Behave as if Export... was invoked */ file_export_dialog_show (gimp, image, widget); break; } overwrite = FALSE; } else if (save_mode == GIMP_SAVE_MODE_OVERWRITE) { uri = gimp_image_get_imported_uri (image); overwrite = TRUE; } if (uri) { export_proc = file_procedure_find (image->gimp->plug_in_manager->export_procs, uri, NULL); } if (uri && export_proc) { char *uri_copy; /* The memory that 'uri' points to can be freed by file_save_dialog_save_image(), when it eventually calls gimp_image_set_imported_uri() to reset the imported uri, resulting in garbage. So make a duplicate of it here. */ uri_copy = g_strdup (uri); saved = file_save_dialog_save_image (GIMP_PROGRESS (display), gimp, image, uri_copy, export_proc, GIMP_RUN_WITH_LAST_VALS, FALSE, overwrite, ! overwrite, TRUE); g_free (uri_copy); } } break; } if (save_mode == GIMP_SAVE_MODE_SAVE_AND_CLOSE && saved && ! gimp_image_is_dirty (image)) { gimp_display_close (display); } }
static gboolean gimp_display_shell_close_time_changed (GimpMessageBox *box) { GimpImage *image = g_object_get_data (G_OBJECT (box), "gimp-image"); gint dirty_time = gimp_image_get_dirty_time (image); gchar *time_text = NULL; gchar *export_text = NULL; if (dirty_time) { gint hours = 0; gint minutes = 0; gimp_time_since (dirty_time, &hours, &minutes); if (hours > 0) { if (hours > 1 || minutes == 0) { time_text = g_strdup_printf (ngettext ("If you don't save the image, " "changes from the last hour " "will be lost.", "If you don't save the image, " "changes from the last %d " "hours will be lost.", hours), hours); } else { time_text = g_strdup_printf (ngettext ("If you don't save the image, " "changes from the last hour " "and %d minute will be lost.", "If you don't save the image, " "changes from the last hour " "and %d minutes will be lost.", minutes), minutes); } } else { time_text = g_strdup_printf (ngettext ("If you don't save the image, " "changes from the last minute " "will be lost.", "If you don't save the image, " "changes from the last %d " "minutes will be lost.", minutes), minutes); } } if (! gimp_image_is_export_dirty (image)) { const gchar *uri; gchar *filename; uri = gimp_image_get_exported_uri (image); if (! uri) uri = gimp_image_get_imported_uri (image); filename = file_utils_uri_to_utf8_filename (uri); export_text = g_strdup_printf (_("The image has been exported to '%s'."), filename); g_free (filename); } if (time_text && export_text) gimp_message_box_set_text (box, "%s\n\n%s", time_text, export_text); else if (time_text || export_text) gimp_message_box_set_text (box, "%s", time_text ? time_text : export_text); else gimp_message_box_set_text (box, "%s", time_text); g_free (time_text); g_free (export_text); return TRUE; }