efreet can actually free icons now... and flush the cache explicitly
SVN revision: 30328
This commit is contained in:
parent
d9d4d5ee8e
commit
b784b8142a
|
@ -26,6 +26,7 @@ static Ecore_List *efreet_desktop_types = NULL;
|
||||||
static int efreet_desktop_command_file_id = 0;
|
static int efreet_desktop_command_file_id = 0;
|
||||||
|
|
||||||
static int init = 0;
|
static int init = 0;
|
||||||
|
static int cache_flush = 0;
|
||||||
|
|
||||||
int EFREET_DESKTOP_TYPE_APPLICATION = 0;
|
int EFREET_DESKTOP_TYPE_APPLICATION = 0;
|
||||||
int EFREET_DESKTOP_TYPE_LINK = 0;
|
int EFREET_DESKTOP_TYPE_LINK = 0;
|
||||||
|
@ -167,7 +168,9 @@ efreet_desktop_cache_check(Efreet_Desktop *desktop)
|
||||||
if (!desktop) return 0;
|
if (!desktop) return 0;
|
||||||
|
|
||||||
/* have we modified this file since we last read it in? */
|
/* have we modified this file since we last read it in? */
|
||||||
if (stat(desktop->orig_path, &buf) || (buf.st_mtime > desktop->load_time))
|
if ((desktop->cache_flush != cache_flush) ||
|
||||||
|
(stat(desktop->orig_path, &buf) ||
|
||||||
|
(buf.st_mtime > desktop->load_time)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -191,12 +194,20 @@ efreet_desktop_get(const char *file)
|
||||||
if (desktop)
|
if (desktop)
|
||||||
{
|
{
|
||||||
if (efreet_desktop_cache_check(desktop))
|
if (efreet_desktop_cache_check(desktop))
|
||||||
|
{
|
||||||
|
desktop->ref++;
|
||||||
return desktop;
|
return desktop;
|
||||||
|
}
|
||||||
|
|
||||||
efreet_desktop_clear(desktop);
|
efreet_desktop_clear(desktop);
|
||||||
if (efreet_desktop_read(desktop))
|
if (efreet_desktop_read(desktop))
|
||||||
|
{
|
||||||
|
desktop->ref++;
|
||||||
|
desktop->cache_flush = cache_flush;
|
||||||
return desktop;
|
return desktop;
|
||||||
|
}
|
||||||
|
|
||||||
|
desktop->cached = 0;
|
||||||
ecore_hash_remove(efreet_desktop_cache, file);
|
ecore_hash_remove(efreet_desktop_cache, file);
|
||||||
efreet_desktop_free(desktop);
|
efreet_desktop_free(desktop);
|
||||||
}
|
}
|
||||||
|
@ -206,8 +217,8 @@ efreet_desktop_get(const char *file)
|
||||||
if (!desktop) return NULL;
|
if (!desktop) return NULL;
|
||||||
|
|
||||||
ecore_hash_set(efreet_desktop_cache, strdup(file), desktop);
|
ecore_hash_set(efreet_desktop_cache, strdup(file), desktop);
|
||||||
|
desktop->cached = 1;
|
||||||
return desktop;
|
return desktop;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -225,6 +236,9 @@ efreet_desktop_empty_new(const char *file)
|
||||||
|
|
||||||
desktop->orig_path = strdup(file);
|
desktop->orig_path = strdup(file);
|
||||||
desktop->load_time = ecore_time_get();
|
desktop->load_time = ecore_time_get();
|
||||||
|
|
||||||
|
desktop->ref = 1;
|
||||||
|
|
||||||
return desktop;
|
return desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +264,10 @@ efreet_desktop_new(const char *file)
|
||||||
efreet_desktop_free(desktop);
|
efreet_desktop_free(desktop);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
desktop->ref = 1;
|
||||||
|
desktop->cache_flush = cache_flush;
|
||||||
|
|
||||||
return desktop;
|
return desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,10 +418,13 @@ efreet_desktop_save(Efreet_Desktop *desktop)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (desktop != ecore_hash_get(efreet_desktop_cache, desktop->orig_path))
|
if (desktop != ecore_hash_get(efreet_desktop_cache, desktop->orig_path))
|
||||||
|
{
|
||||||
|
desktop->cached = 1;
|
||||||
ecore_hash_set(efreet_desktop_cache,
|
ecore_hash_set(efreet_desktop_cache,
|
||||||
strdup(desktop->orig_path), desktop);
|
strdup(desktop->orig_path), desktop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
efreet_ini_free(ini);
|
efreet_ini_free(ini);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@ -418,7 +439,10 @@ int
|
||||||
efreet_desktop_save_as(Efreet_Desktop *desktop, const char *file)
|
efreet_desktop_save_as(Efreet_Desktop *desktop, const char *file)
|
||||||
{
|
{
|
||||||
if (desktop == ecore_hash_get(efreet_desktop_cache, desktop->orig_path))
|
if (desktop == ecore_hash_get(efreet_desktop_cache, desktop->orig_path))
|
||||||
|
{
|
||||||
|
desktop->cached = 0;
|
||||||
ecore_hash_remove(efreet_desktop_cache, desktop->orig_path);
|
ecore_hash_remove(efreet_desktop_cache, desktop->orig_path);
|
||||||
|
}
|
||||||
FREE(desktop->orig_path);
|
FREE(desktop->orig_path);
|
||||||
desktop->orig_path = strdup(file);
|
desktop->orig_path = strdup(file);
|
||||||
return efreet_desktop_save(desktop);
|
return efreet_desktop_save(desktop);
|
||||||
|
@ -435,6 +459,12 @@ efreet_desktop_free(Efreet_Desktop *desktop)
|
||||||
{
|
{
|
||||||
if (!desktop) return;
|
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->orig_path);
|
||||||
|
|
||||||
IF_FREE(desktop->name);
|
IF_FREE(desktop->name);
|
||||||
|
@ -717,6 +747,19 @@ efreet_desktop_string_list_join(Ecore_List *list)
|
||||||
return string;
|
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++;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @param desktop: the Efreet_Desktop to store parsed fields in
|
* @param desktop: the Efreet_Desktop to store parsed fields in
|
||||||
|
|
|
@ -63,6 +63,9 @@ struct Efreet_Desktop
|
||||||
{
|
{
|
||||||
int type; /**< type of desktop file */
|
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 */
|
double version; /**< version of spec file conforms to */
|
||||||
|
|
||||||
char *orig_path; /**< original path to .desktop file */
|
char *orig_path; /**< original path to .desktop file */
|
||||||
|
@ -90,6 +93,7 @@ struct Efreet_Desktop
|
||||||
unsigned char hidden:1; /**< User delete the item */
|
unsigned char hidden:1; /**< User delete the item */
|
||||||
unsigned char terminal:1; /**< Does the program run in a terminal */
|
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 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- */
|
Ecore_Hash *x; /**< Keep track of all user extensions, keys that begin with X- */
|
||||||
void *type_data; /**< Type specific data for custom types */
|
void *type_data; /**< Type specific data for custom types */
|
||||||
|
@ -131,6 +135,7 @@ void *efreet_desktop_type_data_get(Efreet_Desktop *desktop);
|
||||||
|
|
||||||
Ecore_List *efreet_desktop_string_list_parse(const char *string);
|
Ecore_List *efreet_desktop_string_list_parse(const char *string);
|
||||||
char *efreet_desktop_string_list_join(Ecore_List *list);
|
char *efreet_desktop_string_list_join(Ecore_List *list);
|
||||||
|
void efreet_desktop_cache_flush(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
|
Loading…
Reference in New Issue