a temperature monitor module for acpi... it's simple... and really only

handles 1 temperature guage - but it's useful. fixed stuff in battery
modules, added config menus... ibar size change menu only works after a
restart for now.. need to fix that.


SVN revision: 12676
This commit is contained in:
Carsten Haitzler 2005-01-02 02:39:44 +00:00
parent b4804a4025
commit 75c635290d
16 changed files with 1519 additions and 25 deletions

View File

@ -185,6 +185,7 @@ src/modules/clock/Makefile
src/modules/flame/Makefile
src/modules/snow/Makefile
src/modules/battery/Makefile
src/modules/temperature/Makefile
data/Makefile
data/fonts/Makefile
data/images/Makefile

View File

@ -269,6 +269,11 @@ images {
image: "e17_battery_090.png" COMP;
image: "e17_battery_100.png" COMP;
image: "e17_battery_ac.png" COMP;
image: "e17_temperature_base.png" COMP;
image: "e17_temperature_mid.png" COMP;
image: "e17_temperature_overlay.png" COMP;
}
collections {
@ -5435,4 +5440,175 @@ collections {
}
}
}
group {
name: "modules/temperature/main";
max: 128 128;
script {
public message(Msg_Type:type, id, ...) {
if ((type == MSG_FLOAT) && (id == 1)) {
new Float:val;
val = getfarg(2);
set_drag(PART:"temp_top", 0.0, val);
}
}
}
parts {
part {
name: "base";
clip_to: "fade_clip";
description {
state: "default" 0.0;
aspect: 0.387 0.387;
align: 0.0 0.5;
max: 48 124;
rel1 {
relative: 0.0 0.0;
}
rel2 {
relative: 1.0 1.0;
}
image {
normal: "e17_temperature_base.png";
}
}
}
part {
name: "temp";
clip_to: "temp_clip";
description {
state: "default" 0.0;
rel1 {
to: "base";
}
rel2 {
to: "base";
}
image {
normal: "e17_temperature_mid.png";
}
}
}
part {
name: "overlay";
clip_to: "fade_clip";
description {
state: "default" 0.0;
rel1 {
to: "base";
}
rel2 {
to: "base";
}
image {
normal: "e17_temperature_overlay.png";
}
}
}
part {
name: "reading";
type: TEXT;
effect: SOFT_SHADOW;
clip_to: "fade_clip";
description {
state: "default" 0.0;
align: 1.0 0.0;
rel1 {
relative: 1.0 0.0;
to_x: "temp";
}
rel2 {
relative: 1.0 0.0;
}
color: 255 255 255 255;
color3: 0 0 0 32;
text {
text: "99^C";
font: "Edje Vera";
size: 7;
min: 1 1;
align: 0.0 0.0;
}
}
}
part {
name: "fade_clip";
type: RECT;
mouse_events: 0;
description {
state: "default" 0.0;
color: 255 255 255 255;
}
description {
state: "faded" 0.0;
color: 255 255 255 128;
}
}
part {
// +10 -46 / 124
name: "temp_clip";
type: RECT;
clip_to: "fade_clip";
mouse_events: 0;
description {
state: "default" 0.0;
rel1 {
to_x: "base";
to_y: "temp_top";
}
rel2 {
to: "base";
}
}
}
part {
// +10 -46 / 124
name: "temp_top";
type: RECT;
dragable {
x: 0 0 0;
y: -1 1 0;
confine: "temp_limit";
}
mouse_events: 0;
description {
state: "default" 0.0;
visible: 0;
}
}
part {
// +10 -46 / 124
name: "temp_limit";
type: RECT;
mouse_events: 0;
description {
state: "default" 0.0;
visible: 0;
rel1 {
relative: 0.0 0.081;
to: "base";
}
rel2 {
relative: 1.0 0.637;
to: "base";
}
}
}
}
programs {
program {
name: "on";
signal: "enable";
source: "";
action: STATE_SET "default" 0.0;
target: "fade_clip";
}
program {
name: "off";
signal: "disable";
source: "";
action: STATE_SET "faded" 0.0;
target: "fade_clip";
}
}
}
}

View File

@ -243,4 +243,8 @@ e17_battery_070.png \
e17_battery_080.png \
e17_battery_090.png \
e17_battery_100.png \
e17_battery_ac.png
e17_battery_ac.png \
e17_temperature_base.png \
e17_temperature_mid.png \
e17_temperature_overlay.png

View File

@ -2300,6 +2300,7 @@ _e_border_menu_show(E_Border *bd, Evas_Coord x, Evas_Coord y)
E_Menu_Item *mi;
E_App *a;
if (e_menu_grab_window_get()) return;
if (!_e_border_menu)
_e_border_menu = e_menu_new();
else
@ -2440,4 +2441,3 @@ _e_border_menu_cb_icon_edit(void *data, E_Menu *m, E_Menu_Item *mi)
please install e_util_eapp_edit\n \
or make sure it is in your PATH\n");
}

View File

@ -88,6 +88,10 @@ e_config_init(void)
em->name = strdup("battery");
e_config->modules = evas_list_append(e_config->modules, em);
em->enabled = 1;
em = E_NEW(E_Config_Module, 1);
em->name = strdup("temperature");
e_config->modules = evas_list_append(e_config->modules, em);
em->enabled = 1;
}
}

View File

@ -335,6 +335,8 @@ _e_container_cb_bg_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *ev
ev = (Evas_Event_Mouse_Down *)event_info;
con = data;
if (e_menu_grab_window_get()) return;
if (ev->button == 1)
{
E_Menu *m;

View File

@ -617,6 +617,12 @@ e_menu_idler_before(void)
}
}
Ecore_X_Window
e_menu_grab_window_get(void)
{
return _e_menu_win;
}
/* local subsystem functions */
static void
_e_menu_free(E_Menu *m)

View File

@ -138,5 +138,6 @@ EAPI void e_menu_item_callback_set(E_Menu_Item *mi, void (*func) (void
EAPI void e_menu_item_active_set(E_Menu_Item *mi, int active);
EAPI void e_menu_idler_before(void);
EAPI Ecore_X_Window e_menu_grab_window_get(void);
#endif

View File

@ -6,4 +6,5 @@ dropshadow \
clock \
flame \
snow \
battery
battery \
temperature

View File

@ -34,7 +34,7 @@ init(E_Module *m)
if (m->api->version < E_MODULE_API_VERSION)
{
e_error_dialog_show("Module API Error",
"Error initializing Module: IBar\n"
"Error initializing Module: Battery\n"
"It requires a minimum module API version of: %i.\n"
"The module API advertized by Enlightenment is: %i.\n"
"Aborting module.",
@ -91,7 +91,10 @@ int
about(E_Module *m)
{
e_error_dialog_show("Enlightenment Battery Module",
"A simple module to give E17 a battery meter.");
"A basic battery meter that uses either ACPI or APM\n"
"on Linux to monitor your battery and AC power adaptor\n"
"status. This will only work under Linux and is only\n"
"as accurate as your BIOS or kernel drivers.");
return 1;
}
@ -113,7 +116,8 @@ _battery_init(E_Module *m)
E_CONFIG_VAL(D, T, width, INT);
E_CONFIG_VAL(D, T, x, DOUBLE);
E_CONFIG_VAL(D, T, y, DOUBLE);
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
e->conf = e_config_domain_load("module.battery", e->conf_edd);
if (!e->conf)
{
@ -121,10 +125,12 @@ _battery_init(E_Module *m)
e->conf->width = 64;
e->conf->x = 1.0;
e->conf->y = 1.0;
e->conf->poll_time = 30.0;
}
E_CONFIG_LIMIT(e->conf->width, 2, 256);
E_CONFIG_LIMIT(e->conf->x, 0.0, 1.0);
E_CONFIG_LIMIT(e->conf->y, 0.0, 1.0);
E_CONFIG_LIMIT(e->conf->poll_time, 0.5, 1000.0);
managers = e_manager_list();
for (l = managers; l; l = l->next)
@ -162,18 +168,109 @@ _battery_shutdown(Battery *e)
free(e);
}
static void
_battery_menu_fast(void *data, E_Menu *m, E_Menu_Item *mi)
{
Battery *e;
e = data;
e->conf->poll_time = 1.0;
ecore_timer_del(e->face->battery_check_timer);
e->face->battery_check_timer = ecore_timer_add(e->face->bat->conf->poll_time, _battery_cb_check, e->face);
e_config_save_queue();
}
static void
_battery_menu_medium(void *data, E_Menu *m, E_Menu_Item *mi)
{
Battery *e;
e = data;
e->conf->poll_time = 5.0;
ecore_timer_del(e->face->battery_check_timer);
e->face->battery_check_timer = ecore_timer_add(e->face->bat->conf->poll_time, _battery_cb_check, e->face);
e_config_save_queue();
}
static void
_battery_menu_normal(void *data, E_Menu *m, E_Menu_Item *mi)
{
Battery *e;
e = data;
e->conf->poll_time = 10.0;
ecore_timer_del(e->face->battery_check_timer);
e->face->battery_check_timer = ecore_timer_add(e->face->bat->conf->poll_time, _battery_cb_check, e->face);
e_config_save_queue();
}
static void
_battery_menu_slow(void *data, E_Menu *m, E_Menu_Item *mi)
{
Battery *e;
e = data;
e->conf->poll_time = 30.0;
ecore_timer_del(e->face->battery_check_timer);
e->face->battery_check_timer = ecore_timer_add(e->face->bat->conf->poll_time, _battery_cb_check, e->face);
e_config_save_queue();
}
static void
_battery_menu_very_slow(void *data, E_Menu *m, E_Menu_Item *mi)
{
Battery *e;
e = data;
e->conf->poll_time = 60.0;
ecore_timer_del(e->face->battery_check_timer);
e->face->battery_check_timer = ecore_timer_add(e->face->bat->conf->poll_time, _battery_cb_check, e->face);
e_config_save_queue();
}
static E_Menu *
_battery_config_menu_new(Battery *e)
{
E_Menu *mn;
E_Menu_Item *mi;
/* FIXME: hook callbacks to each menu item */
mn = e_menu_new();
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "(Unused)");
/* e_menu_item_callback_set(mi, _battery_cb_time_set, e);*/
e_menu_item_label_set(mi, "Check Fast (1 sec)");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->poll_time == 1.0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _battery_menu_fast, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Check Medium (5 sec)");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->poll_time == 5.0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _battery_menu_medium, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Check Normal (10 sec)");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->poll_time == 10.0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _battery_menu_normal, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Check Slow (30 sec)");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->poll_time == 30.0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _battery_menu_slow, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Check Very Slow (60 sec)");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->poll_time == 60.0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _battery_menu_very_slow, e);
e->config_menu = mn;
return mn;
@ -230,7 +327,7 @@ _battery_face_init(Battery_Face *ef)
ef->battery_prev_drain = 1;
ef->battery_prev_ac = -1;
ef->battery_prev_battery = -1;
ef->battery_check_timer = ecore_timer_add(1.0, _battery_cb_check, ef);
ef->battery_check_timer = ecore_timer_add(ef->bat->conf->poll_time, _battery_cb_check, ef);
_battery_cb_check(ef);
@ -434,9 +531,9 @@ _battery_linux_acpi_check(Battery_Face *ef)
char *name;
name = bats->data;
bats = evas_list_remove_list(bats, bats);
if ((!strcmp(name, ".")) || (!strcmp(name, "..")))
{
bats = evas_list_remove_list(bats, bats);
free(name);
continue;
}
@ -447,12 +544,12 @@ _battery_linux_acpi_check(Battery_Face *ef)
int design_cap = 0;
int last_full = 0;
fgets(buf2, sizeof(buf2), f); buf[sizeof(buf2) - 1] = 0;
fgets(buf2, sizeof(buf2), f); buf[sizeof(buf2) - 1] = 0;
fgets(buf2, sizeof(buf2), f); buf2[sizeof(buf2) - 1] = 0;
fgets(buf2, sizeof(buf2), f); buf2[sizeof(buf2) - 1] = 0;
sscanf(buf2, "%*[^:]: %250s %*s", buf);
if (!strcmp(buf, "unknown")) design_cap_unknown = 1;
else sscanf(buf2, "%*[^:]: %i %*s", &design_cap);
fgets(buf2, sizeof(buf2), f); buf[sizeof(buf2) - 1] = 0;
fgets(buf2, sizeof(buf2), f); buf2[sizeof(buf2) - 1] = 0;
sscanf(buf2, "%*[^:]: %250s %*s", buf);
if (!strcmp(buf, "unknown")) last_full_unknown = 1;
else sscanf(buf2, "%*[^:]: %i %*s", &last_full);
@ -470,17 +567,17 @@ _battery_linux_acpi_check(Battery_Face *ef)
int rate = 1;
int level = 0;
fgets(buf2, sizeof(buf2), f); buf[sizeof(buf2) - 1] = 0;
fgets(buf2, sizeof(buf2), f); buf2[sizeof(buf2) - 1] = 0;
sscanf(buf2, "%*[^:]: %250s", present);
fgets(buf2, sizeof(buf2), f); buf[sizeof(buf2) - 1] = 0;
fgets(buf2, sizeof(buf2), f); buf2[sizeof(buf2) - 1] = 0;
sscanf(buf2, "%*[^:]: %250s", capacity_state);
fgets(buf2, sizeof(buf2), f); buf[sizeof(buf2) - 1] = 0;
fgets(buf2, sizeof(buf2), f); buf2[sizeof(buf2) - 1] = 0;
sscanf(buf2, "%*[^:]: %250s", charging_state);
fgets(buf2, sizeof(buf2), f); buf[sizeof(buf2) - 1] = 0;
fgets(buf2, sizeof(buf2), f); buf2[sizeof(buf2) - 1] = 0;
sscanf(buf2, "%*[^:]: %250s %*s", buf);
if (!strcmp(buf, "unknown")) rate_unknown = 1;
else sscanf(buf2, "%*[^:]: %i %*s", &rate);
fgets(buf2, sizeof(buf2), f); buf[sizeof(buf2) - 1] = 0;
fgets(buf2, sizeof(buf2), f); buf2[sizeof(buf2) - 1] = 0;
sscanf(buf2, "%*[^:]: %250s %*s", buf);
if (!strcmp(buf, "unknown")) level_unknown = 1;
else sscanf(buf2, "%*[^:]: %i %*s", &level);
@ -491,7 +588,6 @@ _battery_linux_acpi_check(Battery_Face *ef)
bat_drain += rate;
bat_level += level;
}
bats = evas_list_remove_list(bats, bats);
free(name);
}

View File

@ -13,6 +13,7 @@ struct _Config
{
int width;
double x, y;
double poll_time;
};
struct _Battery

View File

@ -32,9 +32,11 @@ static void _ibar_config_menu_del(IBar *ib, E_Menu *m);
static void _ibar_cb_width_fixed(void *data, E_Menu *m, E_Menu_Item *mi);
static void _ibar_cb_width_auto(void *data, E_Menu *m, E_Menu_Item *mi);
static void _ibar_cb_width_fill(void *data, E_Menu *m, E_Menu_Item *mi);
static void _ibar_bar_iconsize_change(IBar_Bar *ibb);
static IBar_Icon *_ibar_bar_icon_find(IBar_Bar *ibb, E_App *a);
static void _ibar_bar_icon_del(IBar_Icon *ic);
static IBar_Icon *_ibar_bar_icon_new(IBar_Bar *ibb, E_App *a);
static void _ibar_bar_icon_resize(IBar_Icon *ic);
static void _ibar_bar_icon_reorder_before(IBar_Icon *ic, IBar_Icon *before);
static void _ibar_bar_icon_reorder_after(IBar_Icon *ic, IBar_Icon *after);
static void _ibar_bar_frame_resize(IBar_Bar *ibb);
@ -360,6 +362,216 @@ _ibar_app_change(void *data, E_App *a, E_App_Change ch)
}
}
/* FIXME: none of these work runtime... only on restart */
static void
_ibar_cb_iconsize_microscopic(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 8;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static void
_ibar_cb_iconsize_tiny(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 12;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static void
_ibar_cb_iconsize_very_small(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 16;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static void
_ibar_cb_iconsize_small(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 24;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static void
_ibar_cb_iconsize_medium(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 32;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static void
_ibar_cb_iconsize_large(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 40;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static void
_ibar_cb_iconsize_very_large(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 48;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static void
_ibar_cb_iconsize_extremely_large(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 56;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static void
_ibar_cb_iconsize_huge(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 64;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static void
_ibar_cb_iconsize_enormous(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 96;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static void
_ibar_cb_iconsize_gigantic(void *data, E_Menu *m, E_Menu_Item *mi)
{
IBar *ib;
Evas_List *l;
ib = data;
ib->conf->iconsize = 128;
for (l = ib->bars; l; l = l->next)
{
IBar_Bar *ibb;
ibb = l->data;
_ibar_bar_iconsize_change(ibb);
_ibar_bar_edge_change(ibb, ib->conf->edge);
}
e_config_save_queue();
}
static E_Menu *
_ibar_config_menu_new(IBar *ib)
{
@ -372,28 +584,105 @@ _ibar_config_menu_new(IBar *ib)
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Fixed width");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
e_menu_item_radio_group_set(mi, 1);
if (ib->conf->width > 0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_width_fixed, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Auto fit icons");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
e_menu_item_radio_group_set(mi, 1);
if (ib->conf->width < 0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_width_auto, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Fill edge");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
e_menu_item_radio_group_set(mi, 1);
if (ib->conf->width == 0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_width_fill, ib);
/*
mi = e_menu_item_new(mn);
e_menu_item_separator_set(mi, 1);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Microscopic");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 8) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_microscopic, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Tiny");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 12) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_tiny, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Very Small");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 16) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_very_small, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Small");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 24) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_small, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Medium");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 32) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_medium, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Large");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 40) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_large, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Very Large");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 48) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_very_large, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Exteremely Large");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 56) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_extremely_large, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Huge");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 64) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_huge, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Enormous");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 96) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_enormous, ib);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Gigantic");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 2);
if (ib->conf->iconsize == 128) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _ibar_cb_iconsize_gigantic, ib);
/*
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Auto hide");
e_menu_item_check_set(mi, 1);
@ -484,6 +773,22 @@ _ibar_cb_width_fill(void *data, E_Menu *m, E_Menu_Item *mi)
e_config_save_queue();
}
static void
_ibar_bar_iconsize_change(IBar_Bar *ibb)
{
Evas_List *l;
for (l = ibb->icons; l; l = l->next)
{
IBar_Icon *ic;
ic = l->data;
_ibar_bar_icon_resize(ic);
}
_ibar_bar_convert_move_resize_to_config(ibb);
_ibar_bar_frame_resize(ibb);
}
static IBar_Icon *
_ibar_bar_icon_find(IBar_Bar *ibb, E_App *a)
{
@ -608,6 +913,28 @@ _ibar_bar_icon_new(IBar_Bar *ibb, E_App *a)
return ic;
}
static void
_ibar_bar_icon_resize(IBar_Icon *ic)
{
Evas_Object *o;
Evas_Coord bw, bh;
e_box_freeze(ic->ibb->box_object);
o = ic->icon_object;
edje_extern_object_min_size_set(o, ic->ibb->ibar->conf->iconsize, ic->ibb->ibar->conf->iconsize);
edje_object_part_swallow(ic->bg_object, "item", o);
edje_object_size_min_calc(ic->bg_object, &bw, &bh);
e_box_pack_options_set(ic->bg_object,
1, 1, /* fill */
0, 0, /* expand */
0.5, 0.5, /* align */
bw, bh, /* min */
bw, bh /* max */
);
e_box_thaw(ic->ibb->box_object);
}
static void
_ibar_bar_icon_reorder_before(IBar_Icon *ic, IBar_Icon *before)
{

View File

@ -0,0 +1,26 @@
MAINTAINERCLEANFILES = Makefile.in
MODULE = temperature
# data files for the module
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
files_DATA = \
module_icon.png
EXTRA_DIST = $(files_DATA)
# the module .so file
INCLUDES = -I. \
-I$(top_srcdir) \
-I$(includedir) \
-I$(top_srcdir)$(MODULE) \
-I$(top_srcdir)/src/bin \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/modules \
@e_cflags@
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h
module_la_LIBADD = @e_libs@ @dlopen_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h

View File

@ -0,0 +1,794 @@
#include "e.h"
#include "e_mod_main.h"
/* TODO List:
*
* should support proepr resize and move handles in the edje.
*
*/
/* module private routines */
static Temperature *_temperature_init(E_Module *m);
static void _temperature_shutdown(Temperature *e);
static E_Menu *_temperature_config_menu_new(Temperature *e);
static void _temperature_config_menu_del(Temperature *e, E_Menu *m);
static void _temperature_face_init(Temperature_Face *ef);
static void _temperature_face_free(Temperature_Face *ef);
static void _temperature_face_reconfigure(Temperature_Face *ef);
static void _temperature_cb_face_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _temperature_cb_face_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _temperature_cb_face_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
static int _temperature_cb_event_container_resize(void *data, int type, void *event);
static int _temperature_cb_check(void *data);
static void _temperature_level_set(Temperature_Face *ef, double level);
/* public module routines. all modules must have these */
void *
init(E_Module *m)
{
Temperature *e;
/* check module api version */
if (m->api->version < E_MODULE_API_VERSION)
{
e_error_dialog_show("Module API Error",
"Error initializing Module: Temperature\n"
"It requires a minimum module API version of: %i.\n"
"The module API advertized by Enlightenment is: %i.\n"
"Aborting module.",
E_MODULE_API_VERSION,
m->api->version);
return NULL;
}
/* actually init temperature */
e = _temperature_init(m);
m->config_menu = _temperature_config_menu_new(e);
return e;
}
int
shutdown(E_Module *m)
{
Temperature *e;
e = m->data;
if (e)
{
if (m->config_menu)
{
_temperature_config_menu_del(e, e->config_menu1);
_temperature_config_menu_del(e, e->config_menu2);
_temperature_config_menu_del(e, e->config_menu3);
_temperature_config_menu_del(e, m->config_menu);
m->config_menu = NULL;
}
_temperature_shutdown(e);
}
return 1;
}
int
save(E_Module *m)
{
Temperature *e;
e = m->data;
e_config_domain_save("module.temperature", e->conf_edd, e->conf);
return 1;
}
int
info(E_Module *m)
{
char buf[4096];
m->label = strdup("Temperature");
snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
m->icon_file = strdup(buf);
return 1;
}
int
about(E_Module *m)
{
e_error_dialog_show("Enlightenment Temperature Module",
"A module to measure the ACPI Thermal sensor on Linux.\n"
"It is especially useful for modern Laptops with high speed\n"
"CPUs that generate a lot of heat.");
return 1;
}
/* module private routines */
static Temperature *
_temperature_init(E_Module *m)
{
Temperature *e;
Evas_List *managers, *l, *l2;
e = calloc(1, sizeof(Temperature));
if (!e) return NULL;
e->conf_edd = E_CONFIG_DD_NEW("Temperature_Config", Config);
#undef T
#undef D
#define T Config
#define D e->conf_edd
E_CONFIG_VAL(D, T, width, INT);
E_CONFIG_VAL(D, T, x, DOUBLE);
E_CONFIG_VAL(D, T, y, DOUBLE);
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
E_CONFIG_VAL(D, T, low, INT);
E_CONFIG_VAL(D, T, high, INT);
e->conf = e_config_domain_load("module.temperature", e->conf_edd);
if (!e->conf)
{
e->conf = E_NEW(Config, 1);
e->conf->width = 64;
e->conf->x = 0.9;
e->conf->y = 1.0;
e->conf->poll_time = 10.0;
e->conf->low = 30;
e->conf->high = 80;
}
E_CONFIG_LIMIT(e->conf->width, 2, 256);
E_CONFIG_LIMIT(e->conf->x, 0.0, 1.0);
E_CONFIG_LIMIT(e->conf->y, 0.0, 1.0);
E_CONFIG_LIMIT(e->conf->poll_time, 0.5, 1000.0);
E_CONFIG_LIMIT(e->conf->low, 0, 100);
E_CONFIG_LIMIT(e->conf->high, 0, 200);
managers = e_manager_list();
for (l = managers; l; l = l->next)
{
E_Manager *man;
man = l->data;
for (l2 = man->containers; l2; l2 = l2->next)
{
E_Container *con;
Temperature_Face *ef;
con = l2->data;
ef = calloc(1, sizeof(Temperature_Face));
if (ef)
{
ef->temp = e;
ef->con = con;
ef->evas = con->bg_evas;
_temperature_face_init(ef);
e->face = ef;
}
}
}
return e;
}
static void
_temperature_shutdown(Temperature *e)
{
free(e->conf);
E_CONFIG_DD_FREE(e->conf_edd);
_temperature_face_free(e->face);
free(e);
}
static void
_temperature_menu_fast(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->poll_time = 1.0;
ecore_timer_del(e->face->temperature_check_timer);
e->face->temperature_check_timer = ecore_timer_add(e->face->temp->conf->poll_time, _temperature_cb_check, e->face);
e_config_save_queue();
}
static void
_temperature_menu_medium(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->poll_time = 5.0;
ecore_timer_del(e->face->temperature_check_timer);
e->face->temperature_check_timer = ecore_timer_add(e->face->temp->conf->poll_time, _temperature_cb_check, e->face);
e_config_save_queue();
}
static void
_temperature_menu_normal(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->poll_time = 10.0;
ecore_timer_del(e->face->temperature_check_timer);
e->face->temperature_check_timer = ecore_timer_add(e->face->temp->conf->poll_time, _temperature_cb_check, e->face);
e_config_save_queue();
}
static void
_temperature_menu_slow(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->poll_time = 30.0;
ecore_timer_del(e->face->temperature_check_timer);
e->face->temperature_check_timer = ecore_timer_add(e->face->temp->conf->poll_time, _temperature_cb_check, e->face);
e_config_save_queue();
}
static void
_temperature_menu_very_slow(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->poll_time = 60.0;
ecore_timer_del(e->face->temperature_check_timer);
e->face->temperature_check_timer = ecore_timer_add(e->face->temp->conf->poll_time, _temperature_cb_check, e->face);
e_config_save_queue();
}
static void
_temperature_menu_low_10(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->low = 10;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_low_20(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->low = 20;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_low_30(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->low = 30;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_low_40(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->low = 40;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_low_50(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->low = 50;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_high_20(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->high = 20;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_high_30(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->high = 30;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_high_40(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->high = 40;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_high_50(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->high = 50;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_high_60(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->high = 60;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_high_70(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->high = 70;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_high_80(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->high = 80;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_high_90(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->high = 90;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static void
_temperature_menu_high_100(void *data, E_Menu *m, E_Menu_Item *mi)
{
Temperature *e;
e = data;
e->conf->high = 100;
_temperature_cb_check(e->face);
e_config_save_queue();
}
static E_Menu *
_temperature_config_menu_new(Temperature *e)
{
E_Menu *mn;
E_Menu_Item *mi;
mn = e_menu_new();
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Fast (1 sec)");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->poll_time == 1.0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_fast, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Medium (5 sec)");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->poll_time == 5.0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_medium, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Normal (10 sec)");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->poll_time == 10.0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_normal, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Slow (30 sec)");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->poll_time == 30.0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_slow, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "Very Slow (60 sec)");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->poll_time == 60.0) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_very_slow, e);
e->config_menu1 = mn;
mn = e_menu_new();
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "10°C");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->low == 10) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_low_10, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "20°C");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->low == 20) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_low_20, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "30°C");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->low == 30) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_low_30, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "40°C");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->low == 40) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_low_40, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "50°C");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->low == 50) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_low_50, e);
e->config_menu2 = mn;
mn = e_menu_new();
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "20°C");
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
if (e->conf->high == 20) e_menu_item_toggle_set(mi, 1);
e_menu_item_callback_set(mi, _temperature_menu_high_20, e);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, "30°C");
e_menu_item_radio_set(mi, 1)<