Trim trailing white spaces.
[geeqie.git] / src / metadata.c
index cca2110..88c9cad 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Geeqie
  * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis, Laurent Monin
  *
@@ -62,6 +62,113 @@ static void metadata_legacy_delete(FileData *fd, const gchar *except);
 static gboolean metadata_file_read(gchar *path, GList **keywords, gchar **comment);
 
 
+/*
+ *-------------------------------------------------------------------
+ * long-term cache - keep keywords from whole dir in memory
+ *-------------------------------------------------------------------
+ */
+
+/* fd->cached metadata list of lists
+   each particular list contains key as a first entry, then the values
+*/
+
+static void metadata_cache_update(FileData *fd, const gchar *key, const GList *values)
+{
+       GList *work;
+       
+       work = fd->cached_metadata;
+       while (work)
+               {
+               GList *entry = work->data;
+               gchar *entry_key = entry->data;
+               
+               if (strcmp(entry_key, key) == 0)
+                       {
+                       /* key found - just replace values */
+                       GList *old_values = entry->next;
+                       entry->next = NULL;
+                       old_values->prev = NULL;
+                       string_list_free(old_values);
+                       work->data = g_list_append(entry, string_list_copy(values));
+                       DEBUG_1("updated %s %s\n", key, fd->path);
+                       return;
+                       }
+               work = work->next;
+               }
+       
+       /* key not found - prepend new entry */
+       fd->cached_metadata = g_list_prepend(fd->cached_metadata,
+                               g_list_prepend(string_list_copy(values), g_strdup(key)));
+       DEBUG_1("added %s %s\n", key, fd->path);
+
+}
+
+static const GList *metadata_cache_get(FileData *fd, const gchar *key)
+{
+       GList *work;
+       
+       work = fd->cached_metadata;
+       while (work)
+               {
+               GList *entry = work->data;
+               gchar *entry_key = entry->data;
+               
+               if (strcmp(entry_key, key) == 0)
+                       {
+                       /* key found */
+                       DEBUG_1("found %s %s\n", key, fd->path);
+                       return entry;
+                       }
+               work = work->next;
+               }
+       return NULL;
+       DEBUG_1("not found %s %s\n", key, fd->path);
+}
+
+static void metadata_cache_remove(FileData *fd, const gchar *key)
+{
+       GList *work;
+       
+       work = fd->cached_metadata;
+       while (work)
+               {
+               GList *entry = work->data;
+               gchar *entry_key = entry->data;
+               
+               if (strcmp(entry_key, key) == 0)
+                       {
+                       /* key found */
+                       string_list_free(entry);
+                       fd->cached_metadata = g_list_delete_link(fd->cached_metadata, work);
+                       DEBUG_1("removed %s %s\n", key, fd->path);
+                       return;
+                       }
+               work = work->next;
+               }
+       DEBUG_1("not removed %s %s\n", key, fd->path);
+}
+
+void metadata_cache_free(FileData *fd)
+{
+       GList *work;
+       if (fd->cached_metadata) DEBUG_1("freed %s\n", fd->path);
+       
+       work = fd->cached_metadata;
+       while (work)
+               {
+               GList *entry = work->data;
+               string_list_free(entry);
+               
+               work = work->next;
+               }
+       g_list_free(fd->cached_metadata);
+       fd->cached_metadata = NULL;
+}
+
+
+
+
+
 
 /*
  *-------------------------------------------------------------------
@@ -82,7 +189,7 @@ static void metadata_write_queue_add(FileData *fd)
                layout_util_status_update_write_all();
                }
 
-       if (metadata_write_idle_id) 
+       if (metadata_write_idle_id)
                {
                g_source_remove(metadata_write_idle_id);
                metadata_write_idle_id = 0;
@@ -126,6 +233,23 @@ gboolean metadata_write_queue_remove_list(GList *list)
        return ret;
 }
 
+void metadata_notify_cb(FileData *fd, NotifyType type, gpointer data)
+{
+       if (type & (NOTIFY_REREAD | NOTIFY_CHANGE))
+               {
+               metadata_cache_free(fd);
+               
+               if (g_list_find(metadata_write_queue, fd))
+                       {
+                       DEBUG_1("Notify metadata: %s %04x", fd->path, type);
+                       if (!isname(fd->path))
+                               {
+                               /* ignore deleted files */
+                               metadata_write_queue_remove(fd);
+                               }
+                       }
+               }
+}
 
 gboolean metadata_write_queue_confirm(gboolean force_dialog, FileUtilDoneFunc done_func, gpointer done_data)
 {
@@ -138,6 +262,13 @@ gboolean metadata_write_queue_confirm(gboolean force_dialog, FileUtilDoneFunc do
                FileData *fd = work->data;
                work = work->next;
                
+               if (!isname(fd->path))
+                       {
+                       /* ignore deleted files */
+                       metadata_write_queue_remove(fd);
+                       continue;
+                       }
+               
                if (fd->change) continue; /* another operation in progress, skip this file for now */
                
                to_approve = g_list_prepend(to_approve, file_data_ref(fd));
@@ -162,7 +293,7 @@ gboolean metadata_write_perform(FileData *fd)
        
        g_assert(fd->change);
        
-       if (fd->change->dest && 
+       if (fd->change->dest &&
            strcmp(extension_from_path(fd->change->dest), GQ_CACHE_EXT_METADATA) == 0)
                {
                success = metadata_legacy_write(fd);
@@ -171,23 +302,23 @@ gboolean metadata_write_perform(FileData *fd)
                }
 
        /* write via exiv2 */
-       /*  we can either use cached metadata which have fd->modified_xmp already applied 
+       /*  we can either use cached metadata which have fd->modified_xmp already applied
                                     or read metadata from file and apply fd->modified_xmp
            metadata are read also if the file was modified meanwhile */
-       exif = exif_read_fd(fd); 
+       exif = exif_read_fd(fd);
        if (!exif) return FALSE;
 
        success = (fd->change->dest) ? exif_write_sidecar(exif, fd->change->dest) : exif_write(exif); /* write modified metadata */
        exif_free_fd(fd, exif);
 
        if (fd->change->dest)
-               /* this will create a FileData for the sidecar and link it to the main file 
+               /* this will create a FileData for the sidecar and link it to the main file
                   (we can't wait until the sidecar is discovered by directory scanning because
-                   exif_read_fd is called before that and it would read the main file only and 
+                   exif_read_fd is called before that and it would read the main file only and
                    store the metadata in the cache)
                    FIXME: this does not catch new sidecars created by independent external programs
                */
-               file_data_unref(file_data_new_simple(fd->change->dest)); 
+               file_data_unref(file_data_new_group(fd->change->dest));
                
        if (success) metadata_legacy_delete(fd, fd->change->dest);
        return success;
@@ -236,6 +367,9 @@ gboolean metadata_write_list(FileData *fd, const gchar *key, const GList *values
                fd->modified_xmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)string_list_free);
                }
        g_hash_table_insert(fd->modified_xmp, g_strdup(key), string_list_copy((GList *)values));
+       
+       metadata_cache_remove(fd, key);
+       
        if (fd->exif)
                {
                exif_update_metadata(fd->exif, key, values);
@@ -253,7 +387,7 @@ gboolean metadata_write_list(FileData *fd, const gchar *key, const GList *values
                        FileData *sfd = work->data;
                        work = work->next;
                        
-                       if (filter_file_class(sfd->extension, FORMAT_CLASS_META)) continue; 
+                       if (filter_file_class(sfd->extension, FORMAT_CLASS_META)) continue;
 
                        metadata_write_list(sfd, key, values);
                        }
@@ -275,7 +409,7 @@ gboolean metadata_write_int(FileData *fd, const gchar *key, guint64 value)
 {
        gchar string[50];
        
-       g_snprintf(string, sizeof(string), "%ld", value);
+       g_snprintf(string, sizeof(string), "%llu", (unsigned long long) value);
        return metadata_write_string(fd, key, string);
 }
 
@@ -338,7 +472,7 @@ static gboolean metadata_legacy_write(FileData *fd)
        
        if (!have_keywords || !have_comment) metadata_file_read(metadata_pathl, &orig_keywords, &orig_comment);
        
-       success = metadata_file_write(metadata_pathl, 
+       success = metadata_file_write(metadata_pathl,
                                      have_keywords ? (GList *)keywords : orig_keywords,
                                      have_comment ? comment : orig_comment);
 
@@ -408,7 +542,7 @@ static gboolean metadata_file_read(gchar *path, GList **keywords, gchar **commen
        
        fclose(f);
 
-       if (keywords) 
+       if (keywords)
                {
                *keywords = g_list_reverse(list);
                }
@@ -450,7 +584,7 @@ static void metadata_legacy_delete(FileData *fd, const gchar *except)
        if (!fd) return;
 
        metadata_path = cache_find_location(CACHE_TYPE_METADATA, fd->path);
-       if (metadata_path && (!except || strcmp(metadata_path, except) != 0)) 
+       if (metadata_path && (!except || strcmp(metadata_path, except) != 0))
                {
                metadata_pathl = path_from_utf8(metadata_path);
                unlink(metadata_pathl);
@@ -459,10 +593,10 @@ static void metadata_legacy_delete(FileData *fd, const gchar *except)
                }
 
 #ifdef HAVE_EXIV2
-       /* without exiv2: do not delete xmp metadata because we are not able to convert it, 
+       /* 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)) 
+       if (metadata_path && (!except || strcmp(metadata_path, except) != 0))
                {
                metadata_pathl = path_from_utf8(metadata_path);
                unlink(metadata_pathl);
@@ -521,6 +655,7 @@ GList *metadata_read_list(FileData *fd, const gchar *key, MetadataFormat format)
 {
        ExifData *exif;
        GList *list = NULL;
+       const GList *cache_entry;
        if (!fd) return NULL;
 
        /* unwritten data overide everything */
@@ -530,7 +665,14 @@ GList *metadata_read_list(FileData *fd, const gchar *key, MetadataFormat format)
                if (list) return string_list_copy(list);
                }
 
-       /* 
+
+       if (format == METADATA_PLAIN && strcmp(key, KEYWORD_KEY) == 0
+           && (cache_entry = metadata_cache_get(fd, key)))
+               {
+               return string_list_copy(cache_entry->next);
+               }
+
+       /*
            Legacy metadata file is the primary source if it exists.
            Merging the lists does not make much sense, because the existence of
            legacy metadata file indicates that the other metadata sources are not
@@ -539,8 +681,15 @@ GList *metadata_read_list(FileData *fd, const gchar *key, MetadataFormat format)
        */
        if (strcmp(key, KEYWORD_KEY) == 0)
                {
-               if (metadata_legacy_read(fd, &list, NULL)) return list;
-               }
+               if (metadata_legacy_read(fd, &list, NULL))
+                       {
+                       if (format == METADATA_PLAIN)
+                               {
+                               metadata_cache_update(fd, key, list);
+                               }
+                       return list;
+                       }
+               }
        else if (strcmp(key, COMMENT_KEY) == 0)
                {
                gchar *comment = NULL;
@@ -555,6 +704,12 @@ GList *metadata_read_list(FileData *fd, const gchar *key, MetadataFormat format)
        if (!exif) return NULL;
        list = exif_get_metadata(exif, key, format);
        exif_free_fd(fd, exif);
+       
+       if (format == METADATA_PLAIN && strcmp(key, KEYWORD_KEY) == 0)
+               {
+               metadata_cache_update(fd, key, list);
+               }
+               
        return list;
 }
 
@@ -599,11 +754,11 @@ gdouble metadata_read_GPS_coord(FileData *fd, const gchar *key, gdouble fallback
                min = g_ascii_strtod(endptr + 1, &endptr);
                if (*endptr == ',')
                        sec = g_ascii_strtod(endptr + 1, &endptr);
-               else 
+               else
                        sec = 0.0;
                
                
-               if (*endptr == 'S' || *endptr == 'W' || *endptr == 'N' || *endptr == 'E') 
+               if (*endptr == 'S' || *endptr == 'W' || *endptr == 'N' || *endptr == 'E')
                        {
                        coord = deg + min /60.0 + sec / 3600.0;
                        ok = TRUE;
@@ -625,7 +780,7 @@ gboolean metadata_append_string(FileData *fd, const gchar *key, const char *valu
 {
        gchar *str = metadata_read_string(fd, key, METADATA_PLAIN);
        
-       if (!str) 
+       if (!str)
                {
                return metadata_write_string(fd, key, value);
                }
@@ -643,7 +798,7 @@ gboolean metadata_append_list(FileData *fd, const gchar *key, const GList *value
 {
        GList *list = metadata_read_list(fd, key, METADATA_PLAIN);
        
-       if (!list) 
+       if (!list)
                {
                return metadata_write_list(fd, key, values);
                }
@@ -806,7 +961,7 @@ gboolean meta_data_set_keyword_mark(FileData *fd, gint n, gboolean value, gpoint
 
        if (!!keyword_tree_is_set(GTK_TREE_MODEL(keyword_tree), &iter, keywords) != !!value)
                {
-               if (value) 
+               if (value)
                        {
                        keyword_tree_set(GTK_TREE_MODEL(keyword_tree), &iter, &keywords);
                        }
@@ -835,12 +990,12 @@ void meta_data_connect_mark_with_keyword(GtkTreeModel *keyword_tree, GtkTreeIter
        for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
                {
                file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &mark_func_data);
-               if (get_mark_func == meta_data_get_keyword_mark) 
+               if (get_mark_func == meta_data_get_keyword_mark)
                        {
                        GtkTreeIter old_kw_iter;
                        GList *old_path = mark_func_data;
                        
-                       if (keyword_tree_get_iter(keyword_tree, &old_kw_iter, old_path) && 
+                       if (keyword_tree_get_iter(keyword_tree, &old_kw_iter, old_path) &&
                            (i == mark || /* release any previous connection of given mark */
                             keyword_compare(keyword_tree, &old_kw_iter, kw_iter) == 0)) /* or given keyword */
                                {
@@ -977,7 +1132,7 @@ gboolean keyword_exists(GtkTreeModel *keyword_tree, GtkTreeIter *parent_ptr, Gtk
                                g_free(iter_casefold);
                                } // if (options->metadata.tags_cas...
                        }
-               if (ret) 
+               if (ret)
                        {
                        if (result) *result = iter;
                        break;
@@ -1065,7 +1220,7 @@ gboolean keyword_tree_get_iter(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr
                        if (!gtk_tree_model_iter_next(keyword_tree, &iter)) return FALSE;
                        }
                path = path->next;
-               if (!path) 
+               if (!path)
                        {
                        *iter_ptr = iter;
                        return TRUE;
@@ -1085,7 +1240,7 @@ static gboolean keyword_tree_is_set_casefold(GtkTreeModel *keyword_tree, GtkTree
                {
                /* for the purpose of expanding and hiding, a helper is set if it has any children set */
                GtkTreeIter child;
-               if (!gtk_tree_model_iter_children(keyword_tree, &child, &iter)) 
+               if (!gtk_tree_model_iter_children(keyword_tree, &child, &iter))
                        return FALSE; /* this should happen only on empty helpers */
 
                while (TRUE)
@@ -1225,6 +1380,26 @@ void keyword_tree_set(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr, GList *
                }
 }
 
+GList *keyword_tree_get(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr)
+{
+       GtkTreeIter iter = *iter_ptr;
+       GList *kw_list = NULL;
+
+       while (TRUE)
+               {
+               GtkTreeIter parent;
+
+               if (keyword_get_is_keyword(keyword_tree, &iter))
+                       {
+                       gchar *name = keyword_get_name(keyword_tree, &iter);
+                       kw_list = g_list_append(kw_list, name);
+                       }
+
+               if (!gtk_tree_model_iter_parent(keyword_tree, &parent, &iter)) return kw_list;
+               iter = parent;
+               }
+} // GList *keyword_tree_get(GtkTre...
+
 static void keyword_tree_reset1(GtkTreeModel *keyword_tree, GtkTreeIter *iter, GList **kw_list)
 {
        gchar *found;
@@ -1260,7 +1435,7 @@ static gboolean keyword_tree_check_empty_children(GtkTreeModel *keyword_tree, Gt
 {
        GtkTreeIter iter;
        
-       if (!gtk_tree_model_iter_children(keyword_tree, &iter, parent)) 
+       if (!gtk_tree_model_iter_children(keyword_tree, &iter, parent))
                return TRUE; /* this should happen only on empty helpers */
 
        while (TRUE)
@@ -1356,7 +1531,7 @@ static void keyword_hide_unset_in_recursive(GtkTreeStore *keyword_tree, GtkTreeI
                else
                        {
                        GtkTreeIter child;
-                       if (gtk_tree_model_iter_children(GTK_TREE_MODEL(keyword_tree), &child, &iter)) 
+                       if (gtk_tree_model_iter_children(GTK_TREE_MODEL(keyword_tree), &child, &iter))
                                {
                                keyword_hide_unset_in_recursive(keyword_tree, &child, id, keywords);
                                }
@@ -1417,70 +1592,70 @@ static GtkTreeIter keyword_tree_default_append(GtkTreeStore *keyword_tree, GtkTr
 
 void keyword_tree_new_default(void)
 {
-       GtkTreeIter i1, i2, i3;
+       GtkTreeIter i1, i2;
 
        if (!keyword_tree) keyword_tree_new();
 
-       i1 = keyword_tree_default_append(keyword_tree, NULL, _("People"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Family"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Free time"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Children"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Sport"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Culture"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Festival"), TRUE); 
-       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Nature"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Animal"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Bird"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Insect"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Pets"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Wildlife"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Zoo"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Plant"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Tree"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Flower"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Water"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("River"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Lake"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Sea"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Landscape"), TRUE); 
-       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Art"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Statue"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Painting"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Historic"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Modern"), TRUE); 
-       i1 = keyword_tree_default_append(keyword_tree, NULL, _("City"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Park"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Street"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Square"), TRUE); 
-       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Architecture"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Buildings"), FALSE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("House"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Cathedral"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Palace"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Castle"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Bridge"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Interior"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Historic"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Modern"), TRUE); 
-       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Places"), FALSE); 
-       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Conditions"), FALSE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Night"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Lights"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Reflections"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Sun"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Weather"), FALSE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Fog"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Rain"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Clouds"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Snow"), TRUE); 
-                       i3 = keyword_tree_default_append(keyword_tree, &i2, _("Sunny weather"), TRUE); 
-       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Photo"), FALSE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Edited"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Detail"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Macro"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Portrait"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Black and White"), TRUE); 
-               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Perspective"), TRUE); 
+       i1 = keyword_tree_default_append(keyword_tree, NULL, _("People"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Family"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Free time"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Children"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Sport"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Culture"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Festival"), TRUE);
+       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Nature"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Animal"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Bird"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Insect"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Pets"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Wildlife"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Zoo"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Plant"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Tree"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Flower"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Water"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("River"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Lake"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Sea"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Landscape"), TRUE);
+       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Art"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Statue"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Painting"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Historic"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Modern"), TRUE);
+       i1 = keyword_tree_default_append(keyword_tree, NULL, _("City"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Park"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Street"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Square"), TRUE);
+       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Architecture"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Buildings"), FALSE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("House"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Cathedral"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Palace"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Castle"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Bridge"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Interior"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Historic"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Modern"), TRUE);
+       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Places"), FALSE);
+       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Conditions"), FALSE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Night"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Lights"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Reflections"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Sun"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Weather"), FALSE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Fog"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Rain"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Clouds"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Snow"), TRUE);
+                       keyword_tree_default_append(keyword_tree, &i2, _("Sunny weather"), TRUE);
+       i1 = keyword_tree_default_append(keyword_tree, NULL, _("Photo"), FALSE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Edited"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Detail"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Macro"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Portrait"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Black and White"), TRUE);
+               i2 = keyword_tree_default_append(keyword_tree, &i1, _("Perspective"), TRUE);
 }
 
 
@@ -1497,7 +1672,7 @@ static void keyword_tree_node_write_config(GtkTreeModel *keyword_tree, GtkTreeIt
                write_char_option(outstr, indent, "name", name);
                g_free(name);
                write_bool_option(outstr, indent, "kw", keyword_get_is_keyword(keyword_tree, &iter));
-               if (gtk_tree_model_iter_children(keyword_tree, &children, &iter)) 
+               if (gtk_tree_model_iter_children(keyword_tree, &children, &iter))
                        {
                        WRITE_STRING(">");
                        indent++;
@@ -1505,7 +1680,7 @@ static void keyword_tree_node_write_config(GtkTreeModel *keyword_tree, GtkTreeIt
                        indent--;
                        WRITE_NL(); WRITE_STRING("</keyword>");
                        }
-               else 
+               else
                        {
                        WRITE_STRING("/>");
                        }
@@ -1542,7 +1717,7 @@ GtkTreeIter *keyword_add_from_config(GtkTreeStore *keyword_tree, GtkTreeIter *pa
 
                log_printf("unknown attribute %s = %s\n", option, value);
                }
-       if (name && name[0]) 
+       if (name && name[0])
                {
                GtkTreeIter iter;
                /* re-use existing keyword if any */