forked from enlightenment/enlightenment
parent
48c472a91c
commit
3184ef1247
18
src/e.h
18
src/e.h
|
@ -364,6 +364,20 @@ struct _E_Icon
|
||||||
char *shelf_name;
|
char *shelf_name;
|
||||||
E_Shelf *shelf;
|
E_Shelf *shelf;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
struct {
|
||||||
|
char *base, *type;
|
||||||
|
} mime;
|
||||||
|
char *link;
|
||||||
|
int is_exe;
|
||||||
|
int is_dir;
|
||||||
|
struct {
|
||||||
|
char *normal;
|
||||||
|
char *selected;
|
||||||
|
char *clicked;
|
||||||
|
} icon;
|
||||||
|
} info;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
struct {
|
struct {
|
||||||
|
@ -612,7 +626,9 @@ char *e_file_get_file(char *file);
|
||||||
char *e_file_get_dir(char *file);
|
char *e_file_get_dir(char *file);
|
||||||
void *e_memdup(void *data, int size);
|
void *e_memdup(void *data, int size);
|
||||||
int e_glob_matches(char *str, char *glob);
|
int e_glob_matches(char *str, char *glob);
|
||||||
|
int e_file_can_exec(struct stat *st);
|
||||||
|
char *e_file_link(char *link);
|
||||||
|
|
||||||
void e_exec_set_args(int argc, char **argv);
|
void e_exec_set_args(int argc, char **argv);
|
||||||
void e_exec_restart(void);
|
void e_exec_restart(void);
|
||||||
pid_t e_exec_run(char *exe);
|
pid_t e_exec_run(char *exe);
|
||||||
|
|
70
src/icons.c
70
src/icons.c
|
@ -11,7 +11,9 @@ e_icon_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
||||||
E_Icon *icon;
|
E_Icon *icon;
|
||||||
|
|
||||||
icon = _data;
|
icon = _data;
|
||||||
e_icon_set_icon(icon, PACKAGE_DATA_DIR"/data/icons/directory/default.db:/icon/selected");
|
icon->current.state.hilited = 1;
|
||||||
|
icon->changed = 1;
|
||||||
|
icon->view->changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -20,7 +22,9 @@ e_icon_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
||||||
E_Icon *icon;
|
E_Icon *icon;
|
||||||
|
|
||||||
icon = _data;
|
icon = _data;
|
||||||
e_icon_set_icon(icon, PACKAGE_DATA_DIR"/data/icons/directory/default.db:/icon/normal");
|
icon->current.state.hilited = 0;
|
||||||
|
icon->changed = 1;
|
||||||
|
icon->view->changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -29,7 +33,9 @@ e_icon_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
||||||
E_Icon *icon;
|
E_Icon *icon;
|
||||||
|
|
||||||
icon = _data;
|
icon = _data;
|
||||||
e_icon_set_icon(icon, PACKAGE_DATA_DIR"/data/icons/directory/default.db:/icon/clicked");
|
icon->current.state.clicked = 1;
|
||||||
|
icon->changed = 1;
|
||||||
|
icon->view->changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -38,15 +44,25 @@ e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
||||||
E_Icon *icon;
|
E_Icon *icon;
|
||||||
|
|
||||||
icon = _data;
|
icon = _data;
|
||||||
e_icon_set_icon(icon, PACKAGE_DATA_DIR"/data/icons/directory/default.db:/icon/selected");
|
icon->current.state.clicked = 0;
|
||||||
|
if (icon->current.state.selected)
|
||||||
|
icon->current.state.selected = 0;
|
||||||
|
else
|
||||||
|
icon->current.state.selected = 1;
|
||||||
|
icon->changed = 1;
|
||||||
|
icon->view->changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_icon_free(E_Icon *icon)
|
e_icon_free(E_Icon *icon)
|
||||||
{
|
{
|
||||||
IF_FREE(icon->file);
|
IF_FREE(icon->file);
|
||||||
IF_FREE(icon->current.icon);
|
IF_FREE(icon->info.icon.normal);
|
||||||
IF_FREE(icon->previous.icon);
|
IF_FREE(icon->info.icon.selected);
|
||||||
|
IF_FREE(icon->info.icon.clicked);
|
||||||
|
IF_FREE(icon->info.link);
|
||||||
|
IF_FREE(icon->info.mime.base);
|
||||||
|
IF_FREE(icon->info.mime.type);
|
||||||
FREE(icon);
|
FREE(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +74,8 @@ e_icon_new(void)
|
||||||
icon = NEW(E_Icon, 1);
|
icon = NEW(E_Icon, 1);
|
||||||
ZERO(icon, E_Icon, 1);
|
ZERO(icon, E_Icon, 1);
|
||||||
OBJ_INIT(icon, e_icon_free);
|
OBJ_INIT(icon, e_icon_free);
|
||||||
|
icon->info.icon.normal = strdup(PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/normal");
|
||||||
|
icon->previous.state.clicked = -1;
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,14 +181,40 @@ e_icon_update(E_Icon *icon)
|
||||||
int obj_new = 0;
|
int obj_new = 0;
|
||||||
|
|
||||||
if (!icon->changed) return;
|
if (!icon->changed) return;
|
||||||
|
if (icon->current.state.clicked)
|
||||||
|
{
|
||||||
|
if (icon->info.icon.clicked)
|
||||||
|
icon->current.icon = icon->info.icon.clicked;
|
||||||
|
else if (icon->info.icon.selected)
|
||||||
|
icon->current.icon = icon->info.icon.selected;
|
||||||
|
else
|
||||||
|
icon->current.icon = icon->info.icon.normal;
|
||||||
|
}
|
||||||
|
else if (icon->current.state.selected)
|
||||||
|
{
|
||||||
|
if (icon->info.icon.selected)
|
||||||
|
icon->current.icon = icon->info.icon.selected;
|
||||||
|
else
|
||||||
|
icon->current.icon = icon->info.icon.normal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
icon->current.icon = icon->info.icon.normal;
|
||||||
|
}
|
||||||
if (((icon->current.icon) && (icon->previous.icon) &&
|
if (((icon->current.icon) && (icon->previous.icon) &&
|
||||||
(strcmp(icon->current.icon, icon->previous.icon))) ||
|
(strcmp(icon->current.icon, icon->previous.icon))) ||
|
||||||
(!icon->current.icon) || (!icon->previous.icon))
|
(!icon->current.icon) || (!icon->previous.icon))
|
||||||
{
|
{
|
||||||
if (icon->obj.filename) evas_del_object(icon->view->evas, icon->obj.filename);
|
if (icon->obj.icon)
|
||||||
icon->obj.filename = NULL;
|
{
|
||||||
if (icon->obj.icon) evas_del_object(icon->view->evas, icon->obj.icon);
|
int iw, ih;
|
||||||
icon->obj.icon = NULL;
|
|
||||||
|
evas_set_image_file(icon->view->evas, icon->obj.icon, icon->current.icon);
|
||||||
|
evas_get_image_size(icon->view->evas, icon->obj.icon, &iw, &ih);
|
||||||
|
evas_set_image_fill(icon->view->evas, icon->obj.icon, 0, 0, iw, ih);
|
||||||
|
evas_resize(icon->view->evas, icon->obj.icon, iw, ih);
|
||||||
|
icon->previous.x = icon->current.x - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!icon->obj.filename)
|
if (!icon->obj.filename)
|
||||||
{
|
{
|
||||||
|
@ -207,7 +251,7 @@ e_icon_update(E_Icon *icon)
|
||||||
double tw, th;
|
double tw, th;
|
||||||
|
|
||||||
evas_get_geometry(icon->view->evas, icon->obj.filename, NULL, NULL, &tw, &th);
|
evas_get_geometry(icon->view->evas, icon->obj.filename, NULL, NULL, &tw, &th);
|
||||||
evas_get_image_size(icon->view->evas, icon->obj.icon, & iw, &ih);
|
evas_get_image_size(icon->view->evas, icon->obj.icon, &iw, &ih);
|
||||||
fx = icon->current.x + ((iw - tw) / 2);
|
fx = icon->current.x + ((iw - tw) / 2);
|
||||||
fy = icon->current.y + ih;
|
fy = icon->current.y + ih;
|
||||||
evas_move(icon->view->evas, icon->obj.icon, icon->current.x, icon->current.y);
|
evas_move(icon->view->evas, icon->obj.icon, icon->current.x, icon->current.y);
|
||||||
|
@ -236,9 +280,5 @@ e_icon_update(E_Icon *icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IF_FREE(icon->previous.icon);
|
|
||||||
icon->previous = icon->current;
|
|
||||||
if (icon->current.icon) icon->previous.icon = strdup(icon->current.icon);
|
|
||||||
|
|
||||||
icon->changed = 0;
|
icon->changed = 0;
|
||||||
}
|
}
|
||||||
|
|
37
src/util.c
37
src/util.c
|
@ -129,3 +129,40 @@ e_glob_matches(char *str, char *glob)
|
||||||
if (!fnmatch(glob, str, 0)) return 1;
|
if (!fnmatch(glob, str, 0)) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
e_file_can_exec(struct stat *st)
|
||||||
|
{
|
||||||
|
static uid_t uid = -1;
|
||||||
|
static gid_t gid = -1;
|
||||||
|
int ok;
|
||||||
|
|
||||||
|
if (!st) return 0;
|
||||||
|
ok = 0;
|
||||||
|
if (uid < 0) uid = getuid();
|
||||||
|
if (gid < 0) gid = getgid();
|
||||||
|
if (st->st_uid == uid)
|
||||||
|
{
|
||||||
|
if (st->st_mode & S_IXUSR) ok = 1;
|
||||||
|
}
|
||||||
|
else if (st->st_gid == gid)
|
||||||
|
{
|
||||||
|
if (st->st_mode & S_IXGRP) ok = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (st->st_mode & S_IXOTH) ok = 1;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
e_file_link(char *link)
|
||||||
|
{
|
||||||
|
char buf[4096];
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if ((count = readlink(link, buf, sizeof(buf))) < 0) return NULL;
|
||||||
|
buf[count] = 0;
|
||||||
|
return strdup(buf);
|
||||||
|
}
|
||||||
|
|
53
src/view.c
53
src/view.c
|
@ -412,7 +412,6 @@ e_view_file_added(int id, char *file)
|
||||||
e_icon_set_filename(icon, file);
|
e_icon_set_filename(icon, file);
|
||||||
e_icon_set_xy(icon, rand()%(v->size.w - 60), rand()%(v->size.h - 60));
|
e_icon_set_xy(icon, rand()%(v->size.w - 60), rand()%(v->size.h - 60));
|
||||||
e_icon_show(icon);
|
e_icon_show(icon);
|
||||||
e_icon_set_icon(icon, PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/normal");
|
|
||||||
e_view_add_icon(v, icon);
|
e_view_add_icon(v, icon);
|
||||||
sprintf(buf, "%s/%s", v->dir, file);
|
sprintf(buf, "%s/%s", v->dir, file);
|
||||||
efsd_stat(e_fs_get_connection(), buf);
|
efsd_stat(e_fs_get_connection(), buf);
|
||||||
|
@ -561,8 +560,44 @@ e_view_handle_fs(EfsdEvent *ev)
|
||||||
icon = e_view_find_icon_by_path(ev->efsd_reply_event.command.efsd_file_cmd.file);
|
icon = e_view_find_icon_by_path(ev->efsd_reply_event.command.efsd_file_cmd.file);
|
||||||
if (icon)
|
if (icon)
|
||||||
{
|
{
|
||||||
if (S_ISDIR(st->st_mode))
|
char f[4096];
|
||||||
e_icon_set_icon(icon, PACKAGE_DATA_DIR"/data/icons/directory/default.db:/icon/normal");
|
|
||||||
|
sprintf(f, "%s/%s", icon->view->dir, icon->file);
|
||||||
|
/* should get mime type here */
|
||||||
|
/* perhaps this flag should be part of the mime? */
|
||||||
|
if (S_ISDIR(st->st_mode)) icon->info.is_dir = 1;
|
||||||
|
/* this should be able to be returned by efsd */
|
||||||
|
if (S_ISLNK(st->st_mode)) icon->info.link = e_file_link(f);
|
||||||
|
icon->info.is_exe = e_file_can_exec(st);
|
||||||
|
/* figure out icons to use */
|
||||||
|
IF_FREE(icon->info.icon.normal);
|
||||||
|
IF_FREE(icon->info.icon.selected);
|
||||||
|
IF_FREE(icon->info.icon.clicked);
|
||||||
|
if (icon->info.is_dir)
|
||||||
|
{
|
||||||
|
icon->info.icon.normal = strdup(PACKAGE_DATA_DIR"/data/icons/directory/default.db:/icon/normal");
|
||||||
|
icon->info.icon.selected = strdup(PACKAGE_DATA_DIR"/data/icons/directory/default.db:/icon/selected");
|
||||||
|
icon->info.icon.clicked = strdup(PACKAGE_DATA_DIR"/data/icons/directory/default.db:/icon/clicked");
|
||||||
|
}
|
||||||
|
else if (icon->info.is_exe)
|
||||||
|
{
|
||||||
|
icon->info.icon.normal = strdup(PACKAGE_DATA_DIR"/data/icons/executable/default.db:/icon/normal");
|
||||||
|
icon->info.icon.selected = strdup(PACKAGE_DATA_DIR"/data/icons/executable/default.db:/icon/selected");
|
||||||
|
icon->info.icon.clicked = strdup(PACKAGE_DATA_DIR"/data/icons/executable/default.db:/icon/clicked");
|
||||||
|
}
|
||||||
|
else if (icon->info.link)
|
||||||
|
{
|
||||||
|
icon->info.icon.normal = strdup(PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/normal");
|
||||||
|
icon->info.icon.selected = strdup(PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/selected");
|
||||||
|
icon->info.icon.clicked = strdup(PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/clicked");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
icon->info.icon.normal = strdup(PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/normal");
|
||||||
|
icon->info.icon.selected = strdup(PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/selected");
|
||||||
|
icon->info.icon.clicked = strdup(PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/clicked");
|
||||||
|
}
|
||||||
|
icon->changed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -617,14 +652,22 @@ e_view_new(void)
|
||||||
v = NEW(E_View, 1);
|
v = NEW(E_View, 1);
|
||||||
ZERO(v, E_View, 1);
|
ZERO(v, E_View, 1);
|
||||||
OBJ_INIT(v, e_view_free);
|
OBJ_INIT(v, e_view_free);
|
||||||
|
#define SOFT_DESK
|
||||||
#if 1
|
/* #define X_DESK */
|
||||||
|
/* #define GL_DESK */
|
||||||
|
|
||||||
|
#ifdef SOFT_DESK
|
||||||
/* ONLY alpha software can be "backing stored" */
|
/* ONLY alpha software can be "backing stored" */
|
||||||
v->options.render_method = RENDER_METHOD_ALPHA_SOFTWARE;
|
v->options.render_method = RENDER_METHOD_ALPHA_SOFTWARE;
|
||||||
v->options.back_pixmap = 1;
|
v->options.back_pixmap = 1;
|
||||||
#else
|
#else
|
||||||
|
#ifdef X_DESK
|
||||||
v->options.render_method = RENDER_METHOD_BASIC_HARDWARE;
|
v->options.render_method = RENDER_METHOD_BASIC_HARDWARE;
|
||||||
v->options.back_pixmap = 0;
|
v->options.back_pixmap = 0;
|
||||||
|
#else
|
||||||
|
v->options.render_method = RENDER_METHOD_3D_HARDWARE;
|
||||||
|
v->options.back_pixmap = 0;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
views = evas_list_append(views, v);
|
views = evas_list_append(views, v);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue