summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Houston <stephen@localhost.localdomain>2018-02-09 12:26:48 -0600
committerStephen Houston <stephen@localhost.localdomain>2018-02-09 12:26:48 -0600
commit5598c2e2c36e43a542030db9c34f283754c59294 (patch)
tree01960719c819a8c82d8daba10a08193a65d1687b
parent9049d050d5dbe75fb5ee7114d8f90ddbaee38a7f (diff)
Fix batman alert system to work with sandbox.
-rw-r--r--batman/src/batman.c92
-rw-r--r--cpuclock/src/cpuclock.c1
-rw-r--r--cpumonitor/src/cpumonitor.c1
-rw-r--r--memusage/src/memusage.c1
-rw-r--r--netstatus/src/netstatus.c1
5 files changed, 45 insertions, 51 deletions
diff --git a/batman/src/batman.c b/batman/src/batman.c
index d166c15..806ab03 100644
--- a/batman/src/batman.c
+++ b/batman/src/batman.c
@@ -5,9 +5,8 @@ Eina_List *batman_device_batteries;
5Eina_List *batman_device_ac_adapters; 5Eina_List *batman_device_ac_adapters;
6double batman_init_time; 6double batman_init_time;
7 7
8//static Eina_Bool _batman_cb_warning_popup_timeout(void *data); 8static Eina_Bool _batman_cb_warning_popup_timeout(void *data);
9//static void _batman_cb_warning_popup_hide(void *data, Evas *e, Evas_Object *obj, void *event); 9static void _batman_warning_popup_destroy(Instance *inst);
10//static void _batman_warning_popup_destroy(Instance *inst);
11static void _batman_warning_popup(Instance *inst, int time, double percent); 10static void _batman_warning_popup(Instance *inst, int time, double percent);
12 11
13//static Ecore_Event_Handler *_handler = NULL; 12//static Ecore_Event_Handler *_handler = NULL;
@@ -251,8 +250,8 @@ _batman_update(Instance *inst, int full, int time_left, Eina_Bool have_battery,
251 _batman_warning_popup(inst, time_left, (double)full / 100.0); 250 _batman_warning_popup(inst, time_left, (double)full / 100.0);
252 } 251 }
253 } 252 }
254 //else if (have_power || ((time_left / 60) > inst->cfg->batman.alert)) 253 else if (have_power || ((time_left / 60) > inst->cfg->batman.alert))
255 // _batman_warning_popup_destroy(inst); 254 _batman_warning_popup_destroy(inst);
256 if ((have_battery) && (!have_power) && (full >= 0) && 255 if ((have_battery) && (!have_power) && (full >= 0) &&
257 (inst->cfg->batman.suspend_below > 0) && 256 (inst->cfg->batman.suspend_below > 0) &&
258 (full < inst->cfg->batman.suspend_below)) 257 (full < inst->cfg->batman.suspend_below))
@@ -377,8 +376,8 @@ _batman_config_updated(Instance *inst)
377 } 376 }
378} 377}
379 378
380/*static void 379static Eina_Bool
381_warning_popup_dismissed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 380_batman_cb_warning_popup_timeout(void *data)
382{ 381{
383 Instance *inst = data; 382 Instance *inst = data;
384 383
@@ -386,39 +385,44 @@ _warning_popup_dismissed(void *data, Evas_Object *obj EINA_UNUSED, void *event_i
386 inst->popup_battery = NULL; 385 inst->popup_battery = NULL;
387 evas_object_del(inst->warning); 386 evas_object_del(inst->warning);
388 inst->warning = NULL; 387 inst->warning = NULL;
389}
390
391static Eina_Bool
392_batman_cb_warning_popup_timeout(void *data)
393{
394 Instance *inst;
395
396 inst = data;
397 elm_ctxpopup_dismiss(inst->warning);
398 inst->cfg->batman.alert_timer = NULL; 388 inst->cfg->batman.alert_timer = NULL;
399 return ECORE_CALLBACK_CANCEL; 389 return ECORE_CALLBACK_CANCEL;
400} 390}
401 391
402static void 392static void
403_batman_cb_warning_popup_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) 393_batman_warning_popup_destroy(Instance *inst)
404{ 394{
405 Instance *inst = NULL; 395 if (inst->cfg->batman.alert_timer)
406 396 {
407 inst = (Instance *)data; 397 ecore_timer_del(inst->cfg->batman.alert_timer);
408 if ((!inst) || (!inst->warning)) return; 398 inst->cfg->batman.alert_timer = NULL;
409 evas_object_hide(inst->warning); 399 }
400 if (!inst->warning) return;
401 evas_object_del(inst->warning);
402 inst->warning = NULL;
410} 403}
411 404
412static void 405static void
413_batman_warning_popup_destroy(Instance *inst) 406_batman_warning_popup_close(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
414{ 407{
408 Instance *inst = data;
409
415 if (inst->cfg->batman.alert_timer) 410 if (inst->cfg->batman.alert_timer)
416 { 411 {
417 ecore_timer_del(inst->cfg->batman.alert_timer); 412 ecore_timer_del(inst->cfg->batman.alert_timer);
418 inst->cfg->batman.alert_timer = NULL; 413 inst->cfg->batman.alert_timer = NULL;
419 } 414 }
420 if (!inst->warning) return; 415 if (!inst->warning) return;
421 elm_ctxpopup_dismiss(inst->warning); 416 evas_object_del(inst->warning);
417 inst->warning = NULL;
418}
419
420static void
421_batman_warning_popup_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
422{
423 Instance *inst = data;
424
425 inst->warning = NULL;
422} 426}
423 427
424static void 428static void
@@ -427,13 +431,12 @@ _batman_warning_popup_cb(void *data, unsigned int id)
427 Instance *inst = data; 431 Instance *inst = data;
428 432
429 inst->notification_id = id; 433 inst->notification_id = id;
430}*/ 434}
431 435
432static void 436static void
433_batman_warning_popup(Instance *inst EINA_UNUSED, int t EINA_UNUSED, double percent EINA_UNUSED) 437_batman_warning_popup(Instance *inst EINA_UNUSED, int t EINA_UNUSED, double percent EINA_UNUSED)
434{ 438{
435 /*Evas_Object *popup_bg = NULL; 439 Evas_Object *popup_bg = NULL;
436 int x, y, w, h;
437 char buf[4096]; 440 char buf[4096];
438 int hrs = 0, mins = 0; 441 int hrs = 0, mins = 0;
439 442
@@ -446,21 +449,22 @@ _batman_warning_popup(Instance *inst EINA_UNUSED, int t EINA_UNUSED, double perc
446 449
447 if (inst->cfg->batman.desktop_notifications) 450 if (inst->cfg->batman.desktop_notifications)
448 { 451 {
449 E_Notification_Notify n; 452 elm_sys_notify_send(0, "battery-low", _("Your battery is low!"), buf,
450 memset(&n, 0, sizeof(E_Notification_Notify)); 453 ELM_SYS_NOTIFY_URGENCY_CRITICAL,
451 n.app_name = _("Battery"); 454 inst->cfg->batman.alert_timeout * 1000,
452 n.replaces_id = 0; 455 _batman_warning_popup_cb, inst);
453 n.icon.icon = "battery-low";
454 n.summary = _("Your battery is low!");
455 n.body = buf;
456 n.timeout = inst->cfg->batman.alert_timeout * 1000;
457 // e_notification_client_send(&n, _batman_warning_popup_cb, inst);
458 return; 456 return;
459 } 457 }
460 458
461 inst->warning = elm_ctxpopup_add(e_comp->elm); 459 inst->warning = elm_win_add(inst->win, "win", ELM_WIN_POPUP_MENU);
462 elm_object_style_set(inst->warning, "noblock"); 460 if (inst->gadget)
463 evas_object_smart_callback_add(inst->warning, "dismissed", _warning_popup_dismissed, inst); 461 elm_win_alpha_set(inst->warning, 1);
462 else
463 elm_win_autodel_set(inst->warning, 1);
464 evas_object_event_callback_add(inst->warning, EVAS_CALLBACK_MOUSE_DOWN,
465 _batman_warning_popup_close, inst);
466 evas_object_event_callback_add(inst->warning, EVAS_CALLBACK_DEL,
467 _batman_warning_popup_deleted, inst);
464 if (!inst->warning) return; 468 if (!inst->warning) return;
465 469
466 popup_bg = elm_layout_add(inst->warning); 470 popup_bg = elm_layout_add(inst->warning);
@@ -488,15 +492,9 @@ _batman_warning_popup(Instance *inst EINA_UNUSED, int t EINA_UNUSED, double perc
488 evas_object_show(inst->popup_battery); 492 evas_object_show(inst->popup_battery);
489 evas_object_show(popup_bg); 493 evas_object_show(popup_bg);
490 494
491 elm_object_content_set(inst->warning, popup_bg); 495 elm_win_resize_object_add(inst->warning, popup_bg);
492// gadget_util_ctxpopup_place(inst->o_main, inst->warning, inst->cfg->batman.o_gadget);
493 evas_object_layer_set(inst->warning, E_LAYER_POPUP);
494 evas_object_show(inst->warning); 496 evas_object_show(inst->warning);
495 497
496 evas_object_geometry_get(inst->warning, &x, &y, &w, &h);
497 evas_object_event_callback_add(inst->warning, EVAS_CALLBACK_MOUSE_DOWN,
498 _batman_cb_warning_popup_hide, inst);
499
500 _batman_face_level_set(inst->popup_battery, percent); 498 _batman_face_level_set(inst->popup_battery, percent);
501 edje_object_signal_emit(inst->popup_battery, "e,state,discharging", "e"); 499 edje_object_signal_emit(inst->popup_battery, "e,state,discharging", "e");
502 500
@@ -506,7 +504,7 @@ _batman_warning_popup(Instance *inst EINA_UNUSED, int t EINA_UNUSED, double perc
506 inst->cfg->batman.alert_timer = 504 inst->cfg->batman.alert_timer =
507 ecore_timer_loop_add(inst->cfg->batman.alert_timeout, 505 ecore_timer_loop_add(inst->cfg->batman.alert_timeout,
508 _batman_cb_warning_popup_timeout, inst); 506 _batman_cb_warning_popup_timeout, inst);
509 }*/ 507 }
510} 508}
511 509
512static void 510static void
diff --git a/cpuclock/src/cpuclock.c b/cpuclock/src/cpuclock.c
index e9b1fd0..e3c4b54 100644
--- a/cpuclock/src/cpuclock.c
+++ b/cpuclock/src/cpuclock.c
@@ -237,7 +237,6 @@ _cpuclock_popup_create(Instance *inst)
237 elm_win_alpha_set(popup, 1); 237 elm_win_alpha_set(popup, 1);
238 else 238 else
239 elm_win_autodel_set(popup, 1); 239 elm_win_autodel_set(popup, 1);
240 elm_object_style_set(popup, "noblock");
241 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, 240 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL,
242 _cpuclock_popup_deleted, inst); 241 _cpuclock_popup_deleted, inst);
243 242
diff --git a/cpumonitor/src/cpumonitor.c b/cpumonitor/src/cpumonitor.c
index 2bbbbba..9ec619d 100644
--- a/cpumonitor/src/cpumonitor.c
+++ b/cpumonitor/src/cpumonitor.c
@@ -70,7 +70,6 @@ _cpumonitor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
70 elm_win_alpha_set(popup, 1); 70 elm_win_alpha_set(popup, 1);
71 else 71 else
72 elm_win_autodel_set(popup, 1); 72 elm_win_autodel_set(popup, 1);
73 elm_object_style_set(popup, "noblock");
74 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _cpumonitor_popup_deleted, inst); 73 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _cpumonitor_popup_deleted, inst);
75 74
76 box = elm_box_add(popup); 75 box = elm_box_add(popup);
diff --git a/memusage/src/memusage.c b/memusage/src/memusage.c
index 03fa972..0a796f1 100644
--- a/memusage/src/memusage.c
+++ b/memusage/src/memusage.c
@@ -117,7 +117,6 @@ _memusage_popup_create(Instance *inst)
117 elm_win_alpha_set(popup, 1); 117 elm_win_alpha_set(popup, 1);
118 else 118 else
119 elm_win_autodel_set(popup, 1); 119 elm_win_autodel_set(popup, 1);
120 elm_object_style_set(popup, "noblock");
121 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, 120 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL,
122 _memusage_popup_deleted, inst); 121 _memusage_popup_deleted, inst);
123 122
diff --git a/netstatus/src/netstatus.c b/netstatus/src/netstatus.c
index a4ff8c6..638e1ab 100644
--- a/netstatus/src/netstatus.c
+++ b/netstatus/src/netstatus.c
@@ -90,7 +90,6 @@ _netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
90 elm_win_alpha_set(popup, 1); 90 elm_win_alpha_set(popup, 1);
91 else 91 else
92 elm_win_autodel_set(popup, 1); 92 elm_win_autodel_set(popup, 1);
93 elm_object_style_set(popup, "noblock");
94 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _netstatus_popup_deleted, inst); 93 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _netstatus_popup_deleted, inst);
95 94
96 table = elm_table_add(popup); 95 table = elm_table_add(popup);