From: Enlightenment C. <no...@cv...> - 2007-06-14 15:53:07
|
Enlightenment CVS committal Author : raster Project : e17 Module : libs/efreet Dir : e17/libs/efreet/src/lib Modified Files: efreet_desktop.c efreet_desktop.h Log Message: efreet can actually free icons now... and flush the cache explicitly =================================================================== RCS file: /cvs/e/e17/libs/efreet/src/lib/efreet_desktop.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- efreet_desktop.c 4 May 2007 15:02:55 -0000 1.14 +++ efreet_desktop.c 14 Jun 2007 15:53:02 -0000 1.15 @@ -26,6 +26,7 @@ static int efreet_desktop_command_file_id = 0; static int init = 0; +static int cache_flush = 0; int EFREET_DESKTOP_TYPE_APPLICATION = 0; int EFREET_DESKTOP_TYPE_LINK = 0; @@ -167,8 +168,10 @@ if (!desktop) return 0; /* have we modified this file since we last read it in? */ - if (stat(desktop->orig_path, &buf) || (buf.st_mtime > desktop->load_time)) - return 0; + if ((desktop->cache_flush != cache_flush) || + (stat(desktop->orig_path, &buf) || + (buf.st_mtime > desktop->load_time))) + return 0; return 1; } @@ -191,12 +194,20 @@ if (desktop) { if (efreet_desktop_cache_check(desktop)) + { + desktop->ref++; return desktop; + } efreet_desktop_clear(desktop); if (efreet_desktop_read(desktop)) + { + desktop->ref++; + desktop->cache_flush = cache_flush; return desktop; + } + desktop->cached = 0; ecore_hash_remove(efreet_desktop_cache, file); efreet_desktop_free(desktop); } @@ -206,8 +217,8 @@ if (!desktop) return NULL; ecore_hash_set(efreet_desktop_cache, strdup(file), desktop); + desktop->cached = 1; return desktop; - } /** @@ -225,6 +236,9 @@ desktop->orig_path = strdup(file); desktop->load_time = ecore_time_get(); + + desktop->ref = 1; + return desktop; } @@ -250,6 +264,10 @@ efreet_desktop_free(desktop); return NULL; } + + desktop->ref = 1; + desktop->cache_flush = cache_flush; + return desktop; } @@ -400,8 +418,11 @@ else { if (desktop != ecore_hash_get(efreet_desktop_cache, desktop->orig_path)) + { + desktop->cached = 1; ecore_hash_set(efreet_desktop_cache, strdup(desktop->orig_path), desktop); + } } } efreet_ini_free(ini); @@ -418,7 +439,10 @@ efreet_desktop_save_as(Efreet_Desktop *desktop, const char *file) { if (desktop == ecore_hash_get(efreet_desktop_cache, desktop->orig_path)) + { + desktop->cached = 0; ecore_hash_remove(efreet_desktop_cache, desktop->orig_path); + } FREE(desktop->orig_path); desktop->orig_path = strdup(file); return efreet_desktop_save(desktop); @@ -435,6 +459,12 @@ { if (!desktop) return; + desktop->ref--; + if (desktop->ref > 0) return; + + if (desktop->cached) + ecore_hash_remove(efreet_desktop_cache, desktop->orig_path); + IF_FREE(desktop->orig_path); IF_FREE(desktop->name); @@ -715,6 +745,19 @@ pos += 1; } return string; +} + +/** + * @brief Tell Efreet to flush any cached desktop entries so it reloads on get. + * + * This flags the cache to be invalid, so next time a desktop file is fetched + * it will force it to be re-read off disk next time efreet_desktop_get() is + * called. + */ +void +efreet_desktop_cache_flush(void) +{ + cache_flush++; } /** =================================================================== RCS file: /cvs/e/e17/libs/efreet/src/lib/efreet_desktop.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- efreet_desktop.h 28 Mar 2007 18:04:51 -0000 1.7 +++ efreet_desktop.h 14 Jun 2007 15:53:02 -0000 1.8 @@ -62,6 +62,9 @@ struct Efreet_Desktop { int type; /**< type of desktop file */ + + int ref; /**< reference count - internal */ + int cache_flush; /**< cache flush value - internal */ double version; /**< version of spec file conforms to */ @@ -90,6 +93,7 @@ unsigned char hidden:1; /**< User delete the item */ unsigned char terminal:1; /**< Does the program run in a terminal */ unsigned char startup_notify:1; /**< The starup notify settings of the app */ + unsigned char cached:1; /**< The desktop file is cached by Efreet */ Ecore_Hash *x; /**< Keep track of all user extensions, keys that begin with X- */ void *type_data; /**< Type specific data for custom types */ @@ -131,7 +135,8 @@ Ecore_List *efreet_desktop_string_list_parse(const char *string); char *efreet_desktop_string_list_join(Ecore_List *list); - +void efreet_desktop_cache_flush(void); + /** * @} */ |