From 9e8ba2077b5b7fdb8605a7af9deb95e32b85391d Mon Sep 17 00:00:00 2001 From: englebass Date: Mon, 22 Nov 2010 21:30:43 +0000 Subject: [PATCH] Always emit icon cache update event If file starts with icon_ and ends with .cache, we have a new icon cache, emit event. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/efreet@54833 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/efreet_cache.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/lib/efreet_cache.c b/src/lib/efreet_cache.c index ec331a3..b1c7e28 100644 --- a/src/lib/efreet_cache.c +++ b/src/lib/efreet_cache.c @@ -19,7 +19,6 @@ static Eet_Data_Descriptor *cache_icon_fallback_edd = NULL; static Eet_File *icon_cache = NULL; static const char *icon_cache_name = NULL; -static const char *icon_cache_file = NULL; static Eet_File *icon_fallback_cache = NULL; static Ecore_File_Monitor *icon_cache_monitor = NULL; @@ -251,10 +250,8 @@ efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon) { eet_close(icon_cache); eina_stringshare_del(icon_cache_name); - eina_stringshare_del(icon_cache_file); icon_cache = NULL; icon_cache_name = NULL; - icon_cache_file = NULL; } } if (!icon_cache) @@ -266,7 +263,6 @@ efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon) if (icon_cache) { icon_cache_name = eina_stringshare_add(theme->name.internal); - icon_cache_file = eina_stringshare_add(path); icon_cache_timer_update(); } } @@ -311,25 +307,21 @@ static void icon_cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__, Ecore_File_Event event, const char *path) { - Eet_File *tmp = NULL; + const char *file, *ext; Efreet_Event_Cache_Update *ev = NULL; if (event != ECORE_FILE_EVENT_CREATED_FILE && event != ECORE_FILE_EVENT_MODIFIED) return; - if (!icon_cache_file || strcmp(path, icon_cache_file)) return; + file = ecore_file_file_get(path); + if (!file || strncmp(file, "icon_", 5)) return; + ext = strrchr(file, '.'); + if (!ext || strcmp(ext, ".cache")) return; - tmp = eet_open(icon_cache_file, EET_FILE_MODE_READ); - if (!tmp) return; - ev = NEW(Efreet_Event_Cache_Update, 1); - if (!ev) goto error; - - eet_close(icon_cache); - icon_cache = tmp; + icon_cache_close(); + ev = NEW(Efreet_Event_Cache_Update, 1); + if (!ev) return; ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, NULL, NULL); - return; -error: - if (tmp) eet_close(tmp); } static void @@ -358,5 +350,4 @@ icon_cache_close(void) if (icon_fallback_cache) eet_close(icon_fallback_cache); icon_fallback_cache = NULL; IF_RELEASE(icon_cache_name); - IF_RELEASE(icon_cache_file); } -- 2.7.4