forked from enlightenment/enlightenment
Temperature config per face. Seems to work, if not complain to me.
SVN revision: 27503
This commit is contained in:
parent
4d95b45eab
commit
41e9901010
2
TODO
2
TODO
|
@ -119,8 +119,6 @@ Some of the things (in very short form) that need to be done to E17...
|
||||||
that overlay the screen
|
that overlay the screen
|
||||||
* pager should be able to be configured to control more than the current zone
|
* pager should be able to be configured to control more than the current zone
|
||||||
(select which zone they control)
|
(select which zone they control)
|
||||||
* temperature module should allow a different sensor to be monitored
|
|
||||||
per-instance
|
|
||||||
* icons for all config panel items
|
* icons for all config panel items
|
||||||
* icons for most mime types
|
* icons for most mime types
|
||||||
]]]
|
]]]
|
||||||
|
|
|
@ -73,11 +73,6 @@ MODULE_ARCH="$host_os-$host_cpu"
|
||||||
AC_SUBST(MODULE_ARCH)
|
AC_SUBST(MODULE_ARCH)
|
||||||
AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture")
|
AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture")
|
||||||
|
|
||||||
# Check for omnibook laptops so that temperature module works with them
|
|
||||||
if test -f /proc/omnibook/temperature; then
|
|
||||||
AC_DEFINE(HAVE_OMNIBOOK, 1, [Omnibook laptop support for temperature module])
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "x${bindir}" = 'xNONE'; then
|
if test "x${bindir}" = 'xNONE'; then
|
||||||
if test "x${prefix}" = "xNONE"; then
|
if test "x${prefix}" = "xNONE"; then
|
||||||
PACKAGE_BIN_DIR="${ac_default_prefix}/bin"
|
PACKAGE_BIN_DIR="${ac_default_prefix}/bin"
|
||||||
|
|
|
@ -30,6 +30,8 @@ struct _E_Config_Dialog_Data
|
||||||
|
|
||||||
int sensor;
|
int sensor;
|
||||||
Ecore_List *sensors;
|
Ecore_List *sensors;
|
||||||
|
|
||||||
|
Config_Face *inst;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Protos */
|
/* Protos */
|
||||||
|
@ -41,7 +43,7 @@ static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas,
|
||||||
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(void)
|
config_temperature_module(Config_Face *inst)
|
||||||
{
|
{
|
||||||
E_Config_Dialog *cfd;
|
E_Config_Dialog *cfd;
|
||||||
E_Config_Dialog_View *v;
|
E_Config_Dialog_View *v;
|
||||||
|
@ -56,12 +58,12 @@ _config_temperature_module(void)
|
||||||
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/module.edj", e_module_dir_get(temperature_config->module));
|
snprintf(buf, sizeof(buf), "%s/module.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 Configuration"),
|
_("Temperature Configuration"),
|
||||||
"E", "_e_mod_temperature_config_dialog",
|
"E", "_e_mod_temperature_config_dialog",
|
||||||
buf, 0, v, NULL);
|
buf, 0, v, inst);
|
||||||
temperature_config->config_dialog = cfd;
|
inst->config_dialog = cfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -71,13 +73,13 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
||||||
Ecore_List *therms;
|
Ecore_List *therms;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
cfdata->units = temperature_config->units;
|
cfdata->units = cfdata->inst->units;
|
||||||
if (temperature_config->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;
|
||||||
|
|
||||||
p = temperature_config->poll_time;
|
p = cfdata->inst->poll_time;
|
||||||
cfdata->poll_time = p;
|
cfdata->poll_time = p;
|
||||||
if ((p >= 0) && (p <= 5))
|
if ((p >= 0) && (p <= 5))
|
||||||
cfdata->poll_method = 1; //Fast
|
cfdata->poll_method = 1; //Fast
|
||||||
|
@ -88,7 +90,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
||||||
else if (p > 30)
|
else if (p > 30)
|
||||||
cfdata->poll_method = 60; //Very Slow
|
cfdata->poll_method = 60; //Very Slow
|
||||||
|
|
||||||
p = temperature_config->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
|
||||||
cfdata->low_temp = p;
|
cfdata->low_temp = p;
|
||||||
|
@ -99,7 +101,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
||||||
else if (p > TEMP_LOW_MID)
|
else if (p > TEMP_LOW_MID)
|
||||||
cfdata->low_method = TEMP_LOW_HIGH;
|
cfdata->low_method = TEMP_LOW_HIGH;
|
||||||
|
|
||||||
p = temperature_config->high;
|
p = cfdata->inst->high;
|
||||||
if (cfdata->units == FAHRENHEIT)
|
if (cfdata->units == FAHRENHEIT)
|
||||||
p = FAR_2_CEL(p - 1);
|
p = FAR_2_CEL(p - 1);
|
||||||
cfdata->high_temp = p;
|
cfdata->high_temp = p;
|
||||||
|
@ -111,7 +113,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
||||||
cfdata->high_method = TEMP_HIGH_HIGH;
|
cfdata->high_method = TEMP_HIGH_HIGH;
|
||||||
|
|
||||||
cfdata->sensor = 0;
|
cfdata->sensor = 0;
|
||||||
switch (temperature_config->sensor_type)
|
switch (cfdata->inst->sensor_type)
|
||||||
{
|
{
|
||||||
case SENSOR_TYPE_NONE:
|
case SENSOR_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
|
@ -128,7 +130,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
||||||
ecore_list_goto_first(cfdata->sensors);
|
ecore_list_goto_first(cfdata->sensors);
|
||||||
while ((name = ecore_list_next(cfdata->sensors)))
|
while ((name = ecore_list_next(cfdata->sensors)))
|
||||||
{
|
{
|
||||||
if (!strcmp(temperature_config->sensor_name, name))
|
if (!strcmp(cfdata->inst->sensor_name, name))
|
||||||
break;
|
break;
|
||||||
cfdata->sensor++;
|
cfdata->sensor++;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +144,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
||||||
while ((name = ecore_list_next(therms)))
|
while ((name = ecore_list_next(therms)))
|
||||||
{
|
{
|
||||||
ecore_list_append(cfdata->sensors, strdup(name));
|
ecore_list_append(cfdata->sensors, strdup(name));
|
||||||
if (!strcmp(temperature_config->sensor_name, name))
|
if (!strcmp(cfdata->inst->sensor_name, name))
|
||||||
{
|
{
|
||||||
cfdata->sensor = n;
|
cfdata->sensor = n;
|
||||||
}
|
}
|
||||||
|
@ -160,6 +162,7 @@ _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->sensors = ecore_list_new();
|
cfdata->sensors = ecore_list_new();
|
||||||
ecore_list_set_free_cb(cfdata->sensors, free);
|
ecore_list_set_free_cb(cfdata->sensors, free);
|
||||||
_fill_data(cfdata);
|
_fill_data(cfdata);
|
||||||
|
@ -169,7 +172,7 @@ _create_data(E_Config_Dialog *cfd)
|
||||||
static void
|
static void
|
||||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
{
|
{
|
||||||
temperature_config->config_dialog = NULL;
|
cfdata->inst->config_dialog = NULL;
|
||||||
if (cfdata->sensors) ecore_list_destroy(cfdata->sensors);
|
if (cfdata->sensors) ecore_list_destroy(cfdata->sensors);
|
||||||
cfdata->sensors = NULL;
|
cfdata->sensors = NULL;
|
||||||
free(cfdata);
|
free(cfdata);
|
||||||
|
@ -259,21 +262,21 @@ static int
|
||||||
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
{
|
{
|
||||||
if (cfdata->unit_method == 0)
|
if (cfdata->unit_method == 0)
|
||||||
temperature_config->units = CELCIUS;
|
cfdata->inst->units = CELCIUS;
|
||||||
else
|
else
|
||||||
temperature_config->units = FAHRENHEIT;
|
cfdata->inst->units = FAHRENHEIT;
|
||||||
temperature_config->poll_time = (double)cfdata->poll_method;
|
cfdata->inst->poll_time = (double)cfdata->poll_method;
|
||||||
if (temperature_config->units == FAHRENHEIT)
|
if (cfdata->inst->units == FAHRENHEIT)
|
||||||
{
|
{
|
||||||
temperature_config->low = CEL_2_FAR(cfdata->low_method);
|
cfdata->inst->low = CEL_2_FAR(cfdata->low_method);
|
||||||
temperature_config->high = CEL_2_FAR(cfdata->high_method);
|
cfdata->inst->high = CEL_2_FAR(cfdata->high_method);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
temperature_config->low = cfdata->low_method;
|
cfdata->inst->low = cfdata->low_method;
|
||||||
temperature_config->high = cfdata->high_method;
|
cfdata->inst->high = cfdata->high_method;
|
||||||
}
|
}
|
||||||
_temperature_face_cb_config_updated();
|
temperature_face_update_config(cfdata->inst);
|
||||||
e_config_save_queue();
|
e_config_save_queue();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -317,8 +320,8 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
|
||||||
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);
|
||||||
|
|
||||||
// cfdata->low_temp = temperature_config->low;
|
// cfdata->low_temp = cfdata->inst->low;
|
||||||
// cfdata->high_temp = temperature_config->high;
|
// cfdata->high_temp = cfdata->inst->high;
|
||||||
|
|
||||||
if (cfdata->units == FAHRENHEIT)
|
if (cfdata->units == FAHRENHEIT)
|
||||||
{
|
{
|
||||||
|
@ -362,7 +365,7 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
|
||||||
static int
|
static int
|
||||||
_advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
_advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
{
|
{
|
||||||
if (cfdata->unit_method != temperature_config->units)
|
if (cfdata->unit_method != cfdata->inst->units)
|
||||||
{
|
{
|
||||||
if (cfdata->unit_method == 0)
|
if (cfdata->unit_method == 0)
|
||||||
{
|
{
|
||||||
|
@ -376,21 +379,18 @@ _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cfdata->unit_method == 0)
|
if (cfdata->unit_method == 0)
|
||||||
temperature_config->units = CELCIUS;
|
cfdata->inst->units = CELCIUS;
|
||||||
else
|
else
|
||||||
temperature_config->units = FAHRENHEIT;
|
cfdata->inst->units = FAHRENHEIT;
|
||||||
temperature_config->poll_time = cfdata->poll_time;
|
cfdata->inst->poll_time = cfdata->poll_time;
|
||||||
temperature_config->low = cfdata->low_temp;
|
cfdata->inst->low = cfdata->low_temp;
|
||||||
temperature_config->high = cfdata->high_temp;
|
cfdata->inst->high = cfdata->high_temp;
|
||||||
if (temperature_config->sensor_name)
|
if (cfdata->inst->sensor_name)
|
||||||
evas_stringshare_del(temperature_config->sensor_name);
|
evas_stringshare_del(cfdata->inst->sensor_name);
|
||||||
temperature_config->sensor_name =
|
cfdata->inst->sensor_name =
|
||||||
evas_stringshare_add(ecore_list_goto_index(cfdata->sensors, cfdata->sensor));
|
evas_stringshare_add(ecore_list_goto_index(cfdata->sensors, cfdata->sensor));
|
||||||
if (temperature_config->sensor_path)
|
|
||||||
evas_stringshare_del(temperature_config->sensor_path);
|
|
||||||
temperature_config->sensor_path = NULL;
|
|
||||||
|
|
||||||
_temperature_face_cb_config_updated();
|
temperature_face_update_config(cfdata->inst);
|
||||||
e_config_save_queue();
|
e_config_save_queue();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,34 +34,45 @@ static const E_Gadcon_Client_Class _gadcon_class =
|
||||||
/**/
|
/**/
|
||||||
/* actual module specifics */
|
/* actual module specifics */
|
||||||
|
|
||||||
typedef struct _Instance Instance;
|
static void _temperature_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||||
|
static void _temperature_face_cb_post_menu(void *data, E_Menu *m);
|
||||||
struct _Instance
|
static void _temperature_sensor_init(Config_Face *inst);
|
||||||
{
|
|
||||||
E_Gadcon_Client *gcc;
|
|
||||||
Evas_Object *o_temp;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
||||||
static void _menu_cb_post(void *data, E_Menu *m);
|
|
||||||
static void _temperature_sensor_init(void);
|
|
||||||
static int _temperature_cb_check(void *data);
|
static int _temperature_cb_check(void *data);
|
||||||
static void _temperature_face_level_set(Instance *inst, double level);
|
static void _temperature_face_level_set(Config_Face *inst, double level);
|
||||||
static void _temperature_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
|
static void _temperature_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||||
|
|
||||||
static E_Config_DD *conf_edd = NULL;
|
static Evas_Bool _temperature_face_shutdown(Evas_Hash *hash, const char *key, void *hdata, void *fdata);
|
||||||
|
|
||||||
Config *temperature_config = NULL;
|
static E_Config_DD *conf_edd = NULL;
|
||||||
|
static E_Config_DD *conf_face_edd = NULL;
|
||||||
|
|
||||||
|
static Config *temperature_config = NULL;
|
||||||
|
|
||||||
static E_Gadcon_Client *
|
static E_Gadcon_Client *
|
||||||
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||||
{
|
{
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
E_Gadcon_Client *gcc;
|
E_Gadcon_Client *gcc;
|
||||||
Instance *inst;
|
Config_Face *inst;
|
||||||
|
|
||||||
inst = E_NEW(Instance, 1);
|
inst = evas_hash_find(temperature_config->faces, id);
|
||||||
|
if (!inst)
|
||||||
|
{
|
||||||
|
inst = E_NEW(Config_Face, 1);
|
||||||
|
temperature_config->faces = evas_hash_add(temperature_config->faces, id, inst);
|
||||||
|
inst->poll_time = 10.0;
|
||||||
|
inst->low = 30;
|
||||||
|
inst->high = 80;
|
||||||
|
inst->sensor_type = SENSOR_TYPE_NONE;
|
||||||
|
inst->sensor_name = NULL;
|
||||||
|
inst->sensor_path = NULL;
|
||||||
|
inst->units = CELCIUS;
|
||||||
|
}
|
||||||
|
E_CONFIG_LIMIT(inst->poll_time, 0.5, 1000.0);
|
||||||
|
E_CONFIG_LIMIT(inst->low, 0, 100);
|
||||||
|
E_CONFIG_LIMIT(inst->high, 0, 220);
|
||||||
|
E_CONFIG_LIMIT(inst->units, CELCIUS, FAHRENHEIT);
|
||||||
|
|
||||||
o = edje_object_add(gc->evas);
|
o = edje_object_add(gc->evas);
|
||||||
e_theme_edje_object_set(o, "base/theme/modules/temperature",
|
e_theme_edje_object_set(o, "base/theme/modules/temperature",
|
||||||
"e/modules/temperature/main");
|
"e/modules/temperature/main");
|
||||||
|
@ -71,30 +82,39 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||||
|
|
||||||
inst->gcc = gcc;
|
inst->gcc = gcc;
|
||||||
inst->o_temp = o;
|
inst->o_temp = o;
|
||||||
|
inst->module = temperature_config->module;
|
||||||
|
inst->have_temp = -1;
|
||||||
|
inst->temperature_check_timer =
|
||||||
|
ecore_timer_add(inst->poll_time, _temperature_cb_check, inst);
|
||||||
|
|
||||||
|
|
||||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
|
||||||
_button_cb_mouse_down, inst);
|
_temperature_face_cb_mouse_down, inst);
|
||||||
temperature_config->instances = evas_list_append(temperature_config->instances, inst);
|
_temperature_sensor_init(inst);
|
||||||
temperature_config->have_temp = -1;
|
_temperature_cb_check(inst);
|
||||||
_temperature_cb_check(NULL);
|
|
||||||
return gcc;
|
return gcc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gc_shutdown(E_Gadcon_Client *gcc)
|
_gc_shutdown(E_Gadcon_Client *gcc)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Config_Face *inst;
|
||||||
|
|
||||||
inst = gcc->data;
|
inst = gcc->data;
|
||||||
temperature_config->instances = evas_list_remove(temperature_config->instances, inst);
|
if (inst->temperature_check_timer) ecore_timer_del(inst->temperature_check_timer);
|
||||||
evas_object_del(inst->o_temp);
|
inst->temperature_check_timer = NULL;
|
||||||
free(inst);
|
if (inst->o_temp) evas_object_del(inst->o_temp);
|
||||||
|
inst->o_temp = NULL;
|
||||||
|
if (inst->config_dialog) e_object_del(E_OBJECT(inst->config_dialog));
|
||||||
|
inst->config_dialog = NULL;
|
||||||
|
if (inst->menu) e_object_del(E_OBJECT(inst->menu));
|
||||||
|
inst->menu = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gc_orient(E_Gadcon_Client *gcc)
|
_gc_orient(E_Gadcon_Client *gcc)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Config_Face *inst;
|
||||||
|
|
||||||
inst = gcc->data;
|
inst = gcc->data;
|
||||||
e_gadcon_client_aspect_set(gcc, 16, 16);
|
e_gadcon_client_aspect_set(gcc, 16, 16);
|
||||||
|
@ -125,27 +145,27 @@ _gc_icon(Evas *evas)
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/**/
|
/**/
|
||||||
static void
|
static void
|
||||||
_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
_temperature_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
Instance *inst;
|
Config_Face *inst;
|
||||||
Evas_Event_Mouse_Down *ev;
|
Evas_Event_Mouse_Down *ev;
|
||||||
|
|
||||||
inst = data;
|
inst = data;
|
||||||
ev = event_info;
|
ev = event_info;
|
||||||
if ((ev->button == 3) && (!temperature_config->menu))
|
if ((ev->button == 3) && (!inst->menu))
|
||||||
{
|
{
|
||||||
E_Menu *mn;
|
E_Menu *mn;
|
||||||
E_Menu_Item *mi;
|
E_Menu_Item *mi;
|
||||||
int cx, cy, cw, ch;
|
int cx, cy, cw, ch;
|
||||||
|
|
||||||
mn = e_menu_new();
|
mn = e_menu_new();
|
||||||
e_menu_post_deactivate_callback_set(mn, _menu_cb_post, inst);
|
e_menu_post_deactivate_callback_set(mn, _temperature_face_cb_post_menu, inst);
|
||||||
temperature_config->menu = mn;
|
inst->menu = mn;
|
||||||
|
|
||||||
mi = e_menu_item_new(mn);
|
mi = e_menu_item_new(mn);
|
||||||
e_menu_item_label_set(mi, _("Configuration"));
|
e_menu_item_label_set(mi, _("Configuration"));
|
||||||
e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
|
e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
|
||||||
e_menu_item_callback_set(mi, _temperature_face_cb_menu_configure, NULL);
|
e_menu_item_callback_set(mi, _temperature_face_cb_menu_configure, inst);
|
||||||
|
|
||||||
e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
|
e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
|
||||||
|
|
||||||
|
@ -157,21 +177,23 @@ _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
|
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
|
||||||
e_util_evas_fake_mouse_up_later(inst->gcc->gadcon->evas,
|
e_util_evas_fake_mouse_up_later(inst->gcc->gadcon->evas,
|
||||||
ev->button);
|
ev->button);
|
||||||
// evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
|
|
||||||
// EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_menu_cb_post(void *data, E_Menu *m)
|
_temperature_face_cb_post_menu(void *data, E_Menu *m)
|
||||||
{
|
{
|
||||||
if (!temperature_config->menu) return;
|
Config_Face *inst;
|
||||||
e_object_del(E_OBJECT(temperature_config->menu));
|
|
||||||
temperature_config->menu = NULL;
|
inst = data;
|
||||||
|
|
||||||
|
if (!inst->menu) return;
|
||||||
|
e_object_del(E_OBJECT(inst->menu));
|
||||||
|
inst->menu = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_temperature_sensor_init(void)
|
_temperature_sensor_init(Config_Face *inst)
|
||||||
{
|
{
|
||||||
Ecore_List *therms;
|
Ecore_List *therms;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
@ -179,43 +201,40 @@ _temperature_sensor_init(void)
|
||||||
int len;
|
int len;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((!temperature_config->sensor_type) || (!temperature_config->sensor_name))
|
if ((!inst->sensor_type) || (!inst->sensor_name))
|
||||||
{
|
{
|
||||||
if (temperature_config->sensor_name) evas_stringshare_del(temperature_config->sensor_name);
|
if (inst->sensor_name) evas_stringshare_del(inst->sensor_name);
|
||||||
if (temperature_config->sensor_path) evas_stringshare_del(temperature_config->sensor_path);
|
if (inst->sensor_path) evas_stringshare_del(inst->sensor_path);
|
||||||
temperature_config->sensor_path = NULL;
|
inst->sensor_path = NULL;
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
/* TODO: FreeBSD can also have more temperature sensors! */
|
/* TODO: FreeBSD can also have more temperature sensors! */
|
||||||
temperature_config->sensor_type = SENSOR_TYPE_FREEBSD;
|
inst->sensor_type = SENSOR_TYPE_FREEBSD;
|
||||||
temperature_config->sensor_name = evas_stringshare_add("tz0");
|
inst->sensor_name = evas_stringshare_add("tz0");
|
||||||
#else
|
#else
|
||||||
# ifdef HAVE_OMNIBOOK
|
|
||||||
/* TODO: This does not have to be a define */
|
|
||||||
temperature_config->sensor_type = SENSOR_TYPE_OMNIBOOK;
|
|
||||||
temperature_config->sensor_name = evas_stringshare_add("dummy");
|
|
||||||
# else
|
|
||||||
therms = ecore_file_ls("/proc/acpi/thermal_zone");
|
therms = ecore_file_ls("/proc/acpi/thermal_zone");
|
||||||
if ((therms) && (!ecore_list_is_empty(therms)))
|
if ((therms) && (!ecore_list_is_empty(therms)))
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
name = ecore_list_next(therms);
|
name = ecore_list_next(therms);
|
||||||
temperature_config->sensor_type = SENSOR_TYPE_LINUX_ACPI;
|
inst->sensor_type = SENSOR_TYPE_LINUX_ACPI;
|
||||||
temperature_config->sensor_name = evas_stringshare_add(name);
|
inst->sensor_name = evas_stringshare_add(name);
|
||||||
|
|
||||||
ecore_list_destroy(therms);
|
ecore_list_destroy(therms);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
if (therms) ecore_list_destroy(therms);
|
if (therms) ecore_list_destroy(therms);
|
||||||
|
|
||||||
f = fopen("/sys/devices/temperatures/cpu_temperature", "rb");
|
if (ecore_file_exists("/proc/omnibook/temperature"))
|
||||||
if (f)
|
|
||||||
{
|
{
|
||||||
temperature_config->sensor_type = SENSOR_TYPE_LINUX_MACMINI;
|
inst->sensor_type = SENSOR_TYPE_OMNIBOOK;
|
||||||
temperature_config->sensor_name = evas_stringshare_add("dummy");
|
inst->sensor_name = evas_stringshare_add("dummy");
|
||||||
|
}
|
||||||
|
else if (ecore_file_exists("/sys/devices/temperatures/cpu_temperature"))
|
||||||
|
{
|
||||||
|
inst->sensor_type = SENSOR_TYPE_LINUX_MACMINI;
|
||||||
|
inst->sensor_name = evas_stringshare_add("dummy");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -237,43 +256,42 @@ _temperature_sensor_init(void)
|
||||||
name, sensors[i]);
|
name, sensors[i]);
|
||||||
if (ecore_file_exists(path))
|
if (ecore_file_exists(path))
|
||||||
{
|
{
|
||||||
temperature_config->sensor_type = SENSOR_TYPE_LINUX_I2C;
|
inst->sensor_type = SENSOR_TYPE_LINUX_I2C;
|
||||||
temperature_config->sensor_name = evas_stringshare_add(sensors[i]);
|
inst->sensor_name = evas_stringshare_add(sensors[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (temperature_config->sensor_type) break;
|
if (inst->sensor_type) break;
|
||||||
}
|
}
|
||||||
ecore_list_destroy(therms);
|
ecore_list_destroy(therms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if ((temperature_config->sensor_type) &&
|
if ((inst->sensor_type) &&
|
||||||
(temperature_config->sensor_name) &&
|
(inst->sensor_name) &&
|
||||||
(!temperature_config->sensor_path))
|
(!inst->sensor_path))
|
||||||
{
|
{
|
||||||
switch (temperature_config->sensor_type)
|
switch (inst->sensor_type)
|
||||||
{
|
{
|
||||||
case SENSOR_TYPE_NONE:
|
case SENSOR_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_FREEBSD:
|
case SENSOR_TYPE_FREEBSD:
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
snprintf(path, sizeof(path), "hw.acpi.thermal.%s.temperature",
|
snprintf(path, sizeof(path), "hw.acpi.thermal.%s.temperature",
|
||||||
temperature_config->sensor_name);
|
inst->sensor_name);
|
||||||
temperature_config->sensor_path = evas_stringshare_add(path);
|
inst->sensor_path = evas_stringshare_add(path);
|
||||||
|
|
||||||
len = 5;
|
len = 5;
|
||||||
sysctlnametomib(temperature_config->sensor_path, temperature_config->mib, &len);
|
sysctlnametomib(inst->sensor_path, inst->mib, &len);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_OMNIBOOK:
|
case SENSOR_TYPE_OMNIBOOK:
|
||||||
temperature_config->sensor_path = evas_stringshare_add("/proc/omnibook/temperature");
|
inst->sensor_path = evas_stringshare_add("/proc/omnibook/temperature");
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_LINUX_MACMINI:
|
case SENSOR_TYPE_LINUX_MACMINI:
|
||||||
temperature_config->sensor_path = evas_stringshare_add("/sys/devices/temperatures/cpu_temperature");
|
inst->sensor_path = evas_stringshare_add("/sys/devices/temperatures/cpu_temperature");
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_LINUX_I2C:
|
case SENSOR_TYPE_LINUX_I2C:
|
||||||
therms = ecore_file_ls("/sys/bus/i2c/devices");
|
therms = ecore_file_ls("/sys/bus/i2c/devices");
|
||||||
|
@ -284,10 +302,10 @@ _temperature_sensor_init(void)
|
||||||
while ((name = ecore_list_next(therms)))
|
while ((name = ecore_list_next(therms)))
|
||||||
{
|
{
|
||||||
sprintf(path, "/sys/bus/i2c/devices/%s/%s_input",
|
sprintf(path, "/sys/bus/i2c/devices/%s/%s_input",
|
||||||
name, temperature_config->sensor_name);
|
name, inst->sensor_name);
|
||||||
if (ecore_file_exists(path))
|
if (ecore_file_exists(path))
|
||||||
{
|
{
|
||||||
temperature_config->sensor_path = evas_stringshare_add(path);
|
inst->sensor_path = evas_stringshare_add(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,8 +314,8 @@ _temperature_sensor_init(void)
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_LINUX_ACPI:
|
case SENSOR_TYPE_LINUX_ACPI:
|
||||||
snprintf(path, sizeof(path), "/proc/acpi/thermal_zone/%s/temperature",
|
snprintf(path, sizeof(path), "/proc/acpi/thermal_zone/%s/temperature",
|
||||||
temperature_config->sensor_name);
|
inst->sensor_name);
|
||||||
temperature_config->sensor_path = evas_stringshare_add(path);
|
inst->sensor_path = evas_stringshare_add(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,21 +326,20 @@ _temperature_cb_check(void *data)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
Instance *inst;
|
Config_Face *inst;
|
||||||
Evas_List *l;
|
|
||||||
int temp = 0;
|
int temp = 0;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
int len;
|
int len;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_temperature_sensor_init();
|
inst = data;
|
||||||
|
|
||||||
/* TODO: Make standard parser. Seems to be two types of temperature string:
|
/* TODO: Make standard parser. Seems to be two types of temperature string:
|
||||||
* - Somename: <temp> C
|
* - Somename: <temp> C
|
||||||
* - <temp>
|
* - <temp>
|
||||||
*/
|
*/
|
||||||
switch (temperature_config->sensor_type)
|
switch (inst->sensor_type)
|
||||||
{
|
{
|
||||||
case SENSOR_TYPE_NONE:
|
case SENSOR_TYPE_NONE:
|
||||||
/* TODO: Slow down timer? */
|
/* TODO: Slow down timer? */
|
||||||
|
@ -330,7 +347,7 @@ _temperature_cb_check(void *data)
|
||||||
case SENSOR_TYPE_FREEBSD:
|
case SENSOR_TYPE_FREEBSD:
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
len = sizeof(temp);
|
len = sizeof(temp);
|
||||||
if (sysctl(temperature_config->mib, 5, &temp, &len, NULL, 0) != -1)
|
if (sysctl(inst->mib, 5, &temp, &len, NULL, 0) != -1)
|
||||||
{
|
{
|
||||||
temp = (temp - 2732) / 10;
|
temp = (temp - 2732) / 10;
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
@ -340,7 +357,7 @@ _temperature_cb_check(void *data)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_OMNIBOOK:
|
case SENSOR_TYPE_OMNIBOOK:
|
||||||
f = fopen(temperature_config->sensor_path, "r");
|
f = fopen(inst->sensor_path, "r");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
char dummy[4096];
|
char dummy[4096];
|
||||||
|
@ -356,7 +373,7 @@ _temperature_cb_check(void *data)
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_LINUX_MACMINI:
|
case SENSOR_TYPE_LINUX_MACMINI:
|
||||||
f = fopen(temperature_config->sensor_path, "rb");
|
f = fopen(inst->sensor_path, "rb");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||||
|
@ -370,7 +387,7 @@ _temperature_cb_check(void *data)
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_LINUX_I2C:
|
case SENSOR_TYPE_LINUX_I2C:
|
||||||
f = fopen(temperature_config->sensor_path, "r");
|
f = fopen(inst->sensor_path, "r");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fgets(buf, sizeof(buf), f);
|
fgets(buf, sizeof(buf), f);
|
||||||
|
@ -389,7 +406,7 @@ _temperature_cb_check(void *data)
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case SENSOR_TYPE_LINUX_ACPI:
|
case SENSOR_TYPE_LINUX_ACPI:
|
||||||
f = fopen(temperature_config->sensor_path, "r");
|
f = fopen(inst->sensor_path, "r");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
|
@ -413,53 +430,41 @@ _temperature_cb_check(void *data)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temperature_config->units == FAHRENHEIT)
|
if (inst->units == FAHRENHEIT)
|
||||||
temp = (temp * 9.0 / 5.0) + 32;
|
temp = (temp * 9.0 / 5.0) + 32;
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
char *utf8;
|
char *utf8;
|
||||||
|
|
||||||
if (temperature_config->have_temp != 1)
|
if (inst->have_temp != 1)
|
||||||
{
|
{
|
||||||
/* enable therm object */
|
/* enable therm object */
|
||||||
for (l = temperature_config->instances; l; l = l->next)
|
edje_object_signal_emit(inst->o_temp, "e,state,known", "");
|
||||||
{
|
inst->have_temp = 1;
|
||||||
inst = l->data;
|
|
||||||
edje_object_signal_emit(inst->o_temp, "e,state,known", "");
|
|
||||||
}
|
|
||||||
temperature_config->have_temp = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temperature_config->units == FAHRENHEIT)
|
if (inst->units == FAHRENHEIT)
|
||||||
snprintf(buf, sizeof(buf), "%i°F", temp);
|
snprintf(buf, sizeof(buf), "%i°F", temp);
|
||||||
else
|
else
|
||||||
snprintf(buf, sizeof(buf), "%i°C", temp);
|
snprintf(buf, sizeof(buf), "%i°C", temp);
|
||||||
utf8 = ecore_txt_convert("iso-8859-1", "utf-8", buf);
|
utf8 = ecore_txt_convert("iso-8859-1", "utf-8", buf);
|
||||||
|
|
||||||
for (l = temperature_config->instances; l; l = l->next)
|
_temperature_face_level_set(inst,
|
||||||
{
|
(double)(temp - inst->low) /
|
||||||
inst = l->data;
|
(double)(inst->high - inst->low));
|
||||||
_temperature_face_level_set(inst,
|
edje_object_part_text_set(inst->o_temp, "e.text.reading", utf8);
|
||||||
(double)(temp - temperature_config->low) /
|
|
||||||
(double)(temperature_config->high - temperature_config->low));
|
|
||||||
edje_object_part_text_set(inst->o_temp, "e.text.reading", utf8);
|
|
||||||
}
|
|
||||||
free(utf8);
|
free(utf8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (temperature_config->have_temp != 0)
|
if (inst->have_temp != 0)
|
||||||
{
|
{
|
||||||
/* disable therm object */
|
/* disable therm object */
|
||||||
for (l = temperature_config->instances; l; l = l->next)
|
edje_object_signal_emit(inst->o_temp, "e,state,unknown", "");
|
||||||
{
|
edje_object_part_text_set(inst->o_temp, "e.text.reading", "NO TEMP");
|
||||||
inst = l->data;
|
_temperature_face_level_set(inst, 0.5);
|
||||||
edje_object_signal_emit(inst->o_temp, "e,state,unknown", "");
|
inst->have_temp = 0;
|
||||||
edje_object_part_text_set(inst->o_temp, "e.text.reading", "NO TEMP");
|
|
||||||
_temperature_face_level_set(inst, 0.5);
|
|
||||||
}
|
|
||||||
temperature_config->have_temp = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -468,16 +473,16 @@ error:
|
||||||
/* TODO: Error count? Might be a temporary problem */
|
/* TODO: Error count? Might be a temporary problem */
|
||||||
/* TODO: Error dialog */
|
/* TODO: Error dialog */
|
||||||
/* TODO: This should be further up, so that it will affect the gadcon */
|
/* TODO: This should be further up, so that it will affect the gadcon */
|
||||||
temperature_config->sensor_type = SENSOR_TYPE_NONE;
|
inst->sensor_type = SENSOR_TYPE_NONE;
|
||||||
if (temperature_config->sensor_name) evas_stringshare_del(temperature_config->sensor_name);
|
if (inst->sensor_name) evas_stringshare_del(inst->sensor_name);
|
||||||
temperature_config->sensor_name = NULL;
|
inst->sensor_name = NULL;
|
||||||
if (temperature_config->sensor_path) evas_stringshare_del(temperature_config->sensor_path);
|
if (inst->sensor_path) evas_stringshare_del(inst->sensor_path);
|
||||||
temperature_config->sensor_path = NULL;
|
inst->sensor_path = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_temperature_face_level_set(Instance *inst, double level)
|
_temperature_face_level_set(Config_Face *inst, double level)
|
||||||
{
|
{
|
||||||
Edje_Message_Float msg;
|
Edje_Message_Float msg;
|
||||||
|
|
||||||
|
@ -490,17 +495,38 @@ _temperature_face_level_set(Instance *inst, double level)
|
||||||
static void
|
static void
|
||||||
_temperature_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi)
|
_temperature_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||||
{
|
{
|
||||||
if (!temperature_config) return;
|
Config_Face *inst;
|
||||||
if (temperature_config->config_dialog) return;
|
|
||||||
_config_temperature_module();
|
inst = data;
|
||||||
|
if (inst->config_dialog) return;
|
||||||
|
config_temperature_module(inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Evas_Bool
|
||||||
|
_temperature_face_shutdown(Evas_Hash *hash, const char *key, void *hdata, void *fdata)
|
||||||
|
{
|
||||||
|
Config_Face *inst;
|
||||||
|
|
||||||
|
inst = hdata;
|
||||||
|
|
||||||
|
if (inst->sensor_name) evas_stringshare_del(inst->sensor_name);
|
||||||
|
if (inst->sensor_path) evas_stringshare_del(inst->sensor_path);
|
||||||
|
free(inst);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_temperature_face_cb_config_updated(void)
|
temperature_face_update_config(Config_Face *inst)
|
||||||
{
|
{
|
||||||
ecore_timer_del(temperature_config->temperature_check_timer);
|
if (inst->sensor_path)
|
||||||
temperature_config->temperature_check_timer =
|
evas_stringshare_del(inst->sensor_path);
|
||||||
ecore_timer_add(temperature_config->poll_time, _temperature_cb_check, NULL);
|
inst->sensor_path = NULL;
|
||||||
|
|
||||||
|
_temperature_sensor_init(inst);
|
||||||
|
|
||||||
|
if (inst->temperature_check_timer) ecore_timer_del(inst->temperature_check_timer);
|
||||||
|
inst->temperature_check_timer =
|
||||||
|
ecore_timer_add(inst->poll_time, _temperature_cb_check, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
@ -515,11 +541,11 @@ EAPI E_Module_Api e_modapi =
|
||||||
EAPI void *
|
EAPI void *
|
||||||
e_modapi_init(E_Module *m)
|
e_modapi_init(E_Module *m)
|
||||||
{
|
{
|
||||||
conf_edd = E_CONFIG_DD_NEW("Temperature_Config", Config);
|
conf_face_edd = E_CONFIG_DD_NEW("Temperature_Config_Face", Config_Face);
|
||||||
#undef T
|
#undef T
|
||||||
#undef D
|
#undef D
|
||||||
#define T Config
|
#define T Config_Face
|
||||||
#define D conf_edd
|
#define D conf_face_edd
|
||||||
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
|
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
|
||||||
E_CONFIG_VAL(D, T, low, INT);
|
E_CONFIG_VAL(D, T, low, INT);
|
||||||
E_CONFIG_VAL(D, T, high, INT);
|
E_CONFIG_VAL(D, T, high, INT);
|
||||||
|
@ -527,28 +553,18 @@ e_modapi_init(E_Module *m)
|
||||||
E_CONFIG_VAL(D, T, sensor_name, STR);
|
E_CONFIG_VAL(D, T, sensor_name, STR);
|
||||||
E_CONFIG_VAL(D, T, units, INT);
|
E_CONFIG_VAL(D, T, units, INT);
|
||||||
|
|
||||||
|
conf_edd = E_CONFIG_DD_NEW("Temperature_Config", Config);
|
||||||
|
#undef T
|
||||||
|
#undef D
|
||||||
|
#define T Config
|
||||||
|
#define D conf_edd
|
||||||
|
E_CONFIG_HASH(D, T, faces, conf_face_edd);
|
||||||
|
|
||||||
temperature_config = e_config_domain_load("module.temperature", conf_edd);
|
temperature_config = e_config_domain_load("module.temperature", conf_edd);
|
||||||
if (!temperature_config)
|
if (!temperature_config)
|
||||||
{
|
{
|
||||||
temperature_config = E_NEW(Config, 1);
|
temperature_config = E_NEW(Config, 1);
|
||||||
temperature_config->poll_time = 10.0;
|
|
||||||
temperature_config->low = 30;
|
|
||||||
temperature_config->high = 80;
|
|
||||||
temperature_config->sensor_type = SENSOR_TYPE_NONE;
|
|
||||||
temperature_config->sensor_name = NULL;
|
|
||||||
temperature_config->sensor_path = NULL;
|
|
||||||
temperature_config->units = CELCIUS;
|
|
||||||
}
|
}
|
||||||
E_CONFIG_LIMIT(temperature_config->poll_time, 0.5, 1000.0);
|
|
||||||
E_CONFIG_LIMIT(temperature_config->low, 0, 100);
|
|
||||||
E_CONFIG_LIMIT(temperature_config->high, 0, 220);
|
|
||||||
E_CONFIG_LIMIT(temperature_config->units, CELCIUS, FAHRENHEIT);
|
|
||||||
|
|
||||||
temperature_config->have_temp = -1;
|
|
||||||
temperature_config->temperature_check_timer =
|
|
||||||
ecore_timer_add(temperature_config->poll_time, _temperature_cb_check,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
temperature_config->module = m;
|
temperature_config->module = m;
|
||||||
|
|
||||||
e_gadcon_provider_register(&_gadcon_class);
|
e_gadcon_provider_register(&_gadcon_class);
|
||||||
|
@ -560,22 +576,11 @@ e_modapi_shutdown(E_Module *m)
|
||||||
{
|
{
|
||||||
e_gadcon_provider_unregister(&_gadcon_class);
|
e_gadcon_provider_unregister(&_gadcon_class);
|
||||||
|
|
||||||
if (temperature_config->config_dialog)
|
evas_hash_foreach(temperature_config->faces, _temperature_face_shutdown, NULL);
|
||||||
e_object_del(E_OBJECT(temperature_config->config_dialog));
|
evas_hash_free(temperature_config->faces);
|
||||||
if (temperature_config->menu)
|
|
||||||
{
|
|
||||||
e_menu_post_deactivate_callback_set(temperature_config->menu , NULL, NULL);
|
|
||||||
e_object_del(E_OBJECT(temperature_config->menu));
|
|
||||||
temperature_config->menu = NULL;
|
|
||||||
}
|
|
||||||
if (temperature_config->temperature_check_timer)
|
|
||||||
ecore_timer_del(temperature_config->temperature_check_timer);
|
|
||||||
if (temperature_config->sensor_name)
|
|
||||||
evas_stringshare_del(temperature_config->sensor_name);
|
|
||||||
if (temperature_config->sensor_path)
|
|
||||||
evas_stringshare_del(temperature_config->sensor_path);
|
|
||||||
free(temperature_config);
|
free(temperature_config);
|
||||||
temperature_config = NULL;
|
temperature_config = NULL;
|
||||||
|
E_CONFIG_DD_FREE(conf_face_edd);
|
||||||
E_CONFIG_DD_FREE(conf_edd);
|
E_CONFIG_DD_FREE(conf_edd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -597,13 +602,5 @@ e_modapi_about(E_Module *m)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
|
||||||
e_modapi_config(E_Module *m)
|
|
||||||
{
|
|
||||||
if (!temperature_config) return 0;
|
|
||||||
if (temperature_config->config_dialog) return 0;
|
|
||||||
_config_temperature_module();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/**/
|
/**/
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#define E_MOD_MAIN_H
|
#define E_MOD_MAIN_H
|
||||||
|
|
||||||
typedef struct _Config Config;
|
typedef struct _Config Config;
|
||||||
|
typedef struct _Config_Face Config_Face;
|
||||||
|
|
||||||
typedef enum _Unit
|
typedef enum _Unit
|
||||||
{
|
{
|
||||||
|
@ -22,7 +23,7 @@ typedef enum _Sensor_Type
|
||||||
SENSOR_TYPE_LINUX_ACPI
|
SENSOR_TYPE_LINUX_ACPI
|
||||||
} Sensor_Type;
|
} Sensor_Type;
|
||||||
|
|
||||||
struct _Config
|
struct _Config_Face
|
||||||
{
|
{
|
||||||
/* saved * loaded config values */
|
/* saved * loaded config values */
|
||||||
double poll_time;
|
double poll_time;
|
||||||
|
@ -31,10 +32,13 @@ struct _Config
|
||||||
const char *sensor_name;
|
const char *sensor_name;
|
||||||
const char *sensor_path;
|
const char *sensor_path;
|
||||||
Unit units;
|
Unit units;
|
||||||
/* just config state */
|
/* config state */
|
||||||
|
E_Gadcon_Client *gcc;
|
||||||
|
Evas_Object *o_temp;
|
||||||
|
|
||||||
E_Module *module;
|
E_Module *module;
|
||||||
|
|
||||||
E_Config_Dialog *config_dialog;
|
E_Config_Dialog *config_dialog;
|
||||||
Evas_List *instances;
|
|
||||||
E_Menu *menu;
|
E_Menu *menu;
|
||||||
Ecore_Timer *temperature_check_timer;
|
Ecore_Timer *temperature_check_timer;
|
||||||
unsigned char have_temp;
|
unsigned char have_temp;
|
||||||
|
@ -43,17 +47,23 @@ struct _Config
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _Config
|
||||||
|
{
|
||||||
|
/* saved * loaded config values */
|
||||||
|
Evas_Hash *faces;
|
||||||
|
/* config state */
|
||||||
|
E_Module *module;
|
||||||
|
};
|
||||||
|
|
||||||
EAPI extern E_Module_Api e_modapi;
|
EAPI extern E_Module_Api e_modapi;
|
||||||
|
|
||||||
EAPI void *e_modapi_init (E_Module *m);
|
EAPI void *e_modapi_init (E_Module *m);
|
||||||
EAPI int e_modapi_shutdown (E_Module *m);
|
EAPI int e_modapi_shutdown (E_Module *m);
|
||||||
EAPI int e_modapi_save (E_Module *m);
|
EAPI int e_modapi_save (E_Module *m);
|
||||||
EAPI int e_modapi_about (E_Module *m);
|
EAPI int e_modapi_about (E_Module *m);
|
||||||
EAPI int e_modapi_config (E_Module *m);
|
|
||||||
|
|
||||||
void _config_temperature_module(void);
|
void config_temperature_module(Config_Face *inst);
|
||||||
void _temperature_face_cb_config_updated(void);
|
void temperature_face_update_config(Config_Face *inst);
|
||||||
extern Config *temperature_config;
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue