gthumb r2243 - in trunk: . libgthumb src
- From: mjc svn gnome org
- To: svn-commits-list gnome org
- Subject: gthumb r2243 - in trunk: . libgthumb src
- Date: Sat, 2 Feb 2008 19:12:36 +0000 (GMT)
Author: mjc
Date: Sat Feb 2 19:12:35 2008
New Revision: 2243
URL: http://svn.gnome.org/viewvc/gthumb?rev=2243&view=rev
Log:
2008-02-02 Michael J. Chudobiak <mjc svn gnome org>
* libgthumb/gth-exif-utils.c: (update_and_save_metadata),
(update_metadata):
* libgthumb/gth-exiv2-utils.cpp:
* src/dlg-change-date.c: (ok_clicked):
Improved remote vfs support for metadata reading / writing.
Modified:
trunk/ChangeLog
trunk/libgthumb/gth-exif-utils.c
trunk/libgthumb/gth-exiv2-utils.cpp
trunk/src/dlg-change-date.c
Modified: trunk/libgthumb/gth-exif-utils.c
==============================================================================
--- trunk/libgthumb/gth-exif-utils.c (original)
+++ trunk/libgthumb/gth-exif-utils.c Sat Feb 2 19:12:35 2008
@@ -270,18 +270,52 @@
const char *tag_name,
const char *tag_value)
{
- char *from_local_file;
- char *to_local_file;
+ char *from_local_file;
+ char *to_local_file;
+ GnomeVFSFileInfo *to_info;
+ gboolean to_is_local;
+ gboolean remote_copy_ok;
+
+ /* FIXME: use the fancy async cache code? */
+
+ to_is_local = is_local_file (uri_dest);
+ from_local_file = obtain_local_file (uri_src);
+ to_local_file = obtain_local_file (uri_dest);
+
+ if (from_local_file == NULL) {
+ g_warning ("Can't update the metadata because the remote file %s has not yet been copied to the local cache. Skipping.\n", uri_src);
+ g_free (to_local_file);
+ return;
+ }
+
+ if (to_local_file == NULL) {
+ g_warning ("Can't update the metadata because the remote file %s has not yet been copied to the local cache. Skipping.\n", uri_dest);
+ g_free (from_local_file);
+ return;
+ }
- from_local_file = get_cache_filename_from_uri (uri_src);
- to_local_file = get_cache_filename_from_uri (uri_dest);
+ to_info = gnome_vfs_file_info_new ();
+ gnome_vfs_get_file_info (uri_dest,
+ to_info,
+ GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS|GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
write_metadata (from_local_file, to_local_file, tag_name, tag_value);
- /* to do: update non-local uri_dest */
+ if (!to_is_local) {
+ remote_copy_ok = copy_cache_file_to_remote_uri (to_local_file, uri_dest);
+
+ if (remote_copy_ok == TRUE) {
+ gnome_vfs_set_file_info (uri_dest,
+ to_info,
+ GNOME_VFS_SET_FILE_INFO_PERMISSIONS|GNOME_VFS_SET_FILE_INFO_OWNER);
+ } else {
+ g_warning ("Metadata update of remote file %s failed.\n", uri_dest);
+ }
+ }
g_free (from_local_file);
g_free (to_local_file);
+ gnome_vfs_file_info_unref (to_info);
}
@@ -359,6 +393,14 @@
local_file = get_cache_filename_from_uri (fd->path);
+ /* What if the remote file has not actually been copied to the cache?
+ In that case, do not bother to load the metadata, because it's
+ too slow. fd->exif_data_loaded will remain FALSE. */
+ if (!path_is_file (local_file)) {
+ g_warning ("Can't read the metadata because the remote file %s has not yet been copied to the local cache. Skipping.\n", fd->path);
+ return;
+ }
+
if (fd->mime_type == NULL)
file_data_update_mime_type (fd, FALSE);
Modified: trunk/libgthumb/gth-exiv2-utils.cpp
==============================================================================
--- trunk/libgthumb/gth-exiv2-utils.cpp (original)
+++ trunk/libgthumb/gth-exiv2-utils.cpp Sat Feb 2 19:12:35 2008
@@ -584,8 +584,8 @@
image2->writeMetadata();
}
- catch (const Exiv2::AnyError& e) {
+ catch (const Exiv2::AnyError& error) {
// TODO: signal an error to the caller?
- // (e.what() returns a const char* error message)
+ std::cerr << error << "\n";
}
}
Modified: trunk/src/dlg-change-date.c
==============================================================================
--- trunk/src/dlg-change-date.c (original)
+++ trunk/src/dlg-change-date.c Sat Feb 2 19:12:35 2008
@@ -163,63 +163,28 @@
if (is_active (data->cd_exif_checkbutton) ||
is_active (data->cd_exif_orig_checkbutton) ||
is_active (data->cd_exif_dig_checkbutton)) {
- char buf[32];
- struct tm tm;
+ char *buf;
+ struct tm tm;
- char *local_file_to_modify = NULL;
- GnomeVFSFileInfo *info;
- gboolean is_local;
- gboolean remote_copy_ok;
-
- is_local = is_local_file (fdata->path);
-
- /* If the original file is stored on a remote VFS location, copy it to a local
- temp file, modify it, then copy it back. This is easier than modifying the
- underlying jpeg code (and other code) to handle VFS URIs. */
-
- local_file_to_modify = obtain_local_file (fdata->path);
-
- if (local_file_to_modify == NULL) {
- _gtk_error_dialog_run (GTK_WINDOW (data->dialog),
- _("Could not create a local temporary copy of the remote file."));
- return;
- }
- info = gnome_vfs_file_info_new ();
- gnome_vfs_get_file_info (fdata->path, info, GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS|GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
-
- localtime_r(&mtime, &tm);
- snprintf (buf, 32, "%04d:%02d:%02d %02d:%02d:%02d ",
- tm.tm_year + 1900,
- tm.tm_mon + 1,
- tm.tm_mday,
- tm.tm_hour,
- tm.tm_min,
- tm.tm_sec );
+ localtime_r (&mtime, &tm);
+ buf = g_strdup_printf ("%04d:%02d:%02d %02d:%02d:%02d ",
+ tm.tm_year + 1900,
+ tm.tm_mon + 1,
+ tm.tm_mday,
+ tm.tm_hour,
+ tm.tm_min,
+ tm.tm_sec );
if (is_active (data->cd_exif_checkbutton))
- update_and_save_metadata (local_file_to_modify, local_file_to_modify, "Exif.Image.DateTime", buf);
+ update_and_save_metadata (fdata->path, fdata->path, "Exif.Image.DateTime", buf);
if (is_active (data->cd_exif_orig_checkbutton))
- update_and_save_metadata (local_file_to_modify, local_file_to_modify, "Exif.Photo.DateTimeOriginal", buf);
+ update_and_save_metadata (fdata->path, fdata->path, "Exif.Photo.DateTimeOriginal", buf);
if (is_active (data->cd_exif_dig_checkbutton))
- update_and_save_metadata (local_file_to_modify, local_file_to_modify, "Exif.Photo.DateTimeDigitized", buf);
-
- mtime++; // Step the time to enable sorting of pictures according to EXIF time
-
- if (!is_local)
- remote_copy_ok = copy_cache_file_to_remote_uri (local_file_to_modify, fdata->path);
-
- g_free (local_file_to_modify);
-
- if (!is_local && !remote_copy_ok) {
- _gtk_error_dialog_run (GTK_WINDOW (data->dialog),
- _("Could not move temporary file to remote location. Check remote permissions."));
- } else {
- gnome_vfs_set_file_info (fdata->path, info, GNOME_VFS_SET_FILE_INFO_PERMISSIONS|GNOME_VFS_SET_FILE_INFO_OWNER);
- }
+ update_and_save_metadata (fdata->path, fdata->path, "Exif.Photo.DateTimeDigitized", buf);
- gnome_vfs_file_info_unref (info);
+ g_free (buf);
}
file_list = g_list_prepend (file_list, fdata->path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]