/*
- * Copyright (C) 2010-2013 jeanfi@gmail.com
+ * Copyright (C) 2010-2014 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
+#include <stdlib.h>
+
#include "cfg.h"
#include "slog.h"
#include "ui.h"
_("Psensor is a GTK+ application for monitoring hardware "
"sensors"),
"copyright",
- _("Copyright(c) 2010-2012\njeanfi@gmail.com"),
+ _("Copyright(c) 2010-2014\njeanfi@gmail.com"),
"logo-icon-name", "psensor",
"program-name", "Psensor",
"title", _("About Psensor"),
}
}
-static void on_slog_enabled_cb(GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+static void
+slog_enabled_cbk(GConfClient *client, guint id, GConfEntry *e, gpointer data)
{
struct ui_psensor *ui;
struct psensor **sensors;
pthread_mutex_t *mutex;
- ui = (struct ui_psensor *)user_data;
+ ui = (struct ui_psensor *)data;
sensors = ui->sensors;
mutex = &ui->sensors_mutex;
- log_debug("cbk_slog_enabled");
+ log_debug("slog_enabled_cbk");
if (is_slog_enabled())
slog_activate(NULL, sensors, mutex, config_get_slog_interval());
cfg->window_x,
cfg->window_y);
- config_slog_enabled_notify_add(on_slog_enabled_cb, ui);
+ config_slog_enabled_notify_add(slog_enabled_cbk, ui);
gtk_window_set_default_size(GTK_WINDOW(window),
cfg->window_w,
gtk_container_remove(GTK_CONTAINER(ui->sensor_box),
GTK_WIDGET(ui->sensors_scrolled_tree));
- gtk_container_remove(GTK_CONTAINER(ui->sensor_box),
- ui->w_graph);
+ gtk_container_remove(GTK_CONTAINER(ui->sensor_box), ui->w_graph);
gtk_container_remove(GTK_CONTAINER(ui->main_box),
GTK_WIDGET(ui->sensor_box));
ui_window_update(ui);
gtk_window_present(GTK_WINDOW(ui->main_window));
}
+
+static int cmp_sensors(const void *p1, const void *p2)
+{
+ const struct psensor *s1, *s2;
+ int pos1, pos2;
+
+ s1 = *(void **)p1;
+ s2 = *(void **)p2;
+
+ pos1 = config_get_sensor_position(s1->id);
+ pos2 = config_get_sensor_position(s2->id);
+
+ return pos1 - pos2;
+}
+
+struct psensor **ui_get_sensors_ordered_by_position(const struct ui_psensor *ui)
+{
+ struct psensor **result;
+
+ result = psensor_list_copy(ui->sensors);
+ qsort(result,
+ psensor_list_size(result),
+ sizeof(struct psensor *),
+ cmp_sensors);
+
+ return result;
+}