aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gstädtner <thomas@gstaedtner.net>2012-03-26 04:00:53 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-03-26 04:00:53 +0000
commit6f55d529a3308bdfffd654f678063e39c94787f0 (patch)
tree318d0acf6a376aa317a56d38cf707024984b6677
parentf456602ebbe410224e1ca13420b0d7986f8bc478 (diff)
downloadenlightenment-6f55d529a3308bdfffd654f678063e39c94787f0.tar.gz
enlightenment-6f55d529a3308bdfffd654f678063e39c94787f0.tar.xz
enlightenment-6f55d529a3308bdfffd654f678063e39c94787f0.zip
From: Thomas Gstädtner <thomas@gstaedtner.net>
Subject: [E-devel] [PATCH] battery: add support for different suspend methods Allow the user to select what to do when the battery runs low: Suspend, Hibernate or Shutdown. SVN revision: 69623
-rw-r--r--AUTHORS1
-rw-r--r--src/modules/battery/e_mod_config.c16
-rw-r--r--src/modules/battery/e_mod_main.c9
-rw-r--r--src/modules/battery/e_mod_main.h7
4 files changed, 29 insertions, 4 deletions
diff --git a/AUTHORS b/AUTHORS
index f08a69f62..6b0f204d4 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -31,3 +31,4 @@ Jihoon Kim <jihoon48.kim@samsung.com>
Sthitha <iamsthitha@gmail>
Doyoun Kang <doyoun.kang@samsung.com>
Gwanglim Lee <gl77.lee@samsung.com>
+Thomas Gstädtner <thomas@gstaedtner.net>
diff --git a/src/modules/battery/e_mod_config.c b/src/modules/battery/e_mod_config.c
index 048b6c6f5..75f8861f5 100644
--- a/src/modules/battery/e_mod_config.c
+++ b/src/modules/battery/e_mod_config.c
@@ -13,6 +13,7 @@ struct _E_Config_Dialog_Data
int dismiss_alert;
int alert_timeout;
int suspend_below;
+ int suspend_method;
int force_mode; // 0 == auto, 1 == batget, 2 == subsystem
#ifdef HAVE_ENOTIFY
int desktop_notifications;
@@ -76,6 +77,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->poll_interval = battery_config->poll_interval;
cfdata->alert_timeout = battery_config->alert_timeout;
cfdata->suspend_below = battery_config->suspend_below;
+ cfdata->suspend_method = battery_config->suspend_method;
cfdata->force_mode = battery_config->force_mode;
#ifdef HAVE_EEZE
cfdata->fuzzy = battery_config->fuzzy;
@@ -236,11 +238,19 @@ _advanced_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_D
NULL, &(cfdata->poll_interval), 100);
e_widget_table_object_append(o, ob, 0, 1, 1, 1, 1, 0, 1, 0);
- ob = e_widget_label_add(evas, _("Hibernate when below:"));
+ rg = e_widget_radio_group_new(&(cfdata->suspend_method));
+ ob = e_widget_radio_add(evas, _("Suspend when below:"), 0, rg);
+ e_widget_on_change_hook_set(ob, _cb_radio_changed, cfdata);
e_widget_table_object_append(o, ob, 0, 2, 1, 1, 1, 0, 1, 0);
+ ob = e_widget_radio_add(evas, _("Hibernate when below:"), 1, rg);
+ e_widget_on_change_hook_set(ob, _cb_radio_changed, cfdata);
+ e_widget_table_object_append(o, ob, 0, 3, 1, 1, 1, 0, 1, 0);
+ ob = e_widget_radio_add(evas, _("Shutdown when below:"), 2, rg);
+ e_widget_on_change_hook_set(ob, _cb_radio_changed, cfdata);
+ e_widget_table_object_append(o, ob, 0, 4, 1, 1, 1, 0, 1, 0);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f %%"), 0, 50, 1, 0,
NULL, &(cfdata->suspend_below), 100);
- e_widget_table_object_append(o, ob, 0, 3, 1, 1, 1, 0, 1, 0);
+ e_widget_table_object_append(o, ob, 0, 5, 1, 1, 1, 0, 1, 0);
e_widget_toolbook_page_append(otb, NULL, _("Polling"), o, 1, 0, 1, 0,
0.5, 0.0);
@@ -334,6 +344,7 @@ _advanced_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfda
battery_config->force_mode = cfdata->force_mode;
battery_config->suspend_below = cfdata->suspend_below;
+ battery_config->suspend_method = cfdata->suspend_method;
_battery_config_updated();
e_config_save_queue();
@@ -352,6 +363,7 @@ _advanced_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *c
(cfdata->poll_interval != battery_config->poll_interval) ||
(cfdata->alert_timeout != battery_config->alert_timeout) ||
(cfdata->suspend_below != battery_config->suspend_below) ||
+ (cfdata->suspend_method != battery_config->suspend_method) ||
#ifdef HAVE_EEZE
(cfdata->fuzzy != battery_config->fuzzy) ||
#endif
diff --git a/src/modules/battery/e_mod_main.c b/src/modules/battery/e_mod_main.c
index 3cf967128..b29a1aada 100644
--- a/src/modules/battery/e_mod_main.c
+++ b/src/modules/battery/e_mod_main.c
@@ -610,7 +610,14 @@ _battery_update(int full, int time_left, int time_full, Eina_Bool have_battery,
if ((have_battery) && (!have_power) && (full >= 0) &&
(battery_config->suspend_below > 0) &&
(full < battery_config->suspend_below))
- e_sys_action_do(E_SYS_HIBERNATE, NULL);
+ {
+ if (battery_config->suspend_method == SUSPEND)
+ e_sys_action_do(E_SYS_SUSPEND, NULL);
+ else if (battery_config->suspend_method == HIBERNATE)
+ e_sys_action_do(E_SYS_HIBERNATE, NULL);
+ else if (battery_config->suspend_method == SHUTDOWN)
+ e_sys_action_do(E_SYS_HALT, NULL);
+ }
}
if (!have_battery)
e_powersave_mode_set(E_POWERSAVE_MODE_LOW);
diff --git a/src/modules/battery/e_mod_main.h b/src/modules/battery/e_mod_main.h
index 6f347c820..d1bf8ecd8 100644
--- a/src/modules/battery/e_mod_main.h
+++ b/src/modules/battery/e_mod_main.h
@@ -19,6 +19,10 @@ typedef struct _Config Config;
#define NOSUBSYSTEM 1
#define SUBSYSTEM 2
+#define SUSPEND 0
+#define HIBERNATE 1
+#define SHUTDOWN 2
+
#define POPUP_DEBOUNCE_CYCLES 2
struct _Config
@@ -28,7 +32,8 @@ struct _Config
int alert; /* Alert on minutes remaining */
int alert_p; /* Alert on percentage remaining */
int alert_timeout; /* Popup dismissal timeout */
- int suspend_below; /* Suspend if batter drops below this level */
+ int suspend_below; /* Suspend if battery drops below this level */
+ int suspend_method; /* Method used to suspend the machine */
int force_mode; /* force use of batget or hal */
/* just config state */
E_Module *module;