annotate src/bar_keywords.c @ 1752:7cd0f91329e2

import 1768 and 1789 together
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 29 Jan 2010 19:16:00 +0900
parents 8a1aa99345fa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1 /*
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
2 * Geeqie
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
3 * (C) 2004 John Ellis
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
5 *
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
6 * Author: John Ellis
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
7 *
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
9 * Please read the included file COPYING for more information.
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
11 */
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
12
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
13 #include <glib/gprintf.h>
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
14
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
15 #include "main.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
16 #include "bar_keywords.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
17
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
18 #include "filedata.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
19 #include "history_list.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
20 #include "metadata.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
21 #include "misc.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
22 #include "ui_fileops.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
23 #include "ui_misc.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
24 #include "ui_utildlg.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
25 #include "utilops.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
26 #include "bar.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
27 #include "ui_menu.h"
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
28 #include "rcfile.h"
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1346
diff changeset
29 #include "layout.h"
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
30 #include "dnd.h"
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
31
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
32
1712
7f91f906f9c2 Comment out unused functions, silenting related compilation warnings.
zas_
parents: 1595
diff changeset
33 //static void bar_pane_keywords_keyword_update_all(void);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
34 static void bar_pane_keywords_changed(GtkTextBuffer *buffer, gpointer data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
35
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
36 /*
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
37 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
38 * keyword / comment utils
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
39 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
40 */
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
41
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
42
1292
4a3ae0e6f1eb droped Preferences dialog, sidebar should replace it completely
nadvornik
parents: 1291
diff changeset
43 GList *keyword_list_pull(GtkWidget *text_widget)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
44 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
45 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
46 gchar *text;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
47
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
48 text = text_widget_text_pull(text_widget);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
49 list = string_to_keywords_list(text);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
50
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
51 g_free(text);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
52
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
53 return list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
54 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
55
1449
76da5ba54a1d call the notify function just once when the keywords are pushed to the
nadvornik
parents: 1430
diff changeset
56 /* the "changed" signal should be blocked before calling this */
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
57 static void keyword_list_push(GtkWidget *textview, GList *list)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
58 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
59 GtkTextBuffer *buffer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
60 GtkTextIter start, end;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
61
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
62 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
63 gtk_text_buffer_get_bounds(buffer, &start, &end);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
64 gtk_text_buffer_delete(buffer, &start, &end);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
65
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
66 while (list)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
67 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
68 const gchar *word = list->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
69 GtkTextIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
70
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
71 gtk_text_buffer_get_end_iter(buffer, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
72 if (word) gtk_text_buffer_insert(buffer, &iter, word, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
73 gtk_text_buffer_get_end_iter(buffer, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
74 gtk_text_buffer_insert(buffer, &iter, "\n", -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
75
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
76 list = list->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
77 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
78 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
79
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
80
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
81 /*
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
82 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
83 * info bar
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
84 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
85 */
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
86
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
87
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
88 enum {
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
89 FILTER_KEYWORD_COLUMN_TOGGLE = 0,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
90 FILTER_KEYWORD_COLUMN_MARK,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
91 FILTER_KEYWORD_COLUMN_NAME,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
92 FILTER_KEYWORD_COLUMN_IS_KEYWORD,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
93 FILTER_KEYWORD_COLUMN_COUNT
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
94 };
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
95
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
96 static GType filter_keyword_column_types[] = {G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN};
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
97
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
98 typedef struct _PaneKeywordsData PaneKeywordsData;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
99 struct _PaneKeywordsData
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
100 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
101 PaneData pane;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
102 GtkWidget *widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
103
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
104 GtkWidget *keyword_view;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
105 GtkWidget *keyword_treeview;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
106
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
107 GtkTreePath *click_tpath;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
108
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
109 gboolean expand_checked;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
110 gboolean collapse_unchecked;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
111 gboolean hide_unchecked;
1455
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
112
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
113 guint idle_id; /* event source id */
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
114 FileData *fd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
115 gchar *key;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
116 };
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
117
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
118 typedef struct _ConfDialogData ConfDialogData;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
119 struct _ConfDialogData
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
120 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
121 PaneKeywordsData *pkd;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
122 GtkTreePath *click_tpath;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
123
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
124 /* dialog parts */
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
125 GenericDialog *gd;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
126 GtkWidget *edit_widget;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
127 gboolean is_keyword;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
128
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
129 gboolean edit_existing;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
130 };
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
131
1712
7f91f906f9c2 Comment out unused functions, silenting related compilation warnings.
zas_
parents: 1595
diff changeset
132 //static GList *bar_list = NULL;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
133
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
134
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
135 static void bar_pane_keywords_write(PaneKeywordsData *pkd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
136 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
137 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
138
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
139 if (!pkd->fd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
140
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
141 list = keyword_list_pull(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
142
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
143 metadata_write_list(pkd->fd, KEYWORD_KEY, list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
144
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
145 string_list_free(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
146 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
147
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
148 gboolean bar_keyword_tree_expand_if_set_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
149 {
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
150 PaneKeywordsData *pkd = data;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
151 gboolean set;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
152
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
153 gtk_tree_model_get(model, iter, FILTER_KEYWORD_COLUMN_TOGGLE, &set, -1);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
154
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
155 if (set && !gtk_tree_view_row_expanded(GTK_TREE_VIEW(pkd->keyword_treeview), path))
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
156 {
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
157 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(pkd->keyword_treeview), path);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
158 }
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
159 return FALSE;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
160 }
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
161
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
162 gboolean bar_keyword_tree_collapse_if_unset_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
163 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
164 PaneKeywordsData *pkd = data;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
165 gboolean set;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
166
1456
b24391991f7f improved expanding and hiding of helper keywords
nadvornik
parents: 1455
diff changeset
167 gtk_tree_model_get(model, iter, FILTER_KEYWORD_COLUMN_TOGGLE, &set, -1);
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
168
1456
b24391991f7f improved expanding and hiding of helper keywords
nadvornik
parents: 1455
diff changeset
169 if (!set && gtk_tree_view_row_expanded(GTK_TREE_VIEW(pkd->keyword_treeview), path))
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
170 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
171 gtk_tree_view_collapse_row(GTK_TREE_VIEW(pkd->keyword_treeview), path);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
172 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
173 return FALSE;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
174 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
175
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
176 static void bar_keyword_tree_sync(PaneKeywordsData *pkd)
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
177 {
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
178 GtkTreeModel *model;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
179
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
180 GtkTreeModel *keyword_tree;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
181 GList *keywords;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
182
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
183 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
184 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
185
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
186 keywords = keyword_list_pull(pkd->keyword_view);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
187 keyword_show_set_in(GTK_TREE_STORE(keyword_tree), model, keywords);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
188 if (pkd->hide_unchecked) keyword_hide_unset_in(GTK_TREE_STORE(keyword_tree), model, keywords);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
189 string_list_free(keywords);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
190
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
191 gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(model));
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
192
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
193 if (pkd->expand_checked) gtk_tree_model_foreach(model, bar_keyword_tree_expand_if_set_cb, pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
194 if (pkd->collapse_unchecked) gtk_tree_model_foreach(model, bar_keyword_tree_collapse_if_unset_cb, pkd);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
195 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
196
1712
7f91f906f9c2 Comment out unused functions, silenting related compilation warnings.
zas_
parents: 1595
diff changeset
197 #if 0
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
198 static void bar_pane_keywords_keyword_update_all(void)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
199 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
200 GList *work;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
201
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
202 work = bar_list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
203 while (work)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
204 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
205 PaneKeywordsData *pkd;
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
206 // GList *keywords;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
207
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
208 pkd = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
209 work = work->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
210
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
211 bar_keyword_tree_sync(pkd);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
212 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
213 }
1712
7f91f906f9c2 Comment out unused functions, silenting related compilation warnings.
zas_
parents: 1595
diff changeset
214 #endif
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
215
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
216 static void bar_pane_keywords_update(PaneKeywordsData *pkd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
217 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
218 GList *keywords = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
219 GtkTextBuffer *keyword_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
220
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
221 g_signal_handlers_block_by_func(keyword_buffer, bar_pane_keywords_changed, pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
222
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
223 keywords = metadata_read_list(pkd->fd, KEYWORD_KEY, METADATA_PLAIN);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
224 keyword_list_push(pkd->keyword_view, keywords);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
225 bar_keyword_tree_sync(pkd);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
226 string_list_free(keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
227
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
228 g_signal_handlers_unblock_by_func(keyword_buffer, bar_pane_keywords_changed, pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
229
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
230 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
231
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
232 void bar_pane_keywords_set_fd(GtkWidget *pane, FileData *fd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
233 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
234 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
235
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
236 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
237 if (!pkd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
238
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
239 file_data_unref(pkd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
240 pkd->fd = file_data_ref(fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
241
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
242 bar_pane_keywords_update(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
243 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
244
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
245 static void bar_pane_keywords_write_config(GtkWidget *pane, GString *outstr, gint indent)
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
246 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
247 PaneKeywordsData *pkd;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
248
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
249 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
250 if (!pkd) return;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
251
1461
e015b6573d36 improved config file formatting
nadvornik
parents: 1456
diff changeset
252 WRITE_NL(); WRITE_STRING("<pane_keywords ");
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
253 write_char_option(outstr, indent, "id", pkd->pane.id);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
254 write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(pkd->pane.title)));
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
255 WRITE_BOOL(pkd->pane, expanded);
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
256 WRITE_CHAR(*pkd, key);
1461
e015b6573d36 improved config file formatting
nadvornik
parents: 1456
diff changeset
257 WRITE_STRING("/>");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
258 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
259
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
260 gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
261 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
262 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
263
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
264 pkd = g_object_get_data(G_OBJECT(bar), "pane_data");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
265 if (!pkd) return FALSE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
266
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
267 if (GTK_WIDGET_HAS_FOCUS(pkd->keyword_view)) return gtk_widget_event(pkd->keyword_view, event);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
268
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
269 return FALSE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
270 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
271
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
272 static void bar_pane_keywords_keyword_toggle(GtkCellRendererToggle *toggle, const gchar *path, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
273 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
274 PaneKeywordsData *pkd = data;
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
275 GtkTreeModel *model;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
276 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
277 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
278 gboolean active;
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
279 GList *list;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
280 GtkTreeIter child_iter;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
281 GtkTreeModel *keyword_tree;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
282
1449
76da5ba54a1d call the notify function just once when the keywords are pushed to the
nadvornik
parents: 1430
diff changeset
283 GtkTextBuffer *keyword_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view));
76da5ba54a1d call the notify function just once when the keywords are pushed to the
nadvornik
parents: 1430
diff changeset
284
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
285 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
286
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
287 tpath = gtk_tree_path_new_from_string(path);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
288 gtk_tree_model_get_iter(model, &iter, tpath);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
289 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
290
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
291 gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_TOGGLE, &active, -1);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
292 active = (!active);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
293
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
294
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
295 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
296 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
297
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
298 list = keyword_list_pull(pkd->keyword_view);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
299 if (active)
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
300 keyword_tree_set(keyword_tree, &child_iter, &list);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
301 else
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
302 keyword_tree_reset(keyword_tree, &child_iter, &list);
1449
76da5ba54a1d call the notify function just once when the keywords are pushed to the
nadvornik
parents: 1430
diff changeset
303
76da5ba54a1d call the notify function just once when the keywords are pushed to the
nadvornik
parents: 1430
diff changeset
304 g_signal_handlers_block_by_func(keyword_buffer, bar_pane_keywords_changed, pkd);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
305 keyword_list_push(pkd->keyword_view, list);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
306 string_list_free(list);
1449
76da5ba54a1d call the notify function just once when the keywords are pushed to the
nadvornik
parents: 1430
diff changeset
307 g_signal_handlers_unblock_by_func(keyword_buffer, bar_pane_keywords_changed, pkd);
76da5ba54a1d call the notify function just once when the keywords are pushed to the
nadvornik
parents: 1430
diff changeset
308
76da5ba54a1d call the notify function just once when the keywords are pushed to the
nadvornik
parents: 1430
diff changeset
309 /* call this just once in the end */
76da5ba54a1d call the notify function just once when the keywords are pushed to the
nadvornik
parents: 1430
diff changeset
310 bar_pane_keywords_changed(keyword_buffer, pkd);
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
311 /*
1449
76da5ba54a1d call the notify function just once when the keywords are pushed to the
nadvornik
parents: 1430
diff changeset
312 bar_pane_keywords_change calls bar_keyword_tree_sync, no need to do it again
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
313 bar_keyword_tree_sync(pkd);
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
314 */
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
315 }
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
316
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
317 void bar_pane_keywords_filter_modify(GtkTreeModel *model, GtkTreeIter *iter, GValue *value, gint column, gpointer data)
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
318 {
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
319 PaneKeywordsData *pkd = data;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
320 GtkTreeModel *keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
321 GtkTreeIter child_iter;
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
322
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
323 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, iter);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
324
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
325 memset(value, 0, sizeof (GValue));
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
326
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
327 switch (column)
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
328 {
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
329 case FILTER_KEYWORD_COLUMN_TOGGLE:
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
330 {
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
331 GList *keywords = keyword_list_pull(pkd->keyword_view);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
332 gboolean set = keyword_tree_is_set(keyword_tree, &child_iter, keywords);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
333 string_list_free(keywords);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
334
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
335 g_value_init(value, G_TYPE_BOOLEAN);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
336 g_value_set_boolean(value, set);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
337 break;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
338 }
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
339 case FILTER_KEYWORD_COLUMN_MARK:
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
340 gtk_tree_model_get_value(keyword_tree, &child_iter, KEYWORD_COLUMN_MARK, value);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
341 break;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
342 case FILTER_KEYWORD_COLUMN_NAME:
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
343 gtk_tree_model_get_value(keyword_tree, &child_iter, KEYWORD_COLUMN_NAME, value);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
344 break;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
345 case FILTER_KEYWORD_COLUMN_IS_KEYWORD:
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
346 gtk_tree_model_get_value(keyword_tree, &child_iter, KEYWORD_COLUMN_IS_KEYWORD, value);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
347 break;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
348 }
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
349 return;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
350
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
351 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
352
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
353 gboolean bar_pane_keywords_filter_visible(GtkTreeModel *keyword_tree, GtkTreeIter *iter, gpointer data)
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
354 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
355 GtkTreeModel *filter = data;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
356
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
357 return !keyword_is_hidden_in(keyword_tree, iter, filter);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
358 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
359
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
360 static void bar_pane_keywords_set_selection(PaneKeywordsData *pkd, gboolean append)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
361 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
362 GList *keywords = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
363 GList *list = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
364 GList *work;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
365
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
366 keywords = keyword_list_pull(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
367
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1346
diff changeset
368 list = layout_selection_list(pkd->pane.lw);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
369 work = list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
370 while (work)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
371 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
372 FileData *fd = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
373 work = work->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
374
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
375 if (append)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
376 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
377 metadata_append_list(fd, KEYWORD_KEY, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
378 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
379 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
380 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
381 metadata_write_list(fd, KEYWORD_KEY, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
382 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
383 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
384
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
385 filelist_free(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
386 string_list_free(keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
387 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
388
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
389 static void bar_pane_keywords_sel_add_cb(GtkWidget *button, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
390 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
391 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
392
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
393 bar_pane_keywords_set_selection(pkd, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
394 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
395
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
396 static void bar_pane_keywords_sel_replace_cb(GtkWidget *button, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
397 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
398 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
399
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
400 bar_pane_keywords_set_selection(pkd, FALSE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
401 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
402
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
403 static void bar_pane_keywords_populate_popup_cb(GtkTextView *textview, GtkMenu *menu, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
404 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
405 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
406
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
407 menu_item_add_divider(GTK_WIDGET(menu));
1295
8c59e6e50bd8 Fix up few compilation warnings.
zas_
parents: 1292
diff changeset
408 menu_item_add_stock(GTK_WIDGET(menu), _("Add keywords to selected files"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_keywords_sel_add_cb), pkd);
8c59e6e50bd8 Fix up few compilation warnings.
zas_
parents: 1292
diff changeset
409 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);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
410 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
411
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
412
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
413 static void bar_pane_keywords_notify_cb(FileData *fd, NotifyType type, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
414 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
415 PaneKeywordsData *pkd = data;
1498
5f49f305a6b6 improved debug messages
nadvornik
parents: 1485
diff changeset
416 if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pkd->fd)
5f49f305a6b6 improved debug messages
nadvornik
parents: 1485
diff changeset
417 {
5f49f305a6b6 improved debug messages
nadvornik
parents: 1485
diff changeset
418 DEBUG_1("Notify pane_keywords: %s %04x", fd->path, type);
5f49f305a6b6 improved debug messages
nadvornik
parents: 1485
diff changeset
419 bar_pane_keywords_update(pkd);
5f49f305a6b6 improved debug messages
nadvornik
parents: 1485
diff changeset
420 }
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
421 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
422
1455
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
423 static gboolean bar_pane_keywords_changed_idle_cb(gpointer data)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
424 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
425 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
426
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
427 file_data_unregister_notify_func(bar_pane_keywords_notify_cb, pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
428 bar_pane_keywords_write(pkd);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
429 bar_keyword_tree_sync(pkd);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
430 file_data_register_notify_func(bar_pane_keywords_notify_cb, pkd, NOTIFY_PRIORITY_LOW);
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
431 pkd->idle_id = 0;
1455
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
432 return FALSE;
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
433 }
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
434
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
435 static void bar_pane_keywords_changed(GtkTextBuffer *buffer, gpointer data)
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
436 {
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
437 PaneKeywordsData *pkd = data;
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
438
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
439 if (pkd->idle_id) return;
1455
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
440 /* higher prio than redraw */
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
441 pkd->idle_id = g_idle_add_full(G_PRIORITY_HIGH_IDLE, bar_pane_keywords_changed_idle_cb, pkd, NULL);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
442 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
443
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
444
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
445 /*
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
446 *-------------------------------------------------------------------
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
447 * dnd
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
448 *-------------------------------------------------------------------
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
449 */
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
450
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
451
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
452 static GtkTargetEntry bar_pane_keywords_drag_types[] = {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
453 { TARGET_APP_KEYWORD_PATH_STRING, GTK_TARGET_SAME_WIDGET, TARGET_APP_KEYWORD_PATH },
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
454 { "text/plain", 0, TARGET_TEXT_PLAIN }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
455 };
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
456 static gint n_keywords_drag_types = 2;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
457
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
458
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
459 static GtkTargetEntry bar_pane_keywords_drop_types[] = {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
460 { TARGET_APP_KEYWORD_PATH_STRING, GTK_TARGET_SAME_WIDGET, TARGET_APP_KEYWORD_PATH },
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
461 { "text/plain", 0, TARGET_TEXT_PLAIN }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
462 };
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
463 static gint n_keywords_drop_types = 2;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
464
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
465
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
466 static void bar_pane_keywords_dnd_get(GtkWidget *tree_view, GdkDragContext *context,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
467 GtkSelectionData *selection_data, guint info,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
468 guint time, gpointer data)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
469 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
470 GtkTreeIter iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
471 GtkTreeModel *model;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
472 GtkTreeIter child_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
473 GtkTreeModel *keyword_tree;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
474
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
475 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
476
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
477 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) return;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
478
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
479 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
480 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
481
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
482 switch (info)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
483 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
484 case TARGET_APP_KEYWORD_PATH:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
485 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
486 GList *path = keyword_tree_get_path(keyword_tree, &child_iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
487 gtk_selection_data_set(selection_data, selection_data->target,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
488 8, (gpointer) &path, sizeof(path));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
489 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
490 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
491
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
492 case TARGET_TEXT_PLAIN:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
493 default:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
494 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
495 gchar *name = keyword_get_name(keyword_tree, &child_iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
496 gtk_selection_data_set_text(selection_data, name, -1);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
497 g_free(name);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
498 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
499 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
500 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
501 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
502
1393
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
503 static void bar_pane_keywords_dnd_begin(GtkWidget *tree_view, GdkDragContext *context, gpointer data)
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
504 {
1393
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
505 GtkTreeIter iter;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
506 GtkTreeModel *model;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
507 GtkTreeIter child_iter;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
508 GtkTreeModel *keyword_tree;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
509 gchar *name;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
510
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
511 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
512
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
513 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) return;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
514
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
515 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
516 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter);
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
517
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
518 name = keyword_get_name(keyword_tree, &child_iter);
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
519
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
520 dnd_set_drag_label(tree_view, context, name);
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
521 g_free(name);
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
522
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
523 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
524
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
525 static void bar_pane_keywords_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
526 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
527 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
528
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
529
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
530 static gboolean bar_pane_keywords_dnd_can_move(GtkTreeModel *keyword_tree, GtkTreeIter *src_kw_iter, GtkTreeIter *dest_kw_iter)
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
531 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
532 gchar *src_name;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
533 GtkTreeIter parent;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
534
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
535 if (dest_kw_iter && keyword_same_parent(keyword_tree, src_kw_iter, dest_kw_iter))
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
536 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
537 return TRUE; /* reordering of siblings is ok */
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
538 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
539 if (!dest_kw_iter && !gtk_tree_model_iter_parent(keyword_tree, &parent, src_kw_iter))
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
540 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
541 return TRUE; /* reordering of top-level siblings is ok */
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
542 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
543
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
544 src_name = keyword_get_name(keyword_tree, src_kw_iter);
1465
400ecfc3d8b1 do not add duplicate keywords from config file
nadvornik
parents: 1464
diff changeset
545 if (keyword_exists(keyword_tree, NULL, dest_kw_iter, src_name, FALSE, NULL))
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
546 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
547 g_free(src_name);
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
548 return FALSE;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
549 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
550 g_free(src_name);
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
551 return TRUE;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
552 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
553
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
554 static gboolean bar_pane_keywords_dnd_skip_existing(GtkTreeModel *keyword_tree, GtkTreeIter *dest_kw_iter, GList **keywords)
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
555 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
556 /* we have to find at least one keyword that does not already exist as a sibling of dest_kw_iter */
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
557 GList *work = *keywords;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
558 while (work)
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
559 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
560 gchar *keyword = work->data;
1465
400ecfc3d8b1 do not add duplicate keywords from config file
nadvornik
parents: 1464
diff changeset
561 if (keyword_exists(keyword_tree, NULL, dest_kw_iter, keyword, FALSE, NULL))
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
562 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
563 GList *next = work->next;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
564 g_free(keyword);
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
565 *keywords = g_list_delete_link(*keywords, work);
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
566 work = next;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
567 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
568 else
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
569 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
570 work = work->next;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
571 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
572 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
573 return !!*keywords;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
574 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
575
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
576 static void bar_pane_keywords_dnd_receive(GtkWidget *tree_view, GdkDragContext *context,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
577 gint x, gint y,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
578 GtkSelectionData *selection_data, guint info,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
579 guint time, gpointer data)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
580 {
1396
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
581 PaneKeywordsData *pkd = data;
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
582 GtkTreePath *tpath = NULL;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
583 GtkTreeViewDropPosition pos;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
584 GtkTreeModel *model;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
585
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
586 GtkTreeModel *keyword_tree;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
587 gboolean src_valid = FALSE;
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
588 GList *new_keywords = NULL;
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
589 GList *work;
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
590
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
591 /* iterators for keyword_tree */
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
592 GtkTreeIter src_kw_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
593 GtkTreeIter dest_kw_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
594 GtkTreeIter new_kw_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
595
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
596 g_signal_stop_emission_by_name(tree_view, "drag_data_received");
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
597
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
598 model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
599 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
600
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
601 gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(tree_view), x, y, &tpath, &pos);
1430
7718e351bc45 cleanup, small fixes
nadvornik
parents: 1429
diff changeset
602 gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(tree_view), NULL, pos);
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
603
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
604 switch (info)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
605 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
606 case TARGET_APP_KEYWORD_PATH:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
607 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
608 GList *path = *(gpointer *)selection_data->data;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
609 src_valid = keyword_tree_get_iter(keyword_tree, &src_kw_iter, path);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
610 string_list_free(path);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
611 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
612 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
613 default:
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
614 new_keywords = string_to_keywords_list((gchar *)selection_data->data);
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
615 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
616 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
617
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
618 if (tpath)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
619 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
620 GtkTreeIter dest_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
621 gtk_tree_model_get_iter(model, &dest_iter, tpath);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
622 gtk_tree_path_free(tpath);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
623 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &dest_kw_iter, &dest_iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
624
1395
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
625 if (src_valid && gtk_tree_store_is_ancestor(GTK_TREE_STORE(keyword_tree), &src_kw_iter, &dest_kw_iter))
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
626 {
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
627 /* can't move to it's own child */
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
628 return;
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
629 }
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
630
1396
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
631 if (src_valid && keyword_compare(keyword_tree, &src_kw_iter, &dest_kw_iter) == 0)
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
632 {
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
633 /* can't move to itself */
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
634 return;
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
635 }
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
636
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
637 if ((pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE || pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER) &&
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
638 !gtk_tree_model_iter_has_child(keyword_tree, &dest_kw_iter))
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
639 {
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
640 /* the node has no children, all keywords can be added */
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
641 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &new_kw_iter, &dest_kw_iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
642 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
643 else
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
644 {
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
645 if (src_valid && !bar_pane_keywords_dnd_can_move(keyword_tree, &src_kw_iter, &dest_kw_iter))
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
646 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
647 /* the keyword can't be moved if the same name already exist */
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
648 return;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
649 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
650 if (new_keywords && !bar_pane_keywords_dnd_skip_existing(keyword_tree, &dest_kw_iter, &new_keywords))
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
651 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
652 /* the keywords can't be added if the same name already exist */
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
653 return;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
654 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
655
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
656 switch (pos)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
657 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
658 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
659 case GTK_TREE_VIEW_DROP_BEFORE:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
660 gtk_tree_store_insert_before(GTK_TREE_STORE(keyword_tree), &new_kw_iter, NULL, &dest_kw_iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
661 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
662 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
663 case GTK_TREE_VIEW_DROP_AFTER:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
664 gtk_tree_store_insert_after(GTK_TREE_STORE(keyword_tree), &new_kw_iter, NULL, &dest_kw_iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
665 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
666 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
667 }
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
668
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
669 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
670 else
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
671 {
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
672 if (src_valid && !bar_pane_keywords_dnd_can_move(keyword_tree, &src_kw_iter, NULL))
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
673 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
674 /* the keyword can't be moved if the same name already exist */
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
675 return;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
676 }
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
677 if (new_keywords && !bar_pane_keywords_dnd_skip_existing(keyword_tree, NULL, &new_keywords))
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
678 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
679 /* the keywords can't be added if the same name already exist */
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
680 return;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
681 }
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
682 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &new_kw_iter, NULL);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
683 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
684
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
685
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
686 if (src_valid)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
687 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
688 keyword_move_recursive(GTK_TREE_STORE(keyword_tree), &new_kw_iter, &src_kw_iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
689 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
690
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
691 work = new_keywords;
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
692 while (work)
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
693 {
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
694 gchar *keyword = work->data;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
695 keyword_set(GTK_TREE_STORE(keyword_tree), &new_kw_iter, keyword, TRUE);
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
696 work = work->next;
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
697
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
698 if (work)
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
699 {
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
700 GtkTreeIter add;
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
701 gtk_tree_store_insert_after(GTK_TREE_STORE(keyword_tree), &add, NULL, &new_kw_iter);
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
702 new_kw_iter = add;
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
703 }
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
704 }
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
705 string_list_free(new_keywords);
1396
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
706 bar_keyword_tree_sync(pkd);
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
707 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
708
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
709 static gint bar_pane_keywords_dnd_motion(GtkWidget *tree_view, GdkDragContext *context,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
710 gint x, gint y, guint time, gpointer data)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
711 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
712 GtkTreePath *tpath = NULL;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
713 GtkTreeViewDropPosition pos;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
714 gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(tree_view), x, y, &tpath, &pos);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
715 if (tpath)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
716 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
717 GtkTreeModel *model;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
718 GtkTreeIter dest_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
719 model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
720 gtk_tree_model_get_iter(model, &dest_iter, tpath);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
721 if (pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE && gtk_tree_model_iter_has_child(model, &dest_iter))
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
722 pos = GTK_TREE_VIEW_DROP_BEFORE;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
723
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
724 if (pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER && gtk_tree_model_iter_has_child(model, &dest_iter))
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
725 pos = GTK_TREE_VIEW_DROP_AFTER;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
726 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
727
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
728 gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(tree_view), tpath, pos);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
729 gtk_tree_path_free(tpath);
1395
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
730
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
731 if (tree_view == gtk_drag_get_source_widget(context))
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
732 gdk_drag_status(context, GDK_ACTION_MOVE, time);
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
733 else
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
734 gdk_drag_status(context, GDK_ACTION_COPY, time);
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
735
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
736 return TRUE;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
737 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
738
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
739 /*
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
740 *-------------------------------------------------------------------
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
741 * edit dialog
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
742 *-------------------------------------------------------------------
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
743 */
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
744
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
745 static void bar_pane_keywords_edit_destroy_cb(GtkWidget *widget, gpointer data)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
746 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
747 ConfDialogData *cdd = data;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
748 gtk_tree_path_free(cdd->click_tpath);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
749 g_free(cdd);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
750 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
751
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
752
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
753 static void bar_pane_keywords_edit_cancel_cb(GenericDialog *gd, gpointer data)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
754 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
755 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
756
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
757
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
758 static void bar_pane_keywords_edit_ok_cb(GenericDialog *gd, gpointer data)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
759 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
760 ConfDialogData *cdd = data;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
761 PaneKeywordsData *pkd = cdd->pkd;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
762 GtkTreeModel *model;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
763
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
764 GtkTreeModel *keyword_tree;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
765 GtkTreeIter kw_iter;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
766
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
767 gboolean have_dest = FALSE;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
768
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
769 GList *keywords;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
770
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
771 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
772 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
773
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
774 if (cdd->click_tpath)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
775 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
776 GtkTreeIter iter;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
777 if (gtk_tree_model_get_iter(model, &iter, cdd->click_tpath))
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
778 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
779 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
780 have_dest = TRUE;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
781 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
782 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
783
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
784 if (cdd->edit_existing && !have_dest) return;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
785
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
786 keywords = keyword_list_pull(cdd->edit_widget);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
787
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
788 if (cdd->edit_existing)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
789 {
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
790 if (keywords && keywords->data && /* there should be one keyword */
1465
400ecfc3d8b1 do not add duplicate keywords from config file
nadvornik
parents: 1464
diff changeset
791 !keyword_exists(keyword_tree, NULL, &kw_iter, keywords->data, TRUE, NULL))
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
792 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
793 keyword_set(GTK_TREE_STORE(keyword_tree), &kw_iter, keywords->data, cdd->is_keyword);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
794 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
795 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
796 else
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
797 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
798 GList *work = keywords;
1527
12b0eeb5d528 Nest new keywords inside existing
mow
parents: 1526
diff changeset
799 gboolean append_to = FALSE;
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
800
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
801 while (work)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
802 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
803 GtkTreeIter add;
1527
12b0eeb5d528 Nest new keywords inside existing
mow
parents: 1526
diff changeset
804 if (keyword_exists(keyword_tree, NULL, (have_dest || append_to) ? &kw_iter : NULL, work->data, FALSE, NULL))
1429
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
805 {
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
806 work = work->next;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
807 continue;
985366bccfb8 do not allow to add keywords with the same name as siblings
nadvornik
parents: 1428
diff changeset
808 }
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
809 if (have_dest)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
810 {
1527
12b0eeb5d528 Nest new keywords inside existing
mow
parents: 1526
diff changeset
811 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &add, &kw_iter);
12b0eeb5d528 Nest new keywords inside existing
mow
parents: 1526
diff changeset
812 }
12b0eeb5d528 Nest new keywords inside existing
mow
parents: 1526
diff changeset
813 else if (append_to)
12b0eeb5d528 Nest new keywords inside existing
mow
parents: 1526
diff changeset
814 {
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
815 gtk_tree_store_insert_after(GTK_TREE_STORE(keyword_tree), &add, NULL, &kw_iter);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
816 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
817 else
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
818 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
819 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &add, NULL);
1527
12b0eeb5d528 Nest new keywords inside existing
mow
parents: 1526
diff changeset
820 append_to = TRUE;
12b0eeb5d528 Nest new keywords inside existing
mow
parents: 1526
diff changeset
821 kw_iter = add;
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
822 }
1527
12b0eeb5d528 Nest new keywords inside existing
mow
parents: 1526
diff changeset
823 keyword_set(GTK_TREE_STORE(keyword_tree), &add, work->data, cdd->is_keyword);
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
824 work = work->next;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
825 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
826 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
827 string_list_free(keywords);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
828 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
829
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
830 static void bar_pane_keywords_conf_set_helper(GtkWidget *widget, gpointer data)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
831 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
832 ConfDialogData *cdd = data;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
833 cdd->is_keyword = FALSE;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
834 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
835
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
836 static void bar_pane_keywords_conf_set_kw(GtkWidget *widget, gpointer data)
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
837 {
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
838 ConfDialogData *cdd = data;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
839 cdd->is_keyword = TRUE;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
840 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
841
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
842
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
843
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
844 static void bar_pane_keywords_edit_dialog(PaneKeywordsData *pkd, gboolean edit_existing)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
845 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
846 ConfDialogData *cdd;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
847 GenericDialog *gd;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
848 GtkWidget *table;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
849 GtkWidget *group;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
850 GtkWidget *button;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
851
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
852 gchar *name = NULL;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
853 gboolean is_keyword = TRUE;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
854
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
855
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
856 if (edit_existing && pkd->click_tpath)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
857 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
858 GtkTreeModel *model;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
859 GtkTreeIter iter;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
860 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
861
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
862 if (gtk_tree_model_get_iter(model, &iter, pkd->click_tpath))
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
863 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
864 gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_NAME, &name,
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
865 FILTER_KEYWORD_COLUMN_IS_KEYWORD, &is_keyword, -1);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
866 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
867 else
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
868 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
869 return;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
870 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
871 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
872
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
873 if (edit_existing && !name) return;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
874
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
875
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
876 cdd = g_new0(ConfDialogData, 1);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
877 cdd->pkd =pkd;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
878 cdd->click_tpath = pkd->click_tpath;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
879 pkd->click_tpath = NULL;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
880 cdd->edit_existing = edit_existing;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
881
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
882 cdd->gd = gd = generic_dialog_new(name ? _("Edit keyword") : _("Add keywords"), "keyword_edit",
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
883 pkd->widget, TRUE,
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
884 bar_pane_keywords_edit_cancel_cb, cdd);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
885 g_signal_connect(G_OBJECT(gd->dialog), "destroy",
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
886 G_CALLBACK(bar_pane_keywords_edit_destroy_cb), cdd);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
887
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
888
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
889 generic_dialog_add_message(gd, NULL, name ? _("Configure keyword") : _("Add keyword"), NULL);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
890
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
891 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
892 bar_pane_keywords_edit_ok_cb, TRUE);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
893
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
894 table = pref_table_new(gd->vbox, 3, 1, FALSE, TRUE);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
895 pref_table_label(table, 0, 0, _("Keyword:"), 1.0);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
896 cdd->edit_widget = gtk_entry_new();
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
897 gtk_widget_set_size_request(cdd->edit_widget, 300, -1);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
898 if (name) gtk_entry_set_text(GTK_ENTRY(cdd->edit_widget), name);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
899 gtk_table_attach_defaults(GTK_TABLE(table), cdd->edit_widget, 1, 2, 0, 1);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
900 /* here could eventually be a text view instead of entry */
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
901 generic_dialog_attach_default(gd, cdd->edit_widget);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
902 gtk_widget_show(cdd->edit_widget);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
903
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
904 group = pref_group_new(gd->vbox, FALSE, _("Keyword type:"), GTK_ORIENTATION_VERTICAL);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
905
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
906 button = pref_radiobutton_new(group, NULL, _("Active keyword"),
1526
51b9d42ed79b Fix the is_keyword bug
mow
parents: 1525
diff changeset
907 (is_keyword),
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
908 G_CALLBACK(bar_pane_keywords_conf_set_kw), cdd);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
909 button = pref_radiobutton_new(group, button, _("Helper"),
1526
51b9d42ed79b Fix the is_keyword bug
mow
parents: 1525
diff changeset
910 (!is_keyword),
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
911 G_CALLBACK(bar_pane_keywords_conf_set_helper), cdd);
1526
51b9d42ed79b Fix the is_keyword bug
mow
parents: 1525
diff changeset
912
51b9d42ed79b Fix the is_keyword bug
mow
parents: 1525
diff changeset
913 cdd->is_keyword = is_keyword;
51b9d42ed79b Fix the is_keyword bug
mow
parents: 1525
diff changeset
914
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
915 g_free(name);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
916
1525
bd8001efdccc Set the focus for new keyword dialog
mow
parents: 1523
diff changeset
917 gtk_widget_grab_focus(cdd->edit_widget);
bd8001efdccc Set the focus for new keyword dialog
mow
parents: 1523
diff changeset
918
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
919 gtk_widget_show(gd->dialog);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
920 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
921
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
922
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
923
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
924
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
925 /*
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
926 *-------------------------------------------------------------------
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
927 * popup menu
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
928 *-------------------------------------------------------------------
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
929 */
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
930
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
931 static void bar_pane_keywords_edit_dialog_cb(GtkWidget *menu_widget, gpointer data)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
932 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
933 PaneKeywordsData *pkd = data;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
934 bar_pane_keywords_edit_dialog(pkd, TRUE);
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
935 }
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
936
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
937 static void bar_pane_keywords_add_dialog_cb(GtkWidget *menu_widget, gpointer data)
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
938 {
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
939 PaneKeywordsData *pkd = data;
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
940 bar_pane_keywords_edit_dialog(pkd, FALSE);
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
941 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
942
1425
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
943 static void bar_pane_keywords_connect_mark_cb(GtkWidget *menu_widget, gpointer data)
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
944 {
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
945 PaneKeywordsData *pkd = data;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
946
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
947 GtkTreeModel *model;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
948 GtkTreeIter iter;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
949
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
950 GtkTreeModel *keyword_tree;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
951 GtkTreeIter kw_iter;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
952
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
953 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_widget), "mark")) - 1;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
954
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
955 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
956 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
957
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
958 if (!pkd->click_tpath) return;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
959 if (!gtk_tree_model_get_iter(model, &iter, pkd->click_tpath)) return;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
960
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
961 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
962
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
963 file_data_unregister_notify_func(bar_pane_keywords_notify_cb, pkd);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
964
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
965 meta_data_connect_mark_with_keyword(keyword_tree, &kw_iter, mark);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
966
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
967 file_data_register_notify_func(bar_pane_keywords_notify_cb, pkd, NOTIFY_PRIORITY_LOW);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
968 // bar_pane_keywords_update(pkd);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
969 }
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
970
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
971
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
972 static void bar_pane_keywords_delete_cb(GtkWidget *menu_widget, gpointer data)
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
973 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
974 PaneKeywordsData *pkd = data;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
975 GtkTreeModel *model;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
976 GtkTreeIter iter;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
977
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
978 GtkTreeModel *keyword_tree;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
979 GtkTreeIter kw_iter;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
980
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
981 if (!pkd->click_tpath) return;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
982
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
983 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
984 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
985
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
986 if (!gtk_tree_model_get_iter(model, &iter, pkd->click_tpath)) return;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
987 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
988
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
989 keyword_delete(GTK_TREE_STORE(keyword_tree), &kw_iter);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
990 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
991
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
992 static void bar_pane_keywords_hide_cb(GtkWidget *menu_widget, gpointer data)
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
993 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
994 PaneKeywordsData *pkd = data;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
995 GtkTreeModel *model;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
996 GtkTreeIter iter;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
997
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
998 GtkTreeModel *keyword_tree;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
999 GtkTreeIter kw_iter;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1000
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1001 if (!pkd->click_tpath) return;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1002
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1003 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1004 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1005
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1006 if (!gtk_tree_model_get_iter(model, &iter, pkd->click_tpath)) return;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1007 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1008
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1009 keyword_hide_in(GTK_TREE_STORE(keyword_tree), &kw_iter, model);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1010 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1011
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1012 static void bar_pane_keywords_show_all_cb(GtkWidget *menu_widget, gpointer data)
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1013 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1014 PaneKeywordsData *pkd = data;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1015 GtkTreeModel *model;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1016
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1017 GtkTreeModel *keyword_tree;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1018
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1019 pkd->hide_unchecked = FALSE;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1020
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1021 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1022 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1023
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1024 keyword_show_all_in(GTK_TREE_STORE(keyword_tree), model);
1430
7718e351bc45 cleanup, small fixes
nadvornik
parents: 1429
diff changeset
1025
7718e351bc45 cleanup, small fixes
nadvornik
parents: 1429
diff changeset
1026 if (!pkd->collapse_unchecked) gtk_tree_view_expand_all(GTK_TREE_VIEW(pkd->keyword_treeview));
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1027 bar_keyword_tree_sync(pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1028 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1029
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1030 static void bar_pane_keywords_expand_checked_cb(GtkWidget *menu_widget, gpointer data)
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1031 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1032 PaneKeywordsData *pkd = data;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1033 GtkTreeModel *model;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1034
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1035 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1036 gtk_tree_model_foreach(model, bar_keyword_tree_expand_if_set_cb, pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1037 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1038
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1039 static void bar_pane_keywords_collapse_unchecked_cb(GtkWidget *menu_widget, gpointer data)
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1040 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1041 PaneKeywordsData *pkd = data;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1042 GtkTreeModel *model;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1043
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1044 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1045 gtk_tree_model_foreach(model, bar_keyword_tree_collapse_if_unset_cb, pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1046 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1047
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1048 static void bar_pane_keywords_hide_unchecked_cb(GtkWidget *menu_widget, gpointer data)
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1049 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1050 PaneKeywordsData *pkd = data;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1051 GtkTreeModel *model;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1052
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1053 GtkTreeModel *keyword_tree;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1054 GList *keywords;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1055
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1056 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1057 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1058
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1059 keywords = keyword_list_pull(pkd->keyword_view);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1060 keyword_hide_unset_in(GTK_TREE_STORE(keyword_tree), model, keywords);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1061 string_list_free(keywords);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1062 bar_keyword_tree_sync(pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1063 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1064
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1065 static void bar_pane_keywords_expand_checked_toggle_cb(GtkWidget *menu_widget, gpointer data)
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1066 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1067 PaneKeywordsData *pkd = data;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1068 pkd->expand_checked = !pkd->expand_checked;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1069 bar_keyword_tree_sync(pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1070 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1071
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1072 static void bar_pane_keywords_collapse_unchecked_toggle_cb(GtkWidget *menu_widget, gpointer data)
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1073 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1074 PaneKeywordsData *pkd = data;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1075 pkd->collapse_unchecked = !pkd->collapse_unchecked;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1076 bar_keyword_tree_sync(pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1077 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1078
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1079 static void bar_pane_keywords_hide_unchecked_toggle_cb(GtkWidget *menu_widget, gpointer data)
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1080 {
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1081 PaneKeywordsData *pkd = data;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1082 pkd->hide_unchecked = !pkd->hide_unchecked;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1083 bar_keyword_tree_sync(pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1084 }
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1085
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1086 static void bar_pane_keywords_menu_popup(GtkWidget *widget, PaneKeywordsData *pkd, gint x, gint y)
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1087 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1088 GtkWidget *menu;
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1089 GtkWidget *item;
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1090 GtkWidget *submenu;
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1091 GtkTreeViewDropPosition pos;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1092
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1093 if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1094 pkd->click_tpath = NULL;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1095 gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(pkd->keyword_treeview), x, y, &pkd->click_tpath, &pos);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1096
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1097 menu = popup_menu_short_lived();
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1098
1740
8a1aa99345fa Move "Add Keyword" menu item at top of Keywords bar contextual menu.
zas_
parents: 1739
diff changeset
1099 menu_item_add_stock(menu, _("Add keyword"), GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_add_dialog_cb), pkd);
8a1aa99345fa Move "Add Keyword" menu item at top of Keywords bar contextual menu.
zas_
parents: 1739
diff changeset
1100
8a1aa99345fa Move "Add Keyword" menu item at top of Keywords bar contextual menu.
zas_
parents: 1739
diff changeset
1101 menu_item_add_divider(menu);
8a1aa99345fa Move "Add Keyword" menu item at top of Keywords bar contextual menu.
zas_
parents: 1739
diff changeset
1102
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1103 if (pkd->click_tpath)
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1104 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1105 /* for the entry */
1425
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1106 gchar *text;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1107 gchar *mark;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1108 gint i;
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1109
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1110 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1111
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1112 GtkTreeIter iter;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1113 gtk_tree_model_get_iter(model, &iter, pkd->click_tpath);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1114 gchar *name;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1115
1425
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1116 gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_NAME, &name,
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1117 FILTER_KEYWORD_COLUMN_MARK, &mark, -1);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1118
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1119 text = g_strdup_printf(_("Hide \"%s\""), name);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1120 menu_item_add_stock(menu, text, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_hide_cb), pkd);
1425
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1121 g_free(text);
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1122
1425
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1123 submenu = gtk_menu_new();
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1124 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1125 {
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1126 text = g_strdup_printf(_("Mark %d"), i + 1);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1127 item = menu_item_add(submenu, text, G_CALLBACK(bar_pane_keywords_connect_mark_cb), pkd);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1128 g_object_set_data(G_OBJECT(item), "mark", GINT_TO_POINTER(i + 1));
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1129 g_free(text);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1130 }
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1131 text = g_strdup_printf(_("Connect \"%s\" to mark"), name);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1132 item = menu_item_add(menu, text, NULL, NULL);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1133 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1134 g_free(text);
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1135
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1136 menu_item_add_divider(menu);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1137
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1138 text = g_strdup_printf(_("Edit \"%s\""), name);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1139 menu_item_add_stock(menu, text, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_edit_dialog_cb), pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1140 g_free(text);
1543
c8ac214a2fca fixed ambiguous strings
nadvornik
parents: 1527
diff changeset
1141 text = g_strdup_printf(_("Remove \"%s\""), name);
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1142 menu_item_add_stock(menu, text, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_delete_cb), pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1143 g_free(text);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1144
1425
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1145
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1146 if (mark && mark[0])
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1147 {
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1148 text = g_strdup_printf(_("Disconnect \"%s\" from mark %s"), name, mark);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1149 menu_item_add_stock(menu, text, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_connect_mark_cb), pkd);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1150 g_free(text);
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1151 }
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1152
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1153 menu_item_add_divider(menu);
1425
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1154 g_free(mark);
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1155 g_free(name);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1156 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1157 /* for the pane */
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1158
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1159
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1160 menu_item_add(menu, _("Expand checked"), G_CALLBACK(bar_pane_keywords_expand_checked_cb), pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1161 menu_item_add(menu, _("Collapse unchecked"), G_CALLBACK(bar_pane_keywords_collapse_unchecked_cb), pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1162 menu_item_add(menu, _("Hide unchecked"), G_CALLBACK(bar_pane_keywords_hide_unchecked_cb), pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1163 menu_item_add(menu, _("Show all"), G_CALLBACK(bar_pane_keywords_show_all_cb), pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1164
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1165 submenu = gtk_menu_new();
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1166 item = menu_item_add(menu, _("On any change"), NULL, NULL);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1167 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1168
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1169 menu_item_add_check(submenu, _("Expand checked"), pkd->expand_checked, G_CALLBACK(bar_pane_keywords_expand_checked_toggle_cb), pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1170 menu_item_add_check(submenu, _("Collapse unchecked"), pkd->collapse_unchecked, G_CALLBACK(bar_pane_keywords_collapse_unchecked_toggle_cb), pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1171 menu_item_add_check(submenu, _("Hide unchecked"), pkd->hide_unchecked, G_CALLBACK(bar_pane_keywords_hide_unchecked_toggle_cb), pkd);
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1172
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1173 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1174 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1175
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1176
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1177 static gboolean bar_pane_keywords_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1178 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1179 PaneKeywordsData *pkd = data;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1180 if (bevent->button == MOUSE_BUTTON_RIGHT)
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1181 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1182 bar_pane_keywords_menu_popup(widget, pkd, bevent->x, bevent->y);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1183 return TRUE;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1184 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1185 return FALSE;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1186 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1187
1421
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
1188 /*
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
1189 *-------------------------------------------------------------------
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
1190 * init
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
1191 *-------------------------------------------------------------------
130054d9dd8a added a dialog for editing keyword tree
nadvornik
parents: 1414
diff changeset
1192 */
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1193
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1194 void bar_pane_keywords_close(GtkWidget *bar)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1195 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1196 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1197
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1198 pkd = g_object_get_data(G_OBJECT(bar), "pane_data");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1199 if (!pkd) return;
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1200
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1201 g_free(pkd->pane.id);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1202 gtk_widget_destroy(pkd->widget);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1203 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1204
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1205 static void bar_pane_keywords_destroy(GtkWidget *widget, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1206 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1207 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1208
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1209 if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath);
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
1210 if (pkd->idle_id) g_source_remove(pkd->idle_id);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1211 file_data_unregister_notify_func(bar_pane_keywords_notify_cb, pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1212
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1213 file_data_unref(pkd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1214 g_free(pkd->key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1215
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1216 g_free(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1217 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1218
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1219
1485
0e82a03c165b pane interface cleanup
nadvornik
parents: 1471
diff changeset
1220 static GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1221 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1222 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1223 GtkWidget *hbox;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1224 GtkWidget *scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1225 GtkTextBuffer *buffer;
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1226 GtkTreeModel *store;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1227 GtkTreeViewColumn *column;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1228 GtkCellRenderer *renderer;
1595
9e2111452988 fixed keyword tree initialization
nadvornik
parents: 1543
diff changeset
1229 GtkTreeIter iter;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1230
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1231 pkd = g_new0(PaneKeywordsData, 1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1232
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1233 pkd->pane.pane_set_fd = bar_pane_keywords_set_fd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1234 pkd->pane.pane_event = bar_pane_keywords_event;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1235 pkd->pane.pane_write_config = bar_pane_keywords_write_config;
1389
c44f21235ffe Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents: 1387
diff changeset
1236 pkd->pane.title = bar_pane_expander_title(title);
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1237 pkd->pane.id = g_strdup(id);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1238 pkd->pane.type = PANE_KEYWORDS;
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1346
diff changeset
1239
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1240 pkd->pane.expanded = expanded;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1241
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1242 pkd->key = g_strdup(key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1243
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1244 pkd->expand_checked = TRUE;
1455
2545780d4779 fixed keyword tree redrawing
nadvornik
parents: 1450
diff changeset
1245
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1246 hbox = gtk_hbox_new(FALSE, PREF_PAD_GAP);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1247
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1248 pkd->widget = hbox;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1249 g_object_set_data(G_OBJECT(pkd->widget), "pane_data", pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1250 g_signal_connect(G_OBJECT(pkd->widget), "destroy",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1251 G_CALLBACK(bar_pane_keywords_destroy), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1252 gtk_widget_show(hbox);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1253
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1254 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1255 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1256 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1257 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1258 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1259 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1260
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1261 pkd->keyword_view = gtk_text_view_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1262 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1263 g_signal_connect(G_OBJECT(pkd->keyword_view), "populate-popup",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1264 G_CALLBACK(bar_pane_keywords_populate_popup_cb), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1265 gtk_widget_show(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1266
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1267 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pkd->keyword_view));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1268 g_signal_connect(G_OBJECT(buffer), "changed",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1269 G_CALLBACK(bar_pane_keywords_changed), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1270
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1271 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1272 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1273 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1274 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1275 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1276 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1277
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1278
1595
9e2111452988 fixed keyword tree initialization
nadvornik
parents: 1543
diff changeset
1279 if (!keyword_tree || !gtk_tree_model_get_iter_first(GTK_TREE_MODEL(keyword_tree), &iter))
9e2111452988 fixed keyword tree initialization
nadvornik
parents: 1543
diff changeset
1280 {
9e2111452988 fixed keyword tree initialization
nadvornik
parents: 1543
diff changeset
1281 /* keyword tree does not exist or is empty - fill with defaults */
9e2111452988 fixed keyword tree initialization
nadvornik
parents: 1543
diff changeset
1282 keyword_tree_new_default();
9e2111452988 fixed keyword tree initialization
nadvornik
parents: 1543
diff changeset
1283 }
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1284
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1285 store = gtk_tree_model_filter_new(GTK_TREE_MODEL(keyword_tree), NULL);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1286
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1287 gtk_tree_model_filter_set_modify_func(GTK_TREE_MODEL_FILTER(store),
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1288 FILTER_KEYWORD_COLUMN_COUNT,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1289 filter_keyword_column_types,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1290 bar_pane_keywords_filter_modify,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1291 pkd,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1292 NULL);
1428
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1293 gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(store),
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1294 bar_pane_keywords_filter_visible,
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1295 store,
3019f5d3a3c7 added keyword tree filtering
nadvornik
parents: 1425
diff changeset
1296 NULL);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1297
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1298 pkd->keyword_treeview = gtk_tree_view_new_with_model(store);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1299 g_object_unref(store);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1300
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1301 gtk_widget_set_size_request(pkd->keyword_treeview, -1, 400);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1302
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1303 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(pkd->keyword_treeview), FALSE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1304
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1305 // gtk_tree_view_set_search_column(GTK_TREE_VIEW(pkd->keyword_treeview), FILTER_KEYWORD_COLUMN_);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1306
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1307 column = gtk_tree_view_column_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1308 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1309
1425
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1310 renderer = gtk_cell_renderer_text_new();
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1311 gtk_tree_view_column_pack_start(column, renderer, TRUE);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1312
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1313 gtk_tree_view_column_add_attribute(column, renderer, "text", FILTER_KEYWORD_COLUMN_MARK);
1425
80462be81410 fixed keyword to mark connection
nadvornik
parents: 1421
diff changeset
1314
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1315 gtk_tree_view_append_column(GTK_TREE_VIEW(pkd->keyword_treeview), column);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1316
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1317 column = gtk_tree_view_column_new();
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1318 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1319 renderer = gtk_cell_renderer_toggle_new();
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1320 gtk_tree_view_column_pack_start(column, renderer, FALSE);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1321 gtk_tree_view_column_add_attribute(column, renderer, "active", FILTER_KEYWORD_COLUMN_TOGGLE);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1322 gtk_tree_view_column_add_attribute(column, renderer, "visible", FILTER_KEYWORD_COLUMN_IS_KEYWORD);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1323 g_signal_connect(G_OBJECT(renderer), "toggled",
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1324 G_CALLBACK(bar_pane_keywords_keyword_toggle), pkd);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1325
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1326 renderer = gtk_cell_renderer_text_new();
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1327 gtk_tree_view_column_pack_start(column, renderer, TRUE);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1328 gtk_tree_view_column_add_attribute(column, renderer, "text", FILTER_KEYWORD_COLUMN_NAME);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1329
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1330 gtk_tree_view_append_column(GTK_TREE_VIEW(pkd->keyword_treeview), column);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1331 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(pkd->keyword_treeview), column);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
1332
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1333 gtk_drag_source_set(pkd->keyword_treeview,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1334 GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1335 bar_pane_keywords_drag_types, n_keywords_drag_types,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1336 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1337
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1338 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_data_get",
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1339 G_CALLBACK(bar_pane_keywords_dnd_get), pkd);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1340
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1341 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_begin",
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1342 G_CALLBACK(bar_pane_keywords_dnd_begin), pkd);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1343 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_end",
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1344 G_CALLBACK(bar_pane_keywords_dnd_end), pkd);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1345
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1346 gtk_drag_dest_set(pkd->keyword_treeview,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1347 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1348 bar_pane_keywords_drop_types, n_keywords_drop_types,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1349 GDK_ACTION_COPY | GDK_ACTION_MOVE);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1350
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1351 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_data_received",
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1352 G_CALLBACK(bar_pane_keywords_dnd_receive), pkd);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1353
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1354 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_motion",
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1355 G_CALLBACK(bar_pane_keywords_dnd_motion), pkd);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
1356
1739
70f58b0dd4aa Fix contextual menus in lateral bars.
zas_
parents: 1712
diff changeset
1357 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "button_release_event",
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1358 G_CALLBACK(bar_pane_keywords_menu_cb), pkd);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
1359
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1360 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1361 gtk_widget_show(pkd->keyword_treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1362
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1363 file_data_register_notify_func(bar_pane_keywords_notify_cb, pkd, NOTIFY_PRIORITY_LOW);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1364
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1365 return pkd->widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1366 }
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1367
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1368 GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1369 {
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1370 gchar *id = g_strdup("keywords");
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
1371 gchar *title = NULL;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1372 gchar *key = g_strdup(COMMENT_KEY);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1373 gboolean expanded = TRUE;
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1374 GtkWidget *ret;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1375
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1376 while (*attribute_names)
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1377 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1378 const gchar *option = *attribute_names++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1379 const gchar *value = *attribute_values++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1380
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1381 if (READ_CHAR_FULL("id", id)) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1382 if (READ_CHAR_FULL("title", title)) continue;
1315
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
1383 if (READ_CHAR_FULL("key", key)) continue;
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1384 if (READ_BOOL_FULL("expanded", expanded)) continue;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1385
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1386
1464
1b3751ac4743 be more verbose on parse errors
nadvornik
parents: 1461
diff changeset
1387 log_printf("unknown attribute %s = %s\n", option, value);
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1388 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1389
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
1390 bar_pane_translate_title(PANE_KEYWORDS, id, &title);
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1391 ret = bar_pane_keywords_new(id, title, key, expanded);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1392 g_free(id);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1393 g_free(title);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1394 g_free(key);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1395 return ret;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1396 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
1397
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1398 void bar_pane_keywords_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1399 {
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1400 PaneKeywordsData *pkd;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1401
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1402 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1403 if (!pkd) return;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1404
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1405 gchar *title = NULL;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1406
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1407 while (*attribute_names)
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1408 {
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1409 const gchar *option = *attribute_names++;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1410 const gchar *value = *attribute_values++;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1411
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1412 if (READ_CHAR_FULL("title", title)) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1413 if (READ_CHAR_FULL("key", pkd->key)) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1414 if (READ_BOOL_FULL("expanded", pkd->pane.expanded)) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1415 if (READ_CHAR_FULL("id", pkd->pane.id)) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1416
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1417
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1418 log_printf("unknown attribute %s = %s\n", option, value);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1419 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1420
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1421 if (title)
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1422 {
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
1423 bar_pane_translate_title(PANE_KEYWORDS, pkd->pane.id, &title);
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1424 gtk_label_set_text(GTK_LABEL(pkd->pane.title), title);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1425 g_free(title);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1426 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1427
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1428 bar_update_expander(pane);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1429 bar_pane_keywords_update(pkd);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1430 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1431
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1465
diff changeset
1432
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1433 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */