forked from enlightenment/enlightenment
Add desktop notifications to battery module.
SVN revision: 67027
This commit is contained in:
parent
a0ae01c227
commit
40b2ec83b7
|
@ -14,6 +14,9 @@ struct _E_Config_Dialog_Data
|
|||
int alert_timeout;
|
||||
int suspend_below;
|
||||
int force_mode; // 0 == auto, 1 == batget, 2 == subsystem
|
||||
#ifdef HAVE_ENOTIFY
|
||||
int desktop_notifications;
|
||||
#endif
|
||||
struct
|
||||
{
|
||||
Evas_Object *show_alert_label;
|
||||
|
@ -77,6 +80,9 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
|||
#ifdef HAVE_EEZE
|
||||
cfdata->fuzzy = battery_config->fuzzy;
|
||||
#endif
|
||||
#ifdef HAVE_ENOTIFY
|
||||
cfdata->desktop_notifications = battery_config->desktop_notifications;
|
||||
#endif
|
||||
|
||||
if ((cfdata->alert_time > 0) || (cfdata->alert_percent > 0))
|
||||
cfdata->show_alert = 1;
|
||||
|
@ -126,6 +132,11 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dial
|
|||
ob = e_widget_check_add(evas, _("Show alert when battery is low"),
|
||||
&(cfdata->show_alert));
|
||||
e_widget_list_object_append(o, ob, 1, 0, 0.5);
|
||||
#ifdef HAVE_ENOTIFY
|
||||
ob = e_widget_check_add(evas, _("Use desktop notifications for alert."),
|
||||
&(cfdata->desktop_notifications));
|
||||
e_widget_list_object_append(o, ob, 1, 0, 0.5);
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -139,11 +150,17 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
|||
_ensure_alert_time(cfdata);
|
||||
battery_config->alert = cfdata->alert_time;
|
||||
battery_config->alert_p = cfdata->alert_percent;
|
||||
#ifdef HAVE_ENOTIFY
|
||||
battery_config->desktop_notifications = cfdata->desktop_notifications;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
battery_config->alert = 0;
|
||||
battery_config->alert_p = 0;
|
||||
#ifdef HAVE_ENOTIFY
|
||||
battery_config->desktop_notifications = EINA_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
_battery_config_updated();
|
||||
|
@ -154,10 +171,15 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
|||
static int
|
||||
_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Eina_Bool ret;
|
||||
int old_show_alert = ((battery_config->alert > 0) ||
|
||||
(battery_config->alert_p > 0));
|
||||
|
||||
return (cfdata->show_alert != old_show_alert);
|
||||
ret = (cfdata->show_alert != old_show_alert);
|
||||
#ifdef HAVE_ENOTIFY
|
||||
ret |= (cfdata->desktop_notifications != battery_config->desktop_notifications);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#ifdef HAVE_ENOTIFY
|
||||
#include "E_Notify.h"
|
||||
#endif
|
||||
|
||||
/* gadcon requirements */
|
||||
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
||||
|
@ -427,9 +430,28 @@ _battery_warning_popup(Instance *inst, int time, double percent)
|
|||
Evas *e = NULL;
|
||||
Evas_Object *rect = NULL, *popup_bg = NULL;
|
||||
int x,y,w,h;
|
||||
#ifdef HAVE_ENOTIFY
|
||||
static E_Notification *notification;
|
||||
#endif
|
||||
|
||||
if ((!inst) || (inst->warning)) return;
|
||||
|
||||
#ifdef HAVE_ENOTIFY
|
||||
if (battery_config && battery_config->desktop_notifications)
|
||||
{
|
||||
if (notification) return;
|
||||
notification = e_notification_full_new("Enlightenment",
|
||||
0,
|
||||
"battery-low",
|
||||
_("Your battery is low!"),
|
||||
_("AC power is recommended."),
|
||||
2);
|
||||
e_notification_send(notification, NULL, NULL);
|
||||
e_notification_unref(notification);
|
||||
notification = NULL;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
inst->warning = e_gadcon_popup_new(inst->gcc);
|
||||
if (!inst->warning) return;
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@ struct _Config
|
|||
int time_full;
|
||||
int have_battery;
|
||||
int have_power;
|
||||
#ifdef HAVE_ENOTIFY
|
||||
int desktop_notifications;
|
||||
#endif
|
||||
#ifdef HAVE_EEZE
|
||||
Eeze_Udev_Watch *acwatch;
|
||||
Eeze_Udev_Watch *batwatch;
|
||||
|
|
Loading…
Reference in New Issue