images can also be order by last modified time
This commit is contained in:
parent
ad899e49cf
commit
38dbff5bab
|
@ -106,13 +106,13 @@ static void
|
|||
_entice_ctrl_prev_cb(void *win, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Entice *entice;
|
||||
Eina_List *next;
|
||||
Eina_List *prev;
|
||||
|
||||
entice = evas_object_data_get(win, "entice");
|
||||
next = eina_list_prev(entice->image_current);
|
||||
if (next)
|
||||
prev = eina_list_prev(entice->image_current);
|
||||
if (prev)
|
||||
{
|
||||
entice_image_set(entice->image, next);
|
||||
entice_image_file_set(entice->image, prev);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ _entice_ctrl_next_cb(void *win, Evas_Object *obj EINA_UNUSED, void *event_info E
|
|||
next = eina_list_next(entice->image_current);
|
||||
if (next)
|
||||
{
|
||||
entice_image_set(entice->image, next);
|
||||
entice_image_file_set(entice->image, next);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ _entice_exif_key_down_cb(void *win,
|
|||
{
|
||||
if (!strcmp(ev->key, "Escape"))
|
||||
{
|
||||
ERR("exif cb");
|
||||
elm_object_signal_emit(entice->layout, "state,exif,hide", "entice");
|
||||
entice->exif_shown = EINA_FALSE;
|
||||
}
|
||||
|
@ -250,6 +251,7 @@ entice_exif_fill(Evas_Object *win)
|
|||
{
|
||||
char value[1024];
|
||||
Entice *entice;
|
||||
const Entice_List_Data *data;
|
||||
ExifData *ed;
|
||||
ExifContent *ec;
|
||||
ExifEntry *ee;
|
||||
|
@ -260,11 +262,11 @@ entice_exif_fill(Evas_Object *win)
|
|||
evas_object_event_callback_add(entice->frame_exif, EVAS_CALLBACK_KEY_DOWN,
|
||||
_entice_exif_key_down_cb, win);
|
||||
|
||||
ed = exif_data_new_from_file(eina_list_data_get(entice->image_current));
|
||||
data = (const Entice_List_Data *)eina_list_data_get(entice->image_current);
|
||||
ed = exif_data_new_from_file(data->path);
|
||||
if (!ed)
|
||||
{
|
||||
printf("can not get exif data from %s\n",
|
||||
(char *)eina_list_data_get(entice->image_current));
|
||||
WRN("can not get exif data from %s", data->path);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -337,13 +337,13 @@ entice_image_add(Evas_Object *win)
|
|||
}
|
||||
|
||||
void
|
||||
entice_image_set(Evas_Object *obj, Eina_List *image)
|
||||
entice_image_file_set(Evas_Object *obj, Eina_List *image)
|
||||
{
|
||||
Entice *entice;
|
||||
const Entice_List_Data *data;
|
||||
Img *sd;
|
||||
Evas_Object *win;
|
||||
Evas_Load_Error err;
|
||||
const char *filename;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
EINA_SAFETY_ON_NULL_RETURN(sd);
|
||||
|
@ -365,17 +365,17 @@ entice_image_set(Evas_Object *obj, Eina_List *image)
|
|||
return;
|
||||
|
||||
entice->image_current = image;
|
||||
filename = eina_list_data_get(entice->image_current);
|
||||
|
||||
evas_object_image_load_orientation_set(sd->img,
|
||||
entice->config->automatic_orientation);
|
||||
|
||||
evas_object_image_file_set(sd->img, filename, NULL);
|
||||
data = (const Entice_List_Data *)eina_list_data_get(entice->image_current);
|
||||
evas_object_image_file_set(sd->img, data->path, NULL);
|
||||
err = evas_object_image_load_error_get(sd->img);
|
||||
if (err != EVAS_LOAD_ERROR_NONE)
|
||||
{
|
||||
ERR("Could not load image '%s' : \"%s\"\n",
|
||||
filename, evas_load_error_str(err));
|
||||
data->path, evas_load_error_str(err));
|
||||
ERR("Verify that the Evas loader is available for this image if you think it is a valid image");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef enum
|
|||
|
||||
Evas_Object *entice_image_add(Evas_Object *win);
|
||||
|
||||
void entice_image_set(Evas_Object *obj, Eina_List *image);
|
||||
void entice_image_file_set(Evas_Object *obj, Eina_List *image);
|
||||
|
||||
const char *entice_image_file_get(Evas_Object *obj);
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ void entice_key_handle(Evas_Object *win, Evas_Event_Key_Down *ev)
|
|||
next = eina_list_next(entice->image_current);
|
||||
if (next)
|
||||
{
|
||||
entice_image_set(entice->image, next);
|
||||
entice_image_file_set(entice->image, next);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(ev->key, "BackSpace") ||
|
||||
|
@ -87,7 +87,7 @@ void entice_key_handle(Evas_Object *win, Evas_Event_Key_Down *ev)
|
|||
prev = eina_list_prev(entice->image_current);
|
||||
if (prev)
|
||||
{
|
||||
entice_image_set(entice->image, prev);
|
||||
entice_image_file_set(entice->image, prev);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(ev->key, "plus"))
|
||||
|
@ -177,11 +177,11 @@ void entice_key_handle(Evas_Object *win, Evas_Event_Key_Down *ev)
|
|||
{
|
||||
if (!strcmp(ev->key, "Home"))
|
||||
{
|
||||
entice_image_set(entice->image, entice->images);
|
||||
entice_image_file_set(entice->image, entice->images);
|
||||
}
|
||||
else if (!strcmp(ev->key, "End"))
|
||||
{
|
||||
entice_image_set(entice->image, eina_list_last(entice->images));
|
||||
entice_image_file_set(entice->image, eina_list_last(entice->images));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,16 +201,40 @@ _entice_translate_options(void)
|
|||
#endif
|
||||
|
||||
static int
|
||||
_entice_compare_name(const void *data1, const void *data2)
|
||||
_entice_compare_path(const void *data1, const void *data2)
|
||||
{
|
||||
return strcmp((const char *)data1, (const char *)data2);
|
||||
const Entice_List_Data *d1;
|
||||
const Entice_List_Data *d2;
|
||||
|
||||
d1 = (const Entice_List_Data *)data1;
|
||||
d2 = (const Entice_List_Data *)data2;
|
||||
return strcmp(d1->path, d2->path);
|
||||
}
|
||||
|
||||
static Eina_Compare_Cb _entice_compare_default = _entice_compare_name;
|
||||
static int
|
||||
_entice_compare_date(const void *data1, const void *data2)
|
||||
{
|
||||
const Entice_List_Data *d1;
|
||||
const Entice_List_Data *d2;
|
||||
|
||||
d1 = (const Entice_List_Data *)data1;
|
||||
d2 = (const Entice_List_Data *)data2;
|
||||
|
||||
if (d1->date < d2->date)
|
||||
return 1;
|
||||
|
||||
else if (d1->date > d2->date)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Eina_Compare_Cb _entice_compare_default = _entice_compare_path;
|
||||
|
||||
static Eina_List *
|
||||
_file_list_append(Eina_List *list, const char *path, Eina_Bool sort)
|
||||
_file_list_append(Eina_List *list, const char *path, unsigned long mtime, Eina_Bool sort)
|
||||
{
|
||||
Entice_List_Data *data;
|
||||
Eina_Bool found = EINA_FALSE;
|
||||
|
||||
/* check if the file has a supported extension */
|
||||
|
@ -229,11 +253,25 @@ _file_list_append(Eina_List *list, const char *path, Eina_Bool sort)
|
|||
return list;
|
||||
}
|
||||
INF("File %s added.", path);
|
||||
|
||||
data = calloc(1, sizeof(Entice_List_Data));
|
||||
if (!data)
|
||||
{
|
||||
WRN("Can not allocate data for %s.", path);
|
||||
return list;
|
||||
}
|
||||
|
||||
data->path = eina_stringshare_add(path);
|
||||
data->date = mtime;
|
||||
|
||||
if (sort)
|
||||
list = eina_list_sorted_insert(list, _entice_compare_default,
|
||||
eina_stringshare_add(path));
|
||||
{
|
||||
list = eina_list_sorted_insert(list, _entice_compare_default, data);
|
||||
}
|
||||
else
|
||||
list = eina_list_append(list, eina_stringshare_add(path));
|
||||
{
|
||||
list = eina_list_append(list, data);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
@ -248,12 +286,20 @@ _dir_parse(Eina_List *list, const char *path)
|
|||
if (!path || !*path)
|
||||
return list;
|
||||
|
||||
it = eina_file_direct_ls(path);
|
||||
it = eina_file_stat_ls(path);
|
||||
EINA_ITERATOR_FOREACH(it, info)
|
||||
{
|
||||
if (info->type == EINA_FILE_REG)
|
||||
{
|
||||
list = _file_list_append(list, info->path, EINA_TRUE);
|
||||
Eina_Stat buf;
|
||||
int ret;
|
||||
|
||||
ret = eina_file_statat(eina_iterator_container_get(it),
|
||||
info, &buf);
|
||||
if (ret == 0)
|
||||
{
|
||||
list = _file_list_append(list, info->path, buf.mtime, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
eina_iterator_free(it);
|
||||
|
@ -326,6 +372,18 @@ elm_main(int argc, char **argv)
|
|||
printf(" config order : %d\n", cfg->order);
|
||||
fflush(stdout);
|
||||
|
||||
switch (cfg->order)
|
||||
{
|
||||
case 0:
|
||||
_entice_compare_default = _entice_compare_path;
|
||||
break;
|
||||
case 1:
|
||||
_entice_compare_default = _entice_compare_date;
|
||||
break;
|
||||
default:
|
||||
_entice_compare_default = _entice_compare_path;
|
||||
}
|
||||
|
||||
list = NULL;
|
||||
if (args == argc)
|
||||
{
|
||||
|
@ -365,7 +423,7 @@ elm_main(int argc, char **argv)
|
|||
for (i = args; i < argc; i++)
|
||||
{
|
||||
char *path = _path_uri_decode(argv[i]);
|
||||
list = _file_list_append(list, path, EINA_FALSE);
|
||||
list = _file_list_append(list, path, 0UL, EINA_FALSE);
|
||||
free(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -395,7 +395,7 @@ entice_win_image_first_set(Evas_Object *win, Eina_List *first)
|
|||
Entice *entice;
|
||||
|
||||
entice = evas_object_data_get(win, "entice");
|
||||
entice_image_set(entice->image, first);
|
||||
entice_image_file_set(entice->image, first);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -426,8 +426,7 @@ entice_win_filename_copy(Evas_Object *win)
|
|||
const char *filename;
|
||||
|
||||
entice = evas_object_data_get(win, "entice");
|
||||
|
||||
filename = (char *)eina_list_data_get(entice->image_current);
|
||||
filename = entice_image_file_get(entice->image);
|
||||
if (filename)
|
||||
{
|
||||
elm_cnp_selection_set(win,
|
||||
|
@ -441,16 +440,12 @@ void
|
|||
entice_win_file_copy(Evas_Object *win)
|
||||
{
|
||||
Entice *entice;
|
||||
const char *filename;
|
||||
Eina_File *f;
|
||||
void *base;
|
||||
size_t length;
|
||||
|
||||
entice = evas_object_data_get(win, "entice");
|
||||
|
||||
filename = (char *)eina_list_data_get(entice->image_current);
|
||||
/* if filename is NULL, eina_file_open() returns NULL */
|
||||
f = eina_file_open(filename, EINA_FALSE);
|
||||
f = eina_file_open(entice_image_file_get(entice->image), EINA_FALSE);
|
||||
if (f)
|
||||
{
|
||||
base = eina_file_map_all(f, EINA_FILE_POPULATE);
|
||||
|
|
|
@ -28,8 +28,15 @@
|
|||
#define ENTICE_WIN_H
|
||||
|
||||
typedef struct Entice Entice;
|
||||
typedef struct Entice_List_Data Entice_List_Data;
|
||||
typedef struct Entice_Hover_Menu_Item Entice_Hover_Menu_Item;
|
||||
|
||||
struct Entice_List_Data
|
||||
{
|
||||
const char *path;
|
||||
unsigned long date;
|
||||
};
|
||||
|
||||
struct Entice_Hover_Menu_Item
|
||||
{
|
||||
Elm_Widget_Item *item;
|
||||
|
|
Loading…
Reference in New Issue