we can finally navigate to child dirs and parent dirs...

This commit is contained in:
Carsten Haitzler 2023-12-27 21:22:42 +00:00
parent 577bacfd04
commit d5109ca872
5 changed files with 117 additions and 8 deletions

View File

@ -974,6 +974,64 @@ do_handle_cmd(Cmd *c)
}
KEY_WALK_END
}
else if (!strcmp(c->command, "file-run"))
{
KEY_WALK_BEGIN
{
if (!strcmp(key, "path"))
{
char **plist, **p;
int files = 0, dirs = 0;
plist = eina_str_split(data, "\n", -1);
for (p = plist; *p; p++)
{
Efreet_Uri *uri = efreet_uri_decode(*p);
if (uri)
{
if ((uri->protocol) && (!strcmp(uri->protocol, "file")))
{
files++;
if (ecore_file_is_dir(uri->path)) dirs++;
}
efreet_uri_free(uri);
}
}
if ((files == 1) && (dirs == 1))
{ // open a single dir, so set view to that dir
Efreet_Uri *uri = efreet_uri_decode(*plist);
if (uri)
{
Eina_Strbuf *strbuf;
strbuf = cmd_strbuf_new("dir-request");
cmd_strbuf_append(strbuf, "path", uri->path);
cmd_strbuf_print_consume(strbuf);
efreet_uri_free(uri);
}
}
else
{ // walk through all files and "run" them
for (p = plist; *p; p++)
{
Efreet_Uri *uri = efreet_uri_decode(*p);
if (uri)
{
fprintf(stderr, "FFF: [%s][%s][%s]\n", uri->protocol,
uri->hostname, uri->path);
efreet_uri_free(uri);
}
}
}
free(*plist);
free(plist);
}
}
KEY_WALK_END
}
// cmd_dump_sterr(c);
}

View File

@ -45,13 +45,15 @@ static Evas_Smart_Class _sc_parent = EVAS_SMART_CLASS_INIT_NULL;
Smart_Data *sd = evas_object_smart_data_get(obj); \
if (!sd) return
static void _reset(Smart_Data *sd);
static char *_sanitize_dir(const char *path);
#include "efm_private.h"
#include "efm_back_end.c"
#include "efm_util.c"
#include "efm_dnd.c"
static void
_cb_header_change(void *data)
static void _cb_header_change(void *data)
{
Smart_Data *sd = data;
@ -1424,6 +1426,7 @@ _reset(Smart_Data *sd)
if (sd->config.path)
{
printf("O [ %s ]\n", sd->config.path);
_listing_do(sd);
buf = cmd_strbuf_new("dir-set");
cmd_strbuf_append(buf, "path", sd->config.path);
@ -1802,6 +1805,27 @@ efm_path_get(Evas_Object *obj)
return sd->config.path;
}
void
efm_path_parent(Evas_Object *obj)
{
char *tmps, *p;
ENTRY;
if (!sd->config.path) return;
tmps = strdup(sd->config.path);
if (!tmps) return;
p = strrchr(tmps, '/');
if ((p) && (p != tmps))
{
*p = 0;
p = strrchr(tmps, '/');
if (p) p[1] = 0;
}
eina_stringshare_replace(&sd->config.path, tmps);
_reset(sd);
free(tmps);
}
////////
void
efm_path_view_mode_set(Evas_Object *obj, Efm_View_Mode mode)

View File

@ -52,6 +52,7 @@ void efm_backend_set(Evas_Object *obj, const char *backend);
// alweays call path_Set last after setup above like setting icon size etc.
void efm_path_set(Evas_Object *obj, const char *path);
const char *efm_path_get(Evas_Object *obj);
void efm_path_parent(Evas_Object *obj);
#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__)
#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)

View File

@ -407,7 +407,7 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
Eina_List *l, *il2, *il = NULL;
Icon *icon, *icon2;
Block *block;
const char *file, *label, *s;
const char *path, *file, *label, *s;
int file_adds = 0, file_dels = 0;
if (!sd)
@ -463,7 +463,7 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
}
else if (!strcmp(c->command, "timer-del"))
{ // *** must call before list-begin
const char *name = cmd_key_find(c, "backend");
const char *name = cmd_key_find(c, "name");
Smart_Data_Timer *st;
Eina_List *l;
@ -562,13 +562,13 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
}
// below commands all send a path for a specific file
file = cmd_key_find(c, "path");
path = file = cmd_key_find(c, "path");
printf("XXXXX [%s] [%s]\n", c->command, file);
if (file)
{
s = strrchr(file, '/');
if (s) file = s + 1;
if (file[0] == '.') // XXX filter dor files or not
if (file[0] == '.') // XXX filter dot files or not
{
CMD_DONE;
}
@ -577,6 +577,16 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
{ // somehow we didn't get a sane filename from the back-end
CMD_DONE;
}
if (!strcmp(c->command, "dir-request"))
{
char *path2;
path2 = _sanitize_dir(path);
eina_stringshare_replace(&sd->config.path, path2);
free(path2);
_reset(sd);
CMD_DONE;
}
label = cmd_key_find(c, "link-label");
if (!label) label = cmd_key_find(c, "label");

View File

@ -6,6 +6,13 @@
static Evas_Object *o_detail_header_box = NULL;
static Evas_Object *o_detail_header = NULL;
static void
_cb_parent(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
efm_path_parent(data);
}
static void
_cb_icons(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@ -64,7 +71,7 @@ EAPI_MAIN int
elm_main(int argc, char **argv)
{
const char *path;
Evas_Object *o, *win, *sc, *efm, *bx, *bx2;
Evas_Object *o, *win, *sc, *efm, *bx, *bx2, *par;
char buf[PATH_MAX];
if (argc > 1)
@ -109,11 +116,18 @@ elm_main(int argc, char **argv)
bx2 = o = elm_box_add(win);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
elm_box_homogeneous_set(o, EINA_TRUE);
elm_box_homogeneous_set(o, EINA_FALSE);
elm_box_horizontal_set(o, EINA_TRUE);
elm_box_pack_end(bx, o);
evas_object_show(o);
par = o = elm_button_add(win);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(o, 0, 0);
elm_object_text_set(o, "<");
elm_box_pack_end(bx2, o);
evas_object_show(o);
o = elm_button_add(win);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
@ -142,6 +156,8 @@ elm_main(int argc, char **argv)
efm_path_set(o, path);
evas_object_show(o);
evas_object_smart_callback_add(par, "clicked", _cb_parent, efm);
bx2 = o = elm_box_add(win);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);