+static gboolean initial_window_show(gpointer data)
+{
+ struct ui_psensor *ui;
+
+ log_debug("initial_window_show()");
+
+ ui = (struct ui_psensor *)data;
+
+ log_debug("is_status_supported: %d", is_status_supported());
+ log_debug("is_appindicator_supported: %d",
+ is_appindicator_supported());
+ log_debug("hide_on_startup: %d", ui->config->hide_on_startup);
+
+ if (!ui->config->hide_on_startup
+ || (!is_appindicator_supported() && !is_status_supported()))
+ ui_window_show(ui);
+
+ ui_window_update(ui);
+
+ return FALSE;
+}
+
+static void log_glib_info()
+{
+ log_debug("Compiled with GLib %d.%d.%d",
+ GLIB_MAJOR_VERSION,
+ GLIB_MINOR_VERSION,
+ GLIB_MICRO_VERSION);
+
+ log_debug("Running with GLib %d.%d.%d",
+ glib_major_version,
+ glib_minor_version,
+ glib_micro_version);
+}
+
+static void cb_activate(GApplication *application,
+ gpointer data)
+{
+ ui_window_show((struct ui_psensor *)data);
+}
+
+/*
+ * Release memory for Valgrind.
+ */
+static void cleanup(struct ui_psensor *ui)
+{
+ pthread_mutex_lock(&ui->sensors_mutex);
+
+ log_debug("Cleanup...");
+
+ psensor_cleanup();
+
+#ifdef HAVE_NVIDIA
+ nvidia_cleanup();
+#endif
+#ifdef HAVE_LIBATIADL
+ amd_cleanup();
+#endif
+#ifdef HAVE_REMOTE_SUPPORT
+ rsensor_cleanup();
+#endif
+
+ psensor_list_free(ui->sensors);
+ ui->sensors = NULL;
+
+#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029)
+ ui_appindicator_cleanup();
+#endif
+
+ ui_status_cleanup();
+
+ pthread_mutex_unlock(&ui->sensors_mutex);
+
+ config_cleanup();
+
+ log_debug("Cleanup done, closing log");
+}
+
+/*
+ * Creates the list of sensors.
+ *
+ * 'url': remote psensor server url, null for local monitoring.
+ * 'use_libatasmart': whether the libatasmart must be used.
+ */
+static struct psensor **create_sensors_list(const char *url,
+ unsigned int use_libatasmart)
+{
+ struct psensor **sensors;
+
+ if (url) {
+#ifdef HAVE_REMOTE_SUPPORT
+ rsensor_init();
+ sensors = get_remote_sensors(url, 600);
+#else
+ log_err(_("Psensor has not been compiled with remote "
+ "sensor support."));
+ exit(EXIT_FAILURE);
+#endif
+ } else {
+ sensors = get_all_sensors(use_libatasmart, 600);
+#ifdef HAVE_NVIDIA
+ sensors = nvidia_psensor_list_add(sensors, 600);
+#endif
+#ifdef HAVE_LIBATIADL
+ sensors = amd_psensor_list_add(sensors, 600);
+#endif
+#ifdef HAVE_GTOP
+ sensors = cpu_psensor_list_add(sensors, 600);
+#endif
+ }
+
+ associate_preferences(sensors);
+ associate_colors(sensors);
+
+ return sensors;
+}
+