Commit aa1ca52a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Changed libgimpthumb API in a way that will make GtkFileChooser

2004-02-25  Michael Natterer  <mitch@gimp.org>

	Changed libgimpthumb API in a way that will make GtkFileChooser
	integration possible without doing major hacks:

	* libgimpthumb/gimpthumb-enums.h: added GimpThumbFileType enum
	and extended GimpThumbState enum.

	* libgimpthumb/gimpthumb-utils.[ch]: return GimpThumbFileType
	instead of gboolean from gimp_thumb_file_test().

	* libgimpthumb/gimpthumbnail.c
	* app/core/gimpimagefile.c: changed accordingly (the icons
	used for REMOTE, FOLDER and SPECIAL need to be changed).
parent 4ae2c548
2004-02-25 Michael Natterer <mitch@gimp.org>
Changed libgimpthumb API in a way that will make GtkFileChooser
integration possible without doing major hacks:
* libgimpthumb/gimpthumb-enums.h: added GimpThumbFileType enum
and extended GimpThumbState enum.
* libgimpthumb/gimpthumb-utils.[ch]: return GimpThumbFileType
instead of gboolean from gimp_thumb_file_test().
* libgimpthumb/gimpthumbnail.c
* app/core/gimpimagefile.c: changed accordingly (the icons
used for REMOTE, FOLDER and SPECIAL need to be changed).
2004-02-25 Michael Natterer <mitch@gimp.org>
* app/tools/gimpimagemaptool.c: cleanup.
......@@ -312,6 +312,8 @@ gimp_imagefile_name_changed (GimpObject *object)
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
gimp_viewable_set_stock_id (GIMP_VIEWABLE (imagefile), NULL);
gimp_thumbnail_set_uri (imagefile->thumbnail, gimp_object_get_name (object));
}
......@@ -379,8 +381,26 @@ gimp_imagefile_get_new_preview (GimpViewable *viewable,
temp_buf_free (temp_buf);
return scaled_buf;
temp_buf = scaled_buf;
}
gimp_viewable_set_stock_id (GIMP_VIEWABLE (imagefile), NULL);
}
else if (imagefile->thumbnail->image_state == GIMP_THUMB_STATE_REMOTE)
{
gimp_viewable_set_stock_id (GIMP_VIEWABLE (imagefile), "gtk-network");
}
else if (imagefile->thumbnail->image_state == GIMP_THUMB_STATE_FOLDER)
{
gimp_viewable_set_stock_id (GIMP_VIEWABLE (imagefile), "gtk-open");
}
else if (imagefile->thumbnail->image_state == GIMP_THUMB_STATE_SPECIAL)
{
gimp_viewable_set_stock_id (GIMP_VIEWABLE (imagefile), "gtk-harddisk");
}
else
{
gimp_viewable_set_stock_id (GIMP_VIEWABLE (imagefile), NULL);
}
return temp_buf;
......@@ -459,6 +479,16 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
imagefile->static_desc = TRUE;
break;
case GIMP_THUMB_STATE_FOLDER:
imagefile->description = _("Folder");
imagefile->static_desc = TRUE;
break;
case GIMP_THUMB_STATE_SPECIAL:
imagefile->description = _("Special File");
imagefile->static_desc = TRUE;
break;
case GIMP_THUMB_STATE_NOT_FOUND:
imagefile->description = _("Could not open");
imagefile->static_desc = TRUE;
......
......@@ -27,6 +27,19 @@
#define __GIMP_THUMB_ENUMS_H__
#define GIMP_TYPE_THUMB_FILE_TYPE (gimp_thumb_file_type_get_type ())
GType gimp_thumb_file_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_THUMB_FILE_TYPE_NONE,
GIMP_THUMB_FILE_TYPE_REGULAR,
GIMP_THUMB_FILE_TYPE_FOLDER,
GIMP_THUMB_FILE_TYPE_SPECIAL
} GimpThumbFileType;
#define GIMP_TYPE_THUMB_SIZE (gimp_thumb_size_get_type ())
GType gimp_thumb_size_get_type (void) G_GNUC_CONST;
......@@ -47,6 +60,8 @@ typedef enum
{
GIMP_THUMB_STATE_UNKNOWN,
GIMP_THUMB_STATE_REMOTE,
GIMP_THUMB_STATE_FOLDER,
GIMP_THUMB_STATE_SPECIAL,
GIMP_THUMB_STATE_NOT_FOUND,
GIMP_THUMB_STATE_EXISTS,
GIMP_THUMB_STATE_OLD,
......
......@@ -262,7 +262,8 @@ gimp_thumb_find_thumb (const gchar *uri,
{
thumb_name = g_build_filename (thumb_subdirs[i], name, NULL);
if (gimp_thumb_file_test (thumb_name, NULL, NULL))
if (gimp_thumb_file_test (thumb_name, NULL, NULL) ==
GIMP_THUMB_FILE_TYPE_REGULAR)
{
*size = thumb_sizes[i];
return thumb_name;
......@@ -275,7 +276,8 @@ gimp_thumb_find_thumb (const gchar *uri,
{
thumb_name = g_build_filename (thumb_subdirs[i], name, NULL);
if (gimp_thumb_file_test (thumb_name, NULL, NULL))
if (gimp_thumb_file_test (thumb_name, NULL, NULL) ==
GIMP_THUMB_FILE_TYPE_REGULAR)
{
*size = thumb_sizes[i];
return thumb_name;
......@@ -297,9 +299,10 @@ gimp_thumb_find_thumb (const gchar *uri,
* checks if the given @filename exists and returns modification time
* and file size in 64bit integer values.
*
* Return value: %TRUE if the file exists, %FALSE otherwise
* Return value: The type of the file, or #GIMP_THUMB_FILE_TYPE_NONE if
* the file doesn't exist.
**/
gboolean
GimpThumbFileType
gimp_thumb_file_test (const gchar *filename,
gint64 *mtime,
gint64 *size)
......@@ -308,17 +311,27 @@ gimp_thumb_file_test (const gchar *filename,
g_return_val_if_fail (filename != NULL, FALSE);
if (stat (filename, &s) == 0 && (S_ISREG (s.st_mode)))
if (stat (filename, &s) == 0)
{
if (mtime)
*mtime = s.st_mtime;
if (size)
*size = s.st_size;
if (mtime) *mtime = s.st_mtime;
if (size) *size = s.st_size;
if (S_ISREG (s.st_mode))
{
return GIMP_THUMB_FILE_TYPE_REGULAR;
}
else if (S_ISDIR (s.st_mode))
{
return GIMP_THUMB_FILE_TYPE_FOLDER;
}
return TRUE;
return GIMP_THUMB_FILE_TYPE_SPECIAL;
}
return FALSE;
if (mtime) *mtime = 0;
if (size) *size = 0;
return GIMP_THUMB_FILE_TYPE_NONE;
}
static void
......
......@@ -29,21 +29,21 @@
G_BEGIN_DECLS
gboolean gimp_thumb_init (const gchar *creator,
const gchar *thumb_basedir);
gboolean gimp_thumb_init (const gchar *creator,
const gchar *thumb_basedir);
const gchar * gimp_thumb_get_thumb_dir (GimpThumbSize size);
gboolean gimp_thumb_ensure_thumb_dir (GimpThumbSize size,
GError **error);
const gchar * gimp_thumb_get_thumb_dir (GimpThumbSize size);
gboolean gimp_thumb_ensure_thumb_dir (GimpThumbSize size,
GError **error);
gchar * gimp_thumb_name_from_uri (const gchar *uri,
GimpThumbSize size);
gchar * gimp_thumb_find_thumb (const gchar *uri,
GimpThumbSize *size);
gchar * gimp_thumb_name_from_uri (const gchar *uri,
GimpThumbSize size);
gchar * gimp_thumb_find_thumb (const gchar *uri,
GimpThumbSize *size);
gboolean gimp_thumb_file_test (const gchar *filename,
gint64 *mtime,
gint64 *size);
GimpThumbFileType gimp_thumb_file_test (const gchar *filename,
gint64 *mtime,
gint64 *size);
G_END_DECLS
......
......@@ -546,8 +546,8 @@ static void
gimp_thumbnail_update_image (GimpThumbnail *thumbnail)
{
GimpThumbState state;
gint64 filesize = 0;
gint64 mtime = 0;
gint64 filesize = 0;
if (! thumbnail->image_uri)
return;
......@@ -581,10 +581,25 @@ gimp_thumbnail_update_image (GimpThumbnail *thumbnail)
break;
default:
if (gimp_thumb_file_test (thumbnail->image_filename, &mtime, &filesize))
state = GIMP_THUMB_STATE_EXISTS;
else
state = GIMP_THUMB_STATE_NOT_FOUND;
switch (gimp_thumb_file_test (thumbnail->image_filename,
&mtime, &filesize))
{
case GIMP_THUMB_FILE_TYPE_REGULAR:
state = GIMP_THUMB_STATE_EXISTS;
break;
case GIMP_THUMB_FILE_TYPE_FOLDER:
state = GIMP_THUMB_STATE_FOLDER;
break;
case GIMP_THUMB_FILE_TYPE_SPECIAL:
state = GIMP_THUMB_STATE_SPECIAL;
break;
default:
state = GIMP_THUMB_STATE_NOT_FOUND;
break;
}
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment