This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository enlightenment.

View the commit online.

commit 43e6c1ee218a0384c67642176e52c19141195da3
Author: [email protected] <[email protected]>
AuthorDate: Tue Apr 14 21:45:39 2026 -0600

    refactor(networkmanager): address PR #125 review feedback
    
    This commit consolidates raster's review comments (PR1 batch) and
    implements the following improvements:
    
    1. Replace 4096-byte static buffer with lazy stringshare cache for
       theme path and small 64-byte buffer for gadget ID generation
    
    2. Convert paired eina_stringshare_del/add calls to eina_stringshare_replace
       at device adoption, watch tear-down, and no-active-connections paths
    
    3. Add null-check guard in _enm_popup_build_entries to match sibling
       functions
    
    4. Remove custom E_EVENT_SCREENSAVER_ON/OFF handlers and screen_off
       field — rely solely on E_EVENT_POWERSAVE_UPDATE / powersave_high
    
    5. Guard sysfs counter reader with #ifdef __linux__ and provide
       non-Linux stub implementation
    
    6. Replace immediate genlist item deselect with 0.5s deselect timer,
       cleaned up in enm_popup_del and _enm_popup_update
    
    7. Remove evas_object_size_hint_min_set on popup genlist (scrollers
       self-size)
    
    8. Collapse _enm_popup_update_timer_cb to call enm_mod_aps_update_now()
    
    All changes scoped to src/modules/networkmanager/. Module builds cleanly.
    
    Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
---
 src/modules/networkmanager/e_mod_main.c       | 116 +++++++++++++-------------
 src/modules/networkmanager/e_mod_main.h       |   5 +-
 src/modules/networkmanager/e_networkmanager.c |  38 ++++-----
 3 files changed, 72 insertions(+), 87 deletions(-)

diff --git a/src/modules/networkmanager/e_mod_main.c b/src/modules/networkmanager/e_mod_main.c
index 4c08abe65..cf825f3b7 100644
--- a/src/modules/networkmanager/e_mod_main.c
+++ b/src/modules/networkmanager/e_mod_main.c
@@ -3,7 +3,7 @@
 #include "e_networkmanager.h"
 
 E_Module *networkmanager_mod = NULL;
-static char tmpbuf[4096]; /* general purpose buffer, use immediately */
+static Eina_Stringshare *_theme_path = NULL;
 
 const char _e_nm_name[] = "networkmanager";
 const char _e_nm_Name[] = N_("NetworkManager");
@@ -16,18 +16,14 @@ static void _enm_traffic_timer_stop(E_NM_Module_Context *ctxt);
 const char *
 e_nm_theme_path(void)
 {
-#define TF "/e-module-connman.edj"
-   size_t dirlen;
+   char buf[PATH_MAX];
 
-   dirlen = strlen(networkmanager_mod->dir);
-   if (dirlen >= sizeof(tmpbuf) - sizeof(TF))
-     return NULL;
-
-   memcpy(tmpbuf, networkmanager_mod->dir, dirlen);
-   memcpy(tmpbuf + dirlen, TF, sizeof(TF));
-
-   return tmpbuf;
-#undef TF
+   if (_theme_path) return _theme_path;
+   if (!networkmanager_mod || !networkmanager_mod->dir) return NULL;
+   snprintf(buf, sizeof(buf), "%s/e-module-connman.edj",
+            networkmanager_mod->dir);
+   _theme_path = eina_stringshare_add(buf);
+   return _theme_path;
 }
 
 /* --- popup ---------------------------------------------------------------- */
@@ -35,6 +31,8 @@ e_nm_theme_path(void)
 void
 enm_popup_del(E_NM_Instance *inst)
 {
+   E_FREE_FUNC(inst->ui.popup.deselect_timer, ecore_timer_del);
+   inst->ui.popup.deselect_item = NULL;
    E_FREE_FUNC(inst->popup, e_object_del);
    E_FREE_FUNC(inst->ctxt->popup_update_timer, ecore_timer_del);
    inst->ui.popup.genlist = inst->ui.popup.ip_label = NULL;
@@ -253,6 +251,27 @@ _enm_itc_group_wifi_content_get(void *data, Evas_Object *obj,
    return ck;
 }
 
+static Eina_Bool
+_enm_deselect_timer_cb(void *data)
+{
+   E_NM_Instance *inst = data;
+
+   if (inst->ui.popup.deselect_item)
+     elm_genlist_item_selected_set(inst->ui.popup.deselect_item, EINA_FALSE);
+   inst->ui.popup.deselect_item = NULL;
+   inst->ui.popup.deselect_timer = NULL;
+   return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_enm_deselect_timer_schedule(E_NM_Instance *inst, Elm_Object_Item *it)
+{
+   E_FREE_FUNC(inst->ui.popup.deselect_timer, ecore_timer_del);
+   inst->ui.popup.deselect_item = it;
+   inst->ui.popup.deselect_timer =
+      ecore_timer_add(0.5, _enm_deselect_timer_cb, inst);
+}
+
 /* Activated smart callback — handles connect/disconnect on row tap */
 static void
 _enm_item_activated_cb(void *data, Evas_Object *obj EINA_UNUSED,
@@ -265,8 +284,8 @@ _enm_item_activated_cb(void *data, Evas_Object *obj EINA_UNUSED,
    struct NM_Device *dev;
 
    if (!it) return;
-   /* Deselect immediately so repeat clicks always fire "selected" */
-   elm_genlist_item_selected_set(it, EINA_FALSE);
+   /* Delay deselect so the user sees their click landed. */
+   _enm_deselect_timer_schedule(inst, it);
    id = elm_object_item_data_get(it);
    if (!id) return;
 
@@ -550,6 +569,8 @@ _enm_popup_build_entries(struct NM_Manager *nm,
    Eina_Hash *seen_ssids;
    int n = 0;
 
+   if (!nm) return 0;
+
    /* Ethernet entries first */
    EINA_INLIST_FOREACH(nm->devices, dev)
      {
@@ -620,6 +641,11 @@ _enm_popup_update(struct NM_Manager *nm, E_NM_Instance *inst)
    EINA_SAFETY_ON_NULL_RETURN(nm);
    EINA_SAFETY_ON_NULL_RETURN(gl);
 
+   /* elm_genlist_clear() below frees all items — drop any pending
+    * deselect targeting an item about to be destroyed. */
+   E_FREE_FUNC(inst->ui.popup.deselect_timer, ecore_timer_del);
+   inst->ui.popup.deselect_item = NULL;
+
    want_n = _enm_popup_build_entries(nm, desired, 256);
 
    /* Count per-type so we know whether to insert group headers */
@@ -763,7 +789,6 @@ _enm_popup_new(E_NM_Instance *inst)
    gl = elm_genlist_add(box);
    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   evas_object_size_hint_min_set(gl, ELM_SCALE_SIZE(192), ELM_SCALE_SIZE(100));
    elm_scroller_bounce_set(gl, EINA_FALSE, EINA_TRUE);
    evas_object_show(gl);
    inst->ui.popup.genlist = gl;
@@ -831,19 +856,9 @@ static Eina_Bool
 _enm_popup_update_timer_cb(void *data)
 {
    E_NM_Module_Context *ctxt = data;
-   const Eina_List *l;
-   E_NM_Instance *inst;
 
    ctxt->popup_update_timer = NULL;
-
-   if (!ctxt->nm) return ECORE_CALLBACK_CANCEL;
-
-   EINA_LIST_FOREACH(ctxt->instances, l, inst)
-     {
-        if (!inst->popup) continue;
-        _enm_popup_update(ctxt->nm, inst);
-     }
-
+   enm_mod_aps_update_now();
    return ECORE_CALLBACK_CANCEL;
 }
 
@@ -865,11 +880,12 @@ void
 enm_mod_aps_update_now(void)
 {
    E_NM_Module_Context *ctxt;
-   if (!networkmanager_mod) return;
-   ctxt = networkmanager_mod->data;
    const Eina_List *l;
    E_NM_Instance *inst;
 
+   if (!networkmanager_mod) return;
+   ctxt = networkmanager_mod->data;
+
    /* Cancel any pending throttle timer — we are doing an immediate rebuild */
    E_FREE_FUNC(ctxt->popup_update_timer, ecore_timer_del);
 
@@ -1109,6 +1125,7 @@ static Eina_Bool
 _enm_read_sysfs_counter(const char *iface, const char *counter,
                          unsigned long long *val)
 {
+#ifdef __linux__
    char path[256];
    FILE *f;
 
@@ -1122,6 +1139,11 @@ _enm_read_sysfs_counter(const char *iface, const char *counter,
      }
    fclose(f);
    return EINA_TRUE;
+#else
+   (void)iface; (void)counter;
+   *val = 0;
+   return EINA_FALSE;
+#endif
 }
 
 /* Classify bytes/sec into traffic level: 0=idle, 1=low, 2=medium, 3=high
@@ -1221,7 +1243,7 @@ static void
 _enm_traffic_timer_start(E_NM_Module_Context *ctxt)
 {
    if (ctxt->traffic_timer) return;
-   if (ctxt->screen_off || ctxt->powersave_high) return;
+   if (ctxt->powersave_high) return;
    if (!ctxt->nm) return;
    if (ctxt->nm->state < NM_STATE_CONNECTED_LOCAL) return;
 
@@ -1244,26 +1266,6 @@ _enm_traffic_timer_stop(E_NM_Module_Context *ctxt)
      }
 }
 
-static Eina_Bool
-_enm_screensaver_on_cb(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
-{
-   E_NM_Module_Context *ctxt = data;
-
-   ctxt->screen_off = EINA_TRUE;
-   _enm_traffic_timer_stop(ctxt);
-   return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_enm_screensaver_off_cb(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
-{
-   E_NM_Module_Context *ctxt = data;
-
-   ctxt->screen_off = EINA_FALSE;
-   _enm_traffic_timer_start(ctxt);
-   return ECORE_CALLBACK_PASS_ON;
-}
-
 static Eina_Bool
 _enm_powersave_cb(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
 {
@@ -1407,6 +1409,7 @@ _gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas)
 static const char *
 _gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
 {
+   static char idbuf[64]; /* returned string — use immediately */
    E_NM_Module_Context *ctxt;
    Eina_List *instances;
 
@@ -1416,9 +1419,9 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
    if (!ctxt) return NULL;
 
    instances = ctxt->instances;
-   snprintf(tmpbuf, sizeof(tmpbuf), "networkmanager.%d",
+   snprintf(idbuf, sizeof(idbuf), "networkmanager.%d",
             eina_list_count(instances));
-   return tmpbuf;
+   return idbuf;
 }
 
 static const E_Gadcon_Client_Class _gc_class =
@@ -1487,13 +1490,6 @@ e_modapi_init(E_Module *m)
    /* Initialize power-aware traffic monitoring state */
    ctxt->powersave_high = (e_powersave_mode_get() >= E_POWERSAVE_MODE_EXTREME);
 
-   /* Register event handlers for power-aware traffic monitoring */
-   ctxt->screensaver_on_handler =
-     ecore_event_handler_add(E_EVENT_SCREENSAVER_ON,
-                             _enm_screensaver_on_cb, ctxt);
-   ctxt->screensaver_off_handler =
-     ecore_event_handler_add(E_EVENT_SCREENSAVER_OFF,
-                             _enm_screensaver_off_cb, ctxt);
    ctxt->powersave_handler =
      ecore_event_handler_add(E_EVENT_POWERSAVE_UPDATE,
                              _enm_powersave_cb, ctxt);
@@ -1542,12 +1538,12 @@ e_modapi_shutdown(E_Module *m)
 
    E_FREE_FUNC(ctxt->popup_update_timer, ecore_timer_del);
    E_FREE_FUNC(ctxt->traffic_timer, ecore_timer_del);
-   E_FREE_FUNC(ctxt->screensaver_on_handler, ecore_event_handler_del);
-   E_FREE_FUNC(ctxt->screensaver_off_handler, ecore_event_handler_del);
    E_FREE_FUNC(ctxt->powersave_handler, ecore_event_handler_del);
    E_FREE(ctxt);
    networkmanager_mod = NULL;
 
+   eina_stringshare_replace(&_theme_path, NULL);
+
    eina_log_domain_unregister(_e_nm_log_dom);
    _e_nm_log_dom = -1;
 
diff --git a/src/modules/networkmanager/e_mod_main.h b/src/modules/networkmanager/e_mod_main.h
index 06484d168..ab41faa41 100644
--- a/src/modules/networkmanager/e_mod_main.h
+++ b/src/modules/networkmanager/e_mod_main.h
@@ -32,6 +32,8 @@ struct E_NM_Instance
              Elm_Genlist_Item_Class *itc_group_wifi;
              Elm_Genlist_Item_Class *itc_ap;
              Elm_Genlist_Item_Class *itc_eth;
+             Ecore_Timer            *deselect_timer;
+             Elm_Object_Item        *deselect_item;
           } popup;
      } ui;
 };
@@ -46,14 +48,11 @@ struct E_NM_Module_Context
 
    /* Network activity indicator */
    Ecore_Timer        *traffic_timer;
-   Ecore_Event_Handler *screensaver_on_handler;
-   Ecore_Event_Handler *screensaver_off_handler;
    Ecore_Event_Handler *powersave_handler;
    unsigned long long   prev_rx;
    unsigned long long   prev_tx;
    int                  rx_level; /* 0=idle, 1=low, 2=medium, 3=high */
    int                  tx_level;
-   Eina_Bool            screen_off : 1;
    Eina_Bool            powersave_high : 1;
 };
 
diff --git a/src/modules/networkmanager/e_networkmanager.c b/src/modules/networkmanager/e_networkmanager.c
index aa723b357..1a5bd13a8 100644
--- a/src/modules/networkmanager/e_networkmanager.c
+++ b/src/modules/networkmanager/e_networkmanager.c
@@ -531,14 +531,12 @@ _device_get_props_cb(void *data, const Eldbus_Message *msg,
         _manager_active_conn_watch_free(nm_manager);
         _manager_ip4_watch_free(nm_manager);
 
-        eina_stringshare_del(nm_manager->active_connection_path);
-        nm_manager->active_connection_path =
-           eina_stringshare_add(dev->active_conn_path);
+        eina_stringshare_replace(&nm_manager->active_connection_path,
+                                 dev->active_conn_path);
 
         nm_manager->active_conn_type = NM_DEVICE_TYPE_ETHERNET;
 
-        eina_stringshare_del(nm_manager->active_ap_path);
-        nm_manager->active_ap_path = NULL;
+        eina_stringshare_replace(&nm_manager->active_ap_path, NULL);
 
         /* Set up persistent watcher on the active connection object */
         {
@@ -625,12 +623,9 @@ _device_wifi_props_cb(void *data, const Eldbus_Message *msg,
 
    nm_manager->active_conn_type = NM_DEVICE_TYPE_WIFI;
 
-   eina_stringshare_del(nm_manager->active_ap_path);
-   nm_manager->active_ap_path = eina_stringshare_add(ap_path);
-
-   eina_stringshare_del(nm_manager->active_connection_path);
-   nm_manager->active_connection_path =
-      eina_stringshare_add(dev->active_conn_path);
+   eina_stringshare_replace(&nm_manager->active_ap_path, ap_path);
+   eina_stringshare_replace(&nm_manager->active_connection_path,
+                            dev->active_conn_path);
 
    /* Set up persistent watcher on the active connection object */
    {
@@ -924,10 +919,8 @@ _manager_active_conn_watch_free(struct NM_Manager *nm)
         nm->active_conn_proxy = NULL;
         nm->active_conn_obj = NULL;
      }
-   eina_stringshare_del(nm->active_connection_path);
-   nm->active_connection_path = NULL;
-   eina_stringshare_del(nm->active_ap_path);
-   nm->active_ap_path = NULL;
+   eina_stringshare_replace(&nm->active_connection_path, NULL);
+   eina_stringshare_replace(&nm->active_ap_path, NULL);
 }
 
 static void
@@ -960,9 +953,9 @@ _active_conn_prop_changed(void *data, const Eldbus_Message *msg)
              if (eldbus_message_iter_arguments_get(var, "o", &ap_path))
                {
                   DBG("ActiveConn SpecificObject changed: %s", ap_path);
-                  eina_stringshare_del(nm->active_ap_path);
-                  nm->active_ap_path = (ap_path && strcmp(ap_path, "/"))
-                                       ? eina_stringshare_add(ap_path) : NULL;
+                  eina_stringshare_replace(&nm->active_ap_path,
+                                           (ap_path && strcmp(ap_path, "/"))
+                                           ? ap_path : NULL);
                   enm_mod_manager_update(nm);
                   enm_mod_aps_changed(nm);
                }
@@ -1080,8 +1073,7 @@ _active_conn_probe_cb(void *data, const Eldbus_Message *msg,
 
    nm->active_conn_type = conn_type;
 
-   eina_stringshare_del(nm->active_ap_path);
-   nm->active_ap_path = ap_path ? eina_stringshare_add(ap_path) : NULL;
+   eina_stringshare_replace(&nm->active_ap_path, ap_path);
 
    /* Subscribe to property changes on the now-persistent proxy */
    nm->active_conn_signal_handler =
@@ -1201,10 +1193,8 @@ _manager_prop_changed(void *data, const Eldbus_Message *msg)
              else
                {
                   /* No active connections — tear down already done above */
-                  eina_stringshare_del(nm->active_ap_path);
-                  nm->active_ap_path = NULL;
-                  eina_stringshare_del(nm->active_connection_path);
-                  nm->active_connection_path = NULL;
+                  eina_stringshare_replace(&nm->active_ap_path, NULL);
+                  eina_stringshare_replace(&nm->active_connection_path, NULL);
                   free(nm->ip_address);
                   nm->ip_address = NULL;
                   nm->active_conn_type = NM_DEVICE_TYPE_UNKNOWN;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to