Enlightenment CVS committal
Author : ravenlock
Project : e17
Module : apps/e
Dir : e17/apps/e/src/modules/battery
Modified Files:
e_mod_config.c e_mod_main.c e_mod_main.h
Log Message:
Allow module to fire its alarm given a percentage remaining threshold.
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/battery/e_mod_config.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- e_mod_config.c 24 Mar 2007 23:12:22 -0000 1.22
+++ e_mod_config.c 20 May 2007 05:20:04 -0000 1.23
@@ -6,6 +6,7 @@
int show_alert;
double poll_time;
int alarm_time;
+ int alarm_percent;
};
/* Protos */
@@ -45,8 +46,9 @@
{
if (!battery_config) return;
cfdata->alarm_time = battery_config->alarm;
+ cfdata->alarm_percent = battery_config->alarm_p;
cfdata->poll_time = battery_config->poll_time;
- if (cfdata->alarm_time > 0)
+ if (cfdata->alarm_time > 0 || cfdata->alarm_percent > 0)
cfdata->show_alert = 1;
else
cfdata->show_alert = 0;
@@ -87,10 +89,16 @@
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
if (!battery_config) return 0;
- if (cfdata->show_alert)
+ if (cfdata->show_alert)
+ {
battery_config->alarm = cfdata->alarm_time;
- else
+ battery_config->alarm_p = cfdata->alarm_percent;
+ }
+ else
+ {
battery_config->alarm = 0;
+ battery_config->alarm_p = 0;
+ }
_battery_config_updated();
e_config_save_queue();
return 1;
@@ -108,16 +116,19 @@
ob = e_widget_label_add(evas, _("Check battery every:"));
e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 1, 0, 1, 0);
- ob = e_widget_slider_add(evas, 1, 0, _("%1.1f seconds"), 0.5, 1000.0, 0.5,
0, &(cfdata->poll_time), NULL, 200);
+ ob = e_widget_slider_add(evas, 1, 0, _("%1.1f seconds"), 0.5, 900.0, 0.5,
0, &(cfdata->poll_time), NULL, 200);
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 0, 1, 0);
ob = e_widget_check_add(evas, _("Show alert when battery is low"),
&(cfdata->show_alert));
- e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 1, 1, 1, 0);
+ e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 1, 1, 0);
ob = e_widget_label_add(evas, _("Alert when battery is down to:"));
- e_widget_frametable_object_append(of, ob, 0, 4, 1, 1, 1, 0, 1, 1);
+ e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 1, 0, 1, 1);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f minutes"), 1, 60, 1, 0, NULL,
&(cfdata->alarm_time), 200);
+ e_widget_frametable_object_append(of, ob, 0, 4, 1, 1, 1, 0, 1, 0);
+
+ ob = e_widget_slider_add(evas, 1, 0, _("%1.0f percent"), 1, 100, 1, 0,
NULL, &(cfdata->alarm_percent), 200);
e_widget_frametable_object_append(of, ob, 0, 5, 1, 1, 1, 0, 1, 0);
e_widget_list_object_append(o, of, 1, 1, 0.5);
@@ -129,10 +140,16 @@
{
if (!battery_config) return 0;
battery_config->poll_time = cfdata->poll_time;
- if (cfdata->show_alert)
+ if (cfdata->show_alert)
+ {
battery_config->alarm = cfdata->alarm_time;
+ battery_config->alarm_p = cfdata->alarm_percent;
+ }
else
+ {
battery_config->alarm = 0;
+ battery_config->alarm_p = 0;
+ }
_battery_config_updated();
e_config_save_queue();
return 1;
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/battery/e_mod_main.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -3 -r1.96 -r1.97
--- e_mod_main.c 25 Mar 2007 22:46:20 -0000 1.96
+++ e_mod_main.c 20 May 2007 05:20:04 -0000 1.97
@@ -559,6 +559,8 @@
{
if (((hours * 60) + minutes) <= battery_config->alarm)
stat->alarm = 1;
+ if (bat_val <= battery_config->alarm_p)
+ stat->alarm = 1;
}
}
if (level_unknown)
@@ -684,6 +686,8 @@
{
if (((hours * 60) + minutes) <= battery_config->alarm)
stat->alarm = 1;
+ if (bat_val <= battery_config->alarm_p)
+ stat->alarm = 1;
}
}
@@ -859,11 +863,21 @@
else if ((charging) || (discharging))
{
stat->has_battery = 1;
- if (charging)
- {
+ stat->level = (double)charge / (double)max_charge;
+ if (stat->level > 1.0) stat->level = 1.0;
+ tmp = (double)max_charge / 100;
+ tmp = (double)charge / tmp;
+ stat->level = (double)tmp / 100;
+
+ snprintf(buf, sizeof(buf), "%.0f%%", tmp);
+ stat->reading = strdup(buf);
+ snprintf(buf, sizeof(buf), "%i:%02i", hours, minutes);
+ stat->time = strdup(buf);
+ if (charging)
+ {
stat->state = BATTERY_STATE_CHARGING;
battery_config->alarm_triggered = 0;
- }
+ }
else if (discharging)
{
stat->state = BATTERY_STATE_DISCHARGING;
@@ -871,18 +885,10 @@
{
if (((hours * 60) + minutes) <= battery_config->alarm)
stat->alarm = 1;
+ if (stat->level <= battery_config->alarm_p)
+ stat->alarm = 1;
}
}
- stat->level = (double)charge / (double)max_charge;
- if (stat->level > 1.0) stat->level = 1.0;
- tmp = (double)max_charge / 100;
- tmp = (double)charge / tmp;
- stat->level = (double)tmp / 100;
-
- snprintf(buf, sizeof(buf), "%.0f%%", tmp);
- stat->reading = strdup(buf);
- snprintf(buf, sizeof(buf), "%i:%02i", hours, minutes);
- stat->time = strdup(buf);
}
else
{
@@ -1027,6 +1033,8 @@
{
if (((hours * 60) + minutes) <= battery_config->alarm)
stat->alarm = 1;
+ if (bat_val <= battery_config->alarm_p)
+ stat->alarm = 1;
}
}
if (level == -1)
@@ -1150,6 +1158,8 @@
{
if (((hours * 60) + minutes) <= battery_config->alarm)
stat->alarm = 1;
+ if (bat_val <= battery_config->alarm_p)
+ stat->alarm = 1;
}
}
@@ -1288,6 +1298,8 @@
*/
if (currentval <= battery_config->alarm)
stat->alarm = 1;
+ if (stat->level <= battery_config->alarm_p)
+ stat->alarm = 1;
}
else
{
@@ -1397,6 +1409,7 @@
#define D conf_edd
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
E_CONFIG_VAL(D, T, alarm, INT);
+ E_CONFIG_VAL(D, T, alarm_p, INT);
battery_config = e_config_domain_load("module.battery", conf_edd);
if (!battery_config)
@@ -1404,9 +1417,11 @@
battery_config = E_NEW(Config, 1);
battery_config->poll_time = 30.0;
battery_config->alarm = 30;
+ battery_config->alarm_p = 10;
}
E_CONFIG_LIMIT(battery_config->poll_time, 0.5, 1000.0);
E_CONFIG_LIMIT(battery_config->alarm, 0, 60);
+ E_CONFIG_LIMIT(battery_config->alarm_p, 0, 100);
battery_config->battery_check_mode = CHECK_NONE;
battery_config->battery_prev_drain = 1;
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/battery/e_mod_main.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- e_mod_main.h 3 Sep 2006 08:51:32 -0000 1.26
+++ e_mod_main.h 20 May 2007 05:20:04 -0000 1.27
@@ -16,7 +16,8 @@
{
/* saved * loaded config values */
double poll_time;
- int alarm;
+ int alarm; /* Alarm on minutes remaining */
+ int alarm_p; /* Alarm on percentage remaining */
/* just config state */
E_Module *module;
E_Config_Dialog *config_dialog;
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs