and some major refinements of efm - the selector code - well its in e_test.c


			
			
				devs/princeamd/enlightenment-0.17-elive
			
			
		
Carsten Haitzler 17 years ago
parent 03cca925e3
commit 01efbd7683
  1. 8
      src/bin/Makefile.am
  2. 394
      src/bin/e_fm.c
  3. 21
      src/bin/e_fm.h
  4. 1
      src/bin/e_includes.h
  5. 107
      src/bin/e_sha1.c
  6. 35
      src/bin/e_sha1.h
  7. 94
      src/bin/e_test.c
  8. 10
      src/bin/e_thumb.c
  9. 143
      src/bin/e_thumb_main.c
  10. 71
      src/bin/e_utils.c
  11. 3
      src/bin/e_utils.h
  12. 27
      src/bin/e_widget_scrollframe.c
  13. 3
      src/bin/e_widget_scrollframe.h

@ -164,7 +164,8 @@ e_confirm_dialog.h \
e_int_border_prop.h \
e_entry_dialog.h \
e_fm.h \
e_widget_scrollframe.h
e_widget_scrollframe.h \
e_sha1.h
enlightenment_src = \
e_user.c \
@ -305,6 +306,7 @@ e_int_border_prop.c \
e_entry_dialog.c \
e_fm.c \
e_widget_scrollframe.c \
e_sha1.c \
$(ENLIGHTENMENTHEADERS)
enlightenment_SOURCES = \
@ -345,7 +347,9 @@ e_start_main.c
enlightenment_start_LDFLAGS =
enlightenment_thumb_SOURCES = \
e_thumb_main.c
e_thumb_main.c \
e_sha1.c \
e_sha1.h
enlightenment_thumb_LDFLAGS = @e_libs@ @dlopen_libs@

@ -3,7 +3,11 @@
*/
#include "e.h"
/* IGNORE this code for now! */
/* FIXME: this is NOT complete. dnd doesnt work. only list view works.
* in icon view it needs to be much better about placement of icons and
* being able to save/load icon placement. it doesn't support backgrounds or
* custom frames or icons yet
*/
typedef struct _E_Fm2_Smart_Data E_Fm2_Smart_Data;
typedef struct _E_Fm2_Region E_Fm2_Region;
@ -57,20 +61,14 @@ struct _E_Fm2_Icon
Evas_Object *obj, *obj_icon;
int saved_x, saved_y;
int saved_rel;
const char *file;
const char *mime;
const char *label;
const char *comment;
const char *generic;
const char *icon;
const char *link;
struct stat st;
E_Fm2_Icon_Info info;
unsigned char realized : 1;
unsigned char selected : 1;
unsigned char last_selected : 1;
unsigned char saved_pos : 1;
unsigned char odd : 1;
unsigned char mount : 1;
};
static const char *_e_fm2_dev_path_map(const char *dev, const char *path);
@ -189,31 +187,33 @@ e_fm2_path_set(Evas_Object *obj, char *dev, char *path)
/* internal config for now - don't see a pont making this configurable */
sd->regions.member_max = 32;
if (sd->config) _e_fm2_config_free(sd->config);
sd->config = E_NEW(E_Fm2_Config, 1);
if (!sd->config) return;
if (!sd->config)
{
sd->config = E_NEW(E_Fm2_Config, 1);
if (!sd->config) return;
// sd->config->view.mode = E_FM2_VIEW_MODE_ICONS;
sd->config->view.mode = E_FM2_VIEW_MODE_LIST;
sd->config->view.open_dirs_in_place = 1;
sd->config->view.selector = 1;
sd->config->view.single_click = 0;
sd->config->view.no_subdir_jump = 0;
sd->config->icon.icon.w = 64;
sd->config->icon.icon.h = 64;
sd->config->icon.list.w = 24;
sd->config->icon.list.h = 24;
sd->config->icon.fixed.w = 1;
sd->config->icon.fixed.h = 1;
sd->config->icon.extension.show = 0;
sd->config->list.sort.no_case = 1;
sd->config->list.sort.dirs.first = 1;
sd->config->list.sort.dirs.last = 1;
sd->config->selection.single = 0;
sd->config->selection.windows_modifiers = 0;
sd->config->theme.background = NULL;
sd->config->theme.frame = NULL;
sd->config->theme.icons = NULL;
sd->config->theme.fixed = 0;
sd->config->view.mode = E_FM2_VIEW_MODE_LIST;
sd->config->view.open_dirs_in_place = 1;
sd->config->view.selector = 1;
sd->config->view.single_click = 0;
sd->config->view.no_subdir_jump = 0;
sd->config->icon.icon.w = 64;
sd->config->icon.icon.h = 64;
sd->config->icon.list.w = 24;
sd->config->icon.list.h = 24;
sd->config->icon.fixed.w = 1;
sd->config->icon.fixed.h = 1;
sd->config->icon.extension.show = 0;
sd->config->list.sort.no_case = 1;
sd->config->list.sort.dirs.first = 1;
sd->config->list.sort.dirs.last = 0;
sd->config->selection.single = 0;
sd->config->selection.windows_modifiers = 0;
sd->config->theme.background = NULL;
sd->config->theme.frame = NULL;
sd->config->theme.icons = NULL;
sd->config->theme.fixed = 0;
}
_e_fm2_scan_stop(obj);
_e_fm2_queue_free(obj);
@ -226,7 +226,6 @@ e_fm2_path_set(Evas_Object *obj, char *dev, char *path)
if (dev) sd->dev = evas_stringshare_add(dev);
sd->path = evas_stringshare_add(path);
sd->realpath = _e_fm2_dev_path_map(sd->dev, sd->path);
printf("FM: %s\n", sd->realpath);
_e_fm2_scan_start(obj);
evas_object_smart_callback_call(obj, "changed", NULL);
}
@ -260,6 +259,18 @@ e_fm2_has_parent_get(Evas_Object *obj)
return 1;
}
EAPI const char *
e_fm2_real_path_get(Evas_Object *obj)
{
E_Fm2_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return NULL; // safety
if (!evas_object_type_get(obj)) return NULL; // safety
if (strcmp(evas_object_type_get(obj), "e_fm")) return NULL; // safety
return sd->realpath;
}
EAPI void
e_fm2_parent_go(Evas_Object *obj)
{
@ -280,7 +291,6 @@ e_fm2_parent_go(Evas_Object *obj)
E_FREE(path);
}
/*
EAPI void
e_fm2_config_set(Evas_Object *obj, E_Fm2_Config *cfg)
{
@ -290,6 +300,15 @@ e_fm2_config_set(Evas_Object *obj, E_Fm2_Config *cfg)
if (!sd) return; // safety
if (!evas_object_type_get(obj)) return; // safety
if (strcmp(evas_object_type_get(obj), "e_fm")) return; // safety
if (sd->config) _e_fm2_config_free(sd->config);
sd->config = NULL;
if (!cfg) return;
sd->config = E_NEW(E_Fm2_Config, 1);
if (!sd->config) return;
memcpy(sd->config, cfg, sizeof(E_Fm2_Config));
if (cfg->theme.background) sd->config->theme.background = evas_stringshare_add(cfg->theme.background);
if (cfg->theme.frame) sd->config->theme.frame = evas_stringshare_add(cfg->theme.frame);
if (cfg->theme.icons) sd->config->theme.icons = evas_stringshare_add(cfg->theme.icons);
}
EAPI E_Fm2_Config *
@ -297,12 +316,79 @@ e_fm2_config_get(Evas_Object *obj)
{
E_Fm2_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return NULL; // safety
if (!evas_object_type_get(obj)) return NULL; // safety
if (strcmp(evas_object_type_get(obj), "e_fm")) return NULL; // safety
return sd->config;
}
EAPI Evas_List *
e_fm2_selected_list_get(Evas_Object *obj)
{
E_Fm2_Smart_Data *sd;
Evas_List *list = NULL, *l;
E_Fm2_Icon *ic;
sd = evas_object_smart_data_get(obj);
if (!sd) return NULL; // safety
if (!evas_object_type_get(obj)) return NULL; // safety
if (strcmp(evas_object_type_get(obj), "e_fm")) return NULL; // safety
for (l = sd->icons; l; l = l->next)
{
ic = l->data;
if (ic->selected)
list = evas_list_append(list, &(ic->info));
}
return list;
}
EAPI Evas_List *
e_fm2_all_list_get(Evas_Object *obj)
{
E_Fm2_Smart_Data *sd;
Evas_List *list = NULL, *l;
E_Fm2_Icon *ic;
sd = evas_object_smart_data_get(obj);
if (!sd) return NULL; // safety
if (!evas_object_type_get(obj)) return NULL; // safety
if (strcmp(evas_object_type_get(obj), "e_fm")) return NULL; // safety
for (l = sd->icons; l; l = l->next)
{
ic = l->data;
list = evas_list_append(list, &(ic->info));
}
return list;
}
EAPI void
e_fm2_select_set(Evas_Object *obj, char *file, int select)
{
E_Fm2_Smart_Data *sd;
Evas_List *l;
E_Fm2_Icon *ic;
sd = evas_object_smart_data_get(obj);
if (!sd) return; // safety
if (!evas_object_type_get(obj)) return; // safety
if (strcmp(evas_object_type_get(obj), "e_fm")) return; // safety
for (l = sd->icons; l; l = l->next)
{
ic = l->data;
if (!strcmp(ic->info.file, file))
{
if (select) _e_fm2_icon_select(ic);
else _e_fm2_icon_deselect(ic);
}
else
{
if (ic->sd->config->view.single_click)
_e_fm2_icon_deselect(ic);
ic->last_selected = 0;
}
}
}
*/
EAPI void
e_fm2_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
@ -320,7 +406,6 @@ e_fm2_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
if ((sd->pos.x == x) && (sd->pos.y == y)) return;
sd->pos.x = x;
sd->pos.y = y;
printf("POS %i %i\n", x, y);
if (sd->scroll_job) ecore_job_del(sd->scroll_job);
sd->scroll_job = ecore_job_add(_e_fm2_cb_scroll_job, obj);
}
@ -398,6 +483,19 @@ _e_fm2_dev_path_map(const char *dev, const char *path)
PRT("%s%s", s, path);
free(s);
}
else if (dev[0] == '/') {
/* dev is a full path - consider it a mountpoint device on its own */
PRT("%s%s", dev, path);
}
else if (CMP("favorites")) {
/* this is a virtual device - it's where your favorites list is
* stored - a dir with .desktop files or symlinks (in fact anything
* you like
*/
s = e_user_homedir_get();
PRT("%s/.e/e/fileman/favorites", s);
free(s);
}
else if (CMP("dvd") || CMP("dvd-*")) {
/* FIXME: find dvd mountpoint optionally for dvd no. X */
/* maybe make part of the device mappings config? */
@ -524,6 +622,7 @@ _e_fm2_queue_process(Evas_Object *obj)
sd->icons = evas_list_sort(sd->icons, evas_list_count(sd->icons), _e_fm2_cb_icon_sort);
if (sd->resize_job) ecore_job_del(sd->resize_job);
sd->resize_job = ecore_job_add(_e_fm2_cb_resize_job, obj);
evas_object_smart_callback_call(sd->obj, "files_changed", NULL);
}
static void
@ -866,21 +965,25 @@ _e_fm2_icon_new(E_Fm2_Smart_Data *sd, char *file)
E_Fm2_Icon *ic;
Evas_Coord mw = 0, mh = 0;
Evas_Object *obj, *obj2;
char buf[4096], buf2[4096];
char buf[4096], *lnk;
/* create icon */
ic = E_NEW(E_Fm2_Icon, 1);
snprintf(buf, sizeof(buf), "%s/%s", sd->realpath, file);
if (stat(buf, &(ic->st)) == -1)
if (stat(buf, &(ic->info.statinfo)) == -1)
{
free(ic);
return NULL;
}
ic->sd = sd;
ic->file = evas_stringshare_add(file);
if (readlink(buf, buf2, sizeof(buf2) - 1) == 0)
ic->link = evas_stringshare_add(buf2);
if (e_util_glob_case_match(ic->file, "*.desktop"))
ic->info.file = evas_stringshare_add(file);
lnk = ecore_file_readlink(buf);
if (lnk)
{
ic->info.link = evas_stringshare_add(lnk);
free(lnk);
}
if (e_util_glob_case_match(ic->info.file, "*.desktop"))
_e_fm2_icon_desktop_load(ic);
switch (sd->config->view.mode)
{
@ -956,13 +1059,13 @@ _e_fm2_icon_free(E_Fm2_Icon *ic)
{
/* free icon, object data etc. etc. */
_e_fm2_icon_unrealize(ic);
if (ic->file) evas_stringshare_del(ic->file);
if (ic->mime) evas_stringshare_del(ic->mime);
if (ic->label) evas_stringshare_del(ic->label);
if (ic->comment) evas_stringshare_del(ic->comment);
if (ic->generic) evas_stringshare_del(ic->generic);
if (ic->icon) evas_stringshare_del(ic->icon);
if (ic->link) evas_stringshare_del(ic->link);
if (ic->info.file) evas_stringshare_del(ic->info.file);
if (ic->info.mime) evas_stringshare_del(ic->info.mime);
if (ic->info.label) evas_stringshare_del(ic->info.label);
if (ic->info.comment) evas_stringshare_del(ic->info.comment);
if (ic->info.generic) evas_stringshare_del(ic->info.generic);
if (ic->info.icon) evas_stringshare_del(ic->info.icon);
if (ic->info.link) evas_stringshare_del(ic->info.link);
free(ic);
}
@ -1065,20 +1168,20 @@ _e_fm2_icon_label_set(E_Fm2_Icon *ic, Evas_Object *obj)
char buf[4096], *p;
int len;
if (ic->label)
if (ic->info.label)
{
edje_object_part_text_set(obj, "label", ic->label);
edje_object_part_text_set(obj, "label", ic->info.label);
return;
}
if (ic->sd->config->icon.extension.show)
edje_object_part_text_set(obj, "label", ic->file);
edje_object_part_text_set(obj, "label", ic->info.file);
else
{
/* remove extension. handle double extensions like .tar.gz too
* also be fuzzy - up to 4 chars of extn is ok - eg .html but 5 or
* more is considered part of the name
*/
strncpy(buf, ic->file, sizeof(buf) - 2);
strncpy(buf, ic->info.file, sizeof(buf) - 2);
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
@ -1101,30 +1204,30 @@ _e_fm2_icon_icon_set(E_Fm2_Icon *ic)
char buf[4096];
if (!ic->realized) return;
if (ic->icon)
if (ic->info.icon)
{
/* custom icon */
/* FIXME:
* if ic->icon == blah then use theme icon
* if ic->icon == blah/blah2 then use theme icon
* if ic->icon == /blah/blah2.xxx then use full path
* if ic->icon == blah.xxx then use relative path to icon dirs
* if ic->icon == blah/blah2.xxx then use relative path to icon dirs
* if ic->info.icon == blah then use theme icon
* if ic->info.icon == blah/blah2 then use theme icon
* if ic->info.icon == /blah/blah2.xxx then use full path
* if ic->info.icon == blah.xxx then use relative path to icon dirs
* if ic->info.icon == blah/blah2.xxx then use relative path to icon dirs
*/
/* theme icon */
ic->obj_icon = edje_object_add(evas_object_evas_get(ic->sd->obj));
e_util_edje_icon_set(ic->obj_icon, ic->icon);
e_util_edje_icon_set(ic->obj_icon, ic->info.icon);
edje_object_part_swallow(ic->obj, "icon_swallow", ic->obj_icon);
evas_object_show(ic->obj_icon);
return;
}
if (ic->mime)
if (ic->info.mime)
{
/* use mime type to select icon */
return;
}
/* fallback */
if (S_ISDIR(ic->st.st_mode))
if (S_ISDIR(ic->info.statinfo.st_mode))
{
ic->obj_icon = edje_object_add(evas_object_evas_get(ic->sd->obj));
e_theme_edje_object_set(ic->obj_icon, "base/theme/fileman",
@ -1135,48 +1238,48 @@ _e_fm2_icon_icon_set(E_Fm2_Icon *ic)
else
{
if (
(e_util_glob_case_match(ic->file, "*.jpg")) ||
(e_util_glob_case_match(ic->file, "*.jpeg")) ||
(e_util_glob_case_match(ic->file, "*.jfif")) ||
(e_util_glob_case_match(ic->file, "*.jpe")) ||
(e_util_glob_case_match(ic->file, "*.png")) ||
(e_util_glob_case_match(ic->file, "*.gif")) ||
(e_util_glob_case_match(ic->file, "*.tif")) ||
(e_util_glob_case_match(ic->file, "*.tiff"))
(e_util_glob_case_match(ic->info.file, "*.jpg")) ||
(e_util_glob_case_match(ic->info.file, "*.jpeg")) ||
(e_util_glob_case_match(ic->info.file, "*.jfif")) ||
(e_util_glob_case_match(ic->info.file, "*.jpe")) ||
(e_util_glob_case_match(ic->info.file, "*.png")) ||
(e_util_glob_case_match(ic->info.file, "*.gif")) ||
(e_util_glob_case_match(ic->info.file, "*.tif")) ||
(e_util_glob_case_match(ic->info.file, "*.tiff"))
)
{
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->file);
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->info.file);
ic->obj_icon = e_thumb_icon_add(evas_object_evas_get(ic->sd->obj));
e_thumb_icon_file_set(ic->obj_icon, buf, NULL);
e_thumb_icon_size_set(ic->obj_icon, 64, 64);
evas_object_smart_callback_add(ic->obj_icon, "e_thumb_gen", _e_fm2_cb_icon_thumb_gen, ic);
e_thumb_icon_begin(ic->obj_icon);
if (_e_fm2_icon_visible(ic)) e_thumb_icon_begin(ic->obj_icon);
edje_object_part_swallow(ic->obj, "icon_swallow", ic->obj_icon);
evas_object_show(ic->obj_icon);
}
else if (
(e_util_glob_case_match(ic->file, "*.edj"))
(e_util_glob_case_match(ic->info.file, "*.edj"))
)
{
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->file);
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->info.file);
ic->obj_icon = e_thumb_icon_add(evas_object_evas_get(ic->sd->obj));
e_thumb_icon_file_set(ic->obj_icon, buf, "desktop/background");
e_thumb_icon_size_set(ic->obj_icon, 64, 64);
evas_object_smart_callback_add(ic->obj_icon, "e_thumb_gen", _e_fm2_cb_icon_thumb_gen, ic);
e_thumb_icon_begin(ic->obj_icon);
if (_e_fm2_icon_visible(ic)) e_thumb_icon_begin(ic->obj_icon);
edje_object_part_swallow(ic->obj, "icon_swallow", ic->obj_icon);
evas_object_show(ic->obj_icon);
}
else if (
(e_util_glob_case_match(ic->file, "*.eap"))
(e_util_glob_case_match(ic->info.file, "*.eap"))
)
{
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->file);
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->info.file);
ic->obj_icon = e_thumb_icon_add(evas_object_evas_get(ic->sd->obj));
e_thumb_icon_file_set(ic->obj_icon, buf, "icon");
e_thumb_icon_size_set(ic->obj_icon, 64, 64);
evas_object_smart_callback_add(ic->obj_icon, "e_thumb_gen", _e_fm2_cb_icon_thumb_gen, ic);
e_thumb_icon_begin(ic->obj_icon);
if (_e_fm2_icon_visible(ic)) e_thumb_icon_begin(ic->obj_icon);
edje_object_part_swallow(ic->obj, "icon_swallow", ic->obj_icon);
evas_object_show(ic->obj_icon);
}
@ -1221,50 +1324,16 @@ _e_fm2_icon_deselect(E_Fm2_Icon *ic)
static const char *
_e_fm2_icon_desktop_url_eval(const char *val)
{
char *path, *p, buf[4096], *pd, *e1, *e2;
char *path, *p, *s;
if (strlen(val) < 6) return NULL;
if (strncmp(val, "file:", 5)) return NULL;
path = val + 5;
buf[0] = 0;
p = path;
pd = buf;
e1 = e2 = NULL;
/* FIXME: evaluate any shell vars - eg:
* $XX/blah/$HOME/blah2/$A$B
*/
while (*p)
{
/*
if (*p == '$')
{
if (e1)
{
e2 = p;
e1 = NULL;
e2 = NULL;
}
else
e1 = p + 1;
}
else if (e1)
{
if (!(isalnum(*p) || (*p == '_')))
{
e2 = p;
e1 = NULL;
e2 = NULL;
}
}
*/
*pd = *p;
p++;
pd++;
}
*pd = 0;
return evas_stringshare_add(buf);
path = (char *)val + 5;
p = e_util_shell_env_path_eval(path);
if (!p) return NULL;
s = evas_stringshare_add(p);
free(p);
return s;
}
static int
@ -1273,21 +1342,24 @@ _e_fm2_icon_desktop_load(E_Fm2_Icon *ic)
char buf[4096], key[256], val[4096];
FILE *f;
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->file);
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->info.file);
f = fopen(buf, "rb");
if (!f) return 0;
if (!fgets(buf, sizeof(buf), f)) goto error;
if (strcmp(buf, "[Desktop Entry]\n")) goto error;
while (fscanf(f, "%255[^=]=%4095[^\n]\n", key, val) == 2)
{
printf("%s=%s\n", key, val);
if (!strcmp(key, "Name")) ic->label = evas_stringshare_add(val);
else if (!strcmp(key, "Comment")) ic->comment = evas_stringshare_add(val);
else if (!strcmp(key, "Generic")) ic->generic = evas_stringshare_add(val);
else if (!strcmp(key, "Icon")) ic->icon = evas_stringshare_add(val);
if (!strcmp(key, "Name"))
ic->info.label = evas_stringshare_add(val);
else if (!strcmp(key, "Comment"))
ic->info.comment = evas_stringshare_add(val);
else if (!strcmp(key, "Generic"))
ic->info.generic = evas_stringshare_add(val);
else if (!strcmp(key, "Icon"))
ic->info.icon = evas_stringshare_add(val);
else if (!strcmp(key, "Type"))
{
if (!strcmp(val, "Mount")) ic->mount = 1;
if (!strcmp(val, "Mount")) ic->info.mount = 1;
else if (!strcmp(val, "Link"))
{
}
@ -1295,25 +1367,25 @@ _e_fm2_icon_desktop_load(E_Fm2_Icon *ic)
goto error;
}
else if (!strcmp(key, "File"))
ic->link = _e_fm2_icon_desktop_url_eval(val);
ic->info.link = _e_fm2_icon_desktop_url_eval(val);
else if (!strcmp(key, "URL"))
ic->link = _e_fm2_icon_desktop_url_eval(val);
ic->info.link = _e_fm2_icon_desktop_url_eval(val);
else if (!strcmp(key, "Path"))
ic->link = _e_fm2_icon_desktop_url_eval(val);
ic->info.link = _e_fm2_icon_desktop_url_eval(val);
}
fclose(f);
return 1;
error:
if (ic->label) evas_stringshare_del(ic->label);
if (ic->comment) evas_stringshare_del(ic->comment);
if (ic->generic) evas_stringshare_del(ic->generic);
if (ic->icon) evas_stringshare_del(ic->icon);
if (ic->link) evas_stringshare_del(ic->link);
ic->label = NULL;
ic->comment = NULL;
ic->generic = NULL;
ic->icon = NULL;
ic->link = NULL;
if (ic->info.label) evas_stringshare_del(ic->info.label);
if (ic->info.comment) evas_stringshare_del(ic->info.comment);
if (ic->info.generic) evas_stringshare_del(ic->info.generic);
if (ic->info.icon) evas_stringshare_del(ic->info.icon);
if (ic->info.link) evas_stringshare_del(ic->info.link);
ic->info.label = NULL;
ic->info.comment = NULL;
ic->info.generic = NULL;
ic->info.icon = NULL;
ic->info.link = NULL;
fclose(f);
return 0;
}
@ -1347,13 +1419,18 @@ static void
_e_fm2_region_realize(E_Fm2_Region *rg)
{
Evas_List *l;
E_Fm2_Icon *ic;
if (rg->realized) return;
/* actually create evas objects etc. */
rg->realized = 1;
printf("REG %p REALIZE\n", rg);
edje_freeze();
for (l = rg->list; l; l = l->next) _e_fm2_icon_realize(l->data);
for (l = rg->list; l; l = l->next)
{
ic = l->data;
if (ic->selected) evas_object_raise(ic->obj);
}
edje_thaw();
}
@ -1365,7 +1442,6 @@ _e_fm2_region_unrealize(E_Fm2_Region *rg)
if (!rg->realized) return;
/* delete evas objects */
rg->realized = 0;
printf("REG %p UNREALIZE\n", rg);
edje_freeze();
for (l = rg->list; l; l = l->next) _e_fm2_icon_unrealize(l->data);
edje_thaw();
@ -1404,7 +1480,7 @@ _e_fm2_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_inf
{
/* if its a directory && open dirs in-place is set then change the dir
* to be the dir + file */
if ((S_ISDIR(ic->st.st_mode)) &&
if ((S_ISDIR(ic->info.statinfo.st_mode)) &&
(ic->sd->config->view.open_dirs_in_place) &&
(!ic->sd->config->view.no_subdir_jump) &&
(!ic->sd->config->view.single_click)
@ -1413,7 +1489,7 @@ _e_fm2_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_inf
char buf[4096], *dev = NULL;
if (ic->sd->dev) dev = strdup(ic->sd->dev);
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->path, ic->file);
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->path, ic->info.file);
e_fm2_path_set(ic->sd->obj, dev, buf);
E_FREE(dev);
}
@ -1507,7 +1583,8 @@ _e_fm2_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_inf
_e_fm2_icon_deselect(ic);
else
_e_fm2_icon_select(ic);
if (!(S_ISDIR(ic->st.st_mode)) &&
if ((!(S_ISDIR(ic->info.statinfo.st_mode)) ||
(ic->sd->config->view.no_subdir_jump)) &&
(ic->sd->config->view.single_click)
)
{
@ -1556,7 +1633,6 @@ _e_fm2_cb_scroll_job(void *data)
sd = evas_object_smart_data_get(data);
if (!sd) return;
sd->scroll_job = NULL;
printf("DO scroll!\n");
evas_event_freeze(evas_object_evas_get(sd->obj));
edje_freeze();
_e_fm2_regions_eval(sd->obj);
@ -1625,19 +1701,21 @@ _e_fm2_cb_icon_sort(void *data1, void *data2)
ic1 = data1;
ic2 = data2;
if (ic1->sd->config->list.sort.dirs.last)
if (ic1->sd->config->list.sort.dirs.first)
{
if ((S_ISDIR(ic1->st.st_mode)) != (S_ISDIR(ic2->st.st_mode)))
if ((S_ISDIR(ic1->info.statinfo.st_mode)) !=
(S_ISDIR(ic2->info.statinfo.st_mode)))
{
if (S_ISDIR(ic1->st.st_mode)) return -1;
if (S_ISDIR(ic1->info.statinfo.st_mode)) return -1;
else return 1;
}
}
else if (ic1->sd->config->list.sort.dirs.first)
else if (ic1->sd->config->list.sort.dirs.last)
{
if ((S_ISDIR(ic1->st.st_mode)) != (S_ISDIR(ic2->st.st_mode)))
if ((S_ISDIR(ic1->info.statinfo.st_mode)) !=
(S_ISDIR(ic2->info.statinfo.st_mode)))
{
if (S_ISDIR(ic1->st.st_mode)) return 1;
if (S_ISDIR(ic1->info.statinfo.st_mode)) return 1;
else return -1;
}
}
@ -1645,8 +1723,8 @@ _e_fm2_cb_icon_sort(void *data1, void *data2)
{
char buf1[4096], buf2[4096], *p;
strncpy(buf1, ic1->file, sizeof(buf1) - 2);
strncpy(buf2, ic2->file, sizeof(buf2) - 2);
strncpy(buf1, ic1->info.file, sizeof(buf1) - 2);
strncpy(buf2, ic2->info.file, sizeof(buf2) - 2);
buf1[sizeof(buf1) - 1] = 0;
buf2[sizeof(buf2) - 1] = 0;
p = buf1;
@ -1663,7 +1741,7 @@ _e_fm2_cb_icon_sort(void *data1, void *data2)
}
return strcmp(buf1, buf2);
}
return strcmp(ic1->file, ic2->file);
return strcmp(ic1->info.file, ic2->info.file);
}
static int
@ -1741,6 +1819,10 @@ _e_fm2_obj_icons_place(E_Fm2_Smart_Data *sd)
sd->x + ic->x - sd->pos.x,
sd->y + ic->y - sd->pos.y);
evas_object_resize(ic->obj, ic->w, ic->h);
if (_e_fm2_icon_visible(ic))
e_thumb_icon_begin(ic->obj_icon);
else
e_thumb_icon_end(ic->obj_icon);
}
}
}

@ -15,7 +15,8 @@ typedef enum _E_Fm2_View_Mode
E_FM2_VIEW_MODE_LIST /* vertical fileselector list */
} E_Fm2_View_Mode;
typedef struct _E_Fm2_Config E_Fm2_Config;
typedef struct _E_Fm2_Config E_Fm2_Config;
typedef struct _E_Fm2_Icon_Info E_Fm2_Icon_Info;
#else
#ifndef E_FM_H
@ -81,13 +82,31 @@ struct _E_Fm2_Config
} geometry;
};
struct _E_Fm2_Icon_Info
{
const char *file;
const char *mime;
const char *label;
const char *comment;
const char *generic;
const char *icon;
const char *link;
struct stat statinfo;
unsigned char mount : 1;
};
EAPI int e_fm2_init(void);
EAPI int e_fm2_shutdown(void);
EAPI Evas_Object *e_fm2_add(Evas *evas);
EAPI void e_fm2_path_set(Evas_Object *obj, char *dev, char *path);
EAPI void e_fm2_path_get(Evas_Object *obj, const char **dev, const char **path);
EAPI const char *e_fm2_real_path_get(Evas_Object *obj);
EAPI int e_fm2_has_parent_get(Evas_Object *obj);
EAPI void e_fm2_parent_go(Evas_Object *obj);
EAPI void e_fm2_config_set(Evas_Object *obj, E_Fm2_Config *cfg);
EAPI E_Fm2_Config *e_fm2_config_get(Evas_Object *obj);
EAPI Evas_List *e_fm2_selected_list_get(Evas_Object *obj);
EAPI Evas_List *e_fm2_all_list_get(Evas_Object *obj);
EAPI void e_fm2_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
EAPI void e_fm2_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);

@ -140,3 +140,4 @@
#include "e_entry_dialog.h"
#include "e_fm.h"
#include "e_widget_scrollframe.h"
#include "e_sha1.h"

@ -0,0 +1,107 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e_sha1.h"
#include <string.h>
#include <arpa/inet.h>
/* externally accessible functions */
#define SHSH(n, v) ((((v) << (n)) & 0xffffffff) | ((v) >> (32 - (n))))
/* this is ALMOST canonical sha1 - i took some shortcuts to make it smaller
* when handling the last 64 bytes in a buffer to just keep it short. it
* still generates decent hashes either way...
*/
EAPI int
e_sha1_sum(unsigned char *data, int size, unsigned char *dst)
{
unsigned int digest[5], word[80], wa, wb, wc, wd, we, t;
unsigned char buf[64], *d;
int index, left, i;
const unsigned int magic[4] =
{
0x5a827999,
0x6ed9eba1,
0x8f1bbcdc,
0xca62c1d6
};
index = 0;
digest[0] = 0x67452301;
digest[1] = 0xefcdab89;
digest[2] = 0x98badcfe;
digest[3] = 0x10325476;
digest[4] = 0xc3d2e1f0;
for (left = size, d = data; left > 0; left--, d++)
{
if ((index == 0) && (left < 64))
{
memset(buf, 0, 60);
buf[60] = (size >> 24) & 0xff;
buf[61] = (size >> 16) & 0xff;
buf[62] = (size >> 8) & 0xff;
buf[63] = (size ) & 0xff;
}
buf[index] = *d;
index++;
if ((index == 64) || (left == 1))
{
if ((left == 1) && (index < 64)) buf[index] = 0x80;
for (i = 0; i < 16; i++)
{
word[i] = (unsigned int)buf[(i * 4) ] << 24;
word[i] |= (unsigned int)buf[(i * 4) + 1] << 16;
word[i] |= (unsigned int)buf[(i * 4) + 2] << 8;
word[i] |= (unsigned int)buf[(i * 4) + 3];
}
for (i = 16; i < 80; i++)
word[i] = SHSH(1,
word[i - 3 ] ^ word[i - 8 ] ^
word[i - 14] ^ word[i - 16]);
wa = digest[0];
wb = digest[1];
wc = digest[2];
wd = digest[3];
we = digest[4];
for (i = 0; i < 80; i++)
{
if (i < 20)
t = SHSH(5, wa) + ((wb & wc) | ((~wb) & wd)) +
we + word[i] + magic[0];
else if (i < 40)
t = SHSH(5, wa) + (wb ^ wc ^ wd) +
we + word[i] + magic[1];
else if (i < 60)
t = SHSH(5, wa) + ((wb & wc) | (wb & wd) | (wc & wd)) +
we + word[i] + magic[2];
else if (i < 80)
t = SHSH(5, wa) + (wb ^ wc ^ wd) +
we + word[i] + magic[3];
we = wd;
wd = wc;
wc = SHSH(30, wb);
wb = wa;
wa = t;
}
digest[0] += wa;
digest[1] += wb;
digest[2] += wc;
digest[3] += wd;
digest[4] += we;
index = 0;
}
}
t = htonl(digest[0]); digest[0] = t;
t = htonl(digest[1]); digest[1] = t;
t = htonl(digest[2]); digest[2] = t;
t = htonl(digest[3]); digest[3] = t;
t = htonl(digest[4]); digest[4] = t;
memcpy(dst, digest, 5 * 4);
return 1;
}
/* local subsystem functions */

@ -0,0 +1,35 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef E_TYPEDEFS
#else
#ifndef E_SHA1_H
#define E_SHA1_H
#ifndef EAPI
# ifdef WIN32
# ifdef BUILDING_DLL
# define EAPI __declspec(dllexport)
# else
# define EAPI __declspec(dllimport)
# endif
# else
# ifdef __GNUC__
# if __GNUC__ >= 4
// BROKEN in gcc 4 on amd64
//# pragma GCC visibility push(hidden)
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
# endif
#endif
EAPI int e_sha1_sum(unsigned char *data, int size, unsigned char *dst);
#endif
#endif

@ -601,7 +601,54 @@ _e_test_cb_changed(void *data, Evas_Object *obj, void *event_info)
static void
_e_test_cb_favorites_selected(void *data, Evas_Object *obj, void *event_info)
{
printf("FAV CHANGED\n");
Evas_List *selected;
E_Fm2_Icon_Info *ici;
printf("FAV SELECTED\n");
selected = e_fm2_selected_list_get(obj);
if (!selected) return;
ici = selected->data;
if ((ici->link) && (ici->mount))
e_fm2_path_set(data, (char *)ici->link, "/");
else if (ici->link)
e_fm2_path_set(data, NULL, (char *)ici->link);
// FIXME: this should happen on the scrollframe not the fm obj
// e_widget_scrollframe_child_pos_set(data, 0, 0);
evas_list_free(selected);
}
static void
_e_test_cb_favorites_files_changed(void *data, Evas_Object *obj, void *event_info)
{
Evas_List *icons, *l;
E_Fm2_Icon_Info *ici;
const char *realpath;
char *p1, *p2;
printf("FAV LIST CHANGE!\n");
icons = e_fm2_all_list_get(obj);
if (!icons) return;
realpath = e_fm2_real_path_get(data);
p1 = ecore_file_realpath(realpath);
if (!p1) goto done;
for (l = icons; l; l = l->next)
{
ici = l->data;
if (ici->link)
{
p2 = ecore_file_realpath(ici->link);
if (!strcmp(p1, p2))
{
e_fm2_select_set(obj, ici->file);
E_FREE(p2);
goto done;
}
E_FREE(p2);
}
}
done:
E_FREE(p1);
evas_list_free(icons);
}
static void
@ -626,8 +673,26 @@ _e_test_internal(E_Container *con)
/* actual files */
ofm = e_fm2_add(dia->win->evas);
/* FIXME: set config */
e_fm2_path_set(ofm, "~/", "/pix/bg");
memset(&fmc, 0, sizeof(E_Fm2_Config));
fmc.view.mode = E_FM2_VIEW_MODE_LIST;
fmc.view.open_dirs_in_place = 1;
fmc.view.selector = 1;
fmc.view.single_click = 0;
fmc.view.no_subdir_jump = 0;
fmc.icon.list.w = 24;
fmc.icon.list.h = 24;
fmc.icon.fixed.w = 1;
fmc.icon.fixed.h = 1;
fmc.icon.extension.show = 0;
fmc.list.sort.no_case = 1;
fmc.list.sort.dirs.first = 1;
fmc.list.sort.dirs.last = 0;
fmc.selection.single = 1;
fmc.selection.windows_modifiers = 0;
e_fm2_config_set(ofm, &fmc);
e_fm2_path_set(ofm, "~/", "/");
ob = e_widget_button_add(dia->win->evas, "Up a directory", NULL,
_e_test_cb_button, ofm, NULL);
e_widget_table_object_append(ot, ob, 1, 0, 1, 1, 0, 0, 1, 0);
@ -646,8 +711,27 @@ _e_test_internal(E_Container *con)
/* shortcut list */
ofm = e_fm2_add(dia->win->evas);
/* FIXME: set config */
e_fm2_path_set(ofm, "~/", "/.e/e/fileman/favorites");
memset(&fmc, 0, sizeof(E_Fm2_Config));
fmc.view.mode = E_FM2_VIEW_MODE_LIST;
fmc.view.open_dirs_in_place = 1;
fmc.view.selector = 1;
fmc.view.single_click = 1;
fmc.view.no_subdir_jump = 1;
fmc.icon.list.w = 24;
fmc.icon.list.h = 24;
fmc.icon.fixed.w = 1;
fmc.icon.fixed.h = 1;
fmc.icon.extension.show = 0;
fmc.list.sort.no_case = 1;
fmc.list.sort.dirs.first = 0;
fmc.list.sort.dirs.last = 0;
fmc.selection.single = 1;
fmc.selection.windows_modifiers = 0;
e_fm2_config_set(ofm, &fmc);
e_fm2_path_set(ofm, "favorites", "/");
evas_object_smart_callback_add(ofm, "files_changed", _e_test_cb_favorites_files_changed, ofm2);
evas_object_smart_callback_add(ofm, "selected", _e_test_cb_favorites_selected, ofm2);
of = e_widget_scrollframe_pan_add(dia->win->evas, ofm,
e_fm2_pan_set, e_fm2_pan_get,

@ -121,6 +121,7 @@ e_thumb_icon_begin(Evas_Object *obj)
eth = evas_object_data_get(obj, "e_thumbdata");
if (!eth) return;
if (eth->busy) return;
if (!eth->file) return;
if (!_thumbnailers)
{
@ -161,11 +162,7 @@ e_thumb_icon_end(Evas_Object *obj)
if (!eth) return;
if (eth->queued) _thumb_queue = evas_list_remove(_thumb_queue, eth);
eth->queued = 0;
if (eth->busy)
{
printf("REQ DEL %s\n", eth->file);
_e_thumb_gen_end(eth->objid);
}
if (eth->busy) _e_thumb_gen_end(eth->objid);
eth->busy = 0;
_pending--;
if (_pending == 0) _e_thumb_thumbnailers_kill();
@ -223,6 +220,7 @@ e_thumb_client_del(Ecore_Ipc_Event_Client_Del *e)
{
if (!evas_list_find(_thumbnailers, e->client)) return;
_thumbnailers = evas_list_remove(_thumbnailers, e->client);
if ((!_thumbs) && (!_thumbnailers)) _objid = 0;
}
/* local subsystem functions */
@ -300,7 +298,7 @@ _e_thumb_hash_del(int objid)
snprintf(buf, sizeof(buf), "%i", objid);
_thumbs = evas_hash_del(_thumbs, buf, NULL);
if (!_thumbs) _objid = 0;
if ((!_thumbs) && (!_thumbnailers)) _objid = 0;
}
static Evas_Object *

@ -12,6 +12,7 @@
#include <Evas.h>
#include <Eet.h>
#include <Edje.h>
#include "e_sha1.h"
typedef struct _E_Thumb E_Thumb;
@ -29,6 +30,7 @@ static int _e_ipc_cb_server_add(void *data, int type, void *event);
static int _e_ipc_cb_server_del(void *data, int type, void *event);
static int _e_ipc_cb_server_data(void *data, int type, void *event);
static int _e_cb_timer(void *data);
static int _e_thumb_valid(E_Thumb *eth);
static void _e_thumb_generate(E_Thumb *eth);
static char *_e_thumb_file_id(char *file, char *key);
@ -43,7 +45,8 @@ int
main(int argc, char **argv)
{
int i;
nice(20);
for (i = 1; i < argc; i++)
{
if ((!strcmp(argv[i], "-h")) ||
@ -168,7 +171,7 @@ _e_ipc_cb_server_data(void *data, int type, void *event)
eth->file = strdup(file);
if (key) eth->key = strdup(key);
_thumblist = evas_list_append(_thumblist, eth);
if (!_timer) _timer = ecore_timer_add(0.001, _e_cb_timer, NULL);
if (!_timer) _timer = ecore_timer_add(0.000001, _e_cb_timer, NULL);
}
}
break;
@ -201,17 +204,36 @@ static int
_e_cb_timer(void *data)
{
E_Thumb *eth;
Evas_List *del_list = NULL, *l;
/* take thumb at head of list */
if (_thumblist)
{
eth = _thumblist->data;
_thumblist = evas_list_remove_list(_thumblist, _thumblist);
_e_thumb_generate(eth);
if (eth->file) free(eth->file);
if (eth->key) free(eth->key);
free(eth);
if (_thumblist) _timer = ecore_timer_add(0.00001, _e_cb_timer, NULL);
for (l = _thumblist; l; l = l->next)
{
eth = l->data;
if (_e_thumb_valid(eth))
del_list = evas_list_append(del_list, eth);
}
while (del_list)
{
eth = del_list->data;
del_list = evas_list_remove_list(del_list, del_list);
_thumblist = evas_list_remove(_thumblist, eth);
if (eth->file) free(eth->file);
if (eth->key) free(eth->key);
free(eth);
}
if (_thumblist)
{
eth = _thumblist->data;
_thumblist = evas_list_remove_list(_thumblist, _thumblist);
_e_thumb_generate(eth);
if (eth->file) free(eth->file);
if (eth->key) free(eth->key);
free(eth);
}
if (_thumblist) _timer = ecore_timer_add(0.000001, _e_cb_timer, NULL);
else _timer = NULL;
}
else
@ -219,6 +241,39 @@ _e_cb_timer(void *data)
return 0;
}
static int
_e_thumb_valid(E_Thumb *eth)
{
char buf[4096], dbuf[4096], *id, *td;
time_t mtime_orig, mtime_thumb;
id = _e_thumb_file_id(eth->file, eth->key);
if (!id) return;
td = strdup(id);
if (!td)
{
free(id);
return;
}