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

git pushed a commit to branch master
in repository efm2.

View the commit online.

commit 6d5f1617373926673cd3b93b4612f2ada4c7a5b8
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Sat Sep 9 11:42:48 2023 +0100

    add some efm api's to set config stuff
---
 src/backends/default/meta.c |  4 +--
 src/efm/efm.c               | 78 +++++++++++++++++++++++++++++++++++++++++----
 src/efm/efm.h               | 11 +++++--
 src/efm/efm_structs.h       |  2 ++
 4 files changed, 84 insertions(+), 11 deletions(-)

diff --git a/src/backends/default/meta.c b/src/backends/default/meta.c
index f037050..73fb5a6 100644
--- a/src/backends/default/meta.c
+++ b/src/backends/default/meta.c
@@ -13,7 +13,7 @@
 // "primary" location for medata for a /path/to/dir/ location is
 // /path/to/dir/.efm/filename.efm where that file is a desktop style
 // ini format with X-Efm-XXX=YYY fields where XXX is the meta key and YYY is
-// the meta data. Secondary location is ~/.e/e/efm-meta/7a/172c003a7fb98e.efm
+// the meta data. Secondary location is ~/.e/e/efm/meta/7a/172c003a7fb98e.efm
 // i.e. the sha1 of the full target file path for metadata with first 2 hex
 // chars being a toplevel dir to store all sub-hashes in that dir from the
 // first 2 chars of the hex string of the sha1.
@@ -55,7 +55,7 @@ _meta_personal_overlay_file_get(Meta_File *mf)
 
    eina_sha1((unsigned char *)mf->path, strlen(mf->path), dst);
    sha1_str(dst, sha1);
-   snprintf(buf, sizeof(buf), "%s/efm-meta/%c%c/%s.efm",
+   snprintf(buf, sizeof(buf), "%s/efm/meta/%c%c/%s.efm",
             _config_dir, sha1[0], sha1[1], sha1 + 2);
    return strdup(buf);
 }
diff --git a/src/efm/efm.c b/src/efm/efm.c
index 065c82b..ce1cd9a 100644
--- a/src/efm/efm.c
+++ b/src/efm/efm.c
@@ -655,6 +655,7 @@ _smart_add(Evas_Object *obj)
    sd->config.sort_mode = EFM_SORT_MODE_NAME |
                           EFM_SORT_MODE_LABEL_NOT_PATH |
                           EFM_SORT_MODE_DIRS_FIRST;
+   // XXX: get this from config...
    sd->config.icon_size = 40;
    sd->detail_min_w[0] =  50;
    sd->detail_min_w[1] = 120;
@@ -662,6 +663,7 @@ _smart_add(Evas_Object *obj)
    sd->detail_min_w[3] =  60;
    sd->detail_min_w[4] =  60;
    sd->detail_min_w[5] = 120;
+   sd->backend = eina_stringshare_add("default");
 
    evas_object_size_hint_min_set(obj, 1, 1);
 
@@ -767,6 +769,7 @@ _smart_del(Evas_Object *obj)
         sd->thread = NULL;
      }
    eina_stringshare_replace(&(sd->path), NULL);
+   eina_stringshare_replace(&(sd->backend), NULL);
    if (sd->exe_open)
      {
         Pending_Exe_Del *pend = calloc(1, sizeof(Pending_Exe_Del));
@@ -1230,7 +1233,8 @@ _reset(Smart_Data *sd)
    Eina_Strbuf *buf;
    Block *block;
    Icon *icon;
-   static char envbuf[4096];
+   static char envbuf[PATH_MAX];
+   const char *s;
 
    // clear out stuff there so we can start listing again...
    sd->file_max = 0;
@@ -1273,14 +1277,31 @@ _reset(Smart_Data *sd)
                                           _cb_thread_done, _cb_thread_done,
                                           sd->thread_data, EINA_TRUE);
    buf = eina_strbuf_new();
-   eina_strbuf_append(buf, elm_app_lib_dir_get());
+   s = getenv("E_HOME_DIR");
+   if (s) eina_strbuf_append(buf, s);
+   else
+     {
+        s = getenv("HOME");
+        eina_strbuf_append(buf, s);
+        eina_strbuf_append(buf, "/.e/e");
+     }
    eina_strbuf_append(buf, "/efm/backends/");
-   // XXX: choose backend other than default
-   eina_strbuf_append(buf, "default");
-   snprintf(envbuf, sizeof(envbuf),
-            "EFM_BACKEND_DIR=%s", eina_strbuf_string_get(buf));
-   putenv(envbuf);
+   eina_strbuf_append(buf, sd->backend);
+   snprintf(envbuf, sizeof(envbuf), "EFM_BACKEND_DIR=%s",
+            eina_strbuf_string_get(buf));
    eina_strbuf_append(buf, "/open");
+   if (!ecore_file_can_exec(eina_strbuf_string_get(buf)))
+     {
+        eina_strbuf_reset(buf);
+
+        eina_strbuf_append(buf, elm_app_lib_dir_get());
+        eina_strbuf_append(buf, "/efm/backends/");
+        eina_strbuf_append(buf, sd->backend);
+        snprintf(envbuf, sizeof(envbuf), "EFM_BACKEND_DIR=%s",
+                 eina_strbuf_string_get(buf));
+        eina_strbuf_append(buf, "/open");
+     }
+   putenv(envbuf);
    sd->exe_open = ecore_exe_pipe_run(eina_strbuf_string_get(buf),
                                      ECORE_EXE_NOT_LEADER |
                                      ECORE_EXE_TERM_WITH_PARENT |
@@ -1716,3 +1737,46 @@ efm_column_min_get(Evas_Object *obj, int col)
    else if (col >= 6) return 0;
    return sd->detail_min_w[col];
 }
+
+void
+efm_column_min_set(Evas_Object *obj, int col, Evas_Coord w)
+{
+   ENTRY;
+
+   if (col < 0) return;
+   else if (col >= 6) return;
+   sd->detail_min_w[col] = w;
+}
+
+Evas_Coord
+efm_iconsize_get(Evas_Object *obj)
+{
+   ENTRY 0;
+
+   return sd->config.icon_size;
+}
+
+void
+efm_iconsize_set(Evas_Object *obj, Evas_Coord sz)
+{
+   ENTRY;
+
+   sd->config.icon_size = sz;
+}
+
+const char *
+efm_backend_get(Evas_Object *obj)
+{
+   ENTRY NULL;
+
+   return sd->backend;
+}
+
+void
+efm_backend_set(Evas_Object *obj, const char *backend)
+{
+   ENTRY;
+
+   if (!backend) backend = "default";
+   eina_stringshare_replace(&(sd->backend), backend);
+}
diff --git a/src/efm/efm.h b/src/efm/efm.h
index 13d4e6b..3dc1789 100644
--- a/src/efm/efm.h
+++ b/src/efm/efm.h
@@ -43,13 +43,20 @@ Evas_Object  *efm_add               (Evas_Object *parent);
 void          efm_scroller_set      (Evas_Object *obj, Evas_Object *scroller);
 Evas_Object  *efm_scroller_get      (Evas_Object *obj);
 Evas_Object  *efm_detail_header_get (Evas_Object *obj);
-void          efm_path_set          (Evas_Object *obj, const char *path);
-const char   *efm_path_get          (Evas_Object *obj);
 void          efm_path_view_mode_set(Evas_Object *obj, Efm_View_Mode mode);
 Efm_View_Mode efm_path_view_mode_get(Evas_Object *obj);
 void          efm_path_sort_mode_set(Evas_Object *obj, Efm_Sort_Mode mode);
 Efm_Sort_Mode efm_path_sort_mode_get(Evas_Object *obj);
 Evas_Coord    efm_column_min_get    (Evas_Object *obj, int col);
+void          efm_column_min_set    (Evas_Object *obj, int col, Evas_Coord w);
+Evas_Coord    efm_iconsize_get      (Evas_Object *obj);
+void          efm_iconsize_set      (Evas_Object *obj, Evas_Coord sz);
+const char   *efm_backend_get       (Evas_Object *obj);
+void          efm_backend_set       (Evas_Object *obj, const char *backend);
+
+// alweays call path_Set last after setup above like setting icon size etc.
+void          efm_path_set          (Evas_Object *obj, const char *path);
+const char   *efm_path_get          (Evas_Object *obj);
 
 #define DBG(...) EINA_LOG_DOM_DBG (_log_dom, __VA_ARGS__)
 #define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
diff --git a/src/efm/efm_structs.h b/src/efm/efm_structs.h
index c671fcd..600d0bc 100644
--- a/src/efm/efm_structs.h
+++ b/src/efm/efm_structs.h
@@ -40,6 +40,8 @@ struct _Smart_Data
 
    Eina_Stringshare     *path;
 
+   Eina_Stringshare     *backend;
+
    Ecore_Exe            *exe_open;
    Ecore_Event_Handler  *handler_exe_del;
    Ecore_Event_Handler  *handler_exe_data;

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

Reply via email to