b attery has option fo forcing hal or internal (batget). config ui is still
too big. SVN revision: 38873
This commit is contained in:
parent
ca0d7dfcfc
commit
6a7c68a45b
|
@ -9,6 +9,7 @@ struct _E_Config_Dialog_Data
|
|||
int alert_percent;
|
||||
int dismiss_alert;
|
||||
int alert_timeout;
|
||||
int force_mode; // 0 == auto, 1 == batget, 2 == hal
|
||||
};
|
||||
|
||||
/* Protos */
|
||||
|
@ -125,10 +126,11 @@ static Evas_Object *
|
|||
_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *of, *ob;
|
||||
E_Radio_Group *rg;
|
||||
|
||||
/* Use Sliders for both cfg options */
|
||||
o = e_widget_list_add(evas, 0, 0);
|
||||
of = e_widget_frametable_add(evas, _("Advanced Settings"), 1);
|
||||
of = e_widget_frametable_add(evas, _("Polling (Internal)"), 1);
|
||||
|
||||
ob = e_widget_label_add(evas, _("Check battery every:"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 1, 0, 1, 0);
|
||||
|
@ -136,28 +138,45 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
|
|||
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f ticks"), 1, 1024, 4, 0, NULL, &(cfdata->poll_interval), 256);
|
||||
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Alert"), 1);
|
||||
|
||||
ob = e_widget_check_add(evas, _("Show alert when battery is low"), &(cfdata->show_alert));
|
||||
e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 1, 1, 0);
|
||||
e_widget_frametable_object_append(of, ob, 0, 0, 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, 3, 1, 1, 1, 0, 1, 1);
|
||||
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 0, 1, 1);
|
||||
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f minutes"), 0, 60, 1, 0, NULL, &(cfdata->alert_time), 60);
|
||||
e_widget_frametable_object_append(of, ob, 0, 4, 1, 1, 1, 0, 1, 0);
|
||||
e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f percent"), 0, 100, 1, 0, NULL, &(cfdata->alert_percent), 100);
|
||||
e_widget_frametable_object_append(of, ob, 0, 5, 1, 1, 1, 0, 1, 0);
|
||||
e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
ob = e_widget_check_add(evas, _("Dismiss alert automatically"), &(cfdata->dismiss_alert));
|
||||
e_widget_frametable_object_append(of, ob, 0, 6, 1, 1, 1, 1, 1, 0);
|
||||
e_widget_frametable_object_append(of, ob, 0, 4, 1, 1, 1, 1, 1, 0);
|
||||
|
||||
ob = e_widget_label_add(evas, _("Dismiss alert after:"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 7, 1, 1, 1, 0, 1, 0);
|
||||
e_widget_frametable_object_append(of, ob, 0, 5, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f seconds"), 1, 300, 1, 0, NULL, &(cfdata->alert_timeout), 150);
|
||||
e_widget_frametable_object_append(of, ob, 0, 8, 1, 1, 1, 0, 1, 0);
|
||||
e_widget_frametable_object_append(of, ob, 0, 6, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Hardware Interface"), 0);
|
||||
|
||||
rg = e_widget_radio_group_new(&(cfdata->force_mode));
|
||||
ob = e_widget_radio_add(evas, _("Auto Detect"), 0, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Internal"), 1, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("HAL"), 2, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -184,6 +203,8 @@ _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
else
|
||||
battery_config->alert_timeout = 0;
|
||||
|
||||
battery_config->force_mode = cfdata->force_mode;
|
||||
|
||||
_battery_config_updated();
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
|
|
|
@ -739,7 +739,8 @@ _battery_config_updated(void)
|
|||
battery_config->have_hal = NOHAL;
|
||||
}
|
||||
|
||||
if (battery_config->have_hal == NOHAL)
|
||||
if ((battery_config->have_hal == NOHAL) ||
|
||||
(battery_config->force_mode == 1))
|
||||
{
|
||||
if (battery_config->batget_exe)
|
||||
{
|
||||
|
@ -755,7 +756,8 @@ _battery_config_updated(void)
|
|||
ECORE_EXE_PIPE_READ_LINE_BUFFERED |
|
||||
ECORE_EXE_NOT_LEADER, NULL);
|
||||
}
|
||||
else if (battery_config->have_hal == UNKNOWN)
|
||||
else if ((battery_config->have_hal == UNKNOWN) ||
|
||||
(battery_config->force_mode == 2))
|
||||
{
|
||||
E_DBus_Connection *conn;
|
||||
DBusPendingCall *call;
|
||||
|
@ -775,6 +777,7 @@ _battery_cb_warning_popup_timeout(void *data)
|
|||
|
||||
inst = data;
|
||||
e_gadcon_popup_hide(inst->warning);
|
||||
battery_config->alert_timer = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -791,6 +794,11 @@ _battery_cb_warning_popup_hide(void *data, Evas *e, Evas_Object *obj, void *even
|
|||
static void
|
||||
_battery_warning_popup_destroy(Instance *inst)
|
||||
{
|
||||
if (battery_config->alert_timer)
|
||||
{
|
||||
ecore_timer_del(battery_config->alert_timer);
|
||||
battery_config->alert_timer = NULL;
|
||||
}
|
||||
if ((!inst) || (!inst->warning)) return;
|
||||
e_object_del(E_OBJECT(inst->warning));
|
||||
inst->warning = NULL;
|
||||
|
@ -854,8 +862,10 @@ _battery_warning_popup(Instance *inst, int time, double percent)
|
|||
_battery_face_level_set(inst->popup_battery, percent);
|
||||
edje_object_signal_emit(inst->popup_battery, "e,state,discharging", "e");
|
||||
|
||||
if (battery_config->alert_timeout)
|
||||
if ((battery_config->alert_timeout > 0) &&
|
||||
(!battery_config->alert_timer))
|
||||
{
|
||||
battery_config->alert_timer =
|
||||
ecore_timer_add(battery_config->alert_timeout,
|
||||
_battery_cb_warning_popup_timeout, inst);
|
||||
}
|
||||
|
@ -1042,6 +1052,7 @@ e_modapi_init(E_Module *m)
|
|||
E_CONFIG_VAL(D, T, alert, INT);
|
||||
E_CONFIG_VAL(D, T, alert_p, INT);
|
||||
E_CONFIG_VAL(D, T, alert_timeout, INT);
|
||||
E_CONFIG_VAL(D, T, force_mode, INT);
|
||||
|
||||
battery_config = e_config_domain_load("module.battery", conf_edd);
|
||||
if (!battery_config)
|
||||
|
@ -1051,11 +1062,13 @@ e_modapi_init(E_Module *m)
|
|||
battery_config->alert = 30;
|
||||
battery_config->alert_p = 10;
|
||||
battery_config->alert_timeout = 0;
|
||||
battery_config->force_mode = 0;
|
||||
}
|
||||
E_CONFIG_LIMIT(battery_config->poll_interval, 4, 4096);
|
||||
E_CONFIG_LIMIT(battery_config->alert, 0, 60);
|
||||
E_CONFIG_LIMIT(battery_config->alert_p, 0, 100);
|
||||
E_CONFIG_LIMIT(battery_config->alert_timeout, 0, 300);
|
||||
E_CONFIG_LIMIT(battery_config->force_mode, 0, 2);
|
||||
|
||||
battery_config->module = m;
|
||||
battery_config->full = -2;
|
||||
|
@ -1088,6 +1101,9 @@ e_modapi_shutdown(E_Module *m)
|
|||
e_configure_registry_category_del("advanced");
|
||||
e_gadcon_provider_unregister(&_gadcon_class);
|
||||
|
||||
if (battery_config->alert_timer)
|
||||
ecore_timer_del(battery_config->alert_timer);
|
||||
|
||||
if (battery_config->batget_exe)
|
||||
{
|
||||
ecore_exe_terminate(battery_config->batget_exe);
|
||||
|
|
|
@ -19,6 +19,7 @@ struct _Config
|
|||
int alert; /* Alert on minutes remaining */
|
||||
int alert_p; /* Alert on percentage remaining */
|
||||
int alert_timeout; /* Popup dismissal timeout */
|
||||
int force_mode; /* force use of batget or hal */
|
||||
/* just config state */
|
||||
E_Module *module;
|
||||
E_Config_Dialog *config_dialog;
|
||||
|
@ -27,6 +28,7 @@ struct _Config
|
|||
Ecore_Exe *batget_exe;
|
||||
Ecore_Event_Handler *batget_data_handler;
|
||||
Ecore_Event_Handler *batget_del_handler;
|
||||
Ecore_Timer *alert_timer;
|
||||
int have_hal;
|
||||
int full;
|
||||
int time_left;
|
||||
|
|
Loading…
Reference in New Issue