Mercurial > geeqie
annotate src/bar_keywords.c @ 1425:80462be81410
fixed keyword to mark connection
author | nadvornik |
---|---|
date | Fri, 13 Mar 2009 09:03:06 +0000 |
parents | 130054d9dd8a |
children | 3019f5d3a3c7 |
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 | 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 | 28 #include "rcfile.h" |
1387 | 29 #include "layout.h" |
1392 | 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 | 97 |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
98 enum { |
1391 | 99 FILTER_KEYWORD_COLUMN_TOGGLE = 0, |
100 FILTER_KEYWORD_COLUMN_MARK, | |
101 FILTER_KEYWORD_COLUMN_NAME, | |
102 FILTER_KEYWORD_COLUMN_IS_KEYWORD, | |
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 | 106 static GType filter_keyword_column_types[] = {G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN}; |
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 | 117 GtkTreePath *click_tpath; |
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 |
1421 | 123 typedef struct _ConfDialogData ConfDialogData; |
124 struct _ConfDialogData | |
125 { | |
126 PaneKeywordsData *pkd; | |
127 GtkTreePath *click_tpath; | |
128 | |
129 /* dialog parts */ | |
130 GenericDialog *gd; | |
131 GtkWidget *edit_widget; | |
132 gboolean is_keyword; | |
133 | |
134 gboolean edit_existing; | |
135 }; | |
1291
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 static GList *bar_list = NULL; |
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 void bar_pane_keywords_write(PaneKeywordsData *pkd) |
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 GList *list; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
143 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
144 if (!pkd->fd) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
145 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
146 list = keyword_list_pull(pkd->keyword_view); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
147 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
148 metadata_write_list(pkd->fd, KEYWORD_KEY, list); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
149 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
150 string_list_free(list); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
151 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
152 |
1391 | 153 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
|
154 { |
1391 | 155 PaneKeywordsData *pkd = data; |
156 gboolean set; | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
157 |
1391 | 158 gtk_tree_model_get(model, iter, FILTER_KEYWORD_COLUMN_TOGGLE, &set, -1); |
159 | |
160 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
|
161 { |
1391 | 162 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(pkd->keyword_treeview), path); |
163 } | |
164 return FALSE; | |
165 } | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
166 |
1391 | 167 static void bar_keyword_tree_sync(PaneKeywordsData *pkd) |
168 { | |
169 GtkTreeModelFilter *store; | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
170 |
1391 | 171 store = GTK_TREE_MODEL_FILTER(gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview))); |
172 | |
173 gtk_tree_model_filter_refilter(store); | |
174 gtk_tree_model_foreach(GTK_TREE_MODEL(store), bar_keyword_tree_expand_if_set, pkd); | |
175 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
176 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
177 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
178 static void bar_pane_keywords_keyword_update_all(void) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
179 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
180 GList *work; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
181 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
182 work = bar_list; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
183 while (work) |
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 PaneKeywordsData *pkd; |
1391 | 186 // GList *keywords; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
187 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
188 pkd = work->data; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
189 work = work->next; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
190 |
1391 | 191 bar_keyword_tree_sync(pkd); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
192 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
193 } |
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 static void bar_pane_keywords_update(PaneKeywordsData *pkd) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
196 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
197 GList *keywords = NULL; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
198 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
|
199 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
200 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
|
201 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
202 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
|
203 keyword_list_push(pkd->keyword_view, keywords); |
1391 | 204 bar_keyword_tree_sync(pkd); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
205 string_list_free(keywords); |
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_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
|
208 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
209 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
210 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
211 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
|
212 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
213 PaneKeywordsData *pkd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
214 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
215 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
|
216 if (!pkd) return; |
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 file_data_unref(pkd->fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
219 pkd->fd = file_data_ref(fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
220 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
221 bar_pane_keywords_update(pkd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
222 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
223 |
1309 | 224 static void bar_pane_keywords_write_config(GtkWidget *pane, GString *outstr, gint indent) |
225 { | |
226 PaneKeywordsData *pkd; | |
227 | |
228 pkd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
229 if (!pkd) return; | |
230 | |
1314 | 231 WRITE_STRING("<pane_keywords\n"); |
1309 | 232 indent++; |
1343 | 233 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(pkd->pane.title))); |
1309 | 234 WRITE_BOOL(*pkd, pane.expanded); |
235 WRITE_CHAR(*pkd, key); | |
236 indent--; | |
1314 | 237 WRITE_STRING("/>\n"); |
1309 | 238 } |
239 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
240 gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
241 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
242 PaneKeywordsData *pkd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
243 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
244 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
|
245 if (!pkd) return FALSE; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
246 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
247 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
|
248 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
249 return FALSE; |
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 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
252 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
|
253 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
254 PaneKeywordsData *pkd = data; |
1391 | 255 GtkTreeModel *model; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
256 GtkTreeIter iter; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
257 GtkTreePath *tpath; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
258 gboolean active; |
1391 | 259 GList *list; |
260 GtkTreeIter child_iter; | |
261 GtkTreeModel *keyword_tree; | |
262 | |
263 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
|
264 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
265 tpath = gtk_tree_path_new_from_string(path); |
1391 | 266 gtk_tree_model_get_iter(model, &iter, tpath); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
267 gtk_tree_path_free(tpath); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
268 |
1391 | 269 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
|
270 active = (!active); |
1391 | 271 |
272 | |
273 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); | |
274 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter); | |
275 | |
276 list = keyword_list_pull(pkd->keyword_view); | |
277 if (active) | |
278 keyword_tree_set(keyword_tree, &child_iter, &list); | |
279 else | |
280 keyword_tree_reset(keyword_tree, &child_iter, &list); | |
281 | |
282 keyword_list_push(pkd->keyword_view, list); | |
283 string_list_free(list); | |
1392 | 284 /* |
285 keyword_list_push triggers bar_pane_keywords_change which calls bar_keyword_tree_sync, no need to do it again | |
1391 | 286 bar_keyword_tree_sync(pkd); |
1392 | 287 */ |
1391 | 288 } |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
289 |
1391 | 290 void bar_pane_keywords_filter_modify(GtkTreeModel *model, GtkTreeIter *iter, GValue *value, gint column, gpointer data) |
291 { | |
292 PaneKeywordsData *pkd = data; | |
293 GtkTreeModel *keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); | |
294 GtkTreeIter child_iter; | |
1392 | 295 |
1391 | 296 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, iter); |
297 | |
298 memset(value, 0, sizeof (GValue)); | |
299 | |
300 switch (column) | |
301 { | |
302 case FILTER_KEYWORD_COLUMN_TOGGLE: | |
303 { | |
304 GList *keywords = keyword_list_pull(pkd->keyword_view); | |
305 gboolean set = keyword_tree_is_set(keyword_tree, &child_iter, keywords); | |
306 string_list_free(keywords); | |
307 | |
308 g_value_init(value, G_TYPE_BOOLEAN); | |
309 g_value_set_boolean(value, set); | |
310 break; | |
311 } | |
312 case FILTER_KEYWORD_COLUMN_MARK: | |
313 gtk_tree_model_get_value(keyword_tree, &child_iter, KEYWORD_COLUMN_MARK, value); | |
314 break; | |
315 case FILTER_KEYWORD_COLUMN_NAME: | |
316 gtk_tree_model_get_value(keyword_tree, &child_iter, KEYWORD_COLUMN_NAME, value); | |
317 break; | |
318 case FILTER_KEYWORD_COLUMN_IS_KEYWORD: | |
319 gtk_tree_model_get_value(keyword_tree, &child_iter, KEYWORD_COLUMN_IS_KEYWORD, value); | |
320 break; | |
321 } | |
322 return; | |
323 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
324 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
325 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
326 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
|
327 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
328 GList *keywords = NULL; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
329 GList *list = NULL; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
330 GList *work; |
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 keywords = keyword_list_pull(pkd->keyword_view); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
333 |
1387 | 334 list = layout_selection_list(pkd->pane.lw); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
335 work = list; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
336 while (work) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
337 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
338 FileData *fd = work->data; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
339 work = work->next; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
340 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
341 if (append) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
342 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
343 metadata_append_list(fd, KEYWORD_KEY, keywords); |
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 else |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
346 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
347 metadata_write_list(fd, KEYWORD_KEY, keywords); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
348 } |
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 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
351 filelist_free(list); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
352 string_list_free(keywords); |
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 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
355 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
|
356 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
357 PaneKeywordsData *pkd = data; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
358 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
359 bar_pane_keywords_set_selection(pkd, TRUE); |
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_replace_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, FALSE); |
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_populate_popup_cb(GtkTextView *textview, GtkMenu *menu, 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 menu_item_add_divider(GTK_WIDGET(menu)); |
1295 | 374 menu_item_add_stock(GTK_WIDGET(menu), _("Add keywords to selected files"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_keywords_sel_add_cb), pkd); |
375 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
|
376 } |
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 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
379 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
|
380 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
381 PaneKeywordsData *pkd = data; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
382 if (fd == pkd->fd) bar_pane_keywords_update(pkd); |
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 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
|
386 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
387 PaneKeywordsData *pkd = data; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
388 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
389 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
|
390 bar_pane_keywords_write(pkd); |
1391 | 391 bar_keyword_tree_sync(pkd); |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
392 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
|
393 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
394 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
395 |
1421 | 396 /* |
397 *------------------------------------------------------------------- | |
398 * dnd | |
399 *------------------------------------------------------------------- | |
400 */ | |
401 | |
1392 | 402 |
403 static GtkTargetEntry bar_pane_keywords_drag_types[] = { | |
404 { TARGET_APP_KEYWORD_PATH_STRING, GTK_TARGET_SAME_WIDGET, TARGET_APP_KEYWORD_PATH }, | |
405 { "text/plain", 0, TARGET_TEXT_PLAIN } | |
406 }; | |
407 static gint n_keywords_drag_types = 2; | |
408 | |
409 | |
410 static GtkTargetEntry bar_pane_keywords_drop_types[] = { | |
411 { TARGET_APP_KEYWORD_PATH_STRING, GTK_TARGET_SAME_WIDGET, TARGET_APP_KEYWORD_PATH }, | |
412 { "text/plain", 0, TARGET_TEXT_PLAIN } | |
413 }; | |
414 static gint n_keywords_drop_types = 2; | |
415 | |
416 | |
417 static void bar_pane_keywords_dnd_get(GtkWidget *tree_view, GdkDragContext *context, | |
418 GtkSelectionData *selection_data, guint info, | |
419 guint time, gpointer data) | |
420 { | |
421 GtkTreeIter iter; | |
422 GtkTreeModel *model; | |
423 GtkTreeIter child_iter; | |
424 GtkTreeModel *keyword_tree; | |
425 | |
426 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); | |
427 | |
428 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) return; | |
429 | |
430 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); | |
431 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter); | |
432 | |
433 switch (info) | |
434 { | |
435 case TARGET_APP_KEYWORD_PATH: | |
436 { | |
437 GList *path = keyword_tree_get_path(keyword_tree, &child_iter); | |
438 gtk_selection_data_set(selection_data, selection_data->target, | |
439 8, (gpointer) &path, sizeof(path)); | |
440 break; | |
441 } | |
442 | |
443 case TARGET_TEXT_PLAIN: | |
444 default: | |
445 { | |
446 gchar *name = keyword_get_name(keyword_tree, &child_iter); | |
447 gtk_selection_data_set_text(selection_data, name, -1); | |
448 g_free(name); | |
449 } | |
450 break; | |
451 } | |
452 } | |
453 | |
1393 | 454 static void bar_pane_keywords_dnd_begin(GtkWidget *tree_view, GdkDragContext *context, gpointer data) |
1392 | 455 { |
1393 | 456 GtkTreeIter iter; |
457 GtkTreeModel *model; | |
458 GtkTreeIter child_iter; | |
459 GtkTreeModel *keyword_tree; | |
460 gchar *name; | |
461 | |
462 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); | |
463 | |
464 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) return; | |
465 | |
466 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); | |
467 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &child_iter, &iter); | |
468 | |
469 name = keyword_get_name(keyword_tree, &child_iter); | |
470 | |
471 dnd_set_drag_label(tree_view, context, name); | |
472 g_free(name); | |
473 | |
1392 | 474 } |
475 | |
476 static void bar_pane_keywords_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
477 { | |
478 } | |
479 | |
480 static void bar_pane_keywords_dnd_receive(GtkWidget *tree_view, GdkDragContext *context, | |
481 gint x, gint y, | |
482 GtkSelectionData *selection_data, guint info, | |
483 guint time, gpointer data) | |
484 { | |
1396 | 485 PaneKeywordsData *pkd = data; |
1392 | 486 GtkTreePath *tpath = NULL; |
487 GtkTreeViewDropPosition pos; | |
488 GtkTreeModel *model; | |
489 | |
490 GtkTreeModel *keyword_tree; | |
491 gboolean src_valid = FALSE; | |
1394 | 492 GList *new_keywords = NULL; |
493 GList *work; | |
1392 | 494 |
495 /* iterators for keyword_tree */ | |
496 GtkTreeIter src_kw_iter; | |
497 GtkTreeIter dest_kw_iter; | |
498 GtkTreeIter new_kw_iter; | |
499 | |
500 g_signal_stop_emission_by_name(tree_view, "drag_data_received"); | |
501 | |
502 gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(tree_view), NULL, pos); | |
503 | |
504 model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view)); | |
505 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); | |
506 | |
507 gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(tree_view), x, y, &tpath, &pos); | |
508 | |
509 | |
510 switch (info) | |
511 { | |
512 case TARGET_APP_KEYWORD_PATH: | |
513 { | |
514 GList *path = *(gpointer *)selection_data->data; | |
515 src_valid = keyword_tree_get_iter(keyword_tree, &src_kw_iter, path); | |
516 string_list_free(path); | |
517 break; | |
518 } | |
519 default: | |
1394 | 520 new_keywords = string_to_keywords_list((gchar *)selection_data->data); |
1392 | 521 break; |
522 } | |
523 | |
524 if (tpath) | |
525 { | |
526 GtkTreeIter dest_iter; | |
527 gtk_tree_model_get_iter(model, &dest_iter, tpath); | |
528 gtk_tree_path_free(tpath); | |
529 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &dest_kw_iter, &dest_iter); | |
530 | |
1395 | 531 if (src_valid && gtk_tree_store_is_ancestor(GTK_TREE_STORE(keyword_tree), &src_kw_iter, &dest_kw_iter)) |
532 { | |
533 /* can't move to it's own child */ | |
534 return; | |
535 } | |
1392 | 536 |
1396 | 537 if (src_valid && keyword_compare(keyword_tree, &src_kw_iter, &dest_kw_iter) == 0) |
538 { | |
539 /* can't move to itself */ | |
540 return; | |
541 } | |
542 | |
1392 | 543 if ((pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE || pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER) && |
544 !gtk_tree_model_iter_has_child(keyword_tree, &dest_kw_iter)) | |
545 { | |
546 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &new_kw_iter, &dest_kw_iter); | |
547 } | |
548 else | |
549 { | |
550 switch (pos) | |
551 { | |
552 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
553 case GTK_TREE_VIEW_DROP_BEFORE: | |
554 gtk_tree_store_insert_before(GTK_TREE_STORE(keyword_tree), &new_kw_iter, NULL, &dest_kw_iter); | |
555 break; | |
556 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
557 case GTK_TREE_VIEW_DROP_AFTER: | |
558 gtk_tree_store_insert_after(GTK_TREE_STORE(keyword_tree), &new_kw_iter, NULL, &dest_kw_iter); | |
559 break; | |
560 } | |
561 } | |
562 } | |
563 else | |
564 { | |
565 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &new_kw_iter, NULL); | |
566 } | |
567 | |
568 | |
569 if (src_valid) | |
570 { | |
571 keyword_move_recursive(GTK_TREE_STORE(keyword_tree), &new_kw_iter, &src_kw_iter); | |
572 } | |
573 | |
1394 | 574 work = new_keywords; |
575 while (work) | |
1392 | 576 { |
1394 | 577 keyword_set(GTK_TREE_STORE(keyword_tree), &new_kw_iter, work->data, TRUE); |
578 work = work->next; | |
579 if (work) | |
580 { | |
581 GtkTreeIter add; | |
582 gtk_tree_store_insert_after(GTK_TREE_STORE(keyword_tree), &add, NULL, &new_kw_iter); | |
583 new_kw_iter = add; | |
584 } | |
1392 | 585 } |
1394 | 586 string_list_free(new_keywords); |
1396 | 587 bar_keyword_tree_sync(pkd); |
1392 | 588 } |
589 | |
590 static gint bar_pane_keywords_dnd_motion(GtkWidget *tree_view, GdkDragContext *context, | |
591 gint x, gint y, guint time, gpointer data) | |
592 { | |
593 GtkTreePath *tpath = NULL; | |
594 GtkTreeViewDropPosition pos; | |
595 gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(tree_view), x, y, &tpath, &pos); | |
596 if (tpath) | |
597 { | |
598 GtkTreeModel *model; | |
599 GtkTreeIter dest_iter; | |
600 model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view)); | |
601 gtk_tree_model_get_iter(model, &dest_iter, tpath); | |
602 if (pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE && gtk_tree_model_iter_has_child(model, &dest_iter)) | |
603 pos = GTK_TREE_VIEW_DROP_BEFORE; | |
604 | |
605 if (pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER && gtk_tree_model_iter_has_child(model, &dest_iter)) | |
606 pos = GTK_TREE_VIEW_DROP_AFTER; | |
607 } | |
608 | |
609 gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(tree_view), tpath, pos); | |
610 gtk_tree_path_free(tpath); | |
1395 | 611 |
612 if (tree_view == gtk_drag_get_source_widget(context)) | |
613 gdk_drag_status(context, GDK_ACTION_MOVE, time); | |
614 else | |
615 gdk_drag_status(context, GDK_ACTION_COPY, time); | |
616 | |
1392 | 617 return TRUE; |
618 } | |
619 | |
1421 | 620 /* |
621 *------------------------------------------------------------------- | |
622 * edit dialog | |
623 *------------------------------------------------------------------- | |
624 */ | |
625 | |
626 static void bar_pane_keywords_edit_destroy_cb(GtkWidget *widget, gpointer data) | |
627 { | |
628 ConfDialogData *cdd = data; | |
629 gtk_tree_path_free(cdd->click_tpath); | |
630 g_free(cdd); | |
631 } | |
632 | |
633 | |
634 static void bar_pane_keywords_edit_cancel_cb(GenericDialog *gd, gpointer data) | |
635 { | |
636 } | |
637 | |
638 | |
639 static void bar_pane_keywords_edit_ok_cb(GenericDialog *gd, gpointer data) | |
640 { | |
641 ConfDialogData *cdd = data; | |
642 PaneKeywordsData *pkd = cdd->pkd; | |
643 GtkTreeModel *model; | |
644 | |
645 GtkTreeModel *keyword_tree; | |
646 GtkTreeIter kw_iter; | |
647 | |
648 gboolean have_dest = FALSE; | |
649 | |
650 GList *keywords; | |
651 | |
652 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)); | |
653 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); | |
654 | |
655 if (cdd->click_tpath) | |
656 { | |
657 GtkTreeIter iter; | |
658 if (gtk_tree_model_get_iter(model, &iter, cdd->click_tpath)) | |
659 { | |
660 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter); | |
661 have_dest = TRUE; | |
662 } | |
663 } | |
664 | |
665 if (cdd->edit_existing && !have_dest) return; | |
666 | |
667 keywords = keyword_list_pull(cdd->edit_widget); | |
668 | |
669 if (cdd->edit_existing) | |
670 { | |
671 if (keywords && keywords->data) /* there should be one keyword */ | |
672 { | |
673 keyword_set(GTK_TREE_STORE(keyword_tree), &kw_iter, keywords->data, cdd->is_keyword); | |
674 } | |
675 } | |
676 else | |
677 { | |
678 GList *work = keywords; | |
679 | |
680 while (work) | |
681 { | |
682 GtkTreeIter add; | |
683 if (have_dest) | |
684 { | |
685 gtk_tree_store_insert_after(GTK_TREE_STORE(keyword_tree), &add, NULL, &kw_iter); | |
686 } | |
687 else | |
688 { | |
689 gtk_tree_store_append(GTK_TREE_STORE(keyword_tree), &add, NULL); | |
690 have_dest = TRUE; | |
691 } | |
692 kw_iter = add; | |
693 keyword_set(GTK_TREE_STORE(keyword_tree), &kw_iter, work->data, cdd->is_keyword); | |
694 work = work->next; | |
695 } | |
696 } | |
697 string_list_free(keywords); | |
698 } | |
699 | |
700 static void bar_pane_keywords_conf_set_helper(GtkWidget *widget, gpointer data) | |
701 { | |
702 ConfDialogData *cdd = data; | |
703 cdd->is_keyword = FALSE; | |
704 } | |
705 | |
706 static void bar_pane_keywords_conf_set_kw(GtkWidget *widget, gpointer data) | |
1414 | 707 { |
1421 | 708 ConfDialogData *cdd = data; |
709 cdd->is_keyword = TRUE; | |
710 } | |
711 | |
712 | |
713 | |
714 static void bar_pane_keywords_edit_dialog(PaneKeywordsData *pkd, gboolean edit_existing) | |
715 { | |
716 ConfDialogData *cdd; | |
717 GenericDialog *gd; | |
718 GtkWidget *table; | |
719 GtkWidget *group; | |
720 GtkWidget *button; | |
721 | |
722 gchar *name = NULL; | |
723 gboolean is_keyword = TRUE; | |
724 | |
725 | |
726 if (edit_existing && pkd->click_tpath) | |
727 { | |
728 GtkTreeModel *model; | |
729 GtkTreeIter iter; | |
730 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)); | |
731 | |
732 if (gtk_tree_model_get_iter(model, &iter, pkd->click_tpath)) | |
733 { | |
734 gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_NAME, &name, | |
735 FILTER_KEYWORD_COLUMN_IS_KEYWORD, &is_keyword, -1); | |
736 } | |
737 else | |
738 { | |
739 return; | |
740 } | |
741 } | |
742 | |
743 if (edit_existing && !name) return; | |
744 | |
745 | |
746 cdd = g_new0(ConfDialogData, 1); | |
747 cdd->pkd =pkd; | |
748 cdd->click_tpath = pkd->click_tpath; | |
749 pkd->click_tpath = NULL; | |
750 cdd->is_keyword = is_keyword; | |
751 cdd->edit_existing = edit_existing; | |
752 | |
753 cdd->gd = gd = generic_dialog_new(name ? _("Edit keyword") : _("Add keywords"), "keyword_edit", | |
754 pkd->widget, TRUE, | |
755 bar_pane_keywords_edit_cancel_cb, cdd); | |
756 g_signal_connect(G_OBJECT(gd->dialog), "destroy", | |
757 G_CALLBACK(bar_pane_keywords_edit_destroy_cb), cdd); | |
758 | |
759 | |
760 generic_dialog_add_message(gd, NULL, name ? _("Configure keyword") : _("Add keyword"), NULL); | |
761 | |
762 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, | |
763 bar_pane_keywords_edit_ok_cb, TRUE); | |
764 | |
765 table = pref_table_new(gd->vbox, 3, 1, FALSE, TRUE); | |
766 pref_table_label(table, 0, 0, _("Keyword:"), 1.0); | |
767 cdd->edit_widget = gtk_entry_new(); | |
768 gtk_widget_set_size_request(cdd->edit_widget, 300, -1); | |
769 if (name) gtk_entry_set_text(GTK_ENTRY(cdd->edit_widget), name); | |
770 gtk_table_attach_defaults(GTK_TABLE(table), cdd->edit_widget, 1, 2, 0, 1); | |
771 /* here could eventually be a text view instead of entry */ | |
772 generic_dialog_attach_default(gd, cdd->edit_widget); | |
773 gtk_widget_show(cdd->edit_widget); | |
774 | |
775 group = pref_group_new(gd->vbox, FALSE, _("Keyword type:"), GTK_ORIENTATION_VERTICAL); | |
776 | |
777 button = pref_radiobutton_new(group, NULL, _("Active keyword"), | |
778 (cdd->is_keyword), | |
779 G_CALLBACK(bar_pane_keywords_conf_set_kw), cdd); | |
780 button = pref_radiobutton_new(group, button, _("Helper"), | |
781 (!cdd->is_keyword), | |
782 G_CALLBACK(bar_pane_keywords_conf_set_helper), cdd); | |
783 g_free(name); | |
784 | |
785 gtk_widget_show(gd->dialog); | |
786 } | |
787 | |
788 | |
789 | |
790 | |
791 /* | |
792 *------------------------------------------------------------------- | |
793 * popup menu | |
794 *------------------------------------------------------------------- | |
795 */ | |
796 | |
797 static void bar_pane_keywords_edit_dialog_cb(GtkWidget *menu_widget, gpointer data) | |
798 { | |
799 PaneKeywordsData *pkd = data; | |
800 bar_pane_keywords_edit_dialog(pkd, TRUE); | |
801 } | |
802 | |
803 static void bar_pane_keywords_add_dialog_cb(GtkWidget *menu_widget, gpointer data) | |
804 { | |
805 PaneKeywordsData *pkd = data; | |
806 bar_pane_keywords_edit_dialog(pkd, FALSE); | |
1414 | 807 } |
808 | |
1425 | 809 static void bar_pane_keywords_connect_mark_cb(GtkWidget *menu_widget, gpointer data) |
810 { | |
811 PaneKeywordsData *pkd = data; | |
812 | |
813 GtkTreeModel *model; | |
814 GtkTreeIter iter; | |
815 | |
816 GtkTreeModel *keyword_tree; | |
817 GtkTreeIter kw_iter; | |
818 | |
819 gint mark = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_widget), "mark")) - 1; | |
820 | |
821 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)); | |
822 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); | |
823 | |
824 if (!pkd->click_tpath) return; | |
825 if (!gtk_tree_model_get_iter(model, &iter, pkd->click_tpath)) return; | |
826 | |
827 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter); | |
828 | |
829 file_data_unregister_notify_func(bar_pane_keywords_notify_cb, pkd); | |
830 | |
831 meta_data_connect_mark_with_keyword(keyword_tree, &kw_iter, mark); | |
832 | |
833 file_data_register_notify_func(bar_pane_keywords_notify_cb, pkd, NOTIFY_PRIORITY_LOW); | |
834 // bar_pane_keywords_update(pkd); | |
835 } | |
836 | |
837 | |
1414 | 838 static void bar_pane_keywords_delete_cb(GtkWidget *menu_widget, gpointer data) |
839 { | |
840 PaneKeywordsData *pkd = data; | |
841 GtkTreeModel *model; | |
842 GtkTreeIter iter; | |
843 | |
844 GtkTreeModel *keyword_tree; | |
845 GtkTreeIter kw_iter; | |
846 | |
847 if (!pkd->click_tpath) return; | |
848 | |
849 model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)); | |
850 keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); | |
851 | |
852 if (!gtk_tree_model_get_iter(model, &iter, pkd->click_tpath)) return; | |
853 gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &kw_iter, &iter); | |
854 | |
855 keyword_delete(GTK_TREE_STORE(keyword_tree), &kw_iter); | |
856 } | |
857 | |
858 static void bar_pane_keywords_menu_popup(GtkWidget *widget, PaneKeywordsData *pkd, gint x, gint y) | |
859 { | |
860 GtkWidget *menu; | |
861 GtkTreeViewDropPosition pos; | |
862 | |
863 if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath); | |
864 pkd->click_tpath = NULL; | |
865 gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(pkd->keyword_treeview), x, y, &pkd->click_tpath, &pos); | |
866 | |
867 menu = popup_menu_short_lived(); | |
868 | |
869 if (pkd->click_tpath) | |
870 { | |
871 /* for the entry */ | |
1425 | 872 GtkWidget *item; |
873 GtkWidget *submenu; | |
874 gchar *text; | |
875 gchar *mark; | |
876 gint i; | |
877 | |
1414 | 878 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)); |
879 | |
880 GtkTreeIter iter; | |
881 gtk_tree_model_get_iter(model, &iter, pkd->click_tpath); | |
882 gchar *name; | |
883 | |
1425 | 884 gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_NAME, &name, |
885 FILTER_KEYWORD_COLUMN_MARK, &mark, -1); | |
886 | |
887 text = g_strdup_printf(_("Edit \"%s\""), name); | |
888 menu_item_add_stock(menu, text, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_edit_dialog_cb), pkd); | |
889 g_free(text); | |
890 text = g_strdup_printf(_("Delete \"%s\""), name); | |
891 menu_item_add_stock(menu, text, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_delete_cb), pkd); | |
892 g_free(text); | |
1414 | 893 |
1425 | 894 submenu = gtk_menu_new(); |
895 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) | |
896 { | |
897 text = g_strdup_printf(_("Mark %d"), i + 1); | |
898 item = menu_item_add(submenu, text, G_CALLBACK(bar_pane_keywords_connect_mark_cb), pkd); | |
899 g_object_set_data(G_OBJECT(item), "mark", GINT_TO_POINTER(i + 1)); | |
900 g_free(text); | |
901 } | |
902 | |
903 text = g_strdup_printf(_("Connect \"%s\" to mark"), name); | |
904 item = menu_item_add(menu, text, NULL, NULL); | |
905 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
906 g_free(text); | |
907 | |
908 if (mark && mark[0]) | |
909 { | |
910 text = g_strdup_printf(_("Disconnect \"%s\" from mark %s"), name, mark); | |
911 menu_item_add_stock(menu, text, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_connect_mark_cb), pkd); | |
912 g_free(text); | |
913 } | |
914 | |
1414 | 915 menu_item_add_divider(menu); |
1425 | 916 g_free(mark); |
1414 | 917 g_free(name); |
918 } | |
919 /* for the pane */ | |
1421 | 920 menu_item_add_stock(menu, _("Add keyword"), GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_add_dialog_cb), pkd); |
1414 | 921 |
922 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); | |
923 } | |
924 | |
925 | |
926 static gboolean bar_pane_keywords_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
927 { | |
928 PaneKeywordsData *pkd = data; | |
929 if (bevent->button == MOUSE_BUTTON_RIGHT) | |
930 { | |
931 bar_pane_keywords_menu_popup(widget, pkd, bevent->x, bevent->y); | |
932 return TRUE; | |
933 } | |
934 return FALSE; | |
935 } | |
936 | |
1421 | 937 /* |
938 *------------------------------------------------------------------- | |
939 * init | |
940 *------------------------------------------------------------------- | |
941 */ | |
1392 | 942 |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
943 void bar_pane_keywords_close(GtkWidget *bar) |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
944 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
945 PaneKeywordsData *pkd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
946 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
947 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
|
948 if (!pkd) return; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
949 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
950 gtk_widget_destroy(pkd->widget); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
951 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
952 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
953 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
|
954 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
955 PaneKeywordsData *pkd = data; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
956 |
1414 | 957 if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath); |
958 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
959 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
|
960 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
961 file_data_unref(pkd->fd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
962 g_free(pkd->key); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
963 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
964 g_free(pkd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
965 } |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
966 |
1391 | 967 |
1309 | 968 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
|
969 { |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
970 PaneKeywordsData *pkd; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
971 GtkWidget *hbox; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
972 GtkWidget *scrolled; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
973 GtkTextBuffer *buffer; |
1391 | 974 GtkTreeModel *store; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
975 GtkTreeViewColumn *column; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
976 GtkCellRenderer *renderer; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
977 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
978 pkd = g_new0(PaneKeywordsData, 1); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
979 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
980 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
|
981 pkd->pane.pane_event = bar_pane_keywords_event; |
1309 | 982 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
|
983 pkd->pane.title = bar_pane_expander_title(title); |
1387 | 984 |
1309 | 985 pkd->pane.expanded = expanded; |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
986 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
987 pkd->key = g_strdup(key); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
988 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
989 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
990 hbox = gtk_hbox_new(FALSE, PREF_PAD_GAP); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
991 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
992 pkd->widget = hbox; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
993 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
|
994 g_signal_connect(G_OBJECT(pkd->widget), "destroy", |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
995 G_CALLBACK(bar_pane_keywords_destroy), pkd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
996 gtk_widget_show(hbox); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
997 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
998 scrolled = gtk_scrolled_window_new(NULL, NULL); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
999 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
|
1000 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1001 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1002 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
|
1003 gtk_widget_show(scrolled); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1004 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1005 pkd->keyword_view = gtk_text_view_new(); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1006 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_view); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1007 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
|
1008 G_CALLBACK(bar_pane_keywords_populate_popup_cb), pkd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1009 gtk_widget_show(pkd->keyword_view); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1010 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1011 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
|
1012 g_signal_connect(G_OBJECT(buffer), "changed", |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1013 G_CALLBACK(bar_pane_keywords_changed), pkd); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1014 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1015 scrolled = gtk_scrolled_window_new(NULL, NULL); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1016 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
|
1017 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1018 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1019 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
|
1020 gtk_widget_show(scrolled); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1021 |
1391 | 1022 |
1023 if (!keyword_tree) keyword_tree_new_default(); | |
1024 | |
1025 store = gtk_tree_model_filter_new(GTK_TREE_MODEL(keyword_tree), NULL); | |
1026 | |
1027 gtk_tree_model_filter_set_modify_func(GTK_TREE_MODEL_FILTER(store), | |
1028 FILTER_KEYWORD_COLUMN_COUNT, | |
1029 filter_keyword_column_types, | |
1030 bar_pane_keywords_filter_modify, | |
1031 pkd, | |
1032 NULL); | |
1033 | |
1034 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
|
1035 g_object_unref(store); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1036 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1037 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
|
1038 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1039 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
|
1040 |
1391 | 1041 // 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
|
1042 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1043 column = gtk_tree_view_column_new(); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1044 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
|
1045 |
1425 | 1046 renderer = gtk_cell_renderer_text_new(); |
1047 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1048 |
1391 | 1049 gtk_tree_view_column_add_attribute(column, renderer, "text", FILTER_KEYWORD_COLUMN_MARK); |
1425 | 1050 |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1051 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
|
1052 |
1391 | 1053 column = gtk_tree_view_column_new(); |
1054 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
1055 renderer = gtk_cell_renderer_toggle_new(); | |
1056 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
1057 gtk_tree_view_column_add_attribute(column, renderer, "active", FILTER_KEYWORD_COLUMN_TOGGLE); | |
1058 gtk_tree_view_column_add_attribute(column, renderer, "visible", FILTER_KEYWORD_COLUMN_IS_KEYWORD); | |
1059 g_signal_connect(G_OBJECT(renderer), "toggled", | |
1060 G_CALLBACK(bar_pane_keywords_keyword_toggle), pkd); | |
1061 | |
1062 renderer = gtk_cell_renderer_text_new(); | |
1063 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1064 gtk_tree_view_column_add_attribute(column, renderer, "text", FILTER_KEYWORD_COLUMN_NAME); | |
1065 | |
1066 gtk_tree_view_append_column(GTK_TREE_VIEW(pkd->keyword_treeview), column); | |
1067 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(pkd->keyword_treeview), column); | |
1068 | |
1392 | 1069 gtk_drag_source_set(pkd->keyword_treeview, |
1070 GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, | |
1071 bar_pane_keywords_drag_types, n_keywords_drag_types, | |
1072 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
1073 | |
1074 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_data_get", | |
1075 G_CALLBACK(bar_pane_keywords_dnd_get), pkd); | |
1076 | |
1077 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_begin", | |
1078 G_CALLBACK(bar_pane_keywords_dnd_begin), pkd); | |
1079 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_end", | |
1080 G_CALLBACK(bar_pane_keywords_dnd_end), pkd); | |
1081 | |
1082 gtk_drag_dest_set(pkd->keyword_treeview, | |
1083 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, | |
1084 bar_pane_keywords_drop_types, n_keywords_drop_types, | |
1085 GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
1086 | |
1087 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_data_received", | |
1088 G_CALLBACK(bar_pane_keywords_dnd_receive), pkd); | |
1089 | |
1090 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "drag_motion", | |
1091 G_CALLBACK(bar_pane_keywords_dnd_motion), pkd); | |
1092 | |
1414 | 1093 g_signal_connect(G_OBJECT(pkd->keyword_treeview), "button_press_event", |
1094 G_CALLBACK(bar_pane_keywords_menu_cb), pkd); | |
1095 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1096 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_treeview); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1097 gtk_widget_show(pkd->keyword_treeview); |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1098 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1099 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
|
1100 |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1101 return pkd->widget; |
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1102 } |
1309 | 1103 |
1104 GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values) | |
1105 { | |
1106 gchar *title = g_strdup(_("NoName")); | |
1107 gchar *key = g_strdup(COMMENT_KEY); | |
1108 gboolean expanded = TRUE; | |
1109 | |
1110 while (*attribute_names) | |
1111 { | |
1112 const gchar *option = *attribute_names++; | |
1113 const gchar *value = *attribute_values++; | |
1114 | |
1315 | 1115 if (READ_CHAR_FULL("pane.title", title)) continue; |
1116 if (READ_CHAR_FULL("key", key)) continue; | |
1117 if (READ_BOOL_FULL("pane.expanded", expanded)) continue; | |
1309 | 1118 |
1119 | |
1120 DEBUG_1("unknown attribute %s = %s", option, value); | |
1121 } | |
1122 | |
1123 return bar_pane_keywords_new(title, key, expanded); | |
1124 } | |
1125 | |
1291
50ae02a4a675
replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff
changeset
|
1126 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |