annotate src/bar_comment.c @ 1295:8c59e6e50bd8

Fix up few compilation warnings.
author zas_
date Sun, 15 Feb 2009 15:56:48 +0000
parents 50ae02a4a675
children 55ea4962887a
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"
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
22
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
23 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
24
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
25 /*
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 * keyword / comment utils
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 */
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 typedef struct _PaneCommentData PaneCommentData;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
34 struct _PaneCommentData
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
35 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
36 PaneData pane;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
37 GtkWidget *widget;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
38 GtkWidget *comment_view;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
39 FileData *fd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
40 gchar *key;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
44 static void bar_pane_comment_write(PaneCommentData *pcd)
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 gchar *comment;
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 if (!pcd->fd) return;
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 comment = text_widget_text_pull(pcd->comment_view);
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 metadata_write_string(pcd->fd, pcd->key, comment);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
53 g_free(comment);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
56
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
57 static void bar_pane_comment_update(PaneCommentData *pcd)
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 gchar *comment = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
60 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
61
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
62 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
63
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
64 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
65 gtk_text_buffer_set_text(comment_buffer,
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
66 (comment) ? comment : "", -1);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
67 g_free(comment);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
68
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
69 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
70
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
71 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
72 }
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 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
75 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
76 GList *list = NULL;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
77 GList *work;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
78 gchar *comment = NULL;
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 if (!pcd->pane.list_func) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
81
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
82 comment = text_widget_text_pull(pcd->comment_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
83
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
84 list = pcd->pane.list_func(pcd->pane.list_data);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
85 work = list;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
86 while (work)
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 FileData *fd = work->data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
89 work = work->next;
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 if (append)
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
92 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
93 metadata_append_string(fd, pcd->key, comment);
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 else
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
96 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
97 metadata_write_string(fd, pcd->key, comment);
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 }
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 filelist_free(list);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
102 g_free(comment);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
103 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
104
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
105 static 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
106 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
107 PaneCommentData *pcd = data;
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 bar_pane_comment_set_selection(pcd, TRUE);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
112 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
113 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
114 PaneCommentData *pcd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
115
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
116 bar_pane_comment_set_selection(pcd, FALSE);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
117 }
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 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
121 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
122 PaneCommentData *pcd;
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 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
125 if (!pcd) return;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
126
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
127 file_data_unref(pcd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
128 pcd->fd = file_data_ref(fd);
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 bar_pane_comment_update(pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
131 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
132
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
133 gint bar_pane_comment_event(GtkWidget *bar, GdkEvent *event)
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 PaneCommentData *pcd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
136
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
137 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
138 if (!pcd) return FALSE;
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 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
141
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
142 return FALSE;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
143 }
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 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
146 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
147 PaneCommentData *pcd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
148 if (fd == pcd->fd) bar_pane_comment_update(pcd);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
151 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
152 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
153 PaneCommentData *pcd = data;
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 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
156 bar_pane_comment_write(pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
157 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
158 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
159
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
160
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
161 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
162 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
163 PaneCommentData *pcd = data;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
164
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
165 menu_item_add_divider(GTK_WIDGET(menu));
1295
8c59e6e50bd8 Fix up few compilation warnings.
zas_
parents: 1291
diff changeset
166 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
167 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
168 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
169
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
170
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
171 static void bar_pane_comment_close(GtkWidget *bar)
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 PaneCommentData *pcd;
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 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
176 if (!pcd) return;
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 gtk_widget_destroy(pcd->comment_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
179 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
180
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
181 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
182 {
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
183 PaneCommentData *pcd = 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 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
186
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
187 file_data_unref(pcd->fd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
188 g_free(pcd->pane.title);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
189 g_free(pcd->key);
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
192 g_free(pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
193 }
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
194
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
195
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
196 GtkWidget *bar_pane_comment_new(const gchar *title, const gchar *key, gint height)
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 PaneCommentData *pcd;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
199 GtkWidget *scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
200 GtkTextBuffer *buffer;
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 pcd = g_new0(PaneCommentData, 1);
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 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
205 pcd->pane.pane_event = bar_pane_comment_event;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
206 pcd->pane.title = g_strdup(title);
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 pcd->key = g_strdup(key);
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 scrolled = gtk_scrolled_window_new(NULL, NULL);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
211
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
212 pcd->widget = scrolled;
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
213 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
214 g_signal_connect(G_OBJECT(pcd->widget), "destroy",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
215 G_CALLBACK(bar_pane_comment_destroy), 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 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
218 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
219 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
220
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
221 gtk_widget_set_size_request(scrolled, -1, height);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
222 gtk_widget_show(scrolled);
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 pcd->comment_view = gtk_text_view_new();
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
225 gtk_container_add(GTK_CONTAINER(scrolled), pcd->comment_view);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
226 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
227 G_CALLBACK(bar_pane_comment_populate_popup), pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
228 gtk_widget_show(pcd->comment_view);
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 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
231 g_signal_connect(G_OBJECT(buffer), "changed",
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
232 G_CALLBACK(bar_pane_comment_changed), pcd);
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
233
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
234
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
235 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
236
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
237 return pcd->widget;
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
50ae02a4a675 replaced bar_info with an universal bar, restored the original
nadvornik
parents:
diff changeset
240 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */