These are good changes on the batt mod...

+1


dh


On 3/7/21 3:22 PM, Alastair Poole wrote:
netstar pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=39b7896df50c0a352da61ce74f55de8389b2f4a4

commit 39b7896df50c0a352da61ce74f55de8389b2f4a4
Author: Alastair Poole <[email protected]>
Date:   Sun Mar 7 20:21:12 2021 +0000

     battery: fix sysctl battery update and naming.
---
  src/modules/battery/e_mod_main.c   | 30 +++++++++++++++++-------------
  src/modules/battery/e_mod_sysctl.c | 28 +++++++++++++++++++---------
  2 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/src/modules/battery/e_mod_main.c b/src/modules/battery/e_mod_main.c
index fc3a83956..48ec0b2ed 100644
--- a/src/modules/battery/e_mod_main.c
+++ b/src/modules/battery/e_mod_main.c
@@ -73,6 +73,9 @@ static void      _battery_cb_warning_popup_hide(void *data, 
Evas *e, Evas_Object
  static void      _battery_warning_popup_destroy(Instance *inst);
  static void      _battery_warning_popup(Instance *inst, int time, double 
percent);
+static void _battery_popup_usage_destroy(Instance *inst);
+static void      _battery_popup_usage_new(Instance *inst);
+
  static Eina_Bool _powersave_cb_config_update(void *data, int type, void 
*event);
static E_Config_DD *conf_edd = NULL;
@@ -131,6 +134,7 @@ _gc_shutdown(E_Gadcon_Client *gcc)
          e_object_del(E_OBJECT(inst->warning));
          inst->popup_battery = NULL;
       }
+   _battery_popup_usage_destroy(inst);
     E_FREE(inst);
  }
@@ -183,7 +187,7 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class)
  }
static void
-_popup_usage_del(Instance *inst)
+_battery_popup_usage_destroy(Instance *inst)
  {
     if (inst->popup_timer) ecore_timer_del(inst->popup_timer);
     E_FREE_FUNC(inst->popup, e_object_del);
@@ -193,13 +197,13 @@ _popup_usage_del(Instance *inst)
  }
static void
-_popup_usage_del_cb(void *obj)
+_battery_popup_usage_destroy_cb(void *obj)
  {
-   _popup_usage_del(e_object_data_get(obj));
+   _battery_popup_usage_destroy(e_object_data_get(obj));
  }
static Eina_Bool
-_popup_usage_content_update_cb(void *data)
+_battery_popup_usage_content_update_cb(void *data)
  {
     Instance *inst;
     _Popup_Data *pd;
@@ -214,7 +218,7 @@ _popup_usage_content_update_cb(void *data)
if (!battery_config->have_battery)
       {
-        _popup_usage_del(inst);
+        _battery_popup_usage_destroy(inst);
          return ECORE_CALLBACK_CANCEL;
       }
@@ -252,7 +256,7 @@ _popup_usage_content_update_cb(void *data)
  }
static Evas_Object *
-_popup_usage_content_add(Evas_Object *parent, Instance *inst)
+_battery_popup_usage_content_add(Evas_Object *parent, Instance *inst)
  {
     Evas_Object *tb, *tb2, *fr, *lb, *pb, *sep, *rec;
     _Popup_Data *pd;
@@ -333,22 +337,22 @@ _popup_usage_content_add(Evas_Object *parent, Instance 
*inst)
          elm_table_pack(tb2, sep, 0, 3, 2, 1);
       }
- _popup_usage_content_update_cb(pd);
+   _battery_popup_usage_content_update_cb(pd);
if (battery_config->have_battery)
-     inst->popup_timer = ecore_timer_add(10.0, _popup_usage_content_update_cb, 
pd);
+     inst->popup_timer = ecore_timer_add(10.0, 
_battery_popup_usage_content_update_cb, pd);
return tb;
  }
static void
-_popup_usage_new(Instance *inst)
+_battery_popup_usage_new(Instance *inst)
  {
     inst->popup = e_gadcon_popup_new(inst->gcc, 0);
-   e_gadcon_popup_content_set(inst->popup, 
_popup_usage_content_add(e_comp->elm, inst));
+   e_gadcon_popup_content_set(inst->popup, 
_battery_popup_usage_content_add(e_comp->elm, inst));
     e_gadcon_popup_show(inst->popup);
     e_object_data_set(E_OBJECT(inst->popup),inst);
-   E_OBJECT_DEL_SET(inst->popup, _popup_usage_del_cb);
+   E_OBJECT_DEL_SET(inst->popup, _battery_popup_usage_destroy_cb);
  }
static void
@@ -394,9 +398,9 @@ _button_cb_mouse_down(void *data, Evas *e, Evas_Object 
*obj, void *event_info)
          _battery_cb_warning_popup_hide(data, e, obj, event_info);
if (!inst->popup)
-          _popup_usage_new(inst);
+          _battery_popup_usage_new(inst);
          else
-          _popup_usage_del(inst);
+          _battery_popup_usage_destroy(inst);
       }
  }
diff --git a/src/modules/battery/e_mod_sysctl.c b/src/modules/battery/e_mod_sysctl.c
index 38d69c7c6..b199d4ad6 100644
--- a/src/modules/battery/e_mod_sysctl.c
+++ b/src/modules/battery/e_mod_sysctl.c
@@ -16,19 +16,22 @@
  # include <sys/sensors.h>
  #endif
-static Eina_Bool _battery_sysctl_battery_update_poll(void *data EINA_UNUSED);
-static int       _battery_sysctl_battery_update();
+static Eina_Bool   _battery_sysctl_battery_update_poll(void *data EINA_UNUSED);
+static int         _battery_sysctl_battery_update();
-extern Eina_List *device_batteries;
-extern Eina_List *device_ac_adapters;
-extern double init_time;
+extern Eina_List  *device_batteries;
+extern Eina_List  *device_ac_adapters;
+extern double      init_time;
static Ac_Adapter *ac = NULL;
-static Battery *bat = NULL;
int
  _battery_sysctl_start(void)
  {
+   Battery *bat;
+
+   if (device_batteries) return 1;
+
  # if defined(__OpenBSD__)
     int mib[] = {CTL_HW, HW_SENSORS, 0, 0, 0};
     int devn;
@@ -134,6 +137,8 @@ _battery_sysctl_start(void)
  void
  _battery_sysctl_stop(void)
  {
+   Battery *bat;
+
     if (ac)
       {
          eina_stringshare_del(ac->udi);
@@ -143,7 +148,7 @@ _battery_sysctl_stop(void)
          E_FREE(ac);
       }
- if (bat)
+   EINA_LIST_FREE(device_batteries, bat)
       {
          eina_stringshare_del(bat->udi);
          eina_stringshare_del(bat->technology);
@@ -160,12 +165,17 @@ _battery_sysctl_stop(void)
  static Eina_Bool
  _battery_sysctl_battery_update_poll(void *data EINA_UNUSED)
  {
-   _battery_sysctl_battery_update();
+   Battery *bat;
+   Eina_List *l;
+
+   EINA_LIST_FOREACH(device_batteries, l, bat)
+     _battery_sysctl_battery_update(bat);
+
     return EINA_TRUE;
  }
static int
-_battery_sysctl_battery_update()
+_battery_sysctl_battery_update(Battery *bat)
  {
     double _time;
  # if defined(__OpenBSD__)



_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to