annotate src/bar_comment.c @ 1712:7f91f906f9c2

Comment out unused functions, silenting related compilation warnings.
author zas_
date Mon, 07 Sep 2009 08:24:09 +0000
parents 5f49f305a6b6
children
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
13
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
14 #include "main.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
15 #include "bar_comment.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
16
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
17 #include "bar.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
18 #include "metadata.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
19 #include "filedata.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
20 #include "ui_menu.h"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
21 #include "ui_misc.h"
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
22 #include "rcfile.h"
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1384
diff changeset
23 #include "layout.h"
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
24
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
25 static void bar_pane_comment_changed(GtkTextBuffer *buffer, gpointer data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
26
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
27 /*
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
28 *-------------------------------------------------------------------
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
29 * keyword / comment utils
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 */
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
32
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
33
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
34
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
35 typedef struct _PaneCommentData PaneCommentData;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
36 struct _PaneCommentData
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
37 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
38 PaneData pane;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
39 GtkWidget *widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
40 GtkWidget *comment_view;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
41 FileData *fd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
42 gchar *key;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
43 gint height;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
44 };
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
45
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 static void bar_pane_comment_write(PaneCommentData *pcd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
48 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
49 gchar *comment;
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 if (!pcd->fd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
52
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
53 comment = text_widget_text_pull(pcd->comment_view);
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 metadata_write_string(pcd->fd, pcd->key, comment);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
56 g_free(comment);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
59
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
60 static void bar_pane_comment_update(PaneCommentData *pcd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
61 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
62 gchar *comment = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
63 GtkTextBuffer *comment_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pcd->comment_view));
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 g_signal_handlers_block_by_func(comment_buffer, bar_pane_comment_changed, pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
66
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
67 comment = metadata_read_string(pcd->fd, pcd->key, METADATA_PLAIN);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
68 gtk_text_buffer_set_text(comment_buffer,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
69 (comment) ? comment : "", -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
70 g_free(comment);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
71
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
72 g_signal_handlers_unblock_by_func(comment_buffer, bar_pane_comment_changed, pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
73
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
74 gtk_widget_set_sensitive(pcd->comment_view, (pcd->fd != NULL));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
75 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
76
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
77 static void bar_pane_comment_set_selection(PaneCommentData *pcd, gboolean append)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
78 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
79 GList *list = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
80 GList *work;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
81 gchar *comment = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
82
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
83 comment = text_widget_text_pull(pcd->comment_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
84
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1384
diff changeset
85 list = layout_selection_list(pcd->pane.lw);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
86 work = list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
87 while (work)
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 FileData *fd = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
90 work = work->next;
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 if (append)
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 metadata_append_string(fd, pcd->key, comment);
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 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
97 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
98 metadata_write_string(fd, pcd->key, comment);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
99 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
100 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
101
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
102 filelist_free(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
103 g_free(comment);
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 void bar_pane_comment_sel_add_cb(GtkWidget *button, gpointer data)
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 PaneCommentData *pcd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
109
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
110 bar_pane_comment_set_selection(pcd, TRUE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
111 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
112
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
113 static void bar_pane_comment_sel_replace_cb(GtkWidget *button, gpointer data)
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 PaneCommentData *pcd = 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 bar_pane_comment_set_selection(pcd, FALSE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
118 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
119
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
120
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
121 static void bar_pane_comment_set_fd(GtkWidget *bar, FileData *fd)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
122 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
123 PaneCommentData *pcd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
124
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
125 pcd = g_object_get_data(G_OBJECT(bar), "pane_data");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
126 if (!pcd) return;
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 file_data_unref(pcd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
129 pcd->fd = file_data_ref(fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
130
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
131 bar_pane_comment_update(pcd);
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
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
134 static gint bar_pane_comment_event(GtkWidget *bar, GdkEvent *event)
1291
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 PaneCommentData *pcd;
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 pcd = g_object_get_data(G_OBJECT(bar), "pane_data");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
139 if (!pcd) return FALSE;
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 if (GTK_WIDGET_HAS_FOCUS(pcd->comment_view)) return gtk_widget_event(pcd->comment_view, event);
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 return FALSE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
144 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
145
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
146 static void bar_pane_comment_write_config(GtkWidget *pane, GString *outstr, gint indent)
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
147 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
148 PaneCommentData *pcd;
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
149
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
150 pcd = g_object_get_data(G_OBJECT(pane), "pane_data");
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
151 if (!pcd) return;
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
152
1461
e015b6573d36 improved config file formatting
nadvornik
parents: 1389
diff changeset
153 WRITE_NL(); WRITE_STRING("<pane_comment ");
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
154 write_char_option(outstr, indent, "id", pcd->pane.id);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
155 write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(pcd->pane.title)));
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
156 WRITE_BOOL(pcd->pane, expanded);
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
157 WRITE_CHAR(*pcd, key);
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
158 WRITE_INT(*pcd, height);
1461
e015b6573d36 improved config file formatting
nadvornik
parents: 1389
diff changeset
159 WRITE_STRING("/>");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
160 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
161
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
162 static void bar_pane_comment_notify_cb(FileData *fd, NotifyType type, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
163 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
164 PaneCommentData *pcd = data;
1498
5f49f305a6b6 improved debug messages
nadvornik
parents: 1489
diff changeset
165 if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == pcd->fd)
5f49f305a6b6 improved debug messages
nadvornik
parents: 1489
diff changeset
166 {
5f49f305a6b6 improved debug messages
nadvornik
parents: 1489
diff changeset
167 DEBUG_1("Notify pane_comment: %s %04x", fd->path, type);
5f49f305a6b6 improved debug messages
nadvornik
parents: 1489
diff changeset
168
5f49f305a6b6 improved debug messages
nadvornik
parents: 1489
diff changeset
169 bar_pane_comment_update(pcd);
5f49f305a6b6 improved debug messages
nadvornik
parents: 1489
diff changeset
170 }
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
171 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
172
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
173 static void bar_pane_comment_changed(GtkTextBuffer *buffer, gpointer data)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
174 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
175 PaneCommentData *pcd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
176
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
177 file_data_unregister_notify_func(bar_pane_comment_notify_cb, pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
178 bar_pane_comment_write(pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
179 file_data_register_notify_func(bar_pane_comment_notify_cb, pcd, NOTIFY_PRIORITY_LOW);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
182
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
183 static void bar_pane_comment_populate_popup(GtkTextView *textview, GtkMenu *menu, gpointer data)
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 PaneCommentData *pcd = data;
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 menu_item_add_divider(GTK_WIDGET(menu));
1295
8c59e6e50bd8 Fix up few compilation warnings.
zas_
parents: 1291
diff changeset
188 menu_item_add_stock(GTK_WIDGET(menu), _("Add text to selected files"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_comment_sel_add_cb), pcd);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
189 menu_item_add_stock(GTK_WIDGET(menu), _("Replace existing text in selected files"), GTK_STOCK_CONVERT, G_CALLBACK(bar_pane_comment_sel_replace_cb), data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
190 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
191
1712
7f91f906f9c2 Comment out unused functions, silenting related compilation warnings.
zas_
parents: 1498
diff changeset
192 #if 0
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
193 static void bar_pane_comment_close(GtkWidget *bar)
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 PaneCommentData *pcd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
196
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
197 pcd = g_object_get_data(G_OBJECT(bar), "pane_data");
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
198 if (!pcd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
199
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
200 gtk_widget_destroy(pcd->comment_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
201 }
1712
7f91f906f9c2 Comment out unused functions, silenting related compilation warnings.
zas_
parents: 1498
diff changeset
202 #endif
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
203
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
204 static void bar_pane_comment_destroy(GtkWidget *widget, gpointer data)
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 PaneCommentData *pcd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
207
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
208 file_data_unregister_notify_func(bar_pane_comment_notify_cb, pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
209
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
210 file_data_unref(pcd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
211 g_free(pcd->key);
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
212
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
213 g_free(pcd->pane.id);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
214
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
215 g_free(pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
216 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
217
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
218
1485
0e82a03c165b pane interface cleanup
nadvornik
parents: 1471
diff changeset
219 static GtkWidget *bar_pane_comment_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded, gint height)
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
220 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
221 PaneCommentData *pcd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
222 GtkWidget *scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
223 GtkTextBuffer *buffer;
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 pcd = g_new0(PaneCommentData, 1);
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 pcd->pane.pane_set_fd = bar_pane_comment_set_fd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
228 pcd->pane.pane_event = bar_pane_comment_event;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
229 pcd->pane.pane_write_config = bar_pane_comment_write_config;
1389
c44f21235ffe Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents: 1387
diff changeset
230 pcd->pane.title = bar_pane_expander_title(title);
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
231 pcd->pane.id = g_strdup(id);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
232 pcd->pane.type = PANE_COMMENT;
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1384
diff changeset
233
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
234 pcd->pane.expanded = expanded;
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
235
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
236 pcd->key = g_strdup(key);
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
237 pcd->height = height;
1291
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 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
240
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
241 pcd->widget = scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
242 g_object_set_data(G_OBJECT(pcd->widget), "pane_data", pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
243 g_signal_connect(G_OBJECT(pcd->widget), "destroy",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
244 G_CALLBACK(bar_pane_comment_destroy), pcd);
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 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
247 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
248 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
249
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
250 gtk_widget_set_size_request(pcd->widget, -1, height);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
251 gtk_widget_show(scrolled);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
252
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
253 pcd->comment_view = gtk_text_view_new();
1384
99eae1622e0c enable wrap mode in comment pane
nadvornik
parents: 1343
diff changeset
254 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(pcd->comment_view), GTK_WRAP_WORD);
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
255 gtk_container_add(GTK_CONTAINER(scrolled), pcd->comment_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
256 g_signal_connect(G_OBJECT(pcd->comment_view), "populate-popup",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
257 G_CALLBACK(bar_pane_comment_populate_popup), pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
258 gtk_widget_show(pcd->comment_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
259
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
260 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pcd->comment_view));
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
261 g_signal_connect(G_OBJECT(buffer), "changed",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
262 G_CALLBACK(bar_pane_comment_changed), pcd);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
265 file_data_register_notify_func(bar_pane_comment_notify_cb, pcd, NOTIFY_PRIORITY_LOW);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
266
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
267 return pcd->widget;
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
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
270 GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
271 {
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
272 gchar *title = NULL;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
273 gchar *key = g_strdup(COMMENT_KEY);
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
274 gboolean expanded = TRUE;
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
275 gint height = 50;
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
276 gchar *id = g_strdup("comment");
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
277 GtkWidget *ret;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
278
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
279 while (*attribute_names)
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
280 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
281 const gchar *option = *attribute_names++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
282 const gchar *value = *attribute_values++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
283
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
284 if (READ_CHAR_FULL("title", title)) continue;
1315
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
285 if (READ_CHAR_FULL("key", key)) continue;
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
286 if (READ_BOOL_FULL("expanded", expanded)) continue;
1315
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
287 if (READ_INT_FULL("height", height)) continue;
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
288 if (READ_CHAR_FULL("id", id)) continue;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
289
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
290
1464
1b3751ac4743 be more verbose on parse errors
nadvornik
parents: 1461
diff changeset
291 log_printf("unknown attribute %s = %s\n", option, value);
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
292 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
293
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
294 bar_pane_translate_title(PANE_COMMENT, id, &title);
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
295 ret = bar_pane_comment_new(id, title, key, expanded, height);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
296 g_free(title);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
297 g_free(key);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
298 g_free(id);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
299 return ret;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
300 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
301
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
302 void bar_pane_comment_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
303 {
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
304 PaneCommentData *pcd;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
305
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
306 pcd = g_object_get_data(G_OBJECT(pane), "pane_data");
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
307 if (!pcd) return;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
308
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
309 gchar *title = NULL;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
310
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
311 while (*attribute_names)
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
312 {
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
313 const gchar *option = *attribute_names++;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
314 const gchar *value = *attribute_values++;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
315
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
316 if (READ_CHAR_FULL("title", title)) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
317 if (READ_CHAR_FULL("key", pcd->key)) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
318 if (READ_BOOL_FULL("expanded", pcd->pane.expanded)) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
319 if (READ_INT_FULL("height", pcd->height)) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
320 if (READ_CHAR_FULL("id", pcd->pane.id)) continue;
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
321
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
322
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
323 log_printf("unknown attribute %s = %s\n", option, value);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
324 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
325
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
326 if (title)
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
327 {
1471
65a5c27823c2 update translated pane titles
nadvornik
parents: 1469
diff changeset
328 bar_pane_translate_title(PANE_COMMENT, pcd->pane.id, &title);
1469
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
329 gtk_label_set_text(GTK_LABEL(pcd->pane.title), title);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
330 g_free(title);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
331 }
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
332 gtk_widget_set_size_request(pcd->widget, -1, pcd->height);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
333 bar_update_expander(pane);
607c60506863 added a possibility to update existing bars from config
nadvornik
parents: 1464
diff changeset
334 bar_pane_comment_update(pcd);
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
335 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1295
diff changeset
336
1291
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
337 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */