Enlightenment CVS committal
Author : raster
Project : e17
Module : apps/e
Dir : e17/apps/e/src/bin
Modified Files:
e_fm.c e_fm.h e_fm_mime.c e_fm_mime.h e_int_config_mime.c
Log Message:
fix list remove. add cache flush. use it.
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -3 -r1.104 -r1.105
--- e_fm.c 3 Nov 2006 12:04:51 -0000 1.104
+++ e_fm.c 4 Nov 2006 02:31:52 -0000 1.105
@@ -14,17 +14,25 @@
* custom frames or icons yet
*/
-typedef enum
+typedef enum _E_Fm2_Action_Type
{
FILE_ADD,
FILE_DEL,
FILE_CHANGE
} E_Fm2_Action_Type;
-
+
+typedef enum _E_Fm2_Fop_Type
+{
+ FOP_DELETE,
+ FOP_MOVE
+} E_Fm2_Fop_Type;
+
typedef struct _E_Fm2_Smart_Data E_Fm2_Smart_Data;
typedef struct _E_Fm2_Region E_Fm2_Region;
typedef struct _E_Fm2_Icon E_Fm2_Icon;
typedef struct _E_Fm2_Action E_Fm2_Action;
+typedef struct _E_Fm2_Fop E_Fm2_Fop;
+typedef struct _E_Fm2_Fop_Item E_Fm2_Fop_Item;
struct _E_Fm2_Smart_Data
{
@@ -98,6 +106,8 @@
char *buf;
} typebuf;
+ E_Fm2_Fop *fop;
+
E_Object *eobj;
E_Drop_Handler *drop_handler;
E_Fm2_Icon *drop_icon;
@@ -152,6 +162,23 @@
int flags;
};
+struct _E_Fm2_Fop
+{
+ Evas_Object *obj;
+ const char *dir;
+ Evas_List *items;
+ Ecore_Idler *idler;
+};
+
+struct _E_Fm2_Fop_Item
+{
+ E_Fm2_Fop_Type type;
+ E_Fm2_Fop *fop;
+ const char *file;
+ DIR *dir;
+ unsigned char is_dir : 1;
+};
+
static const char *_e_fm2_dev_path_map(const char *dev, const char *path);
static void _e_fm2_file_add(Evas_Object *obj, char *file, int unique, char
*file_rel, int after);
static void _e_fm2_file_del(Evas_Object *obj, char *file);
@@ -271,6 +298,7 @@
static char *_e_fm2_meta_path = NULL;
static Evas_Smart *_e_fm2_smart = NULL;
static Evas_List *_e_fm2_list = NULL;
+static Evas_List *_e_fm2_fop_list = NULL;
/* externally accessible functions */
EAPI int
@@ -726,10 +754,185 @@
}
EAPI void
+e_fm2_all_icons_update(void)
+{
+ /* FIXME: implement - update all icons as config changes */
+}
+
+static E_Fm2_Fop *_e_fm2_fop_add(E_Fm2_Smart_Data *sd);
+static void _e_fm2_fop_del(E_Fm2_Fop *fop);
+static void _e_fm2_fop_detach(E_Fm2_Smart_Data *sd);
+static int _e_fm2_fop_process(E_Fm2_Fop *fop);
+static int _e_fm2_cb_fop_idler(void *data);
+static int _e_fm2_cb_fop_timer(void *data);
+
+static E_Fm2_Fop *
+_e_fm2_fop_add(E_Fm2_Smart_Data *sd)
+{
+ if (!sd->fop)
+ {
+ sd->fop = E_NEW(E_Fm2_Fop, 1);
+ if (!sd->fop) return NULL;
+ sd->fop->obj = sd->obj;
+ sd->fop->dir = evas_stringshare_add(e_fm2_real_path_get(sd->obj));
+ if (!sd->fop->dir)
+ {
+ free(sd->fop);
+ sd->fop = NULL;
+ return NULL;
+ }
+ sd->fop->idler = ecore_idler_add(_e_fm2_cb_fop_idler, sd->fop);
+ if (!sd->fop->idler)
+ {
+ evas_stringshare_del(sd->fop->dir);
+ free(sd->fop);
+ sd->fop = NULL;
+ return NULL;
+ }
+ /* FIXME: add a timer that updates the fop->obj to the current
+ * file being deleted and spin the wheel
+ */
+ }
+ _e_fm2_fop_list = evas_list_append(_e_fm2_fop_list, sd->fop);
+ return sd->fop;
+}
+
+static void
+_e_fm2_fop_del(E_Fm2_Fop *fop)
+{
+ if (fop->idler)
+ {
+ ecore_idler_del(fop->idler);
+ fop->idler = NULL;
+ }
+ /* FIXME: delete timer */
+ if (fop->dir)
+ {
+ evas_stringshare_del(fop->dir);
+ fop->dir = NULL;
+ }
+ if (fop->obj)
+ {
+ E_Fm2_Smart_Data *sd;
+
+ sd = evas_object_smart_data_get(fop->obj);
+ if (sd) sd->fop = NULL;
+ fop->obj = NULL;
+ }
+ _e_fm2_fop_list = evas_list_remove(_e_fm2_fop_list, fop);
+ free(fop);
+}
+
+static void
+_e_fm2_fop_detach(E_Fm2_Smart_Data *sd)
+{
+ if (!sd->fop) return;
+ sd->fop->obj = NULL;
+ sd->fop = NULL;
+}
+
+static int
+_e_fm2_fop_process(E_Fm2_Fop *fop)
+{
+ E_Fm2_Fop_Item *fi, *fi2;
+ char buf[4096];
+ struct dirent *dp;
+
+ if (fop->items) return 0;
+ fi = fop->items->data;
+ switch (fi->type)
+ {
+ case FOP_DELETE:
+ if (fi->dir)
+ {
+ dp = readdir(fi->dir);
+ if (!dp)
+ {
+ snprintf(buf, sizeof(buf), "%s/%s", fi->fop->dir, fi->file);
+ ecore_file_rmdir(buf);
+ }
+ else
+ {
+ if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name,
".."))) return 1;
+ fi2 = E_NEW(E_Fm2_Fop_Item, 1);
+ fi2->fop = fop;
+ fi2->type = FOP_DELETE;
+ snprintf(buf, sizeof(buf), "%s/%s/%s", fi->fop->dir,
fi->file, dp->d_name);
+ fi2->is_dir = ecore_file_is_dir(buf);
+ snprintf(buf, sizeof(buf), "%s/%s", fi->file, dp->d_name);
+ fi2->file = evas_stringshare_add(buf);
+ fi->fop->items = evas_list_prepend(fi->fop->items, fi2);
+ return 1;
+ }
+ }
+ else if (fi->is_dir)
+ {
+ snprintf(buf, sizeof(buf), "%s/%s", fi->fop->dir, fi->file);
+ fi->dir = opendir(buf);
+ if (!fi->dir)
+ ecore_file_rmdir(buf);
+ else
+ return 1;
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), "%s/%s", fi->fop->dir, fi->file);
+ ecore_file_unlink(buf);
+ }
+ break;
+ case FOP_MOVE:
+ /* FIXME: */
+ break;
+ default:
+ break;
+ }
+ /* remove and free */
+ fop->items = evas_list_remove_list(fop->items, fop->items);
+ if (fi->file)
+ {
+ evas_stringshare_del(fi->file);
+ fi->file = NULL;
+ }
+ if (fi->dir)
+ {
+ closedir(fi->dir);
+ fi->dir = NULL;
+ }
+ free(fi);
+ if (fop->items) return 0;
+ return 1;
+}
+
+static int
+_e_fm2_cb_fop_idler(void *data)
+{
+ E_Fm2_Fop *fop;
+
+ fop = data;
+ if (!_e_fm2_fop_process(fop))
+ {
+ _e_fm2_fop_del(fop);
+ return 0;
+ }
+ return 1;
+}
+
+static int
+_e_fm2_cb_fop_timer(void *data)
+{
+ E_Fm2_Fop *fop;
+
+ fop = data;
+ return 1;
+}
+
+EAPI void
e_fm2_fop_delete_add(Evas_Object *obj, E_Fm2_Icon_Info *ici)
{
E_Fm2_Smart_Data *sd;
-
+ E_Fm2_Fop *fop;
+ E_Fm2_Fop_Item *fi;
+
sd = evas_object_smart_data_get(obj);
if (!sd) return; // safety
if (!evas_object_type_get(obj)) return; // safety
@@ -751,6 +954,15 @@
* per fop item processed, if obj is attached to fop - report status usig
* the status overlay for the fm edj obj.
*/
+ fop = _e_fm2_fop_add(sd);
+ if (!fop) return;
+
+ fi = E_NEW(E_Fm2_Fop_Item, 1);
+ fi->fop = fop;
+ fi->type = FOP_DELETE;
+ fi->file = evas_stringshare_add(ici->file);
+ if (S_ISDIR(ici->statinfo.st_mode)) fi->is_dir = 1;
+ fi->fop->items = evas_list_append(fi->fop->items, fi);
}
/* FIXME: not so easy with .orders etc. */
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- e_fm.h 1 Nov 2006 12:52:49 -0000 1.28
+++ e_fm.h 4 Nov 2006 02:31:52 -0000 1.29
@@ -139,5 +139,6 @@
EAPI void e_fm2_pan_max_get(Evas_Object *obj, Evas_Coord *x,
Evas_Coord *y);
EAPI void e_fm2_pan_child_size_get(Evas_Object *obj,
Evas_Coord *w, Evas_Coord *h);
+EAPI void e_fm2_all_icons_update(void);
#endif
#endif
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm_mime.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- e_fm_mime.c 22 Sep 2006 19:55:11 -0000 1.9
+++ e_fm_mime.c 4 Nov 2006 02:31:53 -0000 1.10
@@ -69,20 +69,10 @@
const char *homedir = NULL;
Evas_List *l;
E_Config_Mime_Icon *mi;
- Evas_List *freelist = NULL;
- /* 0.0 clean out hash cache once it has mroe than 256 entried in it */
- if (evas_hash_size(icon_map) > 256)
- {
- evas_hash_foreach(icon_map, _e_fm_mime_icon_foreach, &freelist);
- while (freelist)
- {
- evas_stringshare_del(freelist->data);
- freelist = evas_list_remove_list(freelist, freelist);
- }
- evas_hash_free(icon_map);
- icon_map = NULL;
- }
+ /* 0.0 clean out hash cache once it has mroe than 512 entries in it */
+ if (evas_hash_size(icon_map) > 512) e_fm_mime_icon_cache_flush();
+
/* 0. look in mapping cache */
val = evas_hash_find(icon_map, mime);
if (val) return val;
@@ -149,6 +139,21 @@
icon_map = evas_hash_add(icon_map, mime, val);
return val;
+}
+
+EAPI void
+e_fm_mime_icon_cache_flush(void)
+{
+ Evas_List *freelist = NULL;
+
+ evas_hash_foreach(icon_map, _e_fm_mime_icon_foreach, &freelist);
+ while (freelist)
+ {
+ evas_stringshare_del(freelist->data);
+ freelist = evas_list_remove_list(freelist, freelist);
+ }
+ evas_hash_free(icon_map);
+ icon_map = NULL;
}
/* local subsystem functions */
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm_mime.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- e_fm_mime.h 16 Sep 2006 11:35:54 -0000 1.2
+++ e_fm_mime.h 4 Nov 2006 02:31:53 -0000 1.3
@@ -9,6 +9,7 @@
EAPI const char *e_fm_mime_filename_get(const char *fname);
EAPI const char *e_fm_mime_icon_get(const char *mime);
+EAPI void e_fm_mime_icon_cache_flush(void);
#endif
#endif
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_int_config_mime.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- e_int_config_mime.c 4 Nov 2006 02:04:39 -0000 1.8
+++ e_int_config_mime.c 4 Nov 2006 02:31:53 -0000 1.9
@@ -277,14 +277,15 @@
mi = l->data;
if (!mi) continue;
if (strcmp(mi->mime, cfdata->sel_mt)) continue;
- if (mi->mime)
- evas_stringshare_del(mi->mime);
- if (mi->icon)
- evas_stringshare_del(mi->icon);
- e_config->mime_icons = evas_list_remove_list(e_config->mime_icons,
- e_config->mime_icons);
+ if (mi->mime) evas_stringshare_del(mi->mime);
+ if (mi->icon) evas_stringshare_del(mi->icon);
+ e_config->mime_icons = evas_list_remove_list(e_config->mime_icons, l);
break;
}
+ e_config_save_queue();
+ e_fm_mime_icon_cache_flush();
+ e_fm2_all_icons_update();
+
_fill_data(cfdata);
_fill_list(cfdata);
}
@@ -319,6 +320,8 @@
e_config->mime_icons = evas_list_append(e_config->mime_icons, mime);
e_config_save_queue();
+ e_fm_mime_icon_cache_flush();
+ e_fm2_all_icons_update();
_fill_data(cfdata);
_fill_list(cfdata);
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs