diff options
author | Stefano Karapetsas <[email protected]> | 2013-04-15 12:27:12 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2013-04-15 12:27:12 +0200 |
commit | 766a637d6e3616684f8b49b2f1b8c474ae0ec161 (patch) | |
tree | b30c66819bce58c2b6dfcfbfd26692c2946c736e /sensors-applet | |
parent | 7b4e983c4cfb5486e19db2cd45c867df694997a3 (diff) | |
download | mate-sensors-applet-766a637d6e3616684f8b49b2f1b8c474ae0ec161.tar.bz2 mate-sensors-applet-766a637d6e3616684f8b49b2f1b8c474ae0ec161.tar.xz |
Fix indentation
Added updated copyright info
Diffstat (limited to 'sensors-applet')
-rw-r--r-- | sensors-applet/sensors-applet-settings.c | 220 | ||||
-rw-r--r-- | sensors-applet/sensors-applet-settings.h | 49 |
2 files changed, 139 insertions, 130 deletions
diff --git a/sensors-applet/sensors-applet-settings.c b/sensors-applet/sensors-applet-settings.c index c725673..729a3e9 100644 --- a/sensors-applet/sensors-applet-settings.c +++ b/sensors-applet/sensors-applet-settings.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2009 Alex Murray <[email protected]> + * 2013 Stefano Karapetsas <[email protected]> * * 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 @@ -26,118 +27,125 @@ #include "sensors-applet-settings.h" gchar* sensors_applet_settings_get_unique_id (const gchar *interface, const gchar *id, const gchar *path) { - gchar *unique_id; - gchar *unique_id_hash; - GChecksum *checksum; - guint8 digest[16]; - gsize digest_len = sizeof (digest); + gchar *unique_id; + gchar *unique_id_hash; + GChecksum *checksum; + guint8 digest[16]; + gsize digest_len = sizeof (digest); - unique_id = g_strdup_printf ("%s/%s/%s", interface, id, path); + 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); + 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)); + unique_id_hash = g_strdup (g_checksum_get_string (checksum)); - g_checksum_free (checksum); - g_free (unique_id); + g_checksum_free (checksum); + g_free (unique_id); - return unique_id_hash; + return unique_id_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, sensors_iter; - gboolean not_end_of_interfaces = TRUE, not_end_of_sensors = TRUE; - gchar *applet_path; - - int i; - gchar *current_path, *current_id, *current_label, *current_interface, - *current_low_alarm_command, *current_high_alarm_command, - *current_graph_color; - 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; - - applet_path = mate_panel_applet_get_preferences_path (sensors_applet->applet); - - /* now step through the GtkTreeStore sensors to - find which sensors are enabled */ - 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)) { - gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), - &interfaces_iter, - ID_COLUMN, ¤t_id, - -1); - - //mate_panel_applet_mateconf_set_bool(sensors_applet->applet, current_id, TRUE, NULL); - g_free(current_id); - - /* 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)) { - gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), - &sensors_iter, - PATH_COLUMN, ¤t_path, - ID_COLUMN, ¤t_id, - LABEL_COLUMN, ¤t_label, - INTERFACE_COLUMN, ¤t_interface, - SENSOR_TYPE_COLUMN, ¤t_sensor_type, - ENABLE_COLUMN, ¤t_enable, - LOW_VALUE_COLUMN, ¤t_low_value, - HIGH_VALUE_COLUMN, ¤t_high_value, - ALARM_ENABLE_COLUMN, ¤t_alarm_enable, - LOW_ALARM_COMMAND_COLUMN, ¤t_low_alarm_command, - HIGH_ALARM_COMMAND_COLUMN, ¤t_high_alarm_command, - ALARM_TIMEOUT_COLUMN, ¤t_alarm_timeout, - MULTIPLIER_COLUMN, ¤t_multiplier, - OFFSET_COLUMN, ¤t_offset, - ICON_TYPE_COLUMN, ¤t_icon_type, - GRAPH_COLOR_COLUMN, ¤t_graph_color, - -1); - - gchar *path = g_strdup_printf ("%s%s/", - applet_path, - sensors_applet_settings_get_unique_id (current_interface, - current_id, - current_path)); - - GSettings *settings; - settings = g_settings_new_with_path ("org.mate.sensors-applet.sensor", - path); - g_free (path); - - 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); - - } - } - - g_free (applet_path); - - return TRUE; +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, sensors_iter; + gboolean not_end_of_interfaces = TRUE, not_end_of_sensors = TRUE; + gchar *applet_path; + + int i; + gchar *current_path, + *current_id, + *current_label, + *current_interface, + *current_low_alarm_command, + *current_high_alarm_command, + *current_graph_color; + 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; + + applet_path = mate_panel_applet_get_preferences_path (sensors_applet->applet); + + /* now step through the GtkTreeStore sensors to + find which sensors are enabled */ + 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)) { + gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), + &interfaces_iter, + ID_COLUMN, ¤t_id, + -1); + + //mate_panel_applet_mateconf_set_bool(sensors_applet->applet, current_id, TRUE, NULL); + g_free(current_id); + + /* 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)) { + gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), + &sensors_iter, + PATH_COLUMN, ¤t_path, + ID_COLUMN, ¤t_id, + LABEL_COLUMN, ¤t_label, + INTERFACE_COLUMN, ¤t_interface, + SENSOR_TYPE_COLUMN, ¤t_sensor_type, + ENABLE_COLUMN, ¤t_enable, + LOW_VALUE_COLUMN, ¤t_low_value, + HIGH_VALUE_COLUMN, ¤t_high_value, + ALARM_ENABLE_COLUMN, ¤t_alarm_enable, + LOW_ALARM_COMMAND_COLUMN, ¤t_low_alarm_command, + HIGH_ALARM_COMMAND_COLUMN, ¤t_high_alarm_command, + ALARM_TIMEOUT_COLUMN, ¤t_alarm_timeout, + MULTIPLIER_COLUMN, ¤t_multiplier, + OFFSET_COLUMN, ¤t_offset, + ICON_TYPE_COLUMN, ¤t_icon_type, + GRAPH_COLOR_COLUMN, ¤t_graph_color, + -1); + + gchar *path = g_strdup_printf ("%s%s/", + applet_path, + sensors_applet_settings_get_unique_id (current_interface, + current_id, + current_path)); + + GSettings *settings; + settings = g_settings_new_with_path ("org.mate.sensors-applet.sensor", path); + g_free (path); + + 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); + + } + } + + g_free (applet_path); + + return TRUE; } diff --git a/sensors-applet/sensors-applet-settings.h b/sensors-applet/sensors-applet-settings.h index 89f6ce0..fb7a13e 100644 --- a/sensors-applet/sensors-applet-settings.h +++ b/sensors-applet/sensors-applet-settings.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2009 Alex Murray <[email protected]> + * 2013 Stefano Karapetsas <[email protected]> * * 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 @@ -23,32 +24,32 @@ #include <mate-panel-applet.h> #include <mate-panel-applet-gsettings.h> -#define FONT_SIZE "font-size" -#define HIDE_UNITS "hide-units" -#define DISPLAY_MODE "display-mode" -#define LAYOUT_MODE "layout-mode" -#define TEMPERATURE_SCALE "temperature-scale" +#define FONT_SIZE "font-size" +#define HIDE_UNITS "hide-units" +#define DISPLAY_MODE "display-mode" +#define LAYOUT_MODE "layout-mode" +#define TEMPERATURE_SCALE "temperature-scale" #define DISPLAY_NOTIFICATIONS "display-notifications" -#define TIMEOUT "timeout-delay" -#define GRAPH_SIZE "graph-size" -#define SENSORS_LIST "sensors-list" +#define TIMEOUT "timeout-delay" +#define GRAPH_SIZE "graph-size" +#define SENSORS_LIST "sensors-list" -#define PATH "path" -#define ID "id" -#define INTERFACE "interface" -#define LABEL "label" -#define ENABLED "enabled" -#define LOW_VALUE "low-value" -#define HIGH_VALUE "high-value" -#define ALARM_ENABLED "alarm-enabled" -#define LOW_ALARM_COMMAND "low-alarm-command" -#define HIGH_ALARM_COMMAND "high-alarm-command" -#define ALARM_TIMEOUT "alarm-timeout" -#define SENSOR_TYPE "sensor-type" -#define MULTIPLIER "multiplier" -#define OFFSET "offset" -#define ICON_TYPE "icon-type" -#define GRAPH_COLOR "graph-color" +#define PATH "path" +#define ID "id" +#define INTERFACE "interface" +#define LABEL "label" +#define ENABLED "enabled" +#define LOW_VALUE "low-value" +#define HIGH_VALUE "high-value" +#define ALARM_ENABLED "alarm-enabled" +#define LOW_ALARM_COMMAND "low-alarm-command" +#define HIGH_ALARM_COMMAND "high-alarm-command" +#define ALARM_TIMEOUT "alarm-timeout" +#define SENSOR_TYPE "sensor-type" +#define MULTIPLIER "multiplier" +#define OFFSET "offset" +#define ICON_TYPE "icon-type" +#define GRAPH_COLOR "graph-color" gchar* sensors_applet_settings_get_unique_id (const gchar *interface, const gchar *id, const gchar *path); gboolean sensors_applet_settings_save_sensors(SensorsApplet *sensors_applet); |