summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfo-cppsp <[email protected]>2017-11-18 16:22:23 +0100
committerraveit65 <[email protected]>2017-11-26 20:41:43 +0100
commit287eeb06149861d8a56de73b2c897ebac95e48b0 (patch)
tree79058b9df4aadc78ba9e737be8ca33826c032384
parentb678af6c09b45c7dd2488972ec78a8d86b34a206 (diff)
downloadmate-sensors-applet-287eeb06149861d8a56de73b2c897ebac95e48b0.tar.bz2
mate-sensors-applet-287eeb06149861d8a56de73b2c897ebac95e48b0.tar.xz
Fix indents 05
-rw-r--r--lib/sensors-applet-plugin.c181
-rw-r--r--sensors-applet/sensors-applet-plugin.h10
-rw-r--r--sensors-applet/sensors-applet-plugins.c215
-rw-r--r--sensors-applet/sensors-applet-plugins.h4
4 files changed, 193 insertions, 217 deletions
diff --git a/lib/sensors-applet-plugin.c b/lib/sensors-applet-plugin.c
index db0cfdd..96b47c6 100644
--- a/lib/sensors-applet-plugin.c
+++ b/lib/sensors-applet-plugin.c
@@ -32,68 +32,65 @@ extern const gchar *plugin_name;
void sensors_applet_plugin_find_sensors(GList **sensors,
const gchar *path,
SensorsAppletPluginTestSensorFunc test_sensor) {
- GDir *dir;
- const gchar* new_file;
- gchar *new_path;
-
- if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
- /* also test can actually open file for
- reading */
- if (access(path, R_OK) == 0) {
- test_sensor(sensors, path);
- }
-
- }
- /* if is a directory (but not a symlinked dir as this
- will lead us in circular loops) descend into it and look
- for a sensor dir
- */
- if (g_file_test(path, G_FILE_TEST_IS_DIR) && !g_file_test(path, G_FILE_TEST_IS_SYMLINK)) {
- dir = g_dir_open(path, 0, NULL);
- if (dir != NULL) {
- while(NULL != (new_file = g_dir_read_name(dir))) {
- new_path = g_build_filename(path, new_file, NULL);
- sensors_applet_plugin_find_sensors(sensors,
- new_path,
- test_sensor);
- g_free(new_path);
- }
- g_dir_close(dir);
- }
- }
+ GDir *dir;
+ const gchar* new_file;
+ gchar *new_path;
+
+ if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
+ /* also test can actually open file for reading */
+ if (access(path, R_OK) == 0) {
+ test_sensor(sensors, path);
+ }
+ }
+
+ /* if is a directory (but not a symlinked dir as this
+ will lead us in circular loops) descend into it and look
+ for a sensor dir
+ */
+ if (g_file_test(path, G_FILE_TEST_IS_DIR) && !g_file_test(path, G_FILE_TEST_IS_SYMLINK)) {
+ dir = g_dir_open(path, 0, NULL);
+ if (dir != NULL) {
+ while(NULL != (new_file = g_dir_read_name(dir))) {
+ new_path = g_build_filename(path, new_file, NULL);
+ sensors_applet_plugin_find_sensors(sensors, new_path, test_sensor);
+ g_free(new_path);
+ }
+ g_dir_close(dir);
+ }
+ }
}
/* for error handling */
GQuark sensors_applet_plugin_error_quark(void) {
- static GQuark quark = 0;
- gchar *string;
-
- if (quark == 0) {
- string = g_strdup_printf("%s-plugin-error", plugin_name);
- quark = g_quark_from_string(string);
- g_free(string);
- }
-
- return quark;
+ static GQuark quark = 0;
+ gchar *string;
+
+ if (quark == 0) {
+ string = g_strdup_printf("%s-plugin-error", plugin_name);
+ quark = g_quark_from_string(string);
+ g_free(string);
+ }
+
+ return quark;
}
-void sensors_applet_plugin_default_sensor_limits(SensorType type,
- gdouble *low_value,
- gdouble *high_value)
-{
- switch (type) {
- case TEMP_SENSOR:
- *low_value = 20.0;
- *high_value = 60.0;
- break;
- case FAN_SENSOR:
- *low_value = 600.0;
- *high_value = 3000.0;
- break;
- default:
- *low_value = 0.0;
- *high_value = 0.0;
- }
+void sensors_applet_plugin_default_sensor_limits(SensorType type,
+ gdouble *low_value,
+ gdouble *high_value) {
+
+ switch (type) {
+ case TEMP_SENSOR:
+ *low_value = 20.0;
+ *high_value = 60.0;
+ break;
+ case FAN_SENSOR:
+ *low_value = 600.0;
+ *high_value = 3000.0;
+ break;
+ default:
+ *low_value = 0.0;
+ *high_value = 0.0;
+ }
}
void sensors_applet_plugin_add_sensor(GList **sensors,
@@ -103,24 +100,22 @@ void sensors_applet_plugin_add_sensor(GList **sensors,
SensorType type,
gboolean enable,
IconType icon,
- const gchar *graph_color)
-{
- gdouble low_value;
- gdouble high_value;
- sensors_applet_plugin_default_sensor_limits(type,
- &low_value,
- &high_value);
-
- sensors_applet_plugin_add_sensor_with_limits(sensors,
- path,
- id,
- label,
- type,
- enable,
- low_value,
- high_value,
- icon,
- graph_color);
+ const gchar *graph_color) {
+
+ gdouble low_value;
+ gdouble high_value;
+ sensors_applet_plugin_default_sensor_limits(type, &low_value, &high_value);
+
+ sensors_applet_plugin_add_sensor_with_limits(sensors,
+ path,
+ id,
+ label,
+ type,
+ enable,
+ low_value,
+ high_value,
+ icon,
+ graph_color);
}
@@ -133,24 +128,24 @@ void sensors_applet_plugin_add_sensor_with_limits(GList **sensors,
gdouble low_value,
gdouble high_value,
IconType icon,
- const gchar *graph_color)
-{
- SensorsAppletSensorInfo *info;
-
- info = g_malloc0(sizeof(*info));
-
- info->path = g_strdup(path);
- info->id = g_strdup(id);
- info->label = g_strdup(label);
- info->type = type;
- info->enable = enable;
- info->low_value = low_value;
- info->high_value = high_value;
- info->multiplier = 1.0;
- info->offset = 0.0;
- info->icon = icon;
- info->graph_color = g_strdup(graph_color);
-
- *sensors = g_list_append(*sensors, info);
+ const gchar *graph_color) {
+
+ SensorsAppletSensorInfo *info;
+
+ info = g_malloc0(sizeof(*info));
+
+ info->path = g_strdup(path);
+ info->id = g_strdup(id);
+ info->label = g_strdup(label);
+ info->type = type;
+ info->enable = enable;
+ info->low_value = low_value;
+ info->high_value = high_value;
+ info->multiplier = 1.0;
+ info->offset = 0.0;
+ info->icon = icon;
+ info->graph_color = g_strdup(graph_color);
+
+ *sensors = g_list_append(*sensors, info);
}
diff --git a/sensors-applet/sensors-applet-plugin.h b/sensors-applet/sensors-applet-plugin.h
index 131a4ef..6d7bcdf 100644
--- a/sensors-applet/sensors-applet-plugin.h
+++ b/sensors-applet/sensors-applet-plugin.h
@@ -32,8 +32,8 @@ GQuark sensors_applet_plugin_error_quark(void);
* structs to create the sensors for this plugin from
*/
GList *sensors_applet_plugin_init(void);
-gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+ const gchar *id,
SensorType type,
GError **error);
@@ -43,8 +43,8 @@ void sensors_applet_plugin_find_sensors(GList **sensors,
const gchar *path,
SensorsAppletPluginTestSensorFunc);
-void sensors_applet_plugin_default_sensor_limits(SensorType type,
- gdouble *low_value,
+void sensors_applet_plugin_default_sensor_limits(SensorType type,
+ gdouble *low_value,
gdouble *high_value);
void sensors_applet_plugin_add_sensor(GList **sensors,
@@ -56,7 +56,6 @@ void sensors_applet_plugin_add_sensor(GList **sensors,
IconType icon,
const gchar *graph_color);
-
void sensors_applet_plugin_add_sensor_with_limits(GList **sensors,
const gchar *path,
const gchar *id,
@@ -68,5 +67,4 @@ void sensors_applet_plugin_add_sensor_with_limits(GList **sensors,
IconType icon,
const gchar *graph_color);
-
#endif // SENSORS_APPLET_PLUGIN_H
diff --git a/sensors-applet/sensors-applet-plugins.c b/sensors-applet/sensors-applet-plugins.c
index 94c7c69..e90895a 100644
--- a/sensors-applet/sensors-applet-plugins.c
+++ b/sensors-applet/sensors-applet-plugins.c
@@ -29,130 +29,113 @@
#define SENSORS_APPLET_USER_PLUGIN_DIR ".mate2/sensors-applet/plugins"
-static void load_all_plugins(SensorsApplet *sensors_applet,
- const gchar *path)
-{
- if (g_file_test(path,
- G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
- GDir *dir;
- if ((dir = g_dir_open(path, 0, NULL)) != NULL) {
- const gchar *file;
- while ((file = g_dir_read_name(dir)) != NULL) {
- // try and open plugin
- gchar *plugin_file;
- void *handle;
- SensorsAppletPluginName name_fn;
- SensorsAppletPluginInit init_fn;
- SensorsAppletPluginGetSensorValue get_value_fn;
-
- plugin_file = g_strdup_printf("%s/%s", path, file);
- g_debug("found %s in plugin directory", plugin_file);
- if ((handle = dlopen(plugin_file, RTLD_NOW)) != NULL) {
-
- if ((name_fn = dlsym(handle, "sensors_applet_plugin_name")) != NULL &&
- (init_fn = dlsym(handle, "sensors_applet_plugin_init")) != NULL &&
- (get_value_fn = dlsym(handle, "sensors_applet_plugin_get_sensor_value")) != NULL) {
- GList *sensors;
- g_debug("calling init function for plugin file %s", plugin_file);
-
- if ((sensors = init_fn()) != NULL) {
- GList *sensor;
-
- g_debug("registering plugin %s", name_fn());
- g_hash_table_insert(sensors_applet->plugins,
- g_strdup(name_fn()),
- get_value_fn);
- for (sensor = g_list_first(sensors);
- sensor != NULL;
- sensor = g_list_next(sensor)) {
- SensorsAppletSensorInfo *sensor_info = (SensorsAppletSensorInfo *)sensor->data;
- sensors_applet_add_sensor(sensors_applet,
- sensor_info->path,
- sensor_info->id,
- sensor_info->label,
- name_fn(),
- sensor_info->type,
- sensor_info->enable,
- sensor_info->low_value,
- sensor_info->high_value,
- FALSE, // ALARM OFF
- "", // no alarm commands
- "", // no alarm commands
- 0, // alarm_timeout
- sensor_info->multiplier,
- sensor_info->offset,
- sensor_info->icon,
- sensor_info->graph_color);
-
- // sensors_applet_add_sensor() doesn't free strings, so free them here
- g_free(sensor_info->path);
- g_free(sensor_info->id);
- g_free(sensor_info->label);
- g_free(sensor_info->graph_color);
- g_free(sensor_info);
- }
- g_list_free(sensors);
- } else {
- g_debug("plugin could not find any sensors");
- if (g_hash_table_lookup(sensors_applet->required_plugins,
- name_fn()))
- {
- g_debug("plugin is required - registering even though no sensors detected");
- g_debug("registering plugin %s", name_fn());
- g_hash_table_insert(sensors_applet->plugins,
- g_strdup(name_fn()),
- get_value_fn);
- } else {
- g_debug("unloading plugin");
- }
- }
-
-
-
- } else {
- g_debug("plugin file %s does not contain the required interface", plugin_file);
- if (dlclose(handle) != 0) {
- g_debug("error closing plugin file %s", plugin_file);
- }
- }
- } else {
- g_debug("Could not dlopen: %s: %s", plugin_file, dlerror());
- }
- g_free(plugin_file);
+static void load_all_plugins(SensorsApplet *sensors_applet, const gchar *path) {
+
+ if (g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+ GDir *dir;
+ if ((dir = g_dir_open(path, 0, NULL)) != NULL) {
+ const gchar *file;
+ while ((file = g_dir_read_name(dir)) != NULL) {
+ /* try and open plugin */
+ gchar *plugin_file;
+ void *handle;
+ SensorsAppletPluginName name_fn;
+ SensorsAppletPluginInit init_fn;
+ SensorsAppletPluginGetSensorValue get_value_fn;
+
+ plugin_file = g_strdup_printf("%s/%s", path, file);
+ g_debug("found %s in plugin directory", plugin_file);
+ if ((handle = dlopen(plugin_file, RTLD_NOW)) != NULL) {
+
+ if ((name_fn = dlsym(handle, "sensors_applet_plugin_name")) != NULL &&
+ (init_fn = dlsym(handle, "sensors_applet_plugin_init")) != NULL &&
+ (get_value_fn = dlsym(handle, "sensors_applet_plugin_get_sensor_value")) != NULL) {
+
+ GList *sensors;
+ g_debug("calling init function for plugin file %s", plugin_file);
+
+ if ((sensors = init_fn()) != NULL) {
+ GList *sensor;
+
+ g_debug("registering plugin %s", name_fn());
+ g_hash_table_insert(sensors_applet->plugins, g_strdup(name_fn()), get_value_fn);
+
+ for (sensor = g_list_first(sensors); sensor != NULL; sensor = g_list_next(sensor)) {
+
+ SensorsAppletSensorInfo *sensor_info = (SensorsAppletSensorInfo *)sensor->data;
+ sensors_applet_add_sensor(sensors_applet,
+ sensor_info->path,
+ sensor_info->id,
+ sensor_info->label,
+ name_fn(),
+ sensor_info->type,
+ sensor_info->enable,
+ sensor_info->low_value,
+ sensor_info->high_value,
+ FALSE, /* ALARM OFF */
+ "", /* no alarm commands */
+ "", /* no alarm commands */
+ 0, /* alarm_timeout */
+ sensor_info->multiplier,
+ sensor_info->offset,
+ sensor_info->icon,
+ sensor_info->graph_color);
+
+ // sensors_applet_add_sensor() doesn't free strings, so free them here
+ g_free(sensor_info->path);
+ g_free(sensor_info->id);
+ g_free(sensor_info->label);
+ g_free(sensor_info->graph_color);
+ g_free(sensor_info);
+ }
+ g_list_free(sensors);
+ } else {
+ g_debug("plugin could not find any sensors");
+ if (g_hash_table_lookup(sensors_applet->required_plugins, name_fn())) {
+ g_debug("plugin is required - registering even though no sensors detected");
+ g_debug("registering plugin %s", name_fn());
+ g_hash_table_insert(sensors_applet->plugins, g_strdup(name_fn()), get_value_fn);
+ } else {
+ g_debug("unloading plugin");
+ }
+ }
+
+ } else {
+ g_debug("plugin file %s does not contain the required interface", plugin_file);
+ if (dlclose(handle) != 0) {
+ g_debug("error closing plugin file %s", plugin_file);
}
- g_dir_close(dir);
+ }
} else {
- g_debug("error opening plugin dir %s", path);
+ g_debug("Could not dlopen: %s: %s", plugin_file, dlerror());
}
+ g_free(plugin_file);
+ }
+ g_dir_close(dir);
} else {
- g_debug("path %s is not a valid directory", path);
+ g_debug("error opening plugin dir %s", path);
}
+ } else {
+ g_debug("path %s is not a valid directory", path);
+ }
}
-void sensors_applet_plugins_load_all(SensorsApplet *sensors_applet)
-{
- const gchar *home;
-
- if ((home = g_get_home_dir()) != NULL) {
- gchar *path;
- path = g_build_filename(home,
- SENSORS_APPLET_USER_PLUGIN_DIR,
- NULL);
- load_all_plugins(sensors_applet, path);
- g_free(path);
- } else {
- g_warning("could not get home dir of user");
- }
-
-
- load_all_plugins(sensors_applet, SENSORS_APPLET_PLUGIN_DIR);
+void sensors_applet_plugins_load_all(SensorsApplet *sensors_applet) {
+ const gchar *home;
+
+ if ((home = g_get_home_dir()) != NULL) {
+ gchar *path;
+ path = g_build_filename(home, SENSORS_APPLET_USER_PLUGIN_DIR, NULL);
+ load_all_plugins(sensors_applet, path);
+ g_free(path);
+ } else {
+ g_warning("could not get home dir of user");
+ }
+
+ load_all_plugins(sensors_applet, SENSORS_APPLET_PLUGIN_DIR);
}
-SensorsAppletPluginGetSensorValue sensors_applet_plugins_get_sensor_value_func(SensorsApplet *sensors_applet,
- const gchar *plugin)
-{
- return g_hash_table_lookup(sensors_applet->plugins,
- plugin);
+SensorsAppletPluginGetSensorValue sensors_applet_plugins_get_sensor_value_func(SensorsApplet *sensors_applet, const gchar *plugin) {
+ return g_hash_table_lookup(sensors_applet->plugins, plugin);
}
-
diff --git a/sensors-applet/sensors-applet-plugins.h b/sensors-applet/sensors-applet-plugins.h
index a77d0b2..14fd110 100644
--- a/sensors-applet/sensors-applet-plugins.h
+++ b/sensors-applet/sensors-applet-plugins.h
@@ -23,8 +23,8 @@
typedef const gchar *(*SensorsAppletPluginName)(void);
typedef GList *(*SensorsAppletPluginInit)(void);
-typedef gdouble (*SensorsAppletPluginGetSensorValue)(const gchar *path,
- const gchar *id,
+typedef gdouble (*SensorsAppletPluginGetSensorValue)(const gchar *path,
+ const gchar *id,
SensorType type,
GError **error);