new loader system and fix a bug
* the new picture loader system is much more light and fast :) Its inspirated from the file scan of efm2 * fix a typo * free the config data descriptors * fix a bug when you try to restart loading while thumbnailing SVN revision: 24132
This commit is contained in:
parent
3ab2f63b56
commit
435ed6d2d0
2
TODO
2
TODO
|
@ -4,13 +4,13 @@ make install CFLAGS="-g -Wall -DDEBUG -DDEBUG_MAIN -DDEBUG_CONFIG -DDEBUG_ITEM -
|
||||||
BUGS
|
BUGS
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
|
|
||||||
|
* sometimes the histo menu seems not to show the popup info
|
||||||
|
|
||||||
|
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
NEEDED
|
NEEDED
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
|
|
||||||
* fix thumbnailing messages : too much !
|
|
||||||
* option to set the thumb size, and no thumb mode
|
* option to set the thumb size, and no thumb mode
|
||||||
|
|
||||||
* find a way to have the path of a generated thumb, to load it direcly
|
* find a way to have the path of a generated thumb, to load it direcly
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Enlightenment Eveil Module theme */
|
/* Enlightenment Photo Module theme */
|
||||||
|
|
||||||
images
|
images
|
||||||
{
|
{
|
||||||
|
|
|
@ -266,8 +266,5 @@ static int _theme_init(void)
|
||||||
|
|
||||||
static void _theme_shutdown(void)
|
static void _theme_shutdown(void)
|
||||||
{
|
{
|
||||||
if (photo->theme)
|
|
||||||
{
|
|
||||||
E_FREE(photo->theme);
|
E_FREE(photo->theme);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,6 +170,10 @@ int photo_config_shutdown(void)
|
||||||
|
|
||||||
E_FREE(photo->config);
|
E_FREE(photo->config);
|
||||||
|
|
||||||
|
E_CONFIG_DD_FREE(_photo_edd);
|
||||||
|
E_CONFIG_DD_FREE(_photo_dir_edd);
|
||||||
|
E_CONFIG_DD_FREE(_photo_item_edd);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ typedef struct _Photo_Item Photo_Item;
|
||||||
#define ITEM_SHOW_LABEL_PARENT 2
|
#define ITEM_SHOW_LABEL_PARENT 2
|
||||||
|
|
||||||
#define ITEM_MOUSE_OVER_ACTION_DEFAULT 1
|
#define ITEM_MOUSE_OVER_ACTION_DEFAULT 1
|
||||||
#define ITEM_MOUSE_LEFT_ACTION_DEFAULT 2
|
#define ITEM_MOUSE_LEFT_ACTION_DEFAULT 4
|
||||||
#define ITEM_MOUSE_MIDDLE_ACTION_DEFAULT 7
|
#define ITEM_MOUSE_MIDDLE_ACTION_DEFAULT 2
|
||||||
|
|
||||||
#define ITEM_ACTION_NO 0
|
#define ITEM_ACTION_NO 0
|
||||||
#define ITEM_ACTION_LABEL 1
|
#define ITEM_ACTION_LABEL 1
|
||||||
|
|
|
@ -27,7 +27,7 @@ void photo_picture_shutdown(void)
|
||||||
//photo_picture_net_shutdown();
|
//photo_picture_net_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
Picture *photo_picture_new(char *path, char *name, int thumb_it, void (*func_done) (void *data, Evas_Object *obj, void *event_info))
|
Picture *photo_picture_new(char *path, int thumb_it, void (*func_done) (void *data, Evas_Object *obj, void *event_info))
|
||||||
{
|
{
|
||||||
Picture *picture;
|
Picture *picture;
|
||||||
int th_w, th_h;
|
int th_w, th_h;
|
||||||
|
@ -36,7 +36,7 @@ Picture *photo_picture_new(char *path, char *name, int thumb_it, void (*func_don
|
||||||
th_w = photo->config->pictures_thumb_size;
|
th_w = photo->config->pictures_thumb_size;
|
||||||
th_h = photo->config->pictures_thumb_size;
|
th_h = photo->config->pictures_thumb_size;
|
||||||
|
|
||||||
ext = strrchr(name, '.');
|
ext = strrchr(path, '.');
|
||||||
if (!ext)
|
if (!ext)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (strcasecmp(ext, ".jpg") && strcasecmp(ext, ".JPG") &&
|
if (strcasecmp(ext, ".jpg") && strcasecmp(ext, ".JPG") &&
|
||||||
|
@ -44,11 +44,11 @@ Picture *photo_picture_new(char *path, char *name, int thumb_it, void (*func_don
|
||||||
strcasecmp(ext, ".png") && strcasecmp(ext, ".PNG"))
|
strcasecmp(ext, ".png") && strcasecmp(ext, ".PNG"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
DPICL(("New picture : file %s", name));
|
DPICL(("New picture : file %s", path));
|
||||||
|
|
||||||
picture = E_NEW(Picture, 1);
|
picture = E_NEW(Picture, 1);
|
||||||
picture->path = evas_stringshare_add(path);
|
picture->path = evas_stringshare_add(path);
|
||||||
picture->infos.name = photo_picture_name_get(name);
|
picture->infos.name = photo_picture_name_get(path);
|
||||||
picture->from = PICTURE_LOCAL;
|
picture->from = PICTURE_LOCAL;
|
||||||
|
|
||||||
if (thumb_it)
|
if (thumb_it)
|
||||||
|
|
|
@ -62,7 +62,7 @@ struct _Picture_Event_Fill
|
||||||
int photo_picture_init(void);
|
int photo_picture_init(void);
|
||||||
void photo_picture_shutdown(void);
|
void photo_picture_shutdown(void);
|
||||||
|
|
||||||
Picture *photo_picture_new(char *path, char *name, int thumb_it, void (*func_done) (void *data, Evas_Object *obj, void *event_info));
|
Picture *photo_picture_new(char *path, int thumb_it, void (*func_done) (void *data, Evas_Object *obj, void *event_info));
|
||||||
int photo_picture_free(Picture *p, int force, int force_now);
|
int photo_picture_free(Picture *p, int force, int force_now);
|
||||||
|
|
||||||
int photo_picture_load(Picture *pic, Evas *evas);
|
int photo_picture_load(Picture *pic, Evas *evas);
|
||||||
|
|
|
@ -37,13 +37,16 @@ struct _Picture_Local_List
|
||||||
/* ecore idler to load in background */
|
/* ecore idler to load in background */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
Evas_List *queue;
|
||||||
|
|
||||||
Ecore_Idler *idler;
|
Ecore_Idler *idler;
|
||||||
|
Ecore_Timer *timer;
|
||||||
Popup_Warn *popup;
|
Popup_Warn *popup;
|
||||||
|
|
||||||
Picture_Local_Dir *current_dir;
|
Picture_Local_Dir *current_dir;
|
||||||
|
|
||||||
Evas_List *dirs;
|
Evas_List *dirs;
|
||||||
Ecore_List *file;
|
DIR *odir;
|
||||||
} loader;
|
} loader;
|
||||||
|
|
||||||
/* event to warn photo items wich are waiting for pictures */
|
/* event to warn photo items wich are waiting for pictures */
|
||||||
|
@ -60,6 +63,7 @@ static Picture_Local_List *pictures_local;
|
||||||
static void _pictures_old_del(int force, int force_now);
|
static void _pictures_old_del(int force, int force_now);
|
||||||
|
|
||||||
static int _load_idler(void *data);
|
static int _load_idler(void *data);
|
||||||
|
static int _load_timer(void *data);
|
||||||
static void _load_idler_stop(void);
|
static void _load_idler_stop(void);
|
||||||
static int _load_cb_ev_fill(void *data, int type, void *event);
|
static int _load_cb_ev_fill(void *data, int type, void *event);
|
||||||
|
|
||||||
|
@ -122,7 +126,9 @@ void photo_picture_local_load_start(void)
|
||||||
pictures_local->thumb.popup = NULL;
|
pictures_local->thumb.popup = NULL;
|
||||||
|
|
||||||
/* initialise and launch loader */
|
/* initialise and launch loader */
|
||||||
|
pictures_local->loader.queue = NULL;
|
||||||
pictures_local->loader.idler = ecore_idler_add(_load_idler, NULL);
|
pictures_local->loader.idler = ecore_idler_add(_load_idler, NULL);
|
||||||
|
pictures_local->loader.timer = ecore_timer_add(0.2, _load_timer, NULL);
|
||||||
|
|
||||||
if (photo->config_dialog)
|
if (photo->config_dialog)
|
||||||
photo_config_dialog_refresh_local_load();
|
photo_config_dialog_refresh_local_load();
|
||||||
|
@ -299,9 +305,10 @@ _load_idler(void *data)
|
||||||
Picture_Local_List *pl;
|
Picture_Local_List *pl;
|
||||||
Picture_Local_Dir *d;
|
Picture_Local_Dir *d;
|
||||||
Evas_List *l;
|
Evas_List *l;
|
||||||
Picture *picture;
|
char *file_tmp;
|
||||||
char *name, *file_tmp;
|
|
||||||
char file[200];
|
char file[200];
|
||||||
|
struct dirent *fs;
|
||||||
|
struct stat fs_stat;
|
||||||
|
|
||||||
pl = pictures_local;
|
pl = pictures_local;
|
||||||
|
|
||||||
|
@ -329,9 +336,7 @@ _load_idler(void *data)
|
||||||
pl->loader.current_dir = d;
|
pl->loader.current_dir = d;
|
||||||
pl->loader.dirs = evas_list_append(pl->loader.dirs,
|
pl->loader.dirs = evas_list_append(pl->loader.dirs,
|
||||||
strdup(d->path));
|
strdup(d->path));
|
||||||
if (pl->loader.file && ecore_list_is_empty(pl->loader.file))
|
pl->loader.odir = NULL;
|
||||||
ecore_list_destroy(pl->loader.file);
|
|
||||||
pl->loader.file = NULL;
|
|
||||||
DPICL(("Going to read %s", d->path));
|
DPICL(("Going to read %s", d->path));
|
||||||
if (photo->config_dialog)
|
if (photo->config_dialog)
|
||||||
photo_config_dialog_refresh_local_dirs();
|
photo_config_dialog_refresh_local_dirs();
|
||||||
|
@ -341,9 +346,7 @@ _load_idler(void *data)
|
||||||
/* no more directories to load */
|
/* no more directories to load */
|
||||||
if (!pl->loader.current_dir)
|
if (!pl->loader.current_dir)
|
||||||
{
|
{
|
||||||
if (pl->loader.file)
|
pl->loader.odir = NULL;
|
||||||
ecore_list_destroy(pl->loader.file);
|
|
||||||
pl->loader.file = NULL;
|
|
||||||
pl->loader.idler = NULL;
|
pl->loader.idler = NULL;
|
||||||
if (photo->config_dialog)
|
if (photo->config_dialog)
|
||||||
{
|
{
|
||||||
|
@ -359,54 +362,81 @@ _load_idler(void *data)
|
||||||
evas_list_count(pl->pictures) - pl->pictures_waiting_delete);
|
evas_list_count(pl->pictures) - pl->pictures_waiting_delete);
|
||||||
POPUP_LOADING(pl, buf, 3);
|
POPUP_LOADING(pl, buf, 3);
|
||||||
}
|
}
|
||||||
|
if (pl->loader.timer)
|
||||||
|
{
|
||||||
|
ecore_timer_del(pl->loader.timer);
|
||||||
|
}
|
||||||
|
pl->loader.timer = ecore_timer_add(0.0001, _load_timer, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* first dir list */
|
/* first dir list */
|
||||||
if ( !pl->loader.file )
|
if ( !pl->loader.odir )
|
||||||
pl->loader.file = ecore_file_ls(evas_list_data(pl->loader.dirs));
|
pl->loader.odir = opendir((char *)evas_list_data(pl->loader.dirs));
|
||||||
|
|
||||||
/* no more files in the current loader.dirs item */
|
/* no more files in the current loader.dirs item */
|
||||||
if ( !(name = ecore_list_next(pl->loader.file)) )
|
if ( !pl->loader.odir || !(fs = readdir(pl->loader.odir)) )
|
||||||
{
|
{
|
||||||
DD(("removing %s", (char *)evas_list_data(pl->loader.dirs)));
|
DD(("removing %s", (char *)evas_list_data(pl->loader.dirs)));
|
||||||
/* go to next dir */
|
/* go to next dir */
|
||||||
ecore_list_destroy(pl->loader.file);
|
closedir(pl->loader.odir);
|
||||||
pl->loader.file = NULL;
|
pl->loader.odir = NULL;
|
||||||
free(evas_list_data(pl->loader.dirs));
|
free(evas_list_data(pl->loader.dirs));
|
||||||
pl->loader.dirs = evas_list_remove_list(pl->loader.dirs,
|
pl->loader.dirs = evas_list_remove_list(pl->loader.dirs,
|
||||||
pl->loader.dirs);
|
pl->loader.dirs);
|
||||||
if (!evas_list_count(pl->loader.dirs))
|
|
||||||
return 1;
|
|
||||||
/* list the new dir */
|
|
||||||
pl->loader.file = ecore_file_ls(evas_list_data(pl->loader.dirs));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( (!strcmp(fs->d_name, ".")) || (!strcmp(fs->d_name, "..")) ||
|
||||||
|
(!pl->loader.current_dir->read_hidden && (fs->d_name[0] == '.')) )
|
||||||
|
return 1;
|
||||||
|
|
||||||
snprintf(file, sizeof(file),
|
snprintf(file, sizeof(file),
|
||||||
"%s/%s", (char *)evas_list_data(pl->loader.dirs), name);
|
"%s/%s", (char *)evas_list_data(pl->loader.dirs), fs->d_name);
|
||||||
|
|
||||||
if (!pl->loader.current_dir->read_hidden && (name[0] == '.'))
|
if (stat(file, &fs_stat) < 0) return 1;
|
||||||
return 1;
|
|
||||||
if ((file_tmp = ecore_file_readlink(file)))
|
if ( (S_ISLNK(fs_stat.st_mode)) &&
|
||||||
|
(file_tmp = ecore_file_readlink(file)) )
|
||||||
{
|
{
|
||||||
name = strdup(ecore_file_get_file(file_tmp));
|
|
||||||
strncpy(file, file_tmp, sizeof(file));
|
strncpy(file, file_tmp, sizeof(file));
|
||||||
|
if (stat(file, &fs_stat) < 0) return 0;
|
||||||
}
|
}
|
||||||
if (pl->loader.current_dir->recursive &&
|
|
||||||
ecore_file_is_dir(file))
|
if ( pl->loader.current_dir->recursive &&
|
||||||
|
(S_ISDIR(fs_stat.st_mode)) )
|
||||||
{
|
{
|
||||||
pl->loader.dirs = evas_list_append(pl->loader.dirs, strdup(file));
|
pl->loader.dirs = evas_list_append(pl->loader.dirs, strdup(file));
|
||||||
DPICL(("added %s to loader dirs", file));
|
DPICL(("added %s to loader dirs", file));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create the picture */
|
/* enqueue the file */
|
||||||
picture = photo_picture_new(file, name, 1, _thumb_generate_cb);
|
pl->loader.queue = evas_list_append(pl->loader.queue, strdup(file));
|
||||||
if (!picture)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_load_timer(void *data)
|
||||||
|
{
|
||||||
|
Picture_Local_List *pl;
|
||||||
|
Picture *picture;
|
||||||
|
char *file;
|
||||||
|
int rounds;
|
||||||
|
|
||||||
|
pl = pictures_local;
|
||||||
|
|
||||||
|
rounds = 0;
|
||||||
|
while(pl->loader.queue)// && (rounds < 50))
|
||||||
|
{
|
||||||
|
file = pl->loader.queue->data;
|
||||||
|
|
||||||
|
/* create the picture */
|
||||||
|
picture = photo_picture_new(file, 1, _thumb_generate_cb);
|
||||||
|
if (picture)
|
||||||
|
{
|
||||||
pl->thumb.nb++;
|
pl->thumb.nb++;
|
||||||
pl->pictures = evas_list_append(pl->pictures, picture);
|
pl->pictures = evas_list_append(pl->pictures, picture);
|
||||||
|
|
||||||
|
@ -428,6 +458,19 @@ _load_idler(void *data)
|
||||||
POPUP_LOADING(pl, buf, 0);
|
POPUP_LOADING(pl, buf, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(file);
|
||||||
|
pl->loader.queue = evas_list_remove_list(pl->loader.queue,
|
||||||
|
pl->loader.queue);
|
||||||
|
rounds++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pl->loader.idler)
|
||||||
|
{
|
||||||
|
pl->loader.timer = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -446,6 +489,11 @@ _load_idler_stop(void)
|
||||||
ecore_idler_del(pl->loader.idler);
|
ecore_idler_del(pl->loader.idler);
|
||||||
pl->loader.idler = NULL;
|
pl->loader.idler = NULL;
|
||||||
}
|
}
|
||||||
|
if (pl->loader.timer)
|
||||||
|
{
|
||||||
|
ecore_timer_del(pl->loader.timer);
|
||||||
|
pl->loader.timer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (pl->loader.popup)
|
if (pl->loader.popup)
|
||||||
{
|
{
|
||||||
|
@ -471,10 +519,9 @@ _load_idler_stop(void)
|
||||||
pl->loader.dirs = NULL;
|
pl->loader.dirs = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->loader.file)
|
if (pl->loader.odir)
|
||||||
{
|
{
|
||||||
ecore_list_destroy(pl->loader.file);
|
pl->loader.odir = NULL;
|
||||||
pl->loader.file = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,8 +563,6 @@ _thumb_generate_cb(void *data, Evas_Object *obj, void *event_info)
|
||||||
pl = pictures_local;
|
pl = pictures_local;
|
||||||
picture = data;
|
picture = data;
|
||||||
|
|
||||||
DPICL(("back from thumb generation of %s", picture->infos.name));
|
|
||||||
|
|
||||||
pl->thumb.nb--;
|
pl->thumb.nb--;
|
||||||
|
|
||||||
if (!obj)
|
if (!obj)
|
||||||
|
@ -532,6 +577,7 @@ _thumb_generate_cb(void *data, Evas_Object *obj, void *event_info)
|
||||||
&picture->original_w, &picture->original_h);
|
&picture->original_w, &picture->original_h);
|
||||||
DPICL(("thumb generated %dx%d", picture->original_w, picture->original_h));
|
DPICL(("thumb generated %dx%d", picture->original_w, picture->original_h));
|
||||||
|
|
||||||
|
|
||||||
picture->thumb = PICTURE_THUMB_READY;
|
picture->thumb = PICTURE_THUMB_READY;
|
||||||
|
|
||||||
/* popups about thumbnailing */
|
/* popups about thumbnailing */
|
||||||
|
@ -544,9 +590,11 @@ _thumb_generate_cb(void *data, Evas_Object *obj, void *event_info)
|
||||||
e_module_dialog_show(photo->module, _("Photo Module Information"),
|
e_module_dialog_show(photo->module, _("Photo Module Information"),
|
||||||
_("<hilight>Creating thumbs</hilight><br><br>"
|
_("<hilight>Creating thumbs</hilight><br><br>"
|
||||||
"Some pictures are being thumbed in a <hilight>background task</hilight>.<br>"
|
"Some pictures are being thumbed in a <hilight>background task</hilight>.<br>"
|
||||||
"It can take a while, but after, loading will be faster :)<br><br>"
|
"It can take a while, but after, loading will be faster and lighter :)<br><br>"
|
||||||
"Each time wou will load pictures that haven't been loaded in Photo module before,<br>"
|
"Each time wou will load pictures that haven't been loaded in Photo module before,<br>"
|
||||||
"they will be thumbed"));
|
"they will be thumbed.<br><br>"
|
||||||
|
"While creating popups, you will not be able to see any picture in Photo.<br>"
|
||||||
|
"I hope i'll be able to change that :)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* when still thumbnailing after loading */
|
/* when still thumbnailing after loading */
|
||||||
|
@ -606,21 +654,24 @@ static void
|
||||||
_thumb_generate_stop(void)
|
_thumb_generate_stop(void)
|
||||||
{
|
{
|
||||||
Picture_Local_List *pl;
|
Picture_Local_List *pl;
|
||||||
Evas_List *l;
|
Picture *p;
|
||||||
Picture *picture;
|
int no = 0;
|
||||||
|
|
||||||
pl = pictures_local;
|
pl = pictures_local;
|
||||||
|
|
||||||
if (pl->thumb.nb)
|
if (pl->thumb.nb)
|
||||||
{
|
{
|
||||||
for (l=pl->pictures; l; l=evas_list_next(l))
|
while ( (p = evas_list_nth(pictures_local->pictures, no)) )
|
||||||
{
|
{
|
||||||
picture = evas_list_data(l);
|
if (p->thumb == PICTURE_THUMB_WAITING)
|
||||||
if (picture->thumb != PICTURE_THUMB_WAITING)
|
{
|
||||||
continue;
|
e_thumb_icon_end(p->picture);
|
||||||
|
photo_picture_free(p, 1, 1);
|
||||||
e_thumb_icon_end(picture->picture);
|
pictures_local->pictures = evas_list_remove(pictures_local->pictures,
|
||||||
photo_picture_free(picture, 1, 1);
|
p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
no++;
|
||||||
}
|
}
|
||||||
pl->thumb.nb = 0;
|
pl->thumb.nb = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue