4 * Copyright (C) 2008 - 2009 The Geeqie Team
8 * This software is released under the GNU General Public License (GNU GPL).
9 * Please read the included file COPYING for more information.
10 * This software comes with no warranty of any kind, use at your own risk!
13 #include <glib/gprintf.h>
16 #include "bar_keywords.h"
19 #include "history_list.h"
22 #include "ui_fileops.h"
24 #include "ui_utildlg.h"
33 static void bar_pane_keywords_keyword_update_all(void);
34 static void bar_pane_keywords_changed(GtkTextBuffer *buffer, gpointer data);
37 *-------------------------------------------------------------------
38 * keyword / comment utils
39 *-------------------------------------------------------------------
43 GList *keyword_list_pull(GtkWidget *text_widget)
48 text = text_widget_text_pull(text_widget);
49 list = string_to_keywords_list(text);
56 /* the "changed" signal should be blocked before calling this */
57 static void keyword_list_push(GtkWidget *textview, GList *list)
59 GtkTextBuffer *buffer;
60 GtkTextIter start, end;
62 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
63 gtk_text_buffer_get_bounds(buffer, &start, &end);
64 gtk_text_buffer_delete(buffer, &start, &end);
68 const gchar *word = list->data;
71 gtk_text_buffer_get_end_iter(buffer, &iter);
72 if (word) gtk_text_buffer_insert(buffer, &iter, word, -1);
73 gtk_text_buffer_get_end_iter(buffer, &iter);
74 gtk_text_buffer_insert(buffer, &iter, "\n", -1);
82 *-------------------------------------------------------------------
84 *-------------------------------------------------------------------
89 FILTER_KEYWORD_COLUMN_TOGGLE = 0,
90 FILTER_KEYWORD_COLUMN_MARK,
91 FILTER_KEYWORD_COLUMN_NAME,
92 FILTER_KEYWORD_COLUMN_IS_KEYWORD,
93 FILTER_KEYWORD_COLUMN_COUNT
96 static GType filter_keyword_column_types[] = {G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN};
98 typedef struct _PaneKeywordsData PaneKeywordsData;
99 struct _PaneKeywordsData
104 GtkWidget *keyword_view;
105 GtkWidget *keyword_treeview;
107 GtkTreePath *click_tpath;
109 gboolean expand_checked;
110 gboolean collapse_unchecked;
111 gboolean hide_unchecked;
118 typedef struct _ConfDialogData ConfDialogData;
119 struct _ConfDialogData
121 PaneKeywordsData *pkd;
122 GtkTreePath *click_tpath;
126 GtkWidget *edit_widget;
129 gboolean edit_existing;
132 static GList *bar_list = NULL;
135 static void bar_pane_keywords_write(PaneKeywordsData *pkd)
139 if (!pkd->fd) return;
141 list = keyword_list_pull(pkd->keyword_view);
143 metadata_write_list(pkd->fd, KEYWORD_KEY, list);
145 string_list_free(list);
148 gboolean bar_keyword_tree_expand_if_set_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
150 PaneKeywordsData *pkd = data;
153 gtk_tree_model_get(model, iter, FILTER_KEYWORD_COLUMN_TOGGLE, &set, -1);
155 if (set && !gtk_tree_view_row_expanded(GTK_TREE_VIEW(pkd->keyword_treeview), path))
157 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(pkd->keyword_treeview), path);
162 gboolean bar_keyword_tree_collapse_if_unset_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
164 PaneKeywordsData *pkd = data;
167 gtk_tree_model_get(model, iter, FILTER_KEYWORD_COLUMN_TOGGLE, &set, -1);
169 if (!set && gtk_tree_view_row_expanded(GTK_TREE_VIEW(pkd->keyword_treeview), path))
171 gtk_tree_view_collapse_row(GTK_TREE_VIEW(pkd->keyword_treeview), path);
176 static void bar_keyword_tree_sync(PaneKeywordsData *pkd)
180 GtkTreeModel *keyword_tree;
183 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
184 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
186 keywords = keyword_list_pull(pkd->keyword_view);
187 keyword_show_set_in(GTK_TREE_STORE(keyword_tree), model, keywords);
188 if (pkd->hide_unchecked) keyword_hide_unset_in(GTK_TREE_STORE(keyword_tree), model, keywords);
189 string_list_free(keywords);
191 gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(model));
193 if (pkd->expand_checked) gtk_tree_model_foreach(model, bar_keyword_tree_expand_if_set_cb, pkd);
194 if (pkd->collapse_unchecked) gtk_tree_model_foreach(model, bar_keyword_tree_collapse_if_unset_cb, pkd);
197 static void bar_pane_keywords_keyword_update_all(void)
204 PaneKeywordsData *pkd;
210 bar_keyword_tree_sync(pkd);
214 static void bar_pane_keywords_update(PaneKeywordsData *pkd)
216 GList *keywords = NULL;
217 GtkTextBuffer *keyword_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view));
219 g_signal_handlers_block_by_func(keyword_buffer, bar_pane_keywords_changed, pkd);
221 keywords = metadata_read_list(pkd->fd, KEYWORD_KEY, METADATA_PLAIN);
222 keyword_list_push(pkd->keyword_view, keywords);
223 bar_keyword_tree_sync(pkd);
224 string_list_free(keywords);
226 g_signal_handlers_unblock_by_func(keyword_buffer, bar_pane_keywords_changed, pkd);
230 void bar_pane_keywords_set_fd(GtkWidget *pane, FileData *fd)
232 PaneKeywordsData *pkd;
234 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
237 file_data_unref(pkd->fd);
238 pkd->fd = file_data_ref(fd);
240 bar_pane_keywords_update(pkd);
243 static void bar_pane_keywords_write_config(GtkWidget *pane, GString *outstr, gint indent)
245 PaneKeywordsData *pkd;
247 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
250 WRITE_NL(); WRITE_STRING("<pane_keywords ");
251 write_char_option(outstr, indent, "id", pkd->pane.id);
252 write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(pkd->pane.title)));
253 WRITE_BOOL(pkd->pane, expanded);
254 WRITE_CHAR(*pkd, key);
258 gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event)
260 PaneKeywordsData *pkd;
262 pkd = g_object_get_data(G_OBJECT(bar), "pane_data");
263 if (!pkd) return FALSE;
265 if (GTK_WIDGET_HAS_FOCUS(pkd->keyword_view)) return gtk_widget_event(pkd->keyword_view, event);
270 static void bar_pane_keywords_keyword_toggle(GtkCellRendererToggle *toggle, const gchar *path, gpointer data)
272 PaneKeywordsData *pkd = data;
278 GtkTreeIter child_iter;
279 GtkTreeModel *keyword_tree;
281 GtkTextBuffer *keyword_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view));
283 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
285 tpath = gtk_tree_path_new_from_string(path);
286 gtk_tree_model_get_iter(model, &iter, tpath);
287 gtk_tree_path_free(tpath);
289 gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_TOGGLE, &active, -1);
293 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
294 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter);
296 list = keyword_list_pull(pkd->keyword_view);
298 keyword_tree_set(keyword_tree, &child_iter, &list);
300 keyword_tree_reset(keyword_tree, &child_iter, &list);
302 g_signal_handlers_block_by_func(keyword_buffer, bar_pane_keywords_changed, pkd);
303 keyword_list_push(pkd->keyword_view, list);
304 string_list_free(list);
305 g_signal_handlers_unblock_by_func(keyword_buffer, bar_pane_keywords_changed, pkd);
307 /* call this just once in the end */
308 bar_pane_keywords_changed(keyword_buffer, pkd);
310 bar_pane_keywords_change calls bar_keyword_tree_sync, no need to do it again
311 bar_keyword_tree_sync(pkd);
315 void bar_pane_keywords_filter_modify(GtkTreeModel *model, GtkTreeIter *iter, GValue *value, gint column, gpointer data)
317 PaneKeywordsData *pkd = data;
318 GtkTreeModel *keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
319 GtkTreeIter child_iter;
321 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, iter);
323 memset(value, 0, sizeof (GValue));
327 case FILTER_KEYWORD_COLUMN_TOGGLE:
329 GList *keywords = keyword_list_pull(pkd->keyword_view);
330 gboolean set = keyword_tree_is_set(keyword_tree, &child_iter, keywords);
331 string_list_free(keywords);
333 g_value_init(value, G_TYPE_BOOLEAN);
334 g_value_set_boolean(value, set);
337 case FILTER_KEYWORD_COLUMN_MARK:
338 gtk_tree_model_get_value(keyword_tree, &child_iter, KEYWORD_COLUMN_MARK, value);
340 case FILTER_KEYWORD_COLUMN_NAME:
341 gtk_tree_model_get_value(keyword_tree, &child_iter, KEYWORD_COLUMN_NAME, value);
343 case FILTER_KEYWORD_COLUMN_IS_KEYWORD:
344 gtk_tree_model_get_value(keyword_tree, &child_iter, KEYWORD_COLUMN_IS_KEYWORD, value);
351 gboolean bar_pane_keywords_filter_visible(GtkTreeModel *keyword_tree, GtkTreeIter *iter, gpointer data)
353 GtkTreeModel *filter = data;
355 return !keyword_is_hidden_in(keyword_tree, iter, filter);
358 static void bar_pane_keywords_set_selection(PaneKeywordsData *pkd, gboolean append)
360 GList *keywords = NULL;
364 keywords = keyword_list_pull(pkd->keyword_view);
366 list = layout_selection_list(pkd->pane.lw);
370 FileData *fd = work->data;
375 metadata_append_list(fd, KEYWORD_KEY, keywords);
379 metadata_write_list(fd, KEYWORD_KEY, keywords);
384 string_list_free(keywords);
387 static void bar_pane_keywords_sel_add_cb(GtkWidget *button, gpointer data)
389 PaneKeywordsData *pkd = data;
391 bar_pane_keywords_set_selection(pkd, TRUE);
394 static void bar_pane_keywords_sel_replace_cb(GtkWidget *button, gpointer data)
396 PaneKeywordsData *pkd = data;
398 bar_pane_keywords_set_selection(pkd, FALSE);
401 static void bar_pane_keywords_populate_popup_cb(GtkTextView *textview, GtkMenu *menu, gpointer data)
403 PaneKeywordsData *pkd = data;
405 menu_item_add_divider(GTK_WIDGET(menu));
406 menu_item_add_stock(GTK_WIDGET(menu), _("Add keywords to selected files"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_keywords_sel_add_cb), pkd);
407 menu_item_add_stock(GTK_WIDGET(menu), _("Replace existing keywords in selected files"), GTK_STOCK_CONVERT, G_CALLBACK(bar_pane_keywords_sel_replace_cb), pkd);
411 static void bar_pane_keywords_notify_cb(FileData *fd, NotifyType type, gpointer data)
413 PaneKeywordsData *pkd = data;
414 if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pkd->fd) bar_pane_keywords_update(pkd);
417 static gboolean bar_pane_keywords_changed_idle_cb(gpointer data)
419 PaneKeywordsData *pkd = data;
421 file_data_unregister_notify_func(bar_pane_keywords_notify_cb, pkd);
422 bar_pane_keywords_write(pkd);
423 bar_keyword_tree_sync(pkd);
424 file_data_register_notify_func(bar_pane_keywords_notify_cb, pkd, NOTIFY_PRIORITY_LOW);
429 static void bar_pane_keywords_changed(GtkTextBuffer *buffer, gpointer data)
431 PaneKeywordsData *pkd = data;
433 if (pkd->idle_id != -1) return;
434 /* higher prio than redraw */
435 pkd->idle_id = g_idle_add_full(G_PRIORITY_HIGH_IDLE, bar_pane_keywords_changed_idle_cb, pkd, NULL);
440 *-------------------------------------------------------------------
442 *-------------------------------------------------------------------
446 static GtkTargetEntry bar_pane_keywords_drag_types[] = {
447 { TARGET_APP_KEYWORD_PATH_STRING, GTK_TARGET_SAME_WIDGET, TARGET_APP_KEYWORD_PATH },
448 { "text/plain", 0, TARGET_TEXT_PLAIN }
450 static gint n_keywords_drag_types = 2;
453 static GtkTargetEntry bar_pane_keywords_drop_types[] = {
454 { TARGET_APP_KEYWORD_PATH_STRING, GTK_TARGET_SAME_WIDGET, TARGET_APP_KEYWORD_PATH },
455 { "text/plain", 0, TARGET_TEXT_PLAIN }
457 static gint n_keywords_drop_types = 2;
460 static void bar_pane_keywords_dnd_get(GtkWidget *tree_view, GdkDragContext *context,
461 GtkSelectionData *selection_data, guint info,
462 guint time, gpointer data)
466 GtkTreeIter child_iter;
467 GtkTreeModel *keyword_tree;
469 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
471 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) return;
473 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
474 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter);
478 case TARGET_APP_KEYWORD_PATH:
480 GList *path = keyword_tree_get_path(keyword_tree, &child_iter);
481 gtk_selection_data_set(selection_data, selection_data->target,
482 8, (gpointer) &path, sizeof(path));
486 case TARGET_TEXT_PLAIN:
489 gchar *name = keyword_get_name(keyword_tree, &child_iter);
490 gtk_selection_data_set_text(selection_data, name, -1);
497 static void bar_pane_keywords_dnd_begin(GtkWidget *tree_view, GdkDragContext *context, gpointer data)
501 GtkTreeIter child_iter;
502 GtkTreeModel *keyword_tree;
505 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
507 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) return;
509 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
510 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter);
512 name = keyword_get_name(keyword_tree, &child_iter);
514 dnd_set_drag_label(tree_view, context, name);
519 static void bar_pane_keywords_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
524 static gboolean bar_pane_keywords_dnd_can_move(GtkTreeModel *keyword_tree, GtkTreeIter *src_kw_iter, GtkTreeIter *dest_kw_iter)
529 if (dest_kw_iter && keyword_same_parent(keyword_tree, src_kw_iter, dest_kw_iter))
531 return TRUE; /* reordering of siblings is ok */
533 if (!dest_kw_iter && !gtk_tree_model_iter_parent(keyword_tree, &parent, src_kw_iter))
535 return TRUE; /* reordering of top-level siblings is ok */
538 src_name = keyword_get_name(keyword_tree, src_kw_iter);
539 if (keyword_exists(keyword_tree, NULL, dest_kw_iter, src_name, FALSE, NULL))
548 static gboolean bar_pane_keywords_dnd_skip_existing(GtkTreeModel *keyword_tree, GtkTreeIter *dest_kw_iter, GList **keywords)
550 /* we have to find at least one keyword that does not already exist as a sibling of dest_kw_iter */
551 GList *work = *keywords;
554 gchar *keyword = work->data;
555 if (keyword_exists(keyword_tree, NULL, dest_kw_iter, keyword, FALSE, NULL))
557 GList *next = work->next;
559 *keywords = g_list_delete_link(*keywords, work);
570 static void bar_pane_keywords_dnd_receive(GtkWidget *tree_view, GdkDragContext *context,
572 GtkSelectionData *selection_data, guint info,
573 guint time, gpointer data)
575 PaneKeywordsData *pkd = data;
576 GtkTreePath *tpath = NULL;
577 GtkTreeViewDropPosition pos;
580 GtkTreeModel *keyword_tree;
581 gboolean src_valid = FALSE;
582 GList *new_keywords = NULL;
585 /* iterators for keyword_tree */
586 GtkTreeIter src_kw_iter;
587 GtkTreeIter dest_kw_iter;
588 GtkTreeIter new_kw_iter;
590 g_signal_stop_emission_by_name(tree_view, "drag_data_received");
592 model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
593 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
595 gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(tree_view), x, y, &tpath, &pos);
596 gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(tree_view), NULL, pos);
600 case TARGET_APP_KEYWORD_PATH:
602 GList *path = *(gpointer *)selection_data->data;
603 src_valid = keyword_tree_get_iter(keyword_tree, &src_kw_iter, path);
604 string_list_free(path);
608 new_keywords = string_to_keywords_list((gchar *)selection_data->data);
614 GtkTreeIter dest_iter;
615 gtk_tree_model_get_iter(model, &dest_iter, tpath);
616 gtk_tree_path_free(tpath);
617 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &dest_kw_iter, &dest_iter);
619 if (src_valid && gtk_tree_store_is_ancestor(GTK_TREE_STORE(keyword_tree), &src_kw_iter, &dest_kw_iter))
621 /* can't move to it's own child */
625 if (src_valid && keyword_compare(keyword_tree, &src_kw_iter, &dest_kw_iter) == 0)
627 /* can't move to itself */
631 if ((pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE || pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER) &&
632 !gtk_tree_model_iter_has_child(keyword_tree, &dest_kw_iter))
634 /* the node has no children, all keywords can be added */
635 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &new_kw_iter, &dest_kw_iter);
639 if (src_valid && !bar_pane_keywords_dnd_can_move(keyword_tree, &src_kw_iter, &dest_kw_iter))
641 /* the keyword can't be moved if the same name already exist */
644 if (new_keywords && !bar_pane_keywords_dnd_skip_existing(keyword_tree, &dest_kw_iter, &new_keywords))
646 /* the keywords can't be added if the same name already exist */
652 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
653 case GTK_TREE_VIEW_DROP_BEFORE:
654 gtk_tree_store_insert_before(GTK_TREE_STORE(keyword_tree), &new_kw_iter, NULL, &dest_kw_iter);
656 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
657 case GTK_TREE_VIEW_DROP_AFTER:
658 gtk_tree_store_insert_after(GTK_TREE_STORE(keyword_tree), &new_kw_iter, NULL, &dest_kw_iter);
666 if (src_valid && !bar_pane_keywords_dnd_can_move(keyword_tree, &src_kw_iter, NULL))
668 /* the keyword can't be moved if the same name already exist */
671 if (new_keywords && !bar_pane_keywords_dnd_skip_existing(keyword_tree, NULL, &new_keywords))
673 /* the keywords can't be added if the same name already exist */
676 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &new_kw_iter, NULL);
682 keyword_move_recursive(GTK_TREE_STORE(keyword_tree), &new_kw_iter, &src_kw_iter);
688 gchar *keyword = work->data;
689 keyword_set(GTK_TREE_STORE(keyword_tree), &new_kw_iter, keyword, TRUE);
695 gtk_tree_store_insert_after(GTK_TREE_STORE(keyword_tree), &add, NULL, &new_kw_iter);
699 string_list_free(new_keywords);
700 bar_keyword_tree_sync(pkd);
703 static gint bar_pane_keywords_dnd_motion(GtkWidget *tree_view, GdkDragContext *context,
704 gint x, gint y, guint time, gpointer data)
706 GtkTreePath *tpath = NULL;
707 GtkTreeViewDropPosition pos;
708 gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(tree_view), x, y, &tpath, &pos);
712 GtkTreeIter dest_iter;
713 model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
714 gtk_tree_model_get_iter(model, &dest_iter, tpath);
715 if (pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE && gtk_tree_model_iter_has_child(model, &dest_iter))
716 pos = GTK_TREE_VIEW_DROP_BEFORE;
718 if (pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER && gtk_tree_model_iter_has_child(model, &dest_iter))
719 pos = GTK_TREE_VIEW_DROP_AFTER;
722 gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(tree_view), tpath, pos);
723 gtk_tree_path_free(tpath);
725 if (tree_view == gtk_drag_get_source_widget(context))
726 gdk_drag_status(context, GDK_ACTION_MOVE, time);
728 gdk_drag_status(context, GDK_ACTION_COPY, time);
734 *-------------------------------------------------------------------
736 *-------------------------------------------------------------------
739 static void bar_pane_keywords_edit_destroy_cb(GtkWidget *widget, gpointer data)
741 ConfDialogData *cdd = data;
742 gtk_tree_path_free(cdd->click_tpath);
747 static void bar_pane_keywords_edit_cancel_cb(GenericDialog *gd, gpointer data)
752 static void bar_pane_keywords_edit_ok_cb(GenericDialog *gd, gpointer data)
754 ConfDialogData *cdd = data;
755 PaneKeywordsData *pkd = cdd->pkd;
758 GtkTreeModel *keyword_tree;
761 gboolean have_dest = FALSE;
765 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
766 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
768 if (cdd->click_tpath)
771 if (gtk_tree_model_get_iter(model, &iter, cdd->click_tpath))
773 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter);
778 if (cdd->edit_existing && !have_dest) return;
780 keywords = keyword_list_pull(cdd->edit_widget);
782 if (cdd->edit_existing)
784 if (keywords && keywords->data && /* there should be one keyword */
785 !keyword_exists(keyword_tree, NULL, &kw_iter, keywords->data, TRUE, NULL))
787 keyword_set(GTK_TREE_STORE(keyword_tree), &kw_iter, keywords->data, cdd->is_keyword);
792 GList *work = keywords;
797 if (keyword_exists(keyword_tree, NULL, have_dest ? &kw_iter : NULL, work->data, FALSE, NULL))
804 gtk_tree_store_insert_after(GTK_TREE_STORE(keyword_tree), &add, NULL, &kw_iter);
808 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &add, NULL);
812 keyword_set(GTK_TREE_STORE(keyword_tree), &kw_iter, work->data, cdd->is_keyword);
816 string_list_free(keywords);
819 static void bar_pane_keywords_conf_set_helper(GtkWidget *widget, gpointer data)
821 ConfDialogData *cdd = data;
822 cdd->is_keyword = FALSE;
825 static void bar_pane_keywords_conf_set_kw(GtkWidget *widget, gpointer data)
827 ConfDialogData *cdd = data;
828 cdd->is_keyword = TRUE;
833 static void bar_pane_keywords_edit_dialog(PaneKeywordsData *pkd, gboolean edit_existing)
842 gboolean is_keyword = TRUE;
845 if (edit_existing && pkd->click_tpath)
849 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
851 if (gtk_tree_model_get_iter(model, &iter, pkd->click_tpath))
853 gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_NAME, &name,
854 FILTER_KEYWORD_COLUMN_IS_KEYWORD, &is_keyword, -1);
862 if (edit_existing && !name) return;
865 cdd = g_new0(ConfDialogData, 1);
867 cdd->click_tpath = pkd->click_tpath;
868 pkd->click_tpath = NULL;
869 cdd->is_keyword = is_keyword;
870 cdd->edit_existing = edit_existing;
872 cdd->gd = gd = generic_dialog_new(name ? _("Edit keyword") : _("Add keywords"), "keyword_edit",
874 bar_pane_keywords_edit_cancel_cb, cdd);
875 g_signal_connect(G_OBJECT(gd->dialog), "destroy",
876 G_CALLBACK(bar_pane_keywords_edit_destroy_cb), cdd);
879 generic_dialog_add_message(gd, NULL, name ? _("Configure keyword") : _("Add keyword"), NULL);
881 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
882 bar_pane_keywords_edit_ok_cb, TRUE);
884 table = pref_table_new(gd->vbox, 3, 1, FALSE, TRUE);
885 pref_table_label(table, 0, 0, _("Keyword:"), 1.0);
886 cdd->edit_widget = gtk_entry_new();
887 gtk_widget_set_size_request(cdd->edit_widget, 300, -1);
888 if (name) gtk_entry_set_text(GTK_ENTRY(cdd->edit_widget), name);
889 gtk_table_attach_defaults(GTK_TABLE(table), cdd->edit_widget, 1, 2, 0, 1);
890 /* here could eventually be a text view instead of entry */
891 generic_dialog_attach_default(gd, cdd->edit_widget);
892 gtk_widget_show(cdd->edit_widget);
894 group = pref_group_new(gd->vbox, FALSE, _("Keyword type:"), GTK_ORIENTATION_VERTICAL);
896 button = pref_radiobutton_new(group, NULL, _("Active keyword"),
898 G_CALLBACK(bar_pane_keywords_conf_set_kw), cdd);
899 button = pref_radiobutton_new(group, button, _("Helper"),
901 G_CALLBACK(bar_pane_keywords_conf_set_helper), cdd);
904 gtk_widget_show(gd->dialog);
911 *-------------------------------------------------------------------
913 *-------------------------------------------------------------------
916 static void bar_pane_keywords_edit_dialog_cb(GtkWidget *menu_widget, gpointer data)
918 PaneKeywordsData *pkd = data;
919 bar_pane_keywords_edit_dialog(pkd, TRUE);
922 static void bar_pane_keywords_add_dialog_cb(GtkWidget *menu_widget, gpointer data)
924 PaneKeywordsData *pkd = data;
925 bar_pane_keywords_edit_dialog(pkd, FALSE);
928 static void bar_pane_keywords_connect_mark_cb(GtkWidget *menu_widget, gpointer data)
930 PaneKeywordsData *pkd = data;
935 GtkTreeModel *keyword_tree;
938 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_widget), "mark")) - 1;
940 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
941 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
943 if (!pkd->click_tpath) return;
944 if (!gtk_tree_model_get_iter(model, &iter, pkd->click_tpath)) return;
946 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter);
948 file_data_unregister_notify_func(bar_pane_keywords_notify_cb, pkd);
950 meta_data_connect_mark_with_keyword(keyword_tree, &kw_iter, mark);
952 file_data_register_notify_func(bar_pane_keywords_notify_cb, pkd, NOTIFY_PRIORITY_LOW);
953 // bar_pane_keywords_update(pkd);
957 static void bar_pane_keywords_delete_cb(GtkWidget *menu_widget, gpointer data)
959 PaneKeywordsData *pkd = data;
963 GtkTreeModel *keyword_tree;
966 if (!pkd->click_tpath) return;
968 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
969 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
971 if (!gtk_tree_model_get_iter(model, &iter, pkd->click_tpath)) return;
972 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter);
974 keyword_delete(GTK_TREE_STORE(keyword_tree), &kw_iter);
977 static void bar_pane_keywords_hide_cb(GtkWidget *menu_widget, gpointer data)
979 PaneKeywordsData *pkd = data;
983 GtkTreeModel *keyword_tree;
986 if (!pkd->click_tpath) return;
988 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
989 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
991 if (!gtk_tree_model_get_iter(model, &iter, pkd->click_tpath)) return;
992 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter);
994 keyword_hide_in(GTK_TREE_STORE(keyword_tree), &kw_iter, model);
997 static void bar_pane_keywords_show_all_cb(GtkWidget *menu_widget, gpointer data)
999 PaneKeywordsData *pkd = data;
1000 GtkTreeModel *model;
1002 GtkTreeModel *keyword_tree;
1004 pkd->hide_unchecked = FALSE;
1006 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
1007 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
1009 keyword_show_all_in(GTK_TREE_STORE(keyword_tree), model);
1011 if (!pkd->collapse_unchecked) gtk_tree_view_expand_all(GTK_TREE_VIEW(pkd->keyword_treeview));
1012 bar_keyword_tree_sync(pkd);
1015 static void bar_pane_keywords_expand_checked_cb(GtkWidget *menu_widget, gpointer data)
1017 PaneKeywordsData *pkd = data;
1018 GtkTreeModel *model;
1020 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
1021 gtk_tree_model_foreach(model, bar_keyword_tree_expand_if_set_cb, pkd);
1024 static void bar_pane_keywords_collapse_unchecked_cb(GtkWidget *menu_widget, gpointer data)
1026 PaneKeywordsData *pkd = data;
1027 GtkTreeModel *model;
1029 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
1030 gtk_tree_model_foreach(model, bar_keyword_tree_collapse_if_unset_cb, pkd);
1033 static void bar_pane_keywords_hide_unchecked_cb(GtkWidget *menu_widget, gpointer data)
1035 PaneKeywordsData *pkd = data;
1036 GtkTreeModel *model;
1038 GtkTreeModel *keyword_tree;
1041 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
1042 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
1044 keywords = keyword_list_pull(pkd->keyword_view);
1045 keyword_hide_unset_in(GTK_TREE_STORE(keyword_tree), model, keywords);
1046 string_list_free(keywords);
1047 bar_keyword_tree_sync(pkd);
1050 static void bar_pane_keywords_expand_checked_toggle_cb(GtkWidget *menu_widget, gpointer data)
1052 PaneKeywordsData *pkd = data;
1053 pkd->expand_checked = !pkd->expand_checked;
1054 bar_keyword_tree_sync(pkd);
1057 static void bar_pane_keywords_collapse_unchecked_toggle_cb(GtkWidget *menu_widget, gpointer data)
1059 PaneKeywordsData *pkd = data;
1060 pkd->collapse_unchecked = !pkd->collapse_unchecked;
1061 bar_keyword_tree_sync(pkd);
1064 static void bar_pane_keywords_hide_unchecked_toggle_cb(GtkWidget *menu_widget, gpointer data)
1066 PaneKeywordsData *pkd = data;
1067 pkd->hide_unchecked = !pkd->hide_unchecked;
1068 bar_keyword_tree_sync(pkd);
1071 static void bar_pane_keywords_menu_popup(GtkWidget *widget, PaneKeywordsData *pkd, gint x, gint y)
1076 GtkTreeViewDropPosition pos;
1078 if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath);
1079 pkd->click_tpath = NULL;
1080 gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(pkd->keyword_treeview), x, y, &pkd->click_tpath, &pos);
1082 menu = popup_menu_short_lived();
1084 if (pkd->click_tpath)
1091 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
1094 gtk_tree_model_get_iter(model, &iter, pkd->click_tpath);
1097 gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_NAME, &name,
1098 FILTER_KEYWORD_COLUMN_MARK, &mark, -1);
1100 text = g_strdup_printf(_("Hide \"%s\""), name);
1101 menu_item_add_stock(menu, text, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_hide_cb), pkd);
1104 submenu = gtk_menu_new();
1105 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
1107 text = g_strdup_printf(_("Mark %d"), i + 1);
1108 item = menu_item_add(submenu, text, G_CALLBACK(bar_pane_keywords_connect_mark_cb), pkd);
1109 g_object_set_data(G_OBJECT(item), "mark", GINT_TO_POINTER(i + 1));
1112 text = g_strdup_printf(_("Connect \"%s\" to mark"), name);
1113 item = menu_item_add(menu, text, NULL, NULL);
1114 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1117 menu_item_add_divider(menu);
1119 text = g_strdup_printf(_("Edit \"%s\""), name);
1120 menu_item_add_stock(menu, text, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_edit_dialog_cb), pkd);
1122 text = g_strdup_printf(_("Delete \"%s\""), name);
1123 menu_item_add_stock(menu, text, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_delete_cb), pkd);
1127 if (mark && mark[0])
1129 text = g_strdup_printf(_("Disconnect \"%s\" from mark %s"), name, mark);
1130 menu_item_add_stock(menu, text, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_connect_mark_cb), pkd);
1134 menu_item_add_divider(menu);
1141 menu_item_add(menu, _("Expand checked"), G_CALLBACK(bar_pane_keywords_expand_checked_cb), pkd);
1142 menu_item_add(menu, _("Collapse unchecked"), G_CALLBACK(bar_pane_keywords_collapse_unchecked_cb), pkd);
1143 menu_item_add(menu, _("Hide unchecked"), G_CALLBACK(bar_pane_keywords_hide_unchecked_cb), pkd);
1144 menu_item_add(menu, _("Show all"), G_CALLBACK(bar_pane_keywords_show_all_cb), pkd);
1146 submenu = gtk_menu_new();
1147 item = menu_item_add(menu, _("On any change"), NULL, NULL);
1148 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1150 menu_item_add_check(submenu, _("Expand checked"), pkd->expand_checked, G_CALLBACK(bar_pane_keywords_expand_checked_toggle_cb), pkd);
1151 menu_item_add_check(submenu, _("Collapse unchecked"), pkd->collapse_unchecked, G_CALLBACK(bar_pane_keywords_collapse_unchecked_toggle_cb), pkd);
1152 menu_item_add_check(submenu, _("Hide unchecked"), pkd->hide_unchecked, G_CALLBACK(bar_pane_keywords_hide_unchecked_toggle_cb), pkd);
1154 menu_item_add_divider(menu);
1156 menu_item_add_stock(menu, _("Add keyword"), GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_add_dialog_cb), pkd);
1158 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);
1162 static gboolean bar_pane_keywords_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
1164 PaneKeywordsData *pkd = data;
1165 if (bevent->button == MOUSE_BUTTON_RIGHT)
1167 bar_pane_keywords_menu_popup(widget, pkd, bevent->x, bevent->y);
1174 *-------------------------------------------------------------------
1176 *-------------------------------------------------------------------
1179 void bar_pane_keywords_close(GtkWidget *bar)
1181 PaneKeywordsData *pkd;
1183 pkd = g_object_get_data(G_OBJECT(bar), "pane_data");
1186 g_free(pkd->pane.id);
1187 gtk_widget_destroy(pkd->widget);
1190 static void bar_pane_keywords_destroy(GtkWidget *widget, gpointer data)
1192 PaneKeywordsData *pkd = data;
1194 if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath);
1195 if (pkd->idle_id != -1) g_source_remove(pkd->idle_id);
1196 file_data_unregister_notify_func(bar_pane_keywords_notify_cb, pkd);
1198 file_data_unref(pkd->fd);
1205 GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded)
1207 PaneKeywordsData *pkd;
1209 GtkWidget *scrolled;
1210 GtkTextBuffer *buffer;
1211 GtkTreeModel *store;
1212 GtkTreeViewColumn *column;
1213 GtkCellRenderer *renderer;
1215 pkd = g_new0(PaneKeywordsData, 1);
1217 pkd->pane.pane_set_fd = bar_pane_keywords_set_fd;
1218 pkd->pane.pane_event = bar_pane_keywords_event;
1219 pkd->pane.pane_write_config = bar_pane_keywords_write_config;
1220 pkd->pane.title = bar_pane_expander_title(title);
1221 pkd->pane.id = g_strdup(id);
1222 pkd->pane.type = PANE_KEYWORDS;
1224 pkd->pane.expanded = expanded;
1226 pkd->key = g_strdup(key);
1228 pkd->expand_checked = TRUE;
1232 hbox = gtk_hbox_new(FALSE, PREF_PAD_GAP);
1235 g_object_set_data(G_OBJECT(pkd->widget), "pane_data", pkd);
1236 g_signal_connect(G_OBJECT(pkd->widget), "destroy",
1237 G_CALLBACK(bar_pane_keywords_destroy), pkd);
1238 gtk_widget_show(hbox);
1240 scrolled = gtk_scrolled_window_new(NULL, NULL);
1241 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
1242 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
1243 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1244 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
1245 gtk_widget_show(scrolled);
1247 pkd->keyword_view = gtk_text_view_new();
1248 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_view);
1249 g_signal_connect(G_OBJECT(pkd->keyword_view), "populate-popup",
1250 G_CALLBACK(bar_pane_keywords_populate_popup_cb), pkd);
1251 gtk_widget_show(pkd->keyword_view);
1253 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view));
1254 g_signal_connect(G_OBJECT(buffer), "changed",
1255 G_CALLBACK(bar_pane_keywords_changed), pkd);
1257 scrolled = gtk_scrolled_window_new(NULL, NULL);
1258 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
1259 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
1260 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1261 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
1262 gtk_widget_show(scrolled);
1265 if (!keyword_tree) keyword_tree_new_default();
1267 store = gtk_tree_model_filter_new(GTK_TREE_MODEL(keyword_tree), NULL);
1269 gtk_tree_model_filter_set_modify_func(GTK_TREE_MODEL_FILTER(store),
1270 FILTER_KEYWORD_COLUMN_COUNT,
1271 filter_keyword_column_types,
1272 bar_pane_keywords_filter_modify,
1275 gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(store),
1276 bar_pane_keywords_filter_visible,
1280 pkd->keyword_treeview = gtk_tree_view_new_with_model(store);
1281 g_object_unref(store);
1283 gtk_widget_set_size_request(pkd->keyword_treeview, -1, 400);
1285 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(pkd->keyword_treeview), FALSE);
1287 // gtk_tree_view_set_search_column(GTK_TREE_VIEW(pkd->keyword_treeview), FILTER_KEYWORD_COLUMN_);
1289 column = gtk_tree_view_column_new();
1290 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
1292 renderer = gtk_cell_renderer_text_new();
1293 gtk_tree_view_column_pack_start(column, renderer, TRUE);
1295 gtk_tree_view_column_add_attribute(column, renderer, "text", FILTER_KEYWORD_COLUMN_MARK);
1297 gtk_tree_view_append_column(GTK_TREE_VIEW(pkd->keyword_treeview), column);
1299 column = gtk_tree_view_column_new();
1300 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
1301 renderer = gtk_cell_renderer_toggle_new();
1302 gtk_tree_view_column_pack_start(column, renderer, FALSE);
1303 gtk_tree_view_column_add_attribute(column, renderer, "active", FILTER_KEYWORD_COLUMN_TOGGLE);
1304 gtk_tree_view_column_add_attribute(column, renderer, "visible", FILTER_KEYWORD_COLUMN_IS_KEYWORD);
1305 g_signal_connect(G_OBJECT(renderer), "toggled",
1306 G_CALLBACK(bar_pane_keywords_keyword_toggle), pkd);
1308 renderer = gtk_cell_renderer_text_new();
1309 gtk_tree_view_column_pack_start(column, renderer, TRUE);
1310 gtk_tree_view_column_add_attribute(column, renderer, "text", FILTER_KEYWORD_COLUMN_NAME);
1312 gtk_tree_view_append_column(GTK_TREE_VIEW(pkd->keyword_treeview), column);
1313 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(pkd->keyword_treeview), column);
1315 gtk_drag_source_set(pkd->keyword_treeview,
1316 GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
1317 bar_pane_keywords_drag_types, n_keywords_drag_types,
1318 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
1320 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_data_get",
1321 G_CALLBACK(bar_pane_keywords_dnd_get), pkd);
1323 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_begin",
1324 G_CALLBACK(bar_pane_keywords_dnd_begin), pkd);
1325 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_end",
1326 G_CALLBACK(bar_pane_keywords_dnd_end), pkd);
1328 gtk_drag_dest_set(pkd->keyword_treeview,
1329 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
1330 bar_pane_keywords_drop_types, n_keywords_drop_types,
1331 GDK_ACTION_COPY | GDK_ACTION_MOVE);
1333 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_data_received",
1334 G_CALLBACK(bar_pane_keywords_dnd_receive), pkd);
1336 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_motion",
1337 G_CALLBACK(bar_pane_keywords_dnd_motion), pkd);
1339 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "button_press_event",
1340 G_CALLBACK(bar_pane_keywords_menu_cb), pkd);
1342 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_treeview);
1343 gtk_widget_show(pkd->keyword_treeview);
1345 file_data_register_notify_func(bar_pane_keywords_notify_cb, pkd, NOTIFY_PRIORITY_LOW);
1350 GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
1352 gchar *id = g_strdup("keywords");
1353 gchar *title = NULL;
1354 gchar *key = g_strdup(COMMENT_KEY);
1355 gboolean expanded = TRUE;
1358 while (*attribute_names)
1360 const gchar *option = *attribute_names++;
1361 const gchar *value = *attribute_values++;
1363 if (READ_CHAR_FULL("id", id)) continue;
1364 if (READ_CHAR_FULL("title", title)) continue;
1365 if (READ_CHAR_FULL("key", key)) continue;
1366 if (READ_BOOL_FULL("expanded", expanded)) continue;
1369 log_printf("unknown attribute %s = %s\n", option, value);
1372 bar_pane_translate_title(PANE_KEYWORDS, id, &title);
1373 ret = bar_pane_keywords_new(id, title, key, expanded);
1380 void bar_pane_keywords_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
1382 PaneKeywordsData *pkd;
1384 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
1387 gchar *title = NULL;
1389 while (*attribute_names)
1391 const gchar *option = *attribute_names++;
1392 const gchar *value = *attribute_values++;
1394 if (READ_CHAR_FULL("title", title)) continue;
1395 if (READ_CHAR_FULL("key", pkd->key)) continue;
1396 if (READ_BOOL_FULL("expanded", pkd->pane.expanded)) continue;
1397 if (READ_CHAR_FULL("id", pkd->pane.id)) continue;
1400 log_printf("unknown attribute %s = %s\n", option, value);
1405 bar_pane_translate_title(PANE_KEYWORDS, pkd->pane.id, &title);
1406 gtk_label_set_text(GTK_LABEL(pkd->pane.title), title);
1410 bar_update_expander(pane);
1411 bar_pane_keywords_update(pkd);
1415 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */