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