forked from enlightenment/enlightenment
fileman code is not needed anymore (not built)
error code is pretty legacy - going going going gone. SVN revision: 25876
This commit is contained in:
parent
3737f4e554
commit
dac3a44c8c
|
@ -3,418 +3,18 @@
|
|||
*/
|
||||
#include "e.h"
|
||||
|
||||
/* TODO List:
|
||||
*
|
||||
* * edjify error dialogs if edje data can be found for them
|
||||
* * current gui dialg needs to resize to fit contents if they are bigger
|
||||
*/
|
||||
|
||||
/* local subsystem functions */
|
||||
static void _e_error_message_show_x(char *txt);
|
||||
|
||||
static void _e_error_cb_ok_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _e_error_cb_ok_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _e_error_edje_cb_ok_up(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _e_error_cb_job_ecore_evas_free(void *data);
|
||||
|
||||
/* local subsystem globals */
|
||||
static int error_gui = 0;
|
||||
|
||||
/* externally accessible functions */
|
||||
EAPI void
|
||||
e_error_message_show_internal(char *txt)
|
||||
{
|
||||
printf("_______ _______\n"
|
||||
"|:::::| Enlightenment Error |:::::|\n"
|
||||
"~~~~~~~ ~~~~~~~\n"
|
||||
/* FIXME: maybe log these to a file and display them at some point */
|
||||
printf("<<<< Enlightenment Error >>>>\n"
|
||||
"%s\n",
|
||||
txt);
|
||||
if (error_gui) _e_error_message_show_x(txt);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_error_dialog_show_internal(char *title, char *txt)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_Manager *man;
|
||||
|
||||
l = e_manager_list();
|
||||
if (!l) return;
|
||||
man = l->data;
|
||||
e_error_message_manager_show(man, title, txt);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_error_gui_set(int on)
|
||||
{
|
||||
error_gui = on;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_error_message_manager_show(E_Manager *man, char *title, char *txt)
|
||||
{
|
||||
Ecore_Evas *ee;
|
||||
Evas *e;
|
||||
Evas_Object *o;
|
||||
int error_w, error_h;
|
||||
Evas_List *l, *shapelist = NULL;
|
||||
Evas_Coord maxw, maxh;
|
||||
E_Container *con;
|
||||
Ecore_X_Window win;
|
||||
int x, y;
|
||||
const char *s;
|
||||
|
||||
con = e_container_current_get(man);
|
||||
|
||||
error_w = 400;
|
||||
error_h = 200;
|
||||
x = (man->w - error_w) / 2;
|
||||
y = (man->h - error_h) / 2;
|
||||
ee = e_canvas_new(e_config->evas_engine_errors, man->win,
|
||||
x, y, error_w, error_h, 1, 0,
|
||||
&win, NULL);
|
||||
e_canvas_add(ee);
|
||||
ecore_evas_override_set(ee, 1);
|
||||
e_container_window_raise(con, win, 999);
|
||||
|
||||
ecore_evas_name_class_set(ee, "E", "Low_Level_Dialog");
|
||||
ecore_evas_title_set(ee, "Enlightenment: Low Level Dialog");
|
||||
// ecore_evas_avoid_damage_set(ee, 1);
|
||||
e = ecore_evas_get(ee);
|
||||
|
||||
o = edje_object_add(e);
|
||||
if (!e_theme_edje_object_set(o, "base/theme/error", "e/error/main"))
|
||||
{
|
||||
Evas_Coord tw, th;
|
||||
char *newstr;
|
||||
|
||||
if (o) evas_object_del(o);
|
||||
|
||||
maxw = 0;
|
||||
maxh = 0;
|
||||
|
||||
o = evas_object_image_add(e);
|
||||
s = e_path_find(path_images, "e.png");
|
||||
evas_object_image_file_set(o, s, NULL);
|
||||
if (s) evas_stringshare_del(s);
|
||||
evas_object_move(o, 16, 16);
|
||||
evas_object_resize(o, 64, 64);
|
||||
evas_object_image_fill_set(o, 0, 0, 64, 64);
|
||||
evas_object_pass_events_set(o, 1);
|
||||
evas_object_show(o);
|
||||
|
||||
o = evas_object_text_add(e);
|
||||
evas_object_color_set(o, 255, 255, 255, 128);
|
||||
evas_object_text_font_set(o, "Vera-Bold", 12);
|
||||
evas_object_text_text_set(o, title);
|
||||
evas_object_geometry_get(o, NULL, NULL, &tw, &th);
|
||||
evas_object_move(o,
|
||||
(16 + 64 + 16) + 1,
|
||||
(16 + ((64 - th) / 2)) + 1);
|
||||
evas_object_pass_events_set(o, 1);
|
||||
evas_object_show(o);
|
||||
|
||||
maxw = 16 + 64 + 16 + tw + 16;
|
||||
maxh = 16 + 64;
|
||||
|
||||
o = evas_object_text_add(e);
|
||||
evas_object_color_set(o, 0, 0, 0, 255);
|
||||
evas_object_text_font_set(o, "Vera-Bold", 12);
|
||||
evas_object_text_text_set(o, title);
|
||||
evas_object_geometry_get(o, NULL, NULL, &tw, &th);
|
||||
evas_object_move(o,
|
||||
16 + 64 + 16,
|
||||
16 + ((64 - th) / 2));
|
||||
evas_object_pass_events_set(o, 1);
|
||||
evas_object_show(o);
|
||||
|
||||
newstr = strdup(txt);
|
||||
if (newstr)
|
||||
{
|
||||
char *p;
|
||||
Evas_Coord y;
|
||||
const char *fname;
|
||||
int fsize;
|
||||
|
||||
y = 16 + 64 + 16;
|
||||
fname = e_font_default_string_get("default", &fsize);
|
||||
for (p = newstr; p;)
|
||||
{
|
||||
char *pp;
|
||||
|
||||
pp = strchr(p, '\n');
|
||||
if (pp) *pp = 0;
|
||||
o = evas_object_text_add(e);
|
||||
evas_object_color_set(o, 255, 255, 255, 128);
|
||||
evas_object_text_font_set(o, fname, fsize);
|
||||
evas_object_text_text_set(o, p);
|
||||
evas_object_geometry_get(o, NULL, NULL, &tw, &th);
|
||||
evas_object_move(o, 16 + 1, y + 1);
|
||||
evas_object_pass_events_set(o, 1);
|
||||
evas_object_show(o);
|
||||
|
||||
o = evas_object_text_add(e);
|
||||
evas_object_color_set(o, 0, 0, 0, 255);
|
||||
evas_object_text_font_set(o, fname, fsize);
|
||||
evas_object_text_text_set(o, p);
|
||||
evas_object_geometry_get(o, NULL, NULL, &tw, &th);
|
||||
evas_object_move(o, 16, y);
|
||||
evas_object_pass_events_set(o, 1);
|
||||
evas_object_show(o);
|
||||
|
||||
if ((16 + tw + 16) > maxw) maxw = 16 + tw + 16;
|
||||
y += th;
|
||||
if (pp) p = pp + 1;
|
||||
else p = NULL;
|
||||
}
|
||||
free(newstr);
|
||||
maxh = y;
|
||||
}
|
||||
|
||||
maxh += 16 + 32 + 16;
|
||||
error_w = maxw;
|
||||
error_h = maxh;
|
||||
|
||||
if (error_w > man->w) error_w = man->w;
|
||||
if (error_h > man->h) error_h = man->h;
|
||||
|
||||
o = evas_object_image_add(e);
|
||||
s = e_path_find(path_images, "button_out.png");
|
||||
evas_object_image_file_set(o, s, NULL);
|
||||
if (s) evas_stringshare_del(s);
|
||||
evas_object_move(o, (error_w - 64) / 2, error_h - 16 - 32);
|
||||
evas_object_resize(o, 64, 32);
|
||||
evas_object_image_fill_set(o, 0, 0, 64, 32);
|
||||
evas_object_image_border_set(o, 8, 8, 8, 8);
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_error_cb_ok_down, ee);
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _e_error_cb_ok_up, ee);
|
||||
evas_object_show(o);
|
||||
|
||||
o = evas_object_text_add(e);
|
||||
evas_object_color_set(o, 255, 255, 255, 128);
|
||||
evas_object_text_font_set(o, "Vera-Bold", 12);
|
||||
evas_object_text_text_set(o, _("OK"));
|
||||
evas_object_geometry_get(o, NULL, NULL, &tw, &th);
|
||||
evas_object_move(o, ((error_w - tw) / 2) + 1, (error_h - 16 - 32 + ((32 - th) / 2)) + 1);
|
||||
evas_object_pass_events_set(o, 1);
|
||||
evas_object_show(o);
|
||||
|
||||
o = evas_object_text_add(e);
|
||||
evas_object_color_set(o, 0, 0, 0, 255);
|
||||
evas_object_text_font_set(o, "Vera-Bold", 12);
|
||||
evas_object_text_text_set(o, _("OK"));
|
||||
evas_object_geometry_get(o, NULL, NULL, &tw, &th);
|
||||
evas_object_move(o, (error_w - tw) / 2, error_h - 16 - 32 + ((32 - th) / 2));
|
||||
evas_object_pass_events_set(o, 1);
|
||||
evas_object_show(o);
|
||||
|
||||
o = evas_object_image_add(e);
|
||||
s = e_path_find(path_images, "error_bg.png");
|
||||
evas_object_image_file_set(o, s, NULL);
|
||||
if (s) evas_stringshare_del(s);
|
||||
evas_object_move(o, 0, 0);
|
||||
evas_object_image_fill_set(o, 0, 0, error_w, error_h);
|
||||
evas_object_resize(o, error_w, error_h);
|
||||
evas_object_image_border_set(o, 3, 3, 3, 3);
|
||||
evas_object_pass_events_set(o, 1);
|
||||
evas_object_layer_set(o, -10);
|
||||
evas_object_show(o);
|
||||
|
||||
x = (man->w - error_w) / 2;
|
||||
y = (man->h - error_h) / 2;
|
||||
con = e_container_current_get(man);
|
||||
if (con)
|
||||
{
|
||||
E_Zone *zone;
|
||||
|
||||
zone = e_container_zone_number_get(con, 0);
|
||||
if (zone)
|
||||
{
|
||||
x = zone->x + ((zone->w - error_w) / 2);
|
||||
y = zone->y + ((zone->h - error_h) / 2);
|
||||
}
|
||||
}
|
||||
ecore_evas_move(ee, x, y);
|
||||
ecore_evas_resize(ee, error_w, error_h);
|
||||
|
||||
for (l = man->containers; l; l = l->next)
|
||||
{
|
||||
E_Container_Shape *es;
|
||||
|
||||
con = l->data;
|
||||
es = e_container_shape_add(con);
|
||||
e_container_shape_move(es, x, y);
|
||||
e_container_shape_resize(es, error_w, error_h);
|
||||
e_container_shape_show(es);
|
||||
shapelist = evas_list_append(shapelist, es);
|
||||
}
|
||||
ecore_evas_data_set(ee, "shapes", shapelist);
|
||||
|
||||
o = evas_object_rectangle_add(e);
|
||||
evas_object_name_set(o, "allocated");
|
||||
}
|
||||
else
|
||||
{
|
||||
int x, y;
|
||||
Evas_Coord ow, oh;
|
||||
|
||||
evas_object_move(o, 0, 0);
|
||||
evas_object_resize(o, error_w, error_h);
|
||||
edje_object_signal_callback_add(o, "e,action,close", "",
|
||||
_e_error_edje_cb_ok_up, ee);
|
||||
evas_object_show(o);
|
||||
|
||||
edje_object_part_text_set(o, "e.text.title", title);
|
||||
|
||||
{
|
||||
char *pp, *newstr, *p, *markup = NULL;
|
||||
|
||||
newstr = strdup(txt);
|
||||
p = newstr;
|
||||
while (p)
|
||||
{
|
||||
pp = strchr(p, '\n');
|
||||
if (pp) *pp = 0;
|
||||
if (markup)
|
||||
{
|
||||
markup = realloc(markup, strlen(markup) + strlen(p) + 1);
|
||||
strcat(markup, p);
|
||||
}
|
||||
else
|
||||
markup = strdup(p);
|
||||
if (pp)
|
||||
{
|
||||
p = pp + 1;
|
||||
if (markup)
|
||||
{
|
||||
markup = realloc(markup, strlen(markup) + strlen("<br>") + 1);
|
||||
strcat(markup, "<br>");
|
||||
}
|
||||
else
|
||||
markup = strdup("<br>");
|
||||
}
|
||||
else
|
||||
p = NULL;
|
||||
}
|
||||
edje_object_part_text_set(o, "e.text.message", markup);
|
||||
free(markup);
|
||||
free(newstr);
|
||||
}
|
||||
edje_object_size_min_calc(o, &ow, &oh);
|
||||
error_w = ow;
|
||||
error_h = oh;
|
||||
|
||||
evas_object_move(o, 0, 0);
|
||||
evas_object_resize(o, error_w, error_h);
|
||||
evas_object_show(o);
|
||||
|
||||
x = (man->w - error_w) / 2;
|
||||
y = (man->h - error_h) / 2;
|
||||
con = e_container_current_get(man);
|
||||
if (con)
|
||||
{
|
||||
E_Zone *zone;
|
||||
|
||||
zone = e_container_zone_number_get(con, 0);
|
||||
if (zone)
|
||||
{
|
||||
x = zone->x + ((zone->w - error_w) / 2);
|
||||
y = zone->y + ((zone->h - error_h) / 2);
|
||||
}
|
||||
}
|
||||
ecore_evas_move(ee, x, y);
|
||||
ecore_evas_resize(ee, error_w, error_h);
|
||||
|
||||
for (l = man->containers; l; l = l->next)
|
||||
{
|
||||
E_Container *con;
|
||||
E_Container_Shape *es;
|
||||
|
||||
con = l->data;
|
||||
es = e_container_shape_add(con);
|
||||
e_container_shape_move(es, x, y);
|
||||
e_container_shape_resize(es, error_w, error_h);
|
||||
e_container_shape_show(es);
|
||||
shapelist = evas_list_append(shapelist, es);
|
||||
}
|
||||
ecore_evas_data_set(ee, "shapes", shapelist);
|
||||
|
||||
o = evas_object_rectangle_add(e);
|
||||
evas_object_name_set(o, "allocated");
|
||||
}
|
||||
ecore_evas_show(ee);
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_e_error_message_show_x(char *txt)
|
||||
{
|
||||
e_error_dialog_show_internal(_("Enlightenment: Error!"), txt);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_error_cb_ok_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Event_Mouse_Down *ev;
|
||||
Ecore_Evas *ee;
|
||||
const char *s;
|
||||
|
||||
ev = event_info;
|
||||
if (ev->button != 1) return;
|
||||
ee = data;
|
||||
s = e_path_find(path_images, "button_in.png");
|
||||
evas_object_image_file_set(obj, s, NULL);
|
||||
if (s) evas_stringshare_del(s);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_error_cb_ok_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Event_Mouse_Up *ev;
|
||||
Ecore_Evas *ee;
|
||||
Evas_Object *o;
|
||||
const char *s;
|
||||
|
||||
ev = event_info;
|
||||
if (ev->button != 1) return;
|
||||
ee = data;
|
||||
s = e_path_find(path_images, "button_out.png");
|
||||
evas_object_image_file_set(obj, s, NULL);
|
||||
if (s) evas_stringshare_del(s);
|
||||
o = evas_object_name_find(ecore_evas_get(ee), "allocated");
|
||||
if (o)
|
||||
{
|
||||
evas_object_del(o);
|
||||
ecore_job_add(_e_error_cb_job_ecore_evas_free, ee);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_error_edje_cb_ok_up(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Ecore_Evas *ee;
|
||||
Evas_Object *o;
|
||||
|
||||
ee = data;
|
||||
o = evas_object_name_find(ecore_evas_get(ee), "allocated");
|
||||
if (o)
|
||||
{
|
||||
evas_object_del(o);
|
||||
ecore_job_add(_e_error_cb_job_ecore_evas_free, ee);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_error_cb_job_ecore_evas_free(void *data)
|
||||
{
|
||||
Ecore_Evas *ee;
|
||||
Evas_List *shapelist, *l;
|
||||
|
||||
ee = data;
|
||||
shapelist = ecore_evas_data_get(ee, "shapes");
|
||||
for (l = shapelist; l; l = l->next) e_object_del(E_OBJECT(l->data));
|
||||
evas_list_free(shapelist);
|
||||
|
||||
e_canvas_del(ee);
|
||||
ecore_evas_free(ee);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
#ifdef E_TYPEDEFS
|
||||
|
||||
#define print0(x, args...) x ,print1(## args)
|
||||
//#define print0(x, args...) x ,print1(## args)
|
||||
#define e_error_message_show(args...) \
|
||||
{ \
|
||||
char __tmpbuf[4096]; \
|
||||
|
@ -12,23 +12,11 @@
|
|||
e_error_message_show_internal(__tmpbuf); \
|
||||
}
|
||||
|
||||
#define e_error_dialog_show(title, args...) \
|
||||
{ \
|
||||
char __tmpbuf[4096]; \
|
||||
\
|
||||
snprintf(__tmpbuf, sizeof(__tmpbuf), ##args); \
|
||||
e_error_dialog_show_internal(title, __tmpbuf); \
|
||||
}
|
||||
|
||||
#else
|
||||
#ifndef E_ERROR_H
|
||||
#define E_ERROR_H
|
||||
|
||||
EAPI void e_error_message_show_internal(char *txt);
|
||||
EAPI void e_error_dialog_show_internal(char *title, char *txt);
|
||||
|
||||
EAPI void e_error_gui_set(int on);
|
||||
EAPI void e_error_message_manager_show(E_Manager *man, char *title, char *txt);
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,280 +0,0 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
/* e_fileman.c
|
||||
* ===========
|
||||
*
|
||||
* fileman is the FILE MANager for e.
|
||||
* its composed of several entities:
|
||||
* (check each .c for more reference)
|
||||
*
|
||||
* +-------------+-+
|
||||
* | x x x x |s|
|
||||
* | | |
|
||||
* | x x x x | |
|
||||
* | o| |
|
||||
* | x x x x | |
|
||||
* +-------------+-+
|
||||
* l-s-----------i-i
|
||||
*
|
||||
*
|
||||
* graphically:
|
||||
* o = icon_canvas
|
||||
* x = icon
|
||||
* s = scrollframe
|
||||
*
|
||||
* internally:
|
||||
* a fileman has a fileman_smart.
|
||||
*
|
||||
* fileman_smart
|
||||
* =============
|
||||
* has a list of fileman_icon of that directory (files).
|
||||
* is created above an icon_canvas
|
||||
* has a list of fileman_file of that directory?
|
||||
* has a list of icons
|
||||
*
|
||||
* fileman_icon
|
||||
* ============
|
||||
* a fileman_icon has a fileman_file associated to it.
|
||||
*
|
||||
* fileman_file
|
||||
* ============
|
||||
* a fileman_file has a fileman_mime_entry
|
||||
*
|
||||
* fileman_mime
|
||||
* ============
|
||||
* a fileman_mime_entry has a list of fileman_mime_actions
|
||||
*
|
||||
*/
|
||||
|
||||
#include "e.h"
|
||||
|
||||
/****
|
||||
* TODO:
|
||||
* - reset scrollbar positions on dir changes
|
||||
* - dont allow for menus on ".."
|
||||
* - xdnd
|
||||
* - proper mime system
|
||||
* - create x, y, w, h in canvas struct and make them auto update
|
||||
****/
|
||||
|
||||
#ifdef EFM_DEBUG
|
||||
# define D(x) do {printf(__FILE__ ":%d: ", __LINE__); printf x; fflush(stdout);} while (0)
|
||||
#else
|
||||
# define D(x) ((void) 0)
|
||||
#endif
|
||||
|
||||
static void _e_fileman_resize_cb(E_Win *win);
|
||||
static void _e_fileman_delete_cb(E_Win *win);
|
||||
static void _e_fileman_selector_cb(Evas_Object *object, char *file, void *data);
|
||||
static void _e_fileman_free(E_Fileman *fileman);
|
||||
static void _e_fileman_scroll_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
||||
static void _e_fileman_scroll_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
|
||||
static void _e_fileman_scroll_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
|
||||
static void _e_fileman_scroll_child_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
|
||||
static int _e_fileman_reconfigure_cb(void *data, int type, void *event);
|
||||
|
||||
EAPI E_Fileman *
|
||||
e_fileman_new(E_Container *con)
|
||||
{
|
||||
char dir[PATH_MAX];
|
||||
|
||||
if (!getcwd(dir, sizeof(dir)))
|
||||
return NULL;
|
||||
|
||||
return e_fileman_new_to_dir(con, dir);
|
||||
}
|
||||
|
||||
EAPI E_Fileman *
|
||||
e_fileman_new_to_dir(E_Container *con, char *path)
|
||||
{
|
||||
E_Fileman *fileman;
|
||||
E_Manager *man;
|
||||
char dir[PATH_MAX];
|
||||
|
||||
if (!con)
|
||||
{
|
||||
man = e_manager_current_get();
|
||||
if (!man) return NULL;
|
||||
con = e_container_current_get(man);
|
||||
if (!con) con = e_container_number_get(man, 0);
|
||||
if (!con) return NULL;
|
||||
}
|
||||
|
||||
snprintf(dir, PATH_MAX, "%s", path);
|
||||
|
||||
if(!ecore_file_is_dir(dir))
|
||||
if (!getcwd(dir, sizeof(dir)))
|
||||
return NULL;
|
||||
|
||||
fileman = E_OBJECT_ALLOC(E_Fileman, E_FILEMAN_TYPE, _e_fileman_free);
|
||||
if (!fileman) return NULL;
|
||||
|
||||
fileman->con = con;
|
||||
e_object_ref(E_OBJECT(fileman->con));
|
||||
fileman->win = e_win_new(con);
|
||||
|
||||
if (!fileman->win)
|
||||
{
|
||||
free(fileman);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fileman->xpos = 0;
|
||||
fileman->ypos = 0;
|
||||
|
||||
e_win_delete_callback_set(fileman->win, _e_fileman_delete_cb);
|
||||
fileman->win->data = fileman;
|
||||
|
||||
fileman->evas = e_win_evas_get(fileman->win);
|
||||
|
||||
e_win_name_class_set(fileman->win, "Efm ", "_fileman");
|
||||
e_win_title_set(fileman->win, dir);
|
||||
|
||||
evas_event_freeze(fileman->evas);
|
||||
fileman->smart = e_fm_add(fileman->evas);
|
||||
e_fm_e_win_set(fileman->smart, fileman->win);
|
||||
|
||||
fileman->main = e_scrollframe_add(fileman->evas);
|
||||
e_scrollframe_custom_theme_set(fileman->main, "base/themes/fileman",
|
||||
"e/fileman/main");
|
||||
e_scrollframe_extern_pan_set(fileman->main, fileman->smart,
|
||||
_e_fileman_scroll_set,
|
||||
_e_fileman_scroll_get,
|
||||
_e_fileman_scroll_max_get,
|
||||
_e_fileman_scroll_child_size_get);
|
||||
|
||||
e_win_resize_callback_set(fileman->win, _e_fileman_resize_cb);
|
||||
e_win_resize(fileman->win, 570, 355);
|
||||
|
||||
e_fm_dir_set(fileman->smart, dir);
|
||||
|
||||
ecore_x_dnd_aware_set(fileman->win->evas_win, 1);
|
||||
|
||||
evas_event_thaw(fileman->evas);
|
||||
|
||||
evas_object_focus_set(fileman->main, 0);
|
||||
evas_object_focus_set(fileman->smart, 1);
|
||||
evas_object_propagate_events_set(fileman->smart, 0);
|
||||
|
||||
fileman->event_handlers = evas_list_append(fileman->event_handlers,
|
||||
ecore_event_handler_add(E_EVENT_FM_RECONFIGURE,
|
||||
_e_fileman_reconfigure_cb,
|
||||
fileman));
|
||||
|
||||
|
||||
D(("e_fileman_new: ok\n"));
|
||||
|
||||
return fileman;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_e_fileman_scroll_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
||||
{
|
||||
e_fm_scroll_set(obj, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fileman_scroll_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
|
||||
{
|
||||
e_fm_scroll_get(obj, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fileman_scroll_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
|
||||
{
|
||||
e_fm_scroll_max_get(obj, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fileman_scroll_child_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
|
||||
{
|
||||
e_fm_geometry_virtual_get(obj, x, y);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fileman_selector_enable(E_Fileman *fileman, void (*func)(E_Fileman *fileman, char *file, void *data), void *data)
|
||||
{
|
||||
fileman->selector.func = func;
|
||||
fileman->selector.data = data;
|
||||
e_fm_selector_enable(fileman->smart, _e_fileman_selector_cb, NULL, fileman);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fileman_show(E_Fileman *fileman)
|
||||
{
|
||||
if (!fileman) return;
|
||||
|
||||
D(("e_fileman_show: (%p)\n", fileman));
|
||||
e_win_show(fileman->win);
|
||||
evas_object_show(fileman->main);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fileman_hide(E_Fileman *fileman)
|
||||
{
|
||||
if (!fileman) return;
|
||||
|
||||
D(("e_fileman_hide: (%p)\n", fileman));
|
||||
e_win_hide(fileman->win);
|
||||
evas_object_hide(fileman->main);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fileman_free(E_Fileman *fileman)
|
||||
{
|
||||
D(("e_fileman_free: (%p)\n", fileman));
|
||||
while (fileman->event_handlers)
|
||||
{
|
||||
ecore_event_handler_del(fileman->event_handlers->data);
|
||||
fileman->event_handlers = evas_list_remove_list(fileman->event_handlers, fileman->event_handlers);
|
||||
}
|
||||
|
||||
evas_object_del(fileman->smart);
|
||||
evas_object_del(fileman->main);
|
||||
e_object_del(E_OBJECT(fileman->win));
|
||||
free(fileman);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fileman_resize_cb(E_Win *win)
|
||||
{
|
||||
E_Fileman *fileman;
|
||||
|
||||
fileman = win->data;
|
||||
evas_object_resize(fileman->main, win->w, win->h);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fileman_delete_cb(E_Win *win)
|
||||
{
|
||||
E_Fileman *fileman;
|
||||
|
||||
fileman = win->data;
|
||||
D(("e_fileman_delete_cb: (%p)\n", fileman));
|
||||
e_object_del(E_OBJECT(fileman));
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fileman_selector_cb(Evas_Object *object, char *file, void *data)
|
||||
{
|
||||
E_Fileman *fileman;
|
||||
|
||||
fileman = data;
|
||||
fileman->selector.func(fileman, file, fileman->selector.data);
|
||||
//e_object_del(E_OBJECT(fileman));
|
||||
}
|
||||
|
||||
static int
|
||||
_e_fileman_reconfigure_cb(void *data, int type, void *event)
|
||||
{
|
||||
E_Event_Fm_Reconfigure *ev;
|
||||
E_Fileman *fileman;
|
||||
|
||||
fileman = data;
|
||||
ev = event;
|
||||
|
||||
e_scrollframe_child_region_show(fileman->main, ev->x, ev->y, ev->w, ev->h);
|
||||
return 1;
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef struct _E_Fileman E_Fileman;
|
||||
|
||||
#else
|
||||
#ifndef E_FILEMAN_H
|
||||
#define E_FILEMAN_H
|
||||
|
||||
#define E_FILEMAN_TYPE 0xE0b01016
|
||||
|
||||
struct _E_Fileman
|
||||
{
|
||||
E_Object e_obj_inherit;
|
||||
|
||||
E_Container *con;
|
||||
E_Win *win;
|
||||
|
||||
Evas *evas;
|
||||
Evas_Object *main;
|
||||
Evas_Object *vscrollbar;
|
||||
|
||||
Evas_Object *smart;
|
||||
|
||||
double xpos;
|
||||
double ypos;
|
||||
|
||||
int swallowed;
|
||||
|
||||
Evas_List *event_handlers;
|
||||
|
||||
struct {
|
||||
void (*func)(E_Fileman *fileman, char *file, void *data);
|
||||
void *data;
|
||||
} selector;
|
||||
};
|
||||
|
||||
EAPI E_Fileman *e_fileman_new(E_Container *con);
|
||||
EAPI E_Fileman *e_fileman_new_to_dir(E_Container *con, char *path);
|
||||
EAPI void e_fileman_show(E_Fileman *fileman);
|
||||
EAPI void e_fileman_hide(E_Fileman *fileman);
|
||||
EAPI void e_fileman_selector_enable(E_Fileman *fileman, void (*func)(E_Fileman *fileman, char *file, void *data), void *data);
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -1,390 +0,0 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#include "e.h"
|
||||
|
||||
#ifdef EFM_DEBUG
|
||||
# define D(x) do {printf(__FILE__ ":%d: ", __LINE__); printf x; fflush(stdout);} while (0)
|
||||
#else
|
||||
# define D(x) ((void) 0)
|
||||
#endif
|
||||
|
||||
/* local subsystem functions */
|
||||
static void _e_fm_file_free(E_Fm_File *file);
|
||||
|
||||
/* TODO Make init and shutdown func that populates the assoc */
|
||||
static E_Config_DD *assoc_app_edd = NULL;
|
||||
static Evas_List *assoc_apps = NULL;
|
||||
|
||||
/* externally accessible functions */
|
||||
EAPI E_Fm_File *
|
||||
e_fm_file_new(const char *filename)
|
||||
{
|
||||
char *ext;
|
||||
E_Fm_File *file;
|
||||
struct stat st;
|
||||
|
||||
if (stat(filename, &st) == -1) return NULL;
|
||||
/* FIXME: stat above will fail if the file is a BROKEN SYMLINK - maybe we
|
||||
* should not fail, but do an lstat here and see if it is a symlink (or
|
||||
* just a race condition where the file was deleted as we scan), and
|
||||
* if so mark it as a broken synlink. we should do an lstat ANYWAY
|
||||
* so we know if a file is a symlink or not regardless what it points
|
||||
* to.
|
||||
*/
|
||||
file = E_OBJECT_ALLOC(E_Fm_File, E_FM_FILE_TYPE, _e_fm_file_free);
|
||||
if (!file) return NULL;
|
||||
file->path = strdup(filename);
|
||||
if (!file->path) goto error;
|
||||
file->name = strdup(ecore_file_get_file((char *)filename));
|
||||
if (!file->name) goto error;
|
||||
/* Get attributes */
|
||||
file->device = st.st_dev;
|
||||
file->inode = st.st_ino;
|
||||
file->mode = st.st_mode;
|
||||
file->nlink = st.st_nlink;
|
||||
file->owner = st.st_uid;
|
||||
file->group = st.st_gid;
|
||||
file->rdev = st.st_rdev;
|
||||
file->size = st.st_size;
|
||||
file->atime = st.st_atime;
|
||||
file->mtime = st.st_mtime;
|
||||
file->ctime = st.st_ctime;
|
||||
|
||||
if (S_ISDIR(file->mode))
|
||||
file->type |= E_FM_FILE_TYPE_DIRECTORY;
|
||||
else if (S_ISREG(file->mode))
|
||||
file->type = E_FM_FILE_TYPE_FILE;
|
||||
else if (S_ISLNK(file->mode))
|
||||
file->type = E_FM_FILE_TYPE_SYMLINK;
|
||||
else
|
||||
file->type = E_FM_FILE_TYPE_UNKNOWN;
|
||||
|
||||
if (file->name[0] == '.')
|
||||
file->type |= E_FM_FILE_TYPE_HIDDEN;
|
||||
|
||||
|
||||
e_fm_mime_set(file);
|
||||
D(("e_fm_file_new: %s\n", filename));
|
||||
return file;
|
||||
|
||||
error:
|
||||
if (file->path) free(file->path);
|
||||
if (file->name) free(file->name);
|
||||
free(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_rename(E_Fm_File *file, const char *name)
|
||||
{
|
||||
char path[PATH_MAX], *dir;
|
||||
|
||||
if ((!name) || (!name[0])) return 0;
|
||||
|
||||
dir = ecore_file_get_dir(file->path);
|
||||
if (!dir) return 0;
|
||||
snprintf(path, sizeof(path), "%s/%s", dir, name);
|
||||
|
||||
if (ecore_file_mv(file->path, path))
|
||||
{
|
||||
free(file->path);
|
||||
file->path = strdup(path);
|
||||
free(file->name);
|
||||
file->name = strdup(name);
|
||||
D(("e_fm_file_rename: ok (%p) (%s)\n", file, name));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
D(("e_fm_file_rename: fail (%p) (%s)\n", file, name));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_delete(E_Fm_File *file)
|
||||
{
|
||||
if (ecore_file_recursive_rm(file->path))
|
||||
{
|
||||
free(file->path);
|
||||
file->path = NULL;
|
||||
free(file->name);
|
||||
file->name = NULL;
|
||||
D(("e_fm_file_delete: ok (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
D(("e_fm_file_delete: fail (%p) (%s)\n", file, file->name));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_copy(E_Fm_File *file, const char *name)
|
||||
{
|
||||
if ((!name) || (!name[0])) return 0;
|
||||
|
||||
if (ecore_file_cp(file->path, name))
|
||||
{
|
||||
free(file->path);
|
||||
file->path = strdup(name);
|
||||
free(file->name);
|
||||
file->name = strdup(ecore_file_get_file(name));
|
||||
D(("e_fm_file_copy: ok (%p) (%s)\n", file, name));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
D(("e_fm_file_copy: fail (%p) (%s)\n", file, name));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
e_fm_file_is_regular(E_Fm_File *file) /* TODO: find better name */
|
||||
{
|
||||
return ((file->type == E_FM_FILE_TYPE_FILE)
|
||||
|| (file->type == E_FM_FILE_TYPE_SYMLINK));
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_is_image(E_Fm_File *file)
|
||||
{
|
||||
/* We need to check if it is a filetype supported by evas.
|
||||
* If it isn't supported by evas, we can't show it in the
|
||||
* canvas.
|
||||
*/
|
||||
|
||||
D(("e_fm_file_is_image: (%p)\n", file));
|
||||
return e_fm_file_is_regular(file)
|
||||
&&(e_fm_file_has_mime(file,"jpg")
|
||||
|| e_fm_file_has_mime(file,"png"));
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_has_mime(E_Fm_File *file, char* mime)
|
||||
{
|
||||
if (!file->mime) return 0;
|
||||
|
||||
D(("e_fm_file_has_mime: (%p) : %s\n", file,file->mime->name));
|
||||
return (!strcasecmp(file->mime->name, mime));
|
||||
}
|
||||
|
||||
/* this is pointless for the new model */
|
||||
#if 0
|
||||
|
||||
EAPI int
|
||||
e_fm_file_can_preview(E_Fm_File *file)
|
||||
{
|
||||
int i;
|
||||
|
||||
D(("e_fm_file_can_preview: (%s) (%p)\n", file->name, file));
|
||||
for (i = 0; file->preview_funcs[i]; i++)
|
||||
{
|
||||
E_Fm_File_Preview_Function func;
|
||||
|
||||
func = file->preview_funcs[i];
|
||||
if (func(file))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
EAPI int
|
||||
e_fm_file_is_etheme(E_Fm_File *file)
|
||||
{
|
||||
int val;
|
||||
Evas_List *groups, *l;
|
||||
|
||||
if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".edj"))
|
||||
return 0;
|
||||
|
||||
val = 0;
|
||||
groups = edje_file_collection_list(file->path);
|
||||
if (!groups)
|
||||
return 0;
|
||||
|
||||
for (l = groups; l; l = l->next)
|
||||
{
|
||||
if (!strcmp(l->data, "e/widgets/border/default/border"))
|
||||
{
|
||||
val = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
edje_file_collection_list_free(groups);
|
||||
return val;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_is_ebg(E_Fm_File *file)
|
||||
{
|
||||
int val;
|
||||
Evas_List *groups, *l;
|
||||
|
||||
if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".edj"))
|
||||
return 0;
|
||||
|
||||
val = 0;
|
||||
groups = edje_file_collection_list(file->path);
|
||||
if (!groups)
|
||||
return 0;
|
||||
|
||||
for (l = groups; l; l = l->next)
|
||||
{
|
||||
if (!strcmp(l->data, "e/desktop/background"))
|
||||
{
|
||||
val = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
edje_file_collection_list_free(groups);
|
||||
return val;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_is_eap(E_Fm_File *file)
|
||||
{
|
||||
|
||||
E_App *app;
|
||||
|
||||
if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".eap"))
|
||||
return 0;
|
||||
|
||||
app = e_app_new(file->path, 0);
|
||||
if (!app)
|
||||
{
|
||||
e_object_unref(E_OBJECT(app));
|
||||
return 0;
|
||||
}
|
||||
e_object_unref(E_OBJECT(app));
|
||||
return 1;
|
||||
}
|
||||
EAPI int
|
||||
e_fm_file_can_exec(E_Fm_File *file)
|
||||
{
|
||||
if (e_fm_file_has_mime(file,".eap"))
|
||||
{
|
||||
D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ecore_file_can_exec(file->path))
|
||||
{
|
||||
D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
D(("e_fm_file_can_exec: false (%p) (%s)\n", file, file->name));
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_exec(E_Fm_File *file)
|
||||
{
|
||||
Ecore_Exe *exe;
|
||||
|
||||
/* FIXME: use the e app execution mechanisms where possible so we can
|
||||
* collect error output
|
||||
*/
|
||||
if(e_fm_file_has_mime(file,".eap"))
|
||||
{
|
||||
E_App *e_app;
|
||||
Ecore_Exe *exe;
|
||||
|
||||
e_app = e_app_new(file->path, 0);
|
||||
|
||||
if (!e_app) return 0;
|
||||
|
||||
exe = ecore_exe_run(e_app->exe, NULL);
|
||||
if (exe) ecore_exe_free(exe);
|
||||
e_object_unref(E_OBJECT(e_app));
|
||||
D(("e_fm_file_exec: eap (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
exe = ecore_exe_run(file->path, NULL);
|
||||
if (!exe)
|
||||
{
|
||||
e_error_dialog_show(_("Run Error"),
|
||||
_("Enlightenment was unable to fork a child process:\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"\n"),
|
||||
file->path);
|
||||
D(("e_fm_file_exec: fail (%p) (%s)\n", file, file->name));
|
||||
return 0;
|
||||
}
|
||||
/* E/app is the correct tag if the data is en E_App!
|
||||
ecore_exe_tag_set(exe, "E/app");
|
||||
*/
|
||||
D(("e_fm_file_exec: ok (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_assoc_set(E_Fm_File *file, const char *assoc)
|
||||
{
|
||||
/* TODO */
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_assoc_exec(E_Fm_File *file)
|
||||
{
|
||||
char app[PATH_MAX * 2];
|
||||
Evas_List *l;
|
||||
E_Fm_Assoc_App *assoc;
|
||||
Ecore_Exe *exe;
|
||||
|
||||
if (!assoc_apps) return 0;
|
||||
|
||||
/* FIXME: use the e app execution mechanisms where possible so we can
|
||||
* collect error output
|
||||
*/
|
||||
for (l = assoc_apps; l; l = l->next)
|
||||
{
|
||||
assoc = l->data;
|
||||
if (e_fm_file_has_mime(file,assoc->mime))
|
||||
break;
|
||||
assoc = NULL;
|
||||
}
|
||||
|
||||
if (!assoc) return 0;
|
||||
|
||||
snprintf(app, PATH_MAX * 2, "%s %s", assoc->app, file->path);
|
||||
exe = ecore_exe_run(app, NULL);
|
||||
|
||||
if (!exe)
|
||||
{
|
||||
e_error_dialog_show(_("Run Error"),
|
||||
_("Enlightenment was unable to fork a child process:\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"\n"),
|
||||
app);
|
||||
D(("e_fm_assoc_exec: fail (%s)\n", app));
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* ecore_exe_tag_set(exe, "E/app");
|
||||
*/
|
||||
D(("e_fm_assoc_exec: ok (%s)\n", app));
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_e_fm_file_free(E_Fm_File *file)
|
||||
{
|
||||
D(("_e_fm_file_free: (%p) (%s)\n", file, file->name));
|
||||
if (file->path) free(file->path);
|
||||
if (file->name) free(file->name);
|
||||
free(file);
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef struct _E_Fm_File E_Fm_File;
|
||||
typedef struct _E_Fm_File_Attributes E_Fm_File_Attributes;
|
||||
|
||||
#define E_FM_FILE_TYPE_FILE (1 << 8)
|
||||
#define E_FM_FILE_TYPE_DIRECTORY (1 << 9)
|
||||
#define E_FM_FILE_TYPE_SYMLINK (1 << 10)
|
||||
#define E_FM_FILE_TYPE_UNKNOWN (1 << 11)
|
||||
#define E_FM_FILE_TYPE_HIDDEN (1 << 12)
|
||||
|
||||
#define E_FM_FILE_TYPE_NORMAL E_FM_FILE_TYPE_FILE|E_FM_FILE_TYPE_DIRECTORY|E_FM_FILE_TYPE_SYMLINK
|
||||
#define E_FM_FILE_TYPE_ALL E_FM_FILE_TYPE_NORMAL|E_FM_FILE_TYPE_HIDDEN
|
||||
|
||||
#else
|
||||
#ifndef E_FILEMAN_FILE_H
|
||||
#define E_FILEMAN_FILE_H
|
||||
|
||||
#define E_FM_FILE_TYPE 0xE0b01018
|
||||
|
||||
struct _E_Fm_File
|
||||
{
|
||||
E_Object e_obj_inherit;
|
||||
|
||||
int type;
|
||||
|
||||
Evas *evas; /* what is it used for? the icon theme? use the mime instead */
|
||||
Evas_Object *icon_object;
|
||||
/* Do we need those?
|
||||
* Evas_Object *image_object;
|
||||
* Evas_Object *event_object;
|
||||
*/
|
||||
|
||||
char *path; /* full name with path */
|
||||
char *name; /* file name without parent directories */
|
||||
E_Fm_Mime_Entry *mime;
|
||||
|
||||
dev_t device; /* ID of device containing file */
|
||||
ino_t inode; /* inode number */
|
||||
mode_t mode; /* protection */
|
||||
nlink_t nlink; /* number of hard links */
|
||||
uid_t owner; /* user ID of owner */
|
||||
gid_t group; /* group ID of owner */
|
||||
dev_t rdev; /* device ID (if special file) */
|
||||
off_t size; /* total size, in bytes */
|
||||
time_t atime; /* time of last access */
|
||||
time_t mtime; /* time of last modification */
|
||||
time_t ctime; /* time of last status change */
|
||||
|
||||
};
|
||||
|
||||
EAPI E_Fm_File *e_fm_file_new (const char *filename);
|
||||
EAPI int e_fm_file_rename (E_Fm_File *file, const char *name);
|
||||
EAPI int e_fm_file_delete (E_Fm_File *file);
|
||||
EAPI int e_fm_file_copy (E_Fm_File *file, const char *name);
|
||||
EAPI int e_fm_file_can_preview (E_Fm_File *file);
|
||||
EAPI int e_fm_file_is_image (E_Fm_File *file);
|
||||
EAPI int e_fm_file_is_etheme (E_Fm_File *file);
|
||||
EAPI int e_fm_file_is_ebg (E_Fm_File *file);
|
||||
EAPI int e_fm_file_is_eap (E_Fm_File *file);
|
||||
EAPI int e_fm_file_can_exec (E_Fm_File *file);
|
||||
EAPI int e_fm_file_exec (E_Fm_File *file);
|
||||
EAPI int e_fm_file_assoc_set (E_Fm_File *file, const char *assoc);
|
||||
EAPI int e_fm_file_assoc_exec (E_Fm_File *file);
|
||||
EAPI int e_fm_file_has_mime (E_Fm_File *file, char* mime);
|
||||
EAPI int e_fm_file_is_regular (E_Fm_File *file);
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,589 +0,0 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#include "e.h"
|
||||
|
||||
typedef struct _E_Smart_Data E_Smart_Data;
|
||||
|
||||
struct _E_Smart_Data
|
||||
{
|
||||
Evas_Coord x, y, w, h, iw, ih;
|
||||
|
||||
Evas *evas;
|
||||
Evas_Object *obj;
|
||||
|
||||
char *saved_title;
|
||||
|
||||
Evas_Object *event_object;
|
||||
Evas_Object *icon_object;
|
||||
Evas_Object *image_object;
|
||||
Evas_Object *entry_object;
|
||||
Evas_Object *thumb_object;
|
||||
|
||||
E_Fm_File *file;
|
||||
|
||||
unsigned char visible : 1;
|
||||
|
||||
int type;
|
||||
|
||||
E_Fm_Icon_Metadata *meta;
|
||||
};
|
||||
|
||||
/* local subsystem functions */
|
||||
static void _e_fm_icon_smart_add (Evas_Object *obj);
|
||||
static void _e_fm_icon_smart_del (Evas_Object *obj);
|
||||
static void _e_fm_icon_smart_move (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
||||
static void _e_fm_icon_smart_resize (Evas_Object *obj, Evas_Coord w, Evas_Coord h);
|
||||
static void _e_fm_icon_smart_show (Evas_Object *obj);
|
||||
static void _e_fm_icon_smart_hide (Evas_Object *obj);
|
||||
static void _e_fm_icon_smart_clip_set (Evas_Object *obj, Evas_Object *clip);
|
||||
static void _e_fm_icon_smart_clip_unset (Evas_Object *obj);
|
||||
|
||||
/* Create icons */
|
||||
static void _e_fm_icon_icon_mime_get(E_Smart_Data *sd);
|
||||
static void _e_fm_icon_thumb_generate_cb(Evas_Object *obj, void *data);
|
||||
static void _e_fm_icon_type_set(E_Smart_Data *sd);
|
||||
static void _e_fm_icon_meta_fill(E_Fm_Icon_Metadata *m, E_Smart_Data *sd);
|
||||
|
||||
/* local subsystem globals */
|
||||
static Evas_Smart *e_smart = NULL;
|
||||
|
||||
static Evas_List *thumb_files = NULL;
|
||||
|
||||
static Evas_List *event_handlers = NULL;
|
||||
|
||||
/*
|
||||
static Eet_Data_Descriptor *_e_fm_icon_meta_edd = NULL;
|
||||
*/
|
||||
|
||||
/* externally accessible functions */
|
||||
EAPI int
|
||||
e_fm_icon_init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_icon_shutdown(void)
|
||||
{
|
||||
while (event_handlers)
|
||||
{
|
||||
ecore_event_handler_del(event_handlers->data);
|
||||
event_handlers = evas_list_remove_list(event_handlers, event_handlers);
|
||||
}
|
||||
evas_list_free(thumb_files);
|
||||
evas_smart_free(e_smart);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
e_fm_icon_add(Evas *evas)
|
||||
{
|
||||
Evas_Object *e_fm_icon_smart;
|
||||
|
||||
if (!e_smart)
|
||||
{
|
||||
e_smart = evas_smart_new("e_fm_icon_smart",
|
||||
_e_fm_icon_smart_add,
|
||||
_e_fm_icon_smart_del,
|
||||
NULL, NULL, NULL, NULL, NULL,
|
||||
_e_fm_icon_smart_move,
|
||||
_e_fm_icon_smart_resize,
|
||||
_e_fm_icon_smart_show,
|
||||
_e_fm_icon_smart_hide,
|
||||
NULL,
|
||||
_e_fm_icon_smart_clip_set,
|
||||
_e_fm_icon_smart_clip_unset,
|
||||
NULL);
|
||||
}
|
||||
|
||||
e_fm_icon_smart = evas_object_smart_add(evas, e_smart);
|
||||
|
||||
return e_fm_icon_smart;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm_icon_type_set(Evas_Object *obj, int type)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
|
||||
if(sd->type == type)
|
||||
return;
|
||||
|
||||
sd->type = type;
|
||||
_e_fm_icon_type_set(sd);
|
||||
}
|
||||
|
||||
EAPI E_Fm_File *
|
||||
e_fm_icon_file_get(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return NULL;
|
||||
|
||||
return sd->file;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm_icon_file_set(Evas_Object *obj, E_Fm_File *file)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
Evas_Coord icon_w, icon_h;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if (!sd->file) e_object_ref(E_OBJECT(file));
|
||||
sd->file = file;
|
||||
file->icon_object = obj;
|
||||
|
||||
if (sd->file->mime->thumbnail)
|
||||
{
|
||||
/* FIXME: should use smart callback to change icon when thumb done */
|
||||
sd->thumb_object = e_thumb_icon_add(sd->evas);
|
||||
e_thumb_icon_file_set(sd->thumb_object, sd->file->path, NULL);
|
||||
e_thumb_icon_size_set(sd->thumb_object, 64, 64);
|
||||
e_thumb_icon_begin(sd->thumb_object);
|
||||
evas_object_show(sd->thumb_object);
|
||||
sd->image_object = edje_object_add(sd->evas);
|
||||
e_theme_edje_object_set(sd->image_object, "base/theme/fileman",
|
||||
"e/fileman/icon_thumb");
|
||||
edje_extern_object_min_size_set(sd->thumb_object, sd->iw, sd->ih);
|
||||
edje_extern_object_max_size_set(sd->thumb_object, sd->iw, sd->ih);
|
||||
edje_object_part_swallow(sd->image_object, "icon_swallow",
|
||||
sd->thumb_object);
|
||||
edje_object_size_min_calc(sd->image_object, &icon_w, &icon_h);
|
||||
sd->iw = icon_w;
|
||||
sd->ih = icon_h;
|
||||
edje_extern_object_min_size_set(sd->image_object, icon_w, icon_h);
|
||||
edje_extern_object_max_size_set(sd->image_object, icon_w, icon_h);
|
||||
edje_object_part_swallow(sd->icon_object, "icon_swallow",
|
||||
sd->image_object);
|
||||
}
|
||||
else
|
||||
{
|
||||
_e_fm_icon_icon_mime_get(sd);
|
||||
}
|
||||
_e_fm_icon_type_set(sd);
|
||||
edje_object_size_min_calc(sd->icon_object, &icon_w, &icon_h);
|
||||
evas_object_resize(sd->obj, 0, 0); // because it still thinks its the same size
|
||||
// 96 is an aritary width - should be user configurable
|
||||
evas_object_resize(sd->obj, 80, icon_h);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm_icon_appear_cb(Evas_Object *obj, void *data)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
evas_object_show(obj);
|
||||
return;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if(sd->visible) return;
|
||||
sd->visible = 1;
|
||||
|
||||
sd->icon_object = edje_object_add(sd->evas);
|
||||
evas_object_smart_member_add(sd->icon_object, obj);
|
||||
|
||||
sd->event_object = evas_object_rectangle_add(sd->evas);
|
||||
evas_object_color_set(sd->event_object, 0, 0, 0, 0);
|
||||
evas_object_smart_member_add(sd->event_object, obj);
|
||||
evas_object_smart_data_set(obj, sd);
|
||||
|
||||
e_fm_icon_file_set(obj, sd->file);
|
||||
evas_object_show(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm_icon_disappear_cb(Evas_Object *obj, void *data)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
evas_object_hide(obj);
|
||||
return;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if(!sd->visible) return;
|
||||
sd->visible = 0;
|
||||
|
||||
if (sd->event_object) evas_object_del(sd->event_object);
|
||||
if (sd->icon_object) evas_object_del(sd->icon_object);
|
||||
if (sd->image_object) evas_object_del(sd->image_object);
|
||||
if (sd->thumb_object) evas_object_del(sd->thumb_object);
|
||||
E_FREE(sd->saved_title);
|
||||
}
|
||||
|
||||
EAPI char *
|
||||
e_fm_icon_title_get(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return NULL;
|
||||
|
||||
return edje_object_part_text_get(sd->icon_object, "icon_title");
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm_icon_title_set(Evas_Object *obj, const char *title)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
E_FREE(sd->saved_title);
|
||||
sd->saved_title = E_NEW(char, strlen(title) + 1);
|
||||
snprintf(sd->saved_title, strlen(title) + 1, "%s", title);
|
||||
//if (sd->icon_object) edje_object_part_text_set(sd->icon_object, "icon_title", title);
|
||||
if(sd->icon_object)
|
||||
{
|
||||
#if 0
|
||||
Evas_Textblock_Style *e_editable_text_style;
|
||||
Evas_Coord fw, fh, il, ir, it, ib;
|
||||
|
||||
e_editable_text_style = evas_textblock_style_new();
|
||||
evas_textblock_style_set(e_editable_text_style, "DEFAULT='font=Vera font_size=10 style=shadow shadow_color=#ffffff80 align=center color=#000000 wrap=char'");
|
||||
|
||||
evas_object_textblock_style_set(sd->title_object, e_editable_text_style);
|
||||
evas_object_textblock_text_markup_set(sd->title_object, title);
|
||||
|
||||
evas_object_resize(sd->title_object, sd->w, 1);
|
||||
evas_object_textblock_size_formatted_get(sd->title_object, &fw, &fh);
|
||||
evas_object_textblock_style_insets_get(sd->title_object, &il, &ir, &it, &ib);
|
||||
|
||||
sd->h = sd->ih + fh + it + ib;
|
||||
|
||||
evas_object_resize(sd->title_object, sd->w, fh + it + ib);
|
||||
edje_extern_object_min_size_set(sd->title_object, sd->w, fh + it + ib);
|
||||
evas_object_resize(sd->icon_object, sd->w, sd->h);
|
||||
evas_object_resize(sd->obj, sd->w, sd->h);
|
||||
edje_object_part_swallow(sd->icon_object, "icon_title", sd->title_object);
|
||||
#endif
|
||||
edje_object_part_text_set(sd->icon_object, "icon_title", title);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm_icon_edit_entry_set(Evas_Object *obj, Evas_Object *entry)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if (entry)
|
||||
{
|
||||
sd->entry_object = entry;
|
||||
edje_object_part_swallow(sd->icon_object, "icon_title_edit_swallow", sd->entry_object);
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_part_unswallow(sd->icon_object, sd->entry_object);
|
||||
sd->entry_object = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm_icon_signal_emit(Evas_Object *obj, const char *source, const char *emission)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if (sd->icon_object) edje_object_signal_emit(sd->icon_object, source, emission);
|
||||
if (sd->image_object) edje_object_signal_emit(sd->image_object, source, emission);
|
||||
}
|
||||
|
||||
EAPI E_Fm_Icon_Metadata *
|
||||
e_fm_icon_meta_generate(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
E_Fm_Icon_Metadata *m;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return NULL;
|
||||
|
||||
m = calloc(1, sizeof(E_Fm_Icon_Metadata));
|
||||
if (!m) return NULL;
|
||||
_e_fm_icon_meta_fill(m, sd);
|
||||
|
||||
sd->meta = m;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm_icon_meta_free(E_Fm_Icon_Metadata *m)
|
||||
{
|
||||
if (!m) return;
|
||||
E_FREE(m->name);
|
||||
|
||||
free(m);
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_icon_assoc_set(Evas_Object *obj, const char *assoc)
|
||||
{
|
||||
/* TODO
|
||||
* Store the associated exe in a cfg
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_e_fm_icon_smart_add(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = E_NEW(E_Smart_Data, 1);
|
||||
if (!sd) return;
|
||||
|
||||
sd->evas = evas_object_evas_get(obj);
|
||||
sd->obj = obj;
|
||||
sd->saved_title = NULL;
|
||||
sd->type = E_FM_ICON_NORMAL;
|
||||
sd->w = 64;
|
||||
sd->h = 64;
|
||||
sd->iw = 48;
|
||||
sd->ih = 48;
|
||||
sd->file = NULL;
|
||||
sd->meta = NULL;
|
||||
|
||||
sd->icon_object = edje_object_add(sd->evas);
|
||||
evas_object_smart_member_add(sd->icon_object, obj);
|
||||
|
||||
sd->event_object = evas_object_rectangle_add(sd->evas);
|
||||
evas_object_color_set(sd->event_object, 0, 0, 0, 0);
|
||||
evas_object_smart_member_add(sd->event_object, obj);
|
||||
evas_object_smart_data_set(obj, sd);
|
||||
|
||||
sd->visible = 1;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_smart_del(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if (sd->event_object) evas_object_del(sd->event_object);
|
||||
if (sd->icon_object) evas_object_del(sd->icon_object);
|
||||
if (sd->image_object) evas_object_del(sd->image_object);
|
||||
if (sd->thumb_object) evas_object_del(sd->thumb_object);
|
||||
E_FREE(sd->saved_title);
|
||||
if (sd->file) e_object_unref(E_OBJECT(sd->file));
|
||||
free(sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if ((sd->x == x) && (sd->y == y)) return;
|
||||
sd->x = x;
|
||||
sd->y = y;
|
||||
if(sd->event_object)
|
||||
evas_object_move(sd->event_object, x, y);
|
||||
if(sd->icon_object)
|
||||
evas_object_move(sd->icon_object, x, y);
|
||||
if(sd->meta)
|
||||
{
|
||||
//printf("update meta for %s: x=%d y=%d\n", sd->file->name, x, y);
|
||||
sd->meta->x = x;
|
||||
sd->meta->y = y;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if ((sd->w == w) && (sd->h == h)) return;
|
||||
sd->w = w;
|
||||
sd->h = h;
|
||||
if(sd->event_object)
|
||||
evas_object_resize(sd->event_object, sd->w, sd->h);
|
||||
if(sd->icon_object)
|
||||
evas_object_resize(sd->icon_object, sd->w, sd->h);
|
||||
if(sd->meta)
|
||||
{
|
||||
printf("update meta: w=%d h=%d\n", w, h);
|
||||
sd->meta->w = w;
|
||||
sd->meta->h = h;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_smart_show(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if(sd->event_object)
|
||||
evas_object_show(sd->icon_object);
|
||||
if(sd->icon_object)
|
||||
evas_object_show(sd->event_object);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_smart_hide(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if(sd->event_object)
|
||||
evas_object_hide(sd->icon_object);
|
||||
if(sd->icon_object)
|
||||
evas_object_hide(sd->event_object);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
evas_object_clip_set(sd->event_object, clip);
|
||||
evas_object_clip_set(sd->icon_object, clip);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_smart_clip_unset(Evas_Object *obj)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
evas_object_clip_unset(sd->event_object);
|
||||
evas_object_clip_unset(sd->icon_object);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_icon_mime_get(E_Smart_Data *sd)
|
||||
{
|
||||
char part[PATH_MAX];
|
||||
|
||||
sd->image_object = edje_object_add(sd->evas);
|
||||
/* since a mime is set with every creation of an E_Fm_File its existence isnt checked here */
|
||||
|
||||
snprintf(part, PATH_MAX, "e/icons/fileman/%s", (sd->file->mime->name));
|
||||
if (!e_theme_edje_object_set(sd->image_object, "base/theme/fileman", part))
|
||||
e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "e/icons/fileman/file");
|
||||
|
||||
evas_object_show(sd->image_object);
|
||||
edje_extern_object_min_size_set(sd->image_object, sd->iw, sd->ih);
|
||||
edje_extern_object_max_size_set(sd->image_object, sd->iw, sd->ih);
|
||||
edje_object_part_swallow(sd->icon_object, "icon_swallow",
|
||||
sd->image_object);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_type_set(E_Smart_Data *sd)
|
||||
{
|
||||
switch (sd->type)
|
||||
{
|
||||
case E_FM_ICON_NORMAL:
|
||||
e_theme_edje_object_set(sd->icon_object, "base/theme/fileman",
|
||||
"e/fileman/icon_normal");
|
||||
break;
|
||||
|
||||
case E_FM_ICON_LIST:
|
||||
e_theme_edje_object_set(sd->icon_object, "base/theme/fileman",
|
||||
"e/fileman/icon_list");
|
||||
break;
|
||||
|
||||
default:
|
||||
e_theme_edje_object_set(sd->icon_object, "base/theme/fileman",
|
||||
"e/fileman/icon_normal");
|
||||
break;
|
||||
}
|
||||
|
||||
if (sd->image_object)
|
||||
{
|
||||
edje_extern_object_min_size_set(sd->image_object, sd->iw, sd->ih);
|
||||
edje_extern_object_max_size_set(sd->image_object, sd->iw, sd->ih);
|
||||
edje_object_part_swallow(sd->icon_object, "icon_swallow",
|
||||
sd->image_object);
|
||||
evas_object_show(sd->image_object);
|
||||
}
|
||||
|
||||
if (sd->saved_title)
|
||||
{
|
||||
#if 0
|
||||
Evas_Textblock_Style *e_editable_text_style;
|
||||
Evas_Coord fw, fh, il, ir, it, ib;
|
||||
|
||||
e_editable_text_style = evas_textblock_style_new();
|
||||
evas_textblock_style_set(e_editable_text_style, "DEFAULT='font=Vera font_size=10 style=shadow shadow_color=#ffffff80 align=center color=#000000 wrap=char'");
|
||||
|
||||
evas_object_textblock_style_set(sd->title_object, e_editable_text_style);
|
||||
evas_object_textblock_text_markup_set(sd->title_object, sd->saved_title);
|
||||
|
||||
evas_object_resize(sd->title_object, sd->w, 1);
|
||||
evas_object_textblock_size_formatted_get(sd->title_object, &fw, &fh);
|
||||
evas_object_textblock_style_insets_get(sd->title_object, &il, &ir, &it, &ib);
|
||||
|
||||
sd->h = sd->ih + fh + it + ib;
|
||||
|
||||
evas_object_resize(sd->title_object, sd->w, fh + it + ib);
|
||||
edje_extern_object_min_size_set(sd->title_object, sd->w, fh + it + ib);
|
||||
evas_object_resize(sd->icon_object, sd->w, sd->h);
|
||||
evas_object_resize(sd->obj, sd->w, sd->h);
|
||||
edje_object_part_swallow(sd->icon_object, "icon_title", sd->title_object);
|
||||
#endif
|
||||
edje_object_part_text_set(sd->icon_object, "icon_title", sd->saved_title);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
Evas_Textblock_Style *e_editable_text_style;
|
||||
Evas_Coord fw, fh, il, ir, it, ib;
|
||||
|
||||
e_editable_text_style = evas_textblock_style_new();
|
||||
evas_textblock_style_set(e_editable_text_style, "DEFAULT='font=Vera font_size=10 style=shadow shadow_color=#ffffff80 align=center color=#000000 wrap=char'");
|
||||
|
||||
evas_object_textblock_style_set(sd->title_object, e_editable_text_style);
|
||||
evas_object_textblock_text_markup_set(sd->title_object, sd->file->name);
|
||||
|
||||
evas_object_resize(sd->title_object, sd->w, 1);
|
||||
evas_object_textblock_size_formatted_get(sd->title_object, &fw, &fh);
|
||||
evas_object_textblock_style_insets_get(sd->title_object, &il, &ir, &it, &ib);
|
||||
|
||||
sd->h = sd->ih + fh + it + ib;
|
||||
|
||||
evas_object_resize(sd->title_object, sd->w, fh + it + ib);
|
||||
edje_extern_object_min_size_set(sd->title_object, sd->w, fh + it + ib);
|
||||
evas_object_resize(sd->icon_object, sd->w, sd->h);
|
||||
evas_object_resize(sd->obj, sd->w, sd->h);
|
||||
edje_object_part_swallow(sd->icon_object, "icon_title", sd->title_object);
|
||||
#endif
|
||||
edje_object_part_text_set(sd->icon_object, "icon_title", sd->file->name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_meta_fill(E_Fm_Icon_Metadata *m, E_Smart_Data *sd)
|
||||
{
|
||||
m->x = sd->x;
|
||||
m->y = sd->y;
|
||||
m->w = sd->w;
|
||||
m->h = sd->h;
|
||||
m->name = strdup(sd->file->name);
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef enum _E_Fm_Icon_Type E_Fm_Icon_Type;
|
||||
typedef struct _E_Fm_Icon_Metadata E_Fm_Icon_Metadata;
|
||||
|
||||
#else
|
||||
#ifndef E_FILEMAN_FILE_SMART_H
|
||||
#define E_FILEMAN_FILE_SMART_H
|
||||
|
||||
enum E_Fm_Icon_Type
|
||||
{
|
||||
E_FM_ICON_NORMAL,
|
||||
E_FM_ICON_LIST
|
||||
};
|
||||
|
||||
struct _E_Fm_Icon_Metadata
|
||||
{
|
||||
Evas_Coord x, y, w, h; /* geometry */
|
||||
char *name; /* filename */
|
||||
};
|
||||
|
||||
EAPI int e_fm_icon_init(void);
|
||||
EAPI int e_fm_icon_shutdown(void);
|
||||
EAPI Evas_Object *e_fm_icon_add(Evas *evas);
|
||||
EAPI E_Fm_File *e_fm_icon_file_get(Evas_Object *obj);
|
||||
EAPI void e_fm_icon_file_set(Evas_Object *obj, E_Fm_File *file);
|
||||
EAPI void e_fm_icon_appear_cb(Evas_Object *obj, void *data);
|
||||
EAPI void e_fm_icon_disappear_cb(Evas_Object *obj, void *data);
|
||||
EAPI void e_fm_icon_title_set(Evas_Object *obj, const char *title);
|
||||
EAPI void e_fm_icon_type_set(Evas_Object *obj, int type);
|
||||
EAPI void e_fm_icon_edit_entry_set(Evas_Object *obj, Evas_Object *entry);
|
||||
EAPI void e_fm_icon_signal_emit(Evas_Object *obj, const char *source, const char *emission);
|
||||
EAPI E_Fm_Icon_Metadata *e_fm_icon_meta_generate(Evas_Object *obj);
|
||||
EAPI void e_fm_icon_meta_free(E_Fm_Icon_Metadata *m);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,653 +0,0 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
|
||||
/* e_fileman_mime.c
|
||||
* ================
|
||||
* will provide basic function for mime types, mime handlers
|
||||
* and operations with them, also a small app to actually
|
||||
* edit the mime database
|
||||
*
|
||||
*
|
||||
* abstract types
|
||||
* ==============================
|
||||
* the abstract types will be in a hierarchy way, all the leafs will heritate the parents
|
||||
* info (actions: run,open,edit,whatever)
|
||||
*
|
||||
* properties:
|
||||
* mime: each leaf might have a mime type associated to it ? it wouldnt be neccesary for now,
|
||||
* efm will handle only file names, in the future might visulize other file types?
|
||||
*
|
||||
*
|
||||
* file
|
||||
* +---- data
|
||||
* +---- image
|
||||
* +---- jpg
|
||||
* :mime image/jpeg
|
||||
* +---- png
|
||||
* +---- audio
|
||||
* +---- mp3
|
||||
* +---- ogg
|
||||
* +---- wav
|
||||
* +---- directory
|
||||
* +---- special
|
||||
* +---- executable
|
||||
* +---- a.out
|
||||
* +---- java class
|
||||
* +---- scripts
|
||||
*
|
||||
*
|
||||
*
|
||||
* file recognition for above types
|
||||
* ================================
|
||||
* 1. by regex
|
||||
* 2. by suffix
|
||||
* 3. by type (directory,hidden,etc)
|
||||
* 4. properties (fifo,socket,executables,etc)
|
||||
*
|
||||
* icons visuals
|
||||
* =============
|
||||
* 1. by properties (read,write,execute)
|
||||
* 2. user defined (video directory, audo directory)
|
||||
* 3. by file contents (if a dir is full of mp3, might be an audio dir)
|
||||
*
|
||||
*
|
||||
* previews and thumbnails
|
||||
* =======================
|
||||
* a thumbnail can be done for example on images,videos,or any graphical file
|
||||
* but a preview is for example that when you are over an audio file it starts playing
|
||||
*
|
||||
* actions
|
||||
* =======
|
||||
* each mime entry will have a list of possible actions to be taken for it
|
||||
* to define the command to execute there are several tokens like:
|
||||
*
|
||||
* %f => file input
|
||||
* %h => hover file (might be the current directory, other file, whatever)
|
||||
*
|
||||
*
|
||||
* FUTURE
|
||||
* ======
|
||||
* a new approach can be made, but is too expensive for what e17 currently needs.
|
||||
* the mime subsystem can be in fact independent from e_fileman_smart (the function calls
|
||||
* are very simple to change, just pass always an Evas_List of files, and the E_Fm_File hover,
|
||||
* instead of the E_Fileman_Smart). What is complicated is how to pass the data to the internal
|
||||
* actions, and if we should define the internal actions here or in the component that will
|
||||
* use the mime subsytem.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "e.h"
|
||||
|
||||
static E_Fm_Mime_Entry *_e_fm_mime_common(E_Fm_Mime_Entry *e1, E_Fm_Mime_Entry *e2);
|
||||
static char *_e_fm_mime_suffix_get(char *filename);
|
||||
static void _e_fm_mime_action_append(E_Fm_Mime_Entry *entry, char *action_name);
|
||||
static void _e_fm_mime_action_default_set(E_Fm_Mime_Entry *entry, char *action_name);
|
||||
static char *_e_fm_mime_string_tokenizer(Evas_List *files, E_Fm_File *dir, char *istr);
|
||||
/* definitions of the internal actions */
|
||||
static void _e_fm_mime_action_internal_folder_open(E_Fm_Smart_Data *data);
|
||||
static void _e_fm_mime_action_internal_folder_open_other(E_Fm_Smart_Data *data);
|
||||
static void _e_fm_mime_action_internal_copy_to(E_Fm_Smart_Data *data);
|
||||
static void _e_fm_mime_action_internal_move_to(E_Fm_Smart_Data *data);
|
||||
/* definitions of thumbnail functions */
|
||||
Evas_Object * _e_fm_mime_thumbnail_evas(char *path, Evas_Coord w, Evas_Coord h, Evas *evas, Evas_Object **tmp, void (*cb)(Evas_Object *obj, void *data), void *data);
|
||||
|
||||
|
||||
static int init_count = 0;
|
||||
static Evas_List *entries = NULL;
|
||||
static Evas_List *actions = NULL;
|
||||
|
||||
/* returns the saved mime tree or a default one */
|
||||
int
|
||||
e_fm_mime_init(void)
|
||||
{
|
||||
E_Fm_Mime_Entry *root;
|
||||
E_Fm_Mime_Entry *entry;
|
||||
E_Fm_Mime_Entry *l1,*l2;
|
||||
E_Fm_Mime_Action *action;
|
||||
|
||||
if(init_count)
|
||||
return 1;
|
||||
|
||||
/* internal actions */
|
||||
/********************/
|
||||
action = E_NEW(E_Fm_Mime_Action,1);
|
||||
action->name = strdup("_folder_open");
|
||||
action->label = strdup("Open the Folder");
|
||||
action->is_internal = 1;
|
||||
action->internal.function = &_e_fm_mime_action_internal_folder_open;
|
||||
actions = evas_list_append(actions,action);
|
||||
|
||||
action = E_NEW(E_Fm_Mime_Action,1);
|
||||
action->name = strdup("_folder_open_other");
|
||||
action->label = strdup("Open the Folder in other Window");
|
||||
action->is_internal = 1;
|
||||
action->internal.function = &_e_fm_mime_action_internal_folder_open_other;
|
||||
actions = evas_list_append(actions,action);
|
||||
|
||||
action = E_NEW(E_Fm_Mime_Action,1);
|
||||
action->name = strdup("_copy_to");
|
||||
action->label = strdup("Copy to %h");
|
||||
action->relative = 1;
|
||||
action->is_internal = 1;
|
||||
action->internal.function = &_e_fm_mime_action_internal_copy_to;
|
||||
actions = evas_list_append(actions,action);
|
||||
|
||||
action = E_NEW(E_Fm_Mime_Action,1);
|
||||
action->name = strdup("_move_to");
|
||||
action->label = strdup("Move to %h");
|
||||
action->relative = 1;
|
||||
action->is_internal = 1;
|
||||
action->internal.function = &_e_fm_mime_action_internal_move_to;
|
||||
actions = evas_list_append(actions,action);
|
||||
|
||||
/* actions */
|
||||
/***********/
|
||||
action = E_NEW(E_Fm_Mime_Action,1);
|
||||
action->name = strdup("gimp_edit");
|
||||
action->label = strdup("Edit with Gimp");
|
||||
action->cmd = strdup("gimp %f");
|
||||
action->multiple = 1;
|
||||
actions = evas_list_append(actions,action);
|
||||
|
||||
action = E_NEW(E_Fm_Mime_Action,1);
|
||||
action->name = strdup("exhibit_view");
|
||||
action->label = strdup("View with Exhibit");
|
||||
action->cmd = strdup("exhibit %f");
|
||||
action->multiple = 0;
|
||||
actions = evas_list_append(actions,action);
|
||||
|
||||
action = E_NEW(E_Fm_Mime_Action,1);
|
||||
action->name = strdup("xmms_enqueue");
|
||||
action->label = strdup("Add to XMMS Queue");
|
||||
action->cmd = strdup("xmms -e %f");
|
||||
action->multiple = 1;
|
||||
actions = evas_list_append(actions,action);
|
||||
|
||||
action = E_NEW(E_Fm_Mime_Action,1);
|
||||
action->name = strdup("xmms_play");
|
||||
action->label = strdup("Play with XMMS");
|
||||
action->cmd = strdup("xmms %f");
|
||||
action->multiple = 0;
|
||||
actions = evas_list_append(actions,action);
|
||||
|
||||
/* entries */
|
||||
/***********/
|
||||
root = E_NEW(E_Fm_Mime_Entry,1);
|
||||
root->name = strdup("file");
|
||||
root->label = strdup("Unkown File");
|
||||
root->level = 0;
|
||||
entries = evas_list_append(entries,root);
|
||||
_e_fm_mime_action_default_set(root, "_copy_to");
|
||||
_e_fm_mime_action_append(root, "_move_to");
|
||||
/* data */
|
||||
entry = E_NEW(E_Fm_Mime_Entry,1);
|
||||
entry->name = strdup("data");
|
||||
entry->label = strdup("Data File");
|
||||
entry->parent = root;
|
||||
entry->level = 1;
|
||||
entries = evas_list_append(entries,entry);
|
||||
l1 = entry;
|
||||
{
|
||||
/* image */
|
||||
entry = E_NEW(E_Fm_Mime_Entry,1);
|
||||
entry->name = strdup("image");
|
||||
entry->label = strdup("Image File");
|
||||
entry->parent = l1;
|
||||
entry->level = 2;
|
||||
entries = evas_list_append(entries,entry);
|
||||
_e_fm_mime_action_default_set(entry, "gimp_edit");
|
||||
_e_fm_mime_action_append(entry, "exhibit_view");
|
||||
l2 = entry;
|
||||
{
|
||||
/* jpg */
|
||||
entry = E_NEW(E_Fm_Mime_Entry, 1);
|
||||
entry->name = strdup("jpg");
|
||||
entry->label = strdup("JPEG Image");
|
||||
entry->parent = l2;
|
||||
entry->level = 3;
|
||||
entry->suffix = strdup("jpg");
|
||||
entry->thumbnail = &_e_fm_mime_thumbnail_evas;
|
||||
entries = evas_list_append(entries,entry);
|
||||
|
||||
/* png */
|
||||
entry = E_NEW(E_Fm_Mime_Entry, 1);
|
||||
entry->name = strdup("png");
|
||||
entry->label = strdup("PNG Image");
|
||||
entry->parent = l2;
|
||||
entry->level = 3;
|
||||
entry->suffix = strdup("png");
|
||||
entry->thumbnail = &_e_fm_mime_thumbnail_evas;
|
||||
entries = evas_list_append(entries,entry);
|
||||
|
||||
}
|
||||
/* audio */
|
||||
entry = E_NEW(E_Fm_Mime_Entry,1);
|
||||
entry->name = strdup("audio");
|
||||
entry->label = strdup("Audio File");
|
||||
entry->parent = l1;
|
||||
entry->level = 2;
|
||||
entries = evas_list_append(entries,entry);
|
||||
_e_fm_mime_action_append(entry, "xmms_play");
|
||||
_e_fm_mime_action_append(entry, "xmms_enqueue");
|
||||
l2 = entry;
|
||||
{
|
||||
/* mp3 */
|
||||
entry = E_NEW(E_Fm_Mime_Entry, 1);
|
||||
entry->name = strdup("mp3");
|
||||
entry->label = strdup("MP3 Audio");
|
||||
entry->parent = l2;
|
||||
entry->level = 3;
|
||||
entry->suffix = strdup("mp3");
|
||||
entries = evas_list_append(entries,entry);
|
||||
|
||||
/* ogg */
|
||||
entry = E_NEW(E_Fm_Mime_Entry, 1);
|
||||
entry->name = strdup("ogg");
|
||||
entry->label = strdup("OGG Audio");
|
||||
entry->parent = l2;
|
||||
entry->level = 3;
|
||||
entry->suffix = strdup("ogg");
|
||||
entries = evas_list_append(entries,entry);
|
||||
|
||||
/* wav */
|
||||
entry = E_NEW(E_Fm_Mime_Entry, 1);
|
||||
entry->name = strdup("wav");
|
||||
entry->label = strdup("WAV Audio");
|
||||
entry->parent = l2;
|
||||
entry->level = 3;
|
||||
entry->suffix = strdup("wav");
|
||||
entries = evas_list_append(entries,entry);
|
||||
}
|
||||
}
|
||||
/* directory */
|
||||
entry = E_NEW(E_Fm_Mime_Entry,1);
|
||||
entry->name = strdup("folder");
|
||||
entry->label = strdup("Folder");
|
||||
entry->type = E_FM_FILE_TYPE_DIRECTORY;
|
||||
entry->parent = root;
|
||||
entry->level = 1;
|
||||
entries = evas_list_append(entries,entry);
|
||||
_e_fm_mime_action_default_set(entry, "_folder_open");
|
||||
_e_fm_mime_action_append(entry, "_folder_open_other");
|
||||
l1 = entry;
|
||||
|
||||
|
||||
|
||||
init_count++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
e_fm_mime_shutdwon(void)
|
||||
{
|
||||
init_count--;
|
||||
}
|
||||
|
||||
|
||||
/* returns the shortest root mime for a list of @files
|
||||
* FIXME can be implemented faster? delete the list while iterating
|
||||
*/
|
||||
E_Fm_Mime_Entry *
|
||||
e_fm_mime_get_from_list(Evas_List *files)
|
||||
{
|
||||
E_Fm_File *file;
|
||||
E_Fm_Mime_Entry *entry;
|
||||
Evas_List *l;
|
||||
|
||||
if (files == NULL)
|
||||
return NULL;
|
||||
|
||||
file = (E_Fm_File *)files->data;
|
||||
entry = file->mime;
|
||||
for (l = files->next; l; l = l->next)
|
||||
{
|
||||
E_Fm_Mime_Entry *eme;
|
||||
|
||||
file = (E_Fm_File *)l->data;
|
||||
eme = file->mime;
|
||||
entry = _e_fm_mime_common(entry,eme);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
/* returns the mime entry for a file */
|
||||
void
|
||||
e_fm_mime_set(E_Fm_File *file)
|
||||
{
|
||||
Evas_List *l;
|
||||
for(l = entries; l; l = l->next)
|
||||
{
|
||||
E_Fm_Mime_Entry *entry;
|
||||
|
||||
entry = (E_Fm_Mime_Entry *)l->data;
|
||||
|
||||
/* FIXME add all the possible comparision, suffix,regexp,flags,etc */
|
||||
if(entry->suffix)
|
||||
{
|
||||
char *suffix;
|
||||
|
||||
suffix = _e_fm_mime_suffix_get(file->name);
|
||||
if(!suffix)
|
||||
continue;
|
||||
if(!strcasecmp(suffix,entry->suffix))
|
||||
{
|
||||
//printf("found by suffix %s\n", suffix);
|
||||
file->mime = entry;
|
||||
}
|
||||
free(suffix);
|
||||
}
|
||||
if(entry->type)
|
||||
{
|
||||
if(entry->type == file->type)
|
||||
file->mime = entry;
|
||||
}
|
||||
}
|
||||
/* if it doesnt match anything set to the root */
|
||||
if(!file->mime)
|
||||
file->mime = (E_Fm_Mime_Entry*)entries->data;
|
||||
}
|
||||
|
||||
#if 0
|
||||
EAPI E_Fm_Mime_Action *
|
||||
e_fm_mime_action_get_by_label(char *label)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_Fm_Mime_Action *action = NULL;
|
||||
|
||||
for(l = actions; l; l = l->next)
|
||||
{
|
||||
action = (E_Fm_Mime_Action*)l->data;
|
||||
if(!strcmp(label,action->label))
|
||||
break;
|
||||
}
|
||||
return action;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* will call the command of an @action for the fileman_smart @sd */
|
||||
EAPI int
|
||||
e_fm_mime_action_call(E_Fm_Smart_Data *sd, E_Fm_Mime_Action *action)
|
||||
{
|
||||
Ecore_Exe *exe;
|
||||
char *command;
|
||||
|
||||
/* FIXME: use the e app execution mechanisms where possible so we can
|
||||
* collect error output
|
||||
*/
|
||||
if(action->is_internal)
|
||||
{
|
||||
action->internal.function(sd);
|
||||
}
|
||||
else
|
||||
{
|
||||
command = _e_fm_mime_string_tokenizer(sd->operation.files,sd->operation.hover,action->cmd);
|
||||
printf("going to execute %s\n", command);
|
||||
exe = ecore_exe_run(command, NULL);
|
||||
|
||||
|
||||
if (!exe)
|
||||
{
|
||||
|
||||
e_error_dialog_show(_("Run Error"),
|
||||
_("Enlightenment was unable to fork a child process:\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"\n"),
|
||||
command);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm_mime_action_default_call(E_Fm_Smart_Data *sd)
|
||||
{
|
||||
E_Fm_Mime_Entry *mime;
|
||||
E_Fm_Mime_Action *action;
|
||||
|
||||
mime = sd->operation.mime;
|
||||
do
|
||||
{
|
||||
action = mime->action_default;
|
||||
|
||||
if(!action)
|
||||
{
|
||||
mime = mime->parent;
|
||||
continue;
|
||||
}
|
||||
/* if we reach here we have an action */
|
||||
break;
|
||||
} while(mime);
|
||||
if(!action)
|
||||
return;
|
||||
|
||||
e_fm_mime_action_call(sd, action);
|
||||
}
|
||||
|
||||
EAPI char *
|
||||
e_fm_mime_translate(E_Fm_Smart_Data *sd, char *istr)
|
||||
{
|
||||
char *ostr;
|
||||
|
||||
ostr = _e_fm_mime_string_tokenizer(sd->operation.files,sd->operation.hover, istr);
|
||||
|
||||
return ostr;
|
||||
}
|
||||
|
||||
/* subsystem functions */
|
||||
/***********************/
|
||||
|
||||
/* returns the shortest root for both entries @e1 and @e2
|
||||
* FIXME can be implemented faster?
|
||||
*/
|
||||
|
||||
static E_Fm_Mime_Entry *
|
||||
_e_fm_mime_common(E_Fm_Mime_Entry *e1, E_Fm_Mime_Entry *e2)
|
||||
{
|
||||
|
||||
E_Fm_Mime_Entry *tmp;
|
||||
int i;
|
||||
int count;
|
||||
|
||||
/* take the lowest on the tree */
|
||||
/* set the e1 upper, e2 lower */
|
||||
if(e1->level > e2->level)
|
||||
{
|
||||
count = e1->level - e2->level;
|
||||
tmp = e1;
|
||||
e1 = e2;
|
||||
e2 = tmp;
|
||||
}
|
||||
else
|
||||
count = e2->level - e1-> level;
|
||||
|
||||
/* first equal levels */
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
e2 = e2->parent;
|
||||
}
|
||||
/* get up on the tree until we find the same parent */
|
||||
for(i = e1->level; i >= 0; i--)
|
||||
{
|
||||
if(!strcmp(e1->name,e2->name))
|
||||
return e1;
|
||||
e1 = e1->parent;
|
||||
e2 = e2->parent;
|
||||
}
|
||||
/* this should never happen */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* will translate %f,%d to file,dir respective */
|
||||
static char*
|
||||
_e_fm_mime_string_tokenizer(Evas_List *files, E_Fm_File *hover, char *istr)
|
||||
{
|
||||
char *buf;
|
||||
char *c;
|
||||
int i, bsize,trans;
|
||||
Evas_List *l;
|
||||
|
||||
buf = calloc(PATH_MAX,sizeof(char));
|
||||
bsize = PATH_MAX;
|
||||
i = 0;
|
||||
trans = 0;
|
||||
for(c = istr; *c; c++)
|
||||
{
|
||||
if( i > bsize - 1)
|
||||
{
|
||||
bsize += PATH_MAX;
|
||||
buf = realloc(buf,bsize);
|
||||
}
|
||||
if(trans)
|
||||
{
|
||||
char *astr = NULL;
|
||||
if(*c == 'f')
|
||||
{
|
||||
int j = 2;
|
||||
|
||||
astr = calloc(PATH_MAX,sizeof(char));
|
||||
for(l = files; l; l = l->next)
|
||||
{
|
||||
E_Fm_File *file;
|
||||
|
||||
file = (E_Fm_File *)l->data;
|
||||
sprintf(astr,"%s %s",astr,file->path);
|
||||
astr = realloc(astr,PATH_MAX*j);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
if(*c == 'h')
|
||||
{
|
||||
astr = strdup(hover->path);
|
||||
}
|
||||
if(!astr)
|
||||
continue;
|
||||
if(bsize < i + strlen(astr))
|
||||
{
|
||||
bsize += strlen(astr) + 1;
|
||||
buf = realloc(buf,bsize);
|
||||
}
|
||||
buf[i-1] = '\0';
|
||||
sprintf(buf, "%s%s", buf, astr);
|
||||
i += strlen(astr) - 1;
|
||||
trans = 0;
|
||||
free(astr);
|
||||
continue;
|
||||
}
|
||||
if(*c == '%')
|
||||
trans = 1;
|
||||
else
|
||||
buf[i] = *c;
|
||||
i++;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_e_fm_mime_action_append(E_Fm_Mime_Entry *entry, char *action_name)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
for(l = actions; l; l = l->next)
|
||||
{
|
||||
E_Fm_Mime_Action *action;
|
||||
|
||||
action = (E_Fm_Mime_Action *)l->data;
|
||||
if(!strcmp(action->name, action_name))
|
||||
{
|
||||
entry->actions = evas_list_append(entry->actions, action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_mime_action_default_set(E_Fm_Mime_Entry *entry, char *action_name)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
for(l = actions; l; l = l->next)
|
||||
{
|
||||
E_Fm_Mime_Action *action;
|
||||
|
||||
action = (E_Fm_Mime_Action *)l->data;
|
||||
if(!strcmp(action->name, action_name))
|
||||
{
|
||||
/* overwrite the old default action */
|
||||
if(action->relative)
|
||||
entry->action_default_relative = action;
|
||||
else
|
||||
entry->action_default = action;
|
||||
entry->actions = evas_list_append(entry->actions, action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
_e_fm_mime_suffix_get(char *filename)
|
||||
{
|
||||
char *suf;
|
||||
|
||||
suf = strrchr(filename, '.');
|
||||
if (suf)
|
||||
{
|
||||
suf++;
|
||||
suf = strdup(suf);
|
||||
return suf;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_e_fm_mime_action_internal_folder_open(E_Fm_Smart_Data *sd)
|
||||
{
|
||||
E_Fm_File *file;
|
||||
|
||||
file = sd->operation.files->data;
|
||||
if (file) e_fm_dir_set(sd->object, file->path);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_mime_action_internal_folder_open_other(E_Fm_Smart_Data *sd)
|
||||
{
|
||||
E_Fileman *fileman;
|
||||
E_Fm_File *file;
|
||||
|
||||
file = sd->operation.files->data;
|
||||
if (file)
|
||||
{
|
||||
fileman = e_fileman_new_to_dir(e_container_current_get(e_manager_current_get()), file->path);
|
||||
e_fileman_show(fileman);
|
||||
}
|
||||
}
|
||||
static void
|
||||
_e_fm_mime_action_internal_copy_to(E_Fm_Smart_Data *sd)
|
||||
{
|
||||
printf("going to copy to %s\n", sd->operation.hover->path);
|
||||
}
|
||||
static void
|
||||
_e_fm_mime_action_internal_move_to(E_Fm_Smart_Data *sd)
|
||||
{
|
||||
printf("going to move to %s\n", sd->operation.hover->path);
|
||||
}
|
||||
|
||||
/* thumbnail functions */
|
||||
/***********************/
|
||||
Evas_Object *
|
||||
_e_fm_mime_thumbnail_evas(char *path, Evas_Coord w, Evas_Coord h, Evas *evas, Evas_Object **tmp, void (*cb)(Evas_Object *obj, void *data), void *data)
|
||||
{
|
||||
Evas_Object *r;
|
||||
|
||||
r = e_thumb_icon_add(evas);
|
||||
e_thumb_icon_file_set(r, path, NULL);
|
||||
e_thumb_icon_size_set(r, w, h);
|
||||
e_thumb_icon_begin(r);
|
||||
return r;
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
|
||||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef struct _E_Fm_Mime_Entry E_Fm_Mime_Entry;
|
||||
typedef struct _E_Fm_Mime_Action E_Fm_Mime_Action;
|
||||
typedef int (*E_Fm_Mime_Preview_Function) (E_Fm_File*);
|
||||
|
||||
#if 0
|
||||
file->preview_funcs = E_NEW(E_Fm_File_Preview_Function, 5);
|
||||
file->preview_funcs[0] = e_fm_file_is_image;
|
||||
file->preview_funcs[1] = e_fm_file_is_etheme;
|
||||
file->preview_funcs[2] = e_fm_file_is_ebg;
|
||||
file->preview_funcs[3] = e_fm_file_is_eap;
|
||||
file->preview_funcs[4] = NULL;
|
||||
#endif
|
||||
|
||||
#else
|
||||
#ifndef E_FILEMAN_MIME_H
|
||||
#define E_FILEMAN_MIME_H
|
||||
|
||||
|
||||
struct _E_Fm_Mime_Entry
|
||||
{
|
||||
char *name;
|
||||
char *label;
|
||||
int level; /* the level on the three for easy search/comparsion */
|
||||
E_Fm_Mime_Entry *parent;
|
||||
E_Fm_Mime_Action *action_default; /* the default action also exists on the actions list */
|
||||
E_Fm_Mime_Action *action_default_relative;
|
||||
Evas_List *actions;
|
||||
/* the autodetect features */
|
||||
char *suffix;
|
||||
int type;
|
||||
/* to thumbnail this file type */
|
||||
Evas_Object * (*thumbnail) (char *path, Evas_Coord w, Evas_Coord h, Evas *evas, Evas_Object **tmp, void (*cb)(Evas_Object *obj, void *data), void *data);
|
||||
/* to preview this file type */
|
||||
E_Fm_Mime_Preview_Function preview;
|
||||
|
||||
};
|
||||
|
||||
struct _E_Fm_Mime_Action
|
||||
{
|
||||
char *name;
|
||||
char *label;
|
||||
char *cmd;
|
||||
unsigned char multiple : 1; /* support for multiple files at once */
|
||||
unsigned char is_internal : 1; /* if its internal cant be modified */
|
||||
unsigned char relative : 1; /* if the action MUST be realitve to a dir */
|
||||
struct
|
||||
{
|
||||
void (*function)(E_Fm_Smart_Data *sd);
|
||||
} internal;
|
||||
};
|
||||
|
||||
EAPI int e_fm_mime_init(void);
|
||||
EAPI void e_fm_mime_shutdwon(void);
|
||||
EAPI E_Fm_Mime_Entry *e_fm_mime_get_from_list(Evas_List *files);
|
||||
EAPI void e_fm_mime_set(E_Fm_File *file);
|
||||
EAPI int e_fm_mime_action_call(E_Fm_Smart_Data *sd, E_Fm_Mime_Action *action);
|
||||
EAPI void e_fm_mime_action_default_call(E_Fm_Smart_Data *sd);
|
||||
EAPI char *e_fm_mime_translate(E_Fm_Smart_Data *sd, char *istr);
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,286 +0,0 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef struct _E_Fm_Smart_Data E_Fm_Smart_Data;
|
||||
typedef struct _E_Fm_Icon E_Fm_Icon;
|
||||
typedef struct _E_Fm_Icon_CFData E_Fm_Icon_CFData;
|
||||
typedef struct _E_Fm_Config E_Fm_Config;
|
||||
typedef struct _E_Fm_Dir_Metadata E_Fm_Dir_Metadata;
|
||||
typedef struct _E_Fm_Fake_Mouse_Up_Info E_Fm_Fake_Mouse_Up_Info;
|
||||
typedef struct _E_Event_Fm_Reconfigure E_Event_Fm_Reconfigure;
|
||||
typedef struct _E_Event_Fm_Directory_Change E_Event_Fm_Directory_Change;
|
||||
typedef struct _E_Fm_Menu_Item_Data E_Fm_Menu_Item_Data;
|
||||
|
||||
typedef struct _E_Fm_Assoc_App E_Fm_Assoc_App;
|
||||
|
||||
typedef enum _E_Fm_Arrange E_Fm_Arrange;
|
||||
typedef enum _E_Fm_State E_Fm_State;
|
||||
typedef enum _E_Fm_Autoscroll E_Fm_Autoscroll;
|
||||
typedef enum _E_Fm_Drag_Status E_Fm_Drag_Status;
|
||||
typedef enum _E_Fm_Drag_Button E_Fm_Drag_Button;
|
||||
|
||||
#else
|
||||
#ifndef E_FM_SMART_H
|
||||
#define E_FM_SMART_H
|
||||
|
||||
/* this is for passing the E_Fm_Mime_Action of a menu item and the E_Fm_Smart_Data
|
||||
* in one struct for the menu item callback */
|
||||
struct _E_Fm_Menu_Item_Data
|
||||
{
|
||||
E_Fm_Mime_Action *action;
|
||||
E_Fm_Smart_Data *sd;
|
||||
};
|
||||
|
||||
struct _E_Fm_Config
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
Evas_List *apps;
|
||||
};
|
||||
|
||||
struct _E_Fm_Dir_Metadata
|
||||
{
|
||||
char *name; /* dir name */
|
||||
char *bg; /* dir's custom bg */
|
||||
int view; /* dir's saved view type */
|
||||
Evas_List *files; /* files in dir */
|
||||
|
||||
/* these are generated post-load */
|
||||
Evas_Hash *files_hash; /* quick lookup hash */
|
||||
};
|
||||
|
||||
struct _E_Fm_Icon
|
||||
{
|
||||
E_Fm_File *file;
|
||||
Evas_Object *icon_obj;
|
||||
E_Fm_Smart_Data *sd;
|
||||
|
||||
struct {
|
||||
unsigned char selected : 1;
|
||||
unsigned char hover : 1;
|
||||
unsigned char visible : 1; /* to stop comparing icon_obj to NULL */
|
||||
}
|
||||
state;
|
||||
};
|
||||
|
||||
struct _E_Fm_Icon_CFData
|
||||
{
|
||||
/*- BASIC -*/
|
||||
int protect;
|
||||
int readwrite;
|
||||
/*- ADVANCED -*/
|
||||
struct {
|
||||
int r;
|
||||
int w;
|
||||
int x;
|
||||
}
|
||||
user, group, world;
|
||||
/*- common -*/
|
||||
E_Fm_Icon *icon;
|
||||
};
|
||||
|
||||
enum _E_Fm_Arrange
|
||||
{
|
||||
E_FILEMAN_CANVAS_ARRANGE_NAME = 0,
|
||||
E_FILEMAN_CANVAS_ARRANGE_MODTIME = 1,
|
||||
E_FILEMAN_CANVAS_ARRANGE_SIZE = 2,
|
||||
};
|
||||
|
||||
enum _E_Fm_State
|
||||
{
|
||||
E_FILEMAN_STATE_IDLE = 0,
|
||||
E_FILEMAN_STATE_TYPEBUFFER = 1,
|
||||
E_FILEMAN_STATE_RENAME = 2,
|
||||
};
|
||||
|
||||
enum _E_Fm_Autoscroll
|
||||
{
|
||||
E_FILEMAN_AUTOSCROLL_NONE = 0,
|
||||
E_FILEMAN_AUTOSCROLL_UP = 1,
|
||||
E_FILEMAN_AUTOSCROLL_DOWN = 2,
|
||||
E_FILEMAN_AUTOSCROLL_LEFT = 4,
|
||||
E_FILEMAN_AUTOSCROLL_RIGHT = 8,
|
||||
};
|
||||
|
||||
enum _E_Fm_Drag_Status
|
||||
{
|
||||
E_FILEMAN_DRAG_NONE = 0, /* to not create the drag window on every mouse move */
|
||||
E_FILEMAN_DRAG_START = 1, /* to create the fake window and identify the fileman sd
|
||||
that does the drag */
|
||||
E_FILEMAN_DRAG_DOING = 2, /* to know when to launch the context menu/call default
|
||||
relative action */
|
||||
E_FILEMAN_DRAG_DONE = 3, /* the mouse up event is *before* the xdnd selection,
|
||||
we need this */
|
||||
};
|
||||
|
||||
enum _E_Fm_Drag_Button
|
||||
{
|
||||
E_FILEMAN_DRAG_PRIMARY = 1,
|
||||
E_FILEMAN_DRAG_SECONDARY = 3,
|
||||
};
|
||||
|
||||
struct _E_Fm_Fake_Mouse_Up_Info
|
||||
{
|
||||
Evas *canvas;
|
||||
int button;
|
||||
};
|
||||
|
||||
struct _E_Fm_Smart_Data
|
||||
{
|
||||
E_Menu *menu;
|
||||
E_Win *win;
|
||||
Evas *evas;
|
||||
|
||||
Evas_Object *edje_obj;
|
||||
Evas_Object *event_obj;
|
||||
Evas_Object *clip_obj;
|
||||
Evas_Object *layout;
|
||||
Evas_Object *object;
|
||||
Evas_Object *entry_obj;
|
||||
|
||||
E_Fm_Dir_Metadata *meta;
|
||||
|
||||
Evas_Hash *mime_menu_hash; /* FIXME delete this */
|
||||
|
||||
char *dir; /* FIXME this could be actually a E_Fm_Dir */
|
||||
|
||||
double timer_int;
|
||||
Ecore_Timer *timer;
|
||||
|
||||
Evas_List *event_handlers;
|
||||
|
||||
Evas_List *icons; /* list of E_Fm_Icons on the current directory */
|
||||
Evas_List *files_raw; /* raw char filenames of files on the current directory */
|
||||
Ecore_File_Monitor *monitor;
|
||||
E_Fm_Arrange arrange;
|
||||
|
||||
E_Fm_State state;
|
||||
// E_Fm_Icon *active_file;
|
||||
int frozen;
|
||||
double position;
|
||||
|
||||
int is_selector;
|
||||
void (*selector_func) (Evas_Object *object, char *file, void *data);
|
||||
void *selector_data;
|
||||
void (*selector_hilite_func) (Evas_Object *object, char *file, void *data);
|
||||
|
||||
Evas_Coord x, y, w, h;
|
||||
|
||||
struct {
|
||||
E_Fm_Drag_Status status;
|
||||
E_Fm_Drag_Button button;
|
||||
int x, y; /* the position of the pointer's x,y, relative to the canvas */
|
||||
int dx, dy; /* the difference from the icon's x,y and the pointer's x,y */
|
||||
Ecore_Evas *ecore_evas;
|
||||
Evas *evas;
|
||||
Ecore_X_Window win;
|
||||
E_Fm_Icon *icon_obj;
|
||||
Evas_Object *image_object;
|
||||
}
|
||||
drag;
|
||||
|
||||
struct {
|
||||
double timer_int;
|
||||
Ecore_Timer *timer;
|
||||
E_Fm_Autoscroll direction;
|
||||
}
|
||||
autoscroll;
|
||||
|
||||
struct {
|
||||
Evas_Coord x_space, y_space, w, h;
|
||||
}
|
||||
icon_info;
|
||||
|
||||
struct {
|
||||
Evas_Coord x, y, w, h;
|
||||
}
|
||||
child;
|
||||
|
||||
struct {
|
||||
Evas_List *icons; /* list of E_Fm_Icons selected */
|
||||
|
||||
struct {
|
||||
E_Fm_Icon *file; /* FIXME should be called icon! */
|
||||
Evas_List *ptr;
|
||||
}
|
||||
current;
|
||||
|
||||
struct {
|
||||
unsigned char enabled : 1;
|
||||
Evas_Coord x, y;
|
||||
Evas_Object *obj;
|
||||
Evas_List *files;
|
||||
}
|
||||
band;
|
||||
|
||||
}
|
||||
selection; /* the selected icons */
|
||||
|
||||
struct {
|
||||
Evas_List *files; /* list of E_Fm_Files */
|
||||
E_Fm_File *hover; /* the file of the relative directory for operations */
|
||||
E_Fm_Mime_Entry *mime; /* overall mime for all the icons we are going to operate wirh */
|
||||
E_Menu *menu; /* the menu displayed for it (action/context) */
|
||||
Evas_List *menu_item_data; /* the data created for each callback, for free later */
|
||||
}
|
||||
operation; /* the operating files, for wich we are going to make actions
|
||||
might be the selected files or the dropped files */
|
||||
|
||||
struct {
|
||||
E_Config_DD *main_edd;
|
||||
E_Fm_Config *main;
|
||||
}
|
||||
conf;
|
||||
};
|
||||
|
||||
struct _E_Event_Fm_Reconfigure
|
||||
{
|
||||
Evas_Object *object;
|
||||
Evas_Coord x, y, w, h;
|
||||
};
|
||||
|
||||
struct _E_Event_Fm_Directory_Change
|
||||
{
|
||||
Evas_Object *object;
|
||||
Evas_Coord w, h;
|
||||
};
|
||||
|
||||
struct _E_Fm_Assoc_App
|
||||
{
|
||||
char *mime;
|
||||
char *app;
|
||||
};
|
||||
|
||||
EAPI int e_fm_init(void);
|
||||
EAPI int e_fm_shutdown(void);
|
||||
EAPI Evas_Object *e_fm_add(Evas *evas);
|
||||
EAPI void e_fm_dir_set(Evas_Object *object, const char *dir);
|
||||
EAPI char *e_fm_dir_get(Evas_Object *object);
|
||||
EAPI void e_fm_e_win_set(Evas_Object *object, E_Win *win);
|
||||
EAPI E_Win *e_fm_e_win_get(Evas_Object *object);
|
||||
EAPI void e_fm_menu_set(Evas_Object *object, E_Menu *menu);
|
||||
EAPI E_Menu *e_fm_menu_get(Evas_Object *object);
|
||||
|
||||
EAPI void e_fm_scroll_set(Evas_Object *object, Evas_Coord x, Evas_Coord y);
|
||||
EAPI void e_fm_scroll_get(Evas_Object *object, Evas_Coord *x, Evas_Coord *y);
|
||||
EAPI void e_fm_scroll_max_get(Evas_Object *object, Evas_Coord *x, Evas_Coord *y);
|
||||
|
||||
EAPI void e_fm_scroll_horizontal(Evas_Object *object, double percent);
|
||||
EAPI void e_fm_scroll_vertical(Evas_Object *object, double percent);
|
||||
|
||||
EAPI void e_fm_geometry_virtual_get(Evas_Object *object, Evas_Coord *w, Evas_Coord *h);
|
||||
EAPI void e_fm_reconfigure_callback_add(Evas_Object *object, void (*func)(void *data, Evas_Object *obj, E_Event_Fm_Reconfigure *ev), void *data);
|
||||
EAPI int e_fm_freeze(Evas_Object *freeze);
|
||||
EAPI int e_fm_thaw(Evas_Object *freeze);
|
||||
EAPI void e_fm_selector_enable(Evas_Object *object, void (*func)(Evas_Object *object, char *file, void *data), void (*hilite_func)(Evas_Object *object, char *file, void *data), void *data);
|
||||
EAPI void e_fm_background_set(Evas_Object *object, Evas_Object *bg);
|
||||
|
||||
EAPI Evas_Object *e_fm_icon_create(void *data);
|
||||
EAPI void e_fm_icon_destroy(Evas_Object *obj, void *data);
|
||||
|
||||
extern int E_EVENT_FM_RECONFIGURE;
|
||||
extern int E_EVENT_FM_DIRECTORY_CHANGE;
|
||||
#endif
|
||||
#endif
|
|
@ -591,10 +591,6 @@ main(int argc, char **argv)
|
|||
|
||||
_e_main_shutdown_push(_e_main_screens_shutdown);
|
||||
|
||||
|
||||
/* tell the error system that it can use gui dialogs now */
|
||||
e_error_gui_set(1);
|
||||
|
||||
/* setup e ipc service */
|
||||
if (_e_main_ipc_init())
|
||||
_e_main_shutdown_push(_e_main_ipc_shutdown);
|
||||
|
@ -1209,7 +1205,6 @@ _e_main_ipc_shutdown(void)
|
|||
static void
|
||||
_e_main_cb_x_fatal(void *data __UNUSED__)
|
||||
{
|
||||
e_error_gui_set(0);
|
||||
e_error_message_show("Lost X connection.");
|
||||
ecore_main_loop_quit();
|
||||
// _e_main_shutdown(-1);
|
||||
|
|
|
@ -659,12 +659,6 @@ e_zone_exec(E_Zone *zone, char *exe)
|
|||
if (!ex)
|
||||
{
|
||||
free(inst);
|
||||
e_error_dialog_show(_("Run Error"),
|
||||
_("Enlightenment was unable to fork a child process:\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"\n"),
|
||||
exe);
|
||||
ret = 0;
|
||||
}
|
||||
/* reset env vars */
|
||||
|
|
Loading…
Reference in New Issue