release x11 connection for nvidia when quitting psensor
[psensor.git] / src / main.c
index 3a092a8..b9c8473 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2010-2011 wpitchoune@gmail.com
+    Copyright (C) 2010-2011 jeanfi@gmail.com
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -33,7 +33,6 @@
 #include "config.h"
 
 #include "cfg.h"
-#include "hdd.h"
 #include "psensor.h"
 #include "graph.h"
 #include "ui.h"
@@ -70,7 +69,7 @@ static const char *program_name;
 void print_version()
 {
        printf("psensor %s\n", VERSION);
-       printf(_("Copyright (C) %s wpitchoune@gmail.com\n\
+       printf(_("Copyright (C) %s jeanfi@gmail.com\n\
 License GPLv2: GNU GPL version 2 or later \
 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n\
 This is free software: you are free to change and redistribute it.\n\
@@ -131,7 +130,6 @@ void update_psensor_measures(struct ui_psensor *ui)
        struct config *cfg = ui->config;
 
        while (1) {
-               /*gdk_threads_enter();*/
                g_mutex_lock(ui->sensors_mutex);
 
                if (!sensors)
@@ -147,7 +145,6 @@ void update_psensor_measures(struct ui_psensor *ui)
                nvidia_psensor_list_update(sensors);
 #endif
 
-               /*gdk_threads_leave();*/
                g_mutex_unlock(ui->sensors_mutex);
 
                sleep(cfg->sensor_update_interval);
@@ -164,18 +161,18 @@ gboolean ui_refresh_thread(gpointer data)
        cfg = ui->config;
 
        g_mutex_lock(ui->sensors_mutex);
-       /*gdk_threads_enter();*/
 
        graph_update(ui->sensors, ui->w_graph, ui->config);
 
-       ui_sensorlist_update(ui->ui_sensorlist);
+       ui_sensorlist_update(ui);
 
 #if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029)
        ui_appindicator_update(ui);
 #endif
 
 #ifdef HAVE_UNITY
-       ui_unity_launcher_entry_update(ui->sensors);
+       ui_unity_launcher_entry_update(ui->sensors,
+                                      !cfg->unity_launcher_count_disabled);
 #endif
 
        if (ui->graph_update_interval != cfg->graph_update_interval) {
@@ -184,7 +181,6 @@ gboolean ui_refresh_thread(gpointer data)
        }
 
        g_mutex_unlock(ui->sensors_mutex);
-       /*gdk_threads_leave();*/
 
        if (ret == FALSE)
                g_timeout_add(1000 * ui->graph_update_interval,
@@ -380,18 +376,16 @@ int main(int argc, char **argv)
        associate_cb_alarm_raised(ui.sensors, &ui);
 
        /* main window */
-       ui.main_window = ui_window_create(&ui);
-       ui.main_box = NULL;
+       ui_window_create(&ui);
+       ui.sensor_box = NULL;
 
        /* drawing box */
        ui.w_graph = ui_graph_create(&ui);
 
        /* sensor list */
-       ui.ui_sensorlist = ui_sensorlist_create(ui.sensors);
+       ui_sensorlist_create(&ui);
 
-       ui_main_box_create(&ui);
-
-       gtk_widget_show_all(ui.main_window);
+       ui_window_update(&ui);
 
        thread = g_thread_create((GThreadFunc) update_psensor_measures,
                                 &ui, TRUE, &error);
@@ -414,7 +408,9 @@ int main(int argc, char **argv)
 
        psensor_list_free(ui.sensors);
 
-       /* gdk_threads_leave(); */
+#ifdef HAVE_NVIDIA
+       nvidia_cleanup();
+#endif
 
        return 0;
 }