Mercurial > geeqie
comparison src/bar_comment.c @ 1469:607c60506863
added a possibility to update existing bars from config
author | nadvornik |
---|---|
date | Fri, 20 Mar 2009 21:28:31 +0000 |
parents | 1b3751ac4743 |
children | 65a5c27823c2 |
comparison
equal
deleted
inserted
replaced
1468:e9f9d3da3f43 | 1469:607c60506863 |
---|---|
149 | 149 |
150 pcd = g_object_get_data(G_OBJECT(pane), "pane_data"); | 150 pcd = g_object_get_data(G_OBJECT(pane), "pane_data"); |
151 if (!pcd) return; | 151 if (!pcd) return; |
152 | 152 |
153 WRITE_NL(); WRITE_STRING("<pane_comment "); | 153 WRITE_NL(); WRITE_STRING("<pane_comment "); |
154 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(pcd->pane.title))); | 154 write_char_option(outstr, indent, "id", pcd->pane.id); |
155 WRITE_BOOL(*pcd, pane.expanded); | 155 write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(pcd->pane.title))); |
156 WRITE_BOOL(pcd->pane, expanded); | |
156 WRITE_CHAR(*pcd, key); | 157 WRITE_CHAR(*pcd, key); |
157 WRITE_INT(*pcd, height); | 158 WRITE_INT(*pcd, height); |
158 WRITE_STRING("/>"); | 159 WRITE_STRING("/>"); |
159 } | 160 } |
160 | 161 |
200 | 201 |
201 file_data_unregister_notify_func(bar_pane_comment_notify_cb, pcd); | 202 file_data_unregister_notify_func(bar_pane_comment_notify_cb, pcd); |
202 | 203 |
203 file_data_unref(pcd->fd); | 204 file_data_unref(pcd->fd); |
204 g_free(pcd->key); | 205 g_free(pcd->key); |
205 | 206 |
207 g_free(pcd->pane.id); | |
206 | 208 |
207 g_free(pcd); | 209 g_free(pcd); |
208 } | 210 } |
209 | 211 |
210 | 212 |
211 GtkWidget *bar_pane_comment_new(const gchar *title, const gchar *key, gboolean expanded, gint height) | 213 GtkWidget *bar_pane_comment_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded, gint height) |
212 { | 214 { |
213 PaneCommentData *pcd; | 215 PaneCommentData *pcd; |
214 GtkWidget *scrolled; | 216 GtkWidget *scrolled; |
215 GtkTextBuffer *buffer; | 217 GtkTextBuffer *buffer; |
216 | 218 |
218 | 220 |
219 pcd->pane.pane_set_fd = bar_pane_comment_set_fd; | 221 pcd->pane.pane_set_fd = bar_pane_comment_set_fd; |
220 pcd->pane.pane_event = bar_pane_comment_event; | 222 pcd->pane.pane_event = bar_pane_comment_event; |
221 pcd->pane.pane_write_config = bar_pane_comment_write_config; | 223 pcd->pane.pane_write_config = bar_pane_comment_write_config; |
222 pcd->pane.title = bar_pane_expander_title(title); | 224 pcd->pane.title = bar_pane_expander_title(title); |
225 pcd->pane.id = g_strdup(id); | |
226 pcd->pane.type = PANE_COMMENT; | |
223 | 227 |
224 pcd->pane.expanded = expanded; | 228 pcd->pane.expanded = expanded; |
225 | 229 |
226 pcd->key = g_strdup(key); | 230 pcd->key = g_strdup(key); |
227 pcd->height = height; | 231 pcd->height = height; |
235 | 239 |
236 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | 240 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); |
237 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | 241 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), |
238 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | 242 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
239 | 243 |
240 gtk_widget_set_size_request(scrolled, -1, height); | 244 gtk_widget_set_size_request(pcd->widget, -1, height); |
241 gtk_widget_show(scrolled); | 245 gtk_widget_show(scrolled); |
242 | 246 |
243 pcd->comment_view = gtk_text_view_new(); | 247 pcd->comment_view = gtk_text_view_new(); |
244 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(pcd->comment_view), GTK_WRAP_WORD); | 248 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(pcd->comment_view), GTK_WRAP_WORD); |
245 gtk_container_add(GTK_CONTAINER(scrolled), pcd->comment_view); | 249 gtk_container_add(GTK_CONTAINER(scrolled), pcd->comment_view); |
257 return pcd->widget; | 261 return pcd->widget; |
258 } | 262 } |
259 | 263 |
260 GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const gchar **attribute_values) | 264 GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const gchar **attribute_values) |
261 { | 265 { |
262 gchar *title = g_strdup(_("NoName")); | 266 gchar *title = g_strdup(_("Comment")); |
263 gchar *key = g_strdup(COMMENT_KEY); | 267 gchar *key = g_strdup(COMMENT_KEY); |
264 gboolean expanded = TRUE; | 268 gboolean expanded = TRUE; |
265 gint height = 50; | 269 gint height = 50; |
270 gchar *id = g_strdup("comment"); | |
271 GtkWidget *ret; | |
266 | 272 |
267 while (*attribute_names) | 273 while (*attribute_names) |
268 { | 274 { |
269 const gchar *option = *attribute_names++; | 275 const gchar *option = *attribute_names++; |
270 const gchar *value = *attribute_values++; | 276 const gchar *value = *attribute_values++; |
271 | 277 |
272 if (READ_CHAR_FULL("pane.title", title)) continue; | 278 if (READ_CHAR_FULL("title", title)) continue; |
273 if (READ_CHAR_FULL("key", key)) continue; | 279 if (READ_CHAR_FULL("key", key)) continue; |
274 if (READ_BOOL_FULL("pane.expanded", expanded)) continue; | 280 if (READ_BOOL_FULL("expanded", expanded)) continue; |
275 if (READ_INT_FULL("height", height)) continue; | 281 if (READ_INT_FULL("height", height)) continue; |
282 if (READ_CHAR_FULL("id", id)) continue; | |
276 | 283 |
277 | 284 |
278 log_printf("unknown attribute %s = %s\n", option, value); | 285 log_printf("unknown attribute %s = %s\n", option, value); |
279 } | 286 } |
280 | 287 |
281 return bar_pane_comment_new(title, key, expanded, height); | 288 ret = bar_pane_comment_new(id, title, key, expanded, height); |
289 g_free(title); | |
290 g_free(key); | |
291 g_free(id); | |
292 return ret; | |
293 } | |
294 | |
295 void bar_pane_comment_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values) | |
296 { | |
297 PaneCommentData *pcd; | |
298 | |
299 pcd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
300 if (!pcd) return; | |
301 | |
302 gchar *title = NULL; | |
303 | |
304 while (*attribute_names) | |
305 { | |
306 const gchar *option = *attribute_names++; | |
307 const gchar *value = *attribute_values++; | |
308 | |
309 if (READ_CHAR_FULL("title", title)) continue; | |
310 if (READ_CHAR_FULL("key", pcd->key)) continue; | |
311 if (READ_BOOL_FULL("expanded", pcd->pane.expanded)) continue; | |
312 if (READ_INT_FULL("height", pcd->height)) continue; | |
313 if (READ_CHAR_FULL("id", pcd->pane.id)) continue; | |
314 | |
315 | |
316 log_printf("unknown attribute %s = %s\n", option, value); | |
317 } | |
318 | |
319 if (title) | |
320 { | |
321 gtk_label_set_text(GTK_LABEL(pcd->pane.title), title); | |
322 g_free(title); | |
323 } | |
324 gtk_widget_set_size_request(pcd->widget, -1, pcd->height); | |
325 bar_update_expander(pane); | |
326 bar_pane_comment_update(pcd); | |
282 } | 327 } |
283 | 328 |
284 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ | 329 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |