From 2232685fe934caf698000813f6394b4e101c7d6c Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Thu, 22 Feb 2024 00:11:02 +0000 Subject: Deploy mate-desktop/mate-sensors-applet to github.com/mate-desktop/mate-sensors-applet.git:gh-pages --- .../0.html | 1179 ++++++++ .../1.html | 445 +++ .../2.html | 1867 +++++++++++++ .../3.html | 1905 +++++++++++++ .../4.html | 1537 +++++++++++ .../5.html | 2911 ++++++++++++++++++++ .../index.html | 232 ++ .../stats.html | 172 ++ .../style.css | 177 ++ 9 files changed, 10425 insertions(+) create mode 100644 2023-05-07-065914-3846-cppcheck@fc56df38106f_master/0.html create mode 100644 2023-05-07-065914-3846-cppcheck@fc56df38106f_master/1.html create mode 100644 2023-05-07-065914-3846-cppcheck@fc56df38106f_master/2.html create mode 100644 2023-05-07-065914-3846-cppcheck@fc56df38106f_master/3.html create mode 100644 2023-05-07-065914-3846-cppcheck@fc56df38106f_master/4.html create mode 100644 2023-05-07-065914-3846-cppcheck@fc56df38106f_master/5.html create mode 100644 2023-05-07-065914-3846-cppcheck@fc56df38106f_master/index.html create mode 100644 2023-05-07-065914-3846-cppcheck@fc56df38106f_master/stats.html create mode 100644 2023-05-07-065914-3846-cppcheck@fc56df38106f_master/style.css (limited to '2023-05-07-065914-3846-cppcheck@fc56df38106f_master') diff --git a/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/0.html b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/0.html new file mode 100644 index 0000000..0261688 --- /dev/null +++ b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/0.html @@ -0,0 +1,1179 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SENSORS_SENSORS_H
+#include <sensors/sensors.h>
+#endif
+
+#include "libsensors-plugin.h"
+
+const gchar *plugin_name = "libsensors";
+
+GHashTable *hash_table = NULL;
+
+enum {
+    LIBSENSORS_CHIP_PARSE_ERROR,
+    LIBSENSORS_MISSING_FEATURE_ERROR,
+    LIBSENSORS_REGEX_URL_COMPILE_ERROR,
+    LIBSENSORS_CHIP_NOT_FOUND_ERROR
+};
+
+#if SENSORS_API_VERSION < 0x400
+#define LIBSENSORS_CONFIG_FILE "/etc/sensors.conf"
+#define LIBSENSORS_ALTERNATIVE_CONFIG_FILE "/usr/local/etc/sensors.conf"
+#endif
+
+GRegex *uri_re;
+
+static char *get_chip_name_string(const sensors_chip_name *chip) {
+    char *name;
+
+#if SENSORS_API_VERSION < 0x400
+    /* taken from lm-sensors:prog/sensors/main.c:sprintf_chip_name */
+    switch (chip->bus) {
+        case SENSORS_CHIP_NAME_BUS_ISA:
+            name = g_strdup_printf ("%s-isa-%04x", chip->prefix, chip->addr);
+            break;
+        case SENSORS_CHIP_NAME_BUS_DUMMY:
+            name = g_strdup_printf ("%s-%s-%04x", chip->prefix, chip->busname, chip->addr);
+            break;
+            case SENSORS_CHIP_NAME_BUS_PCI:
+                    name = g_strdup_printf ("%s-pci-%04x", chip->prefix, chip->addr);
+                    break;
+        default:
+            name = g_strdup_printf ("%s-i2c-%d-%02x", chip->prefix, chip->bus, chip->addr);
+            break;
+    }
+
+#else
+/* adapted from lm-sensors:prog/sensors/main.c:sprintf_chip_name in lm-sensors-3.0 */
+#define BUF_SIZE 200
+    static char buf[BUF_SIZE];
+    if (sensors_snprintf_chip_name(buf, BUF_SIZE, chip) < 0) {
+        name = NULL;
+    } else {
+        name = g_strdup (buf);
+    }
+#endif
+
+    return name;
+}
+
+#if SENSORS_API_VERSION < 0x400
+static SensorType get_sensor_type (const char *name) {
+    SensorType type = CURRENT_SENSOR;
+
+    if (g_strrstr(name, "in")) {
+        type = VOLTAGE_SENSOR;
+    }
+    else if (g_strrstr(name, "fan")) {
+        type = FAN_SENSOR;
+    }
+    else if (g_strrstr(name, "temp")) {
+        type = TEMP_SENSOR;
+    } else {
+        g_debug("sensor %s not recognised as either voltage, fan or temp sensor - assuming is a current sensor", name);
+        type = CURRENT_SENSOR;
+    }
+    return type;
+}
+
+/* If a sensor is 'interesting' to us then return its label, otherwise NULL. */
+static char *get_sensor_interesting_label (sensors_chip_name chip, int feature) {
+    char *label;
+
+    if (sensors_get_ignored(chip, feature) && (sensors_get_label(chip, feature, &label) == 0)) {
+        if (! (strcmp ("alarms", label) == 0 || strncmp ("sensor", label, 6) == 0)) {
+            return label;
+        } else {
+            free (label);
+        }
+    }
+
+    return NULL;
+}
+
+static const sensors_feature_data * get_sensor_min_max(const sensors_chip_name *chip,
+                                                        int *n1, int *n2,
+                                                        int number,
+                                                        gdouble *low_value,
+                                                        gdouble *high_value) {
+
+    const sensors_feature_data *data;
+    double value;
+
+    /* The sub features are returned directly after the main feature by
+       sensors_get_all_features(), so no need to iterate over all features */
+    while ((data = sensors_get_all_features (*chip, n1, n2)) != NULL && data->mapping == number) {
+        if ((data->mode & SENSORS_MODE_R) && (sensors_get_feature(*chip, data->number, &value) == 0) && data->name != NULL) {
+
+            if (g_str_has_suffix(data->name, "_min")) {
+                *low_value = value;
+                g_debug("overriding low value of sensor %s with value %f", data->name, value);
+            } else if (g_str_has_suffix(data->name, "_max")) {
+                *high_value = value;
+                g_debug("overriding high value of sensor %s with value %f", data->name, value);
+            }
+        }
+    }
+    return data;
+}
+
+#endif
+
+static IconType get_sensor_icon (SensorType type) {
+    switch (type) {
+        case TEMP_SENSOR:
+            return CPU_ICON;
+        case FAN_SENSOR:
+            return FAN_ICON;
+        default:
+            return GENERIC_ICON;
+        }
+}
+
+#if SENSORS_API_VERSION < 0x400
+static void check_sensor_with_data(GList **sensors,
+                                   const char * const chip_name,
+                                   const sensors_chip_name *chip,
+                                   int *n1, int *n2,
+                                   const sensors_feature_data *data) {
+
+    char *label;
+    double value;
+    SensorsAppletSensorInfo *sensor_info = NULL;<--- Variable 'sensor_info' is assigned a value that is never used.
+
+    /* ... some of which are boring ... */
+    if ((label = get_sensor_interesting_label (*chip, data->number))) {
+        /* ... and some of which are actually sensors */
+        if ((data->mode & SENSORS_MODE_R) &&
+            (data->mapping == SENSORS_NO_MAPPING) &&
+            (sensors_get_feature(*chip, data->number, &value) == 0)) {    /* make sure we can actually get a value for it */
+
+            SensorType type;
+            gboolean visible;
+            IconType icon;
+            gdouble low_value, high_value;
+
+            gchar *url;
+
+            type = get_sensor_type (data->name);
+            visible = (type == TEMP_SENSOR ? TRUE : FALSE);
+            icon = get_sensor_icon(type);
+
+            /* the 'path' contains all the information we need to identify this sensor later */
+            url = g_strdup_printf ("sensor://%s/%d", chip_name, data->number);
+
+            /* get low and high values */
+            sensors_applet_plugin_default_sensor_limits(type, &low_value, &high_value);
+
+            data = get_sensor_min_max(chip, n1, n2, data->number, &low_value, &high_value);
+            if (data != NULL) {
+                /* try adding this one */
+                /* at this point we have called sensors_get_all_features() and stopped when we have a potential new sensor, so make sure we try this as well - do a recursive call */
+                check_sensor_with_data(sensors, chip_name, chip, n1, n2, data);
+            }
+
+            g_hash_table_insert(hash_table, g_strdup(url), (void *)chip);
+            /* the id identifies a particular sensor for the user; */
+            /* we default to the label returned by libsensors */
+            sensors_applet_plugin_add_sensor_with_limits(sensors,
+                                                         url,
+                                                         label,
+                                                         label,
+                                                         type,
+                                                         visible,
+                                                         low_value,
+                                                         high_value,
+                                                         icon,
+                                                         DEFAULT_GRAPH_COLOR);
+            g_free(url);
+        }
+        free (label);
+    }
+
+}
+
+#endif
+
+static GList *libsensors_plugin_get_sensors(void) {
+    const sensors_chip_name *chip_name;
+    GList *sensors = NULL;
+
+#if SENSORS_API_VERSION < 0x400
+    FILE *file;
+    int i;
+    g_debug("%s: using libsensors version < 4", __FUNCTION__);
+
+    /* try to open config file, otherwise try alternate config
+     * file - if neither succeed, exit */
+    if ((file = fopen (LIBSENSORS_CONFIG_FILE, "r")) == NULL) {
+        if ((file = fopen (LIBSENSORS_ALTERNATIVE_CONFIG_FILE, "r")) == NULL) {
+            g_debug("%s: error opening libsensors config file... ", __FUNCTION__);
+            return sensors;
+        }
+    }
+
+    /* at this point should have an open config file, if is not
+     * valid, close file and return */
+    if (sensors_init(file) != 0) {
+        fclose(file);
+        g_debug("%s: error initing libsensors from config file...", __FUNCTION__);
+        return sensors;
+    }
+    fclose(file);
+
+    /* libsensors exposes a number of chips -  ... */
+    i = 0;
+    while ((chip_name = sensors_get_detected_chips (&i)) != NULL) {
+        char *chip_name_string;
+        const sensors_feature_data *data;
+        int n1 = 0, n2 = 0;
+
+        chip_name_string = get_chip_name_string(chip_name);
+
+        /* ... each of which has one or more 'features' ... */
+        while ((data = sensors_get_all_features (*chip_name, &n1, &n2)) != NULL) { /* error */
+            /* fill in list for us */
+            check_sensor_with_data(&sensors, chip_name_string, chip_name, &n1, &n2, data);
+        }
+        g_free (chip_name_string);
+    }
+
+#else
+    g_debug("%s: using libsensors version >= 4", __FUNCTION__);
+
+    int nr = 0;
+    if (sensors_init(NULL) != 0) {
+        g_debug("%s: error initing libsensors", __FUNCTION__);
+        return sensors;
+    }
+
+    while ((chip_name = sensors_get_detected_chips(NULL, &nr))) {
+
+        char *chip_name_string, *label;
+        const sensors_subfeature *input_feature;
+        const sensors_subfeature *low_feature;
+        const sensors_subfeature *high_feature;
+        const sensors_feature *main_feature;
+        SensorType type;
+        gint nr1 = 0;
+        gdouble value, low, high;
+        gchar *path;
+        gboolean visible;
+        IconType icon;
+
+        chip_name_string = get_chip_name_string(chip_name);
+        if (chip_name_string == NULL) {
+            g_debug("%s: %d: error getting name string for sensor: %s\n", __FILE__, __LINE__, chip_name->path);
+            continue;
+        }
+
+        while ((main_feature = sensors_get_features(chip_name, &nr1))) {
+            switch (main_feature->type) {
+                case SENSORS_FEATURE_IN:
+                    type = VOLTAGE_SENSOR;
+                    input_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_IN_INPUT);
+                    low_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_IN_MIN);
+                    high_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_IN_MAX);
+                    break;
+
+                case SENSORS_FEATURE_FAN:
+                    type = FAN_SENSOR;
+                    input_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_FAN_INPUT);
+                    low_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_FAN_MIN);
+                    /* no fan max feature */
+                    high_feature = NULL;
+                    break;
+
+                case SENSORS_FEATURE_TEMP:
+                    type = TEMP_SENSOR;
+                    input_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_TEMP_INPUT);
+                    low_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_TEMP_MIN);
+                    high_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_TEMP_MAX);
+                    if (!high_feature)
+                        high_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_TEMP_CRIT);
+                    break;
+
+                default:
+                    g_debug("%s: %d: error determining type for: %s\n", __FILE__, __LINE__, chip_name_string);
+                    continue;
+            }
+
+            if (!input_feature) {
+                g_debug("%s: %d: could not get input subfeature for: %s\n", __FILE__, __LINE__, chip_name_string);
+                continue;
+            }
+
+            /* if still here we got input feature so get label */
+            label = sensors_get_label(chip_name, main_feature);
+            if (!label) {
+                g_debug("%s: %d: error: could not get label for: %s\n", __FILE__, __LINE__, chip_name_string);
+                continue;
+            }
+
+            g_assert(chip_name_string && label);
+
+            icon = get_sensor_icon(type);
+            visible = (type == TEMP_SENSOR ? TRUE : FALSE);
+            sensors_applet_plugin_default_sensor_limits(type, &low, &high);
+            if (low_feature) {
+                sensors_get_value(chip_name, low_feature->number, &low);
+            }
+
+            if (high_feature) {
+                sensors_get_value(chip_name, high_feature->number, &high);
+            }
+
+            if (sensors_get_value(chip_name, input_feature->number, &value) < 0) {
+                g_debug("%s: %d: error: could not get value for input feature of sensor: %s\n", __FILE__, __LINE__, chip_name_string);
+                free(label);
+                continue;
+            }
+
+            g_debug("for chip %s (type %s) got label %s and value %f", chip_name_string,
+                (type == TEMP_SENSOR ? "temp" : (type == FAN_SENSOR ? "fan" : (type == VOLTAGE_SENSOR ? "voltage" : "error"))), label, value);
+
+            path = g_strdup_printf ("sensor://%s/%d", chip_name_string, input_feature->number);
+            g_hash_table_insert(hash_table, g_strdup(path), (void *)chip_name);
+
+            sensors_applet_plugin_add_sensor_with_limits(&sensors,
+                                                         path,
+                                                         label,
+                                                         label,
+                                                         type,
+                                                         visible,
+                                                         low,
+                                                         high,
+                                                         icon,
+                                                         DEFAULT_GRAPH_COLOR);
+        }
+        g_free(chip_name_string);
+
+    }
+#endif
+
+    return sensors;
+}
+
+static gdouble libsensors_plugin_get_sensor_value(const gchar *path,
+                                                    const gchar *id,
+                                                    SensorType type,
+                                                    GError **error) {
+    gdouble result = 0;
+    GMatchInfo *m;
+
+    /* parse the uri into a (chip, feature) tuplet */
+    g_regex_match (uri_re, path, 0, &m);
+    if (g_match_info_matches (m)) {
+        const sensors_chip_name *found_chip;
+        int feature;
+
+        if ((found_chip = g_hash_table_lookup(hash_table, path)) != NULL) {
+            gdouble value;
+            gchar *feature_str;
+
+            feature_str = g_match_info_fetch (m, 1);
+            feature = atoi(feature_str);
+            g_free (feature_str);
+
+#if SENSORS_API_VERSION < 0x400
+            /* retrieve the value of the feature */
+            if (sensors_get_feature (*found_chip, feature, &value) == 0) {
+                result = value;
+            } else {
+                g_set_error (error, SENSORS_APPLET_PLUGIN_ERROR, LIBSENSORS_MISSING_FEATURE_ERROR, "Error retrieving sensor value");
+            }
+#else
+            if (sensors_get_value(found_chip, feature, &value) >= 0) {
+                result = value;
+            } else {
+                g_set_error (error, SENSORS_APPLET_PLUGIN_ERROR, LIBSENSORS_MISSING_FEATURE_ERROR, "Error retrieving sensor value");
+            }
+#endif
+
+        } else {
+            g_set_error (error, SENSORS_APPLET_PLUGIN_ERROR, LIBSENSORS_CHIP_NOT_FOUND_ERROR, "Chip not found");
+        }
+    } else {
+        g_set_error (error, SENSORS_APPLET_PLUGIN_ERROR, LIBSENSORS_REGEX_URL_COMPILE_ERROR, "Error compiling URL regex: Not match");
+    }
+    g_match_info_free (m);
+    return result;
+}
+
+static GList *libsensors_plugin_init(void) {
+    GError *err = NULL;
+
+    /* compile the regular expressions */
+    uri_re = g_regex_new ("^sensor://[a-z0-9_-]+/([0-9]+)$", G_REGEX_CASELESS | G_REGEX_OPTIMIZE, G_REGEX_MATCH_ANCHORED, &err);
+    if (err) {
+        g_debug("Error compiling regexp: %s\nnot initing libsensors sensors interface", err->message);
+        g_error_free (err);
+        return NULL;
+    }
+
+    /* create hash table to associate path strings with sensors_chip_name
+     * pointers - make sure it free's the keys strings on destroy */
+    hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+
+    return libsensors_plugin_get_sensors();
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return libsensors_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return libsensors_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/1.html b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/1.html new file mode 100644 index 0000000..d2bc141 --- /dev/null +++ b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/1.html @@ -0,0 +1,445 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_LIBNOTIFY
+#include <libnotify/notify.h>
+#endif
+
+#include "active-sensor-libnotify.h"
+
+static void notif_closed_cb(NotifyNotification *notification,<--- Parameter 'notification' can be declared as pointer to const
+                            ActiveSensor *active_sensor) {
+
+    g_assert(notification != NULL && active_sensor != NULL);
+
+    int i;
+
+    g_debug("Notification was closed.. setting reference to NULL so we can show again if needed.");
+
+    // set notif reference to NULL
+    for (i = 0; i < NUM_NOTIFS; i++) {
+        if (active_sensor->notification[i] == notification) {
+            active_sensor->notification[i] = NULL;
+            break;
+        }
+    }
+}
+
+void active_sensor_libnotify_notify_end(ActiveSensor *active_sensor,
+                                        NotifType notif_type) {
+
+    GError *error = NULL;
+    if (active_sensor->notification[notif_type]) {
+        g_debug("Closing notification");
+        if(!notify_notification_close(active_sensor->notification[notif_type], &error)) {
+            g_warning("Error closing notification: %s", error->message);
+            g_error_free(error);
+        }
+        g_object_unref(active_sensor->notification[notif_type]);
+        active_sensor->notification[notif_type] = NULL;
+    }
+}
+
+void active_sensor_libnotify_notify(ActiveSensor *active_sensor,
+                                    NotifType notif_type,
+                                    const gchar *summary,
+                                    const gchar *message,
+                                    const gchar *icon_filename,
+                                    gint timeout_msecs) {
+
+    GError *error = NULL;
+
+    if (!notify_is_initted()) {
+        if (!notify_init(PACKAGE)) {
+            return;
+        }
+    }
+    g_debug("Doing notification %s: %s: %s", (notif_type == SENSOR_INTERFACE_ERROR ? "interface-error" : "other") ,summary, message);
+
+    /* leave any existing notification since most likely hasn't changed */
+    if (active_sensor->notification[notif_type] != NULL) {
+        return;
+        /* active_sensor_libnotify_notify_end(active_sensor, notif_type); */
+    }
+
+    /* now create a new one */
+    g_debug("Creating new notification");
+    active_sensor->notification[notif_type] = notify_notification_new(summary, message, icon_filename);
+    g_signal_connect(active_sensor->notification[notif_type], "closed",
+                     G_CALLBACK(notif_closed_cb),
+                     active_sensor);
+
+    notify_notification_set_urgency(active_sensor->notification[notif_type], NOTIFY_URGENCY_CRITICAL);
+
+    /* timeout may have changed so update it */
+    notify_notification_set_timeout(active_sensor->notification[notif_type], timeout_msecs);
+
+    g_debug("showing notification");
+    if (!notify_notification_show(active_sensor->notification[notif_type], &error)) {
+        g_debug("Error showing notification: %s", error->message);
+        g_error_free(error);
+    }
+
+}
+
+
+ +
+ +
+ + diff --git a/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/2.html b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/2.html new file mode 100644 index 0000000..7f9685b --- /dev/null +++ b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/2.html @@ -0,0 +1,1867 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif /* HAVE_STRING_H */
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+
+#include "active-sensor.h"
+#include "sensors-applet-plugins.h"
+#include "sensors-applet-settings.h"
+
+typedef enum {
+    VERY_LOW_SENSOR_VALUE = 0,
+    LOW_SENSOR_VALUE,
+    NORMAL_SENSOR_VALUE,
+    HIGH_SENSOR_VALUE,
+    VERY_HIGH_SENSOR_VALUE
+} SensorValueRange;
+
+/* Cast a given value to a valid SensorValueRange */
+#define SENSOR_VALUE_RANGE(x) ((SensorValueRange)(CLAMP(x, VERY_LOW_SENSOR_VALUE, VERY_HIGH_SENSOR_VALUE)))
+
+#define CAIRO_GRAPH_COLOR_GRADIENT 0.4
+
+static const gchar * const temp_overlay_icons[] = {
+    PIXMAPS_DIR "very-low-temp-icon.png",
+    PIXMAPS_DIR "low-temp-icon.png",
+    PIXMAPS_DIR "normal-temp-icon.png",
+    PIXMAPS_DIR "high-temp-icon.png",
+    PIXMAPS_DIR "very-high-temp-icon.png"
+};
+
+static gdouble sensor_value_range_normalised(gdouble value,
+                                          gdouble low_value,
+                                          gdouble high_value) {
+
+    return ((value - low_value)/(high_value - low_value));
+}
+
+static SensorValueRange sensor_value_range(gdouble sensor_value,
+                                            gdouble low_value,
+                                            gdouble high_value) {
+
+    gdouble range;
+    range = sensor_value_range_normalised(sensor_value, low_value, high_value)*(gdouble)(VERY_HIGH_SENSOR_VALUE);
+
+    /* check if need to round up, otherwise let int conversion
+     * round down for us and make sure it is a valid range
+     * value */
+    return SENSOR_VALUE_RANGE(((gint)range + ((range - ((gint)range)) >= 0.5)));
+}
+
+static gboolean active_sensor_execute_alarm(ActiveSensor *active_sensor,
+                                            NotifType notif_type) {
+
+    gboolean ret;
+    GError *error = NULL;
+
+    sensors_applet_notify_active_sensor(active_sensor, notif_type);
+    g_debug("EXECUTING %s ALARM: %s",
+            (notif_type == LOW_ALARM ?
+             "LOW" : "HIGH"),
+            active_sensor->alarm_command[notif_type]);
+    ret = g_spawn_command_line_async (active_sensor->alarm_command[notif_type], &error);
+    g_debug("Command executed in shell");
+
+    if (error)
+        g_error_free (error);
+
+    return ret;
+}
+
+static gboolean active_sensor_execute_low_alarm(ActiveSensor *active_sensor) {
+    return active_sensor_execute_alarm(active_sensor, LOW_ALARM);
+}
+
+static gboolean active_sensor_execute_high_alarm(ActiveSensor *active_sensor) {
+    return active_sensor_execute_alarm(active_sensor, HIGH_ALARM);
+}
+
+/* needs to be able to be called by the config dialog when the alarm command changes */
+void active_sensor_alarm_off(ActiveSensor *active_sensor,
+                             NotifType notif_type) {
+
+    g_assert(active_sensor);
+
+    if (active_sensor->alarm_timeout_id[notif_type] != -1) {
+        g_debug("Disabling %s alarm.", (notif_type == LOW_ALARM ? "LOW" : "HIGH"));
+        if (!g_source_remove(active_sensor->alarm_timeout_id[notif_type])) {
+            g_debug("Error removing alarm source");
+        }
+        g_free(active_sensor->alarm_command[notif_type]);
+        active_sensor->alarm_timeout_id[notif_type] = -1;
+
+    }
+    sensors_applet_notify_end(active_sensor, notif_type);
+}
+
+static void active_sensor_all_alarms_off(ActiveSensor *active_sensor) {
+    /* turn off any alarms */
+    int i;
+    for (i = 0; i < NUM_ALARMS; i++) {
+        if (active_sensor->alarm_timeout_id[i] >= 0) {
+            g_debug("-- turning off notif with type %d ---", i);
+            active_sensor_alarm_off(active_sensor, i);
+        }
+    }
+}
+
+static void active_sensor_alarm_on(ActiveSensor *active_sensor,
+                                   NotifType notif_type) {
+
+    GtkTreeModel *model;
+    GtkTreePath *tree_path;
+    GtkTreeIter iter;
+
+    g_assert(active_sensor);
+
+    model = gtk_tree_row_reference_get_model(active_sensor->sensor_row);
+    tree_path = gtk_tree_row_reference_get_path(active_sensor->sensor_row);
+
+    if (gtk_tree_model_get_iter(model, &iter, tree_path)) {
+
+        if (active_sensor->alarm_timeout_id[notif_type] == -1) {
+            /* alarm is not currently on */
+            gtk_tree_model_get(model,
+                       &iter,
+                       (notif_type == LOW_ALARM ?
+                            LOW_ALARM_COMMAND_COLUMN :
+                            HIGH_ALARM_COMMAND_COLUMN),
+                       &(active_sensor->alarm_command[notif_type]),
+                       ALARM_TIMEOUT_COLUMN, &(active_sensor->alarm_timeout),
+                       -1);
+
+            g_debug("Activating alarm to repeat every %d seconds", active_sensor->alarm_timeout);
+
+            /* execute alarm once, then add to time to keep repeating it */
+            active_sensor_execute_alarm(active_sensor, notif_type);
+            int timeout = (active_sensor->alarm_timeout <= 0 ? G_MAXINT : active_sensor->alarm_timeout);
+            switch (notif_type) {
+                case LOW_ALARM:
+                    active_sensor->alarm_timeout_id[notif_type] = g_timeout_add_seconds(timeout,
+                                                                                        (GSourceFunc)active_sensor_execute_low_alarm,
+                                                                                        active_sensor);
+                    break;
+
+                case HIGH_ALARM:
+                    active_sensor->alarm_timeout_id[notif_type] = g_timeout_add_seconds(timeout,
+                                                                                        (GSourceFunc)active_sensor_execute_high_alarm,
+                                                                                        active_sensor);
+                    break;
+
+                default:
+                    g_debug("Unknown notif type: %d", notif_type);
+            }
+
+        }
+    }
+
+    gtk_tree_path_free(tree_path);
+}
+
+/**
+ * Compares two ActiveSensors and returns -1 if a comes before b in the tree,
+ * 0 if refer to same row, 1 if b comes before a
+ */
+gint active_sensor_compare(ActiveSensor *a, ActiveSensor *b) {
+    GtkTreePath *a_tree_path, *b_tree_path;
+    gint ret_val;
+
+    g_assert(a);
+    g_assert(b);
+
+    a_tree_path = gtk_tree_row_reference_get_path(a->sensor_row);
+    b_tree_path = gtk_tree_row_reference_get_path(b->sensor_row);
+
+    ret_val = gtk_tree_path_compare(a_tree_path, b_tree_path);
+
+    gtk_tree_path_free(a_tree_path);
+    gtk_tree_path_free(b_tree_path);
+
+    return ret_val;
+}
+
+static void active_sensor_update_icon(ActiveSensor *active_sensor,
+                                      GdkPixbuf *base_icon,
+                                      SensorType sensor_type) {
+
+    GdkPixbuf *new_icon;
+    const gchar *overlay_icon_filename = NULL;
+    SensorValueRange value_range;
+
+    g_assert(active_sensor);
+
+    /* select overlay icon depending on sensor value */
+    value_range = sensor_value_range(active_sensor->sensor_values[0],
+                                     active_sensor->sensor_low_value,
+                                     active_sensor->sensor_high_value);
+
+    if (sensor_type == TEMP_SENSOR) {
+        overlay_icon_filename = temp_overlay_icons[value_range];
+    }
+
+    /* load base icon */
+    new_icon = gdk_pixbuf_copy(base_icon);
+
+    /* only load overlay if required */
+    if (overlay_icon_filename) {
+        GdkPixbuf *overlay_icon;
+
+        overlay_icon = gdk_pixbuf_new_from_file_at_size(overlay_icon_filename,
+                                DEFAULT_ICON_SIZE,
+                                DEFAULT_ICON_SIZE,
+                                NULL);
+
+        if (overlay_icon) {
+            gdk_pixbuf_composite(overlay_icon, new_icon,
+                                 0, 0,
+                                 DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE,
+                                 0, 0,
+                                 1.0, 1.0,
+                                 GDK_INTERP_BILINEAR,
+                                 255);
+
+            g_object_unref(overlay_icon);
+        }
+    }
+
+    gtk_image_set_from_pixbuf(GTK_IMAGE(active_sensor->icon),
+                              new_icon);
+    g_object_unref(new_icon);
+
+}
+
+static void active_sensor_update_graph(ActiveSensor *as, cairo_t *cr) {
+    GtkAllocation allocation;
+    gdouble line_height;
+    gdouble width, height;
+    gdouble x = 0.0, y = 0.0;
+    cairo_pattern_t *pattern;
+    gint i;
+
+    gtk_widget_get_allocation (as->graph, &allocation);
+    width = allocation.width;
+    height = allocation.height;
+
+    /* so we can set a clipping area, as well as fill the * back of the graph black */
+    cairo_rectangle(cr,
+                    0, 0,
+                    width,
+                    height);
+    /* clip to rectangle and keep it as a path so can be
+     * filled below */
+    cairo_clip_preserve(cr);
+
+    /* use black for bg color of graphs */
+    cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
+    cairo_fill(cr);
+
+    /* determine height to scale line at for each value -
+     * only do as many as will fit or the number of
+     * samples that we have */
+    for (i = 0; i < MIN(as->num_samples, width); i++) {
+        /* need to remove one more to make it line up
+         * properly  when drawing */
+        x = width - i - 1;
+        y = height;
+
+        line_height = sensor_value_range_normalised(as->sensor_values[i],
+                                                    as->sensor_low_value,
+                                                    as->sensor_high_value) * height;
+
+        if (line_height > 0) {
+            cairo_move_to(cr, x, y);
+            cairo_line_to(cr, x, y - line_height);
+        }
+    }
+
+    /* make lines a gradient from slightly darker than
+     * chosen color at bottom of graph, to slightly
+     * lighter than chosen color at top of graph */
+    pattern = cairo_pattern_create_linear(x, y, x, 0);
+    cairo_pattern_add_color_stop_rgb(pattern,
+                                     0,
+                                     as->graph_color.red - CAIRO_GRAPH_COLOR_GRADIENT,
+                                     as->graph_color.green - CAIRO_GRAPH_COLOR_GRADIENT,
+                                     as->graph_color.blue - CAIRO_GRAPH_COLOR_GRADIENT);
+
+    cairo_pattern_add_color_stop_rgb(pattern,
+                                     height,
+                                     as->graph_color.red + CAIRO_GRAPH_COLOR_GRADIENT,
+                                     as->graph_color.green + CAIRO_GRAPH_COLOR_GRADIENT,
+                                     as->graph_color.blue + CAIRO_GRAPH_COLOR_GRADIENT);
+
+    cairo_set_source(cr, pattern);
+    cairo_stroke(cr);
+    cairo_pattern_destroy(pattern);
+}
+
+void active_sensor_destroy(ActiveSensor *active_sensor) {
+    g_debug("-- destroying active sensor label...");
+    gtk_widget_destroy(active_sensor->label);
+
+    g_debug("-- destroying active sensor icon..");
+    gtk_widget_destroy(active_sensor->icon);
+
+    g_debug("-- destroying active sensor value...");
+    gtk_widget_destroy(active_sensor->value);
+
+    g_debug("-- destroying active sensor graph and frame...");
+    gtk_widget_destroy(active_sensor->graph);
+    gtk_widget_destroy(active_sensor->graph_frame);
+
+    g_debug("-- destroying active sensor values...");
+    g_free(active_sensor->sensor_values);
+
+    active_sensor_all_alarms_off(active_sensor);
+
+    g_free(active_sensor);
+}
+
+static
+gboolean graph_draw_cb(GtkWidget *graph,
+                       cairo_t *cr,
+                       gpointer data) {
+
+    ActiveSensor *as;
+
+    as = (ActiveSensor *)data;
+
+    active_sensor_update_graph(as, cr);
+    /* propagate event onwards */
+
+    return FALSE;
+}
+
+static void active_sensor_set_graph_dimensions(ActiveSensor *as,
+                                               gint width,
+                                               gint height) {
+
+    gint num_samples, old_num_samples;
+    gint graph_width, graph_height;
+
+    /* dimensions are really for graph frame, so need to remove
+     * extra width added by graph frame - make sure not less than
+     * 1 - always need atleast 1 sample */
+    graph_width = CLAMP(width - GRAPH_FRAME_EXTRA_WIDTH, 1, width - GRAPH_FRAME_EXTRA_WIDTH);
+    graph_height = CLAMP(height - GRAPH_FRAME_EXTRA_WIDTH, 1 , height - GRAPH_FRAME_EXTRA_WIDTH);
+
+    g_debug("setting graph dimensions to %d x %d", graph_width, graph_height);
+    num_samples = graph_width;
+
+    if (as->sensor_values) {
+        gdouble *old_values;
+
+        old_values = as->sensor_values;
+        old_num_samples = as->num_samples;
+
+        as->num_samples = num_samples;
+        as->sensor_values = g_new0 (gdouble, as->num_samples);
+        memcpy(as->sensor_values,
+               old_values,
+               MIN(old_num_samples, as->num_samples)*sizeof(gdouble));
+
+        g_free(old_values);
+    } else {
+        as->sensor_values = g_new0 (gdouble, num_samples);
+        as->num_samples = num_samples;
+    }
+
+    /* update graph frame size request */
+    gtk_widget_set_size_request(as->graph,
+                                graph_width,
+                                graph_height);
+}
+
+void active_sensor_update_graph_dimensions(ActiveSensor *as,
+                                     gint sizes[2]) {
+
+    active_sensor_set_graph_dimensions(as, sizes[0], sizes[1]);
+    gtk_widget_queue_draw (as->graph);
+}
+
+ActiveSensor *active_sensor_new(SensorsApplet *sensors_applet,
+                                GtkTreeRowReference *sensor_row) {
+
+    ActiveSensor *active_sensor;
+    MatePanelAppletOrient orient;
+    gint graph_size;
+    gboolean horizontal;
+
+    g_assert(sensors_applet);
+    g_assert(sensor_row);
+
+    g_debug("creating new active sensor");
+
+    active_sensor = g_new0(ActiveSensor, 1);
+    active_sensor->sensors_applet = sensors_applet;
+
+    active_sensor->sensor_row = sensor_row;
+
+#ifdef HAVE_LIBNOTIFY
+    /* set a base time, creation -5 minutes */
+    active_sensor->ierror_ts = time(NULL) - 300;
+#endif
+
+    int i;
+    for (i = 0; i < NUM_ALARMS; i++) {
+        active_sensor->alarm_timeout_id[i] = -1;
+    }
+
+    active_sensor->label = gtk_label_new("");
+    active_sensor->value = gtk_label_new("");
+    active_sensor->icon = gtk_image_new();
+
+    active_sensor->graph = gtk_drawing_area_new();
+    active_sensor->graph_frame = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(active_sensor->graph_frame),
+                              GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(active_sensor->graph_frame),
+                      active_sensor->graph);
+    gtk_widget_add_events(active_sensor->graph_frame,
+                          GDK_ALL_EVENTS_MASK);
+
+    /* need to set size according to orientation */
+    orient = mate_panel_applet_get_orient(active_sensor->sensors_applet->applet);
+    graph_size = g_settings_get_int(active_sensor->sensors_applet->settings, GRAPH_SIZE);
+
+    horizontal = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
+                  (orient == MATE_PANEL_APPLET_ORIENT_DOWN));
+
+    active_sensor_set_graph_dimensions(active_sensor,
+                                       (horizontal ? graph_size : sensors_applet->size),
+                                       (horizontal ? sensors_applet->size : graph_size));
+
+    g_signal_connect(G_OBJECT(active_sensor->graph),
+                     "draw",
+                     G_CALLBACK(graph_draw_cb),
+                     active_sensor);
+
+    active_sensor->updated = FALSE;
+    return active_sensor;
+}
+
+static void active_sensor_update_sensor_value(ActiveSensor *as,
+                                              gdouble sensor_value) {
+
+    /* only if have more than 1 sample stored */
+    if (as->num_samples > 1) {
+        memmove(&(as->sensor_values[1]),
+                as->sensor_values,
+                (as->num_samples - 1)*sizeof(gdouble));
+    }
+
+    as->sensor_values[0] = sensor_value;
+}
+
+void active_sensor_update(ActiveSensor *active_sensor,
+                          SensorsApplet *sensors_applet) {
+
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    GtkTreePath *path;
+
+    /* instance data from the tree for this sensor */
+    gchar *sensor_path = NULL;
+    gchar *sensor_id = NULL;
+    gchar *sensor_label = NULL;
+    SensorType sensor_type;
+    gchar *sensor_interface;
+    gboolean sensor_enabled;
+    gdouble sensor_low_value;
+    gdouble sensor_high_value;
+    gboolean sensor_alarm_enabled;
+    gdouble sensor_multiplier;
+    gdouble sensor_offset;
+    gdouble sensor_value;
+    GdkPixbuf *icon_pixbuf;
+    gchar *graph_color;
+    gint label_min_width;
+    GtkRequisition  req;
+
+    /* to build the list of labels as we go */
+    gchar *value_text = NULL;
+
+    TemperatureScale scale;
+    DisplayMode display_mode;
+
+    GError *error = NULL;
+
+    gchar *tooltip = NULL;
+    gchar *value_tooltip = NULL;
+
+    /* hidden gsettings options */
+    gint font_size = 0;
+    gboolean hide_units = FALSE;
+    gboolean hide_units_old = FALSE;
+
+    g_assert(active_sensor);
+    g_assert(active_sensor->sensor_row);
+    g_assert(sensors_applet);
+
+    model = gtk_tree_row_reference_get_model(active_sensor->sensor_row);
+    path = gtk_tree_row_reference_get_path(active_sensor->sensor_row);
+
+    /* if can successfully get iter can proceed */
+    if (gtk_tree_model_get_iter(model, &iter, path)) {
+        gtk_tree_path_free(path);
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors),
+                   &iter,
+                   PATH_COLUMN, &sensor_path,
+                   ID_COLUMN, &sensor_id,
+                   LABEL_COLUMN, &sensor_label,
+                   INTERFACE_COLUMN, &sensor_interface,
+                   SENSOR_TYPE_COLUMN, &sensor_type,
+                   ENABLE_COLUMN, &sensor_enabled,
+                   LOW_VALUE_COLUMN, &sensor_low_value,
+                   HIGH_VALUE_COLUMN, &sensor_high_value,
+                   ALARM_ENABLE_COLUMN, &sensor_alarm_enabled,
+                   MULTIPLIER_COLUMN, &sensor_multiplier,
+                   OFFSET_COLUMN, &sensor_offset,
+                   ICON_PIXBUF_COLUMN, &icon_pixbuf,
+                   GRAPH_COLOR_COLUMN, &graph_color,
+                   -1);
+
+        SensorsAppletPluginGetSensorValue get_sensor_value;
+        /* only call function if is in hash table for plugin */
+        if ((get_sensor_value = sensors_applet_plugins_get_sensor_value_func(sensors_applet, sensor_interface)) != NULL) {
+            sensor_value = get_sensor_value(sensor_path,
+                                            sensor_id,
+                                            sensor_type,
+                                            &error);
+
+            if (error) {
+                g_debug("Error updating active sensor: %s", error->message);
+                sensors_applet_notify_active_sensor(active_sensor,
+                                                    SENSOR_INTERFACE_ERROR);
+
+                /* hard code text as ERROR */
+                value_text = g_strdup(_("ERROR"));
+                value_tooltip = g_strdup_printf("- %s", error->message);
+                g_error_free(error);
+                error = NULL;
+
+                /* set sensor value to an error code -
+                 * note this is not unique */
+                sensor_value = -1;
+            } else {
+                /* use hidden gsettings key for hide_units */
+                hide_units_old = hide_units;
+                hide_units = g_settings_get_boolean(sensors_applet->settings, HIDE_UNITS);
+
+                /* scale value and set text using this value */
+                switch (sensor_type) {
+                    case TEMP_SENSOR:
+                        scale = (TemperatureScale) g_settings_get_int(sensors_applet->settings, TEMPERATURE_SCALE);
+                        /* scale value */
+                        sensor_value = sensors_applet_convert_temperature(sensor_value, CELSIUS, scale);
+
+                        sensor_value = (sensor_value * sensor_multiplier) + sensor_offset;
+                        switch (scale) {
+                            case FAHRENHEIT:
+                                value_text = g_strdup_printf("%2.0f %s", sensor_value, (hide_units ? "" : UNITS_FAHRENHEIT));
+                                /* tooltip should
+                                 * always display
+                                 * units */
+                                value_tooltip = g_strdup_printf("%2.0f %s", sensor_value, UNITS_FAHRENHEIT);
+
+                                break;
+                            case CELSIUS:
+                                value_text = g_strdup_printf("%2.0f %s", sensor_value, (hide_units ? "" : UNITS_CELSIUS));
+                                value_tooltip = g_strdup_printf("%2.0f %s", sensor_value, UNITS_CELSIUS);
+                                break;
+                            case KELVIN:
+                                value_text = g_strdup_printf("%2.0f", sensor_value);
+                                value_tooltip = g_strdup(value_text);
+                                break;
+                        }
+                        break;
+
+                    case FAN_SENSOR:
+                        sensor_value = (sensor_value * sensor_multiplier) + sensor_offset;
+                        value_text = g_strdup_printf("%4.0f %s", sensor_value, (hide_units ? "" : UNITS_RPM));
+                        value_tooltip = g_strdup_printf("%4.0f %s", sensor_value, UNITS_RPM);
+                        break;
+
+                    case VOLTAGE_SENSOR:
+                        sensor_value = (sensor_value * sensor_multiplier) + sensor_offset;
+                        value_text = g_strdup_printf("%4.2f %s", sensor_value, (hide_units ? "" : UNITS_VOLTAGE));
+                        value_tooltip = g_strdup_printf("%4.2f %s", sensor_value, UNITS_VOLTAGE);
+                        break;
+
+                    case CURRENT_SENSOR:
+                        sensor_value = (sensor_value * sensor_multiplier) + sensor_offset;
+                        value_text = g_strdup_printf("%4.2f %s", sensor_value, (hide_units ? "" : UNITS_CURRENT));
+                        value_tooltip = g_strdup_printf("%4.2f %s", sensor_value, UNITS_CURRENT);
+                        break;
+
+                } /* end switch(sensor_type) */
+            } /* end else on error */
+
+            /* setup for tooltips */
+            if (sensors_applet->show_tooltip)
+                    tooltip = g_strdup_printf("%s %s", sensor_label, value_tooltip);
+            g_free(value_tooltip);
+
+            /* only do icons and labels / graphs if needed */
+            display_mode = g_settings_get_int (sensors_applet->settings, DISPLAY_MODE);
+
+            /* most users wont have a font size set */
+            font_size = g_settings_get_int (sensors_applet->settings, FONT_SIZE);
+
+            /* do icon if needed */
+            if (display_mode == DISPLAY_ICON ||
+                display_mode == DISPLAY_ICON_WITH_VALUE) {
+
+                /* update icon if icon range has changed if no
+                 * update has been done before */
+                if ((sensor_value_range(sensor_value, sensor_low_value, sensor_high_value) != sensor_value_range(active_sensor->sensor_values[0], active_sensor->sensor_low_value, active_sensor->sensor_high_value)) ||
+                    !(active_sensor->updated)) {
+
+                    active_sensor_update_sensor_value(active_sensor, sensor_value);
+                    active_sensor->sensor_low_value = sensor_low_value;
+                    active_sensor->sensor_high_value = sensor_high_value;
+                    active_sensor_update_icon(active_sensor, icon_pixbuf, sensor_type);
+                }
+
+                if (tooltip) {
+                    gtk_widget_set_tooltip_text(active_sensor->icon, tooltip);
+                }
+            }
+
+            active_sensor_update_sensor_value(active_sensor, sensor_value);
+            active_sensor->sensor_low_value = sensor_low_value;
+            active_sensor->sensor_high_value = sensor_high_value;
+
+            /* do graph if needed */
+            if (display_mode == DISPLAY_GRAPH) {
+                /* update graph color in case has changed */
+                gdk_rgba_parse(&(active_sensor->graph_color), graph_color);
+
+                gtk_widget_queue_draw (active_sensor->graph);
+                if (tooltip) {
+                    gtk_widget_set_tooltip_text(active_sensor->graph, tooltip);
+                }
+            }
+
+            gchar *old_value_text = value_text;
+
+            if (sensor_alarm_enabled) {
+                if (sensor_value >= sensor_high_value || sensor_value <= sensor_low_value) {
+
+                    /* make value text red and
+                     * activate alarm */
+                    if (display_mode == DISPLAY_LABEL_WITH_VALUE ||
+                        display_mode == DISPLAY_ICON_WITH_VALUE ||
+                        display_mode == DISPLAY_VALUE) {
+
+                        value_text = g_markup_printf_escaped("<span foreground=\"#FF0000\">%s</span>", old_value_text);
+                        g_free(old_value_text);
+                    }
+
+                    /* could have both coditions at once */
+                    if (sensor_value >= sensor_high_value) {
+                        active_sensor_alarm_on(active_sensor, HIGH_ALARM);
+                    }
+
+                    if (sensor_value <= sensor_low_value) {
+                        active_sensor_alarm_on(active_sensor, LOW_ALARM);
+                    }
+
+                } else {
+                    /* make sure alarms are off */
+                    active_sensor_all_alarms_off(active_sensor);
+                }
+            } else {
+                /* else for if alarm enabled */
+                /* make sure all alarms are off */
+                active_sensor_all_alarms_off(active_sensor);
+            }
+
+            /* do value label */
+            if (display_mode == DISPLAY_LABEL_WITH_VALUE ||
+                display_mode == DISPLAY_ICON_WITH_VALUE ||
+                display_mode == DISPLAY_VALUE) {
+
+                if (font_size) {
+                    old_value_text = value_text;
+
+                    value_text = g_strdup_printf("<span font_desc=\"%d\">%s</span>", font_size, old_value_text);
+                    g_free(old_value_text);
+                }
+
+                /*Keep the label as large as previous size unless hide_units has changed */
+                gtk_widget_get_preferred_size (GTK_WIDGET (active_sensor->value), &req, NULL);
+                if (!(hide_units_old == hide_units)) {
+                    label_min_width = 0;
+                } else {
+                    label_min_width = req.width;
+                }
+
+                gtk_label_set_markup(GTK_LABEL(active_sensor->value), value_text);
+
+                gtk_widget_get_preferred_size (GTK_WIDGET (active_sensor->value), &req, NULL);
+                gtk_widget_set_size_request (GTK_WIDGET (active_sensor->value), label_min_width, req.height);
+
+                if (tooltip) {
+                    gtk_widget_set_tooltip_text(active_sensor->value, tooltip);
+                }
+            }
+            /* finished with value text */
+            g_free(value_text);
+
+            /* do label label */
+            if (display_mode == DISPLAY_LABEL_WITH_VALUE) {
+                if (font_size) {
+                    old_value_text = sensor_label;
+                    sensor_label = g_strdup_printf("<span font_desc=\"%d\">%s</span>", font_size, old_value_text);
+                    g_free(old_value_text);
+                }
+
+                gtk_label_set_markup(GTK_LABEL(active_sensor->label), sensor_label);
+                if (tooltip) {
+                        gtk_widget_set_tooltip_text(active_sensor->label, tooltip);
+                }
+            }
+
+            g_free(tooltip);
+        } else {
+            g_debug("no get_sensor_value function yet installed for interface %s.", sensor_interface);
+        }
+
+        g_free(sensor_path);
+        g_free(sensor_id);
+        g_free(sensor_label);
+        g_free(sensor_interface);
+        g_free(graph_color);
+        g_object_unref(icon_pixbuf);
+
+    } else {
+        g_debug("Error getting iter when updating sensor...");
+    }
+
+    active_sensor->updated = TRUE;
+
+}
+
+/* to be called when the icon within the GtkRowReference that this
+ * sensor references is changed - updates icon based upon value in the
+ * ActiveSensor */
+void active_sensor_icon_changed(ActiveSensor *active_sensor, SensorsApplet *sensors_applet) {
+
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+
+    SensorType sensor_type;
+    GdkPixbuf *icon_pixbuf;
+
+    g_assert(active_sensor);
+    g_assert(sensors_applet);
+
+    model = gtk_tree_row_reference_get_model(active_sensor->sensor_row);
+    path = gtk_tree_row_reference_get_path(active_sensor->sensor_row);
+
+    /* if can successfully get iter can proceed */
+    if (gtk_tree_model_get_iter(model, &iter, path)) {
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors),
+                                           &iter,
+                                           SENSOR_TYPE_COLUMN, &sensor_type,
+                                           ICON_PIXBUF_COLUMN, &icon_pixbuf,
+                                           -1);
+
+        active_sensor_update_icon(active_sensor, icon_pixbuf, sensor_type);
+        g_object_unref(icon_pixbuf);
+    }
+    gtk_tree_path_free(path);
+}
+
+ +
+ +
+ + diff --git a/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/3.html b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/3.html new file mode 100644 index 0000000..4afc93c --- /dev/null +++ b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/3.html @@ -0,0 +1,1905 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <glib/gi18n.h>
+#include "sensor-config-dialog.h"
+#include "sensors-applet.h"
+
+#define SPINBUTTON_WIDTH_CHARS 8
+#define VALUE_DECIMAL_PLACES 3
+
+typedef struct {
+    SensorsApplet *sensors_applet;
+
+    GtkDialog *dialog;
+    /* icon widgets */
+    GtkLabel *icon_header, *icon_type_label;
+    GtkComboBox *icon_type_combo_box;
+    GtkAlignment *icon_type_combo_box_aligner;<--- struct member 'SensorConfigDialog::icon_type_combo_box_aligner' is never used.
+    GtkCellRenderer *icon_renderer;
+
+    /* Graph Color chooser */
+    GtkColorButton *graph_color_button;
+    GtkAlignment *graph_color_button_aligner;<--- struct member 'SensorConfigDialog::graph_color_button_aligner' is never used.
+    GtkLabel *graph_color_label, *graph_header;
+
+    /* multiplier and offset widgets */
+    GtkLabel *scale_header, *multiplier_label, *offset_label;
+    GtkAlignment *multiplier_spinbutton_aligner, *offset_spinbutton_aligner;<--- struct member 'SensorConfigDialog::multiplier_spinbutton_aligner' is never used.<--- struct member 'SensorConfigDialog::offset_spinbutton_aligner' is never used.
+    GtkAdjustment *multiplier_adjust, *offset_adjust;
+    GtkSpinButton *multiplier_spinbutton, *offset_spinbutton;
+
+    GtkLabel *limits_header;
+    GtkLabel *low_value_label, *high_value_label;
+    GtkAlignment *low_value_spinbutton_aligner, *high_value_spinbutton_aligner;<--- struct member 'SensorConfigDialog::low_value_spinbutton_aligner' is never used.<--- struct member 'SensorConfigDialog::high_value_spinbutton_aligner' is never used.
+    GtkAdjustment *low_value_adjust, *high_value_adjust;
+    GtkSpinButton *low_value_spinbutton, *high_value_spinbutton;
+
+    /* alarm widgets */
+    GtkLabel *alarm_header;
+    GtkLabel *low_alarm_command_label, *high_alarm_command_label, *alarm_timeout_label;
+    GtkAlignment *alarm_timeout_spinbutton_aligner;<--- struct member 'SensorConfigDialog::alarm_timeout_spinbutton_aligner' is never used.
+    GtkAdjustment *alarm_timeout_adjust;
+    GtkSpinButton *alarm_timeout_spinbutton;
+    GtkGrid *grid;
+    GtkAlignment *alarm_enable_aligner;<--- struct member 'SensorConfigDialog::alarm_enable_aligner' is never used.
+    GtkCheckButton *alarm_enable_checkbutton;
+    GtkEntry *low_alarm_command_entry, *high_alarm_command_entry;
+
+    GtkSizeGroup *size_group;
+} SensorConfigDialog;
+
+static void sensor_config_dialog_response(GtkDialog *dialog,
+                                          gint response,
+                                          gpointer data) {
+
+    GError *error = NULL;
+
+    switch (response) {
+        case GTK_RESPONSE_HELP:
+            g_debug("loading help in config dialog");
+            gtk_show_uri_on_window(NULL,
+                         "help:mate-sensors-applet/sensors-applet-sensors#sensors-applet-sensor-config-dialog",
+                         gtk_get_current_event_time(),
+                         &error);
+
+            if (error) {
+                    g_debug("Could not open help document: %s ",error->message);
+                    g_error_free (error);
+            }
+            break;
+
+        default:
+            g_debug("destroying config dialog");
+            gtk_widget_destroy(GTK_WIDGET(dialog));
+    }
+}
+
+static void sensor_config_dialog_multiplier_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gdouble value;
+
+    value = gtk_spin_button_get_value(spinbutton);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        MULTIPLIER_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_offset_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gdouble value;
+
+    value = gtk_spin_button_get_value(spinbutton);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        OFFSET_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_low_value_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gdouble value;
+
+    value = gtk_spin_button_get_value(spinbutton);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        LOW_VALUE_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_high_value_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gdouble value;
+
+    value = gtk_spin_button_get_value(spinbutton);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        HIGH_VALUE_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_alarm_toggled(GtkToggleButton *button, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+
+    gboolean value;
+    value = gtk_toggle_button_get_active(button);
+
+    /* update state of alarm widgets */
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->alarm_timeout_label), value);
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), value);
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->low_alarm_command_label), value);
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->low_alarm_command_entry), value);
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->high_alarm_command_label), value);
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->high_alarm_command_entry), value);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        ALARM_ENABLE_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_alarm_timeout_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gint value;
+
+    value = gtk_spin_button_get_value_as_int(spinbutton);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+    sensors_applet_all_alarms_off(config_dialog->sensors_applet, path);
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        ALARM_TIMEOUT_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_alarm_command_edited(GtkEntry *command_entry, SensorConfigDialog *config_dialog, NotifType notif_type) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+
+    gchar *value;
+    g_object_get(command_entry, "text", &value, NULL);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+    sensors_applet_alarm_off(config_dialog->sensors_applet, path, notif_type);
+
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                       &iter,
+                       (notif_type == LOW_ALARM ? LOW_ALARM_COMMAND_COLUMN : HIGH_ALARM_COMMAND_COLUMN),
+                       value,
+                       -1);
+    g_free(value);
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_low_alarm_command_edited(GtkEntry *command_entry, SensorConfigDialog *config_dialog) {
+    sensor_config_dialog_alarm_command_edited(command_entry,
+                                              config_dialog,
+                                              LOW_ALARM);
+}
+
+static void sensor_config_dialog_high_alarm_command_edited(GtkEntry *command_entry, SensorConfigDialog *config_dialog) {
+    sensor_config_dialog_alarm_command_edited(command_entry,
+                                              config_dialog,
+                                              HIGH_ALARM);
+}
+
+static void sensor_config_dialog_icon_type_changed(GtkComboBox *icon_type_combo_box,
+                                                   SensorConfigDialog *config_dialog) {
+    GtkTreeModel *icons_model;
+    GtkTreeIter icons_iter;
+
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    GdkPixbuf *new_icon;
+    IconType icon_type;
+
+    icons_model = gtk_combo_box_get_model(icon_type_combo_box);
+    if (gtk_combo_box_get_active_iter(icon_type_combo_box, &icons_iter)) {
+        GtkTreePath *path;
+
+        gtk_tree_model_get(icons_model, &icons_iter,
+                           0, &new_icon,
+                           -1);
+
+        icon_type = gtk_combo_box_get_active(icon_type_combo_box);
+        gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                        &model,
+                                        &iter);
+
+        path = gtk_tree_model_get_path(model, &iter);
+        gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                           &iter,
+                           ICON_TYPE_COLUMN, icon_type,
+                           ICON_PIXBUF_COLUMN, new_icon,
+                           -1);
+        g_object_unref(new_icon);
+        sensors_applet_icon_changed(config_dialog->sensors_applet, path);
+        gtk_tree_path_free(path);
+    }
+}
+
+static void sensor_config_dialog_graph_color_set(GtkColorChooser *color_chooser,
+                                                 SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gchar *color_string;
+    GdkRGBA color;
+
+    gtk_color_chooser_get_rgba(color_chooser, &color);
+
+    color_string = g_strdup_printf ("#%02X%02X%02X", (int)(0.5 + CLAMP (color.red, 0., 1.) * 255.),
+                                    (int)(0.5 + CLAMP (color.green, 0., 1.) * 255.),
+                                    (int)(0.5 + CLAMP (color.blue, 0., 1.) * 255.));
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                       &iter,
+                       GRAPH_COLOR_COLUMN, color_string,
+                       -1);
+
+    g_free(color_string);
+
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+void sensor_config_dialog_create(SensorsApplet *sensors_applet) {
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    GtkWidget *content_area;
+
+    SensorConfigDialog *config_dialog;
+
+    GtkListStore *icon_store;
+    IconType count;
+    GdkRGBA graph_color;
+    gchar *sensor_label;
+    gchar *header_text;
+
+    /* instance variables for data */
+    gdouble low_value, high_value, multiplier, offset;
+    gboolean alarm_enable;
+    gchar *low_alarm_command, *high_alarm_command;
+    gint alarm_timeout;
+    IconType icon_type;
+    gchar *graph_color_string;
+
+    config_dialog = g_new0(SensorConfigDialog, 1);
+    config_dialog->sensors_applet = sensors_applet;
+
+    gtk_tree_selection_get_selected(sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    /* get current values of alarm and its enable */
+    gtk_tree_model_get(model, &iter,
+                       LOW_VALUE_COLUMN, &low_value,
+                       HIGH_VALUE_COLUMN, &high_value,
+                       ALARM_ENABLE_COLUMN, &alarm_enable,
+                       LOW_ALARM_COMMAND_COLUMN, &low_alarm_command,
+                       HIGH_ALARM_COMMAND_COLUMN, &high_alarm_command,
+                       ALARM_TIMEOUT_COLUMN, &alarm_timeout,
+                       MULTIPLIER_COLUMN, &multiplier,
+                       OFFSET_COLUMN, &offset,
+                       ICON_TYPE_COLUMN, &icon_type,
+                       GRAPH_COLOR_COLUMN, &graph_color_string,
+                       LABEL_COLUMN, &sensor_label,
+                       -1);
+    header_text = g_strdup_printf("%s - %s", _("Sensor Properties"), sensor_label);
+
+    config_dialog->dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(header_text,
+                                                        GTK_WINDOW(sensors_applet->prefs_dialog->dialog),
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        "gtk-help",
+                                                        GTK_RESPONSE_HELP,
+                                                        "gtk-close",
+                                                        GTK_RESPONSE_CLOSE,
+                                                        NULL));
+
+    gtk_window_set_icon_name(GTK_WINDOW(config_dialog->dialog), "sensors-applet");
+
+    g_free(header_text);
+    g_free(sensor_label);
+
+    g_object_set(config_dialog->dialog,
+                 "border-width", 12,
+                 NULL);
+
+    g_signal_connect(config_dialog->dialog,
+                     "response",
+                     G_CALLBACK(sensor_config_dialog_response),
+                     config_dialog);
+
+    /* graph stuff */
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Graph"));
+    config_dialog->graph_header = g_object_new(GTK_TYPE_LABEL,
+                               "use-markup", TRUE,
+                               "label", header_text,
+                               "xalign", 0.0,
+                               NULL);
+    g_free(header_text);
+
+    gdk_rgba_parse(&graph_color, graph_color_string);
+    config_dialog->graph_color_button = GTK_COLOR_BUTTON(gtk_color_button_new_with_rgba(&graph_color));
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->graph_color_button), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->graph_color_button), GTK_ALIGN_START);
+
+    gtk_color_button_set_title(config_dialog->graph_color_button, _("Graph Color"));
+
+    config_dialog->graph_color_label = g_object_new(GTK_TYPE_LABEL,
+                                     "label", _("Graph _color"),
+                                    "mnemonic-widget", config_dialog->graph_color_button,
+                                    "use-underline", TRUE,
+                                    "xalign", 0.0,
+                                    NULL);
+
+    g_signal_connect(config_dialog->graph_color_button, "color-set",
+                     G_CALLBACK(sensor_config_dialog_graph_color_set),
+                     config_dialog);
+
+    /* icon stuff */
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Icon"));
+    config_dialog->icon_header = g_object_new(GTK_TYPE_LABEL,
+                               "use-markup", TRUE,
+                               "label", header_text,
+                               "xalign", 0.0,
+                               NULL);
+    g_free(header_text);
+
+    /* icon type */
+    icon_store = gtk_list_store_new(1, GDK_TYPE_PIXBUF);
+
+    /* populate list with icons */
+    for (count = CPU_ICON; count < NUM_ICONS; count++) {
+        GdkPixbuf *pixbuf;
+
+        pixbuf = sensors_applet_load_icon(count);
+        if (pixbuf) {
+            gtk_list_store_insert(icon_store, &iter, count);
+            gtk_list_store_set(icon_store, &iter, 0, pixbuf, -1);
+            /* let list hold icons */
+            g_object_unref(pixbuf);
+        }
+    }
+
+    config_dialog->icon_type_combo_box = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(icon_store)));
+
+        gtk_widget_set_halign (GTK_WIDGET(config_dialog->icon_type_combo_box), GTK_ALIGN_START);
+        gtk_widget_set_valign (GTK_WIDGET(config_dialog->icon_type_combo_box), GTK_ALIGN_START);
+
+    config_dialog->icon_renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box),
+                               GTK_CELL_RENDERER(config_dialog->icon_renderer),
+                               FALSE);
+
+    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box),
+                                  GTK_CELL_RENDERER(config_dialog->icon_renderer),
+                                  "pixbuf", 0);
+
+    gtk_combo_box_set_active(config_dialog->icon_type_combo_box, icon_type);
+
+    g_signal_connect(config_dialog->icon_type_combo_box, "changed",
+                     G_CALLBACK(sensor_config_dialog_icon_type_changed),
+                     config_dialog);
+
+    config_dialog->icon_type_label = g_object_new(GTK_TYPE_LABEL,
+                                     "label", _("Sensor _icon"),
+                                    "mnemonic-widget", config_dialog->icon_type_combo_box,
+                                    "use-underline", TRUE,
+                                    "xalign", 0.0,
+                                    NULL);
+
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Scaling Parameters"));
+    config_dialog->scale_header = g_object_new(GTK_TYPE_LABEL,
+                               "use-markup", TRUE,
+                               "label", header_text,
+                               "xalign", 0.0,
+                               NULL);
+    g_free(header_text);
+
+    /* do multiplier and offset widgets */
+    config_dialog->multiplier_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                          "value", 1.0,
+                          "lower", 0.001,
+                          "upper", 1000.0,
+                          "step-increment", 0.1,
+                          "page-increment", 1.0,
+                          "page-size", 1.0,
+                          NULL);
+
+    config_dialog->multiplier_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                         "adjustment", config_dialog->multiplier_adjust,
+                                         "digits", VALUE_DECIMAL_PLACES,
+                                         "value", multiplier,
+                                         "width-chars", SPINBUTTON_WIDTH_CHARS,
+                                         NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->multiplier_spinbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->multiplier_spinbutton), GTK_ALIGN_START);
+
+    config_dialog->multiplier_label = g_object_new(GTK_TYPE_LABEL,
+                                                   "label", _("Sensor value _multiplier"),
+                                                   "mnemonic-widget", config_dialog->multiplier_spinbutton,
+                                                   "use-underline", TRUE,
+                                                   "xalign", 0.0,
+                                                   NULL);
+
+    g_signal_connect(config_dialog->multiplier_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_multiplier_changed), config_dialog);
+
+    config_dialog->offset_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                                 "value", 0.0,
+                                 "lower", -1000.000,
+                                 "upper", 1000.000,
+                                 "step-increment", 0.01,
+                                 "page-increment", 1.0,
+                                 "page-size", 1.0,
+                                 NULL);
+
+    config_dialog->offset_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                     "adjustment", config_dialog->offset_adjust,
+                                     "digits", VALUE_DECIMAL_PLACES,
+                                     "value", (gdouble)offset,
+                                     "width-chars", SPINBUTTON_WIDTH_CHARS,
+                                     NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->offset_spinbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->offset_spinbutton), GTK_ALIGN_START);
+
+    config_dialog->offset_label = g_object_new(GTK_TYPE_LABEL,
+                                "label", _("Sensor value _offset"),
+                                "mnemonic-widget", config_dialog->offset_spinbutton,
+                                "use-underline", TRUE,
+                                "xalign", 0.0,
+                                NULL);
+
+    g_signal_connect(config_dialog->offset_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_offset_changed), config_dialog);
+
+    /* now do alarm widgets */
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Sensor Limits"));
+    config_dialog->limits_header = g_object_new(GTK_TYPE_LABEL,
+                                                "use-markup", TRUE,
+                                                "label", header_text,
+                                                "xalign", 0.0,
+                                                NULL);
+    g_free(header_text);
+
+    config_dialog->low_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                                    "value", 0.0,
+                                    "lower", -100000.0,
+                                    "upper", 100000.0,
+                                    "step-increment", 1.0,
+                                    "page-increment", 10.0,
+                                    "page-size", 100.0,
+                                    NULL);
+
+    config_dialog->low_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                                       "adjustment", config_dialog->low_value_adjust,
+                                                       "digits", VALUE_DECIMAL_PLACES,
+                                                       "value", low_value,
+                                                       "width-chars", SPINBUTTON_WIDTH_CHARS,
+                                                       NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->low_value_spinbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->low_value_spinbutton), GTK_ALIGN_START);
+
+    config_dialog->low_value_label = g_object_new(GTK_TYPE_LABEL,
+                                                  "label", _("Sensor _low value"),
+                                                  "mnemonic-widget", config_dialog->low_value_spinbutton,
+                                                  "use-underline", TRUE,
+                                                  "xalign", 0.0,
+                                                  NULL);
+
+    g_signal_connect(config_dialog->low_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_low_value_changed), config_dialog);
+
+    config_dialog->high_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                                                  "value", 0.0,
+                                                  "lower", -100000.0,
+                                                  "upper", 100000.0,
+                                                  "step-increment", 1.0,
+                                                  "page-increment", 10.0,
+                                                  "page-size", 100.0,
+                                                  NULL);
+
+    config_dialog->high_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                                        "adjustment", config_dialog->high_value_adjust,
+                                                        "digits", VALUE_DECIMAL_PLACES,
+                                                        "value", high_value,
+                                                        "width-chars", SPINBUTTON_WIDTH_CHARS,
+                                                        NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->high_value_spinbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->high_value_spinbutton), GTK_ALIGN_START);
+
+    config_dialog->high_value_label = g_object_new(GTK_TYPE_LABEL,
+                                                   "label", _("Sensor _high value"),
+                                                   "mnemonic-widget", config_dialog->high_value_spinbutton,
+                                                   "use-underline", TRUE,
+                                                   "xalign", 0.0,
+                                                   NULL);
+
+    g_signal_connect(config_dialog->high_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_high_value_changed), config_dialog);
+
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Alarm"));
+    config_dialog->alarm_header = g_object_new(GTK_TYPE_LABEL,
+                                               "use-markup", TRUE,
+                                               "label", header_text,
+                                               "xalign", 0.0,
+                                               NULL);
+    g_free(header_text);
+
+    config_dialog->alarm_timeout_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                                        "value", 0.0,
+                                        "lower", 0.0,
+                                        "upper", 10000.0,
+                                        "step-increment", 1.0,
+                                        "page-increment", 10.0,
+                                        "page-size", 100.0,
+                                        NULL);
+
+    config_dialog->alarm_timeout_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                                           "adjustment", config_dialog->alarm_timeout_adjust,
+                                                           "digits", 0,
+                                                           "value", (gdouble)alarm_timeout,
+                                                           "width-chars", SPINBUTTON_WIDTH_CHARS,
+                                                           "sensitive", alarm_enable,
+                                                           NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), GTK_ALIGN_START);
+
+    config_dialog->alarm_timeout_label = g_object_new(GTK_TYPE_LABEL,
+                                                      "label", _("Alarm _repeat interval (secs)"),
+                                                      "mnemonic-widget", config_dialog->alarm_timeout_spinbutton,
+                                                      "use-underline", TRUE,
+                                                      "xalign", 0.0,
+                                                      "sensitive", alarm_enable,
+                                                      NULL);
+
+    g_signal_connect(config_dialog->alarm_timeout_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_alarm_timeout_changed), config_dialog);
+
+    config_dialog->low_alarm_command_entry = g_object_new(GTK_TYPE_ENTRY,
+                                                          "text", low_alarm_command,
+                                                          "width-chars", 25,
+                                                          "sensitive", alarm_enable,
+                                                          NULL);
+
+    g_free(low_alarm_command);
+
+    config_dialog->low_alarm_command_label = g_object_new(GTK_TYPE_LABEL,
+                                                      "use-underline", TRUE,
+                                                      "label", _("Lo_w alarm command"),
+                                                      "mnemonic-widget", config_dialog->low_alarm_command_entry,
+                                                      "xalign", 0.0,
+                                                      "sensitive", alarm_enable,
+                                                      NULL);
+
+    g_signal_connect(config_dialog->low_alarm_command_entry,
+                     "changed",
+                     G_CALLBACK(sensor_config_dialog_low_alarm_command_edited),
+                     config_dialog);
+
+    config_dialog->high_alarm_command_entry = g_object_new(GTK_TYPE_ENTRY,
+                                                          "text", high_alarm_command,
+                                                          "width-chars", 25,
+                                                          "sensitive", alarm_enable,
+                                                          NULL);
+
+    g_free(high_alarm_command);
+
+    config_dialog->high_alarm_command_label = g_object_new(GTK_TYPE_LABEL,
+                                                      "use-underline", TRUE,
+                                                      "label", _("Hi_gh alarm command"),
+                                                      "mnemonic-widget", config_dialog->high_alarm_command_entry,
+                                                      "xalign", 0.0,
+                                                      "sensitive", alarm_enable,
+                                                      NULL);
+
+    g_signal_connect(config_dialog->high_alarm_command_entry,
+                     "changed",
+                     G_CALLBACK(sensor_config_dialog_high_alarm_command_edited),
+                     config_dialog);
+
+    config_dialog->alarm_enable_checkbutton = g_object_new(GTK_TYPE_CHECK_BUTTON,
+                                            "use-underline", TRUE,
+                                            "label", _("_Enable alarm"),
+                                            "active", alarm_enable,
+                                            "xalign", 0.0,
+                                            NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->alarm_enable_checkbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->alarm_enable_checkbutton), GTK_ALIGN_START);
+
+    g_signal_connect(config_dialog->alarm_enable_checkbutton, "toggled", G_CALLBACK(sensor_config_dialog_alarm_toggled), config_dialog);
+
+    config_dialog->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->multiplier_spinbutton));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->offset_spinbutton));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->low_value_spinbutton));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->high_value_spinbutton));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->alarm_timeout_spinbutton));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->icon_type_combo_box));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->graph_color_button));
+    g_object_unref(config_dialog->size_group);
+
+    config_dialog->grid = g_object_new(GTK_TYPE_GRID,
+                                         "column-spacing", 5,
+                                         "row-homogeneous", FALSE,
+                                         "column-homogeneous", FALSE,
+                                         "row-spacing", 6,
+                                         "column-spacing", 12,
+                                         NULL);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->scale_header),
+                    0, 0, 2, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->multiplier_label),
+                    1, 1, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->multiplier_spinbutton),
+                    2, 1, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->offset_label),
+                    1, 2, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->offset_spinbutton),
+                    2, 2, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->limits_header),
+                    0, 3, 2, 1);
+
+    /* now pack alarm widgets */
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->low_value_label),
+                    1, 4, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->low_value_spinbutton),
+                    2, 4, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->high_value_label),
+                    1, 5, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->high_value_spinbutton),
+                    2, 5, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->alarm_header),
+                    0, 6, 2, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->alarm_enable_checkbutton),
+                    1, 7, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->alarm_timeout_label),
+                    1, 8, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->alarm_timeout_spinbutton),
+                    2, 8, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->low_alarm_command_label),
+                    1, 9, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->low_alarm_command_entry),
+                    2, 9, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->high_alarm_command_label),
+                    1, 10, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->high_alarm_command_entry),
+                    2, 10, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->icon_header),
+                    0, 11, 2, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->icon_type_label),
+                    1, 12, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->icon_type_combo_box),
+                    2, 12, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->graph_header),
+                    0, 13, 2, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->graph_color_label),
+                    1, 14, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->graph_color_button),
+                    2, 14, 1, 1);
+
+    content_area = gtk_dialog_get_content_area (config_dialog->dialog);
+    gtk_box_pack_start(GTK_BOX(content_area), GTK_WIDGET(config_dialog->grid), FALSE, FALSE, 0);
+    gtk_widget_show_all(GTK_WIDGET(config_dialog->dialog));
+
+}
+
+ +
+ +
+ + diff --git a/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/4.html b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/4.html new file mode 100644 index 0000000..360f563 --- /dev/null +++ b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/4.html @@ -0,0 +1,1537 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ *               2013 Stefano Karapetsas <stefano@karapetsas.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <glib.h>
+#include "sensors-applet.h"
+#include "sensors-applet-settings.h"
+
+/* #define SORT_DEBUG */
+#ifdef SORT_DEBUG
+#include <syslog.h>
+#endif
+
+/* these must be as the gsettings schema in file org.mate.sensors-applet.gschema.xml.in
+ * gsettings gvariant type string */
+#define GSGVTS "s"
+/* gsettings gvariant type string for the array */
+#define GSGVTSA "as"
+
+gchar* sensors_applet_settings_get_unique_id (const gchar *interface, const gchar *id, const gchar *path) {
+    gchar *unique_id = NULL;
+    gchar *unique_id_hash = NULL;
+    GChecksum *checksum = NULL;
+    guint8 digest[16];
+    gsize digest_len = sizeof (digest);
+
+    unique_id = g_strdup_printf ("%s/%s/%s", interface, id, path);
+
+    checksum = g_checksum_new (G_CHECKSUM_MD5);
+    g_checksum_update (checksum, (const guchar *) unique_id, strlen (unique_id));
+    g_checksum_get_digest (checksum, digest, &digest_len);
+    g_assert (digest_len == 16);
+
+    unique_id_hash = g_strdup (g_checksum_get_string (checksum));
+
+    g_checksum_free (checksum);
+    g_free (unique_id);
+
+    return unique_id_hash;
+}
+
+/* load sensors from gsettings with sorting */
+gboolean sensors_applet_settings_load_sensors (SensorsApplet *sensors_applet) {
+    /* everything gets stored except alarm timeout indexes, which
+    we set to -1, and visible which we set to false for all
+    parent nodes and true for all child nodes */
+
+    gchar *applet_path = NULL;
+    /* not sure about pointer, it is unclear if it is freed by loop, probably yes */
+    GVariantIter *iter = NULL;
+    gchar *gsuid = NULL;
+
+    /* string variables, to help free up memory in loop */
+    gchar *current_path = NULL;
+    gchar *current_id = NULL;
+    gchar *current_label = NULL;
+    gchar *current_interface = NULL;
+    gchar *current_low_alarm_command = NULL;
+    gchar *current_high_alarm_command = NULL;
+    gchar *current_graph_color = NULL;
+
+    /* get gsettings path for applet */
+    applet_path = mate_panel_applet_get_preferences_path (sensors_applet->applet);
+
+    /* get sensors-list array from gsettings */
+    g_settings_get (sensors_applet->settings, "sensors-list", GSGVTSA, &iter);
+
+    /* load sensor data into applet one by one
+     * first get unique id for the sensor
+     * then load sensor data from gsettings
+     * then add sensor
+     * gsuid is freed by g_variant_iter_loop() */
+    while (g_variant_iter_loop (iter, GSGVTS, &gsuid)) {
+
+        /* load sensor data from gsettings individually
+         * g_strdup_printf doesn't free args!
+         * applet_path is freed at the end */
+        gchar *path = g_strdup_printf ("%s%s/", applet_path, gsuid);
+        /*g_free (gsuid);   // freed by loop */
+
+        /* make a schema which points to one sensor data */
+        GSettings *settings;
+        settings = g_settings_new_with_path ("org.mate.sensors-applet.sensor", path);
+        g_free (path);
+
+        /* laod sensor data to temp variables
+         * g_settings_get_string allocates memory!
+         * sensors_applet_add_sensor() gtk_tree_store_set() copies strings, so free them */
+        sensors_applet_add_sensor(sensors_applet,
+            current_path = g_settings_get_string (settings, PATH),
+            current_id = g_settings_get_string (settings, ID),
+            current_label = g_settings_get_string (settings, LABEL),
+            current_interface = g_settings_get_string (settings, INTERFACE),
+            g_settings_get_int (settings, SENSOR_TYPE),
+            g_settings_get_boolean (settings, ENABLED),
+            g_settings_get_double (settings, LOW_VALUE),
+            g_settings_get_double (settings, HIGH_VALUE),
+            g_settings_get_boolean (settings, ALARM_ENABLED),
+            current_low_alarm_command = g_settings_get_string (settings, LOW_ALARM_COMMAND),
+            current_high_alarm_command = g_settings_get_string (settings, HIGH_ALARM_COMMAND),
+            g_settings_get_int (settings, ALARM_TIMEOUT),
+            g_settings_get_double (settings, MULTIPLIER),
+            g_settings_get_double (settings, OFFSET),
+            g_settings_get_int (settings, ICON_TYPE),
+            current_graph_color = g_settings_get_string (settings, GRAPH_COLOR));
+
+        g_free (current_path);
+        g_free (current_id);
+        g_free (current_label);
+        g_free (current_interface);
+        g_free (current_low_alarm_command);
+        g_free (current_high_alarm_command);
+        g_free (current_graph_color);
+
+        g_object_unref (settings);
+
+    }
+
+    g_free (applet_path);
+
+    return TRUE;
+}
+
+#ifdef SORT_DEBUG
+/* print a gtk_tree_store (for debug) */
+static void sensors_applet_settings_print_sensors_tree (SensorsApplet *sensors_applet) {
+
+    g_assert(sensors_applet);
+    g_assert(sensors_applet->sensors);
+
+    GtkTreeIter interfaces_iter;
+    GtkTreeIter sensors_iter;
+    gboolean not_end_of_interfaces = TRUE;
+    gboolean not_end_of_sensors = TRUE;<--- Variable 'not_end_of_sensors' is assigned a value that is never used.
+    gint interfaces_counter = 0;
+    gint sensors_counter = 0;
+
+    gchar *interface_name = NULL;
+    gchar *sensor_id = NULL;
+    gchar *sensor_path = NULL;
+    gchar *sensor_hash = NULL;
+
+    /* iterate through the sensor tree
+     * code from sensors-applet.c sensors_applet_add_sensor()
+     * first go through the interfaces */
+    for (not_end_of_interfaces = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter);
+        not_end_of_interfaces;
+        not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter), interfaces_counter++) {
+
+        /* get interface name */
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter, INTERFACE_COLUMN, &interface_name, -1);
+
+        /* print interface name */
+        syslog(LOG_ERR, "#%d interface name: %s\n", interfaces_counter, interface_name);
+
+        /* then go through the individual sensors under one interface */
+        for (not_end_of_sensors = gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,  &interfaces_iter);
+            not_end_of_sensors;
+            not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter), sensors_counter++) {
+
+            gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,
+                       PATH_COLUMN, &sensor_path,
+                       ID_COLUMN, &sensor_id,
+                       -1);
+
+            sensor_hash = sensors_applet_settings_get_unique_id (interface_name, sensor_id, sensor_path);
+
+            /* print sensor data */
+            syslog(LOG_ERR, "\t#%d sensor id: %s\n", sensors_counter, sensor_id);
+            syslog(LOG_ERR, "\t#%d sensor path: %s\n", sensors_counter, sensor_path);
+            syslog(LOG_ERR, "\t#%d sensor hash: %s\n\n", sensors_counter, sensor_hash);
+
+            g_free(sensor_id);
+            g_free(sensor_path);
+            g_free(sensor_hash);
+
+        }
+
+        g_free(interface_name);
+
+    }
+
+}
+#endif
+
+/* compare two iters using their paths
+ * kinda same as active_sensor_compare () */
+static gint sensors_applet_settings_sort_sensors_iter_compare (SensorsApplet *sensors_applet, GtkTreeIter ti_a, GtkTreeIter ti_b) {
+
+    GtkTreePath *tp_a;
+    GtkTreePath *tp_b;
+    gint ret_val;
+
+    tp_a = gtk_tree_model_get_path (GTK_TREE_MODEL(sensors_applet->sensors), &ti_a);
+    tp_b = gtk_tree_model_get_path (GTK_TREE_MODEL(sensors_applet->sensors), &ti_b);
+
+    ret_val = gtk_tree_path_compare(tp_a, tp_b);
+
+    gtk_tree_path_free(tp_a);
+    gtk_tree_path_free(tp_b);
+
+    return ret_val;
+}
+
+/* find two sensors in the sensors tree based on their hash and sort them
+ * Return codes:
+ * 0: something went very wrong...
+ * 1: normal run, a and b are in place
+ * 2: hash_b has already been removed from the system
+ * 3: hash_a is not found */
+static gint sensors_applet_settings_sort_sensors_sort (SensorsApplet *sensors_applet,
+                                                           const gchar *hash_a,
+                                                           const gchar *hash_b,
+                                                           gboolean a_is_first) {
+
+    g_assert(sensors_applet);
+    g_assert(sensors_applet->sensors);
+
+    GtkTreeIter interfaces_iter;
+    GtkTreeIter sensors_iter;
+    gboolean not_end_of_interfaces = TRUE;
+    gboolean not_end_of_sensors = TRUE;<--- Variable 'not_end_of_sensors' is assigned a value that is never used.
+
+    gchar *interface_name = NULL;
+    gchar *sensor_id = NULL;
+    gchar *sensor_path = NULL;
+    gchar *sensor_hash = NULL;
+
+    GtkTreeIter interface_iter_a;
+    GtkTreeIter interface_iter_b;
+    GtkTreeIter sensor_iter_a;
+    GtkTreeIter sensor_iter_b;
+    gboolean found_a = FALSE;
+    gboolean found_b = FALSE;
+
+    /* iterate through the sensor tree
+     * code from sensors-applet.c sensors_applet_add_sensor()
+     * first go through the interfaces */
+    for (not_end_of_interfaces = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter);
+        not_end_of_interfaces;
+        not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) {
+
+        /* get interface name */
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter, INTERFACE_COLUMN, &interface_name, -1);
+
+        /* then go through the individual sensors under one interface */
+        for (not_end_of_sensors = gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,  &interfaces_iter);
+            not_end_of_sensors;
+            not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) {
+
+            gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,
+                       PATH_COLUMN, &sensor_path,
+                       ID_COLUMN, &sensor_id,
+                       -1);
+
+            sensor_hash = sensors_applet_settings_get_unique_id (interface_name, sensor_id, sensor_path);
+
+            /* save interface_name and iters for swap */
+            if (g_ascii_strcasecmp(sensor_hash, hash_a) == 0) {
+                /* can copy by value, don't free */
+                interface_iter_a = interfaces_iter;
+                sensor_iter_a = sensors_iter;
+                found_a = TRUE;
+            }
+
+            if (g_ascii_strcasecmp(sensor_hash, hash_b) == 0) {
+                interface_iter_b = interfaces_iter;
+                sensor_iter_b = sensors_iter;
+                found_b = TRUE;
+            }
+
+            g_free(sensor_id);
+            g_free(sensor_path);
+            g_free(sensor_hash);
+
+            /* break after freeing loop variables */
+            if (found_a && found_b) {
+                break;
+            }
+        }
+
+        g_free(interface_name);
+
+        /* break after freeing loop variables */
+        if (found_a && found_b) {
+            break;
+        }
+    }
+
+    /* make the switch */
+    if (found_a && found_b) {
+
+        GtkTreeIter first_iter;
+        GtkTreeIter iter_next;
+
+        gint ret_val;
+
+        /* set a's interface to be the first interface in the sensors tree */
+        if (a_is_first) {
+
+            /* this 'fails' if the tree is empty, but this is already checked with the first loop */
+            gtk_tree_model_get_iter_first (GTK_TREE_MODEL(sensors_applet->sensors), &first_iter);
+
+            /* we are only interested in the case, where the two are not equal
+             * that means the a's interface is not the first interface */
+            if ( 0 != sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, first_iter, interface_iter_a)) {
+
+                /* it should be, so it needs to be moved to the first position */
+                gtk_tree_store_move_after (GTK_TREE_STORE(sensors_applet->sensors), &interface_iter_a, NULL);
+            }
+
+        }
+
+        /* check b's interface position
+         * (1) if it is before a's if. - not possible, bc I have just set a's if. as first
+         * afterwards every new if. will be set right after (one) a's if.
+         * (0) if it is the same as a's, noop
+         * (-1) if it is after a, check if it is right after a, if not move it there */
+        ret_val = sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, interface_iter_a, interface_iter_b);
+        if (-1 == ret_val) {
+
+            /* set iter_next to the iter after a's if. iter, can copy like this */
+            iter_next = interface_iter_a;
+            /* this 'fails' if there is no node after a's if. iter, but we already know, that at least b's if. iter is */
+            gtk_tree_model_iter_next (GTK_TREE_MODEL(sensors_applet->sensors), &iter_next);
+
+            /* the node right after a's if. iter is not b's if. iter, so move b's if. iter */
+            if (0 != sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, iter_next, interface_iter_b)) {
+
+                gtk_tree_store_move_after (GTK_TREE_STORE(sensors_applet->sensors), &interface_iter_b, &interface_iter_a);
+            }
+        }
+
+        /* at this point the interfaces are sorted, the sensors are next */
+        /* set a to be the first sensor in the sensors tree, under the first if. iter */
+        if (a_is_first) {
+
+            /* this 'fails' if the tree is empty, but at least a is in it */
+            gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &first_iter,  &interface_iter_a);
+
+            /* we are only interested in the case, where the two are not equal
+             * that means the a is not the first sensor */
+            if ( 0 != sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, first_iter, sensor_iter_a)) {
+
+                /* it should be, so it needs to be moved to the first position */
+                gtk_tree_store_move_after (GTK_TREE_STORE(sensors_applet->sensors), &sensor_iter_a, NULL);
+            }
+
+        }
+
+        /* check b's position
+         * if a's if. and b's if is the same
+         * (1) if it is before a's if. - not possible, bc I have just set a as first
+         * afterwards every new sensor will be set right after (one) a
+         * (0) if it is the same as a's, not possible, a and b would be equal
+         * (-1) if it is after a, check if it is right after a, if not move it there */
+        if (0 == ret_val && -1 == sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, sensor_iter_a, sensor_iter_b)) {
+
+            /* set iter_next to the iter after a's iter, can copy like this */
+            iter_next = sensor_iter_a;
+            /* this 'fails' if there is no node after a's iter, but we already know, that at least b's iter is */
+            gtk_tree_model_iter_next (GTK_TREE_MODEL(sensors_applet->sensors), &iter_next);
+
+            /* the node right after a's iter is not b's iter, so move b's iter */
+            if (0 != sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, iter_next, sensor_iter_b)) {
+
+                gtk_tree_store_move_after (GTK_TREE_STORE(sensors_applet->sensors), &sensor_iter_b, &sensor_iter_a);
+            }
+        }
+
+        /* if a's if. and b's if is not the same
+         * as b comes after a, b must be under a new if.
+         * and so b must be the first node under that if. */
+        /* set b to be the first sensor in the sensors tree, under the b's if. iter */
+        if (-1 == ret_val) {
+
+            /* this 'fails' if the tree is empty, but at least b is in it */
+            gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &first_iter,  &interface_iter_b);
+
+            /* we are only interested in the case, where the two are not equal
+             * that means the b is not the first sensor */
+            if ( 0 != sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, first_iter, sensor_iter_b)) {
+
+                /* it should be, so it needs to be moved to the first position */
+                gtk_tree_store_move_after (GTK_TREE_STORE(sensors_applet->sensors), &sensor_iter_b, NULL);
+            }
+
+        }
+
+        return 1;
+
+    }
+
+    /* hash_b has already been removed from the system */
+    if (found_a && !found_b) {
+        return 2;
+    }
+
+    /* this is the least likely case
+     * if hash_a is not found, then the sensors-list starts with a sensor
+     * that has already been removed from the system */
+    if (!found_a) {
+        return 3;
+    }
+
+    /* we should never get here */
+    return 0;
+}
+
+/* sort sensors based on sensors-list array in gsettings */
+gboolean sensors_applet_settings_sort_sensors (SensorsApplet *sensors_applet) {
+
+    gchar **sensors_list = NULL;
+
+    gchar *hash_a = NULL;
+    gchar *hash_b = NULL;
+
+    gint ret_val = -1;
+    /* marks the first iteration */
+    gint first_counter = 1;
+
+    /* get sensors-list array from gsettings
+     * newly allocated, has to be freed fully
+     * for an empty array a pointer to a NULL pointer will be returned (g_variant_dup_strv ()) */
+    sensors_list = g_settings_get_strv (sensors_applet->settings, "sensors-list");
+
+    /* list is empty (on the first run) */
+    if (NULL == *sensors_list) {
+        /* still need to free the array, even if it is empty */
+        g_strfreev (sensors_list);
+        return FALSE;
+    }
+
+    gint i;
+    /* hash lists are equal */
+    gboolean hle = TRUE;
+    /* compare saved sorted list to newly loaded sensors' list */
+    for (i = 0; (NULL != sensors_applet->sensors_hash_array[i]) && (NULL != sensors_list[i]); i++) {
+
+        if (g_ascii_strcasecmp(sensors_applet->sensors_hash_array[i], sensors_list[i]) != 0) {
+            hle = FALSE;
+            break;
+        }
+    }
+
+    /* lists are the same -> nothing to do */
+    if (hle) {
+#ifdef SORT_DEBUG
+        syslog(LOG_ERR, "sensor sort: saved list is the same as the new one, returning");
+#endif
+
+        /* still need to free the array */
+        g_strfreev (sensors_list);
+        return TRUE;
+    }
+
+#ifdef SORT_DEBUG
+    sensors_applet_settings_print_sensors_tree (sensors_applet);
+#endif
+
+    for (i = 0; NULL != sensors_list[i]; i++) {
+
+        /* first pass */
+        if (i == 0) {
+            /* make a copy */
+            hash_a = g_strdup (sensors_list[i]);
+            continue;
+        }
+
+        hash_b = g_strdup (sensors_list[i]);
+
+        /* now that we have two hashes, find the two corresponding sensors and sort them
+         * if i == 1, we have both a and b set, this is the first time calling this function */
+        ret_val = sensors_applet_settings_sort_sensors_sort (sensors_applet, hash_a, hash_b, (i == first_counter));
+
+        /* hash_b has already been removed from the system
+         * don't free hash_a, don't reassign hash_b
+         * as we already know that b is no longer in the system */
+        if (2 == ret_val) {
+            continue;
+        }
+
+        /* after sorting free hash_a (it should be in place) and reassign hash_b to hash_a */
+        g_free (hash_a);
+        hash_a = hash_b;
+
+        /* hash_a not found
+         * set hash_b as hash_a and set the first element counter
+         * (essentially skip the first element in the sensors-list array) */
+        if (3 == ret_val) {
+            first_counter++;
+        }
+    }
+
+#ifdef SORT_DEBUG
+    sensors_applet_settings_print_sensors_tree (sensors_applet);
+#endif
+
+    /* hash_a already freed
+     * only in the following case do we need to free it */
+    if (2 == ret_val) {
+        g_free (hash_a);
+    }
+    g_free (hash_b);
+
+    g_strfreev (sensors_list);
+
+    /* reorder active sensors based on reordered sensors tree */
+    sensors_applet_reorder_sensors (sensors_applet);
+
+    return TRUE;
+}
+
+/* save sensor data under a unique hash
+ * save sensor sort in an array, with above hash */
+gboolean sensors_applet_settings_save_sensors (SensorsApplet *sensors_applet) {
+
+    /* write everything to GSettings except VISIBLE and ALARM_TIMEOUT_INDEX
+     * for stepping through GtkTreeStore data structure */
+    GtkTreeIter interfaces_iter;
+    GtkTreeIter sensors_iter;
+    gboolean not_end_of_interfaces = TRUE;
+    gboolean not_end_of_sensors = TRUE;<--- Variable 'not_end_of_sensors' is assigned a value that is never used.
+    gchar *applet_path = NULL;
+
+    gchar *current_path = NULL;
+    gchar *current_id = NULL;
+    gchar *current_label = NULL;
+    gchar *current_interface = NULL;
+    gchar *current_low_alarm_command = NULL;
+    gchar *current_high_alarm_command = NULL;
+    gchar *current_graph_color = NULL;
+    gboolean current_enable,
+             current_alarm_enable;
+    gdouble current_low_value,
+            current_high_value,
+            current_multiplier,
+            current_offset;
+    guint current_alarm_timeout,
+          current_sensor_type,
+          current_icon_type;
+
+    /* data structure (array) to be able to save sensors list to gsettings */
+    GVariantBuilder builder;
+    g_variant_builder_init (&builder, G_VARIANT_TYPE (GSGVTSA));
+
+    applet_path = mate_panel_applet_get_preferences_path (sensors_applet->applet);
+
+    /* now step through the GtkTreeStore sensors to find which sensors are available / loaded */
+    for (not_end_of_interfaces = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter);
+        not_end_of_interfaces;
+        not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) {
+
+        for (not_end_of_sensors = gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter, &interfaces_iter);
+            not_end_of_sensors;
+            not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) {
+
+            gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors),
+                               &sensors_iter,
+                               PATH_COLUMN, &current_path,
+                               ID_COLUMN, &current_id,
+                               LABEL_COLUMN, &current_label,
+                               INTERFACE_COLUMN, &current_interface,
+                               SENSOR_TYPE_COLUMN, &current_sensor_type,
+                               ENABLE_COLUMN, &current_enable,
+                               LOW_VALUE_COLUMN, &current_low_value,
+                               HIGH_VALUE_COLUMN, &current_high_value,
+                               ALARM_ENABLE_COLUMN, &current_alarm_enable,
+                               LOW_ALARM_COMMAND_COLUMN, &current_low_alarm_command,
+                               HIGH_ALARM_COMMAND_COLUMN, &current_high_alarm_command,
+                               ALARM_TIMEOUT_COLUMN, &current_alarm_timeout,
+                               MULTIPLIER_COLUMN, &current_multiplier,
+                               OFFSET_COLUMN, &current_offset,
+                               ICON_TYPE_COLUMN, &current_icon_type,
+                               GRAPH_COLOR_COLUMN, &current_graph_color,
+                               -1);
+
+            /* GSettings unique id for one sensor data */
+            gchar *gsuid = sensors_applet_settings_get_unique_id (current_interface, current_id, current_path);
+
+            /* save sensor uid to gvariant array */
+            g_variant_builder_add(&builder,
+                GSGVTS,       /* must be related to the G_VARIANT_TYPE in init and gsettings schema */
+                gsuid);
+
+            /* save sensor data to gsettings individually
+             * g_strdup_printf doesn't free args!
+             * applet_path is freed at the end */
+            gchar *path = g_strdup_printf ("%s%s/", applet_path, gsuid);
+            g_free (gsuid);
+
+            GSettings *settings;
+            settings = g_settings_new_with_path ("org.mate.sensors-applet.sensor", path);
+            g_free (path);
+
+            /* wait until g_settings_apply() is called to save all changes at once to gsettings */
+            g_settings_delay (settings);
+            g_settings_set_string (settings, PATH, current_path);
+            g_settings_set_string (settings, ID, current_id);
+            g_settings_set_string (settings, LABEL, current_label);
+            g_settings_set_string (settings, INTERFACE, current_interface);
+            g_settings_set_int (settings, SENSOR_TYPE, current_sensor_type);
+            g_settings_set_boolean (settings, ENABLED, current_enable);
+            g_settings_set_double (settings, LOW_VALUE, current_low_value);
+            g_settings_set_double (settings, HIGH_VALUE, current_high_value);
+            g_settings_set_boolean (settings, ALARM_ENABLED, current_alarm_enable);
+            g_settings_set_string (settings, LOW_ALARM_COMMAND, current_low_alarm_command);
+            g_settings_set_string (settings, HIGH_ALARM_COMMAND, current_high_alarm_command);
+            g_settings_set_int (settings, ALARM_TIMEOUT, current_alarm_timeout);
+            g_settings_set_double (settings, MULTIPLIER, current_multiplier);
+            g_settings_set_double (settings, OFFSET, current_offset);
+            g_settings_set_int (settings, ICON_TYPE, current_icon_type);
+            g_settings_set_string (settings, GRAPH_COLOR, current_graph_color);
+            g_settings_apply (settings);
+            g_object_unref (settings);
+
+        }
+    }
+
+    /* save the sensor-list array to gsettings
+     * builder is freed by g_variant_builder_end()
+     * the gvariant returned from g_variant_builder_end() is floating, so it is freed by g_settings_set_value() */
+    g_settings_set_value (sensors_applet->settings, "sensors-list", g_variant_builder_end (&builder));
+
+    g_free (applet_path);
+
+    return TRUE;
+}
+
+
+ +
+ +
+ + diff --git a/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/5.html b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/5.html new file mode 100644 index 0000000..2a079e4 --- /dev/null +++ b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/5.html @@ -0,0 +1,2911 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+/** Contain the functions for operating on the SensorsApplet structure
+ *  (represents the applet itself, and its associated variables.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h>
+#include <glib/gprintf.h>
+#include <gio/gio.h>
+#include "sensors-applet.h"
+#include "active-sensor.h"
+#include "sensors-applet-settings.h"
+#include "sensors-applet-plugins.h"
+
+#ifdef HAVE_LIBNOTIFY
+#include "active-sensor-libnotify.h"
+#define DEFAULT_NOTIFY_TIMEOUT 3000
+#endif
+
+#include "prefs-dialog.h"
+#include "about-dialog.h"
+
+#define SENSORS_APPLET_MENU_FILE "SensorsApplet.xml"
+/* initially set as sensors_applet->size to ensure a real value is stored */
+#define DEFAULT_APPLET_SIZE 24
+#define COLUMN_SPACING 2
+#define ROW_SPACING 1
+
+/* builder for sensor sorting verification */
+static GVariantBuilder gvb_sensors_hash_list;
+
+/* callbacks for panel menu */
+static void prefs_cb(GtkAction *action, gpointer *data) {
+
+    SensorsApplet *sensors_applet;
+    sensors_applet = (SensorsApplet *)data;
+
+    if (sensors_applet->prefs_dialog) {
+        gtk_window_present(GTK_WINDOW(sensors_applet->prefs_dialog->dialog));
+        return;
+    }
+    prefs_dialog_open(sensors_applet);
+}
+
+static void about_cb(GtkAction *action, gpointer data) {
+    SensorsApplet *sensors_applet;
+    sensors_applet = (SensorsApplet *)data;
+
+    about_dialog_open(sensors_applet);
+}
+
+static void help_cb(GtkAction *action, gpointer data) {
+
+    GError *error = NULL;
+
+    gtk_show_uri_on_window(NULL, "help:mate-sensors-applet",
+
+        gtk_get_current_event_time(),
+        &error);
+
+    if (error) {
+        g_debug("Could not open help document: %s ",error->message);
+        g_error_free(error);
+    }
+}
+
+static void destroy_cb(GtkWidget *widget, gpointer data) {
+    SensorsApplet *sensors_applet;
+    sensors_applet = (SensorsApplet *)data;
+
+    /* destroy dialogs, remove timeout and clear sensors tree and finally the applet */
+    if (sensors_applet->prefs_dialog != NULL) {
+        /* destroy's dialog too */
+        prefs_dialog_close(sensors_applet);
+    }
+
+    if (sensors_applet->timeout_id) {
+        g_source_remove(sensors_applet->timeout_id);
+    }
+
+    if (sensors_applet->settings) {
+        g_object_unref (sensors_applet->settings);
+        sensors_applet->settings = NULL;
+    }
+
+    /* destroy all active sensors */
+    g_list_foreach(sensors_applet->active_sensors,
+                   (GFunc)active_sensor_destroy,
+                   NULL);
+
+    if (sensors_applet->sensors != NULL) {
+        gtk_tree_store_clear(sensors_applet->sensors);
+    }
+
+    gtk_widget_destroy(GTK_WIDGET(sensors_applet->applet));
+
+    g_free(sensors_applet);
+    return;
+}
+
+static void change_orient_cb (MatePanelApplet *applet,
+                              MatePanelAppletOrient orient,
+                              gpointer data) {
+
+    SensorsApplet *sensors_applet;
+    sensors_applet = (SensorsApplet *)data;
+
+    sensors_applet_display_layout_changed(sensors_applet);
+}
+
+static void size_allocate_cb(MatePanelApplet *applet,
+                             GtkAllocation *allocation,
+                             gpointer data) {
+
+    SensorsApplet *sensors_applet;
+    MatePanelAppletOrient orient;
+
+    sensors_applet = (SensorsApplet *)data;
+    orient = mate_panel_applet_get_orient(sensors_applet->applet);
+
+    if ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
+        (orient == MATE_PANEL_APPLET_ORIENT_RIGHT)) {
+
+        if (sensors_applet->size == allocation->width)
+            return;
+        sensors_applet->size = allocation->width;
+    } else {
+        if (sensors_applet->size == allocation->height)
+            return;
+        sensors_applet->size = allocation->height;
+    }
+
+    /* update if new value */
+    sensors_applet_graph_size_changed(sensors_applet);
+    sensors_applet_display_layout_changed(sensors_applet);
+}
+
+static void style_set_cb(GtkWidget *widget, GtkStyle *old_style, gpointer data) {
+
+    /* update all icons in the sensors tree and update all active sensors */
+    GtkTreeIter interfaces_iter, sensors_iter;
+    gboolean not_end_of_interfaces = TRUE, not_end_of_sensors = TRUE;<--- Variable 'not_end_of_sensors' is assigned a value that is never used.
+    IconType icon_type;
+    gboolean enabled;
+    SensorsApplet *sensors_applet;
+    DisplayMode display_mode;
+
+    sensors_applet = (SensorsApplet *)data;
+
+    display_mode = g_settings_get_int (sensors_applet->settings, DISPLAY_MODE);
+    if (sensors_applet->sensors) {
+        for (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter);
+            not_end_of_interfaces;
+            not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) {
+
+            /* reset sensors sentinel */
+            not_end_of_sensors = TRUE;
+
+            for (gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter, &interfaces_iter);
+                not_end_of_sensors;
+                not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) {
+
+                GdkPixbuf *new_icon;
+
+                gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors),
+                                   &sensors_iter,
+                                   ENABLE_COLUMN, &enabled,
+                                   ICON_TYPE_COLUMN, &icon_type,
+                                   -1);
+                /* update icons */
+                new_icon = sensors_applet_load_icon(icon_type);
+
+                gtk_tree_store_set(sensors_applet->sensors,
+                                   &sensors_iter,
+                                   ICON_PIXBUF_COLUMN, new_icon,
+                                   -1);
+                g_object_unref(new_icon);
+
+                /* update icons only if currently being displayed */
+                if (enabled &&
+                    (display_mode == DISPLAY_ICON ||
+                     display_mode == DISPLAY_ICON_WITH_VALUE)) {
+
+                    GtkTreePath *path;
+
+                    path = gtk_tree_model_get_path(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter);
+                    sensors_applet_icon_changed(sensors_applet, path);
+                    gtk_tree_path_free(path);
+                }
+            }
+        }
+        /* now update layout as size may have changed */
+        sensors_applet_display_layout_changed(sensors_applet);
+    }
+
+}
+
+static gboolean mouse_enter_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
+{
+    SensorsApplet *sensor_applet = data;
+    sensor_applet->show_tooltip = TRUE;
+    sensors_applet_update_active_sensors(sensor_applet);
+    return TRUE;
+}
+
+static gboolean mouse_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
+{
+    SensorsApplet *sensor_applet = data;
+    sensor_applet->show_tooltip = FALSE;
+    return TRUE;
+}
+
+static const GtkActionEntry sensors_applet_menu_actions[] = {
+    { "Preferences", "document-properties", N_("_Preferences"),
+        NULL, NULL,
+        G_CALLBACK(prefs_cb) },
+    { "Help", "help-browser", N_("_Help"),
+        NULL, NULL,
+        G_CALLBACK(help_cb) },
+    { "About", "help-about", N_("_About"),
+        NULL, NULL,
+        G_CALLBACK(about_cb) }
+};
+
+void sensors_applet_notify_active_sensor(ActiveSensor *active_sensor, NotifType notif_type) {
+#ifdef HAVE_LIBNOTIFY
+
+    SensorsApplet *sensors_applet;
+    gchar *summary, *message;
+    gint timeout_msecs;
+    gchar *sensor_label;
+    gchar *sensor_path;
+    SensorType sensor_type;
+    TemperatureScale temp_scale;
+    GtkTreeIter iter;
+    GtkTreePath *path;
+    const gchar *unit_type = NULL;
+    const gchar *unit_type_title = NULL;
+    const gchar *relation = NULL;
+    const gchar *limit_type = NULL;
+    const gchar *units = NULL;
+    gdouble limit_value;
+    gdouble seconds;
+    gboolean show_notification = TRUE;
+
+    sensors_applet = active_sensor->sensors_applet;
+
+    if (!g_settings_get_boolean (sensors_applet->settings, DISPLAY_NOTIFICATIONS)) {
+        g_debug("Wanted to display notification, but user has disabled them");
+        return;
+    }
+
+    path = gtk_tree_row_reference_get_path(active_sensor->sensor_row);
+    if (gtk_tree_model_get_iter(GTK_TREE_MODEL(sensors_applet->sensors), &iter, path)) {
+
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &iter,
+                           LABEL_COLUMN, &sensor_label,
+                           PATH_COLUMN, &sensor_path,
+                           SENSOR_TYPE_COLUMN, &sensor_type,
+                           -1);
+    } else {
+        g_warning("Error getting data from tree for notification...");
+        gtk_tree_path_free(path);
+        return;
+    }
+
+    gtk_tree_path_free(path);
+
+    /* do different stuff for different notif types */
+    switch (notif_type) {
+        case LOW_ALARM: /* fall thru */
+        case HIGH_ALARM:
+            if (active_sensor->sensor_values[0] <= active_sensor->sensor_low_value && notif_type == LOW_ALARM) {
+
+                relation = _("is very low");
+                limit_type = _("lower limit");
+                limit_value = active_sensor->sensor_low_value;
+            } else if (active_sensor->sensor_values[0] >= active_sensor->sensor_high_value && notif_type == HIGH_ALARM) {
+
+                /* assume high alarm condition */
+                relation = _("is very high");
+                limit_type = _("upper limit");
+                limit_value = active_sensor->sensor_high_value;
+            } else {
+                g_warning("Alarm notify called when no alarm condition!");
+                g_free(sensor_path);
+                g_free(sensor_label);
+                return;
+            }
+
+            switch ((SensorType)sensor_type) {
+                case TEMP_SENSOR:
+                    unit_type_title = _("Temperature");
+                    unit_type = _("temperature");
+                    temp_scale = (TemperatureScale) g_settings_get_int (active_sensor->sensors_applet->settings, TEMPERATURE_SCALE);
+
+                    switch (temp_scale) {
+                        case CELSIUS:
+                            units = UNITS_CELSIUS;
+                            break;
+                        case FAHRENHEIT:
+                            units = UNITS_FAHRENHEIT;
+                            break;
+                        case KELVIN:
+                            units = UNITS_KELVIN;
+                            break;
+                        default:
+                            units = NULL;
+                    }
+                    break;
+
+                case VOLTAGE_SENSOR:
+                    unit_type_title = _("Voltage");
+                    unit_type = _("voltage");
+                    units = UNITS_VOLTAGE;
+                    break;
+
+                case FAN_SENSOR:
+                    unit_type_title = _("Fan Speed");
+                    unit_type = _("fan speed");
+                    units = UNITS_RPM;
+                    break;
+
+                case CURRENT_SENSOR:
+                    unit_type_title = _("Current");
+                    unit_type = _("current");
+                    units = UNITS_CURRENT;
+                    break;
+            }
+
+            timeout_msecs = (active_sensor->alarm_timeout ? MIN(DEFAULT_NOTIFY_TIMEOUT, (active_sensor->alarm_timeout * 1000)) : DEFAULT_NOTIFY_TIMEOUT);
+
+            summary = g_strdup_printf("%s %s %s", sensor_label, unit_type_title, _("Alarm"));
+            message = g_strdup_printf("%s %s %s (%s %2.0f%s)", sensor_label, unit_type, relation, limit_type, limit_value, units);
+            break;
+
+        case SENSOR_INTERFACE_ERROR:
+            /* get time since the last error */
+            seconds = difftime(time(NULL), active_sensor->ierror_ts);
+
+            /* if the last error happened less than 10 seconds ago, don't display this one
+             * this should prevent recurring popups for removed sensors, like USB-HDDs */
+            if (seconds < 11.0) {
+                show_notification = FALSE;
+            }
+
+            summary = g_strdup_printf(_("Error updating sensor %s"), sensor_label);
+            message = g_strdup_printf(_("An error occurred while trying to update the value of the sensor %s located at %s."), sensor_label, sensor_path);
+            timeout_msecs = g_settings_get_int (active_sensor->sensors_applet->settings, TIMEOUT);
+
+            /* update timestamp */
+            time(&(active_sensor->ierror_ts));
+            break;
+
+        default:
+            g_assert_not_reached();
+    }
+
+    if (show_notification) {
+        active_sensor_libnotify_notify(active_sensor,
+                                       notif_type,
+                                       summary,
+                                       message,
+                                       "dialog-warning",
+                                       timeout_msecs);
+    }
+
+    g_free(sensor_path);
+    g_free(sensor_label);
+    g_free(summary);
+    g_free(message);
+#endif
+}
+
+void sensors_applet_notify_end(ActiveSensor *active_sensor, NotifType notif_type) {
+#ifdef HAVE_LIBNOTIFY
+    active_sensor_libnotify_notify_end(active_sensor, notif_type);
+#endif
+}
+
+#ifdef HAVE_LIBNOTIFY
+static void sensors_applet_notify_end_all_gfunc(ActiveSensor *active_sensor, gpointer data) {
+    active_sensor_libnotify_notify_end(active_sensor, LOW_ALARM);
+    active_sensor_libnotify_notify_end(active_sensor, HIGH_ALARM);
+}
+#endif
+
+void sensors_applet_notify_end_all(SensorsApplet *sensors_applet) {
+#ifdef HAVE_LIBNOTIFY
+    g_list_foreach(sensors_applet->active_sensors, (GFunc)sensors_applet_notify_end_all_gfunc, NULL);
+#endif
+}
+
+/* internal helper functions for updating display etc */
+
+/* should be called as a g_container_foreach at the start of
+ * pack_display if the grid already exists to remove but keep alive
+ * all children of the grid before repacking it */
+static void sensors_applet_pack_display_empty_grid_cb(GtkWidget *widget, gpointer data)
+{
+    GtkContainer *container;
+
+    container = GTK_CONTAINER(data);
+
+    /* ref then remove widget */
+    g_object_ref(widget);
+    gtk_container_remove(container, widget);
+}
+
+/* should be called as a g_container_foreach at the end of
+ * pack_display to unref any of the old children that we have readdded
+ * to the table to stop reference creep from the g_object_ref called
+ * on each child at the start of pack labels */
+static void sensors_applet_pack_display_cleanup_refs_cb(GtkWidget *widget, gpointer data) {
+
+    GList *old_children;
+
+    old_children = (GList *)data;
+    if (g_list_find(old_children, widget)) {
+        g_object_unref(widget);
+    }
+}
+
+static void sensors_applet_pack_display(SensorsApplet *sensors_applet) {
+    /* note the if () around each widget is to ensure we only
+     * operate on those that actually exist */
+    GtkLabel *no_sensors_enabled_label = NULL;
+    gint num_active_sensors = 0, num_sensors_per_group = 0, rows, cols, i, j;
+    GList *old_grid_children = NULL;
+
+    GList *current_sensor;
+
+    DisplayMode display_mode;
+    LayoutMode layout_mode;
+
+    gboolean horizontal;
+    gint label_width, icon_width, value_width;
+    gint label_height, icon_height, value_height;
+
+    GtkRequisition req;
+
+    ActiveSensor *first_sensor;
+
+    /* it is possible that there could be no active sensors so
+     * handle that case first - make sure we dont do a NULL
+     * pointer access first though */
+    if (sensors_applet->active_sensors == NULL || g_list_length(sensors_applet->active_sensors) == 0) {
+        g_debug("no active sensors to pack in grid");
+        no_sensors_enabled_label = g_object_new(GTK_TYPE_LABEL, "label", _("No sensors enabled!"), NULL);
+
+        if (sensors_applet->grid == NULL) {
+            /* only need 1 row and 1 col */
+            sensors_applet->grid = gtk_grid_new();
+            gtk_grid_set_column_spacing(GTK_GRID(sensors_applet->grid), COLUMN_SPACING);
+            gtk_grid_set_row_spacing(GTK_GRID(sensors_applet->grid), ROW_SPACING);
+            gtk_widget_set_halign(sensors_applet->grid, GTK_ALIGN_CENTER);
+            gtk_widget_set_valign(sensors_applet->grid, GTK_ALIGN_CENTER);
+            /* add grid to applet */
+            gtk_container_add(GTK_CONTAINER(sensors_applet->applet), sensors_applet->grid);
+        } else {
+            /* destroy existing widgets - could be an
+             * existing version of no sensors label - okay
+             * to just add again though if destroy first */
+            g_debug("destroying any existing widgets in container");
+            gtk_container_foreach(GTK_CONTAINER(sensors_applet->grid), (GtkCallback)gtk_widget_destroy, NULL);
+        }
+        g_debug("packing no sensors enabled label");
+        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                 GTK_WIDGET(no_sensors_enabled_label),
+                                 0, 0, 1, 1);
+        gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet));
+        return;
+    }
+    /* otherwise can acess active_sensors without any worries */
+    num_active_sensors = g_list_length(sensors_applet->active_sensors);
+
+    display_mode = (DisplayMode) g_settings_get_int (sensors_applet->settings, DISPLAY_MODE);
+    layout_mode = (LayoutMode) g_settings_get_int (sensors_applet->settings, LAYOUT_MODE);
+
+    horizontal = (((mate_panel_applet_get_orient(sensors_applet->applet) == MATE_PANEL_APPLET_ORIENT_UP) ||
+                  (mate_panel_applet_get_orient(sensors_applet->applet) == MATE_PANEL_APPLET_ORIENT_DOWN)));
+
+    /* figure out num rows / cols by how high / wide sensors
+     * labels / icons are and how much size we have to put them in */
+
+    /* get the first active sensor */
+    first_sensor = (ActiveSensor *)sensors_applet->active_sensors->data;
+
+    switch (display_mode) {
+        case DISPLAY_VALUE:
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->value), &req, NULL);
+            value_width = req.width + COLUMN_SPACING;
+            value_height = req.height + ROW_SPACING;
+
+            /* make sure all widths and heights are non zero,
+             * otherwise will get a divide by zero exception below
+             * - is a non critical error since can happen when
+             * elements first added to list, so simply return - is
+             * not a programming error */
+            if (value_width == 0 && value_height == 0) {
+                return;
+            }
+
+            num_sensors_per_group = (sensors_applet->size / (horizontal ? value_height : value_width));
+            break;
+
+        case DISPLAY_LABEL_WITH_VALUE:
+            /* even though we end up packing the event boxes into the
+             * panel, these dont give back request sizes, so need to ask
+             * widgets directly */
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->value), &req, NULL);
+
+            value_width = req.width + COLUMN_SPACING;
+            value_height = req.height + ROW_SPACING;
+
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->label), &req, NULL);
+            label_width = req.width + COLUMN_SPACING;
+            label_height = req.height + ROW_SPACING;
+
+            /* make sure all widths and heights are non zero, otherwise
+             * will get a divide by zero exception below
+             * - is a non critical error since can happen when
+             * elements first added to list, so simply return - is
+             * not a programming error */
+            if (!(label_width && label_height && value_width && value_height)) {
+                return;
+            }
+
+            switch (layout_mode) {
+                case VALUE_BESIDE_LABEL:
+                    num_sensors_per_group = (sensors_applet->size / (horizontal ? MAX(label_height, value_height) : (label_width + value_width)));
+                    break;
+                case VALUE_BELOW_LABEL:
+                    num_sensors_per_group = (sensors_applet->size / (horizontal ? (label_height + value_height) : MAX(label_width, value_width)));
+                    break;
+            }
+            break;
+
+        case DISPLAY_ICON_WITH_VALUE:
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->value), &req, NULL);
+            value_width = req.width + COLUMN_SPACING;
+            value_height = req.height + ROW_SPACING;
+
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->icon), &req, NULL);
+            icon_width = req.width + COLUMN_SPACING;
+            icon_height = req.height + ROW_SPACING;
+
+            if (!(icon_width && icon_height && value_width && value_height)) {
+                return;
+            }
+
+            switch (layout_mode) {
+                case VALUE_BESIDE_LABEL:
+                    num_sensors_per_group = (sensors_applet->size / (horizontal ? MAX(icon_height, value_height) : (icon_width + value_width)));
+                    break;
+
+                case VALUE_BELOW_LABEL:
+                    num_sensors_per_group = (sensors_applet->size / (horizontal ? (icon_height + value_height) : MAX(icon_width, value_width)));
+                    break;
+            }
+            break;
+
+        case DISPLAY_ICON:
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->icon), &req, NULL);
+            icon_width = req.width + COLUMN_SPACING;
+            icon_height = req.height + ROW_SPACING;
+
+            if (!(icon_width && icon_height)) {
+                return;
+            }
+
+            num_sensors_per_group = (sensors_applet->size / (horizontal ? icon_height : icon_width));
+            break;
+
+        case DISPLAY_GRAPH:
+            /* only show graphs in a line like System Monitor applet */
+            num_sensors_per_group = 1;
+            break;
+    }
+
+    /* ensure always atleast 1 sensor per group */
+    if (num_sensors_per_group < 1) {
+        /* force a better layout */
+        if (horizontal && layout_mode == VALUE_BELOW_LABEL) {
+            layout_mode = VALUE_BESIDE_LABEL;
+        } else if (!horizontal && layout_mode == VALUE_BESIDE_LABEL) {
+            layout_mode = VALUE_BELOW_LABEL;
+        }
+        num_sensors_per_group = 1;
+    }
+
+    if (horizontal) {
+        /* if oriented horizontally, want as many
+           sensors per column as user has defined, then
+           enough columns to hold all the widgets */
+        rows = num_sensors_per_group;
+        cols = num_active_sensors / num_sensors_per_group;
+        while (rows * cols < num_active_sensors || cols == 0) {
+            cols++;
+        }
+
+    } else {
+        /* if oriented vertically, want as many
+           sensors per row as user has defined, then
+           enough rows to hold all the widgets*/
+        cols = num_sensors_per_group;
+        rows = num_active_sensors / num_sensors_per_group;
+        while (rows * cols < num_active_sensors || rows == 0) {
+            rows++;
+        }
+
+    }
+
+    /* if displaying labels / icons and values need to modify
+       number of rows / colums to accomodate this */
+     if (display_mode == DISPLAY_LABEL_WITH_VALUE || display_mode == DISPLAY_ICON_WITH_VALUE) {
+         if (layout_mode == VALUE_BESIDE_LABEL) {
+             /* to display labels next to values need twice as many columns */
+             cols *= 2;
+         } else {
+             /* to display labels above values, we need twice as many rows as without */
+             rows *= 2;
+         }
+     }
+
+    if (sensors_applet->grid == NULL) {
+        /* create grid and add to applet */
+        sensors_applet->grid = gtk_grid_new();
+        gtk_grid_set_column_spacing(GTK_GRID(sensors_applet->grid), COLUMN_SPACING);
+        gtk_grid_set_row_spacing(GTK_GRID(sensors_applet->grid), ROW_SPACING);
+        gtk_widget_set_halign(sensors_applet->grid, GTK_ALIGN_CENTER);
+        gtk_widget_set_valign(sensors_applet->grid, GTK_ALIGN_CENTER);
+        gtk_container_add(GTK_CONTAINER(sensors_applet->applet), sensors_applet->grid);
+    } else {
+        /* remove all children if grid already exists so we can start again */
+        /* save a list of the old children for later */
+        old_grid_children = gtk_container_get_children(GTK_CONTAINER(sensors_applet->grid));
+
+        gtk_container_foreach(GTK_CONTAINER(sensors_applet->grid),
+                      sensors_applet_pack_display_empty_grid_cb,
+                      sensors_applet->grid);
+    }
+    /* pack icons / labels and values into grid */
+    current_sensor = sensors_applet->active_sensors;
+
+    /* if showing labels / icons and values, need to pack labels / icons these first */
+    if (display_mode == DISPLAY_ICON_WITH_VALUE || display_mode == DISPLAY_LABEL_WITH_VALUE) {
+        /* loop through columns */
+        for (i = 0; current_sensor != NULL && i < cols; /* increments depends on how we lay them out - see below */) {
+
+            /* loop through rows in a column */
+            for (j = 0; current_sensor && j < rows; /* see bottom of for loop*/) {
+                /* attach label / icon at this point */
+                if (display_mode == DISPLAY_ICON_WITH_VALUE) {
+                    if (((ActiveSensor *)(current_sensor->data))->icon) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->icon,
+                                        i, j, 1, 1);
+                    }
+                } else {
+                    if (((ActiveSensor *)(current_sensor->data))->label) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->label,
+                                        i, j, 1, 1);
+                    }
+                }
+                /* now attach sensor value to either row below or column next to */
+                if (layout_mode == VALUE_BESIDE_LABEL) {
+                    /* left align labels */
+                    if (((ActiveSensor *)(current_sensor->data))->icon) {
+                        gtk_widget_set_halign (((ActiveSensor *)(current_sensor->data))->icon, GTK_ALIGN_START);
+                        gtk_widget_set_valign (((ActiveSensor *)(current_sensor->data))->icon, GTK_ALIGN_CENTER);
+                    }
+                    if (((ActiveSensor *)(current_sensor->data))->label) {
+                        gtk_label_set_xalign (GTK_LABEL(((ActiveSensor *)(current_sensor->data))->label), 0);
+                        gtk_label_set_yalign (GTK_LABEL(((ActiveSensor *)(current_sensor->data))->label), 0.5);
+                    }
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_widget_set_halign (((ActiveSensor *)(current_sensor->data))->value, GTK_ALIGN_START);
+                        gtk_widget_set_valign (((ActiveSensor *)(current_sensor->data))->value, GTK_ALIGN_CENTER);
+                    }
+
+                     /* place value next to label */
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->value,
+                                        i + 1, j, 1, 1);
+                    }
+                    j++;
+                } else { /* place value below label */
+
+                    /* center align labels */
+                    if (((ActiveSensor *)(current_sensor->data))->icon) {
+                        gtk_widget_set_halign (((ActiveSensor *)(current_sensor->data))->icon, GTK_ALIGN_CENTER);
+                        gtk_widget_set_valign (((ActiveSensor *)(current_sensor->data))->icon, GTK_ALIGN_CENTER);
+                    }
+                    if (((ActiveSensor *)(current_sensor->data))->label) {
+                        gtk_label_set_xalign (GTK_LABEL(((ActiveSensor *)(current_sensor->data))->label), 0.5);
+                        gtk_label_set_yalign (GTK_LABEL(((ActiveSensor *)(current_sensor->data))->label), 0.5);
+                    }
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_widget_set_halign (((ActiveSensor *)(current_sensor->data))->value, GTK_ALIGN_CENTER);
+                        gtk_widget_set_valign (((ActiveSensor *)(current_sensor->data))->value, GTK_ALIGN_CENTER);
+                    }
+
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->value,
+                                        i, j + 1, 1, 1);
+                    }
+                    j += 2;
+                }
+                current_sensor = g_list_next(current_sensor);
+            } /* end row loop */
+
+            /* now increment column index as needed */
+            if (layout_mode == VALUE_BESIDE_LABEL) { /* place value next to label */
+                i += 2;
+            } else {
+                i++;
+            }
+        } /* end column loop    */
+
+    } else { /* not showing labels and icons with values, so just pack either only icons or values */
+        for (i = 0; current_sensor != NULL && i < cols; ++i) {
+            for (j = 0; current_sensor!= NULL && j < rows; ++j) {
+                if (display_mode == DISPLAY_VALUE) {
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->value,
+                                        i, j, 1, 1);
+                    }
+                } else if (display_mode == DISPLAY_ICON) {
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->icon,
+                                        i, j, 1, 1);
+                    }
+                } else if (display_mode == DISPLAY_GRAPH) {
+                    if (((ActiveSensor *)(current_sensor->data))->graph) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->graph_frame,
+                                        i, j, 1, 1);
+                    }
+                }
+
+                current_sensor = g_list_next(current_sensor);
+            }
+        }
+    }
+
+    if (old_grid_children != NULL) {
+        gtk_container_foreach(GTK_CONTAINER(sensors_applet->grid),
+                      sensors_applet_pack_display_cleanup_refs_cb,
+                      old_grid_children);
+        g_list_free(old_grid_children);
+    }
+    gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet));
+
+}
+
+/* must unref when done with returned pixbuf */
+GdkPixbuf *sensors_applet_load_icon(IconType icon_type) {
+    GtkIconTheme *icon_theme;
+    GdkPixbuf *icon = NULL;
+    GError *error = NULL;
+
+    /* try to load the icon */
+
+    /* not allowed to unref or ref icon_theme once we have it */
+    icon_theme = gtk_icon_theme_get_default();
+    icon = gtk_icon_theme_load_icon(icon_theme,
+                                    stock_icons[icon_type],
+                                    DEFAULT_ICON_SIZE,
+                                    GTK_ICON_LOOKUP_USE_BUILTIN,
+                                    &error);
+
+    if (error) {
+        g_warning ("Could not load icon: %s", error->message);
+        g_error_free(error);
+        error = NULL;
+
+        /* try again with default icon */
+        icon = gtk_icon_theme_load_icon(icon_theme,
+                                        "image-missing",
+                                        DEFAULT_ICON_SIZE,
+                                        GTK_ICON_LOOKUP_USE_BUILTIN,
+                                        &error);
+
+        if (error) {
+            /* this will quit sensors-applet but it is a pretty major error so may as well */
+            g_error("Could not load GTK_STOCK_MISSING_IMAGE - major error!!!: %s", error->message);
+            g_error_free(error);
+            error = NULL;
+        }
+
+    }
+    return icon;
+}
+
+// MUST FREE STRINGS AFTER CALLING THIS FUNCTION!!
+gboolean sensors_applet_add_sensor(SensorsApplet *sensors_applet,
+                                   const gchar *path,
+                                   const gchar *id,
+                                   const gchar *label,
+                                   const gchar *interface,
+                                   SensorType type,
+                                   gboolean enable,
+                                   gdouble low_value,
+                                   gdouble high_value,
+                                   gboolean alarm_enable,
+                                   const gchar *low_alarm_command,
+                                   const gchar *high_alarm_command,
+                                   gint alarm_timeout,
+                                   gdouble multiplier,
+                                   gdouble offset,
+                                   IconType icon_type,
+                                   const gchar *graph_color) {
+
+    GtkTreeIter interfaces_iter, sensors_iter;
+    gboolean not_empty_tree;
+
+    gchar *node_interface;
+    gboolean not_end_of_interfaces = TRUE, interface_exists = FALSE;
+    gboolean not_end_of_sensors = TRUE;<--- Variable 'not_end_of_sensors' is assigned a value that is never used.
+    gchar *sensor_id;
+    gchar *sensor_path;
+    SensorType sensor_type;
+    GdkPixbuf *icon;
+    GtkTreePath *tree_path;
+
+    g_assert(sensors_applet);
+
+    /* assume tree is not empty */
+    not_empty_tree = TRUE;<--- not_empty_tree is assigned
+
+    if (NULL == sensors_applet->sensors) {
+
+        sensors_applet->sensors = gtk_tree_store_new(N_COLUMNS,
+                                 G_TYPE_STRING, /* path */
+                                 G_TYPE_STRING, /* id */
+                                 G_TYPE_STRING, /* label */
+                                 G_TYPE_STRING, /* interface */
+                                 G_TYPE_UINT, /* sensor type */
+                                 G_TYPE_BOOLEAN, /* enable */
+                                 G_TYPE_BOOLEAN, /* visible */
+                                 G_TYPE_DOUBLE, /* low value */
+                                 G_TYPE_DOUBLE, /* high type */
+                                 G_TYPE_BOOLEAN, /* alarm enable */
+                                 G_TYPE_STRING, /* low alarm command */
+                                 G_TYPE_STRING, /* high alarm command */
+                                 G_TYPE_UINT, /* alarm timeout */
+                                 G_TYPE_DOUBLE, /* multiplier */
+                                 G_TYPE_DOUBLE, /* offset */
+                                 G_TYPE_UINT, /* icon type */
+                                 GDK_TYPE_PIXBUF, /* icon pixbuf */
+                                 G_TYPE_STRING); /* graph color */
+
+        g_debug("Sensor tree created.");
+
+        /* we know tree is actually empty since we just created it */
+        not_empty_tree = FALSE;<--- not_empty_tree is assigned
+    }
+
+    /* search sensor tree for the parent interface to place this sensor under */
+    for (not_empty_tree = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter);<--- not_empty_tree is overwritten<--- not_empty_tree is overwritten
+        not_empty_tree && not_end_of_interfaces && !interface_exists;
+        not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) {
+
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter, INTERFACE_COLUMN, &node_interface, -1);
+        if (g_ascii_strcasecmp(interface, node_interface) == 0) {
+            /* found interface in tree */
+            interface_exists = TRUE;
+
+            /* now see if this actual sensor already exists within this interface - don't want to add duplicates */
+            /* see if have children */
+            for (not_end_of_sensors = gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,  &interfaces_iter);
+                not_end_of_sensors;
+                not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) {
+
+                gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,
+                           PATH_COLUMN, &sensor_path,
+                           ID_COLUMN, &sensor_id,
+                           SENSOR_TYPE_COLUMN, &sensor_type,
+                           -1);
+                if (g_ascii_strcasecmp(sensor_id, id) == 0 && g_ascii_strcasecmp(sensor_path, path) == 0  && sensor_type == type) {
+                    /* sensor already exists so dont add a second time */
+                    g_debug("sensor with path: %s, id: %s already exists in tree, not adding a second time", sensor_path, sensor_id);
+                    g_free(sensor_id);
+                    g_free(sensor_path);
+                    g_free(node_interface);
+                    return FALSE;
+                }
+                g_free(sensor_id);
+                g_free(sensor_path);
+            }
+            g_free(node_interface);
+            break;
+        }
+        g_free(node_interface);
+    }
+
+    if (!interface_exists) {
+        /* add to required plugins hash table so we ensure this
+           plugin stays loaded to make sure we have a get sensor
+           value function if possible */
+        g_hash_table_insert(sensors_applet->required_plugins,
+                            g_strdup(interface),
+                            GINT_TO_POINTER(TRUE));
+        g_debug("added interface %s to required plugins", interface);
+
+        /* wasn't able to find interface root node so create it */
+        gtk_tree_store_append(sensors_applet->sensors,
+                      &interfaces_iter,
+                      NULL);
+
+        gtk_tree_store_set(sensors_applet->sensors,
+                   &interfaces_iter,
+                   ID_COLUMN, interface,
+                   INTERFACE_COLUMN, interface,
+                   VISIBLE_COLUMN, FALSE,
+                   -1);
+        g_debug("Added sensor interface %s to tree", interface);
+    }
+
+    /* then add sensor as a child under interface node - ie assume
+     * we either found it or created it - the inteface node that is */
+
+    /* for now just add sensors all in a single list */
+    gtk_tree_store_append(sensors_applet->sensors, &sensors_iter, &interfaces_iter);
+
+    /* if sensor is already in settings, load values from there */
+    gchar *applet_path = mate_panel_applet_get_preferences_path (sensors_applet->applet);
+    gchar *gsuid = sensors_applet_settings_get_unique_id (interface, id, path);
+    gchar *settings_path = g_strdup_printf ("%s%s/", applet_path, gsuid);
+    GSettings *settings = g_settings_new_with_path ("org.mate.sensors-applet.sensor", settings_path);
+
+    /* add hash to temp sorting list */
+    g_variant_builder_add (&gvb_sensors_hash_list, "s", gsuid);
+
+    g_free (applet_path);
+    g_free (gsuid);
+    g_free (settings_path);
+
+    gchar *settings_id = g_settings_get_string (settings, ID);
+
+    if (settings_id != NULL && settings_id[0] != '\0') {
+        enable = g_settings_get_boolean (settings, ENABLED);
+        icon = sensors_applet_load_icon(g_settings_get_int (settings, ICON_TYPE));
+        gtk_tree_store_set(sensors_applet->sensors,
+                           &sensors_iter,
+                           PATH_COLUMN, g_settings_get_string (settings, PATH),
+                           ID_COLUMN, settings_id,
+                           LABEL_COLUMN, g_settings_get_string (settings, LABEL),
+                           INTERFACE_COLUMN, g_settings_get_string (settings, INTERFACE),
+                           SENSOR_TYPE_COLUMN, g_settings_get_int (settings, SENSOR_TYPE),
+                           ENABLE_COLUMN, enable,
+                           VISIBLE_COLUMN, TRUE,
+                           LOW_VALUE_COLUMN, g_settings_get_double (settings, LOW_VALUE),
+                           HIGH_VALUE_COLUMN, g_settings_get_double (settings, HIGH_VALUE),
+                           ALARM_ENABLE_COLUMN, g_settings_get_boolean (settings, ALARM_ENABLED),
+                           ALARM_TIMEOUT_COLUMN, g_settings_get_int (settings, ALARM_TIMEOUT),
+                           LOW_ALARM_COMMAND_COLUMN, g_settings_get_string (settings, LOW_ALARM_COMMAND),
+                           HIGH_ALARM_COMMAND_COLUMN, g_settings_get_string (settings, HIGH_ALARM_COMMAND),
+                           MULTIPLIER_COLUMN, g_settings_get_double (settings, MULTIPLIER),
+                           OFFSET_COLUMN, g_settings_get_double (settings, OFFSET),
+                           ICON_TYPE_COLUMN, g_settings_get_int (settings, ICON_TYPE),
+                           ICON_PIXBUF_COLUMN, icon,
+                           GRAPH_COLOR_COLUMN, g_settings_get_string (settings, GRAPH_COLOR),
+                           -1);
+        g_free (settings_id);
+    } else {
+        icon = sensors_applet_load_icon(icon_type);
+        gtk_tree_store_set(sensors_applet->sensors,
+                           &sensors_iter,
+                           PATH_COLUMN, path,
+                           ID_COLUMN, id,
+                           LABEL_COLUMN, label,
+                           INTERFACE_COLUMN, interface,
+                           SENSOR_TYPE_COLUMN, type,
+                           ENABLE_COLUMN, enable,
+                           VISIBLE_COLUMN, TRUE,
+                           LOW_VALUE_COLUMN, low_value,
+                           HIGH_VALUE_COLUMN, high_value,
+                           ALARM_ENABLE_COLUMN, alarm_enable,
+                           ALARM_TIMEOUT_COLUMN, alarm_timeout,
+                           LOW_ALARM_COMMAND_COLUMN, low_alarm_command,
+                           HIGH_ALARM_COMMAND_COLUMN, high_alarm_command,
+                           MULTIPLIER_COLUMN, multiplier,
+                           OFFSET_COLUMN, offset,
+                           ICON_TYPE_COLUMN, icon_type,
+                           ICON_PIXBUF_COLUMN, icon,
+                           GRAPH_COLOR_COLUMN, graph_color,
+                           -1);
+    }
+    g_object_unref (settings);
+    g_debug("added sensor %s to tree", path);
+
+    /* remove reference to icon as tree now has ref */
+    g_object_unref(icon);
+
+    /* create the active sensor */
+    if (enable) {
+        tree_path = gtk_tree_model_get_path(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter);
+        sensors_applet_sensor_enabled(sensors_applet, tree_path);
+        gtk_tree_path_free(tree_path);
+    }
+    return TRUE;
+}
+
+static ActiveSensor *sensors_applet_find_active_sensor(SensorsApplet *sensors_applet, GtkTreePath *path) {
+    GtkTreePath *sensor_tree_path;
+    GList *current_sensor;
+
+    for (current_sensor = sensors_applet->active_sensors; current_sensor != NULL; current_sensor = g_list_next(current_sensor)) {
+        sensor_tree_path = gtk_tree_row_reference_get_path(((ActiveSensor *)(current_sensor->data))->sensor_row);
+
+        if (gtk_tree_path_compare(path, sensor_tree_path) == 0) {
+            gtk_tree_path_free(sensor_tree_path);
+            return ((ActiveSensor *)(current_sensor->data));
+        }
+        gtk_tree_path_free(sensor_tree_path);
+    }
+    return NULL;
+}
+
+/* path should be the full path to a file representing the sensor (eg
+ * /dev/hda or /sys/devices/platform/i2c-0/0-0290/temp1_input) */
+void sensors_applet_display_layout_changed(SensorsApplet *sensors_applet) {
+    /* update sensors since will need to update icons / graphs etc
+     * if weren't displayed before */
+    GList *list = NULL;
+    for (list = sensors_applet->active_sensors; list != NULL; list = list->next) {
+        ActiveSensor *as = (ActiveSensor *)list->data;
+        as->updated = FALSE;
+    }
+    sensors_applet_update_active_sensors(sensors_applet);
+    sensors_applet_pack_display(sensors_applet);
+}
+
+void sensors_applet_alarm_off(SensorsApplet *sensors_applet,
+                              GtkTreePath *path,
+                              NotifType notif_type) {
+    ActiveSensor *active_sensor;
+
+    if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) {
+        active_sensor_alarm_off(active_sensor, notif_type);
+    }
+}
+
+void sensors_applet_all_alarms_off(SensorsApplet *sensors_applet, GtkTreePath *path) {
+    sensors_applet_alarm_off(sensors_applet, path, LOW_ALARM);
+    sensors_applet_alarm_off(sensors_applet, path, HIGH_ALARM);
+}
+
+void sensors_applet_sensor_enabled(SensorsApplet *sensors_applet, GtkTreePath *path) {
+    ActiveSensor *active_sensor;
+
+    g_assert(sensors_applet);
+    g_assert(path);
+
+    active_sensor = active_sensor_new(sensors_applet, gtk_tree_row_reference_new(GTK_TREE_MODEL(sensors_applet->sensors), path));
+    active_sensor_update(active_sensor, sensors_applet);
+
+    /* keep list sorted */
+    sensors_applet->active_sensors = g_list_insert_sorted(sensors_applet->active_sensors,
+                                                              active_sensor,
+                                                              (GCompareFunc)active_sensor_compare);
+
+    sensors_applet_pack_display(sensors_applet);
+}
+
+void sensors_applet_reorder_sensors(SensorsApplet *sensors_applet) {
+    sensors_applet->active_sensors = g_list_sort(sensors_applet->active_sensors, (GCompareFunc)active_sensor_compare);
+
+    sensors_applet_pack_display(sensors_applet);
+}
+
+void sensors_applet_sensor_disabled(SensorsApplet *sensors_applet, GtkTreePath *path) {
+
+    ActiveSensor *active_sensor;
+
+    g_assert(sensors_applet);
+    g_assert(path);
+
+    if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) {
+        g_debug("Destroying active sensor...");
+
+        g_debug("-- removing from list...");
+        sensors_applet->active_sensors = g_list_remove(sensors_applet->active_sensors, active_sensor);
+        g_debug("-- repacking display....");
+        sensors_applet_pack_display(sensors_applet);
+
+        active_sensor_destroy(active_sensor);
+    }
+}
+
+void sensors_applet_update_sensor(SensorsApplet *sensors_applet, GtkTreePath *path) {
+    ActiveSensor *active_sensor;
+
+    g_assert(sensors_applet);
+    g_assert(path);
+
+    if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) {
+        active_sensor_update(active_sensor, sensors_applet);
+    }
+}
+
+void sensors_applet_icon_changed(SensorsApplet *sensors_applet, GtkTreePath *path) {
+    ActiveSensor *active_sensor;
+
+    g_assert(sensors_applet);
+    g_assert(path);
+
+    if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) {
+        active_sensor_icon_changed(active_sensor, sensors_applet);
+    }
+}
+
+/* Cycle thru ActiveSensors and update them all */
+gboolean sensors_applet_update_active_sensors(SensorsApplet *sensors_applet) {
+    g_assert(sensors_applet);
+
+    if (sensors_applet->active_sensors) {
+        g_list_foreach(sensors_applet->active_sensors,
+                       (GFunc)active_sensor_update,
+                       sensors_applet);
+        return TRUE;
+    }
+    return FALSE;
+}
+
+/* Cycle thru ActiveSensors and set new graph dimensions */
+void sensors_applet_graph_size_changed(SensorsApplet *sensors_applet) {
+    gint dimensions[2];
+    gint graph_size;
+    g_assert(sensors_applet);
+
+    if (sensors_applet->active_sensors) {
+
+        graph_size = g_settings_get_int (sensors_applet->settings, GRAPH_SIZE);
+        if (mate_panel_applet_get_orient(sensors_applet->applet) ==  MATE_PANEL_APPLET_ORIENT_UP ||
+            mate_panel_applet_get_orient(sensors_applet->applet) == MATE_PANEL_APPLET_ORIENT_DOWN) {
+
+            /* is horizontal so set graph_size as width */
+            dimensions[0] = graph_size;
+            dimensions[1] = sensors_applet->size;
+        } else {
+            dimensions[0] = sensors_applet->size;
+            dimensions[1] = graph_size;
+        }
+
+        g_list_foreach(sensors_applet->active_sensors,
+                       (GFunc)active_sensor_update_graph_dimensions,
+                       &dimensions);
+    }
+
+}
+
+gdouble sensors_applet_convert_temperature(gdouble value, TemperatureScale old, TemperatureScale new) {
+
+    switch (old) {
+        case KELVIN:
+            switch (new) {
+                case CELSIUS:
+                    value = value - 273.0;
+                    break;
+                case FAHRENHEIT:
+                    value = (9.0 * (value - 273) / 5.0) + 32.0;
+                    break;
+                case KELVIN:
+                    break;
+            }
+            break;
+
+        case CELSIUS:
+            switch (new) {
+                case FAHRENHEIT:
+                    value = (9.0 * value / 5.0) + 32.0;
+                    break;
+                case KELVIN:
+                    value = value + 273.0;
+                    break;
+                case CELSIUS:
+                    break;
+            }
+            break;
+
+        case FAHRENHEIT:
+            switch (new) {
+            case CELSIUS:
+                value = (5.0 * (value - 32.0) / 9.0);
+                break;
+            case KELVIN:
+                value = (5.0 * (value - 32.0) / 9.0) + 273.0;
+                break;
+            case FAHRENHEIT:
+                break;
+            }
+            break;
+    }
+    return value;
+}
+
+void sensors_applet_init(SensorsApplet *sensors_applet) {
+
+    g_assert(sensors_applet);
+    g_assert(sensors_applet->applet);
+
+    GtkActionGroup *action_group;
+    gchar *ui_path;
+
+    /* Have our background automatically painted. */
+    mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(sensors_applet->applet), GTK_WIDGET(sensors_applet->applet));
+
+    /* plugin functions are stored as name -> get_value_function pairs so
+     * use standard string functions on hash table */
+    sensors_applet->plugins = g_hash_table_new(g_str_hash, g_str_equal);
+
+    sensors_applet->required_plugins = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+
+    /* initialise size */
+    sensors_applet->size = DEFAULT_APPLET_SIZE;
+
+    mate_panel_applet_set_flags(sensors_applet->applet, MATE_PANEL_APPLET_EXPAND_MINOR);
+
+    g_signal_connect(sensors_applet->applet, "destroy",
+             G_CALLBACK(destroy_cb),
+             sensors_applet);
+
+    /* init gsettings */
+    sensors_applet->settings = mate_panel_applet_settings_new (sensors_applet->applet, "org.mate.sensors-applet");
+
+    /* set up builder for sorting verification */
+    g_variant_builder_init (&gvb_sensors_hash_list, G_VARIANT_TYPE ("as"));
+
+    /* set up / load sensors from the plugins */
+    sensors_applet_plugins_load_all(sensors_applet);
+
+    /* set sorting hash array */
+    GVariant *gv_temp = g_variant_builder_end (&gvb_sensors_hash_list);
+    sensors_applet->sensors_hash_array = g_variant_dup_strv (gv_temp, NULL);
+    g_variant_unref (gv_temp);
+
+    /* sort sensors based on saved sorting */
+    sensors_applet_settings_sort_sensors(sensors_applet);
+
+    /* free hash array */
+    g_strfreev (sensors_applet->sensors_hash_array);
+
+    /* should have created sensors tree above, but if have not was because we couldn't find any sensors */
+    if (NULL == sensors_applet->sensors) {
+        GtkWidget *label;
+        label = gtk_label_new(_("No sensors found!"));
+        gtk_container_add(GTK_CONTAINER(sensors_applet->applet), label);
+        gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet));
+        return;
+    }
+
+    /* only do menu and signal connections if sensors are found */
+    action_group = gtk_action_group_new ("Sensors Applet Actions");
+    gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+    gtk_action_group_add_actions (action_group,
+                                sensors_applet_menu_actions,
+                                G_N_ELEMENTS (sensors_applet_menu_actions),
+                                sensors_applet);
+    ui_path = g_build_filename (UIDIR, SENSORS_APPLET_MENU_FILE, NULL);
+    mate_panel_applet_setup_menu_from_file (sensors_applet->applet, ui_path, action_group);
+    g_free (ui_path);
+    g_object_unref (action_group);
+
+    g_signal_connect(sensors_applet->applet, "style-set",
+                     G_CALLBACK(style_set_cb),
+                     sensors_applet);
+
+    g_signal_connect(G_OBJECT(sensors_applet->applet), "change_orient",
+                      G_CALLBACK(change_orient_cb),
+                      sensors_applet);
+
+    g_signal_connect(G_OBJECT(sensors_applet->applet), "size_allocate",
+                      G_CALLBACK(size_allocate_cb),
+                      sensors_applet);
+
+    g_signal_connect(G_OBJECT(sensors_applet->applet), "leave_notify_event",
+                     G_CALLBACK(mouse_leave_cb),
+                     (gpointer)sensors_applet);
+
+    g_signal_connect(G_OBJECT(sensors_applet->applet), "enter_notify_event",
+                     G_CALLBACK(mouse_enter_cb),
+                     (gpointer)sensors_applet);
+
+    sensors_applet_update_active_sensors(sensors_applet);
+    sensors_applet_pack_display(sensors_applet);
+
+    sensors_applet->timeout_id = g_timeout_add_seconds(g_settings_get_int(sensors_applet->settings, TIMEOUT) / 1000,
+                                                           (GSourceFunc)sensors_applet_update_active_sensors,
+                                                           sensors_applet);
+    gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet));
+}
+
+
+ +
+ +
+ + diff --git a/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/index.html b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/index.html new file mode 100644 index 0000000..a225250 --- /dev/null +++ b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/index.html @@ -0,0 +1,232 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
plugins/libsensors/libsensors-plugin.c
176unreadVariable563styleVariable 'sensor_info' is assigned a value that is never used.
sensors-applet/active-sensor-libnotify.c
30constParameter398styleParameter 'notification' can be declared as pointer to const
sensors-applet/active-sensor.c
511variableScope398styleThe scope of the variable 'scale' can be reduced.
512variableScope398styleThe scope of the variable 'display_mode' can be reduced.
sensors-applet/sensor-config-dialog.c
38unusedStructMember563stylestruct member 'SensorConfigDialog::icon_type_combo_box_aligner' is never used.
43unusedStructMember563stylestruct member 'SensorConfigDialog::graph_color_button_aligner' is never used.
48unusedStructMember563stylestruct member 'SensorConfigDialog::multiplier_spinbutton_aligner' is never used.
48unusedStructMember563stylestruct member 'SensorConfigDialog::offset_spinbutton_aligner' is never used.
54unusedStructMember563stylestruct member 'SensorConfigDialog::low_value_spinbutton_aligner' is never used.
54unusedStructMember563stylestruct member 'SensorConfigDialog::high_value_spinbutton_aligner' is never used.
61unusedStructMember563stylestruct member 'SensorConfigDialog::alarm_timeout_spinbutton_aligner' is never used.
65unusedStructMember563stylestruct member 'SensorConfigDialog::alarm_enable_aligner' is never used.
285variableScope398styleThe scope of the variable 'icon_type' can be reduced.
sensors-applet/sensors-applet-settings.c
155unreadVariable563styleVariable 'not_end_of_sensors' is assigned a value that is never used.
243unreadVariable563styleVariable 'not_end_of_sensors' is assigned a value that is never used.
544unreadVariable563styleVariable 'not_end_of_sensors' is assigned a value that is never used.
sensors-applet/sensors-applet.c
167unreadVariable563styleVariable 'not_end_of_sensors' is assigned a value that is never used.
850unreadVariable563styleVariable 'not_end_of_sensors' is assigned a value that is never used.
855variableScope398styleThe scope of the variable 'tree_path' can be reduced.
891redundantAssignment563styleVariable 'not_empty_tree' is reassigned a value before the old one has been used.
891redundantAssignment563styleVariable 'not_empty_tree' is reassigned a value before the old one has been used.
1037variableScope398styleThe scope of the variable 'sensor_tree_path' can be reduced.
+
+ +
+ + diff --git a/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/stats.html b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/stats.html new file mode 100644 index 0000000..d353f32 --- /dev/null +++ b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/stats.html @@ -0,0 +1,172 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + + + +
+ + diff --git a/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/style.css b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-05-07-065914-3846-cppcheck@fc56df38106f_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} -- cgit v1.2.1