Formatting & Whitespace.

SVN revision: 44796
This commit is contained in:
Christopher Michael 2009-12-30 17:22:19 +00:00
parent 5a4e004564
commit ec8e145dcd
1 changed files with 39 additions and 49 deletions

View File

@ -5,12 +5,12 @@
#include "e_mod_main.h" #include "e_mod_main.h"
/* celsius */ /* celsius */
#define TEMP_LOW_LOW 32 #define TEMP_LOW_LOW 32
#define TEMP_LOW_MID 43 #define TEMP_LOW_MID 43
#define TEMP_LOW_HIGH 55 #define TEMP_LOW_HIGH 55
#define TEMP_HIGH_LOW 43 #define TEMP_HIGH_LOW 43
#define TEMP_HIGH_MID 65 #define TEMP_HIGH_MID 65
#define TEMP_HIGH_HIGH 93 #define TEMP_HIGH_HIGH 93
#define FAR_2_CEL(x) (x - 32) / 1.8 #define FAR_2_CEL(x) (x - 32) / 1.8
#define CEL_2_FAR(x) (x * 1.8) + 32 #define CEL_2_FAR(x) (x * 1.8) + 32
@ -19,14 +19,12 @@ struct _E_Config_Dialog_Data
{ {
int poll_method; int poll_method;
int poll_interval; int poll_interval;
int unit_method; int unit_method;
Unit units; Unit units;
int low_method; int low_method, low_temp;
int low_temp; int high_method, high_temp;
int high_method;
int high_temp;
int sensor; int sensor;
Eina_List *sensors; Eina_List *sensors;
@ -35,22 +33,22 @@ struct _E_Config_Dialog_Data
}; };
/* Protos */ /* Protos */
static void *_create_data(E_Config_Dialog *cfd); static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata); static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata); static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
void void
config_temperature_module(Config_Face *inst) config_temperature_module(Config_Face *inst)
{ {
E_Config_Dialog *cfd; E_Config_Dialog *cfd;
E_Config_Dialog_View *v; E_Config_Dialog_View *v;
char buf[4096]; char buf[PATH_MAX];
v = E_NEW(E_Config_Dialog_View, 1); v = E_NEW(E_Config_Dialog_View, 1);
v->create_cfdata = _create_data; v->create_cfdata = _create_data;
v->free_cfdata = _free_data; v->free_cfdata = _free_data;
v->basic.apply_cfdata = _basic_apply_data; v->basic.apply_cfdata = _basic_apply_data;
@ -58,7 +56,8 @@ config_temperature_module(Config_Face *inst)
v->advanced.apply_cfdata = _advanced_apply_data; v->advanced.apply_cfdata = _advanced_apply_data;
v->advanced.create_widgets = _advanced_create_widgets; v->advanced.create_widgets = _advanced_create_widgets;
snprintf(buf, sizeof(buf), "%s/e-module-temperature.edj", e_module_dir_get(inst->module)); snprintf(buf, sizeof(buf), "%s/e-module-temperature.edj",
e_module_dir_get(inst->module));
cfd = e_config_dialog_new(e_container_current_get(e_manager_current_get()), cfd = e_config_dialog_new(e_container_current_get(e_manager_current_get()),
_("Temperature Settings"), _("Temperature Settings"),
"E", "_e_mod_temperature_config_dialog", "E", "_e_mod_temperature_config_dialog",
@ -69,19 +68,17 @@ config_temperature_module(Config_Face *inst)
static void static void
_fill_data(E_Config_Dialog_Data *cfdata) _fill_data(E_Config_Dialog_Data *cfdata)
{ {
double p; double p;
int pi; int pi;
Eina_List *therms; Eina_List *therms, *l;
Eina_List *l; char path[PATH_MAX], *name;
char *name;
char path[PATH_MAX];
cfdata->units = cfdata->inst->units; cfdata->units = cfdata->inst->units;
if (cfdata->inst->units == CELCIUS) if (cfdata->inst->units == CELCIUS)
cfdata->unit_method = 0; cfdata->unit_method = 0;
else else
cfdata->unit_method = 1; cfdata->unit_method = 1;
pi = cfdata->inst->poll_interval; pi = cfdata->inst->poll_interval;
cfdata->poll_interval = pi; cfdata->poll_interval = pi;
if ((pi >= 1) && (pi <= 64)) if ((pi >= 1) && (pi <= 64))
@ -92,7 +89,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->poll_method = 256; /* Slow */ cfdata->poll_method = 256; /* Slow */
else if (pi > 256) else if (pi > 256)
cfdata->poll_method = 512; /* Very Slow */ cfdata->poll_method = 512; /* Very Slow */
p = cfdata->inst->low; p = cfdata->inst->low;
if (cfdata->units == FAHRENHEIT) if (cfdata->units == FAHRENHEIT)
p = FAR_2_CEL(p - 1); /* -1 so the conversion doesn't make mid go hi */ p = FAR_2_CEL(p - 1); /* -1 so the conversion doesn't make mid go hi */
@ -114,7 +111,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->high_method = TEMP_HIGH_MID; cfdata->high_method = TEMP_HIGH_MID;
else if (p > TEMP_HIGH_MID) else if (p > TEMP_HIGH_MID)
cfdata->high_method = TEMP_HIGH_HIGH; cfdata->high_method = TEMP_HIGH_HIGH;
cfdata->sensor = 0; cfdata->sensor = 0;
switch (cfdata->inst->sensor_type) switch (cfdata->inst->sensor_type)
{ {
@ -129,8 +126,6 @@ _fill_data(E_Config_Dialog_Data *cfdata)
therms = temperature_get_bus_files("i2c"); therms = temperature_get_bus_files("i2c");
if (therms) if (therms)
{ {
char *name;
EINA_LIST_FREE(therms, name) EINA_LIST_FREE(therms, name)
{ {
if (ecore_file_exists(name)) if (ecore_file_exists(name))
@ -140,7 +135,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
sprintf(path, "%s", ecore_file_file_get(name)); sprintf(path, "%s", ecore_file_file_get(name));
len = strlen(path); len = strlen(path);
if (len > 6) if (len > 6)
path[len - 6] = '\0'; path[len - 6] = '\0';
cfdata->sensors = eina_list_append(cfdata->sensors, strdup(path)); cfdata->sensors = eina_list_append(cfdata->sensors, strdup(path));
/* TODO: Track down the user friendly names and display them instead. /* TODO: Track down the user friendly names and display them instead.
* User friendly names are not available on the system, lm-sensors * User friendly names are not available on the system, lm-sensors
@ -164,8 +159,6 @@ _fill_data(E_Config_Dialog_Data *cfdata)
therms = temperature_get_bus_files("pci"); therms = temperature_get_bus_files("pci");
if (therms) if (therms)
{ {
char *name;
EINA_LIST_FREE(therms, name) EINA_LIST_FREE(therms, name)
{ {
if (ecore_file_exists(name)) if (ecore_file_exists(name))
@ -205,9 +198,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
{ {
cfdata->sensors = eina_list_append(cfdata->sensors, name); cfdata->sensors = eina_list_append(cfdata->sensors, name);
if (!strcmp(cfdata->inst->sensor_name, name)) if (!strcmp(cfdata->inst->sensor_name, name))
{ cfdata->sensor = n;
cfdata->sensor = n;
}
n++; n++;
} }
} }
@ -219,7 +210,7 @@ static void *
_create_data(E_Config_Dialog *cfd) _create_data(E_Config_Dialog *cfd)
{ {
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
cfdata = E_NEW(E_Config_Dialog_Data, 1); cfdata = E_NEW(E_Config_Dialog_Data, 1);
cfdata->inst = cfd->data; cfdata->inst = cfd->data;
cfdata->sensors = NULL; cfdata->sensors = NULL;
@ -243,7 +234,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
{ {
Evas_Object *o, *of, *ob; Evas_Object *o, *of, *ob;
E_Radio_Group *rg; E_Radio_Group *rg;
o = e_widget_list_add(evas, 0, 0); o = e_widget_list_add(evas, 0, 0);
of = e_widget_framelist_add(evas, _("Display Units"), 0); of = e_widget_framelist_add(evas, _("Display Units"), 0);
rg = e_widget_radio_group_new(&(cfdata->unit_method)); rg = e_widget_radio_group_new(&(cfdata->unit_method));
@ -252,7 +243,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
ob = e_widget_radio_add(evas, _("Fahrenheit"), 1, rg); ob = e_widget_radio_add(evas, _("Fahrenheit"), 1, rg);
e_widget_framelist_object_append(of, ob); e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5); e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_framelist_add(evas, _("Check Interval"), 0); of = e_widget_framelist_add(evas, _("Check Interval"), 0);
rg = e_widget_radio_group_new(&(cfdata->poll_method)); rg = e_widget_radio_group_new(&(cfdata->poll_method));
ob = e_widget_radio_add(evas, _("Fast"), 4, rg); ob = e_widget_radio_add(evas, _("Fast"), 4, rg);
@ -265,7 +256,6 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
e_widget_framelist_object_append(of, ob); e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5); e_widget_list_object_append(o, of, 1, 1, 0.5);
if (cfdata->units == FAHRENHEIT) if (cfdata->units == FAHRENHEIT)
{ {
of = e_widget_framelist_add(evas, _("High Temperature"), 0); of = e_widget_framelist_add(evas, _("High Temperature"), 0);
@ -278,7 +268,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
ob = e_widget_radio_add(evas, _("110 F"), TEMP_HIGH_LOW, rg); ob = e_widget_radio_add(evas, _("110 F"), TEMP_HIGH_LOW, rg);
e_widget_framelist_object_append(of, ob); e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5); e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_framelist_add(evas, _("Low Temperature"), 0); of = e_widget_framelist_add(evas, _("Low Temperature"), 0);
rg = e_widget_radio_group_new(&(cfdata->low_method)); rg = e_widget_radio_group_new(&(cfdata->low_method));
@ -302,7 +292,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
ob = e_widget_radio_add(evas, _("43 C"), TEMP_HIGH_LOW, rg); ob = e_widget_radio_add(evas, _("43 C"), TEMP_HIGH_LOW, rg);
e_widget_framelist_object_append(of, ob); e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5); e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_framelist_add(evas, _("Low Temperature"), 0); of = e_widget_framelist_add(evas, _("Low Temperature"), 0);
rg = e_widget_radio_group_new(&(cfdata->low_method)); rg = e_widget_radio_group_new(&(cfdata->low_method));
@ -347,7 +337,7 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
Evas_Object *o, *of, *ob; Evas_Object *o, *of, *ob;
E_Radio_Group *rg; E_Radio_Group *rg;
Eina_List *l; Eina_List *l;
o = e_widget_list_add(evas, 0, 0); o = e_widget_list_add(evas, 0, 0);
of = e_widget_framelist_add(evas, _("Display Units"), 0); of = e_widget_framelist_add(evas, _("Display Units"), 0);
rg = e_widget_radio_group_new(&(cfdata->unit_method)); rg = e_widget_radio_group_new(&(cfdata->unit_method));
@ -362,7 +352,7 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
/* TODO: Notify user which thermal system is in use */ /* TODO: Notify user which thermal system is in use */
/* TODO: Let the user choose the wanted thermal system */ /* TODO: Let the user choose the wanted thermal system */
char *name; char *name;
int n = 0; int n = 0;
of = e_widget_framelist_add(evas, _("Sensors"), 0); of = e_widget_framelist_add(evas, _("Sensors"), 0);
rg = e_widget_radio_group_new(&(cfdata->sensor)); rg = e_widget_radio_group_new(&(cfdata->sensor));
@ -397,7 +387,7 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f F"), 0, 230, 5, 0, NULL, &(cfdata->high_temp), 200); ob = e_widget_slider_add(evas, 1, 0, _("%1.0f F"), 0, 230, 5, 0, NULL, &(cfdata->high_temp), 200);
e_widget_framelist_object_append(of, ob); e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5); e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_framelist_add(evas, _("Low Temperature"), 0); of = e_widget_framelist_add(evas, _("Low Temperature"), 0);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f F"), 0, 200, 5, 0, NULL, &(cfdata->low_temp), 200); ob = e_widget_slider_add(evas, 1, 0, _("%1.0f F"), 0, 200, 5, 0, NULL, &(cfdata->low_temp), 200);
e_widget_framelist_object_append(of, ob); e_widget_framelist_object_append(of, ob);
@ -409,7 +399,7 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f C"), 0, 110, 1, 0, NULL, &(cfdata->high_temp), 200); ob = e_widget_slider_add(evas, 1, 0, _("%1.0f C"), 0, 110, 1, 0, NULL, &(cfdata->high_temp), 200);
e_widget_framelist_object_append(of, ob); e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5); e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_framelist_add(evas, _("Low Temperature"), 0); of = e_widget_framelist_add(evas, _("Low Temperature"), 0);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f C"), 0, 95, 1, 0, NULL, &(cfdata->low_temp), 200); ob = e_widget_slider_add(evas, 1, 0, _("%1.0f C"), 0, 95, 1, 0, NULL, &(cfdata->low_temp), 200);
e_widget_framelist_object_append(of, ob); e_widget_framelist_object_append(of, ob);