added change notification to bar_info.c
authorVladimir Nadvornik <nadvornik@suse.cz>
Tue, 23 Dec 2008 20:53:44 +0000 (20:53 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Tue, 23 Dec 2008 20:53:44 +0000 (20:53 +0000)
src/bar_info.c
src/metadata.c

index b145825..79ff955 100644 (file)
@@ -680,11 +680,19 @@ static void bar_info_set_comment_replace(GtkWidget *button, gpointer data)
        bar_info_set_selection(bd, FALSE, TRUE, FALSE);
 }
 
+static void bar_info_notify_cb(FileData *fd, NotifyType type, gpointer data)
+{
+       BarInfoData *bd = data;
+       if (fd == bd->fd) bar_info_update(bd);
+}
+
 static void bar_info_changed(GtkTextBuffer *buffer, gpointer data)
 {
        BarInfoData *bd = data;
 
+       file_data_unregister_notify_func(bar_info_notify_cb, bd);
        bar_info_write(bd);
+       file_data_register_notify_func(bar_info_notify_cb, bd, NOTIFY_PRIORITY_LOW);
 }
 
 void bar_info_close(GtkWidget *bar)
@@ -701,6 +709,7 @@ static void bar_info_destroy(GtkWidget *widget, gpointer data)
 {
        BarInfoData *bd = data;
 
+       file_data_unregister_notify_func(bar_info_notify_cb, bd);
        bar_list = g_list_remove(bar_list, bd);
 
        file_data_unref(bd->fd);
@@ -897,6 +906,8 @@ GtkWidget *bar_info_new(FileData *fd, gint metadata_only, GtkWidget *bounding_wi
 
        bar_list = g_list_append(bar_list, bd);
 
+       file_data_register_notify_func(bar_info_notify_cb, bd, NOTIFY_PRIORITY_LOW);
+
        return bd->vbox;
 }
 
index aa3c247..c443fd9 100644 (file)
@@ -546,30 +546,37 @@ static gint metadata_xmp_read(FileData *fd, GList **keywords, gchar **comment)
                 * and the only way to get all keywords is to iterate through
                 * the item list.
                 */
-               for (item = exif_get_first_item(exif);
-                    item;
-                    item = exif_get_next_item(exif))
+                /* Read IPTC keywords only if there are no XMP keywords
+                 * IPTC does not have standard charset, thus the encoding may differ
+                 * from XMP and keyword merging is not reliable.
+                 */
+                if (!*keywords)
                        {
-                       guint tag;
-               
-                       tag = exif_item_get_tag_id(item);
-                       if (tag == 0x0019)
+                       for (item = exif_get_first_item(exif);
+                            item;
+                            item = exif_get_next_item(exif))
                                {
-                               gchar *tag_name = exif_item_get_tag_name(item);
-
-                               if (strcmp(tag_name, "Iptc.Application2.Keywords") == 0)
+                               guint tag;
+                       
+                               tag = exif_item_get_tag_id(item);
+                               if (tag == 0x0019)
                                        {
-                                       gchar *kw;
-                                       gchar *utf8_kw;
-
-                                       kw = exif_item_get_data_as_text(item);
-                                       if (!kw) continue;
-
-                                       utf8_kw = utf8_validate_or_convert(kw);
-                                       *keywords = g_list_append(*keywords, (gpointer) utf8_kw);
-                                       g_free(kw);
+                                       gchar *tag_name = exif_item_get_tag_name(item);
+        
+                                       if (strcmp(tag_name, "Iptc.Application2.Keywords") == 0)
+                                               {
+                                               gchar *kw;
+                                               gchar *utf8_kw;
+        
+                                               kw = exif_item_get_data_as_text(item);
+                                               if (!kw) continue;
+        
+                                               utf8_kw = utf8_validate_or_convert(kw);
+                                               *keywords = g_list_append(*keywords, (gpointer) utf8_kw);
+                                               g_free(kw);
+                                               }
+                                       g_free(tag_name);
                                        }
-                               g_free(tag_name);
                                }
                        }
                }