display the name of chip in sensor preferences.
authorJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 12 Sep 2012 07:46:54 +0000 (07:46 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 12 Sep 2012 07:46:54 +0000 (07:46 +0000)
moved the sensor id into a expendable frame of the sensor

12 files changed:
NEWS
src/glade/sensor-edit.glade
src/lib/amd.c
src/lib/cpu.c
src/lib/hdd_atasmart.c
src/lib/hdd_hddtemp.c
src/lib/lmsensor.c
src/lib/nvidia.c
src/lib/psensor.c
src/lib/psensor.h
src/lib/psensor_json.c
src/ui_sensorpref.c

diff --git a/NEWS b/NEWS
index 4581b06..c228de6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@
 ** psensor: added an option to enable logging of sensors
    ($HOME/.psensor/sensors.log).
 ** psensor-server: added sensors logging (--sensor-log-file).
+** psensor: display the name of chip in sensor preferences.
+** psensor: moved the sensor id into a expendable frame of the sensor
+   preferences.
 
 * v0.7.0.3
 
index 8141919..1b3ec37 100644 (file)
               <object class="GtkTable" id="table1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="n_rows">13</property>
+                <property name="n_rows">15</property>
                 <property name="n_columns">2</property>
                 <child>
-                  <object class="GtkLabel" id="sensor_id">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">N/A</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="x_padding">4</property>
-                    <property name="y_padding">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label3">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="xpad">10</property>
-                    <property name="label" translatable="yes">Name:</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="x_padding">4</property>
-                    <property name="y_padding">4</property>
-                  </packing>
-                </child>
-                <child>
                   <object class="GtkEntry" id="sensor_name">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
                     <property name="x_padding">4</property>
                     <property name="y_padding">4</property>
                   </packing>
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="xalign">0</property>
+                    <property name="yalign">0.49000000953674316</property>
                     <property name="label" translatable="yes">Type:</property>
+                    <property name="justify">fill</property>
                   </object>
                   <packing>
                     <property name="top_attach">2</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="label2">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Id:</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="x_padding">14</property>
-                    <property name="y_padding">4</property>
-                  </packing>
-                </child>
-                <child>
                   <object class="GtkLabel" id="label5">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                   </object>
                   <packing>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
+                    <property name="top_attach">6</property>
+                    <property name="bottom_attach">7</property>
                     <property name="x_padding">4</property>
                     <property name="y_padding">4</property>
                   </packing>
                     <property name="label" translatable="yes">Color:</property>
                   </object>
                   <packing>
-                    <property name="top_attach">6</property>
-                    <property name="bottom_attach">7</property>
+                    <property name="top_attach">8</property>
+                    <property name="bottom_attach">9</property>
                     <property name="x_padding">14</property>
                     <property name="y_padding">4</property>
                   </packing>
                   </object>
                   <packing>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">7</property>
-                    <property name="bottom_attach">8</property>
+                    <property name="top_attach">9</property>
+                    <property name="bottom_attach">10</property>
                     <property name="x_padding">4</property>
                     <property name="y_padding">4</property>
                   </packing>
                   </object>
                   <packing>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">8</property>
-                    <property name="bottom_attach">9</property>
+                    <property name="top_attach">10</property>
+                    <property name="bottom_attach">11</property>
                     <property name="x_padding">14</property>
                     <property name="y_padding">4</property>
                   </packing>
                   </object>
                   <packing>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">5</property>
-                    <property name="bottom_attach">6</property>
+                    <property name="top_attach">7</property>
+                    <property name="bottom_attach">8</property>
                     <property name="x_padding">14</property>
                     <property name="y_padding">4</property>
                   </packing>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">9</property>
-                    <property name="bottom_attach">10</property>
+                    <property name="top_attach">11</property>
+                    <property name="bottom_attach">12</property>
                   </packing>
                 </child>
                 <child>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">6</property>
-                    <property name="bottom_attach">7</property>
+                    <property name="top_attach">8</property>
+                    <property name="bottom_attach">9</property>
                     <property name="x_options"></property>
                     <property name="x_padding">4</property>
                     <property name="y_padding">4</property>
                     <property name="label" translatable="yes">High threshold:</property>
                   </object>
                   <packing>
-                    <property name="top_attach">9</property>
-                    <property name="bottom_attach">10</property>
+                    <property name="top_attach">11</property>
+                    <property name="bottom_attach">12</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_padding">14</property>
                     <property name="y_padding">4</property>
                     <property name="label" translatable="yes">Low threshold:</property>
                   </object>
                   <packing>
-                    <property name="top_attach">10</property>
-                    <property name="bottom_attach">11</property>
+                    <property name="top_attach">12</property>
+                    <property name="bottom_attach">13</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_padding">14</property>
                     <property name="y_padding">4</property>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">10</property>
-                    <property name="bottom_attach">11</property>
+                    <property name="top_attach">12</property>
+                    <property name="bottom_attach">13</property>
                   </packing>
                 </child>
                 <child>
                   </object>
                   <packing>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">11</property>
-                    <property name="bottom_attach">12</property>
+                    <property name="top_attach">13</property>
+                    <property name="bottom_attach">14</property>
                     <property name="x_padding">4</property>
                     <property name="y_padding">4</property>
                   </packing>
                   </object>
                   <packing>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">12</property>
-                    <property name="bottom_attach">13</property>
+                    <property name="top_attach">14</property>
+                    <property name="bottom_attach">15</property>
+                    <property name="x_padding">14</property>
+                    <property name="y_padding">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="chip_name_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Chip:</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                    <property name="x_options">GTK_FILL</property>
                     <property name="x_padding">14</property>
                     <property name="y_padding">4</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkLabel" id="chip_name">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">N/A</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                    <property name="x_padding">4</property>
+                    <property name="y_padding">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkExpander" id="expander1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <child>
+                      <object class="GtkGrid" id="grid1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">4</property>
+                        <property name="margin_right">4</property>
+                        <property name="margin_top">4</property>
+                        <property name="margin_bottom">4</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <child>
+                          <object class="GtkLabel" id="label2">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Id:</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">0</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="sensor_id">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_left">4</property>
+                            <property name="margin_right">4</property>
+                            <property name="margin_top">4</property>
+                            <property name="margin_bottom">4</property>
+                            <property name="hexpand">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">N/A</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">0</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="details_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Details</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">5</property>
+                    <property name="bottom_attach">6</property>
+                    <property name="x_padding">14</property>
+                    <property name="y_padding">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="xpad">10</property>
+                    <property name="label" translatable="yes">Name:</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="x_padding">4</property>
+                    <property name="y_padding">4</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="resize">True</property>
index 6b7f59d..7d77da5 100644 (file)
@@ -121,7 +121,7 @@ static struct psensor *create_sensor(int id, int values_len)
        sid = malloc(strlen("amd") + 1 + strlen(name) + 1);
        sprintf(sid, "amd %s", name);
 
-       s = psensor_create(sid, strdup(name),
+       s = psensor_create(sid, strdup(name), strdup("ATI GPU"),
                           sensor_type, values_len);
 
        s->amd_id = active_amd_adapters[id];
index 66c6df9..9d28ab0 100644 (file)
@@ -41,7 +41,7 @@ struct psensor *create_cpu_usage_sensor(int measures_len)
        label = strdup("cpu usage");
        type = SENSOR_TYPE_CPU_USAGE;
 
-       psensor = psensor_create(id, label, type, measures_len);
+       psensor = psensor_create(id, label, strdup("CPU"), type, measures_len);
 
        return psensor;
 }
index 3943fa3..ae94a17 100644 (file)
@@ -47,6 +47,7 @@ create_sensor(char *id, char *name, SkDisk *disk, int values_max_length)
        struct psensor *s;
        s = psensor_create(id,
                           strdup(name),
+                          strdup("HDD"),
                           SENSOR_TYPE_HDD_TEMP_ATASMART,
                           values_max_length);
 
index 1013c59..3358b9c 100644 (file)
@@ -115,7 +115,8 @@ static int str_index(char *str, char d)
 static struct psensor *
 create_sensor(char *id, char *name, int values_max_length)
 {
-       return psensor_create(id, name, SENSOR_TYPE_HDD_TEMP_HDDTEMP,
+       return psensor_create(id, name, strdup("HDD"),
+                             SENSOR_TYPE_HDD_TEMP_HDDTEMP,
                              values_max_length);
 }
 
index 6264aac..f12955c 100644 (file)
@@ -104,9 +104,8 @@ lmsensor_psensor_create(const sensors_chip_name *chip,
 {
        char name[200];
        const sensors_subfeature *sf;
-       char *label;
        int type;
-       char *id;
+       char *id, *label, *cname;
        struct psensor *psensor;
        sensors_subfeature_type fault_subfeature;
 
@@ -145,7 +144,16 @@ lmsensor_psensor_create(const sensors_chip_name *chip,
                    1);
        sprintf(id, "lmsensor %s %s", name, label);
 
-       psensor = psensor_create(id, label, type, values_max_length);
+       if (!strcmp(chip->prefix, "coretemp"))
+               cname = strdup("Intel CPU");
+       else if (!strcmp(chip->prefix, "k10temp"))
+               cname = strdup("AMD CPU");
+       else if (!strcmp(chip->prefix, "nouveau"))
+               cname = strdup("Nvidia GPU");
+       else
+               cname = strdup(chip->prefix);
+
+       psensor = psensor_create(id, label, cname, type, values_max_length);
 
        psensor->iname = chip;
        psensor->feature = feature;
index cface2f..5b2bdea 100644 (file)
@@ -68,6 +68,7 @@ static struct psensor *create_sensor(int id, int values_len)
 
        s = psensor_create(sid,
                           strdup(name),
+                          strdup("Nvidia GPU"),
                           SENSOR_TYPE_NVIDIA_TEMP,
                           values_len);
 
index abacd9f..c399544 100644 (file)
 #endif
 
 
-struct psensor *psensor_create(char *id, char *name,
-                              unsigned int type, int values_max_length)
+struct psensor *psensor_create(char *id,
+                              char *name,
+                              char *chip,
+                              unsigned int type,
+                              int values_max_length)
 {
        struct psensor *psensor
            = (struct psensor *)malloc(sizeof(struct psensor));
 
        psensor->id = id;
        psensor->name = name;
+       psensor->chip = chip;
        psensor->enabled = 1;
        psensor->min = UNKNOWN_DBL_VALUE;
        psensor->max = UNKNOWN_DBL_VALUE;
@@ -96,6 +100,9 @@ void psensor_free(struct psensor *sensor)
                free(sensor->name);
                free(sensor->id);
 
+               if (sensor->chip)
+                       free(sensor->chip);
+
                if (sensor->color)
                        free(sensor->color);
 
index 012bd12..dfc7629 100644 (file)
@@ -59,6 +59,9 @@ struct psensor {
        /* Uniq id of the sensor */
        char *id;
 
+       /* Name of the chip. */
+       char *chip;
+
        /* lm-sensor */
        const sensors_chip_name *iname;
        const sensors_feature *feature;
@@ -115,7 +118,9 @@ struct psensor {
 };
 
 struct psensor *psensor_create(char *id,
-                              char *name, unsigned int type,
+                              char *name,
+                              char *chip,
+                              unsigned int type,
                               int values_max_length);
 
 void psensor_values_resize(struct psensor *s, int new_size);
index 18058bf..0ef0cff 100644 (file)
@@ -150,6 +150,7 @@ struct psensor *psensor_new_from_json(json_object *o,
 
        s = psensor_create(strdup(url),
                           strdup(json_object_get_string(oname)),
+                          NULL,
                           json_object_get_int(otype) | SENSOR_TYPE_REMOTE,
                           values_max_length);
        s->url = url;
index a015c5e..2135769 100644 (file)
@@ -291,7 +291,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 +310,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);