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 019ff14ba0b17d7d05f4f749c73537709140b2d8
Author: Carsten Haitzler <[email protected]>
AuthorDate: Tue Jan 27 19:02:10 2026 +0000

    move all config fiddling entirely into e_mod_config.c
    
    so main mod doesnt really see details of config much (well still for
    display of popup list - need to change this)
---
 src/modules/clipboard/e_mod_config.c | 38 +++++++++++++++
 src/modules/clipboard/e_mod_main.c   | 90 ++++--------------------------------
 src/modules/clipboard/e_mod_main.h   |  1 +
 3 files changed, 48 insertions(+), 81 deletions(-)

diff --git a/src/modules/clipboard/e_mod_config.c b/src/modules/clipboard/e_mod_config.c
index db4804ef9..0a779becb 100644
--- a/src/modules/clipboard/e_mod_config.c
+++ b/src/modules/clipboard/e_mod_config.c
@@ -29,6 +29,16 @@ static E_Config_DD *conf_edd = NULL;
 static E_Config_DD *conf_item_edd = NULL;
 /////////////////////////////////////////////////////////////////////////////
 
+static Eina_Bool
+_empty(const char *s)
+{
+  // walk to first non-space char
+  while ((isspace((unsigned char)*s)) && (*s++));
+  // first non-empty char is NOT 0 byte (end of str) thus not empty
+  if (s[0]) return EINA_FALSE;
+  return EINA_TRUE;
+}
+
 static void
 _fill_data(E_Config_Dialog_Data *cfdata)
 {
@@ -255,3 +265,31 @@ config_clip_data_free(Config_Item *cd)
   eina_stringshare_del(cd->str);
   free(cd);
 }
+
+void
+config_paste_add(const char *data, size_t size, int type)
+{
+  Config_Item *cd = NULL;
+  const char *last = "";
+  Eina_List *l;
+
+  if (!data) return;
+  if (cfg->items) last = ((Config_Item *)eina_list_data_get(cfg->items))->str;
+  if (!strcmp(last, data)) return; // same as last one we added
+  if (_empty(data)) return; // empty - we don't want it
+  EINA_LIST_FOREACH(cfg->items, l, cd)
+    {
+      if (!strcmp(data, cd->str))
+        {// promote to last - already there
+          cfg->items = eina_list_promote_list(cfg->items, l);
+          return;
+        }
+    }
+  // not there already
+  cd = E_NEW(Config_Item, 1);
+  if (!cd) return;
+  // XXX: if we select huge amounts of text this could use a lot of ram
+  cd->str = eina_stringshare_add(data);
+  cfg->items = eina_list_prepend(cfg->items, cd);
+  config_hist_limit();
+}
diff --git a/src/modules/clipboard/e_mod_main.c b/src/modules/clipboard/e_mod_main.c
index 14fd7fb30..73b98bca3 100644
--- a/src/modules/clipboard/e_mod_main.c
+++ b/src/modules/clipboard/e_mod_main.c
@@ -45,11 +45,8 @@ static void       _clipboard_config_show(void *d1, void *d2 EINA_UNUSED);
 static void       _clipboard_popup_free(Instance *inst);
 
 static void       _clip_inst_free(Instance *inst);
-static void       _clip_add_item(Config_Item *cd);
 static void       _clipboard_popup_new(Instance *inst);
 static void       _clear_history(void);
-static Eina_List *_item_in_history(Config_Item *cd);
-static int        _clip_compare(Config_Item *cd, char *text);
 
 static void
 _clipboard_cb_mouse_down(void *data,
@@ -194,7 +191,7 @@ _cb_del_item(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNU
   Eina_List *l;
   Instance *inst;
 
-  EINA_SAFETY_ON_NULL_RETURN(cfg);
+  if (!cfg) return;
   EINA_LIST_FOREACH(mod.instances, l, inst) _clipboard_popup_free(inst);
   cfg->items = eina_list_remove(cfg->items, cd);
   config_clip_data_free(cd);
@@ -388,55 +385,6 @@ _clipboard_popup_new(Instance *inst)
   E_OBJECT_DEL_SET(inst->popup, _clipboard_popup_del_cb);
 }
 
-static void
-_clip_add_item(Config_Item *cd)
-{
-  Eina_List *l, *it;
-  Instance *inst;
-
-  EINA_SAFETY_ON_NULL_RETURN(cd);
-  if (cd->str[0] == 0) return;
-  // hide all popups - item lists point to data that might be invalid soon
-  EINA_LIST_FOREACH(mod.instances, l, inst) _clipboard_popup_free(inst);
-
-  if ((it = _item_in_history(cd))) // move to top of list
-    cfg->items = eina_list_promote_list(cfg->items, it);
-  else
-    { // add item to the list
-      if (eina_list_count(cfg->items) < cfg->hist_items) // add to start
-        cfg->items = eina_list_prepend(cfg->items, cd);
-      else
-        { // remove last item from the list
-          Eina_List *l_last = eina_list_last(cfg->items);
-
-          if (l_last)
-            {
-              config_clip_data_free(l_last->data); // makes popup ptrs invalid
-              cfg->items = eina_list_remove_list(cfg->items, l_last);
-            }
-          //  add clipboard data stored in cd to the list as a first item
-          cfg->items = eina_list_prepend(cfg->items, cd);
-        }
-    }
-  // saving list to the file
-  e_config_save_queue();
-}
-
-static Eina_List *
-_item_in_history(Config_Item *cd)
-{
-  if (cfg->items)
-    return eina_list_search_unsorted_list(cfg->items, (Eina_Compare_Cb)_clip_compare, cd->str);
-  else
-    return NULL;
-}
-
-static int
-_clip_compare(Config_Item *cd, char *text)
-{
-  return strcmp(cd->str, text);
-}
-
 static void
 _clear_history(void)
 {
@@ -483,39 +431,19 @@ _clip_inst_free(Instance *inst)
   E_FREE(inst);
 }
 
-static Eina_Bool
-_empty(const char *s)
-{
-  // walk to first non-space char
-  while ((isspace((unsigned char)*s)) && (*s++));
-  // first non-empty char is NOT 0 byte (end of str) thus not empty
-  if (s[0]) return EINA_FALSE;
-  return EINA_TRUE;
-}
-
 static Eina_Bool
 _cliboard_cb_paste(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
                    Elm_Selection_Data *event)
 {
-  Config_Item *cd = NULL;
-  char *str = NULL;
-  const char *last = "";
+  Eina_List *l;
+  Instance *inst;
+  if (!event) goto done;
 
-  if (cfg->items) last = ((Config_Item *)eina_list_data_get(cfg->items))->str;
-  if (event) str = event->data;
-  if (!str) return EINA_TRUE;
-
-  if (!!strcmp(last, str))
-    {
-      if (_empty(str)) return ECORE_CALLBACK_DONE;
-      cd = E_NEW(Config_Item, 1);
-      if (cd)
-        { // XXX: if we select huge amounts of text this could use a lot of ram
-          cd->str = eina_stringshare_add(str);
-          _clip_add_item(cd);
-        }
-    }
-  return EINA_TRUE;
+  EINA_LIST_FOREACH(mod.instances, l, inst) _clipboard_popup_free(inst);
+  config_paste_add(event->data, event->len, event->format);
+  e_config_save_queue();
+done:
+  return ECORE_CALLBACK_DONE;
 }
 
 static void
diff --git a/src/modules/clipboard/e_mod_main.h b/src/modules/clipboard/e_mod_main.h
index 29ed1ccab..2ee6d73aa 100644
--- a/src/modules/clipboard/e_mod_main.h
+++ b/src/modules/clipboard/e_mod_main.h
@@ -98,5 +98,6 @@ void             config_free(void);
 void             config_save(void);
 void             config_hist_limit(void);
 void             config_clip_data_free(Config_Item *cd);
+void             config_paste_add(const char *data, size_t size, int type);
 
 #endif

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

Reply via email to