X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_sensorpref.c;h=91f24e3a2ec62bb1b8695612ab566a7778ebf67b;hb=de58b641143d1fb9622fa4021c2dd1ab50149dee;hp=2135769c15a93008e60d8b6df5971d5216ea5ff8;hpb=b01d095d6b123bcc7ed221cccf2c04295834cc84;p=psensor.git diff --git a/src/ui_sensorpref.c b/src/ui_sensorpref.c index 2135769..91f24e3 100644 --- a/src/ui_sensorpref.c +++ b/src/ui_sensorpref.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2012 jeanfi@gmail.com + * Copyright (C) 2010-2014 jeanfi@gmail.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -20,35 +20,39 @@ #include -#include "cfg.h" -#include "ui_pref.h" -#include "ui_sensorlist.h" -#include "ui_sensorpref.h" -#include "ui_color.h" - -#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029) -#include "ui_appindicator.h" -#endif +#include +#include +#include +#include +#include +#include +#include + +enum { + COL_NAME = 0, + COL_SENSOR_PREF +}; struct sensor_pref { struct psensor *sensor; char *name; - int enabled; - struct color *color; + int graph_enabled; + GdkRGBA *color; int alarm_enabled; int alarm_high_threshold; int alarm_low_threshold; - unsigned int appindicator_enabled; + bool appindicator_enabled; + unsigned int appindicator_label_enabled; + unsigned int display_enabled; }; struct cb_data { struct ui_psensor *ui; GtkBuilder *builder; - struct sensor_pref **prefs; }; -static struct sensor_pref *sensor_pref_new(struct psensor *s, - struct config *cfg) +static struct sensor_pref * +sensor_pref_new(struct psensor *s, struct config *cfg) { struct sensor_pref *p; @@ -56,21 +60,24 @@ static struct sensor_pref *sensor_pref_new(struct psensor *s, p->sensor = s; p->name = strdup(s->name); - p->enabled = s->enabled; - p->alarm_enabled = s->alarm_enabled; - p->color = color_dup(s->color); + p->graph_enabled = config_is_sensor_graph_enabled(s->id); + p->alarm_enabled = config_get_sensor_alarm_enabled(s->id); + p->color = config_get_sensor_color(s->id); + p->display_enabled = config_is_sensor_enabled(s->id); - if (cfg->temperature_unit == CELCIUS) { + if (cfg->temperature_unit == CELSIUS) { p->alarm_high_threshold = s->alarm_high_threshold; p->alarm_low_threshold = s->alarm_low_threshold; } else { p->alarm_high_threshold - = celcius_to_fahrenheit(s->alarm_high_threshold); + = celsius_to_fahrenheit(s->alarm_high_threshold); p->alarm_low_threshold - = celcius_to_fahrenheit(s->alarm_low_threshold); + = celsius_to_fahrenheit(s->alarm_low_threshold); } - p->appindicator_enabled = s->appindicator_enabled; + p->appindicator_enabled = config_is_appindicator_enabled(s->id); + p->appindicator_label_enabled + = config_is_appindicator_label_enabled(s->id); return p; } @@ -78,97 +85,38 @@ static struct sensor_pref *sensor_pref_new(struct psensor *s, static void sensor_pref_free(struct sensor_pref *p) { if (!p) - return ; + return; free(p->name); - free(p->color); + gdk_rgba_free(p->color); free(p); } -static struct sensor_pref **sensor_pref_list_new(struct psensor **sensors, - struct config *cfg) -{ - int n, i; - struct sensor_pref **pref_list; - - n = psensor_list_size(sensors); - pref_list = malloc(sizeof(struct sensor_pref *) * (n+1)); - - for (i = 0; i < n; i++) - pref_list[i] = sensor_pref_new(sensors[i], - cfg); - - pref_list[n] = NULL; - - return pref_list; -} - -static void sensor_pref_list_free(struct sensor_pref **list) -{ - struct sensor_pref **cur = list; - - while (*cur) { - sensor_pref_free(*cur); - - cur++; - } - - free(list); -} - -static struct sensor_pref * -sensor_pref_get(struct sensor_pref **ps, struct psensor *s) -{ - struct sensor_pref **p_cur = ps; - - while (*p_cur) { - struct sensor_pref *p = *p_cur; - - if (p->sensor == s) - return p; - - p_cur++; - } - - return NULL; -} - -static struct sensor_pref * -get_selected_sensor_pref(GtkBuilder *builder, struct sensor_pref **ps) +static struct sensor_pref *get_selected_sensor_pref(GtkTreeView *tree) { GtkTreeModel *model; GtkTreeIter iter; - struct sensor_pref *pref = NULL; + struct sensor_pref *pref; GtkTreeSelection *selection; - GtkTreeView *tree; - - tree = GTK_TREE_VIEW(gtk_builder_get_object(builder, - "sensors_list")); selection = gtk_tree_view_get_selection(tree); - if (gtk_tree_selection_get_selected(selection, &model, &iter)) { - GtkTreePath *p = gtk_tree_model_get_path(model, &iter); - gint *indices = gtk_tree_path_get_indices(p); - - pref = ps[*indices]; - - gtk_tree_path_free(p); - } + pref = NULL; + if (gtk_tree_selection_get_selected(selection, &model, &iter)) + gtk_tree_model_get(model, &iter, COL_SENSOR_PREF, &pref, -1); return pref; } -static void on_name_changed(GtkEntry *entry, gpointer data) +void ui_sensorpref_name_changed_cb(GtkEntry *entry, gpointer data) { - struct cb_data *cbdata = data; struct sensor_pref *p; const char *str; str = gtk_entry_get_text(entry); - p = get_selected_sensor_pref(cbdata->builder, cbdata->prefs); + p = get_selected_sensor_pref(GTK_TREE_VIEW(data)); if (p && strcmp(p->name, str)) { free(p->name); @@ -176,130 +124,105 @@ static void on_name_changed(GtkEntry *entry, gpointer data) } } -static void -on_drawed_toggled(GtkToggleButton *btn, gpointer data) +void ui_sensorpref_draw_toggled_cb(GtkToggleButton *btn, gpointer data) { - struct cb_data *cbdata = data; struct sensor_pref *p; - p = get_selected_sensor_pref(cbdata->builder, cbdata->prefs); + p = get_selected_sensor_pref(GTK_TREE_VIEW(data)); if (p) - p->enabled = gtk_toggle_button_get_active(btn); + p->graph_enabled = gtk_toggle_button_get_active(btn); } -static void -on_alarm_toggled(GtkToggleButton *btn, gpointer data) +void ui_sensorpref_display_toggled_cb(GtkToggleButton *btn, gpointer data) +{ + struct sensor_pref *p; + + p = get_selected_sensor_pref(GTK_TREE_VIEW(data)); + + if (p) + p->display_enabled = gtk_toggle_button_get_active(btn); +} + +void ui_sensorpref_alarm_toggled_cb(GtkToggleButton *btn, gpointer data) { - struct cb_data *cbdata = data; struct sensor_pref *p; - p = get_selected_sensor_pref(cbdata->builder, cbdata->prefs); + p = get_selected_sensor_pref(GTK_TREE_VIEW(data)); if (p) p->alarm_enabled = gtk_toggle_button_get_active(btn); } -static void -on_appindicator_toggled(GtkToggleButton *btn, gpointer data) +void +ui_sensorpref_appindicator_menu_toggled_cb(GtkToggleButton *btn, gpointer data) { - struct cb_data *cbdata = data; struct sensor_pref *p; - p = get_selected_sensor_pref(cbdata->builder, cbdata->prefs); + p = get_selected_sensor_pref(GTK_TREE_VIEW(data)); if (p) p->appindicator_enabled = gtk_toggle_button_get_active(btn); } -static void on_color_set(GtkColorButton *widget, gpointer data) +void +ui_sensorpref_appindicator_label_toggled_cb(GtkToggleButton *btn, gpointer data) { - struct cb_data *cbdata = data; struct sensor_pref *p; - GdkColor color; - p = get_selected_sensor_pref(cbdata->builder, cbdata->prefs); + p = get_selected_sensor_pref(GTK_TREE_VIEW(data)); - if (p) { - gtk_color_button_get_color(widget, &color); - color_set(p->color, color.red, color.green, color.blue); - } + if (p) + p->appindicator_label_enabled + = gtk_toggle_button_get_active(btn); } -static void on_alarm_high_threshold_changed(GtkSpinButton *btn, gpointer data) +void ui_sensorpref_color_set_cb(GtkColorButton *widget, gpointer data) { - struct cb_data *cbdata; struct sensor_pref *p; - cbdata = data; - - p = get_selected_sensor_pref(cbdata->builder, cbdata->prefs); + p = get_selected_sensor_pref(GTK_TREE_VIEW(data)); if (p) - p->alarm_high_threshold = gtk_spin_button_get_value(btn); + gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(widget), p->color); } -static void on_alarm_low_threshold_changed(GtkSpinButton *btn, gpointer data) +void +ui_sensorpref_alarm_high_threshold_changed_cb(GtkSpinButton *btn, gpointer data) { - struct cb_data *cbdata; struct sensor_pref *p; - cbdata = data; - - p = get_selected_sensor_pref(cbdata->builder, cbdata->prefs); + p = get_selected_sensor_pref(GTK_TREE_VIEW(data)); if (p) - p->alarm_low_threshold = gtk_spin_button_get_value(btn); + p->alarm_high_threshold = gtk_spin_button_get_value(btn); } -static void connect_signals(GtkBuilder *builder, struct cb_data *cbdata) +void +ui_sensorpref_alarm_low_threshold_changed_cb(GtkSpinButton *btn, gpointer data) { - g_signal_connect(gtk_builder_get_object(builder, "sensor_name"), - "changed", G_CALLBACK(on_name_changed), cbdata); - - g_signal_connect(gtk_builder_get_object(builder, "sensor_draw"), - "toggled", G_CALLBACK(on_drawed_toggled), cbdata); - - g_signal_connect(gtk_builder_get_object(builder, "sensor_color"), - "color-set", G_CALLBACK(on_color_set), cbdata); - - g_signal_connect(gtk_builder_get_object(builder, "sensor_alarm"), - "toggled", G_CALLBACK(on_alarm_toggled), cbdata); - - g_signal_connect(gtk_builder_get_object(builder, - "sensor_alarm_high_threshold"), - "value-changed", - G_CALLBACK(on_alarm_high_threshold_changed), - cbdata); - - g_signal_connect(gtk_builder_get_object(builder, - "sensor_alarm_low_threshold"), - "value-changed", - G_CALLBACK(on_alarm_low_threshold_changed), - cbdata); - - g_signal_connect(gtk_builder_get_object(builder, - "indicator_checkbox"), - "toggled", - G_CALLBACK(on_appindicator_toggled), - cbdata); + struct sensor_pref *p; + + p = get_selected_sensor_pref(GTK_TREE_VIEW(data)); + + if (p) + p->alarm_low_threshold = gtk_spin_button_get_value(btn); } static void -update_pref(struct psensor *s, - struct sensor_pref **prefs, - struct config *cfg, - GtkBuilder *builder) +update_pref(struct sensor_pref *p, struct config *cfg, GtkBuilder *builder) { GtkLabel *w_id, *w_type, *w_high_threshold_unit, *w_low_threshold_unit, *w_chipname; GtkEntry *w_name; - GtkToggleButton *w_draw, *w_alarm, *w_appindicator_enabled; + GtkToggleButton *w_draw, *w_alarm, *w_appindicator_enabled, + *w_appindicator_label_enabled, *w_display; GtkColorButton *w_color; GtkSpinButton *w_high_threshold, *w_low_threshold; - GdkColor *color; - struct sensor_pref *p = sensor_pref_get(prefs, s); - int use_celcius; + struct psensor *s; + int use_celsius; + + s = p->sensor; w_id = GTK_LABEL(gtk_builder_get_object(builder, "sensor_id")); gtk_label_set_text(w_id, s->id); @@ -318,12 +241,16 @@ update_pref(struct psensor *s, w_draw = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "sensor_draw")); - gtk_toggle_button_set_active(w_draw, p->enabled); + gtk_toggle_button_set_active(w_draw, p->graph_enabled); + + w_display = GTK_TOGGLE_BUTTON(gtk_builder_get_object + (builder, + "sensor_enable_checkbox")); + gtk_toggle_button_set_active(w_display, p->display_enabled); - color = color_to_gdkcolor(p->color); w_color = GTK_COLOR_BUTTON(gtk_builder_get_object(builder, "sensor_color")); - gtk_color_button_set_color(w_color, color); + gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(w_color), p->color); w_alarm = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "sensor_alarm")); @@ -341,164 +268,168 @@ update_pref(struct psensor *s, (builder, "sensor_alarm_low_threshold_unit")); - use_celcius = cfg->temperature_unit == CELCIUS ? 1 : 0; + use_celsius = cfg->temperature_unit == CELSIUS ? 1 : 0; gtk_label_set_text(w_high_threshold_unit, psensor_type_to_unit_str(s->type, - use_celcius)); + use_celsius)); gtk_label_set_text(w_low_threshold_unit, psensor_type_to_unit_str(s->type, - use_celcius)); + use_celsius)); w_appindicator_enabled = GTK_TOGGLE_BUTTON (gtk_builder_get_object(builder, "indicator_checkbox")); + w_appindicator_label_enabled = GTK_TOGGLE_BUTTON + (gtk_builder_get_object(builder, "indicator_label_checkbox")); - if (is_temp_type(s->type) || is_fan_type(s->type)) { - gtk_toggle_button_set_active(w_alarm, p->alarm_enabled); - gtk_spin_button_set_value(w_high_threshold, - p->alarm_high_threshold); - gtk_spin_button_set_value(w_low_threshold, - p->alarm_low_threshold); - gtk_widget_set_sensitive(GTK_WIDGET(w_alarm), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(w_high_threshold), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(w_low_threshold), TRUE); + + if (is_appindicator_supported()) { + gtk_widget_set_has_tooltip + (GTK_WIDGET(w_appindicator_label_enabled), FALSE); + gtk_widget_set_has_tooltip + (GTK_WIDGET(w_appindicator_enabled), FALSE); } else { - gtk_toggle_button_set_active(w_alarm, 0); - gtk_spin_button_set_value(w_high_threshold, 0); - gtk_spin_button_set_value(w_low_threshold, 0); - gtk_widget_set_sensitive(GTK_WIDGET(w_alarm), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(w_high_threshold), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(w_low_threshold), FALSE); + gtk_widget_set_sensitive + (GTK_WIDGET(w_appindicator_label_enabled), FALSE); + gtk_widget_set_has_tooltip + (GTK_WIDGET(w_appindicator_label_enabled), TRUE); + gtk_widget_set_sensitive + (GTK_WIDGET(w_appindicator_enabled), FALSE); + gtk_widget_set_has_tooltip + (GTK_WIDGET(w_appindicator_enabled), TRUE); } + gtk_toggle_button_set_active(w_alarm, p->alarm_enabled); + gtk_spin_button_set_value(w_high_threshold, p->alarm_high_threshold); + gtk_spin_button_set_value(w_low_threshold, p->alarm_low_threshold); + gtk_widget_set_sensitive(GTK_WIDGET(w_alarm), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(w_high_threshold), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(w_low_threshold), TRUE); + gtk_toggle_button_set_active(w_appindicator_enabled, p->appindicator_enabled); + gtk_toggle_button_set_active(w_appindicator_label_enabled, + p->appindicator_label_enabled); } static void on_changed(GtkTreeSelection *selection, gpointer data) { - GtkTreeModel *model; - GtkTreeIter iter; struct cb_data *cbdata = data; struct ui_psensor *ui = cbdata->ui; + struct sensor_pref *p; + GtkTreeView *tree; - if (gtk_tree_selection_get_selected(selection, &model, &iter)) { - GtkTreePath *p = gtk_tree_model_get_path(model, &iter); - gint *indices = gtk_tree_path_get_indices(p); - struct psensor *s = *(ui->sensors + *indices); - - update_pref(s, - cbdata->prefs, - ui->config, - cbdata->builder); - - gtk_tree_path_free(p); - } + tree = GTK_TREE_VIEW(gtk_builder_get_object(cbdata->builder, + "sensors_list")); + p = get_selected_sensor_pref(tree); + update_pref(p, ui->config, cbdata->builder); } static void select_sensor(struct psensor *s, struct psensor **sensors, GtkTreeView *tree) { - struct psensor **s_cur = sensors; - int i = 0; - GtkTreePath *p = NULL; + struct psensor **s_cur; + int i; + GtkTreePath *p; + GtkTreeSelection *sel; - while (*s_cur) { + p = NULL; + for (s_cur = sensors, i = 0; *s_cur; s_cur++, i++) if (s == *s_cur) { p = gtk_tree_path_new_from_indices(i, -1); break; } - i++; - s_cur++; - } - if (p) { - GtkTreeSelection *s = gtk_tree_view_get_selection(tree); + sel = gtk_tree_view_get_selection(tree); - gtk_tree_selection_select_path(s, p); + gtk_tree_selection_select_path(sel, p); gtk_tree_path_free(p); } } -static void -apply_prefs(struct sensor_pref **prefs, - struct psensor **sensors, - struct config *cfg) +static void apply_pref(struct sensor_pref *p, int pos, struct config *cfg) { - int n = psensor_list_size(sensors); - int i; + struct psensor *s; - for (i = 0; i < n; i++) { - struct psensor *s = sensors[i]; - struct sensor_pref *p = prefs[i]; + s = p->sensor; - if (strcmp(p->name, s->name)) { - free(s->name); - s->name = strdup(p->name); - config_set_sensor_name(s->id, s->name); - } + if (strcmp(p->name, s->name)) { + free(s->name); + s->name = strdup(p->name); + config_set_sensor_name(s->id, s->name); + } - if (s->enabled != p->enabled) { - s->enabled = p->enabled; - config_set_sensor_enabled(s->id, s->enabled); - } + config_set_sensor_graph_enabled(s->id, p->graph_enabled); - if (is_temp_type(s->type) - && cfg->temperature_unit == FAHRENHEIT) { - s->alarm_high_threshold = fahrenheit_to_celcius - (p->alarm_high_threshold); - s->alarm_low_threshold = fahrenheit_to_celcius - (p->alarm_low_threshold); - } else { - s->alarm_high_threshold = p->alarm_high_threshold; - s->alarm_low_threshold = p->alarm_low_threshold; - } + if (is_temp_type(s->type) && cfg->temperature_unit == FAHRENHEIT) { + s->alarm_high_threshold + = fahrenheit_to_celsius(p->alarm_high_threshold); + s->alarm_low_threshold + = fahrenheit_to_celsius(p->alarm_low_threshold); + } else { + s->alarm_high_threshold = p->alarm_high_threshold; + s->alarm_low_threshold = p->alarm_low_threshold; + } - config_set_sensor_alarm_high_threshold(s->id, - s->alarm_high_threshold); - config_set_sensor_alarm_low_threshold(s->id, - s->alarm_low_threshold); + config_set_sensor_alarm_high_threshold(s->id, s->alarm_high_threshold); + config_set_sensor_alarm_low_threshold(s->id, s->alarm_low_threshold); - if (s->alarm_enabled != p->alarm_enabled) { - s->alarm_enabled = p->alarm_enabled; - config_set_sensor_alarm_enabled(s->id, - s->alarm_enabled); - } + config_set_sensor_alarm_enabled(s->id, p->alarm_enabled); - color_set(s->color, - p->color->red, p->color->green, p->color->blue); - config_set_sensor_color(s->id, s->color); + config_set_sensor_color(s->id, p->color); - if (s->appindicator_enabled != p->appindicator_enabled) { - s->appindicator_enabled = p->appindicator_enabled; - config_set_appindicator_enabled - (s->id, s->appindicator_enabled); - } + config_set_appindicator_enabled(s->id, p->appindicator_enabled); + + config_set_appindicator_label_enabled(s->id, + p->appindicator_label_enabled); + + config_set_sensor_position(s->id, pos); + + config_set_sensor_enabled(s->id, p->display_enabled); +} + +static void apply_prefs(GtkTreeModel *model, struct config *cfg) +{ + gboolean valid; + struct sensor_pref *spref; + GtkTreeIter iter; + int i; + + valid = gtk_tree_model_get_iter_first(model, &iter); + i = 0; + while (valid) { + gtk_tree_model_get(model, &iter, COL_SENSOR_PREF, &spref, -1); + apply_pref(spref, i, cfg); + valid = gtk_tree_model_iter_next(model, &iter); + i++; } + config_sync(); } void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui) { GtkDialog *diag; gint result; + guint ok; GtkBuilder *builder; - GError *error = NULL; + GError *error; GtkTreeView *w_sensors_list; - guint ok; - GtkCellRenderer *renderer; GtkListStore *store; - struct psensor **s_cur; + struct psensor **s_cur, *s, **ordered_sensors; GtkTreeSelection *selection; struct cb_data cbdata; + GtkTreeIter iter; + struct sensor_pref *spref; + gboolean valid; + GtkTreeModel *model; cbdata.ui = ui; - cbdata.prefs = sensor_pref_list_new(ui->sensors, - ui->config); builder = gtk_builder_new(); cbdata.builder = builder; + error = NULL; ok = gtk_builder_add_from_file (builder, PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "sensor-edit.glade", @@ -507,54 +438,59 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui) if (!ok) { log_printf(LOG_ERR, error->message); g_error_free(error); - return ; + return; } - update_pref(sensor, cbdata.prefs, ui->config, builder); - connect_signals(builder, &cbdata); - w_sensors_list = GTK_TREE_VIEW(gtk_builder_get_object(builder, "sensors_list")); + gtk_builder_connect_signals(builder, w_sensors_list); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes(w_sensors_list, - -1, - _("Sensor Name"), - renderer, - "text", 0, NULL); - - store = GTK_LIST_STORE(gtk_tree_view_get_model(w_sensors_list)); - - s_cur = ui->sensors; - while (*s_cur) { - GtkTreeIter iter; - struct psensor *s = *s_cur; + store = GTK_LIST_STORE(gtk_builder_get_object(builder, + "sensors_liststore")); + ordered_sensors = ui_get_sensors_ordered_by_position(ui); + for (s_cur = ordered_sensors; *s_cur; s_cur++) { + s = *s_cur; gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, s->name, -1); - s_cur++; + spref = sensor_pref_new(s, ui->config); + gtk_list_store_set(store, &iter, + COL_NAME, s->name, + COL_SENSOR_PREF, spref, + -1); + + if (s == sensor) + update_pref(spref, ui->config, builder); } selection = gtk_tree_view_get_selection(w_sensors_list); g_signal_connect(selection, "changed", G_CALLBACK(on_changed), &cbdata); - select_sensor(sensor, ui->sensors, w_sensors_list); + select_sensor(sensor, ordered_sensors, w_sensors_list); + + free(ordered_sensors); diag = GTK_DIALOG(gtk_builder_get_object(builder, "dialog1")); result = gtk_dialog_run(diag); + model = gtk_tree_view_get_model(w_sensors_list); + if (result == GTK_RESPONSE_ACCEPT) { - apply_prefs(cbdata.prefs, ui->sensors, ui->config); - ui_sensorlist_update_sensors_preferences(ui); -#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029) + apply_prefs(model, ui->config); + ui_sensorlist_update(ui, 1); +#if defined(HAVE_APPINDICATOR) ui_appindicator_update_menu(ui); #endif } + valid = gtk_tree_model_get_iter_first(model, &iter); + while (valid) { + gtk_tree_model_get(model, &iter, COL_SENSOR_PREF, &spref, -1); + sensor_pref_free(spref); + valid = gtk_tree_model_iter_next(model, &iter); + } + g_object_unref(G_OBJECT(builder)); gtk_widget_destroy(GTK_WIDGET(diag)); - - sensor_pref_list_free(cbdata.prefs); }