shot + efm - add efm action to show dir so if same dir is open it shows

and if there is not the same dir upa  new win is created and shown.
... shot uses this to avoid shot dir duplication.
This commit is contained in:
Carsten Haitzler 2020-01-09 00:26:45 +00:00
parent a9764f3e55
commit dda50e8d87
4 changed files with 84 additions and 2 deletions

View File

@ -647,6 +647,26 @@ e_fwin_zone_find(E_Zone *zone)
return NULL;
}
Eina_Bool
e_fwin_show(const char *dev, const char *path)
{
Eina_List *f;
E_Fwin *fwin;
EINA_LIST_FOREACH(fwins, f, fwin)
{
char *d, *p;
e_fm2_path_get(fwin->cur_page->fm_obj, &d, &p);
if ((d) && (!strcmp(dev, d)) && (p) && (!strcmp(path, p)))
{
elm_win_activate(fwin->win);
return EINA_TRUE;
}
}
return EINA_FALSE;
}
/* local subsystem functions */
static void
_e_fwin_bg_mouse_down(E_Fwin *fwin, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)

View File

@ -3,6 +3,8 @@
/* actual module specifics */
static void _e_mod_action_fileman_cb(E_Object *obj,
const char *params);
static void _e_mod_action_fileman_show_cb(E_Object *obj,
const char *params);
static void _e_mod_action_fileman_reset_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED);
static void _e_mod_menu_add(void *data, E_Menu *m);
static void _e_mod_fileman_config_load(void);
@ -14,6 +16,7 @@ static Eina_Bool _e_mod_zone_add(void *data,
static E_Module *conf_module = NULL;
static E_Action *act = NULL;
static E_Action *act2 = NULL;
static E_Action *act3 = NULL;
static E_Int_Menu_Augmentation *maug = NULL;
static Ecore_Event_Handler *zone_add_handler = NULL;
@ -58,6 +61,13 @@ e_modapi_init(E_Module *m)
act2 = e_action_add("fileman_reset");
if (act2)
act2->func.go = _e_mod_action_fileman_reset_cb;
act3 = e_action_add("fileman_show");
if (act3)
{
act3->func.go = _e_mod_action_fileman_show_cb;
e_action_predef_name_set(N_("Show Dir"), N_("File Manager"),
"fileman_show", NULL, "syntax: /path/to/dir or ~/path/to/dir or favorites or desktop, examples: /boot/grub, ~/downloads", 1);
}
maug = e_int_menus_menu_augmentation_add_sorted("main/1", _("Navigate"), _e_mod_menu_add, NULL, NULL, NULL);
e_fwin_init();
@ -118,6 +128,11 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
e_action_del("fileman_reset");
act2 = NULL;
}
if (act3)
{
e_action_del("fileman_show");
act3 = NULL;
}
while ((cfd = e_config_dialog_get("E", "fileman/mime_edit_dialog")))
e_object_del(E_OBJECT(cfd));
while ((cfd = e_config_dialog_get("E", "fileman/file_icons")))
@ -155,6 +170,12 @@ _e_mod_action_fileman_reset_cb(E_Object *obj EINA_UNUSED, const char *params EIN
e_fwin_reload_all();
}
static void
fwin(const char *dev, const char *path)
{
if (!e_fwin_show(dev, path)) e_fwin_new(dev, path);
}
static void
_e_mod_action_fileman_cb(E_Object *obj EINA_UNUSED,
const char *params)
@ -183,6 +204,46 @@ _e_mod_action_fileman_cb(E_Object *obj EINA_UNUSED,
}
}
static void
_e_mod_action_fileman_show_cb(E_Object *obj EINA_UNUSED,
const char *params)
{
const char *dev = NULL, *path = NULL;
char *p = NULL;
E_Zone *zone = NULL;
zone = e_zone_current_get();
if (zone)
{
if (params && params[0] == '/')
{
dev = "/";
path = params;
}
else if (params && params[0] == '~')
{
dev = "~/";
path = params + 1;
}
else if (params && strcmp(params, "(none)")) /* avoid matching paths that no longer exist */
{
p = e_util_shell_env_path_eval(params);
if (p)
{
dev = p;
path = "/";
}
}
else
{
dev = "favorites";
path = "/";
}
}
fwin(dev, path);
free(p);
}
void
_e_mod_menu_add(void *data EINA_UNUSED, E_Menu *m)
{

View File

@ -125,7 +125,8 @@ void e_fwin_zone_new (E_Zone *zone, void *path);
void e_fwin_zone_shutdown (E_Zone *zone);
void e_fwin_all_unsel (void *data);
void e_fwin_reload_all (void);
void *e_fwin_zone_find (E_Zone *zone);
void *e_fwin_zone_find (E_Zone *zone);
Eina_Bool e_fwin_show (const char *dev, const char *path);
Eina_Bool e_fwin_nav_init(void);
Eina_Bool e_fwin_nav_shutdown(void);

View File

@ -193,7 +193,7 @@ save_show(void)
snprintf(path2, sizeof(path2), "%s/fileman/favorites/shots.desktop",
e_user_dir_get());
if (!ecore_file_exists(path2)) ecore_file_cp(path, path2);
a = e_action_find("fileman");
a = e_action_find("fileman_show");
if (a)
{
a->func.go(NULL, "$E_HOME_DIR/shots");