Mercurial > geeqie
changeset 1806:022456247824
Add the feature to add single keywords to selection
This patch adds a context menu entry to keywords to ad the current
keyword to all selected images.
author | mow |
---|---|
date | Sat, 27 Feb 2010 20:35:26 +0000 |
parents | fccac8fde6c0 |
children | 3a2aff957816 |
files | src/bar_keywords.c src/metadata.c src/metadata.h |
diffstat | 3 files changed, 81 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/bar_keywords.c Sat Feb 27 20:35:09 2010 +0000 +++ b/src/bar_keywords.c Sat Feb 27 20:35:26 2010 +0000 @@ -1085,6 +1085,62 @@ bar_keyword_tree_sync(pkd); } +/** + * \brief Callback for adding selected keyword to all selected images. + */ +static void bar_pane_keywords_add_to_selected_cb(GtkWidget *menu_widget, gpointer data) +{ + PaneKeywordsData *pkd = data; + GtkTreeIter iter; /* This is the iter which initial holds the current keyword */ + GtkTreeIter child_iter; + GtkTreeModel *model; + GtkTreeModel *keyword_tree; + GList *list, *work; + GList *keywords = NULL; + + GtkTextBuffer *keyword_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view)); + + /* Aquire selected keyword */ + if (pkd->click_tpath) + { + gboolean is_keyword = TRUE; + + model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)); + if (!gtk_tree_model_get_iter(model, &iter, pkd->click_tpath)) return; + gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_IS_KEYWORD, &is_keyword, -1); + if (!is_keyword) return; + } + else + return; + + keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); + gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter); + + list = keyword_list_pull(pkd->keyword_view); /* Get the left keyword view */ + + /* Now set the current image */ + keyword_tree_set(keyword_tree, &child_iter, &list); + + keyword_list_push(pkd->keyword_view, list); /* Set the left keyword view */ + string_list_free(list); + + bar_pane_keywords_changed(keyword_buffer, pkd); /* Get list of all keywords in the hierarchy */ + + gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter); + keywords = keyword_tree_get(keyword_tree, &child_iter); + + list = layout_selection_list(pkd->pane.lw); + work = list; + while (work) + { + FileData *fd = work->data; + work = work->next; + metadata_append_list(fd, KEYWORD_KEY, keywords); + } + filelist_free(list); + string_list_free(keywords); +} + static void bar_pane_keywords_menu_popup(GtkWidget *widget, PaneKeywordsData *pkd, gint x, gint y) { GtkWidget *menu; @@ -1102,6 +1158,10 @@ menu_item_add_divider(menu); + menu_item_add(menu, _("Add keyword to all selected images"), G_CALLBACK(bar_pane_keywords_add_to_selected_cb), pkd); + + menu_item_add_divider(menu); + if (pkd->click_tpath) { /* for the entry */
--- a/src/metadata.c Sat Feb 27 20:35:09 2010 +0000 +++ b/src/metadata.c Sat Feb 27 20:35:26 2010 +0000 @@ -1244,6 +1244,26 @@ } } +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;
--- a/src/metadata.h Sat Feb 27 20:35:09 2010 +0000 +++ b/src/metadata.h Sat Feb 27 20:35:26 2010 +0000 @@ -77,6 +77,7 @@ void keyword_set(GtkTreeStore *keyword_tree, GtkTreeIter *iter, const gchar *name, gboolean is_keyword); gboolean keyword_tree_is_set(GtkTreeModel *keyword_tree, GtkTreeIter *iter, GList *kw_list); void keyword_tree_set(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr, GList **kw_list); +GList *keyword_tree_get(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr); void keyword_tree_reset(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr, GList **kw_list); void keyword_delete(GtkTreeStore *keyword_tree, GtkTreeIter *iter_ptr);