comparison src/bar_histogram.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
116 116
117 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); 117 phd = g_object_get_data(G_OBJECT(pane), "pane_data");
118 if (!phd) return; 118 if (!phd) return;
119 119
120 WRITE_NL(); WRITE_STRING("<pane_histogram "); 120 WRITE_NL(); WRITE_STRING("<pane_histogram ");
121 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(phd->pane.title))); 121 write_char_option(outstr, indent, "id", phd->pane.id);
122 WRITE_BOOL(*phd, pane.expanded); 122 write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(phd->pane.title)));
123 WRITE_BOOL(phd->pane, expanded);
123 WRITE_INT(*phd->histogram, histogram_channel); 124 WRITE_INT(*phd->histogram, histogram_channel);
124 WRITE_INT(*phd->histogram, histogram_mode); 125 WRITE_INT(*phd->histogram, histogram_mode);
125 WRITE_STRING("/>"); 126 WRITE_STRING("/>");
126 } 127 }
127 128
180 file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd); 181 file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd);
181 182
182 file_data_unref(phd->fd); 183 file_data_unref(phd->fd);
183 histogram_free(phd->histogram); 184 histogram_free(phd->histogram);
184 if (phd->pixbuf) g_object_unref(phd->pixbuf); 185 if (phd->pixbuf) g_object_unref(phd->pixbuf);
186 g_free(phd->pane.id);
185 187
186 g_free(phd); 188 g_free(phd);
187 } 189 }
188 190
189 static void bar_pane_histogram_popup_channels_cb(GtkWidget *widget, gpointer data) 191 static void bar_pane_histogram_popup_channels_cb(GtkWidget *widget, gpointer data)
324 326
325 return FALSE; 327 return FALSE;
326 } 328 }
327 329
328 330
329 GtkWidget *bar_pane_histogram_new(const gchar *title, gint height, gboolean expanded, gint histogram_channel, gint histogram_mode) 331 GtkWidget *bar_pane_histogram_new(const gchar *id, const gchar *title, gint height, gboolean expanded, gint histogram_channel, gint histogram_mode)
330 { 332 {
331 PaneHistogramData *phd; 333 PaneHistogramData *phd;
332 334
333 phd = g_new0(PaneHistogramData, 1); 335 phd = g_new0(PaneHistogramData, 1);
334 336
335 phd->pane.pane_set_fd = bar_pane_histogram_set_fd; 337 phd->pane.pane_set_fd = bar_pane_histogram_set_fd;
336 phd->pane.pane_write_config = bar_pane_histogram_write_config; 338 phd->pane.pane_write_config = bar_pane_histogram_write_config;
337 phd->pane.title = bar_pane_expander_title(title); 339 phd->pane.title = bar_pane_expander_title(title);
340 phd->pane.id = g_strdup(id);
341 phd->pane.type = PANE_HISTOGRAM;
338 342
339 phd->pane.expanded = expanded; 343 phd->pane.expanded = expanded;
340 phd->idle_id = -1; 344 phd->idle_id = -1;
341 345
342 phd->histogram = histogram_new(); 346 phd->histogram = histogram_new();
374 } 378 }
375 379
376 GtkWidget *bar_pane_histogram_new_from_config(const gchar **attribute_names, const gchar **attribute_values) 380 GtkWidget *bar_pane_histogram_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
377 { 381 {
378 gchar *title = g_strdup(_("NoName")); 382 gchar *title = g_strdup(_("NoName"));
383 gchar *id = g_strdup("histogram");
379 gboolean expanded = TRUE; 384 gboolean expanded = TRUE;
380 gint height = 80; 385 gint height = 80;
381 gint histogram_channel = HCHAN_RGB; 386 gint histogram_channel = HCHAN_RGB;
382 gint histogram_mode = 0; 387 gint histogram_mode = 0;
388 GtkWidget *ret;
383 389
384 while (*attribute_names) 390 while (*attribute_names)
385 { 391 {
386 const gchar *option = *attribute_names++; 392 const gchar *option = *attribute_names++;
387 const gchar *value = *attribute_values++; 393 const gchar *value = *attribute_values++;
388 394
389 if (READ_CHAR_FULL("pane.title", title)) continue; 395 if (READ_CHAR_FULL("id", id)) continue;
390 if (READ_BOOL_FULL("pane.expanded", expanded)) continue; 396 if (READ_CHAR_FULL("title", title)) continue;
397 if (READ_BOOL_FULL("expanded", expanded)) continue;
391 if (READ_INT_FULL("histogram_channel", histogram_channel)) continue; 398 if (READ_INT_FULL("histogram_channel", histogram_channel)) continue;
392 if (READ_INT_FULL("histogram_mode", histogram_mode)) continue; 399 if (READ_INT_FULL("histogram_mode", histogram_mode)) continue;
393 400
394 log_printf("unknown attribute %s = %s\n", option, value); 401 log_printf("unknown attribute %s = %s\n", option, value);
395 } 402 }
396 403
397 return bar_pane_histogram_new(title, height, expanded, histogram_channel, histogram_mode); 404 ret = bar_pane_histogram_new(id, title, height, expanded, histogram_channel, histogram_mode);
398 } 405 g_free(title);
406 g_free(id);
407 return ret;
408 }
409
410 void bar_pane_histogram_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
411 {
412 PaneHistogramData *phd;
413
414 phd = g_object_get_data(G_OBJECT(pane), "pane_data");
415 if (!phd) return;
416
417 gint histogram_channel = phd->histogram->histogram_channel;
418 gint histogram_mode = phd->histogram->histogram_mode;
419
420 while (*attribute_names)
421 {
422 const gchar *option = *attribute_names++;
423 const gchar *value = *attribute_values++;
424
425 if (READ_CHAR_FULL("id", phd->pane.id)) continue;
426 // if (READ_CHAR_FULL("pane.title", title)) continue;
427 if (READ_BOOL_FULL("expanded", phd->pane.expanded)) continue;
428 if (READ_INT_FULL("histogram_channel", histogram_channel)) continue;
429 if (READ_INT_FULL("histogram_mode", histogram_mode)) continue;
430
431
432 log_printf("unknown attribute %s = %s\n", option, value);
433 }
434
435 histogram_set_channel(phd->histogram, histogram_channel);
436 histogram_set_mode(phd->histogram, histogram_mode);
437
438 bar_update_expander(pane);
439 bar_pane_histogram_update(phd);
440 }
441
399 442
400 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ 443 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */