Cleanup desktop notifications in battery.

-Properly init and shutdown e_notify
-Use "Battery" as name for notification sender
-Use ui configurable timeout for notification
-Save "use desktop notification" for real

SVN revision: 67029
This commit is contained in:
Leif Middelschulte 2012-01-11 01:40:13 +00:00
parent e5d5b57bc5
commit 72e9ba4bca
1 changed files with 20 additions and 2 deletions

View File

@ -440,12 +440,12 @@ _battery_warning_popup(Instance *inst, int time, double percent)
if (battery_config && battery_config->desktop_notifications) if (battery_config && battery_config->desktop_notifications)
{ {
if (notification) return; if (notification) return;
notification = e_notification_full_new("Enlightenment", notification = e_notification_full_new(_("Battery"),
0, 0,
"battery-low", "battery-low",
_("Your battery is low!"), _("Your battery is low!"),
_("AC power is recommended."), _("AC power is recommended."),
2); (battery_config->alert_timeout * 1000));
e_notification_send(notification, NULL, NULL); e_notification_send(notification, NULL, NULL);
e_notification_unref(notification); e_notification_unref(notification);
notification = NULL; notification = NULL;
@ -687,6 +687,10 @@ e_modapi_init(E_Module *m)
{ {
char buf[4096]; char buf[4096];
#ifdef HAVE_ENOTIFY
e_notification_init();
#endif
conf_edd = E_CONFIG_DD_NEW("Battery_Config", Config); conf_edd = E_CONFIG_DD_NEW("Battery_Config", Config);
#undef T #undef T
#undef D #undef D
@ -701,6 +705,9 @@ e_modapi_init(E_Module *m)
#if defined HAVE_EEZE || defined __OpenBSD__ #if defined HAVE_EEZE || defined __OpenBSD__
E_CONFIG_VAL(D, T, fuzzy, INT); E_CONFIG_VAL(D, T, fuzzy, INT);
#endif #endif
#ifdef HAVE_ENOTIFY
E_CONFIG_VAL(D, T, desktop_notifications, INT);
#endif
battery_config = e_config_domain_load("module.battery", conf_edd); battery_config = e_config_domain_load("module.battery", conf_edd);
if (!battery_config) if (!battery_config)
@ -714,6 +721,9 @@ e_modapi_init(E_Module *m)
battery_config->force_mode = 0; battery_config->force_mode = 0;
#if defined HAVE_EEZE || defined __OpenBSD__ #if defined HAVE_EEZE || defined __OpenBSD__
battery_config->fuzzy = 0; battery_config->fuzzy = 0;
#endif
#ifdef HAVE_ENOTIFY
battery_config->desktop_notifications = 0;
#endif #endif
} }
E_CONFIG_LIMIT(battery_config->poll_interval, 4, 4096); E_CONFIG_LIMIT(battery_config->poll_interval, 4, 4096);
@ -722,6 +732,9 @@ e_modapi_init(E_Module *m)
E_CONFIG_LIMIT(battery_config->alert_timeout, 0, 300); E_CONFIG_LIMIT(battery_config->alert_timeout, 0, 300);
E_CONFIG_LIMIT(battery_config->suspend_below, 0, 50); E_CONFIG_LIMIT(battery_config->suspend_below, 0, 50);
E_CONFIG_LIMIT(battery_config->force_mode, 0, 2); E_CONFIG_LIMIT(battery_config->force_mode, 0, 2);
#ifdef HAVE_ENOTIFY
E_CONFIG_LIMIT(battery_config->desktop_notifications, 0, 1);
#endif
battery_config->module = m; battery_config->module = m;
battery_config->full = -2; battery_config->full = -2;
@ -793,6 +806,11 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
_battery_dbus_stop(); _battery_dbus_stop();
#endif #endif
#ifdef HAVE_ENOTIFY
e_notification_shutdown();
#endif
free(battery_config); free(battery_config);
battery_config = NULL; battery_config = NULL;
E_CONFIG_DD_FREE(conf_edd); E_CONFIG_DD_FREE(conf_edd);