Added tooltip explaining why a setting is not available
[psensor.git] / src / main.c
index 804b8a8..461949f 100644 (file)
@@ -154,8 +154,6 @@ static void *update_measures(void *data)
 
                update_psensor_values_size(sensors, cfg);
 
-               psensor_list_update_measures(sensors);
-
                lmsensor_psensor_list_update(sensors);
 #ifdef HAVE_REMOTE_SUPPORT
                remote_psensor_list_update(sensors);
@@ -263,29 +261,47 @@ static void cb_alarm_raised(struct psensor *sensor, void *data)
 
 static void associate_colors(struct psensor **sensors)
 {
-       /* number of uniq colors */
-#define COLORS_COUNT 8
-
-       double colors[COLORS_COUNT][3] = {
-               {0, 0, 0},      /* black */
-               {1, 0, 0},      /* red */
-               {0, 0, 1},      /* blue */
-               {0, 1, 0},      /* green */
-
-               {0.5, 0.5, 0.5},/* grey */
-               {0.5, 0, 0},    /* dark red */
-               {0, 0, 0.5},    /* dark blue */
-               {0, 0.5, 0}     /* dark green */
+       GdkRGBA rgba;
+       /* copied from the default colors of the gtk color color
+        * chooser. */
+       const char *default_colors[27] = {
+               "#ef2929",  /* Scarlet Red */
+               "#fcaf3e",  /* Orange */
+               "#fce94f",  /* Butter */
+               "#8ae234",  /* Chameleon */
+               "#729fcf",  /* Sky Blue */
+               "#ad7fa8",  /* Plum */
+               "#e9b96e",  /* Chocolate */
+               "#888a85",  /* Aluminum 1 */
+               "#eeeeec",  /* Aluminum 2 */
+               "#cc0000",
+               "#f57900",
+               "#edd400",
+               "#73d216",
+               "#3465a4",
+               "#75507b",
+               "#c17d11",
+               "#555753",
+               "#d3d7cf",
+               "#a40000",
+               "#ce5c00",
+               "#c4a000",
+               "#4e9a06",
+               "#204a87",
+               "#5c3566",
+               "#8f5902",
+               "#2e3436",
+               "#babdb6"
        };
-       struct psensor **cur;
        int i;
+       struct psensor **cur;
        struct color c;
 
        for (cur = sensors, i = 0; *cur; cur++, i++) {
-               color_set(&c,
-                         colors[i % COLORS_COUNT][0],
-                         colors[i % COLORS_COUNT][1],
-                         colors[i % COLORS_COUNT][2]);
+               gdk_rgba_parse(&rgba, default_colors[i % 27]);
+               c.red = rgba.red;
+               c.green = rgba.green;
+               c.blue = rgba.blue;
 
                (*cur)->color = config_get_sensor_color((*cur)->id, &c);
        }
@@ -414,8 +430,6 @@ static void cleanup(struct ui_psensor *ui)
 
        log_debug("Cleanup...");
 
-       psensor_cleanup();
-
 #ifdef HAVE_NVIDIA
        nvidia_cleanup();
 #endif
@@ -505,7 +519,7 @@ int main(int argc, char **argv)
        pthread_t thread;
        int optc, cmdok, opti, new_instance, ret;
        char *url = NULL;
-       GApplication *app;
+       GtkApplication *app;
 
        program_name = argv[0];
 
@@ -553,12 +567,12 @@ int main(int argc, char **argv)
 
        log_init();
 
-       app = g_application_new("wpitchoune.psensor", 0);
+       app = gtk_application_new("wpitchoune.psensor", G_APPLICATION_IS_SERVICE);
 
-       g_application_register(app, NULL, NULL);
+       printf("%d\n",g_application_register(G_APPLICATION(app), NULL, NULL));
 
-       if (!new_instance && g_application_get_is_remote(app)) {
-               g_application_activate(app);
+       if (!new_instance && g_application_get_is_remote(G_APPLICATION(app))) {
+               g_application_activate(G_APPLICATION(app));
                log_warn(_("A Psensor instance already exists."));
                exit(EXIT_SUCCESS);
        }
@@ -592,8 +606,6 @@ int main(int argc, char **argv)
 
        ui.config = config_load();
 
-       psensor_init();
-
        ui.sensors = create_sensors_list(url);
        associate_cb_alarm_raised(ui.sensors, &ui);