fixes for a built without Exiv2
authorVladimir Nadvornik <nadvornik@suse.cz>
Tue, 30 Jun 2009 20:12:28 +0000 (20:12 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Tue, 30 Jun 2009 20:12:28 +0000 (20:12 +0000)
don't try to access XMP metadata if not compiled with Exiv2
some metadata options are valid without Exiv2, do not disable them

src/exif-common.c
src/exif.c
src/filedata.c
src/metadata.c
src/preferences.c
src/rcfile.c

index 6535a4c..3be7ccb 100644 (file)
@@ -619,9 +619,14 @@ ExifData *exif_read_fd(FileData *fd)
        
        /* CACHE_TYPE_XMP_METADATA file should exist only if the metadata are
         * not writable directly, thus it should contain the most up-to-date version */
+       sidecar_path = NULL;
+
+#ifdef HAVE_EXIV2
+       /* we are not able to handle XMP sidecars without exiv2 */
        sidecar_path = cache_find_location(CACHE_TYPE_XMP_METADATA, fd->path);
 
        if (!sidecar_path) sidecar_path = file_data_get_sidecar_path(fd, TRUE);
+#endif
 
        fd->exif = exif_read(fd->path, sidecar_path, fd->modified_xmp);
 
index ff98a8b..a68dc67 100644 (file)
@@ -1582,13 +1582,13 @@ void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list)
 
 gboolean exif_write(ExifData *exif)
 {
-       log_printf("Not compiled with EXIF write support");
+       log_printf("Not compiled with EXIF write support\n");
        return FALSE;
 }
 
 gboolean exif_write_sidecar(ExifData *exif, gchar *path)
 {
-       log_printf("Not compiled with EXIF write support");
+       log_printf("Not compiled with EXIF write support\n");
        return FALSE;
 }
 
index e6d575a..3455f7c 100644 (file)
@@ -1949,7 +1949,11 @@ gint file_data_verify_ci(FileData *fd)
                        /* If an existing metadata file exists, we will try writing to
                         * it's location regardless of the user's preference.
                         */
-                       gchar *metadata_path = cache_find_location(CACHE_TYPE_XMP_METADATA, fd->path);
+                       gchar *metadata_path = NULL;
+#ifdef HAVE_EXIV2
+                       /* but ignore XMP if we are not able to write it */
+                       metadata_path = cache_find_location(CACHE_TYPE_XMP_METADATA, fd->path);
+#endif
                        if (!metadata_path) metadata_path = cache_find_location(CACHE_TYPE_METADATA, fd->path);
                        
                        if (metadata_path && !access_file(metadata_path, W_OK))
index c6a0f36..c0a8082 100644 (file)
@@ -457,6 +457,10 @@ static void metadata_legacy_delete(FileData *fd, const gchar *except)
                g_free(metadata_pathl);
                g_free(metadata_path);
                }
+
+#ifdef HAVE_EXIV2
+       /* without exiv2: do not delete xmp metadata because we are not able to convert it, 
+          just ignore it */
        metadata_path = cache_find_location(CACHE_TYPE_XMP_METADATA, fd->path);
        if (metadata_path && (!except || strcmp(metadata_path, except) != 0)) 
                {
@@ -465,6 +469,7 @@ static void metadata_legacy_delete(FileData *fd, const gchar *except)
                g_free(metadata_pathl);
                g_free(metadata_path);
                }
+#endif
 }
 
 static gboolean metadata_legacy_read(FileData *fd, GList **keywords, gchar **comment)
index 74e8b10..4ae3c46 100644 (file)
@@ -1594,16 +1594,19 @@ static void config_tab_metadata(GtkWidget *notebook)
 
        vbox = scrolled_notebook_page(notebook, _("Metadata"));
 
-#ifndef HAVE_EXIV2
-       gtk_widget_set_sensitive(vbox, FALSE);
-#endif
 
        group = pref_group_new(vbox, FALSE, _("Metadata writing process"), GTK_ORIENTATION_VERTICAL);
+#ifndef HAVE_EXIV2
+       label = pref_label_new(group, _("Warning: Geeqie is built without Exiv2. Some options are disabled."));
+#endif
        label = pref_label_new(group, _("Metadata are written in the following order. The process ends after first success."));
        gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
 
        ct_button = pref_checkbox_new_int(group, _("1) Save metadata in image files, resp. sidecar files, according to the XMP standard"),
                              options->metadata.save_in_image_file, &c_options->metadata.save_in_image_file);
+#ifndef HAVE_EXIV2
+       gtk_widget_set_sensitive(ct_button, FALSE);
+#endif
 
        pref_checkbox_new_int(group, _("2) Save metadata in '.metadata' folder, local to image folder (non-standard)"),
                              options->metadata.enable_metadata_dirs, &c_options->metadata.enable_metadata_dirs);
@@ -1614,6 +1617,9 @@ static void config_tab_metadata(GtkWidget *notebook)
        g_free(text);
 
        group = pref_group_new(vbox, FALSE, _("Step 1: Write to image files"), GTK_ORIENTATION_VERTICAL);
+#ifndef HAVE_EXIV2
+       gtk_widget_set_sensitive(group, FALSE);
+#endif
 
        hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
        pref_checkbox_link_sensitivity(ct_button, hbox);
@@ -1628,6 +1634,9 @@ static void config_tab_metadata(GtkWidget *notebook)
                              options->metadata.confirm_write, &c_options->metadata.confirm_write);
 
        group = pref_group_new(vbox, FALSE, _("Step 2 and 3: write to Geeqie private files"), GTK_ORIENTATION_VERTICAL);
+#ifndef HAVE_EXIV2
+       gtk_widget_set_sensitive(group, FALSE);
+#endif
 
        pref_checkbox_new_int(group, _("Use GQview legacy metadata format (supports only keywords and comments) instead of XMP"),
                              options->metadata.save_legacy_format, &c_options->metadata.save_legacy_format);
@@ -1640,8 +1649,11 @@ static void config_tab_metadata(GtkWidget *notebook)
        pref_checkbox_new_int(group, _("Allow keywords to differ only in case"),
                              options->metadata.keywords_case_sensitive, &c_options->metadata.keywords_case_sensitive);
 
-       pref_checkbox_new_int(group, _("Write altered image orientation to the metadata"),
+       ct_button = pref_checkbox_new_int(group, _("Write altered image orientation to the metadata"),
                              options->metadata.write_orientation, &c_options->metadata.write_orientation);
+#ifndef HAVE_EXIV2
+       gtk_widget_set_sensitive(ct_button, FALSE);
+#endif
 
        group = pref_group_new(vbox, FALSE, _("Auto-save options"), GTK_ORIENTATION_VERTICAL);
 
index 39b4f26..102ce95 100644 (file)
@@ -877,6 +877,14 @@ static void options_parse_global(GQParserData *parser_data, GMarkupParseContext
 
 static void options_parse_global_end(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, gpointer data, GError **error)
 {
+#ifndef HAVE_EXIV2
+       /* some options do not work without exiv2 */
+       options->metadata.save_in_image_file = FALSE;
+       options->metadata.save_legacy_format = TRUE;
+       options->metadata.write_orientation = FALSE;
+       DEBUG_1("compiled without Exiv2 - disabling XMP write support");
+#endif
+
        /* on startup there are no layout windows and this just loads the editors */
        layout_editors_reload_all();
 }