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 e98d662fd2f27fd8b228f902d6c316bfa23cef07
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Fri Jul 26 18:21:18 2024 +0100

    handle the mime edje objects too in menu
---
 src/efm/efm.c      |  33 +++++++++---
 src/efm/efm_util.c | 149 ++++++++++++++++++++++++++++++-----------------------
 2 files changed, 111 insertions(+), 71 deletions(-)

diff --git a/src/efm/efm.c b/src/efm/efm.c
index a85c361..3474a68 100644
--- a/src/efm/efm.c
+++ b/src/efm/efm.c
@@ -5,6 +5,7 @@
 //
 // maximum # of files in a dir that is sane: 10,000
 // maximum number of files in a dir on a real system to be fast with: 3,000
+#include "Edje.h"
 #include "cmd.h"
 #include "efm.h"
 #include "efl_ui_check_eo.legacy.h"
@@ -2001,7 +2002,7 @@ _menu_icon_radcheck_add(Evas_Object *o_base, int icon_col, const char *icon, int
   if (icon)
     { // we have an icon to add to the icon column
       // icon can be,,,,
-      // 
+      //
       // "std:menu-eject" - native to elm menus (strip std:)
       // "std:menu/folder" - native to elm menus (strip std:)
       // "file:/path/to/file.png" - use efm_icon
@@ -2010,6 +2011,7 @@ _menu_icon_radcheck_add(Evas_Object *o_base, int icon_col, const char *icon, int
       // "thumb:/path/to/file" - use efm_icon
       // "video:/path/to/file.mp4" - use efm_icon
       // "fdo:icon-name" - use efreet to look up icon then use that
+      o = NULL;
       if (!strncmp(icon, "std:", 4))
         {
           o = elm_icon_add(o_base);
@@ -2044,11 +2046,30 @@ _menu_icon_radcheck_add(Evas_Object *o_base, int icon_col, const char *icon, int
           o = elm_icon_add(o_base);
           elm_icon_standard_set(o, icon + 4);
         }
-      // XXX: what if its an alpha thumb - needs colro multiply by fg!
-      evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
-      evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-      elm_table_pack(o_table, o, icon_col, 0, 1, 1);
-      evas_object_show(o);
+      else if (!strncmp(icon, "edje:", 5))
+        {
+          char *dup = strdup(icon);
+
+          if (dup)
+            {
+              char *delim = strchr(dup, '|'); // | == magic delimiter char
+              if (delim)
+                {
+                  *delim = 0; // break string at delim /path/file.edj|group
+                  o      = edje_object_add(evas_object_evas_get(o_base));
+                  edje_object_file_set(o, dup + 5, delim + 1);
+                }
+              free(dup);
+            }
+        }
+      // XXX: what if its an alpha thumb - needs color multiply by fg!
+      if (o)
+        {
+          evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+          evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+          elm_table_pack(o_table, o, icon_col, 0, 1, 1);
+          evas_object_show(o);
+        }
     }
   else if (icon_num)
     { // other icons in the list, but not this one - so dummy rect
diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index 1c9f6c5..1a11830 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -7,6 +7,7 @@
 #include "efm_back_end.h"
 #include "efm_private.h"
 #include "eina_strbuf.h"
+#include "eina_types.h"
 
 // util funcs for the efm view
 static inline int
@@ -690,22 +691,34 @@ _cb_icon_longpress_timer(void *data)
   return EINA_FALSE;
 }
 
+static Eina_Bool
+_file_video_is(const char *file)
+{
+  // XXX: this probably should look up in config
+  const char *videxts[]
+    = { "webm", "ogv",  "mp4",    "m4v", "mpg", "mp2",  "mpeg",  "mpeg2",
+        "avi",  "flv",  "wmv",    "f4v", "swf", "mkv",  "avchd", "mov",
+        "3gp",  "3g2",  "prores", "vob", "mts", "m2ts", "ts",    "qt",
+        "rm",   "rmvb", "viv",    "asf", "amv", "m2v",  "mpe",   "mpv",
+        "svi",  "mxf",  "nsv",    "f4p", "f4b", NULL };
+  const char *ext = strrchr(file, '.');
+  int         i;
+
+  if (!ext) return EINA_FALSE;
+  for (i = 0; videxts[i]; i++)
+    {
+      if (!strcasecmp(ext + 1, videxts[i])) return EINA_TRUE;
+    }
+  return EINA_FALSE;
+}
+
 static void
 _icon_file_set(Icon *icon, const char *file)
 {
-  const char *ext;
-
-  ext = strrchr(file, '.');
-  if (ext
-      && ((!strcasecmp(ext, ".webm")) || (!strcasecmp(ext, ".mp4"))
-          || (!strcasecmp(ext, ".m4v"))))
-    {
-      efm_icon_video_set(icon->o_icon, file);
-    }
+  if (_file_video_is(file))
+    efm_icon_video_set(icon->o_icon, file);
   else
-    {
-      efm_icon_file_set(icon->o_icon, file);
-    }
+    efm_icon_file_set(icon->o_icon, file);
 }
 
 void
@@ -1041,6 +1054,62 @@ _cb_ic_item7(void *data, void *data2, Evas_Object *efm,
   printf("ic7");
 }
 
+static const char *
+_icon_strbuf_icon_def(Icon *icon, Eina_Strbuf *icbuf)
+{
+  const char *icstr;
+
+  eina_strbuf_reset(icbuf);
+  if (icon->info.thumb)
+    {
+      eina_strbuf_append(icbuf, "thumb:");
+      eina_strbuf_append(icbuf, icon->info.thumb);
+    }
+  else
+    {
+      const char *ic;
+
+      ic = icon->info.pre_lookup_icon;
+      if (!ic) ic = icon->info.icon;
+      if ((!ic) && (icon->info.mime))
+        {
+          const char *icfile;
+          char        buf[1024];
+
+          snprintf(buf, sizeof(buf), "e/icons/fileman/mime/%s",
+                   icon->info.mime);
+          icfile = elm_theme_group_path_find(NULL, buf);
+          if (!icfile)
+            {
+              snprintf(buf, sizeof(buf), "e/icons/fileman/mime/inode/file");
+              icfile = elm_theme_group_path_find(NULL, buf);
+            }
+          if (icfile)
+            {
+              eina_strbuf_append(icbuf, "edje:");
+              eina_strbuf_append(icbuf, icfile);
+              eina_strbuf_append(icbuf, "|");
+              eina_strbuf_append(icbuf, buf);
+            }
+        }
+      if ((ic) && (ic[0] == '/'))
+        {
+          // XXX: need common code for this to share
+          if (_file_video_is(ic)) eina_strbuf_append(icbuf, "video:");
+          else eina_strbuf_append(icbuf, "file:");
+          eina_strbuf_append(icbuf, ic);
+        }
+      else if (ic)
+        {
+          eina_strbuf_append(icbuf, "std:");
+          eina_strbuf_append(icbuf, ic);
+        }
+    }
+  icstr = eina_strbuf_string_get(icbuf);
+  if ((icstr) && (!icstr[0])) icstr = NULL;
+  return icstr;
+}
+
 static void
 _cb_icon_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
                   void *event_info)
@@ -1116,60 +1185,10 @@ _cb_icon_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
                               _cb_ic_item3, icon, NULL);
           _efm_menu_it_normal(m1, "Item 4", "std:battery", _cb_ic_item4, icon,
                               NULL);
-
           m2 = _efm_menu_add("Main Menu", "std:security-high");
-          eina_strbuf_reset(icbuf);
-          if (icon->info.thumb)
-            {
-              eina_strbuf_append(icbuf, "thumb:");
-              eina_strbuf_append(icbuf, icon->info.thumb);
-            }
-          else
-            {
-              const char *ic;
-
-              ic = icon->info.pre_lookup_icon;
-              if (!ic) ic = icon->info.icon;
-              if (!ic)
-                {
-//              snprintf(buf, sizeof(buf), "e/icons/fileman/mime/%s",
-//                       icon->info.mime);
-//              icon_file = elm_theme_group_path_find(NULL, buf);
-//              // mime type icon exists
-//              if (icon_file) icon_group = buf;
-//              else
-//                { // use an out-of-theme std mime icon
-                  ic = icon->info.mime_icon;
-//                }
-                }
-//              if (!ic)
-//                {
-//              snprintf(buf, sizeof(buf), "e/icons/fileman/mime/inode/file");
-//              icon_file  = elm_theme_group_path_find(NULL, buf);
-//              icon_group = buf;
-//                }
-              if ((ic) && (ic[0] == '/'))
-                {
-                  // XXX: need common code for this toshare
-                  const char *ext = strrchr(ic, '.');
-                  if (ext
-                      && ((!strcasecmp(ext, ".webm"))
-                          || (!strcasecmp(ext, ".mp4"))
-                          || (!strcasecmp(ext, ".m4v"))))
-                    eina_strbuf_append(icbuf, "video:");
-                  else eina_strbuf_append(icbuf, "file:");
-                  eina_strbuf_append(icbuf, ic);
-                }
-              else if (ic)
-                {
-                  eina_strbuf_append(icbuf, "std:");
-                  eina_strbuf_append(icbuf, ic);
-                }
-            }
-          icstr = eina_strbuf_string_get(icbuf);
-          if ((icstr) && (!icstr[0])) icstr = NULL;
-          _efm_menu_it_normal(m2, icon->info.label, icstr, _cb_ic_item5,
-                              icon, NULL);
+          icstr = _icon_strbuf_icon_def(icon, icbuf);
+          _efm_menu_it_normal(m2, icon->info.label, icstr, _cb_ic_item5, icon,
+                              NULL);
           _efm_menu_it_normal(m2, "Item 5", "std:system-run", _cb_ic_item5,
                               icon, NULL);
           _efm_menu_it_separator(m2);

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

Reply via email to