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 2526305e90f2a3fe506f38269a801c0521514715
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Thu Dec 14 18:50:38 2023 +0000
add file-detail updater command to more optimally update
---
src/backends/table/open | 15 +++++++
src/efm/efm.c | 7 +++
src/efm/efm_back_end.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++
src/efm/efm_private.h | 5 +++
src/efm/efm_structs.h | 15 ++++++-
src/shared/cmd.c | 68 ++++++++++++++++++++++++++++-
src/shared/cmd.h | 1 +
7 files changed, 219 insertions(+), 3 deletions(-)
diff --git a/src/backends/table/open b/src/backends/table/open
index ffe4c3f..4a40045 100755
--- a/src/backends/table/open
+++ b/src/backends/table/open
@@ -115,6 +115,9 @@ function handle_cmd_dir_set() {
e_cmd "detail-header-set col=5 size=130 label=h-five"
e_cmd "detail-header-set col=6 size=90 label=h-six"
+# test timers
+ e_cmd "timer-add name=ONE-OFF delay=1500"
+ e_cmd "timer-add name=REPEAT-800ms repeat=true delay=800"
# begin initial listing of files
e_cmd "list-begin"
# define some params we're going to use
@@ -214,6 +217,18 @@ function handle_cmd() {
fi
;;
# commands this fs doesn;'t handle (yet?)
+ timer )
+ if [ ${ARGS[0]} = "name" ]; then
+ NAME=${ARGS[1]}
+ e_err "timer :$NAME:"
+ if [ ${NAME} = "REPEAT-800ms" ]; then
+ e_val_escape F ${DIR}"abba"
+ R=$[ $RANDOM * 100 ];
+ R=$[ $R / 32767 ];
+ e_cmd "file-detail path="${F}" detail3="${R}"/100"
+ fi
+ fi
+ ;;
meta-set )
;;
cnp-cut )
diff --git a/src/efm/efm.c b/src/efm/efm.c
index 79db2ed..0df9d97 100644
--- a/src/efm/efm.c
+++ b/src/efm/efm.c
@@ -847,6 +847,7 @@ _smart_del(Evas_Object *obj)
Icon *icon;
Evas *e;
int i;
+ Smart_Data_Timer *st;
ENTRY;
_efm_list = eina_list_remove(_efm_list, obj);
@@ -992,6 +993,12 @@ _smart_del(Evas_Object *obj)
ecore_timer_del(sd->dnd_scroll_timer);
sd->dnd_scroll_timer = NULL;
}
+ EINA_LIST_FREE(sd->timers, st)
+ {
+ eina_stringshare_del(st->name);
+ ecore_timer_del(st->timer);
+ free(st);
+ }
_icon_custom_data_free(sd);
// XXX: anything special with scroller?
diff --git a/src/efm/efm_back_end.c b/src/efm/efm_back_end.c
index d9ec713..187c1e4 100644
--- a/src/efm/efm_back_end.c
+++ b/src/efm/efm_back_end.c
@@ -1,3 +1,4 @@
+#include "eina_types.h"
static void
_size_message(Evas_Object *o, double v)
{
@@ -381,6 +382,21 @@ _icon_add_mod_props_get(Icon *icon, Cmd *c, const char *label)
}
}
+static Eina_Bool
+_cb_smart_timer(void *data)
+{
+ Smart_Data_Timer *st = data;
+ Eina_Strbuf *buf = cmd_strbuf_new("timer");
+
+ cmd_strbuf_append(buf, "name", st->name);
+ cmd_strbuf_exe_consume(buf, st->sd->exe_open);
+ if (st->repeat) return EINA_TRUE;
+ st->sd->timers = eina_list_remove(st->sd->timers, st);
+ eina_stringshare_del(st->name);
+ free(st);
+ return EINA_FALSE;
+}
+
static void
_cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
{ // handle data from the view thread to the UI - this will be a batch of cmds
@@ -423,6 +439,49 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
sd->listing_done_reblock = EINA_TRUE;
CMD_DONE;
}
+ else if (!strcmp(c->command, "timer-add"))
+ { // *** must call before list-begin
+ const char *name = cmd_key_find(c, "name");
+ const char *delay = cmd_key_find(c, "delay");
+ const char *repeat = cmd_key_find(c, "repeat");
+
+ if (name && delay)
+ {
+ Smart_Data_Timer *st = calloc(1, sizeof(Smart_Data_Timer));
+
+ if (st)
+ {
+ st->sd = sd;
+ st->name = eina_stringshare_add(name);
+ st->repeat = repeat ? EINA_TRUE : EINA_FALSE;
+ st->delay = (double)atoi(delay) / 1000.0;
+ st->timer = ecore_timer_add(st->delay, _cb_smart_timer, st);
+ sd->timers = eina_list_append(sd->timers, st);
+ }
+ }
+ CMD_DONE;
+ }
+ else if (!strcmp(c->command, "timer-del"))
+ { // *** must call before list-begin
+ const char *name = cmd_key_find(c, "backend");
+ Smart_Data_Timer *st;
+ Eina_List *l;
+
+ if (name)
+ {
+ EINA_LIST_FOREACH(sd->timers, l, st)
+ {
+ if (!strcmp(st->name, name))
+ {
+ sd->timers = eina_list_remove_list(sd->timers, l);
+ eina_stringshare_del(st->name);
+ ecore_timer_del(st->timer);
+ free(st);
+ }
+ }
+ }
+ CMD_DONE;
+ }
else if (!strcmp(c->command, "backend-set"))
{ // *** must call before list-begin
const char *backend = cmd_key_find(c, "backend");
@@ -673,6 +732,58 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
cmd_free(c);
c = NULL;
}
+ else if (!strcmp(c->command, "file-detail"))
+ {
+ int n;
+ const char *theme_edj_file;
+ char **plist;
+ char bufdetail[16];
+
+ theme_edj_file
+ = elm_theme_group_path_find(NULL, "e/fileman/default/icon/fixed");
+ for (n = 0; il; il = il->next, n++)
+ {
+ icon = il->data;
+ if (!strcmp(file, icon->info.file))
+ {
+ int i;
+
+ s = cmd_key_find(icon->cmd, "detail-format");
+ if (s)
+ {
+ plist = eina_str_split(s, ",", 6);
+ if (plist)
+ {
+ for (i = 0; plist[i];) i++;
+ if (i >= 6)
+ {
+ for (i = 1; i < 7; i++)
+ {
+ snprintf(bufdetail, sizeof(bufdetail), "detail%i", i);
+ s = cmd_key_find(c, bufdetail);
+ if (s)
+ {
+ icon->cmd = cmd_modify(icon->cmd,
+ bufdetail, s);
+ if (icon->realized)
+ _icon_detail_add(
+ icon, icon->sd,
+ evas_object_evas_get(icon->o_base),
+ theme_edj_file, i - 1, s,
+ plist[i - 1]);
+ }
+ }
+ }
+ free(*plist);
+ free(plist);
+ }
+ }
+ break;
+ }
+ }
+ cmd_free(c);
+ c = NULL;
+ }
cprev = c;
}
eina_list_free(batch);
diff --git a/src/efm/efm_private.h b/src/efm/efm_private.h
index d28da6b..7d04b24 100644
--- a/src/efm/efm_private.h
+++ b/src/efm/efm_private.h
@@ -42,3 +42,8 @@ static void _drag_start(Icon *icon);
static void _icon_custom_data_free(Smart_Data *sd);
static void _reset(Smart_Data *sd);
+
+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);
\ No newline at end of file
diff --git a/src/efm/efm_structs.h b/src/efm/efm_structs.h
index bd398fa..4464037 100644
--- a/src/efm/efm_structs.h
+++ b/src/efm/efm_structs.h
@@ -2,6 +2,7 @@
//
typedef struct _Smart_Data Smart_Data;
typedef struct _Smart_Data_Thread Smart_Data_Thread;
+typedef struct _Smart_Data_Timer Smart_Data_Timer;
typedef struct _Block Block;
typedef struct _Icon Icon;
@@ -14,8 +15,17 @@ struct _Smart_Data_Thread
Eina_Thread_Queue *thq;
};
-// an icon view gui data
-struct _Smart_Data
+struct _Smart_Data_Timer
+{
+ Smart_Data *sd;
+ Eina_Stringshare *name;
+ Ecore_Timer *timer;
+ double delay;
+ Eina_Bool repeat : 1;
+};
+
+ // an icon view gui data
+ struct _Smart_Data
{
Evas_Object_Smart_Clipped_Data __clipped_data;
@@ -76,6 +86,7 @@ struct _Smart_Data
Ecore_Timer *scroll_timer;
Ecore_Timer *dnd_scroll_timer;
Ecore_Timer *dnd_over_open_timer;
+ Eina_List *timers;
Elm_Xdnd_Action dnd_action;
Evas_Coord dnd_x, dnd_y;
void *custom_data; // handled in efm_custom.c
diff --git a/src/shared/cmd.c b/src/shared/cmd.c
index de848f1..1167594 100644
--- a/src/shared/cmd.c
+++ b/src/shared/cmd.c
@@ -114,7 +114,7 @@ cmd_dup(const Cmd *c)
for (i = 0; c->dict[i]; i++)
; // count dict keys
dict_num = i + 2;
- c2 = calloc(1, sizeof(Cmd) + (sizeof(char *) * (dict_num + 2)));
+ c2 = calloc(1, sizeof(Cmd) + (sizeof(char *) * dict_num));
if (!c2) return NULL;
c2->buf_size = c->buf_size;
if (c2->buf_size != 0)
@@ -131,6 +131,72 @@ err:
return NULL;
}
+Cmd *
+cmd_modify(const Cmd *c, const char *key, const char *val)
+{
+ Cmd *c2;
+ int i, dict_num = 0, sub = 0;
+ Eina_Binbuf *binbuf;
+
+ if (!key) return cmd_dup(c);
+ for (i = 0; c->dict[i]; i += 2)
+ { // count dict keys - and skip key if being deleted (val = NULL)
+ if ((!strcmp(c->dict[i], key)) && (!val)) sub = 1;
+ }
+ dict_num = (i * 2) - (sub * 2) + 2;
+ c2 = calloc(1, sizeof(Cmd) + (sizeof(char *) * dict_num));
+ if (!c2) return NULL;
+ if (c->buf)
+ {
+ binbuf = eina_binbuf_new();
+ eina_binbuf_append_length(binbuf, (unsigned char *)c->command,
+ strlen(c->command) + 1);
+ if (!binbuf) goto err;
+ for (i = 0; c->dict[i]; i += 2)
+ {
+ if (!strcmp(c->dict[i], key))
+ {
+ if (val)
+ {
+ c2->dict[i] = (void *)(unsigned long)
+ eina_binbuf_length_get(binbuf);
+ eina_binbuf_append_length(binbuf,
+ (unsigned char *)key,
+ strlen(key) + 1);
+ c2->dict[i + 1] = (void *)(unsigned long)
+ eina_binbuf_length_get(binbuf);
+ eina_binbuf_append_length(binbuf,
+ (unsigned char *)val,
+ strlen(val) + 1);
+ }
+ }
+ else
+ {
+ c2->dict[i] = (void *)(unsigned long)
+ eina_binbuf_length_get(binbuf);
+ eina_binbuf_append_length(binbuf,
+ (unsigned char *)c->dict[i],
+ strlen(c->dict[i]) + 1);
+ c2->dict[i + 1] = (void *)(unsigned long)
+ eina_binbuf_length_get(binbuf);
+ eina_binbuf_append_length(binbuf,
+ (unsigned char *)c->dict[i + 1],
+ strlen(c->dict[i + 1]) + 1);
+ }
+ }
+ c2->buf = (char *)eina_binbuf_string_steal(binbuf);
+ if (!c2->buf) goto err;
+ c2->buf_size = eina_binbuf_length_get(binbuf);
+ eina_binbuf_free(binbuf);
+ for (i = 0; c2->dict[i]; i++) c2->dict[i] = c2->buf + (unsigned long)c2->dict[i];
+ }
+ c2->command = c2->buf;
+ return c2;
+err:
+ cmd_free(c2);
+ return NULL;
+}
+
void
cmd_dump_sterr(Cmd *c)
{
diff --git a/src/shared/cmd.h b/src/shared/cmd.h
index 01ee4a1..cfb7300 100644
--- a/src/shared/cmd.h
+++ b/src/shared/cmd.h
@@ -55,6 +55,7 @@ typedef struct _Cmd
Cmd *cmd_parse(const char *cmd);
void cmd_free(Cmd *c);
Cmd *cmd_dup(const Cmd *c);
+Cmd *cmd_modify(const Cmd *c, const char *key, const char *val);
void cmd_dump_sterr(Cmd *c);
Eina_Strbuf *cmd_strbuf_new(const char *command);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.