annotate src/bar_keywords.c @ 1414:6ce1f7171d48

added a popup menu in keyword tree
author nadvornik
date Wed, 11 Mar 2009 21:54:54 +0000
parents 58f0b4586c8c
children 130054d9dd8a
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 static const gchar *keyword_favorite_defaults[] = {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
33 N_("Favorite"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
34 N_("Todo"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
35 N_("People"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
36 N_("Places"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
37 N_("Art"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
38 N_("Nature"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
39 N_("Possessions"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
40 NULL
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
43
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
44 static void bar_pane_keywords_keyword_update_all(void);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
45 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
46
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 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
49 * keyword / comment utils
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 */
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
1292
4a3ae0e6f1eb droped Preferences dialog, sidebar should replace it completely
nadvornik
parents: 1291
diff changeset
54 GList *keyword_list_pull(GtkWidget *text_widget)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
55 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
56 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
57 gchar *text;
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 text = text_widget_text_pull(text_widget);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
60 list = string_to_keywords_list(text);
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 g_free(text);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
63
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
64 return list;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
67 static void keyword_list_push(GtkWidget *textview, GList *list)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
68 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
69 GtkTextBuffer *buffer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
70 GtkTextIter start, end;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
71
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
72 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
73 gtk_text_buffer_get_bounds(buffer, &start, &end);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
74 gtk_text_buffer_delete(buffer, &start, &end);
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 while (list)
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 const gchar *word = list->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
79 GtkTextIter iter;
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 gtk_text_buffer_get_end_iter(buffer, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
82 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
83 gtk_text_buffer_get_end_iter(buffer, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
84 gtk_text_buffer_insert(buffer, &iter, "\n", -1);
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 list = list->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
87 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
88 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
89
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
90
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
91 /*
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
92 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
93 * info bar
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 */
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
96
1391
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 enum {
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
99 FILTER_KEYWORD_COLUMN_TOGGLE = 0,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
100 FILTER_KEYWORD_COLUMN_MARK,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
101 FILTER_KEYWORD_COLUMN_NAME,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
102 FILTER_KEYWORD_COLUMN_IS_KEYWORD,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
103 FILTER_KEYWORD_COLUMN_COUNT
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
104 };
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
105
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
106 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
107
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
108 typedef struct _PaneKeywordsData PaneKeywordsData;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
109 struct _PaneKeywordsData
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
110 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
111 PaneData pane;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
112 GtkWidget *widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
113
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
114 GtkWidget *keyword_view;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
115 GtkWidget *keyword_treeview;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
116
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
117 GtkTreePath *click_tpath;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
118
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
119 FileData *fd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
120 gchar *key;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
121 };
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
122
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
123
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
124 static GList *bar_list = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
125
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
126
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
127 static void bar_pane_keywords_write(PaneKeywordsData *pkd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
128 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
129 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
130
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
131 if (!pkd->fd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
132
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
133 list = keyword_list_pull(pkd->keyword_view);
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 metadata_write_list(pkd->fd, KEYWORD_KEY, list);
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 string_list_free(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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
140 static gchar *bar_pane_keywords_get_mark_text(const gchar *key)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
141 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
142 gint i;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
143 static gchar buf[10];
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 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
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 FileDataGetMarkFunc get_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
148 FileDataSetMarkFunc set_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
149 gpointer data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
150 file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
151 if (get_mark_func == meta_data_get_keyword_mark && strcmp(data, key) == 0)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
152 {
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
153 g_sprintf(buf, " %d ", i + 1);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
154 return buf;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
155 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
156 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
157 return " ... ";
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
158 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
159
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
160 gboolean bar_keyword_tree_expand_if_set(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
161 {
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
162 PaneKeywordsData *pkd = data;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
163 gboolean set;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
164
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
165 gtk_tree_model_get(model, iter, FILTER_KEYWORD_COLUMN_TOGGLE, &set, -1);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
166
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
167 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
168 {
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
169 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
170 }
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
171 return FALSE;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
172 }
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
173
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
174 static void bar_keyword_tree_sync(PaneKeywordsData *pkd)
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
175 {
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
176 GtkTreeModelFilter *store;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
177
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
178 store = GTK_TREE_MODEL_FILTER(gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)));
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
179
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
180 gtk_tree_model_filter_refilter(store);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
181 gtk_tree_model_foreach(GTK_TREE_MODEL(store), bar_keyword_tree_expand_if_set, pkd);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
182
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
183 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
184
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
185 static void bar_pane_keywords_keyword_update_all(void)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
186 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
187 GList *work;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
188
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
189 work = bar_list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
190 while (work)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
191 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
192 PaneKeywordsData *pkd;
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
193 // GList *keywords;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
194
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
195 pkd = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
196 work = work->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
197
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
198 bar_keyword_tree_sync(pkd);
1291
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 }
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 static void bar_pane_keywords_update(PaneKeywordsData *pkd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
203 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
204 GList *keywords = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
205 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
206
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
207 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
208
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
209 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
210 keyword_list_push(pkd->keyword_view, keywords);
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 string_list_free(keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
213
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
214 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
215
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
216 }
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 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
219 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
220 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
221
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
222 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
223 if (!pkd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
224
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
225 file_data_unref(pkd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
226 pkd->fd = file_data_ref(fd);
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 bar_pane_keywords_update(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
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
231 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
232 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
233 PaneKeywordsData *pkd;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
234
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
235 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
236 if (!pkd) return;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
237
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
238 WRITE_STRING("<pane_keywords\n");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
239 indent++;
1343
eebb8d0cb677 give the panes more control over expander title
nadvornik
parents: 1340
diff changeset
240 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(pkd->pane.title)));
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
241 WRITE_BOOL(*pkd, pane.expanded);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
242 WRITE_CHAR(*pkd, key);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
243 indent--;
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
244 WRITE_STRING("/>\n");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
245 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
246
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
247 gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
248 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
249 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
250
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
251 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
252 if (!pkd) return FALSE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
253
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
254 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
255
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
256 return FALSE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
257 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
258
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
259 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
260 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
261 PaneKeywordsData *pkd = data;
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
262 GtkTreeModel *model;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
263 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
264 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
265 gboolean active;
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
266 GList *list;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
267 GtkTreeIter child_iter;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
268 GtkTreeModel *keyword_tree;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
269
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
270 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
271
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
272 tpath = gtk_tree_path_new_from_string(path);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
273 gtk_tree_model_get_iter(model, &iter, tpath);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
274 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
275
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
276 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
277 active = (!active);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
278
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
279
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
280 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
281 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
282
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
283 list = keyword_list_pull(pkd->keyword_view);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
284 if (active)
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
285 keyword_tree_set(keyword_tree, &child_iter, &list);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
286 else
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
287 keyword_tree_reset(keyword_tree, &child_iter, &list);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
288
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
289 keyword_list_push(pkd->keyword_view, list);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
290 string_list_free(list);
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
291 /*
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
292 keyword_list_push triggers bar_pane_keywords_change which calls bar_keyword_tree_sync, no need to do it again
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
293 bar_keyword_tree_sync(pkd);
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
294 */
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
295 }
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
296
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
297 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
298 {
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
299 PaneKeywordsData *pkd = data;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
300 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
301 GtkTreeIter child_iter;
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
302
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
303 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
304
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
305 memset(value, 0, sizeof (GValue));
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
306
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
307 switch (column)
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
308 {
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
309 case FILTER_KEYWORD_COLUMN_TOGGLE:
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
310 {
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
311 GList *keywords = keyword_list_pull(pkd->keyword_view);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
312 gboolean set = keyword_tree_is_set(keyword_tree, &child_iter, keywords);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
313 string_list_free(keywords);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
314
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
315 g_value_init(value, G_TYPE_BOOLEAN);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
316 g_value_set_boolean(value, set);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
317 break;
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 case FILTER_KEYWORD_COLUMN_MARK:
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
320 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
321 break;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
322 case FILTER_KEYWORD_COLUMN_NAME:
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
323 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
324 break;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
325 case FILTER_KEYWORD_COLUMN_IS_KEYWORD:
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
326 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
327 break;
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 return;
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
330
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
331 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
332
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
333 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
334 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
335 GList *keywords = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
336 GList *list = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
337 GList *work;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
338
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
339 keywords = keyword_list_pull(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
340
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1346
diff changeset
341 list = layout_selection_list(pkd->pane.lw);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
342 work = list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
343 while (work)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
344 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
345 FileData *fd = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
346 work = work->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
347
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
348 if (append)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
349 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
350 metadata_append_list(fd, KEYWORD_KEY, keywords);
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 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
353 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
354 metadata_write_list(fd, KEYWORD_KEY, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
355 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
356 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
357
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
358 filelist_free(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
359 string_list_free(keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
360 }
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 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
363 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
364 PaneKeywordsData *pkd = data;
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 bar_pane_keywords_set_selection(pkd, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
367 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
368
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
369 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
370 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
371 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
372
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
373 bar_pane_keywords_set_selection(pkd, FALSE);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
376 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
377 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
378 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
379
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
380 menu_item_add_divider(GTK_WIDGET(menu));
1295
8c59e6e50bd8 Fix up few compilation warnings.
zas_
parents: 1292
diff changeset
381 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
382 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
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
386 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
387 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
388 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
389 if (fd == pkd->fd) bar_pane_keywords_update(pkd);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
392 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
393 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
394 PaneKeywordsData *pkd = data;
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 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
397 bar_pane_keywords_write(pkd);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
398 bar_keyword_tree_sync(pkd);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
399 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
400 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
401
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1343
diff changeset
402 static void bar_pane_keywords_mark_edited(GtkCellRendererText *cell, const gchar *path, const gchar *text, gpointer data)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
403 {
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
404 /* PaneKeywordsData *pkd = data;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
405 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
406 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
407 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
408 gchar *key = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
409 gint i;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
410 FileDataGetMarkFunc get_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
411 FileDataSetMarkFunc set_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
412 gpointer mark_func_data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
413
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
414 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
415
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
416 store = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
417
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
418 tpath = gtk_tree_path_new_from_string(path);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
419 gtk_tree_model_get_iter(store, &iter, tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
420 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
421
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
422 gtk_tree_model_get(store, &iter, FILTER_KEYWORD_COLUMN_TEXT, &key, -1);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
423
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
424 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
425 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
426 file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &mark_func_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
427 if (get_mark_func == meta_data_get_keyword_mark && strcmp(mark_func_data, key) == 0)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
428 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
429 g_free(mark_func_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
430 file_data_register_mark_func(i, NULL, NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
431 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
432 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
433
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
434 if (sscanf(text, " %d ", &i) &&i >=1 && i <= FILEDATA_MARKS_SIZE)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
435 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
436 i--;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
437 file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &mark_func_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
438 if (get_mark_func == meta_data_get_keyword_mark && mark_func_data) g_free(mark_func_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
439 file_data_register_mark_func(i, meta_data_get_keyword_mark, meta_data_set_keyword_mark, g_strdup(key));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
440 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
441
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
442 g_free(key);
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 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
445 bar_pane_keywords_update(pkd);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
446 */
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
447 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
448
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
449
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
450 static GtkTargetEntry bar_pane_keywords_drag_types[] = {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
451 { TARGET_APP_KEYWORD_PATH_STRING, GTK_TARGET_SAME_WIDGET, TARGET_APP_KEYWORD_PATH },
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
452 { "text/plain", 0, TARGET_TEXT_PLAIN }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
453 };
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
454 static gint n_keywords_drag_types = 2;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
455
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
456
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
457 static GtkTargetEntry bar_pane_keywords_drop_types[] = {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
458 { TARGET_APP_KEYWORD_PATH_STRING, GTK_TARGET_SAME_WIDGET, TARGET_APP_KEYWORD_PATH },
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
459 { "text/plain", 0, TARGET_TEXT_PLAIN }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
460 };
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
461 static gint n_keywords_drop_types = 2;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
462
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
463
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
464 static void bar_pane_keywords_dnd_get(GtkWidget *tree_view, GdkDragContext *context,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
465 GtkSelectionData *selection_data, guint info,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
466 guint time, gpointer data)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
467 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
468 GtkTreeIter iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
469 GtkTreeModel *model;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
470 GtkTreeIter child_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
471 GtkTreeModel *keyword_tree;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
472
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
473 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
474
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
475 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) return;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
476
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
477 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
478 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
479
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
480 switch (info)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
481 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
482 case TARGET_APP_KEYWORD_PATH:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
483 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
484 GList *path = keyword_tree_get_path(keyword_tree, &child_iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
485 gtk_selection_data_set(selection_data, selection_data->target,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
486 8, (gpointer) &path, sizeof(path));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
487 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
488 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
489
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
490 case TARGET_TEXT_PLAIN:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
491 default:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
492 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
493 gchar *name = keyword_get_name(keyword_tree, &child_iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
494 gtk_selection_data_set_text(selection_data, name, -1);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
495 g_free(name);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
496 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
497 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
498 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
499 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
500
1393
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
501 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
502 {
1393
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
503 GtkTreeIter iter;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
504 GtkTreeModel *model;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
505 GtkTreeIter child_iter;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
506 GtkTreeModel *keyword_tree;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
507 gchar *name;
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
508
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
509 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
510
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
511 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
512
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
513 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
514 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
515
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
516 name = keyword_get_name(keyword_tree, &child_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 dnd_set_drag_label(tree_view, context, name);
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
519 g_free(name);
79b32088ecc4 show a label instead of the default drag icon
nadvornik
parents: 1392
diff changeset
520
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
521 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
522
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
523 static void bar_pane_keywords_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
524 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
525 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
526
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
527 static void bar_pane_keywords_dnd_receive(GtkWidget *tree_view, GdkDragContext *context,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
528 gint x, gint y,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
529 GtkSelectionData *selection_data, guint info,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
530 guint time, gpointer data)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
531 {
1396
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
532 PaneKeywordsData *pkd = data;
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
533 GtkTreePath *tpath = NULL;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
534 GtkTreeViewDropPosition pos;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
535 GtkTreeModel *model;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
536
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
537 GtkTreeModel *keyword_tree;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
538 gboolean src_valid = FALSE;
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
539 GList *new_keywords = NULL;
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
540 GList *work;
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
541
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
542 /* iterators for keyword_tree */
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
543 GtkTreeIter src_kw_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
544 GtkTreeIter dest_kw_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
545 GtkTreeIter new_kw_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
546
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
547 g_signal_stop_emission_by_name(tree_view, "drag_data_received");
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
548
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
549 gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(tree_view), NULL, pos);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
550
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
551 model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
552 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
553
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
554 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
555
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
556
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
557 switch (info)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
558 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
559 case TARGET_APP_KEYWORD_PATH:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
560 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
561 GList *path = *(gpointer *)selection_data->data;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
562 src_valid = keyword_tree_get_iter(keyword_tree, &src_kw_iter, path);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
563 string_list_free(path);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
564 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
565 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
566 default:
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
567 new_keywords = string_to_keywords_list((gchar *)selection_data->data);
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
568 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
569 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
570
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
571 if (tpath)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
572 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
573 GtkTreeIter dest_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
574 gtk_tree_model_get_iter(model, &dest_iter, tpath);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
575 gtk_tree_path_free(tpath);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
576 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
577
1395
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
578 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
579 {
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
580 /* can't move to it's own child */
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
581 return;
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
582 }
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
583
1396
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
584 if (src_valid && keyword_compare(keyword_tree, &src_kw_iter, &dest_kw_iter) == 0)
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
585 {
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
586 /* can't move to itself */
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
587 return;
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
588 }
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
589
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
590 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
591 !gtk_tree_model_iter_has_child(keyword_tree, &dest_kw_iter))
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
592 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
593 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
594 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
595 else
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
596 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
597 switch (pos)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
598 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
599 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
600 case GTK_TREE_VIEW_DROP_BEFORE:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
601 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
602 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
603 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
604 case GTK_TREE_VIEW_DROP_AFTER:
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
605 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
606 break;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
607 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
608 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
609 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
610 else
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
611 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
612 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &new_kw_iter, NULL);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
613 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
614
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
615
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
616 if (src_valid)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
617 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
618 keyword_move_recursive(GTK_TREE_STORE(keyword_tree), &new_kw_iter, &src_kw_iter);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
619 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
620
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
621 work = new_keywords;
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
622 while (work)
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
623 {
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
624 keyword_set(GTK_TREE_STORE(keyword_tree), &new_kw_iter, work->data, TRUE);
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
625 work = work->next;
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
626 if (work)
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
627 {
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
628 GtkTreeIter add;
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
629 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
630 new_kw_iter = add;
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
631 }
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
632 }
1394
bec57fa486f4 allow dropping of multiple keywords
nadvornik
parents: 1393
diff changeset
633 string_list_free(new_keywords);
1396
58f0b4586c8c dnd fixes
nadvornik
parents: 1395
diff changeset
634 bar_keyword_tree_sync(pkd);
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
635 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
636
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
637 static gint bar_pane_keywords_dnd_motion(GtkWidget *tree_view, GdkDragContext *context,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
638 gint x, gint y, guint time, gpointer data)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
639 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
640 GtkTreePath *tpath = NULL;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
641 GtkTreeViewDropPosition pos;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
642 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
643 if (tpath)
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
644 {
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
645 GtkTreeModel *model;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
646 GtkTreeIter dest_iter;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
647 model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
648 gtk_tree_model_get_iter(model, &dest_iter, tpath);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
649 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
650 pos = GTK_TREE_VIEW_DROP_BEFORE;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
651
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
652 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
653 pos = GTK_TREE_VIEW_DROP_AFTER;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
654 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
655
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
656 gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(tree_view), tpath, pos);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
657 gtk_tree_path_free(tpath);
1395
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
658
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
659 if (tree_view == gtk_drag_get_source_widget(context))
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
660 gdk_drag_status(context, GDK_ACTION_MOVE, time);
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
661 else
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
662 gdk_drag_status(context, GDK_ACTION_COPY, time);
e86d8facbdae dnd fixes
nadvornik
parents: 1394
diff changeset
663
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
664 return TRUE;
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
665 }
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
666
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
667 static void bar_pane_keywords_conf_dialog_cb(GtkWidget *menu_widget, gpointer data)
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
668 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
669 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
670
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
671 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
672 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
673 PaneKeywordsData *pkd = data;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
674 GtkTreeModel *model;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
675 GtkTreeIter iter;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
676
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
677 GtkTreeModel *keyword_tree;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
678 GtkTreeIter kw_iter;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
679
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
680 if (!pkd->click_tpath) return;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
681
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
682 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
683 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
684
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
685 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
686 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
687
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
688 keyword_delete(GTK_TREE_STORE(keyword_tree), &kw_iter);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
689 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
690
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
691 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
692 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
693 GtkWidget *menu;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
694 GtkTreeViewDropPosition pos;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
695
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
696 if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
697 pkd->click_tpath = NULL;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
698 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
699
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
700 menu = popup_menu_short_lived();
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
701
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
702 if (pkd->click_tpath)
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
703 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
704 /* for the entry */
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
705 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
706
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
707 GtkTreeIter iter;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
708 gtk_tree_model_get_iter(model, &iter, pkd->click_tpath);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
709 gchar *name;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
710
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
711 gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_NAME, &name, -1);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
712
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
713 gchar *conf = g_strdup_printf(_("Configure \"%s\""), name);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
714 gchar *del = g_strdup_printf(_("Delete \"%s\""), name);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
715 menu_item_add_stock(menu, conf, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_conf_dialog_cb), pkd);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
716 menu_item_add_stock(menu, del, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_delete_cb), pkd);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
717 menu_item_add_divider(menu);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
718 g_free(conf);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
719 g_free(del);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
720 g_free(name);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
721 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
722 /* for the pane */
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
723 // menu_item_add_stock(menu, _("Add entry"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_keywords_conf_dialog_cb), pkd);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
724 // menu_item_add_check(menu, _("Show hidden entries"), pkd->show_all, G_CALLBACK(bar_pane_keywords_toggle_show_all_cb), pkd);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
725
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
726 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
727 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
728
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
729
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
730 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
731 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
732 PaneKeywordsData *pkd = data;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
733 if (bevent->button == MOUSE_BUTTON_RIGHT)
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
734 {
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
735 bar_pane_keywords_menu_popup(widget, pkd, bevent->x, bevent->y);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
736 return TRUE;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
737 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
738 return FALSE;
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
739 }
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
740
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
741
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
742 void bar_pane_keywords_close(GtkWidget *bar)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
743 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
744 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
745
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
746 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
747 if (!pkd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
748
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
749 gtk_widget_destroy(pkd->widget);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
750 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
751
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
752 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
753 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
754 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
755
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
756 if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
757
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
758 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
759
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
760 file_data_unref(pkd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
761 g_free(pkd->key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
762
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
763 g_free(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
764 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
765
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
766 static GtkTreeModel *create_marks_list(void)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
767 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
768 GtkListStore *model;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
769 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
770 gint i;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
771
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
772 /* create list store */
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
773 model = gtk_list_store_new(1, G_TYPE_STRING);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
774 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
775 {
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
776 gchar str[10];
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
777 g_sprintf(str, " %d ", i + 1);
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1343
diff changeset
778 gtk_list_store_append(model, &iter);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
779 gtk_list_store_set(model, &iter, 0, str, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
780 }
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1343
diff changeset
781 gtk_list_store_append(model, &iter);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
782 gtk_list_store_set(model, &iter, 0, " ... ", -1);
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
783 return GTK_TREE_MODEL(model);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
784 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
785
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
786
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
787 GtkWidget *bar_pane_keywords_new(const gchar *title, const gchar *key, gboolean expanded)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
788 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
789 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
790 GtkWidget *hbox;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
791 GtkWidget *scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
792 GtkTextBuffer *buffer;
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
793 GtkTreeModel *store;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
794 GtkTreeViewColumn *column;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
795 GtkCellRenderer *renderer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
796
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
797 pkd = g_new0(PaneKeywordsData, 1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
798
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
799 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
800 pkd->pane.pane_event = bar_pane_keywords_event;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
801 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
802 pkd->pane.title = bar_pane_expander_title(title);
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1346
diff changeset
803
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
804 pkd->pane.expanded = expanded;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
805
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
806 pkd->key = g_strdup(key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
807
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
808
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
809 hbox = gtk_hbox_new(FALSE, PREF_PAD_GAP);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
810
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
811 pkd->widget = hbox;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
812 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
813 g_signal_connect(G_OBJECT(pkd->widget), "destroy",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
814 G_CALLBACK(bar_pane_keywords_destroy), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
815 gtk_widget_show(hbox);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
816
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
817 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
818 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
819 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
820 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
821 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
822 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
823
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
824 pkd->keyword_view = gtk_text_view_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
825 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
826 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
827 G_CALLBACK(bar_pane_keywords_populate_popup_cb), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
828 gtk_widget_show(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
829
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
830 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
831 g_signal_connect(G_OBJECT(buffer), "changed",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
832 G_CALLBACK(bar_pane_keywords_changed), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
833
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
834 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
835 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
836 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
837 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
838 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
839 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
840
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
841
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
842 if (!keyword_tree) keyword_tree_new_default();
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
843
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
844 store = gtk_tree_model_filter_new(GTK_TREE_MODEL(keyword_tree), NULL);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
845
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
846 gtk_tree_model_filter_set_modify_func(GTK_TREE_MODEL_FILTER(store),
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
847 FILTER_KEYWORD_COLUMN_COUNT,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
848 filter_keyword_column_types,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
849 bar_pane_keywords_filter_modify,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
850 pkd,
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
851 NULL);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
852
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
853 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
854 g_object_unref(store);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
855
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
856 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
857
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
858 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
859
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
860 // 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
861
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
862 column = gtk_tree_view_column_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
863 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
864
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
865 renderer = gtk_cell_renderer_combo_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
866 g_object_set(G_OBJECT(renderer), "editable", (gboolean)TRUE,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
867 "model", create_marks_list(),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
868 "text-column", 0,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
869 "has-entry", FALSE,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
870 NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
871
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
872 gtk_tree_view_column_pack_start(column, renderer, TRUE);
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
873 gtk_tree_view_column_add_attribute(column, renderer, "text", FILTER_KEYWORD_COLUMN_MARK);
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1343
diff changeset
874 g_signal_connect(renderer, "edited",
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
875 G_CALLBACK (bar_pane_keywords_mark_edited), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
876 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
877
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
878
1391
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
879 column = gtk_tree_view_column_new();
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
880 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
881 renderer = gtk_cell_renderer_toggle_new();
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
882 gtk_tree_view_column_pack_start(column, renderer, FALSE);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
883 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
884 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
885 g_signal_connect(G_OBJECT(renderer), "toggled",
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
886 G_CALLBACK(bar_pane_keywords_keyword_toggle), pkd);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
887
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
888 renderer = gtk_cell_renderer_text_new();
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
889 gtk_tree_view_column_pack_start(column, renderer, TRUE);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
890 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
891
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
892 gtk_tree_view_append_column(GTK_TREE_VIEW(pkd->keyword_treeview), column);
9e0df7903581 implemented keywords editor as described at
nadvornik
parents: 1389
diff changeset
893 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
894
1392
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
895 gtk_drag_source_set(pkd->keyword_treeview,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
896 GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
897 bar_pane_keywords_drag_types, n_keywords_drag_types,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
898 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
899
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
900 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_data_get",
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
901 G_CALLBACK(bar_pane_keywords_dnd_get), pkd);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
902
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
903 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_begin",
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
904 G_CALLBACK(bar_pane_keywords_dnd_begin), pkd);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
905 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_end",
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
906 G_CALLBACK(bar_pane_keywords_dnd_end), pkd);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
907
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
908 gtk_drag_dest_set(pkd->keyword_treeview,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
909 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
910 bar_pane_keywords_drop_types, n_keywords_drop_types,
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
911 GDK_ACTION_COPY | GDK_ACTION_MOVE);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
912
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
913 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_data_received",
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
914 G_CALLBACK(bar_pane_keywords_dnd_receive), pkd);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
915
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
916 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_motion",
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
917 G_CALLBACK(bar_pane_keywords_dnd_motion), pkd);
d1b32a69b40a dnd in keywords tree
nadvornik
parents: 1391
diff changeset
918
1414
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
919 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "button_press_event",
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
920 G_CALLBACK(bar_pane_keywords_menu_cb), pkd);
6ce1f7171d48 added a popup menu in keyword tree
nadvornik
parents: 1396
diff changeset
921
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
922 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
923 gtk_widget_show(pkd->keyword_treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
924
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
925 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
926
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
927 return pkd->widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
928 }
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
929
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
930 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
931 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
932 gchar *title = g_strdup(_("NoName"));
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
933 gchar *key = g_strdup(COMMENT_KEY);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
934 gboolean expanded = TRUE;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
935
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
936 while (*attribute_names)
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
937 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
938 const gchar *option = *attribute_names++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
939 const gchar *value = *attribute_values++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
940
1315
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
941 if (READ_CHAR_FULL("pane.title", title)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
942 if (READ_CHAR_FULL("key", key)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
943 if (READ_BOOL_FULL("pane.expanded", expanded)) continue;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
944
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
945
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
946 DEBUG_1("unknown attribute %s = %s", option, value);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
947 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
948
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
949 return bar_pane_keywords_new(title, key, expanded);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
950 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
951
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
952 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */