From 2f3a16acdc6c353a3cbcc57bc5c8c5e982adfa45 Mon Sep 17 00:00:00 2001 From: codewarrior Date: Thu, 10 Nov 2005 09:12:58 +0000 Subject: [PATCH] - add metadata structs to icons - add metadata per dir - small theme change - bug: i have something wrong with saving the eet list. can anyone find out what it is? SVN revision: 18411 --- data/themes/default_fileman.edc | 2 + src/bin/e_fileman_icon.c | 139 +++++++++++++++++++-- src/bin/e_fileman_icon.h | 32 +++-- src/bin/e_fileman_smart.c | 265 +++++++++++++++++++++++++++++++++++++++- src/bin/e_icon_layout.c | 126 +++++++++++++++++-- src/bin/e_icon_layout.h | 32 ++--- 6 files changed, 553 insertions(+), 43 deletions(-) diff --git a/data/themes/default_fileman.edc b/data/themes/default_fileman.edc index 56759fc..66f0225 100644 --- a/data/themes/default_fileman.edc +++ b/data/themes/default_fileman.edc @@ -100,6 +100,7 @@ group { \ signal: "clicked"; \ source: ""; \ action: STATE_SET "clicked" 0.0; \ + transition: LINEAR 0.1; \ target: "icon"; \ } \ program { \ @@ -107,6 +108,7 @@ group { \ signal: "unclicked"; \ source: ""; \ action: STATE_SET "default" 0.0; \ + transition: LINEAR 0.1; \ target: "icon"; \ } \ program { \ diff --git a/src/bin/e_fileman_icon.c b/src/bin/e_fileman_icon.c index 4c3a28a..758a652 100644 --- a/src/bin/e_fileman_icon.c +++ b/src/bin/e_fileman_icon.c @@ -3,6 +3,26 @@ */ #include "e.h" +#define NEWD(str, typ) \ + eet_data_descriptor_new(str, sizeof(typ), \ + (void *(*) (void *))evas_list_next, \ + (void *(*) (void *, void *))evas_list_append, \ + (void *(*) (void *))evas_list_data, \ + (void *(*) (void *))evas_list_free, \ + (void (*) (void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach, \ + (void *(*) (void *, const char *, void *))evas_hash_add, \ + (void (*) (void *))evas_hash_free) + +#define FREED(eed) \ + if (eed) \ + { \ + eet_data_descriptor_free((eed)); \ + (eed) = NULL; \ + } +#define NEWI(str, it, type) \ + EET_DATA_DESCRIPTOR_ADD_BASIC(_e_fm_icon_meta_edd, E_Fm_Icon_Metadata, str, it, type) + + typedef struct _E_Smart_Data E_Smart_Data; struct _E_Smart_Data @@ -46,6 +66,7 @@ static int _e_fm_icon_thumb_cb_exe_exit(void *data, int type, void *event); static void _e_fm_icon_type_set(E_Smart_Data *sd); +static void _e_fm_icon_meta_fill(E_Fm_Icon_Metadata *m, E_Smart_Data *sd); /* local subsystem globals */ static Evas_Smart *e_smart = NULL; @@ -55,10 +76,19 @@ static Evas_List *thumb_files = NULL; static Evas_List *event_handlers = NULL; +static Eet_Data_Descriptor *_e_fm_icon_meta_edd = NULL; + /* externally accessible functions */ int e_fm_icon_init(void) { + _e_fm_icon_meta_edd = NEWD("E_Fm_Icon_Metadata", E_Fm_Icon_Metadata); + NEWI("x", x, EET_T_INT); + NEWI("y", y, EET_T_INT); + NEWI("w", w, EET_T_INT); + NEWI("h", h, EET_T_INT); + NEWI("nm", name, EET_T_STRING); + event_handlers = evas_list_append(event_handlers, ecore_event_handler_add(ECORE_EVENT_EXE_EXIT, _e_fm_icon_thumb_cb_exe_exit, @@ -69,6 +99,7 @@ e_fm_icon_init(void) int e_fm_icon_shutdown(void) { + FREED(_e_fm_icon_meta_edd); while (event_handlers) { ecore_event_handler_del(event_handlers->data); @@ -109,7 +140,10 @@ void e_fm_icon_type_set(Evas_Object *obj, int type) { E_Smart_Data *sd; - + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if(sd->type == type) return; @@ -136,7 +170,8 @@ e_fm_icon_file_set(Evas_Object *obj, E_Fm_File *file) sd = evas_object_smart_data_get(obj); if (!sd) return; - e_object_ref(E_OBJECT(file)); + if(!sd->file) + e_object_ref(E_OBJECT(file)); sd->file = file; file->icon_object = obj; @@ -187,6 +222,51 @@ e_fm_icon_file_set(Evas_Object *obj, E_Fm_File *file) } void +e_fm_icon_appear_cb(Evas_Object *obj, void *data) +{ + E_Smart_Data *sd; + + evas_object_show(obj); + return; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if(sd->visible) return; + sd->visible = 1; + + sd->icon_object = edje_object_add(sd->evas); + evas_object_smart_member_add(sd->icon_object, obj); + + sd->event_object = evas_object_rectangle_add(sd->evas); + evas_object_color_set(sd->event_object, 0, 0, 0, 0); + evas_object_smart_member_add(sd->event_object, obj); + evas_object_smart_data_set(obj, sd); + + e_fm_icon_file_set(obj, sd->file); + evas_object_show(obj); +} + +void +e_fm_icon_disappear_cb(Evas_Object *obj, void *data) +{ + E_Smart_Data *sd; + + evas_object_hide(obj); + return; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if(!sd->visible) return; + sd->visible = 0; + + if (sd->event_object) evas_object_del(sd->event_object); + if (sd->icon_object) evas_object_del(sd->icon_object); + if (sd->image_object) evas_object_del(sd->image_object); + if (sd->thumb_object) evas_object_del(sd->thumb_object); + E_FREE(sd->saved_title); +} + +void e_fm_icon_title_set(Evas_Object *obj, const char *title) { E_Smart_Data *sd; @@ -256,6 +336,32 @@ e_fm_icon_signal_emit(Evas_Object *obj, const char *source, const char *emission if (sd->image_object) edje_object_signal_emit(sd->image_object, source, emission); } +E_Fm_Icon_Metadata * +e_fm_icon_meta_generate(Evas_Object *obj) +{ + E_Smart_Data *sd; + E_Fm_Icon_Metadata *m; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + + m = calloc(1, sizeof(E_Fm_Icon_Metadata)); + if (!m) return NULL; + _e_fm_icon_meta_fill(m, sd); + + return m; +} + +void +e_fm_icon_meta_free(E_Fm_Icon_Metadata *m) +{ + if (!m) return; + E_FREE(m->name); + + free(m); +} + + int e_fm_icon_assoc_set(Evas_Object *obj, const char *assoc) { @@ -282,6 +388,7 @@ _e_fm_icon_smart_add(Evas_Object *obj) sd->h = 64; sd->iw = 48; sd->ih = 48; + sd->file = NULL; sd->icon_object = edje_object_add(sd->evas); evas_object_smart_member_add(sd->icon_object, obj); @@ -321,8 +428,10 @@ _e_fm_icon_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) if ((sd->x == x) && (sd->y == y)) return; sd->x = x; sd->y = y; - evas_object_move(sd->event_object, x, y); - evas_object_move(sd->icon_object, x, y); + if(sd->event_object) + evas_object_move(sd->event_object, x, y); + if(sd->icon_object) + evas_object_move(sd->icon_object, x, y); } static void @@ -335,7 +444,9 @@ _e_fm_icon_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) if ((sd->w == w) && (sd->h == h)) return; sd->w = w; sd->h = h; - evas_object_resize(sd->event_object, sd->w, sd->h); + if(sd->event_object) + evas_object_resize(sd->event_object, sd->w, sd->h); + if(sd->icon_object) evas_object_resize(sd->icon_object, sd->w, sd->h); } @@ -346,7 +457,9 @@ _e_fm_icon_smart_show(Evas_Object *obj) sd = evas_object_smart_data_get(obj); if (!sd) return; - evas_object_show(sd->icon_object); + if(sd->event_object) + evas_object_show(sd->icon_object); + if(sd->icon_object) evas_object_show(sd->event_object); } @@ -357,8 +470,10 @@ _e_fm_icon_smart_hide(Evas_Object *obj) sd = evas_object_smart_data_get(obj); if (!sd) return; + if(sd->event_object) evas_object_hide(sd->icon_object); - evas_object_hide(sd->event_object); + if(sd->icon_object) + evas_object_hide(sd->event_object); } static void @@ -583,3 +698,13 @@ _e_fm_icon_type_set(E_Smart_Data *sd) edje_object_part_text_set(sd->icon_object, "icon_title", sd->file->name); } } + +static void +_e_fm_icon_meta_fill(E_Fm_Icon_Metadata *m, E_Smart_Data *sd) +{ + m->x = sd->x; + m->y = sd->y; + m->w = sd->w; + m->h = sd->h; + m->name = strdup(sd->file->name); +} diff --git a/src/bin/e_fileman_icon.h b/src/bin/e_fileman_icon.h index c7d1a56..5ce16ae 100644 --- a/src/bin/e_fileman_icon.h +++ b/src/bin/e_fileman_icon.h @@ -4,6 +4,7 @@ #ifdef E_TYPEDEFS typedef enum _E_Fm_Icon_Type E_Fm_Icon_Type; +typedef struct _E_Fm_Icon_Metadata E_Fm_Icon_Metadata; #else #ifndef E_FILEMAN_FILE_SMART_H @@ -15,18 +16,25 @@ enum E_Fm_Icon_Type E_FM_ICON_LIST }; -EAPI int e_fm_icon_init(void); -EAPI int e_fm_icon_shutdown(void); -EAPI Evas_Object *e_fm_icon_add(Evas *evas); -EAPI E_Fm_File *e_fm_icon_file_get(Evas_Object *obj); -EAPI void e_fm_icon_file_set(Evas_Object *obj, E_Fm_File *file); -EAPI void e_fm_icon_title_set(Evas_Object *obj, const char *title); -EAPI void e_fm_icon_type_set(Evas_Object *obj, int type); -EAPI void e_fm_icon_edit_entry_set(Evas_Object *obj, Evas_Object *entry); -EAPI void e_fm_icon_signal_emit(Evas_Object *obj, const char *source, const char *emission); -EAPI void e_fm_icon_image_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h); -EAPI void e_fm_icon_size_min_calc(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h); - +struct _E_Fm_Icon_Metadata +{ + Evas_Coord x, y, w, h; /* geometry */ + char *name; /* filename */ +}; + +EAPI int e_fm_icon_init(void); +EAPI int e_fm_icon_shutdown(void); +EAPI Evas_Object *e_fm_icon_add(Evas *evas); +EAPI E_Fm_File *e_fm_icon_file_get(Evas_Object *obj); +EAPI void e_fm_icon_file_set(Evas_Object *obj, E_Fm_File *file); +EAPI void e_fm_icon_appear_cb(Evas_Object *obj, void *data); +EAPI void e_fm_icon_disappear_cb(Evas_Object *obj, void *data); +EAPI void e_fm_icon_title_set(Evas_Object *obj, const char *title); +EAPI void e_fm_icon_type_set(Evas_Object *obj, int type); +EAPI void e_fm_icon_edit_entry_set(Evas_Object *obj, Evas_Object *entry); +EAPI void e_fm_icon_signal_emit(Evas_Object *obj, const char *source, const char *emission); +EAPI E_Fm_Icon_Metadata *e_fm_icon_meta_generate(Evas_Object *obj); +EAPI void e_fm_icon_meta_free(E_Fm_Icon_Metadata *m); #endif #endif diff --git a/src/bin/e_fileman_smart.c b/src/bin/e_fileman_smart.c index 66ee1d3..74e11f3 100644 --- a/src/bin/e_fileman_smart.c +++ b/src/bin/e_fileman_smart.c @@ -52,10 +52,34 @@ int E_EVENT_FM_DIRECTORY_CHANGE; # define D(x) ((void) 0) #endif +#define NEWD(str, typ) \ + eet_data_descriptor_new(str, sizeof(typ), \ + (void *(*) (void *))evas_list_next, \ + (void *(*) (void *, void *))evas_list_append, \ + (void *(*) (void *))evas_list_data, \ + (void *(*) (void *))evas_list_free, \ + (void (*) (void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach, \ + (void *(*) (void *, const char *, void *))evas_hash_add, \ + (void (*) (void *))evas_hash_free) + +#define FREED(eed) \ + if (eed) \ + { \ + eet_data_descriptor_free((eed)); \ + (eed) = NULL; \ + } +#define INEWI(str, it, type) \ + EET_DATA_DESCRIPTOR_ADD_BASIC(_e_fm_icon_meta_edd, E_Fm_Icon_Metadata, str, it, type) +#define NEWI(str, it, type) \ + EET_DATA_DESCRIPTOR_ADD_BASIC(_e_fm_dir_meta_edd, E_Fm_Dir_Metadata, str, it, type) +#define NEWL(str, it, type) \ + EET_DATA_DESCRIPTOR_ADD_LIST(_e_fm_icon_meta_edd, E_Fm_Dir_Metadata, str, it, type) + typedef struct _E_Fm_Smart_Data E_Fm_Smart_Data; typedef struct _E_Fm_Icon E_Fm_Icon; typedef struct _E_Fm_Icon_CFData E_Fm_Icon_CFData; typedef struct _E_Fm_Config E_Fm_Config; +typedef struct _E_Fm_Dir_Metadata E_Fm_Dir_Metadata; typedef struct _E_Fm_Fake_Mouse_Up_Info E_Fm_Fake_Mouse_Up_Info; typedef enum _E_Fm_Arrange E_Fm_Arrange; @@ -65,6 +89,17 @@ struct _E_Fm_Config int height; }; +struct _E_Fm_Dir_Metadata +{ + char *name; /* dir name */ + char *bg; /* dir's custom bg */ + int view; /* dir's saved view type */ + Evas_List *files; /* files in dir */ + + /* these are generated post-load */ + Evas_Hash *files_hash; /* quick lookup hash */ +}; + struct _E_Fm_Icon { E_Fm_File *file; @@ -119,6 +154,8 @@ struct _E_Fm_Smart_Data Evas_Object *object; Evas_Object *entry_object; + E_Fm_Dir_Metadata *meta; + char *dir; DIR *dir2; @@ -259,14 +296,39 @@ static int _e_fm_files_sort_layout_name_cb (void *d1, void *d static void _e_fm_selector_send_file (E_Fm_Icon *icon); +static char *_e_fm_dir_meta_dir_id(char *dir); +static int _e_fm_dir_meta_load(E_Fm_Smart_Data *sd); +static int _e_fm_dir_meta_generate(E_Fm_Smart_Data *sd); +static void _e_fm_dir_meta_free(E_Fm_Dir_Metadata *m); +static int _e_fm_dir_meta_save(E_Fm_Smart_Data *sd); +static void _e_fm_dir_meta_fill(E_Fm_Dir_Metadata *m, E_Fm_Smart_Data *sd); + + static Ecore_Event_Handler *e_fm_mouse_up_handler = NULL; static double e_fm_grab_time = 0; static Evas_Smart *e_fm_smart = NULL; +static char *meta_path = NULL; +static Eet_Data_Descriptor *_e_fm_dir_meta_edd = NULL; +static Eet_Data_Descriptor *_e_fm_icon_meta_edd = NULL; /* externally accessible functions */ int e_fm_init(void) { + char *homedir; + char path[PATH_MAX]; + + homedir = e_user_homedir_get(); + if (homedir) + { + snprintf(path, sizeof(path), "%s/.e/e/fileman/metadata", homedir); + if (!ecore_file_exists(path)) + ecore_file_mkpath(path); + meta_path = strdup(path); + free(homedir); + } + else return 0; + e_fm_smart = evas_smart_new("e_fm", _e_fm_smart_add, /* add */ _e_fm_smart_del, /* del */ @@ -280,6 +342,19 @@ e_fm_init(void) _e_fm_smart_clip_unset, /* clip_unset */ NULL); /* data*/ + _e_fm_icon_meta_edd = NEWD("E_Fm_Icon_Metadata", E_Fm_Icon_Metadata); + INEWI("x", x, EET_T_INT); + INEWI("y", y, EET_T_INT); + INEWI("w", w, EET_T_INT); + INEWI("h", h, EET_T_INT); + INEWI("nm", name, EET_T_STRING); + + _e_fm_dir_meta_edd = NEWD("E_Fm_Dir_Metadata", E_Fm_Dir_Metadata); + NEWI("nm", name, EET_T_STRING); + NEWI("bg", bg, EET_T_STRING); + NEWI("vw", view, EET_T_INT); + NEWL("fl", files, _e_fm_icon_meta_edd); + E_EVENT_FM_RECONFIGURE = ecore_event_type_new(); E_EVENT_FM_DIRECTORY_CHANGE = ecore_event_type_new(); return 1; @@ -288,6 +363,8 @@ e_fm_init(void) int e_fm_shutdown(void) { + FREED(_e_fm_dir_meta_edd); + FREED(_e_fm_icon_meta_edd); evas_smart_free(e_fm_smart); return 1; } @@ -510,6 +587,8 @@ _e_fm_smart_add(Evas_Object *object) if (!sd) return; sd->object = object; + sd->meta = NULL; + sd->icon_info.w = 64; sd->icon_info.h = 64; sd->icon_info.x_space = 12; @@ -542,6 +621,7 @@ _e_fm_smart_add(Evas_Object *object) _e_fm_mouse_move_cb, sd); sd->layout = e_icon_layout_add(sd->evas); + e_icon_layout_viewport_set(sd->layout, sd->edje_obj); e_icon_layout_spacing_set(sd->layout, sd->icon_info.x_space, sd->icon_info.y_space); evas_object_show(sd->layout); @@ -1357,6 +1437,28 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir) if (sd->dir) free (sd->dir); sd->dir = strdup(dir); + if(sd->meta) + { + _e_fm_dir_meta_free(sd->meta); + sd->meta = NULL; + } + + _e_fm_dir_meta_load(sd); + + if(sd->meta) + { + Evas_List *l; + printf("Loaded meta! (%s) %p\n", sd->meta->name, sd->meta->files); + for(l = sd->meta->files; l; l = l->next) + { + E_Fm_Icon_Metadata *im; + im = l->data; + printf("META: file = %s\n", im->name); + } + } + + + /* Reset position */ sd->position = 0.0; @@ -1393,6 +1495,7 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir) e_fm_icon_file_set(icon->icon_object, icon->file); sd->files = evas_list_prepend(sd->files, icon); e_icon_layout_pack(sd->layout, icon->icon_object); + e_icon_layout_icon_callbacks_set(icon->icon_object, e_fm_icon_appear_cb, e_fm_icon_disappear_cb, NULL); evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_DOWN, _e_fm_icon_mouse_down_cb, icon); evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_UP, _e_fm_icon_mouse_up_cb, icon); evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_IN, _e_fm_icon_mouse_in_cb, icon); @@ -1452,7 +1555,8 @@ _e_fm_dir_files_get(void *data) evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_OUT, _e_fm_icon_mouse_out_cb, icon); evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_MOVE, _e_fm_icon_mouse_move_cb, sd); evas_object_show(icon->icon_object); - e_icon_layout_pack(sd->layout, icon->icon_object); + e_icon_layout_pack(sd->layout, icon->icon_object); + e_icon_layout_icon_callbacks_set(icon->icon_object, e_fm_icon_appear_cb, e_fm_icon_disappear_cb, NULL); } i++; } @@ -1478,10 +1582,19 @@ _e_fm_dir_files_get(void *data) { icon = l->data; e_icon_layout_pack(sd->layout, icon->icon_object); + e_icon_layout_icon_callbacks_set(icon->icon_object, e_fm_icon_appear_cb, e_fm_icon_disappear_cb, NULL); } e_icon_layout_thaw(sd->layout); sd->timer = NULL; + + if(!sd->meta) + { + printf("Generating Meta!\n"); + _e_fm_dir_meta_generate(sd); + _e_fm_dir_meta_save(sd); + } + return 0; } else @@ -1560,6 +1673,7 @@ _e_fm_dir_monitor_cb(void *data, Ecore_File_Monitor *ecore_file_monitor, //evas_object_resize(icon->icon_object, sd->icon_info.w, sd->icon_info.h); evas_object_show(icon->icon_object); e_icon_layout_pack(sd->layout, icon->icon_object); + e_icon_layout_icon_callbacks_set(icon->icon_object, e_fm_icon_appear_cb, e_fm_icon_disappear_cb, NULL); evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_DOWN, _e_fm_icon_mouse_down_cb, icon); evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_UP, _e_fm_icon_mouse_up_cb, icon); evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_IN, _e_fm_icon_mouse_in_cb, icon); @@ -3055,3 +3169,152 @@ _e_fm_selector_send_file(E_Fm_Icon *icon) { icon->sd->selector_func(icon->sd->object, strdup(icon->file->path), icon->sd->selector_data); } + +static char * +_e_fm_dir_meta_dir_id(char *dir) +{ + char s[256], *sp; + const char *chmap = + "0123456789abcdef" + "ghijklmnopqrstuv" + "wxyz~!@#$%^&*()" + "[];',.{}<>?-=_+|"; + unsigned int id[4], i; + struct stat st; + + if (stat(dir, &st) < 0) + return NULL; + + id[0] = st.st_ino; + id[1] = st.st_dev; + id[2] = (st.st_size & 0xffffffff); + id[3] = (st.st_mtime & 0xffffffff); + + sp = s; + for (i = 0; i < 4; i++) + { + unsigned int t, tt; + int j; + + t = id[i]; + j = 32; + while (j > 0) + { + tt = t & ((1 << 6) - 1); + *sp = chmap[tt]; + t >>= 6; + j -= 6; + sp++; + } + } + *sp = 0; + return strdup(s); +} + + +static int +_e_fm_dir_meta_load(E_Fm_Smart_Data *sd) +{ + E_Fm_Dir_Metadata *m; + Eet_File *ef; + char buf[PATH_MAX]; + char *hash; + + if (!sd->dir) return 0; + + hash = _e_fm_dir_meta_dir_id(sd->dir); + snprintf(buf, sizeof(buf), "%s/%s", meta_path, hash); + ef = eet_open(buf, EET_FILE_MODE_READ); + if (!ef) return 0; + m = eet_data_read(ef, _e_fm_dir_meta_edd, "metadata"); + eet_close(ef); + if (m) + { + Evas_List *l; + + for (l = m->files; l; l = l->next) + { + E_Fm_Icon_Metadata *im; + + im = l->data; + printf("loading %s\n", im->name); + m->files = evas_list_append(m->files, im); + m->files_hash = evas_hash_add(m->files_hash, im->name, im); + } + } + free(hash); + sd->meta = m; + return 1; +} + +static int +_e_fm_dir_meta_generate(E_Fm_Smart_Data *sd) +{ + E_Fm_Dir_Metadata *m; + Evas_List *l; + + if (!sd->dir) return 0; + m = calloc(1, sizeof(E_Fm_Dir_Metadata)); + if (!m) return 0; + _e_fm_dir_meta_fill(m, sd); + for (l = sd->files; l; l = l->next) + { + E_Fm_Icon_Metadata *im; + E_Fm_Icon *icon; + + icon = l->data; + im = e_fm_icon_meta_generate(icon->icon_object); + if (im) + { + printf("adding %s\n", im->name); + m->files = evas_list_append(m->files, im); + m->files_hash = evas_hash_add(m->files_hash, icon->file->name, im); + } + } + sd->meta = m; + return 1; +} + +static void +_e_fm_dir_meta_free(E_Fm_Dir_Metadata *m) +{ + if (!m) return; + E_FREE(m->name); + while (m->files) + { + E_Fm_Icon_Metadata *im; + + im = m->files->data; + m->files = evas_list_remove_list(m->files, m->files); + e_fm_icon_meta_free(im); + } + evas_hash_free(m->files_hash); + free(m); +} + +static int +_e_fm_dir_meta_save(E_Fm_Smart_Data *sd) +{ + Eet_File *ef; + char *hash; + char buf[4096]; + int ret; + + if (!sd->meta) return 0; + hash = _e_fm_dir_meta_dir_id(sd->dir); + snprintf(buf, sizeof(buf), "%s/%s", meta_path, hash); + ef = eet_open(buf, EET_FILE_MODE_WRITE); + if (!ef) return 0; + ret = eet_data_write(ef, _e_fm_dir_meta_edd, "metadata", sd->meta, 1); + eet_close(ef); + free(hash); + return ret; +} + +static void +_e_fm_dir_meta_fill(E_Fm_Dir_Metadata *m, E_Fm_Smart_Data *sd) +{ + m->name = strdup(sd->dir); + m->bg = NULL; + m->view = 1; +} diff --git a/src/bin/e_icon_layout.c b/src/bin/e_icon_layout.c index ce139c7..256b9e2 100644 --- a/src/bin/e_icon_layout.c +++ b/src/bin/e_icon_layout.c @@ -1,8 +1,4 @@ -#include -#include -#include -#include -#include +#include "e.h" typedef struct _E_Smart_Data E_Smart_Data; typedef struct _E_Icon_Layout_Item E_Icon_Layout_Item; @@ -20,7 +16,12 @@ struct _E_Smart_Data int clip_frozen; int fixed; unsigned char changed : 1; - Evas_List *items; + Evas_List *items; + + struct { + Evas_Object *obj; + Evas_Coord x, y, w, h; + } viewport; }; struct _E_Icon_Layout_Item @@ -28,6 +29,9 @@ struct _E_Icon_Layout_Item E_Smart_Data *sd; Evas_Coord x, y, w, h; Evas_Object *obj; + void (*appear_func)(Evas_Object *obj, void *data); + void (*disappear_func)(Evas_Object *obj, void *data); + void *data; }; /* local subsystem functions */ @@ -144,6 +148,17 @@ e_icon_layout_sort(Evas_Object *obj, int (*func)(void *d1, void *d2)) _e_icon_layout_smart_reconfigure(sd); } +void e_icon_layout_icon_callbacks_set(Evas_Object *child, void (*appear)(Evas_Object *obj, void *data), void (*disappear)(Evas_Object *obj, void *data), void *data) +{ + E_Icon_Layout_Item *li; + + li = evas_object_data_get(child, "e_icon_layout_data"); + if (!li) return; + + li->appear_func = appear; + li->disappear_func = disappear; + li->data = data; +} void e_icon_layout_pack(Evas_Object *obj, Evas_Object *child) @@ -191,6 +206,27 @@ e_icon_layout_pack(Evas_Object *obj, Evas_Object *child) sd->yc += li->h + sd->ys; sd->vw = sd->xc - sd->x; } + + if(sd->viewport.obj && li->appear_func && li->disappear_func) + { + if(E_INTERSECTS(sd->viewport.x, sd->viewport.y, + sd->viewport.w, sd->viewport.h, + li->x, li->y, li->w, li->h)) + { + li->appear_func(obj, li->data); + printf("appear! %d %d %d %d - %d %d %d %d\n",sd->viewport.x, sd->viewport.y, + sd->viewport.w, sd->viewport.h, + li->x, li->y, li->w, li->h); + } + else + { + li->disappear_func(obj, li->data); + printf("disappear! %d %d %d %d - %d %d %d %d\n",sd->viewport.x, sd->viewport.y, + sd->viewport.w, sd->viewport.h, + li->x, li->y, li->w, li->h); + } + } + _e_icon_layout_smart_move_resize_item(li); } @@ -301,6 +337,28 @@ e_icon_layout_clip_thaw(Evas_Object *obj) sd->clip_frozen = 0; } +void +e_icon_layout_viewport_set(Evas_Object *obj, Evas_Object *viewport) +{ + E_Smart_Data *sd; + + if ((!obj) || !(sd = evas_object_smart_data_get(obj))) + return; + + if(!viewport) return; + sd->viewport.obj = viewport; + evas_object_geometry_get(sd->viewport.obj, &(sd->viewport.x), &(sd->viewport.y), + &(sd->viewport.w), &(sd->viewport.h)); + if (sd->frozen <= 0) _e_icon_layout_smart_reconfigure(sd); +} + +Evas_Object * +e_icon_layout_viewport_get(Evas_Object *obj) +{ + /* TODO */ +} + + /* local subsystem functions */ static E_Icon_Layout_Item * _e_icon_layout_smart_adopt(E_Smart_Data *sd, Evas_Object *obj) @@ -312,6 +370,9 @@ _e_icon_layout_smart_adopt(E_Smart_Data *sd, Evas_Object *obj) if (!li) return NULL; li->sd = sd; li->obj = obj; + li->appear_func = NULL; + li->disappear_func = NULL; + li->data = NULL; evas_object_geometry_get(obj, NULL, NULL, &li->w, &li->h); /* defaults */ li->x = 0; @@ -390,7 +451,26 @@ _e_icon_layout_smart_reconfigure(E_Smart_Data *sd) li->x = x; li->y = y; - + + if(sd->viewport.obj && li->appear_func && li->disappear_func) + { + if(E_INTERSECTS(sd->viewport.x, sd->viewport.y, + sd->viewport.w, sd->viewport.h, + li->x, li->y, li->w, li->h)) + { + printf("appear! %d %d %d %d - %d %d %d %d\n",sd->viewport.x, sd->viewport.y, + sd->viewport.w, sd->viewport.h, + li->x, li->y, li->w, li->h); + li->appear_func(obj, li->data); + } + else + { + li->disappear_func(obj, li->data); + printf("disappear! %d %d %d %d - %d %d %d %d\n",sd->viewport.x, sd->viewport.y, + sd->viewport.w, sd->viewport.h, + li->x, li->y, li->w, li->h); + } + } _e_icon_layout_smart_move_resize_item(li); x += li->w + sd->xs; @@ -509,6 +589,7 @@ _e_icon_layout_smart_add(Evas_Object *obj) sd->mw = 0; sd->mh = 0; sd->fixed = 0; + sd->viewport.obj = NULL; sd->clip = evas_object_rectangle_add(evas_object_evas_get(obj)); evas_object_move(sd->clip, 0, 0); evas_object_resize(sd->clip, 0, 0); @@ -546,6 +627,10 @@ _e_icon_layout_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) if (!sd) return; if ((x == sd->x) && (y == sd->y)) return; if ((x == sd->x) && (y == sd->y)) return; + if(sd->viewport.obj) + evas_object_geometry_get(sd->viewport.obj, + &(sd->viewport.x), &(sd->viewport.y), + &(sd->viewport.w), &(sd->viewport.h)); /* FIXME: this will get slow with 1000's of objects. be smarter. */ { @@ -560,9 +645,30 @@ _e_icon_layout_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) for (l = sd->items; l; l = l->next) { Evas_Coord ox, oy; + E_Icon_Layout_Item *li; - evas_object_geometry_get(l->data, &ox, &oy, NULL, NULL); + li = evas_object_data_get(l->data, "e_icon_layout_data"); + evas_object_geometry_get(l->data, &ox, &oy, NULL, NULL); evas_object_move(l->data, ox + dx, oy + dy); + if(sd->viewport.obj && li->appear_func && li->disappear_func) + { + if(E_INTERSECTS(sd->viewport.x, sd->viewport.y, + sd->viewport.w, sd->viewport.h, + ox + dx, oy + dy, li->w, li->h)) + { + printf("appear! %d %d %d %d - %d %d %d %d\n",sd->viewport.x, sd->viewport.y, + sd->viewport.w, sd->viewport.h, + li->x, li->y, li->w, li->h); + li->appear_func(li->obj, li->data); + } + else + { + li->disappear_func(li->obj, li->data); + printf("disappear! %d %d %d %d - %d %d %d %d\n",sd->viewport.x, sd->viewport.y, + sd->viewport.w, sd->viewport.h, + ox + dx, oy + dy, li->w, li->h); + } + } } } sd->x = x; @@ -581,6 +687,10 @@ _e_icon_layout_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) sd->w = w; sd->h = h; sd->changed = 1; + if(sd->viewport.obj) + evas_object_geometry_get(sd->viewport.obj, + &(sd->viewport.x), &(sd->viewport.y), + &(sd->viewport.w), &(sd->viewport.h)); _e_icon_layout_smart_reconfigure(sd); } diff --git a/src/bin/e_icon_layout.h b/src/bin/e_icon_layout.h index 28c0fc3..f9153e8 100644 --- a/src/bin/e_icon_layout.h +++ b/src/bin/e_icon_layout.h @@ -6,21 +6,23 @@ #ifndef E_ICON_LAYOUT_H #define E_ICON_LAYOUT_H -EAPI Evas_Object *e_icon_layout_add (Evas *evas); -EAPI int e_icon_layout_freeze (Evas_Object *obj); -EAPI int e_icon_layout_thaw (Evas_Object *obj); -EAPI void e_icon_layout_virtual_size_set (Evas_Object *obj, Evas_Coord w, Evas_Coord h); -EAPI void e_icon_layout_virtual_size_get (Evas_Object *obj, Evas_Coord *w, Evas_Coord *h); -EAPI void e_icon_layout_width_fix (Evas_Object *obj, Evas_Coord w); -EAPI void e_icon_layout_height_fix (Evas_Object *obj, Evas_Coord h); -EAPI void e_icon_layout_pack (Evas_Object *obj, Evas_Object *child); -EAPI void e_icon_layout_child_resize (Evas_Object *obj, Evas_Coord w, Evas_Coord h); -EAPI void e_icon_layout_unpack (Evas_Object *obj); -EAPI void e_icon_layout_spacing_set(Evas_Object *obj, Evas_Coord xs, Evas_Coord ys); -EAPI void e_icon_layout_redraw_force (Evas_Object *obj); -EAPI void e_icon_layout_clip_freeze (Evas_Object *obj); -EAPI void e_icon_layout_clip_thaw (Evas_Object *obj); -EAPI void e_icon_layout_sort (Evas_Object *obj, int (*func)(void *d1, void *d2)); +EAPI Evas_Object *e_icon_layout_add (Evas *evas); +EAPI int e_icon_layout_freeze (Evas_Object *obj); +EAPI int e_icon_layout_thaw (Evas_Object *obj); +EAPI void e_icon_layout_virtual_size_set (Evas_Object *obj, Evas_Coord w, Evas_Coord h); +EAPI void e_icon_layout_virtual_size_get (Evas_Object *obj, Evas_Coord *w, Evas_Coord *h); +EAPI void e_icon_layout_width_fix (Evas_Object *obj, Evas_Coord w); +EAPI void e_icon_layout_height_fix (Evas_Object *obj, Evas_Coord h); +EAPI void e_icon_layout_pack (Evas_Object *obj, Evas_Object *child); +EAPI void e_icon_layout_child_resize (Evas_Object *obj, Evas_Coord w, Evas_Coord h); +EAPI void e_icon_layout_unpack (Evas_Object *obj); +EAPI void e_icon_layout_spacing_set (Evas_Object *obj, Evas_Coord xs, Evas_Coord ys); +EAPI void e_icon_layout_redraw_force (Evas_Object *obj); +EAPI void e_icon_layout_clip_freeze (Evas_Object *obj); +EAPI void e_icon_layout_clip_thaw (Evas_Object *obj); +EAPI void e_icon_layout_viewport_set (Evas_Object *obj, Evas_Object *viewport); +EAPI void e_icon_layout_sort (Evas_Object *obj, int (*func)(void *d1, void *d2)); +EAPI void e_icon_layout_icon_callbacks_set (Evas_Object *child, void (*appear)(Evas_Object *obj, void *data), void (*disappear)(Evas_Object *obj, void *data), void *data); #endif #endif -- 2.7.4