defined the tree in the glade file
[psensor.git] / src / ui_sensorpref.c
index a015c5e..9032633 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2012 jeanfi@gmail.com
+ * Copyright (C) 2010-2013 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
 #include "ui_appindicator.h"
 #endif
 
+enum {
+       COL_NAME = 0
+};
+
 struct sensor_pref {
        struct psensor *sensor;
        char *name;
@@ -291,7 +295,8 @@ update_pref(struct psensor *s,
            struct config *cfg,
            GtkBuilder *builder)
 {
-       GtkLabel *w_id, *w_type, *w_high_threshold_unit, *w_low_threshold_unit;
+       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;
        GtkColorButton *w_color;
@@ -309,6 +314,12 @@ update_pref(struct psensor *s,
        w_name = GTK_ENTRY(gtk_builder_get_object(builder, "sensor_name"));
        gtk_entry_set_text(w_name, p->name);
 
+       w_chipname = GTK_LABEL(gtk_builder_get_object(builder, "chip_name"));
+       if (s->chip)
+               gtk_label_set_text(w_chipname, s->chip);
+       else
+               gtk_label_set_text(w_chipname, _("Unknown"));
+
        w_draw = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
                                                          "sensor_draw"));
        gtk_toggle_button_set_active(w_draw, p->enabled);
@@ -479,7 +490,6 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui)
        GError *error = NULL;
        GtkTreeView *w_sensors_list;
        guint ok;
-       GtkCellRenderer *renderer;
        GtkListStore *store;
        struct psensor **s_cur;
        GtkTreeSelection *selection;
@@ -510,14 +520,8 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui)
                = GTK_TREE_VIEW(gtk_builder_get_object(builder,
                                                       "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));
+       store = GTK_LIST_STORE(gtk_builder_get_object(builder,
+                                                     "sensors_liststore"));
 
        s_cur = ui->sensors;
        while (*s_cur) {
@@ -525,7 +529,7 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui)
                struct psensor *s = *s_cur;
 
                gtk_list_store_append(store, &iter);
-               gtk_list_store_set(store, &iter, 0, s->name, -1);
+               gtk_list_store_set(store, &iter, COL_NAME, s->name, -1);
 
                s_cur++;
        }
@@ -539,7 +543,7 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui)
 
        if (result == GTK_RESPONSE_ACCEPT) {
                apply_prefs(cbdata.prefs, ui->sensors, ui->config);
-               ui_sensorlist_update_sensors_preferences(ui);
+               ui_sensorlist_update(ui, 1);
 #if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029)
                ui_appindicator_update_menu(ui);
 #endif