gboolean meta_data_set_keyword_mark(FileData *fd, gint n, gboolean value, gpointer data) { GList *path = data; GList *keywords = NULL; GtkTreeIter iter; if (!keyword_tree_get_iter(GTK_TREE_MODEL(keyword_tree), &iter, path)) return FALSE; keywords = metadata_read_list(fd, KEYWORD_KEY, METADATA_PLAIN); if (!!keyword_tree_is_set(GTK_TREE_MODEL(keyword_tree), &iter, keywords) != !!value) { if (value) { keyword_tree_set(GTK_TREE_MODEL(keyword_tree), &iter, &keywords); } else { keyword_tree_reset(GTK_TREE_MODEL(keyword_tree), &iter, &keywords); } metadata_write_list(fd, KEYWORD_KEY, keywords); } string_list_free(keywords); return TRUE; }
static void bar_pane_keywords_keyword_toggle(GtkCellRendererToggle *toggle, const gchar *path, gpointer data) { PaneKeywordsData *pkd = data; GtkTreeModel *model; GtkTreeIter iter; GtkTreePath *tpath; gboolean active; GList *list; GtkTreeIter child_iter; GtkTreeModel *keyword_tree; GtkTextBuffer *keyword_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view)); model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)); tpath = gtk_tree_path_new_from_string(path); gtk_tree_model_get_iter(model, &iter, tpath); gtk_tree_path_free(tpath); gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_TOGGLE, &active, -1); active = (!active); 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); if (active) keyword_tree_set(keyword_tree, &child_iter, &list); else keyword_tree_reset(keyword_tree, &child_iter, &list); g_signal_handlers_block_by_func(keyword_buffer, bar_pane_keywords_changed, pkd); keyword_list_push(pkd->keyword_view, list); string_list_free(list); g_signal_handlers_unblock_by_func(keyword_buffer, bar_pane_keywords_changed, pkd); /* call this just once in the end */ bar_pane_keywords_changed(keyword_buffer, pkd); /* bar_pane_keywords_change calls bar_keyword_tree_sync, no need to do it again bar_keyword_tree_sync(pkd); */ }