gthumb r2203 - in trunk: . libgthumb src
- From: mjc svn gnome org
- To: svn-commits-list gnome org
- Subject: gthumb r2203 - in trunk: . libgthumb src
- Date: Sun, 20 Jan 2008 20:58:29 +0000 (GMT)
Author: mjc
Date: Sun Jan 20 20:58:29 2008
New Revision: 2203
URL: http://svn.gnome.org/viewvc/gthumb?rev=2203&view=rev
Log:
2008-01-20 Michael J. Chudobiak <mjc svn gnome org>
* libgthumb/file-data.c: (file_data_update),
(file_data_update_info), (file_data_insert_metadata):
* libgthumb/file-data.h:
* libgthumb/gth-exif-utils.c: (get_metadata_time):
* libgthumb/gth-filter.c: (gth_test_match):
* libgthumb/gth-sort-utils.c: (gth_sort_by_exiftime_then_name):
* src/dlg-scripts.c: (get_date_strings):
* src/gth-exif-data-viewer.c: (gth_exif_data_viewer_update):
Various metadata tidy-ups. Was only working for jpegs, fixed that.
Modified:
trunk/ChangeLog
trunk/libgthumb/file-data.c
trunk/libgthumb/file-data.h
trunk/libgthumb/gth-exif-utils.c
trunk/libgthumb/gth-filter.c
trunk/libgthumb/gth-sort-utils.c
trunk/src/dlg-scripts.c
trunk/src/gth-exif-data-viewer.c
Modified: trunk/libgthumb/file-data.c
==============================================================================
--- trunk/libgthumb/file-data.c (original)
+++ trunk/libgthumb/file-data.c Sun Jan 20 20:58:29 2008
@@ -173,6 +173,7 @@
{
GnomeVFSFileInfo *info;
GnomeVFSResult result;
+ time_t old_mtime;
g_return_if_fail (fd != NULL);
@@ -180,6 +181,8 @@
fd->thumb_loaded = FALSE;
fd->thumb_created = FALSE;
+ old_mtime = fd->mtime;
+
info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (fd->path,
info,
@@ -206,7 +209,14 @@
fd->size = info->size;
fd->mtime = info->mtime;
fd->ctime = info->ctime;
- fd->exif_data_loaded = FALSE;
+
+ /* update metadata only if required */
+ if ((old_mtime != fd->mtime) && fd->exif_data_loaded) {
+ fd->exif_data_loaded = FALSE;
+ if (fd->metadata != NULL)
+ free_metadata (fd->metadata);
+ file_data_insert_metadata (fd);
+ }
gnome_vfs_file_info_unref (info);
}
@@ -218,6 +228,7 @@
{
GnomeVFSFileInfo *info;
GnomeVFSResult result;
+ time_t old_mtime;
g_return_if_fail (fd != NULL);
@@ -225,6 +236,8 @@
fd->thumb_loaded = FALSE;
fd->thumb_created = FALSE;
+ old_mtime = fd->mtime;
+
info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (fd->path,
info,
@@ -250,7 +263,14 @@
fd->size = info->size;
fd->mtime = info->mtime;
fd->ctime = info->ctime;
- fd->exif_data_loaded = FALSE;
+
+ /* update metadata only if required */
+ if ((old_mtime != fd->mtime) && fd->exif_data_loaded) {
+ fd->exif_data_loaded = FALSE;
+ if (fd->metadata != NULL)
+ free_metadata (fd->metadata);
+ file_data_insert_metadata (fd);
+ }
gnome_vfs_file_info_unref (info);
}
@@ -297,17 +317,15 @@
}
void
-file_data_load_exif_data (FileData *fd)
+file_data_insert_metadata (FileData *fd)
{
g_return_if_fail (fd != NULL);
if (fd->exif_data_loaded)
return;
-
+
fd->metadata = update_metadata (fd->metadata, fd->path, fd->mime_type);
-
fd->exif_time = get_metadata_time (fd->mime_type, fd->path, fd->metadata);
-
fd->exif_data_loaded = TRUE;
}
Modified: trunk/libgthumb/file-data.h
==============================================================================
--- trunk/libgthumb/file-data.h (original)
+++ trunk/libgthumb/file-data.h Sun Jan 20 20:58:29 2008
@@ -73,7 +73,7 @@
void file_data_update_all (FileData *fd,
gboolean fast_mime_type);
void file_data_load_comment_data (FileData *fd);
-void file_data_load_exif_data (FileData *fd);
+void file_data_insert_metadata (FileData *fd);
void file_data_update_comment (FileData *fd);
GList* file_data_list_from_uri_list (GList *list);
Modified: trunk/libgthumb/gth-exif-utils.c
==============================================================================
--- trunk/libgthumb/gth-exif-utils.c (original)
+++ trunk/libgthumb/gth-exif-utils.c Sun Jan 20 20:58:29 2008
@@ -35,6 +35,16 @@
#include "gth-gstreamer-utils.h"
+const char *DATE_TAG_NAMES[] = {
+ "DateTimeOriginal",
+ "exif.DateTimeOriginal",
+ "DateTimeDigitized",
+ "exif.DateTimeDigitized"
+ "DateTime",
+ "exif.DateTime",
+ "photoshop.DateCreated" };
+
+
ExifData *
gth_exif_data_new_from_uri (const char *uri)
{
@@ -173,87 +183,6 @@
}
-static time_t
-get_mplayer_time (const char *filename)
-{
- time_t time = 0;
- char *unesc_local_file_to_modify = NULL;
- char *local_file_to_modify = NULL;
- char *tmp_dir;
- char *tmp_filename;
- char *command;
- FILE *in_file;
- char buf[256];
-
- /* This is a quick hack using midentify. It would be nicer if we
- could use a more gnomish approach to extract video metadata.
- Can we use gstreamer? */
-
- if (filename == NULL)
- return (time_t) 0;
-
- unesc_local_file_to_modify = obtain_local_file (filename);
- if (unesc_local_file_to_modify == NULL)
- return (time_t) 0;
-
- local_file_to_modify = gnome_vfs_unescape_string (unesc_local_file_to_modify, NULL);
- g_free (unesc_local_file_to_modify);
-
- tmp_dir = get_temp_dir_name ();
- if (tmp_dir == NULL) {
- g_free (local_file_to_modify);
- return;
- }
- tmp_filename = get_temp_file_name (tmp_dir, NULL);
-
- /* midentify is a helper script supplied with mplayer. It can extract metadata
- like dates. The sed script below strips out everything before the "=" sign,
- removes backslashes, removes forward slashes with trailing white space,
- and then hopes that the date command can understand the result. */
- command = g_strconcat( "midentify '",
- local_file_to_modify,
- "' 2>/dev/null | grep ':' | sed -e 's/[^=]*=//' -e 's/\\\\//g' -e 's/\\/ / /g' | xargs -n 1 -i date --date '{}' +%s 2>/dev/null 1>",
- tmp_filename,
- NULL );
- system (command);
-
- in_file = fopen (tmp_filename, "r");
- while (fgets (buf, sizeof (buf), in_file)) {
- /* Next line if this doesn't work */
- if (sscanf (buf, "%d", &time) != 1)
- continue;
- /* OK if date > Jan 1 1980 */
- if (time > (time_t) 315550800)
- break;
- }
-
- debug (DEBUG_INFO, "mplayer timestamp read for %s: %d", filename, time);
-
- fclose (in_file);
-
- local_dir_remove_recursive (tmp_dir);
-
- g_free (tmp_filename);
- g_free (tmp_dir);
- g_free (local_file_to_modify);
- g_free (command);
-
- if (time < (time_t) 0)
- return (time_t) 0;
-
- return time;
-}
-
-const char *DATE_TAG_NAMES[] = {
- "DateTimeOriginal",
- "exif.DateTimeOriginal",
- "DateTimeDigitized",
- "exif.DateTimeDigitized"
- "DateTime",
- "exif.DateTime",
- "photoshop.DateCreated"
- };
-
gint
metadata_search (GthMetadata *a,
char *b)
@@ -266,44 +195,35 @@
const char *uri,
GList *md)
{
+ gboolean loaded_metadata = FALSE;
+
if (mime_type == NULL)
mime_type = get_mime_type (uri);
- if (mime_type_is (mime_type, "image/jpeg"))
- {
- gboolean loaded_metadata = FALSE;
- if (md == NULL)
- {
- md = update_metadata (NULL, uri, mime_type);
- loaded_metadata = TRUE;
- }
+ if (md == NULL) {
+ md = update_metadata (NULL, uri, mime_type);
+ loaded_metadata = TRUE;
+ }
- int i;
- int len = (sizeof (DATE_TAG_NAMES) / sizeof (DATE_TAG_NAMES[0])) + 1;
- char *date = NULL;
- for (i = 0; i < len && date == NULL; i++)
- {
- GList *search_result = g_list_find_custom (md, DATE_TAG_NAMES[i], (GCompareFunc)metadata_search);
- if (search_result != NULL)
- {
- GthMetadata *md_entry = search_result->data;
- date = g_strdup(md_entry->value);
- }
+ int i;
+ int len = (sizeof (DATE_TAG_NAMES) / sizeof (DATE_TAG_NAMES[0])) + 1;
+ char *date = NULL;
+
+ for (i = 0; i < len && date == NULL; i++) {
+ GList *search_result = g_list_find_custom (md, DATE_TAG_NAMES[i], (GCompareFunc)metadata_search);
+ if (search_result != NULL) {
+ GthMetadata *md_entry = search_result->data;
+ date = g_strdup(md_entry->value);
}
+ }
- if (loaded_metadata)
- free_metadata(md);
-
- if (date != NULL)
- return exif_string_to_time_t (date);
+ if (loaded_metadata)
+ free_metadata(md);
- else return (time_t) 0;
- }
-
- if (mime_type_is_video (mime_type))
- return get_mplayer_time (uri);
-
- return (time_t) 0;
+ if (date != NULL)
+ return exif_string_to_time_t (date);
+ else
+ return (time_t) 0;
}
Modified: trunk/libgthumb/gth-filter.c
==============================================================================
--- trunk/libgthumb/gth-filter.c (original)
+++ trunk/libgthumb/gth-filter.c Sun Jan 20 20:58:29 2008
@@ -342,7 +342,7 @@
break;
case GTH_TEST_SCOPE_DATE:
- file_data_load_exif_data (fdata);
+ file_data_insert_metadata (fdata);
if (fdata->exif_time != 0)
result = test_date (test, fdata->exif_time);
else
Modified: trunk/libgthumb/gth-sort-utils.c
==============================================================================
--- trunk/libgthumb/gth-sort-utils.c (original)
+++ trunk/libgthumb/gth-sort-utils.c Sun Jan 20 20:58:29 2008
@@ -101,8 +101,8 @@
/* Update the exif DateTime tags in memory if they haven't been
read yet, or if the file has changed. */
- file_data_load_exif_data (fd1);
- file_data_load_exif_data (fd2);
+ file_data_insert_metadata (fd1);
+ file_data_insert_metadata (fd2);
time1 = fd1->exif_time;
time2 = fd2->exif_time;
Modified: trunk/src/dlg-scripts.c
==============================================================================
--- trunk/src/dlg-scripts.c (original)
+++ trunk/src/dlg-scripts.c Sun Jan 20 20:58:29 2008
@@ -246,7 +246,7 @@
const gint date_str_replacement_size = date_str->len + 128;
FileData* fd = file_data_new_from_local_path (filename);
- file_data_load_exif_data (fd);
+ file_data_insert_metadata (fd);
time_t exif_time = fd->exif_time;
if (!exif_time)
Modified: trunk/src/gth-exif-data-viewer.c
==============================================================================
--- trunk/src/gth-exif-data-viewer.c (original)
+++ trunk/src/gth-exif-data-viewer.c Sun Jan 20 20:58:29 2008
@@ -436,14 +436,11 @@
if (edv->priv->view_file_info)
update_file_info (edv);
- /* Now read metadata */
- GList *metadata = NULL;
- metadata = update_metadata (metadata, edv->priv->file->path, edv->priv->file->mime_type);
+ /* Now read metadata, if it isn't already loaded */
+ file_data_insert_metadata (file_data);
/* Display the data */
- g_list_foreach (metadata, (GFunc) add_to_display, edv);
-
- free_metadata (metadata);
+ g_list_foreach (file_data->metadata, (GFunc) add_to_display, edv);
gtk_tree_view_expand_all (GTK_TREE_VIEW (edv->priv->image_exif_view));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]