annotate src/bar_keywords.c @ 1314:8cca18bce950

simplified config writing
author nadvornik
date Mon, 23 Feb 2009 22:13:09 +0000
parents 55ea4962887a
children c1d108ab3388
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1 /*
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
2 * Geeqie
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
3 * (C) 2004 John Ellis
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
5 *
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
6 * Author: John Ellis
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
7 *
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
9 * Please read the included file COPYING for more information.
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
11 */
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
12
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
13 #include <glib/gprintf.h>
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
14
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
15 #include "main.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
16 #include "bar_keywords.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
17
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
18 #include "filedata.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
19 #include "history_list.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
20 #include "metadata.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
21 #include "misc.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
22 #include "ui_fileops.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
23 #include "ui_misc.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
24 #include "ui_utildlg.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
25 #include "utilops.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
26 #include "bar.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
27 #include "ui_menu.h"
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
28 #include "rcfile.h"
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
29
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
30 static const gchar *keyword_favorite_defaults[] = {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
31 N_("Favorite"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
32 N_("Todo"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
33 N_("People"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
34 N_("Places"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
35 N_("Art"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
36 N_("Nature"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
37 N_("Possessions"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
38 NULL
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 static void bar_pane_keywords_keyword_update_all(void);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
43 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
44
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
45 /*
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
46 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
47 * keyword / comment utils
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
48 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
49 */
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
1292
4a3ae0e6f1eb droped Preferences dialog, sidebar should replace it completely
nadvornik
parents: 1291
diff changeset
52 GList *keyword_list_pull(GtkWidget *text_widget)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
53 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
54 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
55 gchar *text;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
56
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
57 text = text_widget_text_pull(text_widget);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
58 list = string_to_keywords_list(text);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
59
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
60 g_free(text);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
61
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
62 return list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
63 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
64
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
65 static void keyword_list_push(GtkWidget *textview, GList *list)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
66 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
67 GtkTextBuffer *buffer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
68 GtkTextIter start, end;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
69
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
70 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
71 gtk_text_buffer_get_bounds(buffer, &start, &end);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
72 gtk_text_buffer_delete(buffer, &start, &end);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
73
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
74 while (list)
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 const gchar *word = list->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
77 GtkTextIter iter;
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 gtk_text_buffer_get_end_iter(buffer, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
80 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
81 gtk_text_buffer_get_end_iter(buffer, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
82 gtk_text_buffer_insert(buffer, &iter, "\n", -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
83
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
84 list = list->next;
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 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
87
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
88
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
89 /*
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
90 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
91 * keyword list dialog
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
92 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
93 */
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 #define KEYWORD_DIALOG_WIDTH 200
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
96 #define KEYWORD_DIALOG_HEIGHT 250
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
97
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
98 typedef struct _KeywordDlg KeywordDlg;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
99 struct _KeywordDlg
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 GenericDialog *gd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
102 GtkWidget *treeview;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
105 static KeywordDlg *keyword_dialog = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
106
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
107
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
108 static void keyword_dialog_cancel_cb(GenericDialog *gd, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
109 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
110 g_free(keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
111 keyword_dialog = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
112 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
113
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
114 static void keyword_dialog_ok_cb(GenericDialog *gd, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
115 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
116 KeywordDlg *kd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
117 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
118 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
119 gint valid;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
120
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
121 history_list_free_key("keywords");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
122
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
123 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
124 valid = gtk_tree_model_get_iter_first(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
125 while (valid)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
126 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
127 gchar *key;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
128
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
129 gtk_tree_model_get(store, &iter, 0, &key, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
130 valid = gtk_tree_model_iter_next(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
131
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
132 history_list_add_to_key("keywords", key, 0);
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 keyword_dialog_cancel_cb(gd, data);
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 bar_pane_keywords_keyword_update_all();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
138 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
139
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
140 static void keyword_dialog_add_cb(GtkWidget *button, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
141 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
142 KeywordDlg *kd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
143 GtkTreeSelection *selection;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
144 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
145 GtkTreeIter sibling;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
146 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
147 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
148
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
149 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(kd->treeview));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
150 if (gtk_tree_selection_get_selected(selection, &store, &sibling))
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
151 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
152 gtk_list_store_insert_before(GTK_LIST_STORE(store), &iter, &sibling);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
153 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
154 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
155 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
156 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
157 gtk_list_store_append(GTK_LIST_STORE(store), &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
158 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
159
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
160 gtk_list_store_set(GTK_LIST_STORE(store), &iter, 1, TRUE, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
161
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
162 tpath = gtk_tree_model_get_path(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
163 gtk_tree_view_set_cursor(GTK_TREE_VIEW(kd->treeview), tpath,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
164 gtk_tree_view_get_column(GTK_TREE_VIEW(kd->treeview), 0), TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
165 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
166 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
167
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
168 static void keyword_dialog_remove_cb(GtkWidget *button, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
169 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
170 KeywordDlg *kd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
171 GtkTreeSelection *selection;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
172 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
173 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
174 GtkTreeIter next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
175 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
176
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
177 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(kd->treeview));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
178 if (!gtk_tree_selection_get_selected(selection, &store, &iter)) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
179
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
180 tpath = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
181 next = iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
182 if (gtk_tree_model_iter_next(store, &next))
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
183 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
184 tpath = gtk_tree_model_get_path(store, &next);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
185 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
186 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
187 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
188 tpath = gtk_tree_model_get_path(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
189 if (!gtk_tree_path_prev(tpath))
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
190 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
191 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
192 tpath = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
193 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
194 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
195 if (tpath)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
196 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
197 gtk_tree_view_set_cursor(GTK_TREE_VIEW(kd->treeview), tpath,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
198 gtk_tree_view_get_column(GTK_TREE_VIEW(kd->treeview), 0), FALSE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
199 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
200 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
201
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
202 gtk_list_store_remove(GTK_LIST_STORE(store), &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
203 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
204
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
205 static void keyword_dialog_edit_cb(GtkCellRendererText *renderer, const gchar *path,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
206 const gchar *new_text, gpointer data)
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 KeywordDlg *kd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
209 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
210 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
211 GtkTreePath *tpath;
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 if (!new_text || strlen(new_text) == 0) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
214
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
215 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
216
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
217 tpath = gtk_tree_path_new_from_string(path);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
218 gtk_tree_model_get_iter(store, &iter, tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
219 gtk_tree_path_free(tpath);
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 gtk_list_store_set(GTK_LIST_STORE(store), &iter, 0, new_text, -1);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
224 static void keyword_dialog_populate(KeywordDlg *kd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
225 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
226 GtkListStore *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
227 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
228
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
229 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview)));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
230 gtk_list_store_clear(store);
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 list = history_list_get_by_key("keywords");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
233 list = g_list_last(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
234 while (list)
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 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
237
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
238 gtk_list_store_append(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
239 gtk_list_store_set(store, &iter, 0, list->data,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
240 1, TRUE, -1);
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 list = list->prev;
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 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
245
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
246 static void keyword_dialog_show(void)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
247 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
248 GtkWidget *scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
249 GtkListStore *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
250 GtkTreeViewColumn *column;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
251 GtkCellRenderer *renderer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
252 GtkWidget *hbox;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
253 GtkWidget *button;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
254
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
255 if (keyword_dialog)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
256 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
257 gtk_window_present(GTK_WINDOW(keyword_dialog->gd->dialog));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
258 return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
259 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
260
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
261 keyword_dialog = g_new0(KeywordDlg, 1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
262
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
263 keyword_dialog->gd = generic_dialog_new(_("Keyword Presets"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
264 "keyword_presets", NULL, TRUE,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
265 keyword_dialog_cancel_cb, keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
266 generic_dialog_add_message(keyword_dialog->gd, NULL, _("Favorite keywords list"), NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
267
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
268 generic_dialog_add_button(keyword_dialog->gd, GTK_STOCK_OK, NULL,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
269 keyword_dialog_ok_cb, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
270
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
271 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
272 gtk_widget_set_size_request(scrolled, KEYWORD_DIALOG_WIDTH, KEYWORD_DIALOG_HEIGHT);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
273 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
274 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
275 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
276 gtk_box_pack_start(GTK_BOX(keyword_dialog->gd->vbox), scrolled, TRUE, TRUE, 5);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
277 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
278
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
279 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
280 keyword_dialog->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
281 g_object_unref(store);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
282
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
283 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(keyword_dialog->treeview), FALSE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
284 gtk_tree_view_set_search_column(GTK_TREE_VIEW(keyword_dialog->treeview), 0);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
285 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(keyword_dialog->treeview), TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
286
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
287 column = gtk_tree_view_column_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
288 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
289 renderer = gtk_cell_renderer_text_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
290 g_signal_connect(G_OBJECT(renderer), "edited",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
291 G_CALLBACK(keyword_dialog_edit_cb), keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
292 gtk_tree_view_column_pack_start(column, renderer, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
293 gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
294 gtk_tree_view_column_add_attribute(column, renderer, "editable", 1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
295 gtk_tree_view_append_column(GTK_TREE_VIEW(keyword_dialog->treeview), column);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
296
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
297 gtk_container_add(GTK_CONTAINER(scrolled), keyword_dialog->treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
298 gtk_widget_show(keyword_dialog->treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
299
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
300 hbox = gtk_hbox_new(FALSE, 5);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
301 gtk_box_pack_start(GTK_BOX(keyword_dialog->gd->vbox), hbox, FALSE, FALSE, 0);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
302 gtk_widget_show(hbox);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
303
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
304 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
305 g_signal_connect(G_OBJECT(button), "clicked",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
306 G_CALLBACK(keyword_dialog_add_cb), keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
307 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
308 gtk_widget_show(button);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
309
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
310 button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
311 g_signal_connect(G_OBJECT(button), "clicked",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
312 G_CALLBACK(keyword_dialog_remove_cb), keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
313 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
314 gtk_widget_show(button);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
315
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
316 keyword_dialog_populate(keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
317
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
318 gtk_widget_show(keyword_dialog->gd->dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
319 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
320
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
321
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
322 static void bar_keyword_edit_cb(GtkWidget *button, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
323 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
324 keyword_dialog_show();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
325 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
326
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
327
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
328 /*
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
329 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
330 * info bar
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
331 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
332 */
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
333
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
334 enum {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
335 KEYWORD_COLUMN_TOGGLE = 0,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
336 KEYWORD_COLUMN_TEXT,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
337 KEYWORD_COLUMN_MARK
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
338 };
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
339
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
340 typedef struct _PaneKeywordsData PaneKeywordsData;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
341 struct _PaneKeywordsData
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
342 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
343 PaneData pane;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
344 GtkWidget *widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
345
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
346 GtkWidget *keyword_view;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
347 GtkWidget *keyword_treeview;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
348
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
349 FileData *fd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
350 gchar *key;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
351 };
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
352
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
353
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
354 static GList *bar_list = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
355
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
356
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
357 static void bar_pane_keywords_write(PaneKeywordsData *pkd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
358 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
359 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
360
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
361 if (!pkd->fd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
362
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
363 list = keyword_list_pull(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
364
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
365 metadata_write_list(pkd->fd, KEYWORD_KEY, list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
366
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
367 string_list_free(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
368 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
369
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
370 static gchar *bar_pane_keywords_get_mark_text(const gchar *key)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
371 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
372 gint i;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
373 static gchar buf[10];
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
374
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
375 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
376 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
377 FileDataGetMarkFunc get_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
378 FileDataSetMarkFunc set_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
379 gpointer data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
380 file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
381 if (get_mark_func == meta_data_get_keyword_mark && strcmp(data, key) == 0)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
382 {
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
383 g_sprintf(buf, " %d ", i + 1);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
384 return buf;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
385 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
386 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
387 return " ... ";
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 static void bar_keyword_list_sync(PaneKeywordsData *pkd, GList *keywords)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
391 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
392 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
393 GtkListStore *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
394 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
395
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
396 list = history_list_get_by_key("keywords");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
397 if (!list)
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 /* blank? set up a few example defaults */
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 gint i = 0;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
402
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
403 while (keyword_favorite_defaults[i] != NULL)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
404 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
405 history_list_add_to_key("keywords", _(keyword_favorite_defaults[i]), 0);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
406 i++;
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 list = history_list_get_by_key("keywords");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
410 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
411
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
412 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
413
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
414 gtk_list_store_clear(store);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
415
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
416 list = g_list_last(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
417 while (list)
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 gchar *key = list->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 gtk_list_store_append(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
422 gtk_list_store_set(store, &iter, KEYWORD_COLUMN_TOGGLE, find_string_in_list(keywords, key),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
423 KEYWORD_COLUMN_TEXT, key,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
424 KEYWORD_COLUMN_MARK, bar_pane_keywords_get_mark_text(key), -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
425
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
426 list = list->prev;
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 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
429
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
430 static void bar_pane_keywords_keyword_update_all(void)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
431 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
432 GList *work;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
433
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
434 work = bar_list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
435 while (work)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
436 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
437 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
438 GList *keywords;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
439
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
440 pkd = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
441 work = work->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
442
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
443 keywords = keyword_list_pull(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
444 bar_keyword_list_sync(pkd, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
445 string_list_free(keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
446 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
447 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
448
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
449 static void bar_pane_keywords_update(PaneKeywordsData *pkd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
450 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
451 GList *keywords = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
452 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
453
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
454 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
455
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
456 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
457 keyword_list_push(pkd->keyword_view, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
458 bar_keyword_list_sync(pkd, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
459 string_list_free(keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
460
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
461 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
462
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
463 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
464
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
465 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
466 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
467 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
468
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
469 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
470 if (!pkd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
471
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
472 file_data_unref(pkd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
473 pkd->fd = file_data_ref(fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
474
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
475 bar_pane_keywords_update(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
476 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
477
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
478 static void bar_pane_keywords_write_config(GtkWidget *pane, GString *outstr, gint indent)
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
479 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
480 PaneKeywordsData *pkd;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
481
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
482 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
483 if (!pkd) return;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
484
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
485 WRITE_STRING("<pane_keywords\n");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
486 indent++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
487 WRITE_CHAR(*pkd, pane.title);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
488 WRITE_BOOL(*pkd, pane.expanded);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
489 WRITE_CHAR(*pkd, key);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
490 indent--;
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
491 WRITE_STRING("/>\n");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
492 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
493
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
494 gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
495 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
496 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
497
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
498 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
499 if (!pkd) return FALSE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
500
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
501 if (GTK_WIDGET_HAS_FOCUS(pkd->keyword_view)) return gtk_widget_event(pkd->keyword_view, event);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
502
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
503 return FALSE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
504 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
505
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
506 static void bar_pane_keywords_keyword_set(PaneKeywordsData *pkd, const gchar *keyword, gint active)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
507 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
508 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
509 gint found;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
510
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
511 if (!keyword) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
512
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
513 list = keyword_list_pull(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
514 found = find_string_in_list(list, keyword);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
515
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
516 if (active != found)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
517 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
518 if (found)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
519 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
520 GList *work = list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
521
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
522 while (work)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
523 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
524 gchar *key = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
525 work = work->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
526
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
527 if (key && keyword && strcmp(key, keyword) == 0)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
528 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
529 list = g_list_remove(list, key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
530 g_free(key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
531 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
532 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
533 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
534 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
535 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
536 list = g_list_append(list, g_strdup(keyword));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
537 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
538
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
539 keyword_list_push(pkd->keyword_view, list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
540 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
541
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
542 string_list_free(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
543 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
544
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
545 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
546 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
547 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
548 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
549 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
550 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
551 gchar *key = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
552 gboolean active;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
553
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
554 store = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
555
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
556 tpath = gtk_tree_path_new_from_string(path);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
557 gtk_tree_model_get_iter(store, &iter, tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
558 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
559
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
560 gtk_tree_model_get(store, &iter, KEYWORD_COLUMN_TOGGLE, &active,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
561 KEYWORD_COLUMN_TEXT, &key, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
562 active = (!active);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
563 gtk_list_store_set(GTK_LIST_STORE(store), &iter, KEYWORD_COLUMN_TOGGLE, active, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
564
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
565 bar_pane_keywords_keyword_set(pkd, key, active);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
566 g_free(key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
567 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
568
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
569 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
570 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
571 GList *keywords = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
572 GList *list = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
573 GList *work;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
574
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
575 if (!pkd->pane.list_func) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
576
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
577 keywords = keyword_list_pull(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
578
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
579 list = pkd->pane.list_func(pkd->pane.list_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
580 work = list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
581 while (work)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
582 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
583 FileData *fd = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
584 work = work->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
585
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
586 if (append)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
587 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
588 metadata_append_list(fd, KEYWORD_KEY, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
589 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
590 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
591 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
592 metadata_write_list(fd, KEYWORD_KEY, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
593 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
594 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
595
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
596 filelist_free(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
597 string_list_free(keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
598 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
599
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
600 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
601 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
602 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
603
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
604 bar_pane_keywords_set_selection(pkd, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
605 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
606
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
607 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
608 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
609 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
610
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
611 bar_pane_keywords_set_selection(pkd, FALSE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
612 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
613
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
614 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
615 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
616 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
617
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
618 menu_item_add_divider(GTK_WIDGET(menu));
1295
8c59e6e50bd8 Fix up few compilation warnings.
zas_
parents: 1292
diff changeset
619 menu_item_add_stock(GTK_WIDGET(menu), _("Add keywords to selected files"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_keywords_sel_add_cb), pkd);
8c59e6e50bd8 Fix up few compilation warnings.
zas_
parents: 1292
diff changeset
620 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
621 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
622
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
623
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
624 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
625 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
626 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
627 if (fd == pkd->fd) bar_pane_keywords_update(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
628 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
629
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
630 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
631 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
632 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
633
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
634 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
635 bar_pane_keywords_write(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
636 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
637 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
638
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
639 static void bar_pane_keywords_mark_edited (GtkCellRendererText *cell, const gchar *path, const gchar *text, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
640 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
641 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
642 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
643 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
644 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
645 gchar *key = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
646 gint i;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
647 FileDataGetMarkFunc get_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
648 FileDataSetMarkFunc set_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
649 gpointer mark_func_data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
650
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
651 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
652
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
653 store = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
654
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
655 tpath = gtk_tree_path_new_from_string(path);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
656 gtk_tree_model_get_iter(store, &iter, tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
657 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
658
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
659 gtk_tree_model_get(store, &iter, KEYWORD_COLUMN_TEXT, &key, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
660
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
661 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
662 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
663 file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &mark_func_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
664 if (get_mark_func == meta_data_get_keyword_mark && strcmp(mark_func_data, key) == 0)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
665 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
666 g_free(mark_func_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
667 file_data_register_mark_func(i, NULL, NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
668 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
669 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
670
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
671 if (sscanf(text, " %d ", &i) &&i >=1 && i <= FILEDATA_MARKS_SIZE)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
672 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
673 i--;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
674 file_data_get_registered_mark_func(i, &get_mark_func, &set_mark_func, &mark_func_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
675 if (get_mark_func == meta_data_get_keyword_mark && mark_func_data) g_free(mark_func_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
676 file_data_register_mark_func(i, meta_data_get_keyword_mark, meta_data_set_keyword_mark, g_strdup(key));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
677 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
678
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
679 g_free(key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
680
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
681 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
682 bar_pane_keywords_update(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
683 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
684
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
685 void bar_pane_keywords_close(GtkWidget *bar)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
686 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
687 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
688
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
689 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
690 if (!pkd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
691
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
692 gtk_widget_destroy(pkd->widget);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
693 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
694
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
695 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
696 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
697 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
698
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
699 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
700
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
701 file_data_unref(pkd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
702 g_free(pkd->key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
703
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
704 g_free(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
705 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
706
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
707 static GtkTreeModel *create_marks_list(void)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
708 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
709 GtkListStore *model;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
710 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
711 gint i;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
712
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
713 /* create list store */
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
714 model = gtk_list_store_new(1, G_TYPE_STRING);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
715 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
716 {
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
717 gchar str[10];
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
718 g_sprintf(str, " %d ", i + 1);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
719 gtk_list_store_append (model, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
720 gtk_list_store_set(model, &iter, 0, str, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
721 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
722 gtk_list_store_append (model, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
723 gtk_list_store_set(model, &iter, 0, " ... ", -1);
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
724 return GTK_TREE_MODEL(model);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
725 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
726
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
727 GtkWidget *bar_pane_keywords_new(const gchar *title, const gchar *key, gboolean expanded)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
728 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
729 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
730 GtkWidget *hbox;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
731 GtkWidget *scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
732 GtkTextBuffer *buffer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
733 GtkListStore *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
734 GtkTreeViewColumn *column;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
735 GtkCellRenderer *renderer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
736
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
737 pkd = g_new0(PaneKeywordsData, 1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
738
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
739 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
740 pkd->pane.pane_event = bar_pane_keywords_event;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
741 pkd->pane.pane_write_config = bar_pane_keywords_write_config;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
742 pkd->pane.title = g_strdup(title);
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
743 pkd->pane.expanded = expanded;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
744
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
745 pkd->key = g_strdup(key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
746
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
747
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
748 hbox = gtk_hbox_new(FALSE, PREF_PAD_GAP);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
749
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
750 pkd->widget = hbox;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
751 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
752 g_signal_connect(G_OBJECT(pkd->widget), "destroy",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
753 G_CALLBACK(bar_pane_keywords_destroy), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
754 gtk_widget_show(hbox);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
755
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
756 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
757 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
758 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
759 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
760 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
761 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
762
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
763 pkd->keyword_view = gtk_text_view_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
764 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
765 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
766 G_CALLBACK(bar_pane_keywords_populate_popup_cb), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
767 gtk_widget_show(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
768
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
769 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
770 g_signal_connect(G_OBJECT(buffer), "changed",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
771 G_CALLBACK(bar_pane_keywords_changed), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
772
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
773 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
774 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
775 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
776 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
777 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
778 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
779
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
780 store = gtk_list_store_new(3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
781 pkd->keyword_treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
782 g_object_unref(store);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
783
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
784 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
785
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
786 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
787
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
788 gtk_tree_view_set_search_column(GTK_TREE_VIEW(pkd->keyword_treeview), KEYWORD_COLUMN_TEXT);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
789
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
790 column = gtk_tree_view_column_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
791 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
792
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
793 renderer = gtk_cell_renderer_toggle_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
794 gtk_tree_view_column_pack_start(column, renderer, FALSE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
795 gtk_tree_view_column_add_attribute(column, renderer, "active", KEYWORD_COLUMN_TOGGLE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
796 g_signal_connect(G_OBJECT(renderer), "toggled",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
797 G_CALLBACK(bar_pane_keywords_keyword_toggle), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
798
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
799 renderer = gtk_cell_renderer_text_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
800 gtk_tree_view_column_pack_start(column, renderer, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
801 gtk_tree_view_column_add_attribute(column, renderer, "text", KEYWORD_COLUMN_TEXT);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
802
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
803 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
804
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
805 column = gtk_tree_view_column_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
806 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
807
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
808 renderer = gtk_cell_renderer_combo_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
809 g_object_set(G_OBJECT(renderer), "editable", (gboolean)TRUE,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
810 "model", create_marks_list(),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
811 "text-column", 0,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
812 "has-entry", FALSE,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
813 NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
814
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
815 gtk_tree_view_column_pack_start(column, renderer, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
816 gtk_tree_view_column_add_attribute(column, renderer, "text", KEYWORD_COLUMN_MARK);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
817 g_signal_connect (renderer, "edited",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
818 G_CALLBACK (bar_pane_keywords_mark_edited), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
819 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
820
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
821
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
822 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
823 gtk_widget_show(pkd->keyword_treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
824
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
825 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
826
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
827 return pkd->widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
828 }
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
829
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
830 GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
831 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
832 gchar *title = g_strdup(_("NoName"));
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
833 gchar *key = g_strdup(COMMENT_KEY);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
834 gboolean expanded = TRUE;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
835
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
836 while (*attribute_names)
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
837 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
838 const gchar *option = *attribute_names++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
839 const gchar *value = *attribute_values++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
840
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
841 READ_CHAR_FULL("pane.title", title);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
842 READ_CHAR_FULL("key", key);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
843 READ_BOOL_FULL("pane.expanded", expanded);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
844
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
845
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
846 DEBUG_1("unknown attribute %s = %s", option, value);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
847 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
848
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
849 return bar_pane_keywords_new(title, key, expanded);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
850 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
851
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
852 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */