|
From: <enl...@li...> - 2001-03-25 21:37:11
|
Enlightenment CVS committal
Author : raster
Project : e17
Module : apps/e
Dir : e17/apps/e/src
Modified Files:
fs.c icons.c view.c
Log Message:
use mime types to determine icon.. if u lok in icons - you'll get he idea -
its just mime types exactly splatted out into a dir struct with .db at the
end (falling back to default.db and unknonw/unknown/db in the end if it cant
fall backto default.db)
now what i need is to talk to cK and get the file magic/mime type stuff to
beocme smarter even that it is.. so currently it sees a tar.gz file - it
looks at the magic and boom.. it thinks is a gzip file.. thats correct.. but
theres mroe to it.. now it woudl be good if the magic stuff coudl now also
inspect the inside of the gzip (ie use zlib in this case) and start lookign
ro a tar header to see if tis a tar.gz.... now if it si a tar.gz.. try
getting the file list and seeing if there are telltale signs of it being a
theme tarball or such (though this lats step may be going too far)
efsd definitely needs ot cache mime type though. that much i'm certain of :)
its not fast at all actually doing file magic on every file... every time
the directory is "loaded" :)
but excellent work! another pat on the back for ck :)
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/fs.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- fs.c 2001/03/24 03:18:17 1.9
+++ fs.c 2001/03/25 21:37:09 1.10
@@ -10,7 +10,7 @@
{
double start, current;
- printf("############## fs event...\n");
+/* printf("############## fs event...\n"); */
start = e_get_time();
while ((ec) && efsd_events_pending(ec))
{
@@ -47,7 +47,7 @@
break;
}
}
- printf("############## fs done\n");
+/* printf("############## fs done\n"); */
}
void
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/icons.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- icons.c 2001/03/18 01:16:47 1.15
+++ icons.c 2001/03/25 21:37:09 1.16
@@ -75,7 +75,7 @@
icon = NEW(E_Icon, 1);
ZERO(icon, E_Icon, 1);
OBJ_INIT(icon, e_icon_free);
- icon->info.icon.normal = strdup(PACKAGE_DATA_DIR"/data/icons/file/default.db:/icon/normal");
+ icon->info.icon.normal = strdup(PACKAGE_DATA_DIR"/data/icons/unknown/default.db:/icon/normal");
icon->previous.state.clicked = -1;
return icon;
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/view.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- view.c 2001/03/25 02:47:41 1.27
+++ view.c 2001/03/25 21:37:09 1.28
@@ -422,30 +422,17 @@
/* char buf[4096]; */
/* if we get a path - ignore it - its not a file in the a dir */
- printf("e_view_file_added(%i, \"%s\");\n", id, file);
if (!file) return;
if (file[0] == '/') return;
v = e_view_find_by_monitor_id(id);
if (!v) return;
/* filter files here */
if (!e_view_filter_file(v, file)) return;
+ printf("e_view_file_added(%i, \"%s\");\n", id, file);
icon = e_icon_new();
e_icon_set_filename(icon, file);
e_view_add_icon(v, icon);
- /*
- sprintf(buf, "%s/%s", v->dir, file);
- if (efsd_ready(e_fs_get_connection()))
- {
- printf("Stating %s\n", buf);
- efsd_stat(e_fs_get_connection(), buf);
- }
- else
- {
- printf("*********** EEEEEEEEEEEEEEEEEK Efsd not ready.\n");
- }
- */
-
v->changed = 1;
}
@@ -456,11 +443,14 @@
E_View *v;
/* char *realfile; */
- printf("e_view_file_deleted(%i, \"%s\");\n", id, file);
v = e_view_find_by_monitor_id(id);
if (!v) return;
icon = e_view_find_icon_by_file(v, file);
- if (icon) e_view_del_icon(v, icon);
+ if (icon)
+ {
+ e_view_del_icon(v, icon);
+ printf("e_view_file_deleted(%i, \"%s\");\n", id, file);
+ }
}
E_Icon *
@@ -536,15 +526,15 @@
ev->efsd_filechange_event.file);
break;
case EFSD_CHANGE_CHANGED:
- printf("EFSD_CHANGE_CHANGED: %i %s\n",
+/* printf("EFSD_CHANGE_CHANGED: %i %s\n",
ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file);
- break;
+*/ break;
case EFSD_CHANGE_MOVED:
- printf("EFSD_CHANGE_MOVED: %i %s\n",
+/* printf("EFSD_CHANGE_MOVED: %i %s\n",
ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file);
- break;
+*/ break;
case EFSD_CHANGE_END_EXISTS:
printf("EFSD_CHANGE_END_EXISTS: %i %s\n",
ev->efsd_filechange_event.id,
@@ -569,16 +559,83 @@
break;
case EFSD_CMD_CHMOD:
break;
+ case EFSD_CMD_GETMIME:
+/* printf("Getmime event %i\n",
+ ev->efsd_reply_event.command.efsd_file_cmd.id);
+*/ if (ev->efsd_reply_event.status == SUCCESS)
+ {
+ E_Icon *icon;
+
+ icon = e_view_find_icon_by_path(ev->efsd_reply_event.command.efsd_file_cmd.file);
+ if (icon)
+ {
+ char m1[4096], m2[4096], *p;
+
+ /* figure out icons to use */
+ strcpy(m1, (char*)ev->efsd_reply_event.data);
+ p = strchr(m1, '/');
+ if (p) *p = 0;
+ p = strchr((char*)ev->efsd_reply_event.data, '/');
+ if (p) strcpy(m2, &(p[1]));
+ else m2[0] = 0;
+ icon->info.mime.base = strdup(m1);
+ icon->info.mime.type = strdup(m2);
+
+ printf("%s: %s/%s\n", icon->file, icon->info.mime.base, icon->info.mime.type);
+ sprintf(m1, "%s/data/icons/%s/%s.db",PACKAGE_DATA_DIR,
+ icon->info.mime.base,
+ icon->info.mime.type);
+ if (!e_file_exists(m1))
+ {
+ printf("fallback 1\n");
+ sprintf(m1, "%s/data/icons/%s/default.db",PACKAGE_DATA_DIR,
+ icon->info.mime.base);
+ if (!e_file_exists(m1))
+ {
+ printf("fallback 2\n");
+ sprintf(m1, "%s/data/icons/unknown/unknown.db",PACKAGE_DATA_DIR);
+ if (!e_file_exists(m1))
+ {
+ printf("fallback 3\n");
+ sprintf(m1, "%s/data/icons/unknown/default.db",PACKAGE_DATA_DIR);
+ }
+ }
+ }
+ IF_FREE(icon->info.icon.normal);
+ IF_FREE(icon->info.icon.selected);
+ IF_FREE(icon->info.icon.clicked);
+ sprintf(m2, "%s:/icon/normal", m1);
+ icon->info.icon.normal = strdup(m2);
+ sprintf(m2, "%s:/icon/selected", m1);
+ icon->info.icon.selected = strdup(m2);
+ sprintf(m2, "%s:/icon/clicked", m1);
+ icon->info.icon.clicked = strdup(m2);
+ 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");
+*/ }
+ e_icon_pre_show(icon);
+ }
+ }
+ break;
case EFSD_CMD_STAT:
- printf("Stat event %i stating file %s\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.file);
- {
+*/ {
struct stat *st;
E_Icon *icon;
st = (struct stat*) ev->efsd_reply_event.data;
+ icon = e_view_find_icon_by_path(ev->efsd_reply_event.command.efsd_file_cmd.file);
+ if (icon)
+ {
+ char f[4096];
+
+/*
if (S_ISREG(st->st_mode))
printf("%s is a regular file.\n",
ev->efsd_reply_event.command.efsd_file_cmd.file);
@@ -588,12 +645,7 @@
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)
- {
- char f[4096];
-
- sprintf(f, "%s/%s", icon->view->dir, icon->file);
+*/ 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;
@@ -604,44 +656,14 @@
efsd_readlink(e_fs_get_connection(), 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.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 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
- {
- 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;
icon->view->changed = 1;
- if (!icon->info.link_get_id)
- e_icon_pre_show(icon);
+/* if (!icon->info.link_get_id)
+ e_icon_pre_show(icon);*/
}
}
break;
case EFSD_CMD_READLINK:
- printf("Readlink event %i\n",
- ev->efsd_reply_event.command.efsd_file_cmd.id);
if (ev->efsd_reply_event.status == SUCCESS)
{
Evas_List l;
@@ -779,7 +801,8 @@
/* v->monitor_id = efsd_start_monitor(e_fs_get_connection(), v->dir); */
v->monitor_id = efsd_start_monitor(e_fs_get_connection(), v->dir,
- 1, efsd_op_get_stat());
+ 2, efsd_op_get_stat(),
+ efsd_op_get_mimetype());
v->is_listing = 1;
v->changed = 1;
}
|