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 2bf5777589d30b9e30fc4550533fe63cb8459279
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Tue Oct 3 19:45:35 2023 +0100
start supporting detail columns with multiple formats per cell
---
TODO.md | 2 +-
src/backends/table/open | 11 ++-
src/efm/efm.c | 2 +-
src/efm/efm_dnd.c | 2 +-
src/efm/efm_util.c | 212 ++++++++++++++++++++++++++++++++++++++----------
5 files changed, 177 insertions(+), 52 deletions(-)
diff --git a/TODO.md b/TODO.md
index 98b29e0..d50ca2f 100644
--- a/TODO.md
+++ b/TODO.md
@@ -61,7 +61,7 @@
* Change detailtext=yes to detailformat=col1,col2,col3,...col6
* Above format would be a type per col. Types to support:
* text (already in detail)
- * size (Already in detail)
+ * size (already in detail)
* datetime (already in detail)
* permissions (already in detail)
* checkview
diff --git a/src/backends/table/open b/src/backends/table/open
index 556723c..0d4923e 100755
--- a/src/backends/table/open
+++ b/src/backends/table/open
@@ -52,18 +52,17 @@ function handle_cmd_dir_set() {
echo "CMD detail-header-set col=5 label=h-five"
echo "CMD detail-header-set col=6 label=h-six"
echo "CMD list-begin"
- D="detailtext=yes detail1=one detail2=two detail3=three detail4=four detail5=five detail6=six"
+ D="detail-format=text,text,text,text,timestamp,size detail1=one detail2=two detail3=three detail4=four"
val_escape F ${DIR}"abba"
val_escape M ${DIR}"ic.jpg"
M="type=file icon="${M}
- err "CMD file-add path="${F}" "${M}" "${D}
- echo "CMD file-add path="${F}" "${M}" "${D}
+ echo "CMD file-add path="${F}" "${M}" "${D}" detail5=0 detail6=576/65536"
val_escape F ${DIR}"boopy__==!@#$%^&*();"
- echo "CMD file-add path="${F}" "${M}" "${D}
+ echo "CMD file-add path="${F}" "${M}" "${D}" detail5=1696332215 detail6=16384/65536"
val_escape F ${DIR}"g h i"
- echo "CMD file-add path="${F}" "${M}" "${D}
+ echo "CMD file-add path="${F}" "${M}" "${D}" detail5=1696322215 detail6=65535/65536"
val_escape F ${DIR}"z~"
- echo "CMD file-add path="${F}" "${M}" "${D}
+ echo "CMD file-add path="${F}" "${M}" "${D}" detail5=1296332215 detail6=7823/65536"
echo "CMD list-end"
}
diff --git a/src/efm/efm.c b/src/efm/efm.c
index d9ca4a4..5b4c074 100644
--- a/src/efm/efm.c
+++ b/src/efm/efm.c
@@ -142,7 +142,7 @@ _cb_sel_get(void *data, Evas_Object *_obj EINA_UNUSED, Elm_Selection_Data *ev)
memcpy(tmp, ev->data, ev->len);
tmp[ev->len] = 0;
plist = eina_str_split(tmp, "\n", -1);
- for (p = plist; *p != NULL; ++p)
+ for (p = plist; *p != NULL; p++)
{
if (**p)
{
diff --git a/src/efm/efm_dnd.c b/src/efm/efm_dnd.c
index 6b7a788..6dade22 100644
--- a/src/efm/efm_dnd.c
+++ b/src/efm/efm_dnd.c
@@ -169,7 +169,7 @@ _cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev)
memcpy(tmp, ev->data, ev->len);
tmp[ev->len] = 0;
plist = eina_str_split(tmp, "\n", -1);
- for (p = plist; *p != NULL; ++p)
+ for (p = plist; *p != NULL; p++)
{
if (**p)
{
diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index 17167f0..84bc7f1 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -799,7 +799,9 @@ _icon_select_update(Icon *icon)
_icon_file_set(icon, icon->info.icon_selected);
for (i = 0; i < 6; i++)
{
- if (icon->o_list_detail_swallow2[i])
+ if ((icon->o_list_detail_swallow2[i]) &&
+ (evas_object_data_get(icon->o_list_detail_swallow2[i],
+ "is_edje")))
edje_object_signal_emit(icon->o_list_detail_swallow2[i],
"e,state,selected", "e");
}
@@ -814,7 +816,9 @@ _icon_select_update(Icon *icon)
_icon_file_set(icon, icon->info.pre_lookup_icon);
for (i = 0; i < 6; i++)
{
- if (icon->o_list_detail_swallow2[i])
+ if ((icon->o_list_detail_swallow2[i]) &&
+ (evas_object_data_get(icon->o_list_detail_swallow2[i],
+ "is_edje")))
edje_object_signal_emit(icon->o_list_detail_swallow2[i],
"e,state,unselected", "e");
}
@@ -1144,6 +1148,152 @@ _cb_icon_label_longpress(void *data, Evas_Object *obj EINA_UNUSED,
_icon_rename_begin(icon);
}
+static int
+_icon_detail_size_display(unsigned long long size, char unit[8])
+{
+#define K 1024ULL
+ unsigned long long sizetbl[] =
+ {
+ K, 0 , 0,
+ K*K, (K) - 1, 10,
+ K*K*K, (K*K) - 1, 20,
+ K*K*K*K, (K*K*K) - 1, 30,
+ K*K*K*K*K, (K*K*K*K) - 1, 40,
+ K*K*K*K*K*K, (K*K*K*K*K) - 1, 50,
+ K*K*K*K*K*K*K, (K*K*K*K*K*K) - 1, 60
+ };
+#undef K
+ char *sizes = "bKMGTPE"; /* "ZY" (Zetta, Yotta) not handled - beyond 64b */
+ int i, i3;
+
+ unit[0] = '?';
+ for (i = 0; i < 7; i++)
+ {
+ i3 = i * 3;
+ if (size < sizetbl[(i3)])
+ {
+ size = (size + sizetbl[i3 + 1]) >> sizetbl[i3 + 2];
+ strncpy(unit, &(sizes[i]), 1);
+ break;
+ }
+ }
+ unit[1] = '\0';
+ return (int)size; // int is fine as we reduced the value to unit size
+}
+
+static Evas_Object *
+_icon_detail_grid_add(Icon *icon, Smart_Data *sd, int col)
+{
+ Evas_Object *o;
+ char buf[128];
+
+ icon->o_list_detail_swallow[col] = o = elm_grid_add(sd->o_scroller);
+ elm_grid_size_set(o, 1, 1);
+ 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_sub_edje_add(Icon *icon, Evas *e,
+ const char *theme_edj_file, int col,
+ const char *group)
+{
+ Evas_Object *o;
+
+ icon->o_list_detail_swallow2[col] = o = edje_object_add(e);
+ edje_object_file_set(o, theme_edj_file, group);
+ evas_object_data_set(o, "is_edje", o);
+ if (icon->selected) edje_object_signal_emit(o, "e,state,selected", "e");
+ else edje_object_signal_emit(o, "e,state,unselected", "e");
+ elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
+ evas_object_show(o);
+ return o;
+}
+
+static void
+_icon_detail_edje_text_set_free(Evas_Object *o, const char *part, char *str)
+{
+ edje_object_part_text_set(o, part, str);
+ free(str);
+}
+
+static void
+_icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
+ const char *theme_edj_file, int col,
+ const char *detail, const char *format)
+{
+ Evas_Object *o;
+ char buf[128];
+
+ 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);
+ }
+ else if (!strcmp(format, "size"))
+ {
+ char **plist;
+ unsigned long long size, size_max;
+ double sz;
+
+ plist = eina_str_split(detail, "/", 2);
+ if (plist[0] && plist[1])
+ {
+ size = atoll(plist[0]);
+ size_max = atoll(plist[1]);
+
+ o = _icon_detail_grid_add(icon, sd, col);
+ o = _icon_detail_grid_sub_edje_add(icon, e, theme_edj_file, col,
+ "e/fileman/default/filesize");
+ sz = (double)size / (double)size_max;
+ // counteract _size_message doins a sqrt for show
+ sz = sz * sz;
+ if (size_max > 0) _size_message(o, sz);
+ else _size_message(o, 0.0);
+
+ size = _icon_detail_size_display(size, buf);
+ edje_object_part_text_set(o, "e.text.unit", buf);
+ snprintf(buf, sizeof(buf), "%i", (int)size);
+ edje_object_part_text_set(o, "e.text.label", buf);
+ edje_object_message_signal_process(o);
+ }
+ free(*plist);
+ free(plist);
+ }
+ else if (!strcmp(format, "timestamp"))
+ {
+ time_t tmpt = atoll(detail);
+ 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");
+ _icon_detail_edje_text_set_free(o, "e.text.year",
+ eina_strftime("%y", info));
+ _icon_detail_edje_text_set_free(o, "e.text.month",
+ eina_strftime("%b", info));
+ _icon_detail_edje_text_set_free(o, "e.text.day",
+ eina_strftime("%d", info));
+ _icon_detail_edje_text_set_free(o, "e.text.time",
+ eina_strftime("%H:%M:%S", info));
+ }
+ else
+ fprintf(stderr, "Uknown format for file '%s' column %i format '%s'\n",
+ icon->info.file, col, format);
+}
+
static void
_icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
const char *theme_edj_file, Eina_Bool clip_set, int num)
@@ -1223,24 +1373,20 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
else
edje_object_file_set(o, theme_edj_file,
"e/fileman/default/list/detailed");
- s = cmd_key_find(icon->cmd, "detailtext");
- if ((s) && (!strcmp(s, "yes")))
+ s = cmd_key_find(icon->cmd, "detail-format");
+ if (s)
{
- for (i = 0; i < 6; i++)
+ char **plist, **p;
+
+ plist = eina_str_split(s, ",", 6);
+ for (p = plist, i = 0; *p != NULL; p++, i++)
{
snprintf(buf2, sizeof(buf2), "detail%i", i + 1);
s = cmd_key_find(icon->cmd, buf2);
- snprintf(buf2, sizeof(buf2), "e.text.detail%i", i + 1);
- if (!s) s = "";
- edje_object_part_text_set(icon->o_base, buf2, s);
- 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_add(icon, sd, e, theme_edj_file, i, s, *p);
}
+ free(*plist);
+ free(plist);
}
else
{
@@ -1259,6 +1405,7 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
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");
@@ -1269,31 +1416,8 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
_size_message(o2, (double)size / (double)sd->file_max);
else _size_message(o2, 0.0);
- if (size < 1024)
- {
- edje_object_part_text_set(o2, "e.text.unit", "b");
- }
- else if (size < (1024LL * 1024LL))
- {
- size = ((size + ((1024LL) - 1)) >> 10);
- edje_object_part_text_set(o2, "e.text.unit", "K");
- }
- else if (size < (1024LL * 1024LL * 1024LL))
- {
- size = ((size + ((1024LL * 1024LL) - 1)) >> 20);
- edje_object_part_text_set(o2, "e.text.unit", "M");
- }
- else if (size < (1024LL * 1024LL * 1024LL * 1024LL))
- {
- size = ((size + ((1024LL * 1024LL * 1024LL) - 1)) >> 30);
- edje_object_part_text_set(o2, "e.text.unit", "G");
- }
- else if (size < (1024LL * 1024LL * 1024LL * 1024LL * 1024LL))
- {
- size = ((size + ((1024LL * 1024LL * 1024LL * 1024LL) - 1))
- >> 40);
- edje_object_part_text_set(o2, "e.text.unit", "T");
- }
+ size = _icon_detail_size_display(size, buf2);
+ edje_object_part_text_set(o2, "e.text.unit", buf2);
snprintf(buf2, sizeof(buf2), "%i", (int)size);
edje_object_part_text_set(o2, "e.text.label", buf2);
edje_object_message_signal_process(o2);
@@ -1315,6 +1439,7 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
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");
@@ -1355,6 +1480,7 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
icon->o_list_detail_swallow2[5] = o2 = edje_object_add(e);
edje_object_file_set(o2, theme_edj_file,
"e/fileman/default/fileperms");
+ 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");
@@ -1405,8 +1531,8 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
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);
+ 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);
}
@@ -1416,7 +1542,7 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
edje_object_signal_callback_add(o, "e,action,label,click", "e",
_cb_icon_label_longpress, icon);
icon->edje = EINA_FALSE;
- printf("[%s %s %s]\n", icon_group, icon_file, icon_thumb);
+
if ((!icon_group) && (icon_file))
{ // image file
icon->o_icon = o = efm_icon_add(o);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.