annotate src/bar_keywords.c @ 1387:6f31fa931d3f

simplified bar interface
author nadvornik
date Fri, 06 Mar 2009 15:52:47 +0000
parents c9949c19a6d0
children c44f21235ffe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
1 /*
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
2 * Geeqie
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
3 * (C) 2004 John Ellis
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
5 *
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
6 * Author: John Ellis
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
7 *
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
9 * Please read the included file COPYING for more information.
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
11 */
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
12
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
13 #include <glib/gprintf.h>
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
14
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
15 #include "main.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
16 #include "bar_keywords.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
17
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
18 #include "filedata.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
19 #include "history_list.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
20 #include "metadata.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
21 #include "misc.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
22 #include "ui_fileops.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
23 #include "ui_misc.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
24 #include "ui_utildlg.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
25 #include "utilops.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
26 #include "bar.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
27 #include "ui_menu.h"
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
28 #include "rcfile.h"
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1346
diff changeset
29 #include "layout.h"
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
30
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
31 static const gchar *keyword_favorite_defaults[] = {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
32 N_("Favorite"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
33 N_("Todo"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
34 N_("People"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
35 N_("Places"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
36 N_("Art"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
37 N_("Nature"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
38 N_("Possessions"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
39 NULL
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
43 static void bar_pane_keywords_keyword_update_all(void);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
44 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
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 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
48 * keyword / comment utils
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
52
1292
4a3ae0e6f1eb droped Preferences dialog, sidebar should replace it completely
nadvornik
parents: 1291
diff changeset
53 GList *keyword_list_pull(GtkWidget *text_widget)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
54 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
55 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
56 gchar *text;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
57
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
58 text = text_widget_text_pull(text_widget);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
59 list = string_to_keywords_list(text);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
60
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
61 g_free(text);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
62
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
63 return list;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
66 static void keyword_list_push(GtkWidget *textview, GList *list)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
67 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
68 GtkTextBuffer *buffer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
69 GtkTextIter start, end;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
70
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
71 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
72 gtk_text_buffer_get_bounds(buffer, &start, &end);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
73 gtk_text_buffer_delete(buffer, &start, &end);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
74
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
75 while (list)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
76 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
77 const gchar *word = list->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
78 GtkTextIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
79
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
80 gtk_text_buffer_get_end_iter(buffer, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
81 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
82 gtk_text_buffer_get_end_iter(buffer, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
83 gtk_text_buffer_insert(buffer, &iter, "\n", -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
84
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
85 list = list->next;
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 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
92 * keyword list dialog
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
96 #define KEYWORD_DIALOG_WIDTH 200
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
97 #define KEYWORD_DIALOG_HEIGHT 250
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
98
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
99 typedef struct _KeywordDlg KeywordDlg;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
100 struct _KeywordDlg
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
101 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
102 GenericDialog *gd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
103 GtkWidget *treeview;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
106 static KeywordDlg *keyword_dialog = NULL;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
109 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
110 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
111 g_free(keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
112 keyword_dialog = NULL;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
115 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
116 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
117 KeywordDlg *kd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
118 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
119 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
120 gint valid;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
121
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
122 history_list_free_key("keywords");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
123
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
124 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
125 valid = gtk_tree_model_get_iter_first(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
126 while (valid)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
127 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
128 gchar *key;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
129
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
130 gtk_tree_model_get(store, &iter, 0, &key, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
131 valid = gtk_tree_model_iter_next(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
132
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
133 history_list_add_to_key("keywords", key, 0);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
136 keyword_dialog_cancel_cb(gd, data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
137
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
138 bar_pane_keywords_keyword_update_all();
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
141 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
142 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
143 KeywordDlg *kd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
144 GtkTreeSelection *selection;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
145 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
146 GtkTreeIter sibling;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
147 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
148 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
149
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
150 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
151 if (gtk_tree_selection_get_selected(selection, &store, &sibling))
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
152 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
153 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
154 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
155 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
156 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
157 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
158 gtk_list_store_append(GTK_LIST_STORE(store), &iter);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
161 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
162
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
163 tpath = gtk_tree_model_get_path(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
164 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
165 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
166 gtk_tree_path_free(tpath);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
169 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
170 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
171 KeywordDlg *kd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
172 GtkTreeSelection *selection;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
173 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
174 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
175 GtkTreeIter next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
176 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
177
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
178 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
179 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
180
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
181 tpath = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
182 next = iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
183 if (gtk_tree_model_iter_next(store, &next))
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
184 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
185 tpath = gtk_tree_model_get_path(store, &next);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
186 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
187 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
188 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
189 tpath = gtk_tree_model_get_path(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
190 if (!gtk_tree_path_prev(tpath))
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
191 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
192 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
193 tpath = NULL;
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 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
196 if (tpath)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
197 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
198 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
199 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
200 gtk_tree_path_free(tpath);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
203 gtk_list_store_remove(GTK_LIST_STORE(store), &iter);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
206 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
207 const gchar *new_text, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
208 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
209 KeywordDlg *kd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
210 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
211 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
212 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
213
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
214 if (!new_text || strlen(new_text) == 0) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
215
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
216 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
217
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
218 tpath = gtk_tree_path_new_from_string(path);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
219 gtk_tree_model_get_iter(store, &iter, tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
220 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
221
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
222 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
223 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
224
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
225 static void keyword_dialog_populate(KeywordDlg *kd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
226 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
227 GtkListStore *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
228 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
229
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
230 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
231 gtk_list_store_clear(store);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
232
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
233 list = history_list_get_by_key("keywords");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
234 list = g_list_last(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
235 while (list)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
236 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
237 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
238
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
239 gtk_list_store_append(store, &iter);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
240 gtk_list_store_set(store, &iter, 0, list->data,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
241 1, TRUE, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
242
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
243 list = list->prev;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
247 static void keyword_dialog_show(void)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
248 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
249 GtkWidget *scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
250 GtkListStore *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
251 GtkTreeViewColumn *column;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
252 GtkCellRenderer *renderer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
253 GtkWidget *hbox;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
254 GtkWidget *button;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
255
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
256 if (keyword_dialog)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
257 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
258 gtk_window_present(GTK_WINDOW(keyword_dialog->gd->dialog));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
259 return;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
262 keyword_dialog = g_new0(KeywordDlg, 1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
263
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
264 keyword_dialog->gd = generic_dialog_new(_("Keyword Presets"),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
265 "keyword_presets", NULL, TRUE,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
266 keyword_dialog_cancel_cb, keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
267 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
268
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
269 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
270 keyword_dialog_ok_cb, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
271
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
272 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
273 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
274 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
275 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
276 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
277 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
278 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
279
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
280 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
281 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
282 g_object_unref(store);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
283
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
284 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
285 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
286 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
287
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
288 column = gtk_tree_view_column_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
289 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
290 renderer = gtk_cell_renderer_text_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
291 g_signal_connect(G_OBJECT(renderer), "edited",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
292 G_CALLBACK(keyword_dialog_edit_cb), keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
293 gtk_tree_view_column_pack_start(column, renderer, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
294 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
295 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
296 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
297
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
298 gtk_container_add(GTK_CONTAINER(scrolled), keyword_dialog->treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
299 gtk_widget_show(keyword_dialog->treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
300
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
301 hbox = gtk_hbox_new(FALSE, 5);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
302 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
303 gtk_widget_show(hbox);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
304
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
305 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
306 g_signal_connect(G_OBJECT(button), "clicked",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
307 G_CALLBACK(keyword_dialog_add_cb), keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
308 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
309 gtk_widget_show(button);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
310
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
311 button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
312 g_signal_connect(G_OBJECT(button), "clicked",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
313 G_CALLBACK(keyword_dialog_remove_cb), keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
314 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
315 gtk_widget_show(button);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
316
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
317 keyword_dialog_populate(keyword_dialog);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
318
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
319 gtk_widget_show(keyword_dialog->gd->dialog);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
323 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
324 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
325 keyword_dialog_show();
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 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
331 * info bar
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
335 enum {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
336 KEYWORD_COLUMN_TOGGLE = 0,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
337 KEYWORD_COLUMN_TEXT,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
338 KEYWORD_COLUMN_MARK
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
341 typedef struct _PaneKeywordsData PaneKeywordsData;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
342 struct _PaneKeywordsData
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
343 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
344 PaneData pane;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
345 GtkWidget *widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
346
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
347 GtkWidget *keyword_view;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
348 GtkWidget *keyword_treeview;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
349
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
350 FileData *fd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
351 gchar *key;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
355 static GList *bar_list = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
356
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
357
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
358 static void bar_pane_keywords_write(PaneKeywordsData *pkd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
359 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
360 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
361
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
362 if (!pkd->fd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
363
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
364 list = keyword_list_pull(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
365
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
366 metadata_write_list(pkd->fd, KEYWORD_KEY, list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
367
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
368 string_list_free(list);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
371 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
372 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
373 gint i;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
374 static gchar buf[10];
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
375
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
376 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
377 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
378 FileDataGetMarkFunc get_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
379 FileDataSetMarkFunc set_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
380 gpointer data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
381 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
382 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
383 {
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
384 g_sprintf(buf, " %d ", i + 1);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
385 return buf;
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 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
388 return " ... ";
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
389 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
390
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
391 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
392 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
393 GList *list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
394 GtkListStore *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
395 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
396
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
397 list = history_list_get_by_key("keywords");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
398 if (!list)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
399 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
400 /* blank? set up a few example defaults */
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
401
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
402 gint i = 0;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
403
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
404 while (keyword_favorite_defaults[i] != NULL)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
405 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
406 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
407 i++;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
410 list = history_list_get_by_key("keywords");
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
413 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
414
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
415 gtk_list_store_clear(store);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
416
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
417 list = g_list_last(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
418 while (list)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
419 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
420 gchar *key = list->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
421
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
422 gtk_list_store_append(store, &iter);
1340
361120a66609 Use g_utf8_casefold() to compare keywords, uppercased/lowercased keywords are now matched against predefined list.
zas_
parents: 1315
diff changeset
423 gtk_list_store_set(store, &iter, KEYWORD_COLUMN_TOGGLE, !!find_string_in_list_utf8nocase(keywords, key),
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
424 KEYWORD_COLUMN_TEXT, key,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
425 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
426
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
427 list = list->prev;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
431 static void bar_pane_keywords_keyword_update_all(void)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
432 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
433 GList *work;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
434
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
435 work = bar_list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
436 while (work)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
437 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
438 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
439 GList *keywords;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
440
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
441 pkd = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
442 work = work->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
443
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
444 keywords = keyword_list_pull(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
445 bar_keyword_list_sync(pkd, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
446 string_list_free(keywords);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
450 static void bar_pane_keywords_update(PaneKeywordsData *pkd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
451 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
452 GList *keywords = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
453 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
454
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
455 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
456
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
457 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
458 keyword_list_push(pkd->keyword_view, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
459 bar_keyword_list_sync(pkd, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
460 string_list_free(keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
461
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
462 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
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
466 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
467 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
468 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
469
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
470 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
471 if (!pkd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
472
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
473 file_data_unref(pkd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
474 pkd->fd = file_data_ref(fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
475
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
476 bar_pane_keywords_update(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
477 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
478
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
479 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
480 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
481 PaneKeywordsData *pkd;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
482
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
483 pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
484 if (!pkd) return;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
485
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
486 WRITE_STRING("<pane_keywords\n");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
487 indent++;
1343
eebb8d0cb677 give the panes more control over expander title
nadvornik
parents: 1340
diff changeset
488 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(pkd->pane.title)));
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
489 WRITE_BOOL(*pkd, pane.expanded);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
490 WRITE_CHAR(*pkd, key);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
491 indent--;
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
492 WRITE_STRING("/>\n");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
493 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
494
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
495 gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
496 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
497 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
498
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
499 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
500 if (!pkd) return FALSE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
501
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
502 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
503
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
504 return FALSE;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
507 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
508 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
509 GList *list;
1340
361120a66609 Use g_utf8_casefold() to compare keywords, uppercased/lowercased keywords are now matched against predefined list.
zas_
parents: 1315
diff changeset
510 gchar *found;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
511
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
512 if (!keyword) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
513
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
514 list = keyword_list_pull(pkd->keyword_view);
1340
361120a66609 Use g_utf8_casefold() to compare keywords, uppercased/lowercased keywords are now matched against predefined list.
zas_
parents: 1315
diff changeset
515 found = find_string_in_list_utf8nocase(list, keyword);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
516
1340
361120a66609 Use g_utf8_casefold() to compare keywords, uppercased/lowercased keywords are now matched against predefined list.
zas_
parents: 1315
diff changeset
517 if ((!active && found) || (active && !found))
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
518 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
519 if (found)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
520 {
1340
361120a66609 Use g_utf8_casefold() to compare keywords, uppercased/lowercased keywords are now matched against predefined list.
zas_
parents: 1315
diff changeset
521 list = g_list_remove(list, found);
361120a66609 Use g_utf8_casefold() to compare keywords, uppercased/lowercased keywords are now matched against predefined list.
zas_
parents: 1315
diff changeset
522 g_free(found);
1291
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 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
525 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
526 list = g_list_append(list, g_strdup(keyword));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
527 }
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 keyword_list_push(pkd->keyword_view, list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
530 }
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 string_list_free(list);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
535 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
536 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
537 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
538 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
539 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
540 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
541 gchar *key = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
542 gboolean active;
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 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
545
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
546 tpath = gtk_tree_path_new_from_string(path);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
547 gtk_tree_model_get_iter(store, &iter, tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
548 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
549
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
550 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
551 KEYWORD_COLUMN_TEXT, &key, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
552 active = (!active);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
553 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
554
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
555 bar_pane_keywords_keyword_set(pkd, key, active);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
556 g_free(key);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
557 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
558
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
559 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
560 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
561 GList *keywords = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
562 GList *list = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
563 GList *work;
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 keywords = keyword_list_pull(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
566
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1346
diff changeset
567 list = layout_selection_list(pkd->pane.lw);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
568 work = list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
569 while (work)
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 FileData *fd = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
572 work = work->next;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
573
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
574 if (append)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
575 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
576 metadata_append_list(fd, KEYWORD_KEY, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
577 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
578 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
579 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
580 metadata_write_list(fd, KEYWORD_KEY, keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
581 }
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
584 filelist_free(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
585 string_list_free(keywords);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
586 }
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 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
589 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
590 PaneKeywordsData *pkd = data;
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 bar_pane_keywords_set_selection(pkd, TRUE);
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 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
596 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
597 PaneKeywordsData *pkd = data;
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 bar_pane_keywords_set_selection(pkd, FALSE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
600 }
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 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
603 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
604 PaneKeywordsData *pkd = data;
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 menu_item_add_divider(GTK_WIDGET(menu));
1295
8c59e6e50bd8 Fix up few compilation warnings.
zas_
parents: 1292
diff changeset
607 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
608 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
609 }
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
612 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
613 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
614 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
615 if (fd == pkd->fd) bar_pane_keywords_update(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
616 }
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 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
619 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
620 PaneKeywordsData *pkd = data;
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 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
623 bar_pane_keywords_write(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
624 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
625 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
626
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1343
diff changeset
627 static void bar_pane_keywords_mark_edited(GtkCellRendererText *cell, const gchar *path, const gchar *text, gpointer data)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
628 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
629 PaneKeywordsData *pkd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
630 GtkTreeModel *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
631 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
632 GtkTreePath *tpath;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
633 gchar *key = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
634 gint i;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
635 FileDataGetMarkFunc get_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
636 FileDataSetMarkFunc set_mark_func;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
637 gpointer mark_func_data;
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 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
640
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
641 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
642
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
643 tpath = gtk_tree_path_new_from_string(path);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
644 gtk_tree_model_get_iter(store, &iter, tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
645 gtk_tree_path_free(tpath);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
646
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
647 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
648
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
649 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
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_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
652 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
653 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
654 g_free(mark_func_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
655 file_data_register_mark_func(i, NULL, NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
656 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
657 }
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 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
660 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
661 i--;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
662 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
663 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
664 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
665 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
666
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
667 g_free(key);
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 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
670 bar_pane_keywords_update(pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
671 }
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 void bar_pane_keywords_close(GtkWidget *bar)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
674 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
675 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
676
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
677 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
678 if (!pkd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
679
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
680 gtk_widget_destroy(pkd->widget);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
681 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
682
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
683 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
684 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
685 PaneKeywordsData *pkd = data;
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 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
688
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
689 file_data_unref(pkd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
690 g_free(pkd->key);
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 g_free(pkd);
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 GtkTreeModel *create_marks_list(void)
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 GtkListStore *model;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
698 GtkTreeIter iter;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
699 gint i;
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 /* create list store */
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
702 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
703 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
704 {
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
705 gchar str[10];
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
706 g_sprintf(str, " %d ", i + 1);
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1343
diff changeset
707 gtk_list_store_append(model, &iter);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
708 gtk_list_store_set(model, &iter, 0, str, -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
709 }
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1343
diff changeset
710 gtk_list_store_append(model, &iter);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
711 gtk_list_store_set(model, &iter, 0, " ... ", -1);
1305
2abdd6e50120 Glibification.
zas_
parents: 1295
diff changeset
712 return GTK_TREE_MODEL(model);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
713 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
714
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
715 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
716 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
717 PaneKeywordsData *pkd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
718 GtkWidget *hbox;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
719 GtkWidget *scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
720 GtkTextBuffer *buffer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
721 GtkListStore *store;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
722 GtkTreeViewColumn *column;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
723 GtkCellRenderer *renderer;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
724
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
725 pkd = g_new0(PaneKeywordsData, 1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
726
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
727 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
728 pkd->pane.pane_event = bar_pane_keywords_event;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
729 pkd->pane.pane_write_config = bar_pane_keywords_write_config;
1343
eebb8d0cb677 give the panes more control over expander title
nadvornik
parents: 1340
diff changeset
730 pkd->pane.title = gtk_label_new(title);
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1346
diff changeset
731 pref_label_bold(pkd->pane.title, TRUE, FALSE);
6f31fa931d3f simplified bar interface
nadvornik
parents: 1346
diff changeset
732
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
733 pkd->pane.expanded = expanded;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
734
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
735 pkd->key = g_strdup(key);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
738 hbox = gtk_hbox_new(FALSE, PREF_PAD_GAP);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
739
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
740 pkd->widget = hbox;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
741 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
742 g_signal_connect(G_OBJECT(pkd->widget), "destroy",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
743 G_CALLBACK(bar_pane_keywords_destroy), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
744 gtk_widget_show(hbox);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
745
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
746 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
747 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
748 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
749 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
750 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
751 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
752
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
753 pkd->keyword_view = gtk_text_view_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
754 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
755 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
756 G_CALLBACK(bar_pane_keywords_populate_popup_cb), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
757 gtk_widget_show(pkd->keyword_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
758
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
759 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
760 g_signal_connect(G_OBJECT(buffer), "changed",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
761 G_CALLBACK(bar_pane_keywords_changed), pkd);
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 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
764 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
765 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
766 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
767 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
768 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
769
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
770 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
771 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
772 g_object_unref(store);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
773
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
774 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
775
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
776 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
777
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
778 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
779
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
780 column = gtk_tree_view_column_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
781 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
782
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
783 renderer = gtk_cell_renderer_toggle_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
784 gtk_tree_view_column_pack_start(column, renderer, FALSE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
785 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
786 g_signal_connect(G_OBJECT(renderer), "toggled",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
787 G_CALLBACK(bar_pane_keywords_keyword_toggle), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
788
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
789 renderer = gtk_cell_renderer_text_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
790 gtk_tree_view_column_pack_start(column, renderer, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
791 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
792
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
793 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
794
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
795 column = gtk_tree_view_column_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
796 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
797
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
798 renderer = gtk_cell_renderer_combo_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
799 g_object_set(G_OBJECT(renderer), "editable", (gboolean)TRUE,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
800 "model", create_marks_list(),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
801 "text-column", 0,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
802 "has-entry", FALSE,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
803 NULL);
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 gtk_tree_view_column_pack_start(column, renderer, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
806 gtk_tree_view_column_add_attribute(column, renderer, "text", KEYWORD_COLUMN_MARK);
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1343
diff changeset
807 g_signal_connect(renderer, "edited",
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
808 G_CALLBACK (bar_pane_keywords_mark_edited), pkd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
809 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
810
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
811
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
812 gtk_container_add(GTK_CONTAINER(scrolled), pkd->keyword_treeview);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
813 gtk_widget_show(pkd->keyword_treeview);
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 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
816
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
817 return pkd->widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
818 }
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
819
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
820 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
821 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
822 gchar *title = g_strdup(_("NoName"));
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
823 gchar *key = g_strdup(COMMENT_KEY);
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
824 gboolean expanded = TRUE;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
825
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
826 while (*attribute_names)
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
827 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
828 const gchar *option = *attribute_names++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
829 const gchar *value = *attribute_values++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
830
1315
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
831 if (READ_CHAR_FULL("pane.title", title)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
832 if (READ_CHAR_FULL("key", key)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
833 if (READ_BOOL_FULL("pane.expanded", expanded)) continue;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
834
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 DEBUG_1("unknown attribute %s = %s", option, value);
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
55ea4962887a config file format changed to XML
nadvornik
parents: 1305
diff changeset
839 return bar_pane_keywords_new(title, key, expanded);
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
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
842 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */