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 e4925099536e0e76dfd813a96cb8b19edacbb32b
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Tue Oct 3 20:19:37 2023 +0100

    rationalize and re-use shared code for item realizing
---
 src/efm/efm_util.c | 101 +++++++++++++++++++----------------------------------
 1 file changed, 35 insertions(+), 66 deletions(-)

diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index 84bc7f1..40cef18 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -1181,6 +1181,24 @@ _icon_detail_size_display(unsigned long long size, char unit[8])
   return (int)size; // int is fine as we reduced the value to unit size
 }
 
+static Evas_Object *
+_icon_detail_rectangle_add(Icon *icon, Smart_Data *sd, Evas *e, int col,
+                           const char *detail)
+{
+  Evas_Object *o;
+  char buf[128];
+
+  snprintf(buf, sizeof(buf), "e.text.detail%i", col + 1);
+  if (detail) edje_object_part_text_set(icon->o_base, buf, detail);
+  icon->o_list_detail_swallow[col] = o = evas_object_rectangle_add(e);
+  evas_object_color_set(o, 0, 0, 0, 0);
+  evas_object_size_hint_min_set
+    (o, sd->config.detail_min_w[col] * _scale_get(sd), 0);
+  snprintf(buf, sizeof(buf), "e.swallow.detail%i", col + 1);
+  edje_object_part_swallow(icon->o_base, buf, o);
+  return o;
+}
+
 static Evas_Object *
 _icon_detail_grid_add(Icon *icon, Smart_Data *sd, int col)
 {
@@ -1230,16 +1248,7 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
 
   if (!detail) detail = "";
   if (!strcmp(format, "text"))
-    {
-      snprintf(buf, sizeof(buf), "e.text.detail%i", col + 1);
-      edje_object_part_text_set(icon->o_base, buf, detail);
-      icon->o_list_detail_swallow[col] = o = evas_object_rectangle_add(e);
-      evas_object_color_set(o, 0, 0, 0, 0);
-      evas_object_size_hint_min_set
-        (o, sd->config.detail_min_w[col] * _scale_get(sd), 0);
-      snprintf(buf, sizeof(buf), "e.swallow.detail%i", col + 1);
-      edje_object_part_swallow(icon->o_base, buf, o);
-    }
+    _icon_detail_rectangle_add(icon, sd, e, col, detail);
   else if (!strcmp(format, "size"))
     {
       char **plist;
@@ -1276,7 +1285,6 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
       struct tm *info;
 
       info = localtime(&tmpt);
-
       o = _icon_detail_grid_add(icon, sd, col);
       o = _icon_detail_grid_sub_edje_add(icon, e, theme_edj_file, col,
                                          "e/fileman/default/filedate");
@@ -1301,7 +1309,7 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
   Evas_Object *o, *o2;
   const char  *icon_file = NULL, *icon_group = NULL, *icon_thumb = NULL;
   const char  *ic;
-  char         buf[PATH_MAX], buf2[128], *tmps;
+  char         buf[PATH_MAX], buf2[128];
   int          i;
 
   if (icon->o_base) return;
@@ -1396,22 +1404,9 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
             {
               unsigned long long size = atoll(s);
 
-              icon->o_list_detail_swallow[0] = o2
-                = elm_grid_add(sd->o_scroller);
-              elm_grid_size_set(o2, 1, 1);
-              evas_object_size_hint_min_set(
-                o2, sd->config.detail_min_w[0] * _scale_get(sd), 0);
-              edje_object_part_swallow(icon->o_base, "e.swallow.detail1", o2);
-              icon->o_list_detail_swallow2[0] = o2 = edje_object_add(e);
-              edje_object_file_set(o2, theme_edj_file,
-                                   "e/fileman/default/filesize");
-              evas_object_data_set(o2, "is_edje", o2);
-              if (icon->selected)
-                edje_object_signal_emit(o2, "e,state,selected", "e");
-              else edje_object_signal_emit(o2, "e,state,unselected", "e");
-              elm_grid_pack(icon->o_list_detail_swallow[0], o2, 0, 0, 1, 1);
-              evas_object_show(o2);
-
+              o2 = _icon_detail_grid_add(icon, sd, 0);
+              o2 = _icon_detail_grid_sub_edje_add(icon, e, theme_edj_file, 0,
+                                                  "e/fileman/default/filesize");
               if (sd->file_max > 0)
                 _size_message(o2, (double)size / (double)sd->file_max);
               else _size_message(o2, 0.0);
@@ -1429,35 +1424,17 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
               struct tm *info;
 
               info = localtime(&tmpt);
-
-              icon->o_list_detail_swallow[1] = o2
-                = elm_grid_add(sd->o_scroller);
-              elm_grid_size_set(o2, 1, 1);
-              evas_object_size_hint_min_set(
-                o2, sd->config.detail_min_w[1] * _scale_get(sd), 0);
-              edje_object_part_swallow(icon->o_base, "e.swallow.detail2", o2);
-              icon->o_list_detail_swallow2[1] = o2 = edje_object_add(e);
-              edje_object_file_set(o2, theme_edj_file,
-                                   "e/fileman/default/filedate");
-              evas_object_data_set(o2, "is_edje", o2);
-              if (icon->selected)
-                edje_object_signal_emit(o2, "e,state,selected", "e");
-              else edje_object_signal_emit(o2, "e,state,unselected", "e");
-              elm_grid_pack(icon->o_list_detail_swallow[1], o2, 0, 0, 1, 1);
-              evas_object_show(o2);
-
-              tmps = eina_strftime("%y", info);
-              edje_object_part_text_set(o2, "e.text.year", tmps);
-              free(tmps);
-              tmps = eina_strftime("%b", info);
-              edje_object_part_text_set(o2, "e.text.month", tmps);
-              free(tmps);
-              tmps = eina_strftime("%d", info);
-              edje_object_part_text_set(o2, "e.text.day", tmps);
-              free(tmps);
-              tmps = eina_strftime("%H:%M:%S", info);
-              edje_object_part_text_set(o2, "e.text.time", tmps);
-              free(tmps);
+              o2 = _icon_detail_grid_add(icon, sd, 1);
+              o2 = _icon_detail_grid_sub_edje_add(icon, e, theme_edj_file, 1,
+                                                 "e/fileman/default/filedate");
+              _icon_detail_edje_text_set_free(o2, "e.text.year",
+                                              eina_strftime("%y", info));
+              _icon_detail_edje_text_set_free(o2, "e.text.month",
+                                              eina_strftime("%b", info));
+              _icon_detail_edje_text_set_free(o2, "e.text.day",
+                                              eina_strftime("%d", info));
+              _icon_detail_edje_text_set_free(o2, "e.text.time",
+                                              eina_strftime("%H:%M:%S", info));
             }
           s = icon->info.mime;
           if (!s) s = "";
@@ -1527,15 +1504,7 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
               edje_object_message_signal_process(o2);
             }
           for (i = 2; i < 5; i++)
-            {
-              icon->o_list_detail_swallow[i] = o2
-                = evas_object_rectangle_add(e);
-              evas_object_color_set(o2, 0, 0, 0, 0);
-              evas_object_size_hint_min_set
-                (o2, sd->config.detail_min_w[i] * _scale_get(sd), 0);
-              snprintf(buf2, sizeof(buf2), "e.swallow.detail%i", i + 1);
-              edje_object_part_swallow(icon->o_base, buf2, o2);
-            }
+            _icon_detail_rectangle_add(icon, sd, e, i, NULL);
         }
     }
   edje_object_preload(o, EINA_FALSE);

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

Reply via email to