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 9a3531332786a45e077a1151ea1c525c7491bf71
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Tue Oct 24 08:02:04 2023 +0100

    share more code in funcs for detail view
---
 src/efm/efm_util.c | 121 ++++++++++++++++++++++++-----------------------------
 1 file changed, 55 insertions(+), 66 deletions(-)

diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index 1a7cc9e..0e0e2e4 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -1286,6 +1286,45 @@ _cb_icon_detail_button_clicked(void *data, Evas_Object *o,
   cmd_strbuf_exe_consume(buf, icon->sd->exe_open);
 }
 
+static Evas_Object *
+_icon_detail_icon_add(Evas_Object *base, const char *icon, const char *dir)
+{
+  Evas_Object *o;
+
+  if (!strncmp(icon, "std:", 4))
+    {
+      o = elm_icon_add(base);
+      evas_object_pass_events_set(o, EINA_TRUE);
+      elm_icon_standard_set(o, icon + 4);
+    }
+  else
+    {
+      o = efm_icon_add(base);
+      efm_icon_keep_aspect_set(o, EINA_TRUE);
+      evas_object_pass_events_set(o, EINA_TRUE);
+      if (icon[0] == '/') efm_icon_file_set(o, icon);
+      else
+        {
+          Eina_Strbuf *strbuf = eina_strbuf_new();
+
+          eina_strbuf_append(strbuf, dir);
+          eina_strbuf_append(strbuf, icon);
+          efm_icon_file_set(o, eina_strbuf_string_get(strbuf));
+          eina_strbuf_free(strbuf);
+        }
+    }
+  return o;
+}
+
+static Eina_Bool
+_icon_detail_bool_parse(const char *str)
+{
+  if ((!strcasecmp(str, "1"))    || (!strcasecmp(str, "on")) ||
+      (!strcasecmp(str, "true")) || (!strcasecmp(str, "yes")))
+    return EINA_TRUE;
+  return EINA_FALSE;
+}
+
 static void
 _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
                  const char *theme_edj_file, int col, const char *detail,
@@ -1305,7 +1344,7 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
 
       plist = eina_str_split(detail, "/", 2);
       if (plist[0] && plist[1])
-        { // format: "13/28 - value/max_value
+        { // format: "13/28" = value/max_value
           size = atoll(plist[0]);
           size_max = atoll(plist[1]);
 
@@ -1327,7 +1366,7 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
       free(plist);
     }
   else if (!strcmp(format, "timestamp"))
-    { // format: 1284924 - time_in_seconds_since_epoch
+    { // format: "1284924" = time_in_seconds_since_epoch
       time_t     tmpt = atoll(detail);
       struct tm *info;
 
@@ -1345,17 +1384,16 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
                                       eina_strftime("%H:%M:%S", info));
     }
   else if (!strcmp(format, "checkview"))
-    { // format: true/yes/1 vs false/no/0
+    { // format: "true"/"yes"/"1" or "false"/"no"/"0"
       o = _icon_detail_grid_add(icon, sd, col);
       o = _icon_detail_grid_sub_edje_add(icon, e, theme_edj_file, col,
                                          "e/fileman/default/check");
-      if ((!strcasecmp(detail, "1")) || (!strcasecmp(detail, "on"))
-          || (!strcasecmp(detail, "true")) || (!strcasecmp(detail, "yes")))
+      if (_icon_detail_bool_parse(detail))
         edje_object_signal_emit(o, "e,state,on", "e");
       else edje_object_signal_emit(o, "e,state,off", "e");
     }
   else if (!strcmp(format, "progress"))
-    { // format: 33/100 or noval,41/50 - value / maxvalue optional noval
+    { // format: "33/100" or "noval,41/50" = value / maxvalue optional noval
       int val = 0, max = 100;
 
       o = _icon_detail_grid_add(icon, sd, col);
@@ -1378,7 +1416,7 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
       evas_object_show(o);
     }
   else if (!strcmp(format, "circle"))
-    {
+    { // format: "#fff" or "#ffff" or "#ffffff" or "#ffffffff" = rgb(a)
       Edje_Message_String msg;
 
       msg.str = (char *)detail;
@@ -1391,35 +1429,12 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
   else if (!strcmp(format, "icon"))
     { // format: std:clock or /path/x.png or path/x.gif or x.gif
       o = _icon_detail_grid_add(icon, sd, col);
-      if (!strncmp(detail, "std:", 4))
-        {
-          o = elm_icon_add(o);
-          evas_object_pass_events_set(o, EINA_TRUE);
-          elm_icon_standard_set(o, detail + 4);
-          elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
-          evas_object_show(o);
-        }
-      else
-        {
-          o = efm_icon_add(o);
-          efm_icon_keep_aspect_set(o, EINA_TRUE);
-          evas_object_pass_events_set(o, EINA_TRUE);
-          if (detail[0] == '/') efm_icon_file_set(o, detail);
-          else
-            {
-              Eina_Strbuf *strbuf = eina_strbuf_new();
-
-              eina_strbuf_append(strbuf, sd->config.path);
-              eina_strbuf_append(strbuf, detail);
-              efm_icon_file_set(o, eina_strbuf_string_get(strbuf));
-              eina_strbuf_free(strbuf);
-            }
-          elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
-          evas_object_show(o);
-        }
+      o = _icon_detail_icon_add(o, detail, sd->config.path);
+      elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
+      evas_object_show(o);
     }
   else if (!strcmp(format, "check"))
-    { // format: true/yes/1 vs false/no/0
+    { // format: "true"/"yes"/"1" or "false"/"no"/"0"
       o = _icon_detail_grid_add(icon, sd, col);
       // use table to pack check into to force centering and put it in the grid
       o2 = elm_table_add(o);
@@ -1429,16 +1444,14 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
       evas_object_data_set(o, "detail", (void *)(unsigned long)(col + 1));
       evas_object_propagate_events_set(o, EINA_FALSE);
       elm_table_pack(o2, o, 0, 0, 1, 1);
-      if ((!strcasecmp(detail, "1")) || (!strcasecmp(detail, "on"))
-          || (!strcasecmp(detail, "true")) || (!strcasecmp(detail, "yes")))
-        elm_check_state_set(o, EINA_TRUE);
+      elm_check_state_set(o, _icon_detail_bool_parse(detail));
       evas_object_smart_callback_add(o, "changed",
                                      _cb_icon_detail_check_changed, icon);
       evas_object_show(o2);
       evas_object_show(o);
     }
   else if (!strcmp(format, "button"))
-    { // format: Label or Label,icon where icon is same as icon above
+    { // format: "Label" or "Label,icon" where icon is same as icon above
       char *label, *p;
 
       o = _icon_detail_grid_add(icon, sd, col);
@@ -1452,34 +1465,10 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
           p = strchr(label, ',');
           if (p)
             {
-              *p = 0;
-              p++;
-              if (!strncmp(p, "std:", 4))
-                {
-                  o2 = elm_icon_add(o);
-                  evas_object_pass_events_set(o2, EINA_TRUE);
-                  elm_icon_standard_set(o2, p + 4);
-                  elm_object_part_content_set(o, "icon", o2);
-                  evas_object_show(o2);
-                }
-              else
-                {
-                  o2 = efm_icon_add(o);
-                  efm_icon_keep_aspect_set(o2, EINA_TRUE);
-                  evas_object_pass_events_set(o2, EINA_TRUE);
-                  if (p[0] == '/') efm_icon_file_set(o2, p);
-                  else
-                    {
-                      Eina_Strbuf *strbuf = eina_strbuf_new();
-
-                      eina_strbuf_append(strbuf, sd->config.path);
-                      eina_strbuf_append(strbuf, p);
-                      efm_icon_file_set(o2, eina_strbuf_string_get(strbuf));
-                      eina_strbuf_free(strbuf);
-                    }
-                  elm_object_part_content_set(o, "icon", o2);
-                  evas_object_show(o2);
-                }
+              *p++ = 0;
+              o2 = _icon_detail_icon_add(o, p, sd->config.path);
+              elm_object_part_content_set(o, "icon", o2);
+              evas_object_show(o2);
             }
           elm_object_text_set(o, label);
           evas_object_smart_callback_add(o, "clicked",

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

Reply via email to