icosn are now much mroe state-like :)

SVN revision: 4234
This commit is contained in:
Carsten Haitzler 2001-02-16 21:31:59 +00:00
parent 7eb27c4c7d
commit 36bb6c0019
4 changed files with 204 additions and 61 deletions

27
src/e.h
View File

@ -356,12 +356,22 @@ struct _E_Icon
E_View *view;
int x, y, w, h;
struct {
int text_location;
int show_text;
int show_icon;
} options;
int x, y, w, h;
struct {
int text_location;
int show_text;
int show_icon;
} options;
struct {
int clicked;
int selected;
int hilited;
} state;
char *icon;
int visible;
} current, previous;
struct {
Evas_Object icon;
Evas_Object filename;
@ -371,13 +381,6 @@ struct _E_Icon
Ebits_Object base_icon;
Ebits_Object base_text;
} obj;
struct {
int clicked;
int selected;
int hilited;
} state;
char *icon;
int visible;
int changed;
};

View File

@ -4,7 +4,8 @@ void
e_icon_free(E_Icon *icon)
{
IF_FREE(icon->file);
IF_FREE(icon->icon);
IF_FREE(icon->current.icon);
IF_FREE(icon->previous.icon);
FREE(icon);
}
@ -28,26 +29,6 @@ e_icon_calulcate_geometry(E_Icon *icon)
void
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
@ -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.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
e_icon_update(E_Icon *icon)
{
int fx, fy;
int iw, ih;
double tw, th;
if (!icon->changed) return;
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);
fx = icon->x + ((iw - tw) / 2);
fy = icon->y + ih;
evas_move(icon->view->evas, icon->obj.icon, icon->x, icon->y);
evas_move(icon->view->evas, icon->obj.filename, fx, fy);
icon->changed = 0;
if (icon->view)
if (((icon->current.icon) && (icon->previous.icon) &&
(strcmp(icon->current.icon, icon->previous.icon))) ||
(!icon->current.icon) || (!icon->previous.icon))
{
icon->view->changed = 1;
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 iw, ih;
double 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);
fx = icon->current.x + ((iw - tw) / 2);
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.filename, fx, fy);
evas_set_color(icon->view->evas, icon->obj.filename, 0, 0, 0, 255);
printf("create filename (%s %i %i)\n", icon->file, fx, fy);
}
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;
}

View File

@ -94,7 +94,7 @@ e_file_get_file(char *file)
char *p;
char buf[4096];
p = strchr(file, '/');
p = strrchr(file, '/');
if (!p) return strdup(file);
return strdup(&(p[1]));
}
@ -106,7 +106,7 @@ e_file_get_dir(char *file)
char buf[4096];
strcpy(buf, file);
p = strchr(buf, '/');
p = strrchr(buf, '/');
if (!p) return strdup(file);
*p = 0;
return strdup(buf);

View File

@ -385,16 +385,13 @@ e_view_file_added(int id, char *file)
/* filter files here */
if (!e_view_filter_file(v, file)) return;
icon = e_icon_new();
icon->file = strdup(file);
icon->x = rand()%(v->size.w - 60);
icon->y = rand()%(v->size.h - 60);
icon->changed = 1;
icon->visible = 1;
icon->icon = strdup(PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/normal");
e_icon_set_filename(icon, file);
e_icon_set_xy(icon, rand()%(v->size.w - 60), rand()%(v->size.h - 60));
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);
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;
}
@ -427,6 +424,43 @@ e_view_find_icon_by_file(E_View *v, char *file)
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
e_view_handle_fs(EfsdEvent *ev)
{
@ -482,8 +516,31 @@ e_view_handle_fs(EfsdEvent *ev)
case CHMOD:
break;
case STAT:
printf("Stat event %i\n",
ev->efsd_reply_event.command.efsd_file_cmd.id);
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.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;
case CLOSE:
break;
@ -575,11 +632,11 @@ e_view_scroll(E_View *v, int dx, int dy)
for (l = v->icons; l; l = l->next)
{
E_Icon *icon;
int x, y;
icon = l->data;
icon->x += dx;
icon->y += dy;
icon->changed = 1;
e_icon_get_xy(icon, &x, &y);
e_icon_set_xy(icon, x + dx, y + dy);
}
v->changed = 1;
}