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

git pushed a commit to reference refs/pull/142/head
in repository enlightenment.

View the commit online.

commit cc8018676131e0a502839ca746abe501519cd027
Author: Cedric BAIL <[email protected]>
AuthorDate: Mon Aug 3 14:08:50 2026 -0600

    networkmanager - let the backend be chosen from the settings dialog
    
    The backend config key could only be set with a text editor, and the
    E_NET_BACKEND variable was documented nowhere.
    
    Automatic stays the default and is right wherever only one daemon runs;
    an explicit choice is for machines running both. It applies immediately.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/modules/networkmanager/e_mod_config.c | 79 ++++++++++++++++++++++++++++++-
 src/modules/networkmanager/enm_net.c      |  8 ++++
 src/modules/networkmanager/enm_net.h      |  7 ++-
 3 files changed, 91 insertions(+), 3 deletions(-)

diff --git a/src/modules/networkmanager/e_mod_config.c b/src/modules/networkmanager/e_mod_config.c
index 8997512e6..ea69e91f4 100644
--- a/src/modules/networkmanager/e_mod_config.c
+++ b/src/modules/networkmanager/e_mod_config.c
@@ -5,8 +5,23 @@ typedef struct _E_Config_Dialog_Data
 {
    E_Config_Dialog *cfd;
    double           poll_time;
+   int              backend;   /* index into _backends below */
 } E_Config_Dialog_Data;
 
+/* Which daemon to talk to.  Automatic is right almost always - the module
+ * binds whichever of the two is on the bus - but a machine running both has
+ * no way to say which it prefers otherwise. */
+static const struct
+{
+   const char *value;   /* what goes in the config; NULL means automatic */
+   const char *label;
+} _backends[] = {
+   { NULL,             N_("Automatic") },
+   { "networkmanager", N_("NetworkManager") },
+   { "connman",        N_("ConnMan") },
+};
+#define BACKEND_COUNT ((int)(sizeof(_backends) / sizeof(_backends[0])))
+
 static void *_create_data(E_Config_Dialog *cfd);
 static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
 static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas,
@@ -44,8 +59,20 @@ e_int_config_networkmanager_module(Evas_Object *parent EINA_UNUSED,
 static void
 _fill_data(E_Config_Dialog_Data *cfdata)
 {
+   int i;
+
    if (!networkmanager_config) return;
    cfdata->poll_time = networkmanager_config->poll_time;
+
+   cfdata->backend = 0;
+   for (i = 1; i < BACKEND_COUNT; i++)
+     {
+        if (eina_streq(networkmanager_config->backend, _backends[i].value))
+          {
+             cfdata->backend = i;
+             break;
+          }
+     }
 }
 
 static void *
@@ -74,13 +101,29 @@ _cb_interval_slider(void *data, Evas_Object *obj, void *info EINA_UNUSED)
    e_config_dialog_changed_set(cfdata->cfd, EINA_TRUE);
 }
 
+/* One callback for every entry: the item carries its index, and the hoversel
+ * carries the dialog data. */
+static void
+_cb_backend_selected(void *data, Evas_Object *obj, void *info EINA_UNUSED)
+{
+   E_Config_Dialog_Data *cfdata = evas_object_data_get(obj, "cfdata");
+   int idx = (int)(intptr_t)data;
+
+   if (!cfdata) return;
+   cfdata->backend = idx;
+   elm_object_text_set(obj, _(_backends[idx].label));
+   e_config_dialog_changed_set(cfdata->cfd, EINA_TRUE);
+}
+
 static Evas_Object *
 _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas EINA_UNUSED,
                       E_Config_Dialog_Data *cfdata)
 {
    Evas_Object *win, *table, *obj;
+   int i;
 
    win = cfd->dia->win;
+   cfdata->cfd = cfd;
    table = elm_table_add(e_comp->elm);
 
    obj = elm_icon_add(win);
@@ -110,7 +153,31 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas EINA_UNUSED,
    evas_object_smart_callback_add(obj, "changed", _cb_interval_slider, cfdata);
    evas_object_show(obj);
 
-   cfdata->cfd = cfd;
+   obj = elm_icon_add(win);
+   elm_icon_standard_set(obj, "preferences-system");
+   evas_object_size_hint_min_set(obj, ELM_SCALE_SIZE(20), ELM_SCALE_SIZE(20));
+   elm_table_pack(table, obj, 0, 2, 1, 1);
+   evas_object_show(obj);
+
+   obj = elm_label_add(win);
+   elm_object_text_set(obj, _("Network Service"));
+   evas_object_size_hint_align_set(obj, 0.0, 0.5);
+   evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, 0.0);
+   elm_table_pack(table, obj, 1, 2, 9, 1);
+   evas_object_show(obj);
+
+   obj = elm_hoversel_add(win);
+   elm_hoversel_hover_parent_set(obj, win);
+   evas_object_data_set(obj, "cfdata", cfdata);
+   elm_object_text_set(obj, _(_backends[cfdata->backend].label));
+   for (i = 0; i < BACKEND_COUNT; i++)
+     elm_hoversel_item_add(obj, _(_backends[i].label), NULL, ELM_ICON_NONE,
+                           _cb_backend_selected, (void *)(intptr_t)i);
+   evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, 0.5);
+   evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, 0.0);
+   elm_table_pack(table, obj, 0, 3, 10, 1);
+   evas_object_show(obj);
+
    return table;
 }
 
@@ -122,6 +189,13 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED,
 
    networkmanager_config->poll_time = cfdata->poll_time;
    enm_config_poll_time_set(networkmanager_config->poll_time);
+
+   eina_stringshare_replace(&networkmanager_config->backend,
+                            _backends[cfdata->backend].value);
+   /* Takes effect there and then - it rebinds if the choice rules out the
+    * backend currently in use. */
+   enm_net_backend_preference_set(networkmanager_config->backend);
+
    e_config_save_queue();
    return 1;
 }
@@ -131,5 +205,8 @@ _basic_check_changed(E_Config_Dialog *cfd EINA_UNUSED,
                      E_Config_Dialog_Data *cfdata)
 {
    if (!networkmanager_config) return 0;
+   if (!eina_streq(networkmanager_config->backend,
+                   _backends[cfdata->backend].value))
+     return 1;
    return (fabs(cfdata->poll_time - networkmanager_config->poll_time) > 0.01);
 }
diff --git a/src/modules/networkmanager/enm_net.c b/src/modules/networkmanager/enm_net.c
index 0953cc74f..eeffa29d0 100644
--- a/src/modules/networkmanager/enm_net.c
+++ b/src/modules/networkmanager/enm_net.c
@@ -328,11 +328,19 @@ enm_net_manager_active_set(E_Net_Manager *mgr, E_Net_Type type,
  * which wins - restricts the candidates to that one backend.
  */
 
+static void _backend_rebind(void);
+
 void
 enm_net_backend_preference_set(const char *name)
 {
    free(_preference);
    _preference = (name && name[0]) ? strdup(name) : NULL;
+
+   /* Called before enm_net_init the first time, and again whenever the
+    * setting changes.  In the latter case which daemons are around is
+    * already known, so the choice can be reapplied straight away instead of
+    * waiting for a restart. */
+   if (_probe_conn) _backend_rebind();
 }
 
 /* Is this backend a candidate at all? */
diff --git a/src/modules/networkmanager/enm_net.h b/src/modules/networkmanager/enm_net.h
index bb100adc9..8beac472e 100644
--- a/src/modules/networkmanager/enm_net.h
+++ b/src/modules/networkmanager/enm_net.h
@@ -190,8 +190,11 @@ struct _E_Net_Mod_Callbacks
 void enm_net_module_callbacks_set(const E_Net_Mod_Callbacks *cbs);
 
 /* Restrict backend selection to one named backend ("networkmanager" /
- * "connman").  NULL or "" means automatic.  Call before enm_net_init; the
- * E_NET_BACKEND environment variable overrides it. */
+ * "connman").  NULL or "" means automatic.  Safe to call either before
+ * enm_net_init or later to change the choice, in which case the new one is
+ * applied immediately.  The E_NET_BACKEND environment variable overrides it,
+ * which is what makes it useful for testing the other backend on a machine
+ * that runs both daemons. */
 void       enm_net_backend_preference_set(const char *name);
 
 /* Lifecycle.  enm_net_init starts watching for daemons and binds the most

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

Reply via email to