Mercurial > geeqie.yaz
annotate src/bar_info.c @ 1235:052f26dbe8cf
Silent warnings.
author | zas_ |
---|---|
date | Sat, 03 Jan 2009 17:13:20 +0000 |
parents | 31f50c1b6a9a |
children | 947e603a52c6 |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
9 | 3 * (C) 2004 John Ellis |
475 | 4 * Copyright (C) 2008 The Geeqie Team |
9 | 5 * |
6 * Author: John Ellis | |
7 * | |
8 * This software is released under the GNU General Public License (GNU GPL). | |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
11 */ | |
12 | |
13 | |
281 | 14 #include "main.h" |
9 | 15 #include "bar_info.h" |
16 | |
586 | 17 #include "filedata.h" |
902 | 18 #include "history_list.h" |
9 | 19 #include "info.h" |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
1174
diff
changeset
|
20 #include "metadata.h" |
1022
9962b24b6b43
Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents:
995
diff
changeset
|
21 #include "misc.h" |
9 | 22 #include "ui_fileops.h" |
23 #include "ui_misc.h" | |
24 #include "ui_utildlg.h" | |
1022
9962b24b6b43
Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents:
995
diff
changeset
|
25 #include "utilops.h" |
9 | 26 |
27 static const gchar *keyword_favorite_defaults[] = { | |
28 N_("Favorite"), | |
29 N_("Todo"), | |
30 N_("People"), | |
31 N_("Places"), | |
32 N_("Art"), | |
33 N_("Nature"), | |
34 N_("Possessions"), | |
35 NULL | |
36 }; | |
37 | |
38 | |
39 static void bar_info_keyword_update_all(void); | |
1217
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
40 static void bar_info_changed(GtkTextBuffer *buffer, gpointer data); |
9 | 41 |
42 /* | |
43 *------------------------------------------------------------------- | |
44 * keyword / comment utils | |
45 *------------------------------------------------------------------- | |
46 */ | |
47 | |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
138
diff
changeset
|
48 |
9 | 49 static gchar *comment_pull(GtkWidget *textview) |
50 { | |
51 GtkTextBuffer *buffer; | |
52 GtkTextIter start, end; | |
442 | 53 |
9 | 54 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); |
55 gtk_text_buffer_get_bounds(buffer, &start, &end); | |
442 | 56 |
9 | 57 return gtk_text_buffer_get_text(buffer, &start, &end, FALSE); |
58 } | |
59 | |
60 GList *keyword_list_pull(GtkWidget *text_widget) | |
61 { | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
1174
diff
changeset
|
62 GList *list; |
9 | 63 gchar *text; |
64 | |
65 if (GTK_IS_TEXT_VIEW(text_widget)) | |
66 { | |
67 text = comment_pull(text_widget); | |
68 } | |
69 else if (GTK_IS_ENTRY(text_widget)) | |
70 { | |
71 text = g_strdup(gtk_entry_get_text(GTK_ENTRY(text_widget))); | |
72 } | |
73 else | |
74 { | |
75 return NULL; | |
76 } | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
1174
diff
changeset
|
77 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
1174
diff
changeset
|
78 list = string_to_keywords_list(text); |
9 | 79 |
80 g_free(text); | |
81 | |
82 return list; | |
83 } | |
84 | |
85 void keyword_list_push(GtkWidget *textview, GList *list) | |
86 { | |
87 GtkTextBuffer *buffer; | |
88 GtkTextIter start, end; | |
89 | |
90 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); | |
91 gtk_text_buffer_get_bounds(buffer, &start, &end); | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
92 gtk_text_buffer_delete(buffer, &start, &end); |
9 | 93 |
94 while (list) | |
95 { | |
96 const gchar *word = list->data; | |
97 GtkTextIter iter; | |
98 | |
99 gtk_text_buffer_get_end_iter(buffer, &iter); | |
100 if (word) gtk_text_buffer_insert(buffer, &iter, word, -1); | |
101 gtk_text_buffer_get_end_iter(buffer, &iter); | |
102 gtk_text_buffer_insert(buffer, &iter, "\n", -1); | |
103 | |
104 list = list->next; | |
105 } | |
106 } | |
107 | |
108 | |
109 /* | |
110 *------------------------------------------------------------------- | |
111 * keyword list dialog | |
112 *------------------------------------------------------------------- | |
113 */ | |
114 | |
115 #define KEYWORD_DIALOG_WIDTH 200 | |
116 #define KEYWORD_DIALOG_HEIGHT 250 | |
117 | |
118 typedef struct _KeywordDlg KeywordDlg; | |
119 struct _KeywordDlg | |
120 { | |
121 GenericDialog *gd; | |
122 GtkWidget *treeview; | |
123 }; | |
124 | |
125 static KeywordDlg *keyword_dialog = NULL; | |
126 | |
127 | |
128 static void keyword_dialog_cancel_cb(GenericDialog *gd, gpointer data) | |
129 { | |
130 g_free(keyword_dialog); | |
131 keyword_dialog = NULL; | |
132 } | |
133 | |
134 static void keyword_dialog_ok_cb(GenericDialog *gd, gpointer data) | |
135 { | |
136 KeywordDlg *kd = data; | |
137 GtkTreeModel *store; | |
138 GtkTreeIter iter; | |
139 gint valid; | |
140 | |
141 history_list_free_key("keywords"); | |
142 | |
143 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview)); | |
144 valid = gtk_tree_model_get_iter_first(store, &iter); | |
145 while (valid) | |
146 { | |
147 gchar *key; | |
148 | |
149 gtk_tree_model_get(store, &iter, 0, &key, -1); | |
150 valid = gtk_tree_model_iter_next(store, &iter); | |
151 | |
152 history_list_add_to_key("keywords", key, 0); | |
153 } | |
154 | |
155 keyword_dialog_cancel_cb(gd, data); | |
156 | |
157 bar_info_keyword_update_all(); | |
158 } | |
159 | |
160 static void keyword_dialog_add_cb(GtkWidget *button, gpointer data) | |
161 { | |
162 KeywordDlg *kd = data; | |
163 GtkTreeSelection *selection; | |
164 GtkTreeModel *store; | |
165 GtkTreeIter sibling; | |
166 GtkTreeIter iter; | |
167 GtkTreePath *tpath; | |
168 | |
169 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(kd->treeview)); | |
170 if (gtk_tree_selection_get_selected(selection, &store, &sibling)) | |
171 { | |
172 gtk_list_store_insert_before(GTK_LIST_STORE(store), &iter, &sibling); | |
173 } | |
174 else | |
175 { | |
176 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview)); | |
177 gtk_list_store_append(GTK_LIST_STORE(store), &iter); | |
178 } | |
179 | |
180 gtk_list_store_set(GTK_LIST_STORE(store), &iter, 1, TRUE, -1); | |
181 | |
182 tpath = gtk_tree_model_get_path(store, &iter); | |
183 gtk_tree_view_set_cursor(GTK_TREE_VIEW(kd->treeview), tpath, | |
184 gtk_tree_view_get_column(GTK_TREE_VIEW(kd->treeview), 0), TRUE); | |
185 gtk_tree_path_free(tpath); | |
186 } | |
187 | |
188 static void keyword_dialog_remove_cb(GtkWidget *button, gpointer data) | |
189 { | |
190 KeywordDlg *kd = data; | |
191 GtkTreeSelection *selection; | |
192 GtkTreeModel *store; | |
193 GtkTreeIter iter; | |
194 GtkTreeIter next; | |
195 GtkTreePath *tpath; | |
196 | |
197 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(kd->treeview)); | |
198 if (!gtk_tree_selection_get_selected(selection, &store, &iter)) return; | |
199 | |
200 tpath = NULL; | |
201 next = iter; | |
202 if (gtk_tree_model_iter_next(store, &next)) | |
203 { | |
204 tpath = gtk_tree_model_get_path(store, &next); | |
205 } | |
206 else | |
207 { | |
208 tpath = gtk_tree_model_get_path(store, &iter); | |
209 if (!gtk_tree_path_prev(tpath)) | |
210 { | |
211 gtk_tree_path_free(tpath); | |
212 tpath = NULL; | |
213 } | |
214 } | |
215 if (tpath) | |
216 { | |
217 gtk_tree_view_set_cursor(GTK_TREE_VIEW(kd->treeview), tpath, | |
218 gtk_tree_view_get_column(GTK_TREE_VIEW(kd->treeview), 0), FALSE); | |
219 gtk_tree_path_free(tpath); | |
220 } | |
221 | |
222 gtk_list_store_remove(GTK_LIST_STORE(store), &iter); | |
223 } | |
224 | |
225 static void keyword_dialog_edit_cb(GtkCellRendererText *renderer, const gchar *path, | |
226 const gchar *new_text, gpointer data) | |
227 { | |
228 KeywordDlg *kd = data; | |
229 GtkTreeModel *store; | |
230 GtkTreeIter iter; | |
231 GtkTreePath *tpath; | |
232 | |
233 if (!new_text || strlen(new_text) == 0) return; | |
234 | |
235 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview)); | |
236 | |
237 tpath = gtk_tree_path_new_from_string(path); | |
238 gtk_tree_model_get_iter(store, &iter, tpath); | |
239 gtk_tree_path_free(tpath); | |
240 | |
241 gtk_list_store_set(GTK_LIST_STORE(store), &iter, 0, new_text, -1); | |
242 } | |
243 | |
244 static void keyword_dialog_populate(KeywordDlg *kd) | |
245 { | |
246 GtkListStore *store; | |
247 GList *list; | |
248 | |
249 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview))); | |
250 gtk_list_store_clear(store); | |
251 | |
252 list = history_list_get_by_key("keywords"); | |
253 list = g_list_last(list); | |
254 while (list) | |
255 { | |
256 GtkTreeIter iter; | |
257 | |
258 gtk_list_store_append(store, &iter); | |
259 gtk_list_store_set(store, &iter, 0, list->data, | |
260 1, TRUE, -1); | |
261 | |
262 list = list->prev; | |
263 } | |
264 } | |
265 | |
266 static void keyword_dialog_show(void) | |
267 { | |
268 GtkWidget *scrolled; | |
269 GtkListStore *store; | |
270 GtkTreeViewColumn *column; | |
271 GtkCellRenderer *renderer; | |
272 GtkWidget *hbox; | |
273 GtkWidget *button; | |
274 | |
275 if (keyword_dialog) | |
276 { | |
277 gtk_window_present(GTK_WINDOW(keyword_dialog->gd->dialog)); | |
278 return; | |
279 } | |
280 | |
281 keyword_dialog = g_new0(KeywordDlg, 1); | |
282 | |
283 keyword_dialog->gd = generic_dialog_new(_("Keyword Presets"), | |
1174
0bea79d87065
Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents:
1148
diff
changeset
|
284 "keyword_presets", NULL, TRUE, |
9 | 285 keyword_dialog_cancel_cb, keyword_dialog); |
286 generic_dialog_add_message(keyword_dialog->gd, NULL, _("Favorite keywords list"), NULL); | |
287 | |
288 generic_dialog_add_button(keyword_dialog->gd, GTK_STOCK_OK, NULL, | |
289 keyword_dialog_ok_cb, TRUE); | |
290 | |
291 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
292 gtk_widget_set_size_request(scrolled, KEYWORD_DIALOG_WIDTH, KEYWORD_DIALOG_HEIGHT); | |
293 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | |
294 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | |
295 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
296 gtk_box_pack_start(GTK_BOX(keyword_dialog->gd->vbox), scrolled, TRUE, TRUE, 5); | |
297 gtk_widget_show(scrolled); | |
298 | |
299 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN); | |
300 keyword_dialog->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
301 g_object_unref(store); | |
302 | |
303 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(keyword_dialog->treeview), FALSE); | |
304 gtk_tree_view_set_search_column(GTK_TREE_VIEW(keyword_dialog->treeview), 0); | |
305 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(keyword_dialog->treeview), TRUE); | |
306 | |
307 column = gtk_tree_view_column_new(); | |
308 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
309 renderer = gtk_cell_renderer_text_new(); | |
310 g_signal_connect(G_OBJECT(renderer), "edited", | |
311 G_CALLBACK(keyword_dialog_edit_cb), keyword_dialog); | |
312 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
313 gtk_tree_view_column_add_attribute(column, renderer, "text", 0); | |
314 gtk_tree_view_column_add_attribute(column, renderer, "editable", 1); | |
315 gtk_tree_view_append_column(GTK_TREE_VIEW(keyword_dialog->treeview), column); | |
316 | |
317 gtk_container_add(GTK_CONTAINER(scrolled), keyword_dialog->treeview); | |
318 gtk_widget_show(keyword_dialog->treeview); | |
319 | |
320 hbox = gtk_hbox_new(FALSE, 5); | |
321 gtk_box_pack_start(GTK_BOX(keyword_dialog->gd->vbox), hbox, FALSE, FALSE, 0); | |
322 gtk_widget_show(hbox); | |
323 | |
324 button = gtk_button_new_from_stock(GTK_STOCK_ADD); | |
325 g_signal_connect(G_OBJECT(button), "clicked", | |
326 G_CALLBACK(keyword_dialog_add_cb), keyword_dialog); | |
327 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
328 gtk_widget_show(button); | |
329 | |
330 button = gtk_button_new_from_stock(GTK_STOCK_REMOVE); | |
331 g_signal_connect(G_OBJECT(button), "clicked", | |
332 G_CALLBACK(keyword_dialog_remove_cb), keyword_dialog); | |
333 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
334 gtk_widget_show(button); | |
335 | |
336 keyword_dialog_populate(keyword_dialog); | |
337 | |
338 gtk_widget_show(keyword_dialog->gd->dialog); | |
339 } | |
340 | |
341 | |
342 static void bar_keyword_edit_cb(GtkWidget *button, gpointer data) | |
343 { | |
344 keyword_dialog_show(); | |
345 } | |
346 | |
347 | |
348 /* | |
349 *------------------------------------------------------------------- | |
350 * info bar | |
351 *------------------------------------------------------------------- | |
352 */ | |
353 | |
354 typedef enum { | |
355 BAR_SORT_COPY, | |
356 BAR_SORT_MOVE, | |
357 BAR_SORT_LINK | |
358 } SortActionType; | |
359 | |
360 enum { | |
361 KEYWORD_COLUMN_TOGGLE = 0, | |
1223
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
362 KEYWORD_COLUMN_TEXT, |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
363 KEYWORD_COLUMN_MARK |
9 | 364 }; |
365 | |
366 typedef struct _BarInfoData BarInfoData; | |
367 struct _BarInfoData | |
368 { | |
369 GtkWidget *vbox; | |
370 GtkWidget *group_box; | |
371 GtkWidget *label_file_name; | |
372 GtkWidget *label_file_time; | |
373 | |
374 GtkWidget *keyword_view; | |
375 GtkWidget *keyword_treeview; | |
376 | |
377 GtkWidget *comment_view; | |
378 | |
1217
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
379 #if 0 |
9 | 380 GtkWidget *button_save; |
1217
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
381 #endif |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
382 GtkWidget *button_set_keywords_add; |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
383 GtkWidget *button_set_keywords_replace; |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
384 GtkWidget *button_set_comment_add; |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
385 GtkWidget *button_set_comment_replace; |
9 | 386 |
138 | 387 FileData *fd; |
9 | 388 |
389 GList *(*list_func)(gpointer); | |
390 gpointer list_data; | |
391 }; | |
392 | |
393 | |
394 static GList *bar_list = NULL; | |
395 | |
396 | |
397 static void bar_info_write(BarInfoData *bd) | |
398 { | |
399 GList *list; | |
400 gchar *comment; | |
401 | |
138 | 402 if (!bd->fd) return; |
9 | 403 |
404 list = keyword_list_pull(bd->keyword_view); | |
405 comment = comment_pull(bd->comment_view); | |
406 | |
1234
31f50c1b6a9a
write keywords and comments with separate functions
nadvornik
parents:
1223
diff
changeset
|
407 metadata_write_string(bd->fd, COMMENT_KEY, comment); |
31f50c1b6a9a
write keywords and comments with separate functions
nadvornik
parents:
1223
diff
changeset
|
408 metadata_write_list(bd->fd, KEYWORD_KEY, list); |
9 | 409 |
138 | 410 string_list_free(list); |
9 | 411 g_free(comment); |
412 } | |
413 | |
1223
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
414 static gchar *bar_info_get_mark_text(const gchar *key) |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
415 { |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
416 gint i; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
417 static gchar buf[10]; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
418 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
419 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
420 { |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
421 FileDataGetMarkFunc get_mark_func; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
422 FileDataSetMarkFunc set_mark_func; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
423 gpointer data; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
424 file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &data); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
425 if (get_mark_func == meta_data_get_keyword_mark && strcmp(data, key) == 0) |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
426 { |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
427 sprintf(buf, " %d ", i + 1); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
428 return buf; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
429 } |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
430 } |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
431 return " ... "; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
432 } |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
433 |
9 | 434 static void bar_keyword_list_sync(BarInfoData *bd, GList *keywords) |
435 { | |
436 GList *list; | |
437 GtkListStore *store; | |
438 GtkTreeIter iter; | |
439 | |
440 list = history_list_get_by_key("keywords"); | |
441 if (!list) | |
442 { | |
443 /* blank? set up a few example defaults */ | |
444 | |
445 gint i = 0; | |
446 | |
447 while (keyword_favorite_defaults[i] != NULL) | |
448 { | |
449 history_list_add_to_key("keywords", _(keyword_favorite_defaults[i]), 0); | |
450 i++; | |
451 } | |
452 | |
453 list = history_list_get_by_key("keywords"); | |
454 } | |
455 | |
456 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(bd->keyword_treeview))); | |
457 | |
458 gtk_list_store_clear(store); | |
459 | |
460 list = g_list_last(list); | |
461 while (list) | |
462 { | |
463 gchar *key = list->data; | |
464 | |
465 gtk_list_store_append(store, &iter); | |
1193
aed0e28b2744
keyword_list_find() -> find_string_in_list(), return gboolean.
zas_
parents:
1192
diff
changeset
|
466 gtk_list_store_set(store, &iter, KEYWORD_COLUMN_TOGGLE, find_string_in_list(keywords, key), |
1223
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
467 KEYWORD_COLUMN_TEXT, key, |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
468 KEYWORD_COLUMN_MARK, bar_info_get_mark_text(key), -1); |
9 | 469 |
470 list = list->prev; | |
471 } | |
472 } | |
473 | |
474 static void bar_info_keyword_update_all(void) | |
475 { | |
476 GList *work; | |
477 | |
478 work = bar_list; | |
479 while (work) | |
480 { | |
481 BarInfoData *bd; | |
482 GList *keywords; | |
483 | |
484 bd = work->data; | |
485 work = work->next; | |
486 | |
487 keywords = keyword_list_pull(bd->keyword_view); | |
488 bar_keyword_list_sync(bd, keywords); | |
138 | 489 string_list_free(keywords); |
9 | 490 } |
491 } | |
492 | |
493 static void bar_info_update(BarInfoData *bd) | |
494 { | |
495 GList *keywords = NULL; | |
496 gchar *comment = NULL; | |
1217
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
497 GtkTextBuffer *keyword_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->keyword_view)); |
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
498 GtkTextBuffer *comment_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->comment_view)); |
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
499 |
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
500 g_signal_handlers_block_by_func(keyword_buffer, bar_info_changed, bd); |
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
501 g_signal_handlers_block_by_func(comment_buffer, bar_info_changed, bd); |
9 | 502 |
503 if (bd->label_file_name) | |
504 { | |
138 | 505 gtk_label_set_text(GTK_LABEL(bd->label_file_name), (bd->fd) ? bd->fd->name : ""); |
9 | 506 } |
507 if (bd->label_file_time) | |
508 { | |
138 | 509 gtk_label_set_text(GTK_LABEL(bd->label_file_time), (bd->fd) ? text_from_time(bd->fd->date) : ""); |
9 | 510 } |
511 | |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
512 if (metadata_read(bd->fd, &keywords, &comment)) |
9 | 513 { |
514 keyword_list_push(bd->keyword_view, keywords); | |
1217
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
515 gtk_text_buffer_set_text(comment_buffer, |
9 | 516 (comment) ? comment : "", -1); |
517 | |
518 bar_keyword_list_sync(bd, keywords); | |
519 | |
138 | 520 string_list_free(keywords); |
9 | 521 g_free(comment); |
522 } | |
523 else | |
524 { | |
1217
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
525 gtk_text_buffer_set_text(keyword_buffer, "", -1); |
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
526 gtk_text_buffer_set_text(comment_buffer, "", -1); |
9 | 527 |
528 bar_keyword_list_sync(bd, NULL); | |
529 } | |
530 | |
1217
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
531 g_signal_handlers_unblock_by_func(keyword_buffer, bar_info_changed, bd); |
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
532 g_signal_handlers_unblock_by_func(comment_buffer, bar_info_changed, bd); |
9 | 533 |
138 | 534 gtk_widget_set_sensitive(bd->group_box, (bd->fd != NULL)); |
9 | 535 } |
536 | |
138 | 537 void bar_info_set(GtkWidget *bar, FileData *fd) |
9 | 538 { |
539 BarInfoData *bd; | |
540 | |
541 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data"); | |
542 if (!bd) return; | |
543 | |
138 | 544 file_data_unref(bd->fd); |
545 bd->fd = file_data_ref(fd); | |
9 | 546 |
547 bar_info_update(bd); | |
548 } | |
549 | |
138 | 550 void bar_info_maint_renamed(GtkWidget *bar, FileData *fd) |
9 | 551 { |
552 BarInfoData *bd; | |
553 | |
554 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data"); | |
555 if (!bd) return; | |
556 | |
138 | 557 file_data_unref(bd->fd); |
558 bd->fd = file_data_ref(fd); | |
9 | 559 |
560 if (bd->label_file_name) | |
561 { | |
138 | 562 gtk_label_set_text(GTK_LABEL(bd->label_file_name), (bd->fd) ? bd->fd->name : ""); |
9 | 563 } |
564 } | |
565 | |
566 gint bar_info_event(GtkWidget *bar, GdkEvent *event) | |
567 { | |
568 BarInfoData *bd; | |
569 | |
570 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data"); | |
571 if (!bd) return FALSE; | |
572 | |
573 if (GTK_WIDGET_HAS_FOCUS(bd->keyword_view)) return gtk_widget_event(bd->keyword_view, event); | |
574 if (GTK_WIDGET_HAS_FOCUS(bd->comment_view)) return gtk_widget_event(bd->comment_view, event); | |
575 | |
576 return FALSE; | |
577 } | |
578 | |
579 static void bar_info_keyword_set(BarInfoData *bd, const gchar *keyword, gint active) | |
580 { | |
581 GList *list; | |
582 gint found; | |
583 | |
584 if (!keyword) return; | |
585 | |
586 list = keyword_list_pull(bd->keyword_view); | |
1193
aed0e28b2744
keyword_list_find() -> find_string_in_list(), return gboolean.
zas_
parents:
1192
diff
changeset
|
587 found = find_string_in_list(list, keyword); |
9 | 588 |
589 if (active != found) | |
590 { | |
591 if (found) | |
592 { | |
593 GList *work = list; | |
594 | |
595 while (work) | |
596 { | |
597 gchar *key = work->data; | |
598 work = work->next; | |
599 | |
600 if (key && keyword && strcmp(key, keyword) == 0) | |
601 { | |
602 list = g_list_remove(list, key); | |
603 g_free(key); | |
604 } | |
605 } | |
606 } | |
607 else | |
608 { | |
609 list = g_list_append(list, g_strdup(keyword)); | |
610 } | |
611 | |
612 keyword_list_push(bd->keyword_view, list); | |
613 } | |
614 | |
138 | 615 string_list_free(list); |
9 | 616 } |
617 | |
618 static void bar_info_keyword_toggle(GtkCellRendererToggle *toggle, const gchar *path, gpointer data) | |
619 { | |
620 BarInfoData *bd = data; | |
621 GtkTreeModel *store; | |
622 GtkTreeIter iter; | |
623 GtkTreePath *tpath; | |
624 gchar *key = NULL; | |
625 gboolean active; | |
626 | |
627 store = gtk_tree_view_get_model(GTK_TREE_VIEW(bd->keyword_treeview)); | |
628 | |
629 tpath = gtk_tree_path_new_from_string(path); | |
630 gtk_tree_model_get_iter(store, &iter, tpath); | |
631 gtk_tree_path_free(tpath); | |
632 | |
633 gtk_tree_model_get(store, &iter, KEYWORD_COLUMN_TOGGLE, &active, | |
634 KEYWORD_COLUMN_TEXT, &key, -1); | |
635 active = (!active); | |
636 gtk_list_store_set(GTK_LIST_STORE(store), &iter, KEYWORD_COLUMN_TOGGLE, active, -1); | |
637 | |
638 bar_info_keyword_set(bd, key, active); | |
639 g_free(key); | |
640 } | |
641 | |
1192
48d62a7e3c33
metadata_set_keywords() -> metadata_set(). Use gboolean type for boolean parameters.
zas_
parents:
1191
diff
changeset
|
642 static void bar_info_set_selection(BarInfoData *bd, gboolean set_keywords, gboolean set_comment, gboolean append) |
9 | 643 { |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
644 GList *keywords = NULL; |
9 | 645 GList *list = NULL; |
646 GList *work; | |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
647 gchar *comment = NULL; |
9 | 648 |
649 if (!bd->list_func) return; | |
650 | |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
651 if (set_keywords) |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
652 { |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
653 keywords = keyword_list_pull(bd->keyword_view); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
654 } |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
655 |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
656 if (set_comment) |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
657 { |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
658 comment = comment_pull(bd->comment_view); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
659 } |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
660 |
1192
48d62a7e3c33
metadata_set_keywords() -> metadata_set(). Use gboolean type for boolean parameters.
zas_
parents:
1191
diff
changeset
|
661 if (append && !keywords && !comment) return; |
9 | 662 |
663 list = bd->list_func(bd->list_data); | |
664 work = list; | |
665 while (work) | |
666 { | |
138 | 667 FileData *fd = work->data; |
9 | 668 work = work->next; |
669 | |
1192
48d62a7e3c33
metadata_set_keywords() -> metadata_set(). Use gboolean type for boolean parameters.
zas_
parents:
1191
diff
changeset
|
670 metadata_set(fd, keywords, comment, append); |
9 | 671 } |
672 | |
138 | 673 filelist_free(list); |
674 string_list_free(keywords); | |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
675 g_free(comment); |
9 | 676 } |
677 | |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
678 static void bar_info_set_keywords_add(GtkWidget *button, gpointer data) |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
679 { |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
680 BarInfoData *bd = data; |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
681 |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
682 bar_info_set_selection(bd, TRUE, FALSE, TRUE); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
683 } |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
684 |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
685 static void bar_info_set_keywords_replace(GtkWidget *button, gpointer data) |
9 | 686 { |
687 BarInfoData *bd = data; | |
688 | |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
689 bar_info_set_selection(bd, TRUE, FALSE, FALSE); |
9 | 690 } |
691 | |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
692 static void bar_info_set_comment_add(GtkWidget *button, gpointer data) |
9 | 693 { |
694 BarInfoData *bd = data; | |
695 | |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
696 bar_info_set_selection(bd, FALSE, TRUE, TRUE); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
697 } |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
698 |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
699 static void bar_info_set_comment_replace(GtkWidget *button, gpointer data) |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
700 { |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
701 BarInfoData *bd = data; |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
702 |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
703 bar_info_set_selection(bd, FALSE, TRUE, FALSE); |
9 | 704 } |
705 | |
1219 | 706 static void bar_info_notify_cb(FileData *fd, NotifyType type, gpointer data) |
707 { | |
708 BarInfoData *bd = data; | |
709 if (fd == bd->fd) bar_info_update(bd); | |
710 } | |
711 | |
9 | 712 static void bar_info_changed(GtkTextBuffer *buffer, gpointer data) |
713 { | |
714 BarInfoData *bd = data; | |
715 | |
1219 | 716 file_data_unregister_notify_func(bar_info_notify_cb, bd); |
1217
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
717 bar_info_write(bd); |
1219 | 718 file_data_register_notify_func(bar_info_notify_cb, bd, NOTIFY_PRIORITY_LOW); |
9 | 719 } |
720 | |
1223
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
721 static void bar_info_mark_edited (GtkCellRendererText *cell, const gchar *path, const gchar *text, gpointer data) |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
722 { |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
723 BarInfoData *bd = data; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
724 GtkTreeModel *store; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
725 GtkTreeIter iter; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
726 GtkTreePath *tpath; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
727 gchar *key = NULL; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
728 gint i; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
729 FileDataGetMarkFunc get_mark_func; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
730 FileDataSetMarkFunc set_mark_func; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
731 gpointer mark_func_data; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
732 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
733 file_data_unregister_notify_func(bar_info_notify_cb, bd); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
734 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
735 store = gtk_tree_view_get_model(GTK_TREE_VIEW(bd->keyword_treeview)); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
736 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
737 tpath = gtk_tree_path_new_from_string(path); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
738 gtk_tree_model_get_iter(store, &iter, tpath); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
739 gtk_tree_path_free(tpath); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
740 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
741 gtk_tree_model_get(store, &iter, KEYWORD_COLUMN_TEXT, &key, -1); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
742 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
743 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
744 { |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
745 file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &mark_func_data); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
746 if (get_mark_func == meta_data_get_keyword_mark && strcmp(mark_func_data, key) == 0) |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
747 { |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
748 g_free(mark_func_data); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
749 file_data_register_mark_func(i, NULL, NULL, NULL); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
750 } |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
751 } |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
752 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
753 if (sscanf(text, " %d ", &i) &&i >=1 && i <= FILEDATA_MARKS_SIZE) |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
754 { |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
755 i--; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
756 file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &mark_func_data); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
757 if (get_mark_func == meta_data_get_keyword_mark && mark_func_data) g_free(mark_func_data); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
758 file_data_register_mark_func(i, meta_data_get_keyword_mark, meta_data_set_keyword_mark, g_strdup(key)); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
759 } |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
760 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
761 g_free(key); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
762 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
763 file_data_register_notify_func(bar_info_notify_cb, bd, NOTIFY_PRIORITY_LOW); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
764 bar_info_update(bd); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
765 } |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
766 |
9 | 767 void bar_info_close(GtkWidget *bar) |
768 { | |
769 BarInfoData *bd; | |
770 | |
771 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data"); | |
772 if (!bd) return; | |
773 | |
774 gtk_widget_destroy(bd->vbox); | |
775 } | |
776 | |
777 static void bar_info_destroy(GtkWidget *widget, gpointer data) | |
778 { | |
779 BarInfoData *bd = data; | |
780 | |
1219 | 781 file_data_unregister_notify_func(bar_info_notify_cb, bd); |
9 | 782 bar_list = g_list_remove(bar_list, bd); |
783 | |
138 | 784 file_data_unref(bd->fd); |
9 | 785 |
786 g_free(bd); | |
787 } | |
788 | |
1223
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
789 static GtkTreeModel *create_marks_list(void) |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
790 { |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
791 GtkListStore *model; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
792 GtkTreeIter iter; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
793 gint i; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
794 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
795 /* create list store */ |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
796 model = gtk_list_store_new (1, G_TYPE_STRING); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
797 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
798 { |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
799 char str[10]; |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
800 sprintf(str, " %d ", i + 1); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
801 gtk_list_store_append (model, &iter); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
802 gtk_list_store_set(model, &iter, 0, str, -1); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
803 } |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
804 gtk_list_store_append (model, &iter); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
805 gtk_list_store_set(model, &iter, 0, " ... ", -1); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
806 return GTK_TREE_MODEL (model); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
807 } |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
808 |
138 | 809 GtkWidget *bar_info_new(FileData *fd, gint metadata_only, GtkWidget *bounding_widget) |
9 | 810 { |
811 BarInfoData *bd; | |
812 GtkWidget *box; | |
813 GtkWidget *hbox; | |
814 GtkWidget *table; | |
815 GtkWidget *scrolled; | |
816 GtkTextBuffer *buffer; | |
817 GtkWidget *label; | |
818 GtkWidget *tbar; | |
819 GtkListStore *store; | |
820 GtkTreeViewColumn *column; | |
821 GtkCellRenderer *renderer; | |
822 | |
823 bd = g_new0(BarInfoData, 1); | |
824 | |
825 bd->list_func = NULL; | |
826 bd->list_data = NULL; | |
827 | |
828 bd->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
829 g_object_set_data(G_OBJECT(bd->vbox), "bar_info_data", bd); | |
830 g_signal_connect(G_OBJECT(bd->vbox), "destroy", | |
831 G_CALLBACK(bar_info_destroy), bd); | |
832 | |
833 if (!metadata_only) | |
834 { | |
835 hbox = pref_box_new(bd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
836 | |
837 label = sizer_new(bd->vbox, bounding_widget, SIZER_POS_LEFT); | |
838 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
839 gtk_widget_show(label); | |
840 | |
841 label = gtk_label_new(_("Keywords")); | |
842 pref_label_bold(label, TRUE, FALSE); | |
843 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | |
844 gtk_widget_show(label); | |
845 } | |
846 | |
847 bd->group_box = pref_box_new(bd->vbox, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); | |
848 | |
849 if (!metadata_only) | |
850 { | |
851 GtkWidget *table; | |
852 | |
853 table = pref_table_new(bd->group_box, 2, 2, FALSE, FALSE); | |
854 | |
855 bd->label_file_name = table_add_line(table, 0, 0, _("Filename:"), NULL); | |
856 bd->label_file_time = table_add_line(table, 0, 1, _("File date:"), NULL); | |
857 } | |
858 else | |
859 { | |
860 bd->label_file_name = NULL; | |
861 bd->label_file_time = NULL; | |
862 } | |
863 | |
864 table = gtk_table_new(3, 1, TRUE); | |
865 gtk_table_set_row_spacings(GTK_TABLE(table), PREF_PAD_GAP); | |
866 gtk_box_pack_start(GTK_BOX(bd->group_box), table, TRUE, TRUE, 0); | |
867 gtk_widget_show(table); | |
868 | |
869 /* keyword entry */ | |
870 | |
871 box = gtk_vbox_new(FALSE, 0); | |
872 gtk_table_attach(GTK_TABLE(table), box, 0, 1, 0, 2, | |
873 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); | |
874 gtk_widget_show(box); | |
875 | |
876 label = pref_label_new(box, _("Keywords:")); | |
877 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
878 pref_label_bold(label, TRUE, FALSE); | |
879 | |
880 hbox = pref_box_new(box, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
881 | |
882 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
883 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | |
884 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | |
885 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
886 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0); | |
887 gtk_widget_show(scrolled); | |
888 | |
889 bd->keyword_view = gtk_text_view_new(); | |
890 gtk_container_add(GTK_CONTAINER(scrolled), bd->keyword_view); | |
891 gtk_widget_show(bd->keyword_view); | |
892 | |
893 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->keyword_view)); | |
894 g_signal_connect(G_OBJECT(buffer), "changed", | |
895 G_CALLBACK(bar_info_changed), bd); | |
896 | |
897 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
898 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | |
899 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | |
900 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
901 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0); | |
902 gtk_widget_show(scrolled); | |
903 | |
1223
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
904 store = gtk_list_store_new(3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING); |
9 | 905 bd->keyword_treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
906 g_object_unref(store); | |
907 | |
908 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(bd->keyword_treeview), FALSE); | |
909 | |
910 if (metadata_only) | |
911 { | |
912 gtk_tree_view_set_search_column(GTK_TREE_VIEW(bd->keyword_treeview), KEYWORD_COLUMN_TEXT); | |
913 } | |
914 else | |
915 { | |
916 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(bd->keyword_treeview), FALSE); | |
917 } | |
918 | |
919 column = gtk_tree_view_column_new(); | |
920 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
921 | |
922 renderer = gtk_cell_renderer_toggle_new(); | |
923 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
924 gtk_tree_view_column_add_attribute(column, renderer, "active", KEYWORD_COLUMN_TOGGLE); | |
925 g_signal_connect(G_OBJECT(renderer), "toggled", | |
926 G_CALLBACK(bar_info_keyword_toggle), bd); | |
927 | |
928 renderer = gtk_cell_renderer_text_new(); | |
929 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
930 gtk_tree_view_column_add_attribute(column, renderer, "text", KEYWORD_COLUMN_TEXT); | |
931 | |
932 gtk_tree_view_append_column(GTK_TREE_VIEW(bd->keyword_treeview), column); | |
933 | |
1223
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
934 column = gtk_tree_view_column_new(); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
935 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
936 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
937 renderer = gtk_cell_renderer_combo_new(); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
938 g_object_set(G_OBJECT(renderer), "editable", (gboolean)TRUE, |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
939 "model", create_marks_list(), |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
940 "text-column", 0, |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
941 "has-entry", FALSE, |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
942 NULL); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
943 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
944 gtk_tree_view_column_pack_start(column, renderer, TRUE); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
945 gtk_tree_view_column_add_attribute(column, renderer, "text", KEYWORD_COLUMN_MARK); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
946 g_signal_connect (renderer, "edited", |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
947 G_CALLBACK (bar_info_mark_edited), bd); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
948 gtk_tree_view_append_column(GTK_TREE_VIEW(bd->keyword_treeview), column); |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
949 |
18d08b10b80e
implemented a possibility to connect keywords with marks
nadvornik
parents:
1220
diff
changeset
|
950 |
9 | 951 gtk_container_add(GTK_CONTAINER(scrolled), bd->keyword_treeview); |
952 gtk_widget_show(bd->keyword_treeview); | |
953 | |
954 /* comment entry */ | |
955 | |
956 box = gtk_vbox_new(FALSE, 0); | |
957 gtk_table_attach(GTK_TABLE(table), box, 0, 1, 2, 3, | |
958 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); | |
959 gtk_widget_show(box); | |
960 | |
961 label = pref_label_new(box, _("Comment:")); | |
962 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
963 pref_label_bold(label, TRUE, FALSE); | |
964 | |
965 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
966 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | |
967 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | |
968 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
969 gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0); | |
970 gtk_widget_show(scrolled); | |
971 | |
972 bd->comment_view = gtk_text_view_new(); | |
973 gtk_container_add(GTK_CONTAINER(scrolled), bd->comment_view); | |
974 gtk_widget_show(bd->comment_view); | |
975 | |
976 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->comment_view)); | |
977 g_signal_connect(G_OBJECT(buffer), "changed", | |
978 G_CALLBACK(bar_info_changed), bd); | |
979 | |
980 /* toolbar */ | |
981 | |
982 tbar = pref_toolbar_new(bd->group_box, GTK_TOOLBAR_ICONS); | |
983 | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
984 pref_toolbar_button(tbar, GTK_STOCK_INDEX, NULL, FALSE, |
9 | 985 _("Edit favorite keywords list."), |
986 G_CALLBACK(bar_keyword_edit_cb), bd); | |
987 pref_toolbar_spacer(tbar); | |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
988 bd->button_set_keywords_add = pref_toolbar_button(tbar, GTK_STOCK_ADD, NULL, FALSE, |
9 | 989 _("Add keywords to selected files"), |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
990 G_CALLBACK(bar_info_set_keywords_add), bd); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
991 bd->button_set_keywords_replace = pref_toolbar_button(tbar, GTK_STOCK_CONVERT, NULL, FALSE, |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
992 _("Add keywords to selected files, replacing existing ones"), |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
993 G_CALLBACK(bar_info_set_keywords_replace), bd); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
994 bd->button_set_comment_add = pref_toolbar_button(tbar, GTK_STOCK_DND_MULTIPLE, NULL, FALSE, |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
995 _("Add comment to selected files"), |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
996 G_CALLBACK(bar_info_set_comment_add), bd); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
997 bd->button_set_comment_replace = pref_toolbar_button(tbar, GTK_STOCK_DND, NULL, FALSE, |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
998 _("Add comment to selected files, replacing existing one"), |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
999 G_CALLBACK(bar_info_set_comment_replace), bd); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
1000 |
1217
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
1001 #if 0 |
9 | 1002 pref_toolbar_spacer(tbar); |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
1003 bd->button_save = pref_toolbar_button(tbar, GTK_STOCK_SAVE, NULL, FALSE, |
9 | 1004 _("Save comment now"), |
1005 G_CALLBACK(bar_info_save), bd); | |
1217
70f1d002436f
write changes immediately, the necessary buffering is done on lower
nadvornik
parents:
1193
diff
changeset
|
1006 #endif |
9 | 1007 |
138 | 1008 bd->fd = file_data_ref(fd); |
9 | 1009 bar_info_update(bd); |
1010 | |
1011 bar_info_selection(bd->vbox, 0); | |
1012 | |
1013 bar_list = g_list_append(bar_list, bd); | |
442 | 1014 |
1219 | 1015 file_data_register_notify_func(bar_info_notify_cb, bd, NOTIFY_PRIORITY_LOW); |
1016 | |
9 | 1017 return bd->vbox; |
1018 } | |
1019 | |
1020 void bar_info_set_selection_func(GtkWidget *bar, GList *(*list_func)(gpointer data), gpointer data) | |
1021 { | |
1022 BarInfoData *bd; | |
1023 | |
1024 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data"); | |
1025 if (!bd) return; | |
1026 | |
1027 bd->list_func = list_func; | |
1028 bd->list_data = data; | |
1029 } | |
1030 | |
1031 void bar_info_selection(GtkWidget *bar, gint count) | |
1032 { | |
1033 BarInfoData *bd; | |
1034 gint enable; | |
1035 | |
1036 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data"); | |
1037 if (!bd) return; | |
1038 | |
1039 enable = (count > 0 && bd->list_func != NULL); | |
1040 | |
595
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
1041 gtk_widget_set_sensitive(bd->button_set_keywords_add, enable); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
1042 gtk_widget_set_sensitive(bd->button_set_keywords_replace, enable); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
1043 gtk_widget_set_sensitive(bd->button_set_comment_add, enable); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
1044 gtk_widget_set_sensitive(bd->button_set_comment_replace, enable); |
15766932414c
Allow the user to append or replace comments for a group of selected files.
zas_
parents:
594
diff
changeset
|
1045 |
9 | 1046 } |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1051
diff
changeset
|
1047 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |