forked from enlightenment/enlightenment
parent
7eb27c4c7d
commit
36bb6c0019
17
src/e.h
17
src/e.h
|
@ -356,12 +356,22 @@ struct _E_Icon
|
||||||
|
|
||||||
E_View *view;
|
E_View *view;
|
||||||
|
|
||||||
|
struct {
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
struct {
|
struct {
|
||||||
int text_location;
|
int text_location;
|
||||||
int show_text;
|
int show_text;
|
||||||
int show_icon;
|
int show_icon;
|
||||||
} options;
|
} options;
|
||||||
|
struct {
|
||||||
|
int clicked;
|
||||||
|
int selected;
|
||||||
|
int hilited;
|
||||||
|
} state;
|
||||||
|
char *icon;
|
||||||
|
int visible;
|
||||||
|
} current, previous;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Evas_Object icon;
|
Evas_Object icon;
|
||||||
Evas_Object filename;
|
Evas_Object filename;
|
||||||
|
@ -371,13 +381,6 @@ struct _E_Icon
|
||||||
Ebits_Object base_icon;
|
Ebits_Object base_icon;
|
||||||
Ebits_Object base_text;
|
Ebits_Object base_text;
|
||||||
} obj;
|
} obj;
|
||||||
struct {
|
|
||||||
int clicked;
|
|
||||||
int selected;
|
|
||||||
int hilited;
|
|
||||||
} state;
|
|
||||||
char *icon;
|
|
||||||
int visible;
|
|
||||||
int changed;
|
int changed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
141
src/icons.c
141
src/icons.c
|
@ -4,7 +4,8 @@ void
|
||||||
e_icon_free(E_Icon *icon)
|
e_icon_free(E_Icon *icon)
|
||||||
{
|
{
|
||||||
IF_FREE(icon->file);
|
IF_FREE(icon->file);
|
||||||
IF_FREE(icon->icon);
|
IF_FREE(icon->current.icon);
|
||||||
|
IF_FREE(icon->previous.icon);
|
||||||
FREE(icon);
|
FREE(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,26 +29,6 @@ e_icon_calulcate_geometry(E_Icon *icon)
|
||||||
void
|
void
|
||||||
e_icon_realize(E_Icon *icon)
|
e_icon_realize(E_Icon *icon)
|
||||||
{
|
{
|
||||||
int fx, fy;
|
|
||||||
int iw, ih;
|
|
||||||
double tw, th;
|
|
||||||
|
|
||||||
icon->obj.icon = evas_add_image_from_file(icon->view->evas, icon->icon);
|
|
||||||
icon->obj.filename = evas_add_text(icon->view->evas, "borzoib", 8, icon->file);
|
|
||||||
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_set_color(icon->view->evas, icon->obj.filename, 0, 0, 0, 255);
|
|
||||||
fx = icon->x + ((iw - tw) / 2);
|
|
||||||
fy = icon->y + ih;
|
|
||||||
evas_set_layer(icon->view->evas, icon->obj.icon, 10);
|
|
||||||
evas_set_layer(icon->view->evas, icon->obj.filename, 10);
|
|
||||||
evas_move(icon->view->evas, icon->obj.icon, icon->x, icon->y);
|
|
||||||
evas_move(icon->view->evas, icon->obj.filename, fx, fy);
|
|
||||||
if (icon->visible)
|
|
||||||
{
|
|
||||||
evas_show(icon->view->evas, icon->obj.icon);
|
|
||||||
evas_show(icon->view->evas, icon->obj.filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -55,26 +36,128 @@ e_icon_unrealize(E_Icon *icon)
|
||||||
{
|
{
|
||||||
if (icon->obj.icon) evas_del_object(icon->view->evas, icon->obj.icon);
|
if (icon->obj.icon) evas_del_object(icon->view->evas, icon->obj.icon);
|
||||||
if (icon->obj.filename) evas_del_object(icon->view->evas, icon->obj.filename);
|
if (icon->obj.filename) evas_del_object(icon->view->evas, icon->obj.filename);
|
||||||
|
icon->obj.icon = NULL;
|
||||||
|
icon->obj.filename = NULL;
|
||||||
|
if (icon->view) icon->view->changed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
e_icon_set_icon(E_Icon *icon, char *file)
|
||||||
|
{
|
||||||
|
IF_FREE(icon->current.icon);
|
||||||
|
icon->current.icon = strdup(file);
|
||||||
|
icon->changed = 1;
|
||||||
|
if (icon->view) icon->view->changed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
e_icon_show(E_Icon *icon)
|
||||||
|
{
|
||||||
|
if (!icon->current.visible)
|
||||||
|
{
|
||||||
|
icon->current.visible = 1;
|
||||||
|
icon->changed = 1;
|
||||||
|
if (icon->view) icon->view->changed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
e_icon_hide(E_Icon *icon)
|
||||||
|
{
|
||||||
|
if (icon->current.visible)
|
||||||
|
{
|
||||||
|
icon->current.visible = 0;
|
||||||
|
icon->changed = 1;
|
||||||
|
if (icon->view) icon->view->changed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
e_icon_set_xy(E_Icon *icon, int x, int y)
|
||||||
|
{
|
||||||
|
icon->current.x = x;
|
||||||
|
icon->current.y = y;
|
||||||
|
icon->changed = 1;
|
||||||
|
if (icon->view) icon->view->changed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
e_icon_get_xy(E_Icon *icon, int *x, int *y)
|
||||||
|
{
|
||||||
|
if (x) *x = icon->current.x;
|
||||||
|
if (y) *y = icon->current.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
e_icon_set_filename(E_Icon *icon, char *file)
|
||||||
|
{
|
||||||
|
IF_FREE(icon->file);
|
||||||
|
printf("e_icon_set_filename(%s)\n", file);
|
||||||
|
icon->file = strdup(file);
|
||||||
|
icon->changed = 1;
|
||||||
|
if (icon->view) icon->view->changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_icon_update(E_Icon *icon)
|
e_icon_update(E_Icon *icon)
|
||||||
{
|
{
|
||||||
|
if (!icon->changed) return;
|
||||||
|
if (((icon->current.icon) && (icon->previous.icon) &&
|
||||||
|
(strcmp(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);
|
||||||
|
icon->obj.filename = NULL;
|
||||||
|
if (icon->obj.icon) evas_del_object(icon->view->evas, icon->obj.icon);
|
||||||
|
icon->obj.icon = NULL;
|
||||||
|
}
|
||||||
|
if (!icon->obj.filename)
|
||||||
|
{
|
||||||
|
icon->obj.filename = evas_add_text(icon->view->evas, "borzoib", 8, icon->file);
|
||||||
|
evas_set_layer(icon->view->evas, icon->obj.filename, 10);
|
||||||
|
icon->previous.x = icon->current.x - 1;
|
||||||
|
icon->previous.visible = icon->current.visible - 1;
|
||||||
|
}
|
||||||
|
if (!icon->obj.icon)
|
||||||
|
{
|
||||||
|
icon->obj.icon = evas_add_image_from_file(icon->view->evas, icon->current.icon);
|
||||||
|
evas_set_layer(icon->view->evas, icon->obj.icon, 10);
|
||||||
|
icon->previous.x = icon->current.x - 1;
|
||||||
|
icon->previous.visible = icon->current.visible - 1;
|
||||||
|
}
|
||||||
|
if ((icon->previous.x != icon->current.x) ||
|
||||||
|
(icon->previous.y != icon->current.y))
|
||||||
|
{
|
||||||
int fx, fy;
|
int fx, fy;
|
||||||
int iw, ih;
|
int iw, ih;
|
||||||
double tw, th;
|
double tw, th;
|
||||||
|
|
||||||
if (!icon->changed) return;
|
|
||||||
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->x + ((iw - tw) / 2);
|
fx = icon->current.x + ((iw - tw) / 2);
|
||||||
fy = icon->y + ih;
|
fy = icon->current.y + ih;
|
||||||
evas_move(icon->view->evas, icon->obj.icon, icon->x, icon->y);
|
evas_move(icon->view->evas, icon->obj.icon, icon->current.x, icon->current.y);
|
||||||
evas_move(icon->view->evas, icon->obj.filename, fx, fy);
|
evas_move(icon->view->evas, icon->obj.filename, fx, fy);
|
||||||
icon->changed = 0;
|
evas_set_color(icon->view->evas, icon->obj.filename, 0, 0, 0, 255);
|
||||||
if (icon->view)
|
printf("create filename (%s %i %i)\n", icon->file, fx, fy);
|
||||||
{
|
|
||||||
icon->view->changed = 1;
|
|
||||||
}
|
}
|
||||||
|
if (icon->current.visible != icon->previous.visible)
|
||||||
|
{
|
||||||
|
if (icon->current.visible)
|
||||||
|
{
|
||||||
|
evas_show(icon->view->evas, icon->obj.icon);
|
||||||
|
evas_show(icon->view->evas, icon->obj.filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
evas_hide(icon->view->evas, icon->obj.icon);
|
||||||
|
evas_hide(icon->view->evas, icon->obj.filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ e_file_get_file(char *file)
|
||||||
char *p;
|
char *p;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
p = strchr(file, '/');
|
p = strrchr(file, '/');
|
||||||
if (!p) return strdup(file);
|
if (!p) return strdup(file);
|
||||||
return strdup(&(p[1]));
|
return strdup(&(p[1]));
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ e_file_get_dir(char *file)
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
strcpy(buf, file);
|
strcpy(buf, file);
|
||||||
p = strchr(buf, '/');
|
p = strrchr(buf, '/');
|
||||||
if (!p) return strdup(file);
|
if (!p) return strdup(file);
|
||||||
*p = 0;
|
*p = 0;
|
||||||
return strdup(buf);
|
return strdup(buf);
|
||||||
|
|
83
src/view.c
83
src/view.c
|
@ -385,16 +385,13 @@ e_view_file_added(int id, char *file)
|
||||||
/* filter files here */
|
/* filter files here */
|
||||||
if (!e_view_filter_file(v, file)) return;
|
if (!e_view_filter_file(v, file)) return;
|
||||||
icon = e_icon_new();
|
icon = e_icon_new();
|
||||||
icon->file = strdup(file);
|
e_icon_set_filename(icon, file);
|
||||||
icon->x = rand()%(v->size.w - 60);
|
e_icon_set_xy(icon, rand()%(v->size.w - 60), rand()%(v->size.h - 60));
|
||||||
icon->y = rand()%(v->size.h - 60);
|
e_icon_show(icon);
|
||||||
icon->changed = 1;
|
e_icon_set_icon(icon, PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/normal");
|
||||||
icon->visible = 1;
|
|
||||||
icon->icon = strdup(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);
|
||||||
/* errr - efsd dont do stat yet */
|
efsd_stat(e_fs_get_connection(), buf);
|
||||||
/* efsd_stat(e_fs_get_connection(), buf); */
|
|
||||||
v->changed = 1;
|
v->changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,6 +424,43 @@ e_view_find_icon_by_file(E_View *v, char *file)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
E_Icon *
|
||||||
|
e_view_find_icon_by_path(char *path)
|
||||||
|
{
|
||||||
|
char *dir;
|
||||||
|
char *file;
|
||||||
|
Evas_List l;
|
||||||
|
|
||||||
|
dir = e_file_get_dir(path);
|
||||||
|
file = e_file_get_file(path);
|
||||||
|
|
||||||
|
for (l = views; l; l = l->next)
|
||||||
|
{
|
||||||
|
Evas_List ll;
|
||||||
|
|
||||||
|
E_View *v;
|
||||||
|
v = l->data;
|
||||||
|
if (!strcmp(v->dir, dir))
|
||||||
|
{
|
||||||
|
for (ll = v->icons; ll; ll = ll->next)
|
||||||
|
{
|
||||||
|
E_Icon *icon;
|
||||||
|
|
||||||
|
icon = ll->data;
|
||||||
|
if (!strcmp(file, icon->file))
|
||||||
|
{
|
||||||
|
IF_FREE(dir);
|
||||||
|
IF_FREE(file);
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IF_FREE(dir);
|
||||||
|
IF_FREE(file);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_view_handle_fs(EfsdEvent *ev)
|
e_view_handle_fs(EfsdEvent *ev)
|
||||||
{
|
{
|
||||||
|
@ -482,8 +516,31 @@ e_view_handle_fs(EfsdEvent *ev)
|
||||||
case CHMOD:
|
case CHMOD:
|
||||||
break;
|
break;
|
||||||
case STAT:
|
case STAT:
|
||||||
printf("Stat event %i\n",
|
printf("Stat event %i stating file %s\n",
|
||||||
ev->efsd_reply_event.command.efsd_file_cmd.id);
|
ev->efsd_reply_event.command.efsd_file_cmd.id,
|
||||||
|
ev->efsd_reply_event.command.efsd_file_cmd.file);
|
||||||
|
{
|
||||||
|
struct stat *st;
|
||||||
|
E_Icon *icon;
|
||||||
|
|
||||||
|
st = (struct stat*) ev->efsd_reply_event.data;
|
||||||
|
|
||||||
|
if (S_ISREG(st->st_mode))
|
||||||
|
printf("%s is a regular file.\n",
|
||||||
|
ev->efsd_reply_event.command.efsd_file_cmd.file);
|
||||||
|
if (S_ISLNK(st->st_mode))
|
||||||
|
printf("%s is a symlink.\n",
|
||||||
|
ev->efsd_reply_event.command.efsd_file_cmd.file);
|
||||||
|
if (S_ISDIR(st->st_mode))
|
||||||
|
printf("%s is a directory.\n",
|
||||||
|
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 (S_ISDIR(st->st_mode))
|
||||||
|
e_icon_set_icon(icon, PACKAGE_DATA_DIR"/data/icons/directory/default.db:/icon/normal");
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CLOSE:
|
case CLOSE:
|
||||||
break;
|
break;
|
||||||
|
@ -575,11 +632,11 @@ e_view_scroll(E_View *v, int dx, int dy)
|
||||||
for (l = v->icons; l; l = l->next)
|
for (l = v->icons; l; l = l->next)
|
||||||
{
|
{
|
||||||
E_Icon *icon;
|
E_Icon *icon;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
icon = l->data;
|
icon = l->data;
|
||||||
icon->x += dx;
|
e_icon_get_xy(icon, &x, &y);
|
||||||
icon->y += dy;
|
e_icon_set_xy(icon, x + dx, y + dy);
|
||||||
icon->changed = 1;
|
|
||||||
}
|
}
|
||||||
v->changed = 1;
|
v->changed = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue