app: When importing a file, setup image state properly

When an opened file is not an .xcf file it is considered an imported
file. Adjust the state of the loaded image accordingly to reflect its
imported state. Store the import source and set that as 'Export to'
target.
This commit is contained in:
Martin Nordholts 2009-04-23 20:44:12 +02:00
parent c1a226bc74
commit e8531ce947
2 changed files with 39 additions and 12 deletions

View File

@ -73,15 +73,16 @@
#include "gimp-intl.h"
static void file_open_sanitize_image (GimpImage *image,
gboolean as_new);
static void file_open_convert_items (GimpImage *dest_image,
const gchar *basename,
GList *items);
static void file_open_handle_color_profile (GimpImage *image,
GimpContext *context,
GimpProgress *progress,
GimpRunMode run_mode);
static void file_open_sanitize_image (GimpImage *image,
gboolean as_new);
static void file_open_convert_items (GimpImage *dest_image,
const gchar *basename,
GList *items);
static void file_open_handle_color_profile (GimpImage *image,
GimpContext *context,
GimpProgress *progress,
GimpRunMode run_mode);
static gboolean file_open_file_proc_is_import (const GimpPlugInProcedure *file_proc);
/* public functions */
@ -203,6 +204,20 @@ file_open_image (Gimp *gimp,
file_open_handle_color_profile (image, context, progress, run_mode);
}
if (file_open_file_proc_is_import (file_proc))
{
/* Remember the import source */
g_object_set_data_full (G_OBJECT (image), GIMP_FILE_IMPORT_SOURCE_URI_KEY,
g_strdup (uri), (GDestroyNotify) g_free);
/* Set 'Export to' target to import source */
g_object_set_data_full (G_OBJECT (image), GIMP_FILE_EXPORT_TO_URI_KEY,
g_strdup (uri), (GDestroyNotify) g_free);
/* We shall treat this file as an Untitled file */
gimp_object_set_name (GIMP_OBJECT (image), NULL);
}
return image;
}
@ -709,3 +724,11 @@ file_open_handle_color_profile (GimpImage *image,
gimp_image_undo_enable (image);
}
}
static gboolean
file_open_file_proc_is_import (const GimpPlugInProcedure *file_proc)
{
return !(file_proc &&
file_proc->mime_type &&
strcmp (file_proc->mime_type, "image/xcf") == 0);
}

View File

@ -21,10 +21,14 @@
#ifndef __GIMP_FILE_H__
#define __GIMP_FILE_H__
/* Data keys for Gimp */
#define GIMP_FILE_OPEN_LAST_URI_KEY "gimp-file-open-last-uri"
#define GIMP_FILE_SAVE_LAST_URI_KEY "gimp-file-save-last-uri"
#define GIMP_FILE_SAVE_LAST_URI_KEY "gimp-file-save-last-uri"
#define GIMP_FILE_OPEN_LAST_URI_KEY "gimp-file-open-last-uri"
#define GIMP_FILE_SAVE_A_COPY_URI_KEY "gimp-file-save-a-copy-uri"
/* Data keys for GimpImage */
#define GIMP_FILE_SAVE_A_COPY_URI_KEY "gimp-file-save-a-copy-uri"
#define GIMP_FILE_EXPORT_TO_URI_KEY "gimp-file-export-to-uri"
#define GIMP_FILE_IMPORT_SOURCE_URI_KEY "gimp-file-import-source-uri"
#endif /* __GIMP_FILE_H__ */