2009-04-20 16:20:40 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#include <Ecore.h>
|
|
|
|
#include <Ecore_File.h>
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
#include "Efreet.h"
|
|
|
|
#include "efreet_private.h"
|
|
|
|
|
2010-11-15 13:07:05 -08:00
|
|
|
/* TODO: Scan efreet_extra_icon_dirs for themes */
|
|
|
|
|
2007-04-14 21:51:37 -07:00
|
|
|
static char *efreet_icon_deprecated_user_dir = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
static char *efreet_icon_user_dir = NULL;
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Hash *efreet_icon_themes = NULL;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
static Eina_List *efreet_icon_extensions = NULL;
|
|
|
|
static Eina_List *efreet_extra_icon_dirs = NULL;
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Hash *efreet_icon_cache = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-08-14 22:33:04 -07:00
|
|
|
typedef struct Efreet_Icon_Cache Efreet_Icon_Cache;
|
|
|
|
struct Efreet_Icon_Cache
|
|
|
|
{
|
2010-04-01 12:41:03 -07:00
|
|
|
const char *key;
|
|
|
|
const char *path;
|
2007-08-14 22:33:04 -07:00
|
|
|
time_t lasttime;
|
|
|
|
};
|
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
static char *efreet_icon_remove_extension(const char *icon);
|
|
|
|
static Efreet_Icon_Theme *efreet_icon_find_theme_check(const char *theme_name);
|
|
|
|
|
|
|
|
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *efreet_icon_find_fallback(Efreet_Icon_Theme *theme,
|
2007-07-26 04:30:10 -07:00
|
|
|
const char *icon,
|
2008-08-14 13:02:07 -07:00
|
|
|
unsigned int size);
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *efreet_icon_list_find_fallback(Efreet_Icon_Theme *theme,
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *icons,
|
2008-08-14 13:02:07 -07:00
|
|
|
unsigned int size);
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *efreet_icon_find_helper(Efreet_Icon_Theme *theme,
|
2008-08-14 13:02:07 -07:00
|
|
|
const char *icon, unsigned int size);
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *efreet_icon_list_find_helper(Efreet_Icon_Theme *theme,
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *icons, unsigned int size);
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *efreet_icon_lookup_icon(Efreet_Icon_Theme *theme,
|
2008-08-14 13:02:07 -07:00
|
|
|
const char *icon_name, unsigned int size);
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *efreet_icon_fallback_icon(const char *icon_name);
|
|
|
|
static const char *efreet_icon_fallback_dir_scan(const char *dir,
|
|
|
|
const char *icon_name);
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *efreet_icon_lookup_directory(Efreet_Icon_Theme *theme,
|
2007-07-26 04:30:10 -07:00
|
|
|
Efreet_Icon_Theme_Directory *dir,
|
|
|
|
const char *icon_name);
|
2010-05-16 11:41:56 -07:00
|
|
|
static double efreet_icon_directory_size_distance(Efreet_Icon_Theme_Directory *dir,
|
2007-02-03 05:05:30 -08:00
|
|
|
unsigned int size);
|
2007-07-26 04:30:10 -07:00
|
|
|
static int efreet_icon_directory_size_match(Efreet_Icon_Theme_Directory *dir,
|
2007-02-03 05:05:30 -08:00
|
|
|
unsigned int size);
|
|
|
|
|
|
|
|
static Efreet_Icon *efreet_icon_new(const char *path);
|
|
|
|
static void efreet_icon_populate(Efreet_Icon *icon, const char *file);
|
|
|
|
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *efreet_icon_lookup_directory_helper(Efreet_Icon_Theme_Directory *dir,
|
2007-07-26 04:30:10 -07:00
|
|
|
const char *path, const char *icon_name);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
static Efreet_Icon_Theme *efreet_icon_theme_new(void);
|
|
|
|
static void efreet_icon_theme_free(Efreet_Icon_Theme *theme);
|
|
|
|
static void efreet_icon_theme_dir_scan_all(const char *theme_name);
|
|
|
|
static void efreet_icon_theme_dir_scan(const char *dir,
|
|
|
|
const char *theme_name);
|
|
|
|
static void efreet_icon_theme_dir_validity_check(void);
|
2007-07-26 04:30:10 -07:00
|
|
|
static void efreet_icon_theme_path_add(Efreet_Icon_Theme *theme,
|
2007-02-03 05:05:30 -08:00
|
|
|
const char *path);
|
2007-07-26 04:30:10 -07:00
|
|
|
static void efreet_icon_theme_index_read(Efreet_Icon_Theme *theme,
|
2007-02-03 05:05:30 -08:00
|
|
|
const char *path);
|
|
|
|
|
2007-07-26 04:30:10 -07:00
|
|
|
static Efreet_Icon_Theme_Directory *efreet_icon_theme_directory_new(Efreet_Ini *ini,
|
2007-02-03 05:05:30 -08:00
|
|
|
const char *name);
|
2009-03-23 03:27:54 -07:00
|
|
|
static void efreet_icon_theme_directory_free(Efreet_Icon_Theme_Directory *dir);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
static void efreet_icon_theme_cache_check(Efreet_Icon_Theme *theme);
|
2007-07-26 04:30:10 -07:00
|
|
|
static int efreet_icon_theme_cache_check_dir(Efreet_Icon_Theme *theme,
|
2007-02-03 05:05:30 -08:00
|
|
|
const char *dir);
|
|
|
|
|
2007-08-14 22:33:04 -07:00
|
|
|
static void efreet_icon_cache_free(Efreet_Icon_Cache *value);
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *efreet_icon_cache_check(Efreet_Icon_Theme *theme, const char *icon, unsigned int size);
|
2008-08-14 13:02:07 -07:00
|
|
|
static void efreet_icon_cache_add(Efreet_Icon_Theme *theme, const char *icon, unsigned int size, const char *value);
|
2007-08-14 22:33:04 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @return Returns 1 on success or 0 on failure
|
|
|
|
* @brief Initializes the icon system
|
|
|
|
*/
|
2007-07-26 04:30:10 -07:00
|
|
|
int
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_init(void)
|
|
|
|
{
|
|
|
|
if (!efreet_icon_themes)
|
|
|
|
{
|
2010-05-15 10:55:41 -07:00
|
|
|
const char *default_exts[] = {".png", ".xpm", NULL};
|
2007-02-03 05:05:30 -08:00
|
|
|
int i;
|
|
|
|
|
2007-07-19 07:54:51 -07:00
|
|
|
if (!ecore_init())
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
/* setup the default extension list */
|
2010-08-21 06:52:25 -07:00
|
|
|
for (i = 0; default_exts[i]; i++)
|
2010-04-01 12:41:03 -07:00
|
|
|
efreet_icon_extensions = eina_list_append(efreet_icon_extensions, eina_stringshare_add(default_exts[i]));
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_theme_free));
|
2007-08-14 22:33:04 -07:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
efreet_extra_icon_dirs = NULL;
|
2010-08-04 05:23:00 -07:00
|
|
|
efreet_icon_cache = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_cache_free));
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Shuts down the icon system
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
efreet_icon_shutdown(void)
|
|
|
|
{
|
|
|
|
IF_FREE(efreet_icon_user_dir);
|
2007-06-22 03:20:44 -07:00
|
|
|
IF_FREE(efreet_icon_deprecated_user_dir);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
IF_FREE_LIST(efreet_icon_extensions, eina_stringshare_del);
|
2007-02-03 05:05:30 -08:00
|
|
|
IF_FREE_HASH(efreet_icon_themes);
|
2009-03-23 05:19:31 -07:00
|
|
|
efreet_extra_icon_dirs = eina_list_free(efreet_extra_icon_dirs);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2008-08-14 12:47:48 -07:00
|
|
|
IF_FREE_HASH(efreet_icon_cache);
|
2007-08-14 22:33:04 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
ecore_shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Returns the user icon directory
|
|
|
|
* @brief Returns the user icon directory
|
|
|
|
*/
|
2010-08-17 05:03:10 -07:00
|
|
|
static const char *
|
2007-04-14 21:51:37 -07:00
|
|
|
efreet_icon_deprecated_user_dir_get(void)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
const char *user;
|
|
|
|
int len;
|
|
|
|
|
2007-04-14 21:51:37 -07:00
|
|
|
if (efreet_icon_deprecated_user_dir) return efreet_icon_deprecated_user_dir;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
user = efreet_home_dir_get();
|
|
|
|
len = strlen(user) + strlen("/.icons") + 1;
|
2010-08-03 12:31:34 -07:00
|
|
|
efreet_icon_deprecated_user_dir = malloc(len);
|
|
|
|
if (!efreet_icon_deprecated_user_dir) return NULL;
|
2007-04-14 21:51:37 -07:00
|
|
|
snprintf(efreet_icon_deprecated_user_dir, len, "%s/.icons", user);
|
|
|
|
|
|
|
|
return efreet_icon_deprecated_user_dir;
|
|
|
|
}
|
|
|
|
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI const char *
|
2007-04-14 21:51:37 -07:00
|
|
|
efreet_icon_user_dir_get(void)
|
|
|
|
{
|
|
|
|
const char *user;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (efreet_icon_user_dir) return efreet_icon_user_dir;
|
|
|
|
|
|
|
|
user = efreet_data_home_get();
|
|
|
|
len = strlen(user) + strlen("/icons") + 1;
|
2010-08-03 12:31:34 -07:00
|
|
|
efreet_icon_user_dir = malloc(len);
|
|
|
|
if (!efreet_icon_user_dir) return NULL;
|
2007-04-14 21:51:37 -07:00
|
|
|
snprintf(efreet_icon_user_dir, len, "%s/icons", user);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
return efreet_icon_user_dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ext: The extension to add to the list of checked extensions
|
|
|
|
* @return Returns no value.
|
|
|
|
* @brief Adds the given extension to the list of possible icon extensions
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI void
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_extension_add(const char *ext)
|
|
|
|
{
|
2010-05-15 10:55:41 -07:00
|
|
|
Eina_List *l;
|
2010-05-17 12:45:20 -07:00
|
|
|
|
2010-05-15 10:55:41 -07:00
|
|
|
ext = eina_stringshare_add(ext);
|
2010-05-17 12:45:20 -07:00
|
|
|
|
2010-05-15 10:55:41 -07:00
|
|
|
if ((l = eina_list_data_find_list(efreet_icon_extensions, ext)))
|
|
|
|
{
|
2010-05-15 11:38:50 -07:00
|
|
|
efreet_icon_extensions = eina_list_promote_list(efreet_icon_extensions, l);
|
|
|
|
eina_stringshare_del(ext);
|
2010-05-15 10:55:41 -07:00
|
|
|
}
|
2010-05-15 11:38:50 -07:00
|
|
|
else
|
|
|
|
efreet_icon_extensions = eina_list_prepend(efreet_icon_extensions, ext);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
2007-03-30 18:16:15 -07:00
|
|
|
/**
|
|
|
|
* @return Returns a list of strings that are paths to other icon directories
|
|
|
|
* @brief Gets the list of all extra directories to look for icons. These
|
|
|
|
* directories are used to look for icons after looking in the user icon dir
|
|
|
|
* and before looking in standard system directories. The order of search is
|
|
|
|
* from first to last directory in this list. the strings in the list should
|
2008-10-15 07:48:03 -07:00
|
|
|
* be created with eina_stringshare_add().
|
2007-03-30 18:16:15 -07:00
|
|
|
*/
|
2009-02-25 19:46:35 -08:00
|
|
|
EAPI Eina_List **
|
2007-03-30 18:16:15 -07:00
|
|
|
efreet_icon_extra_list_get(void)
|
|
|
|
{
|
2009-02-25 19:46:35 -08:00
|
|
|
return &efreet_extra_icon_dirs;
|
2007-03-30 18:16:15 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
2009-02-26 14:35:38 -08:00
|
|
|
_hash_keys(Eina_Hash *hash __UNUSED__, const void *key, void *list)
|
2008-12-17 07:33:43 -08:00
|
|
|
{
|
2010-02-04 01:12:35 -08:00
|
|
|
*(Eina_List**)list = eina_list_append(*(Eina_List**)list, key);
|
|
|
|
return EINA_TRUE;
|
2008-12-17 07:33:43 -08:00
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
/**
|
|
|
|
* @return Returns a list of Efreet_Icon structs for all the non-hidden icon
|
2007-07-26 04:30:10 -07:00
|
|
|
* themes
|
|
|
|
* @brief Retrieves all of the non-hidden icon themes available on the system.
|
2007-02-03 05:05:30 -08:00
|
|
|
* The returned list must be freed. Do not free the list data.
|
|
|
|
*/
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EAPI Eina_List *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_theme_list_get(void)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *list = NULL;
|
|
|
|
Eina_List *theme_list = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
char *dir;
|
2008-12-17 07:33:43 -08:00
|
|
|
Eina_Iterator *it;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-03-25 10:28:49 -07:00
|
|
|
/* update the list to include all icon themes */
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_theme_dir_scan_all(NULL);
|
|
|
|
efreet_icon_theme_dir_validity_check();
|
|
|
|
|
|
|
|
/* create the list for the user */
|
2008-12-17 07:33:43 -08:00
|
|
|
it = eina_hash_iterator_key_new(efreet_icon_themes);
|
2010-08-11 07:32:30 -07:00
|
|
|
eina_iterator_foreach(it, EINA_EACH_CB(_hash_keys), &theme_list);
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_iterator_free(it);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
|
|
|
EINA_LIST_FREE(theme_list, dir)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *theme;
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
theme = eina_hash_find(efreet_icon_themes, dir);
|
2007-02-03 05:05:30 -08:00
|
|
|
if (theme->hidden || theme->fake) continue;
|
2007-04-04 03:41:53 -07:00
|
|
|
#ifndef STRICT_SPEC
|
2007-03-24 04:23:29 -07:00
|
|
|
if (!theme->name.name) continue;
|
|
|
|
#endif
|
2007-02-03 05:05:30 -08:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
list = eina_list_append(list, theme);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param theme_name: The theme to look for
|
|
|
|
* @return Returns the icon theme related to the given theme name or NULL if
|
|
|
|
* none exists.
|
|
|
|
* @brief Tries to get the icon theme structure for the given theme name
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI Efreet_Icon_Theme *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_theme_find(const char *theme_name)
|
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *theme;
|
|
|
|
|
2010-08-04 05:23:00 -07:00
|
|
|
if (!theme_name) return NULL;
|
2009-02-25 08:46:51 -08:00
|
|
|
|
|
|
|
theme = eina_hash_find(efreet_icon_themes, theme_name);
|
2007-02-03 05:05:30 -08:00
|
|
|
if (!theme)
|
|
|
|
{
|
|
|
|
efreet_icon_theme_dir_scan_all(theme_name);
|
2009-02-25 08:46:51 -08:00
|
|
|
theme = eina_hash_find(efreet_icon_themes, theme_name);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return theme;
|
|
|
|
}
|
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param icon: The icon name to strip extension
|
|
|
|
* @return Extension removed if in list of extensions, else untouched.
|
|
|
|
* @brief Removes extension from icon name if in list of extensions.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
efreet_icon_remove_extension(const char *icon)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2007-07-17 12:21:20 -07:00
|
|
|
char *tmp = NULL, *ext = NULL;
|
|
|
|
|
2009-09-14 13:18:25 -07:00
|
|
|
if (!icon) return NULL;
|
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
tmp = strdup(icon);
|
|
|
|
ext = strrchr(tmp, '.');
|
|
|
|
if (ext)
|
|
|
|
{
|
|
|
|
const char *ext2;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(efreet_icon_extensions, l, ext2)
|
2007-07-17 12:21:20 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(ext, ext2))
|
|
|
|
{
|
|
|
|
#ifdef STRICT_SPEC
|
2009-09-21 09:36:29 -07:00
|
|
|
WRN("[Efreet]: Requesting an icon with an extension: %s",
|
2007-07-17 12:21:20 -07:00
|
|
|
icon);
|
|
|
|
#endif
|
|
|
|
*ext = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme_name: The icon theme to look for
|
|
|
|
* @return Returns the Efreet_Icon_Theme structure representing this theme
|
|
|
|
* or a new blank theme if not found
|
|
|
|
* @brief Retrieves a theme, or creates a blank one if not found.
|
|
|
|
*/
|
|
|
|
static Efreet_Icon_Theme *
|
|
|
|
efreet_icon_find_theme_check(const char *theme_name)
|
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *theme = NULL;
|
2010-08-04 05:23:00 -07:00
|
|
|
if (!theme_name) return NULL;
|
|
|
|
theme = efreet_icon_theme_find(theme_name);
|
2007-07-17 12:21:20 -07:00
|
|
|
if (!theme)
|
|
|
|
{
|
|
|
|
theme = efreet_icon_theme_new();
|
2010-08-03 13:46:36 -07:00
|
|
|
if (!theme) return NULL;
|
2007-07-17 12:21:20 -07:00
|
|
|
theme->fake = 1;
|
2010-08-04 05:23:00 -07:00
|
|
|
theme->name.internal = eina_stringshare_add(theme_name);
|
|
|
|
eina_hash_add(efreet_icon_themes, (void *)theme->name.internal, theme);
|
2007-07-26 04:30:10 -07:00
|
|
|
}
|
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
return theme;
|
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
/**
|
|
|
|
* @param theme_name: The icon theme to look for
|
|
|
|
* @param icon: The icon to look for
|
|
|
|
* @param size; The icon size to look for
|
2007-08-14 22:33:04 -07:00
|
|
|
* @return Returns the path to the given icon or NULL if none found
|
|
|
|
* @brief Retrives the path to the given icon.
|
2007-02-03 05:05:30 -08:00
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
EAPI const char *
|
2008-08-14 13:48:41 -07:00
|
|
|
efreet_icon_path_find(const char *theme_name, const char *icon, unsigned int size)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *value = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Icon_Theme *theme;
|
2007-09-06 09:15:10 -07:00
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
theme = efreet_icon_find_theme_check(theme_name);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-08-04 05:23:00 -07:00
|
|
|
if (theme)
|
2010-08-03 14:32:45 -07:00
|
|
|
{
|
2010-08-04 05:23:00 -07:00
|
|
|
#ifdef SLOPPY_SPEC
|
|
|
|
{
|
|
|
|
char *tmp;
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2010-08-04 05:23:00 -07:00
|
|
|
tmp = efreet_icon_remove_extension(icon);
|
|
|
|
if (!tmp) return NULL;
|
|
|
|
value = efreet_icon_find_helper(theme, tmp, size);
|
|
|
|
FREE(tmp);
|
|
|
|
}
|
2007-04-04 04:52:46 -07:00
|
|
|
#else
|
2010-08-04 05:23:00 -07:00
|
|
|
value = efreet_icon_find_helper(theme, icon, size);
|
2007-04-04 04:52:46 -07:00
|
|
|
#endif
|
2010-08-04 05:23:00 -07:00
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
/* we didn't find the icon in the theme or in the inherited directories
|
2007-07-26 04:30:10 -07:00
|
|
|
* then just look for a non theme icon
|
2007-07-17 12:21:20 -07:00
|
|
|
*/
|
2008-08-18 23:32:40 -07:00
|
|
|
if (!value || (value == NON_EXISTING)) value = efreet_icon_fallback_icon(icon);
|
2007-08-14 22:33:04 -07:00
|
|
|
|
2008-08-18 23:32:40 -07:00
|
|
|
if (value == NON_EXISTING) value = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
/**
|
|
|
|
* @param theme_name: The icon theme to look for
|
2008-08-02 14:48:44 -07:00
|
|
|
* @param icons: List of icons to look for
|
2007-07-17 12:21:20 -07:00
|
|
|
* @param size; The icon size to look for
|
2007-07-26 04:30:10 -07:00
|
|
|
* @return Returns the path representing first found icon or
|
2007-07-17 12:21:20 -07:00
|
|
|
* NULL if none of the icons are found
|
2007-07-26 04:30:10 -07:00
|
|
|
* @brief Retrieves all of the information about the first found icon in
|
2007-07-17 12:21:20 -07:00
|
|
|
* the list.
|
|
|
|
* @note This function will search the given theme for all icons before falling
|
2007-07-26 04:30:10 -07:00
|
|
|
* back. This is useful when searching for mimetype icons.
|
2007-07-17 12:21:20 -07:00
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
EAPI const char *
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
efreet_icon_list_find(const char *theme_name, Eina_List *icons,
|
2008-08-14 13:48:41 -07:00
|
|
|
unsigned int size)
|
2007-07-17 12:21:20 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2007-07-17 12:21:20 -07:00
|
|
|
const char *icon = NULL;
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *value = NULL;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
char *data;
|
2007-07-17 12:21:20 -07:00
|
|
|
Efreet_Icon_Theme *theme;
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
theme = efreet_icon_find_theme_check(theme_name);
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2010-08-04 05:23:00 -07:00
|
|
|
if (theme)
|
2010-08-03 14:32:45 -07:00
|
|
|
{
|
2010-08-04 05:23:00 -07:00
|
|
|
#ifdef SLOPPY_SPEC
|
2010-08-03 14:32:45 -07:00
|
|
|
{
|
2010-08-04 05:23:00 -07:00
|
|
|
Eina_List *tmps = NULL;
|
2010-08-03 14:32:45 -07:00
|
|
|
|
2010-08-04 05:23:00 -07:00
|
|
|
EINA_LIST_FOREACH(icons, l, icon)
|
|
|
|
{
|
|
|
|
data = efreet_icon_remove_extension(icon);
|
|
|
|
if (!data) return NULL;
|
|
|
|
tmps = eina_list_append(tmps, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
value = efreet_icon_list_find_helper(theme, tmps, size);
|
|
|
|
EINA_LIST_FREE(tmps, data)
|
|
|
|
free(data);
|
|
|
|
}
|
2007-07-17 12:21:20 -07:00
|
|
|
#else
|
2010-08-04 05:23:00 -07:00
|
|
|
value = efreet_icon_list_find_helper(theme, icons, size);
|
2007-07-17 12:21:20 -07:00
|
|
|
#endif
|
2010-08-04 05:23:00 -07:00
|
|
|
}
|
2007-07-17 12:21:20 -07:00
|
|
|
|
|
|
|
/* we didn't find the icons in the theme or in the inherited directories
|
2007-07-26 04:30:10 -07:00
|
|
|
* then just look for a non theme icon
|
2007-07-17 12:21:20 -07:00
|
|
|
*/
|
2008-08-18 23:32:40 -07:00
|
|
|
if (!value || (value == NON_EXISTING))
|
2007-07-17 12:21:20 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(icons, l, icon)
|
2007-07-17 12:21:20 -07:00
|
|
|
{
|
2008-08-14 12:47:48 -07:00
|
|
|
value = efreet_icon_fallback_icon(icon);
|
2008-08-18 23:32:40 -07:00
|
|
|
if (value && (value != NON_EXISTING))
|
2007-07-17 12:21:20 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-18 23:32:40 -07:00
|
|
|
if (value == NON_EXISTING) value = NULL;
|
2007-07-17 12:21:20 -07:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
/**
|
|
|
|
* @param theme: The icon theme to look for
|
|
|
|
* @param icon: The icon to look for
|
|
|
|
* @param size: The icon size to look for
|
2007-08-14 22:33:04 -07:00
|
|
|
* @return Returns the Efreet_Icon structure representing this icon or NULL
|
|
|
|
* if the icon is not found
|
|
|
|
* @brief Retrieves all of the information about the given icon.
|
2007-02-03 05:05:30 -08:00
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI Efreet_Icon *
|
2008-08-14 13:48:41 -07:00
|
|
|
efreet_icon_find(const char *theme_name, const char *icon, unsigned int size)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *path;
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2008-08-14 09:59:41 -07:00
|
|
|
path = efreet_icon_path_find(theme_name, icon, size);
|
2007-07-26 04:30:10 -07:00
|
|
|
if (path)
|
|
|
|
{
|
2010-03-01 13:43:59 -08:00
|
|
|
Efreet_Icon *ic;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-03-01 13:43:59 -08:00
|
|
|
ic = efreet_icon_new(path);
|
|
|
|
return ic;
|
2007-07-26 04:30:10 -07:00
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-07-26 04:30:10 -07:00
|
|
|
return NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The theme to search in
|
|
|
|
* @param icon: The icon to search for
|
|
|
|
* @param size: The size to search for
|
|
|
|
* @return Returns the icon matching the given information or NULL if no
|
|
|
|
* icon found
|
|
|
|
* @brief Scans inheriting themes for the given icon
|
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *
|
2007-07-26 04:30:10 -07:00
|
|
|
efreet_icon_find_fallback(Efreet_Icon_Theme *theme,
|
2008-08-14 13:02:07 -07:00
|
|
|
const char *icon, unsigned int size)
|
2007-07-17 12:21:20 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *parent = NULL;
|
|
|
|
const char *value = NULL;
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
if (theme->inherits)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(theme->inherits, l, parent)
|
2007-07-17 12:21:20 -07:00
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *parent_theme;
|
|
|
|
|
|
|
|
parent_theme = efreet_icon_theme_find(parent);
|
|
|
|
if ((!parent_theme) || (parent_theme == theme)) continue;
|
|
|
|
|
2007-07-26 04:30:10 -07:00
|
|
|
value = efreet_icon_find_helper(parent_theme, icon, size);
|
2008-08-18 23:32:40 -07:00
|
|
|
if (value && (value != NON_EXISTING)) break;
|
2007-07-17 12:21:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* if this isn't the hicolor theme, and we have no other fallbacks
|
|
|
|
* check hicolor */
|
|
|
|
else if (strcmp(theme->name.internal, "hicolor"))
|
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *parent_theme;
|
|
|
|
|
|
|
|
parent_theme = efreet_icon_theme_find("hicolor");
|
|
|
|
if (parent_theme)
|
2007-07-26 04:30:10 -07:00
|
|
|
value = efreet_icon_find_helper(parent_theme, icon, size);
|
2007-07-17 12:21:20 -07:00
|
|
|
}
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The theme to search in
|
|
|
|
* @param icon: The icon to search for
|
|
|
|
* @param size: The size to search for
|
|
|
|
* @return Returns the icon matching the given information or NULL if no
|
|
|
|
* icon found
|
|
|
|
* @brief Scans the theme and any inheriting themes for the given icon
|
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *
|
2007-07-26 04:30:10 -07:00
|
|
|
efreet_icon_find_helper(Efreet_Icon_Theme *theme,
|
2008-08-14 13:02:07 -07:00
|
|
|
const char *icon, unsigned int size)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *value;
|
2007-07-17 12:21:20 -07:00
|
|
|
static int recurse = 0;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
efreet_icon_theme_cache_check(theme);
|
|
|
|
|
|
|
|
|
2007-05-25 23:45:51 -07:00
|
|
|
/* limit recursion in finding themes and inherited themes to 256 levels */
|
|
|
|
if (recurse > 256) return NULL;
|
|
|
|
recurse++;
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2010-08-14 20:01:55 -07:00
|
|
|
/* go no further if this theme is fake */
|
|
|
|
if (theme->fake || !theme->valid)
|
2010-08-15 12:54:19 -07:00
|
|
|
value = NULL;
|
2010-08-14 20:01:55 -07:00
|
|
|
else
|
2010-08-15 12:54:19 -07:00
|
|
|
value = efreet_icon_lookup_icon(theme, icon, size);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
/* we didin't find the image check the inherited themes */
|
2008-08-18 23:32:40 -07:00
|
|
|
if (!value || (value == NON_EXISTING))
|
2007-07-26 04:30:10 -07:00
|
|
|
value = efreet_icon_find_fallback(theme, icon, size);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
recurse--;
|
|
|
|
return value;
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The theme to search in
|
|
|
|
* @param icons: The icons to search for
|
|
|
|
* @param size: The size to search for
|
|
|
|
* @return Returns the icon matching the given information or NULL if no
|
|
|
|
* icon found
|
|
|
|
* @brief Scans inheriting themes for the given icons
|
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *
|
2007-07-26 04:30:10 -07:00
|
|
|
efreet_icon_list_find_fallback(Efreet_Icon_Theme *theme,
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *icons, unsigned int size)
|
2007-07-17 12:21:20 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *parent = NULL;
|
|
|
|
const char *value = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
if (theme->inherits)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(theme->inherits, l, parent)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *parent_theme;
|
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
parent_theme = efreet_icon_theme_find(parent);
|
|
|
|
if ((!parent_theme) || (parent_theme == theme)) continue;
|
|
|
|
|
2007-07-26 04:30:10 -07:00
|
|
|
value = efreet_icon_list_find_helper(parent_theme,
|
2007-07-17 12:21:20 -07:00
|
|
|
icons, size);
|
2008-08-18 23:32:40 -07:00
|
|
|
if (value && (value != NON_EXISTING)) break;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
}
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
/* if this isn't the hicolor theme, and we have no other fallbacks
|
2007-07-26 04:30:10 -07:00
|
|
|
* check hicolor
|
2007-07-17 12:21:20 -07:00
|
|
|
*/
|
|
|
|
else if (strcmp(theme->name.internal, "hicolor"))
|
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *parent_theme;
|
|
|
|
|
|
|
|
parent_theme = efreet_icon_theme_find("hicolor");
|
|
|
|
if (parent_theme)
|
2007-07-26 04:30:10 -07:00
|
|
|
value = efreet_icon_list_find_helper(parent_theme,
|
2007-07-17 12:21:20 -07:00
|
|
|
icons, size);
|
|
|
|
}
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2007-07-17 12:21:20 -07:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The theme to search in
|
|
|
|
* @param icons: The icons to search for
|
|
|
|
* @param size: The size to search for
|
|
|
|
* @return Returns the icon matching the given information or NULL if no
|
|
|
|
* icon found
|
|
|
|
* @brief Scans the theme and any inheriting themes for the given icons
|
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *
|
2007-07-26 04:30:10 -07:00
|
|
|
efreet_icon_list_find_helper(Efreet_Icon_Theme *theme,
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *icons, unsigned int size)
|
2007-07-17 12:21:20 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *value = NULL;
|
2007-07-17 12:21:20 -07:00
|
|
|
const char *icon = NULL;
|
|
|
|
static int recurse = 0;
|
|
|
|
|
|
|
|
efreet_icon_theme_cache_check(theme);
|
|
|
|
|
|
|
|
/* go no further if this theme is fake */
|
|
|
|
if (theme->fake || !theme->valid) return NULL;
|
|
|
|
|
|
|
|
/* limit recursion in finding themes and inherited themes to 256 levels */
|
|
|
|
if (recurse > 256) return NULL;
|
|
|
|
recurse++;
|
2007-07-26 04:30:10 -07:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(icons, l, icon)
|
2007-07-17 12:21:20 -07:00
|
|
|
{
|
2008-08-14 12:47:48 -07:00
|
|
|
value = efreet_icon_lookup_icon(theme, icon, size);
|
2008-08-18 23:32:40 -07:00
|
|
|
if (value && (value != NON_EXISTING))
|
2007-07-17 12:21:20 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we didn't find the image check the inherited themes */
|
2008-08-18 23:32:40 -07:00
|
|
|
if (!value || (value == NON_EXISTING))
|
2007-07-26 04:30:10 -07:00
|
|
|
value = efreet_icon_list_find_fallback(theme, icons, size);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-05-25 23:45:51 -07:00
|
|
|
recurse--;
|
2007-02-03 05:05:30 -08:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The icon theme to look in
|
|
|
|
* @param icon_name: The icon name to look for
|
|
|
|
* @param size: The icon size to look for
|
2007-07-26 04:30:10 -07:00
|
|
|
* @return Returns the path for the theme/icon/size combo or NULL if
|
2007-02-03 05:05:30 -08:00
|
|
|
* none found
|
|
|
|
* @brief Looks for the @a icon in the @a theme for the @a size given.
|
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *
|
2007-07-26 04:30:10 -07:00
|
|
|
efreet_icon_lookup_icon(Efreet_Icon_Theme *theme, const char *icon_name,
|
2008-08-14 13:02:07 -07:00
|
|
|
unsigned int size)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *icon = NULL, *tmp = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Icon_Theme_Directory *dir;
|
2010-05-16 11:42:43 -07:00
|
|
|
double minimal_distance = INT_MAX;
|
2010-05-16 14:02:52 -07:00
|
|
|
unsigned int ret_size = 0;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-08-21 06:52:25 -07:00
|
|
|
if (!theme || (!theme->paths) || !icon_name || !size)
|
2007-02-03 05:05:30 -08:00
|
|
|
return NULL;
|
|
|
|
|
2008-08-14 12:47:48 -07:00
|
|
|
icon = efreet_icon_cache_check(theme, icon_name, size);
|
|
|
|
if (icon) return icon;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
/* search for allowed size == requested size */
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(theme->directories, l, dir)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2008-08-14 13:02:07 -07:00
|
|
|
if (!efreet_icon_directory_size_match(dir, size)) continue;
|
2007-03-26 15:28:28 -07:00
|
|
|
icon = efreet_icon_lookup_directory(theme, dir,
|
|
|
|
icon_name);
|
2008-08-14 12:47:48 -07:00
|
|
|
if (icon)
|
|
|
|
{
|
|
|
|
efreet_icon_cache_add(theme, icon_name, size, icon);
|
|
|
|
return icon;
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* search for any icon that matches */
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(theme->directories, l, dir)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2010-05-16 11:41:56 -07:00
|
|
|
double distance;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2008-08-14 13:02:07 -07:00
|
|
|
distance = efreet_icon_directory_size_distance(dir, size);
|
2010-05-16 11:42:43 -07:00
|
|
|
if (distance > minimal_distance) continue;
|
2010-05-16 11:42:33 -07:00
|
|
|
// prefer downsizing
|
2010-05-16 11:42:43 -07:00
|
|
|
if ((distance == minimal_distance) && (size < ret_size)) continue;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-07-26 04:30:10 -07:00
|
|
|
tmp = efreet_icon_lookup_directory(theme, dir,
|
2007-03-26 15:28:28 -07:00
|
|
|
icon_name);
|
2007-07-26 04:30:10 -07:00
|
|
|
if (tmp)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
icon = tmp;
|
2010-05-16 11:42:43 -07:00
|
|
|
minimal_distance = distance;
|
2010-05-16 11:42:33 -07:00
|
|
|
ret_size = size;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
}
|
2007-03-26 15:28:28 -07:00
|
|
|
|
2008-08-14 12:47:48 -07:00
|
|
|
efreet_icon_cache_add(theme, icon_name, size, icon);
|
2007-02-03 05:05:30 -08:00
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The theme to use
|
|
|
|
* @param dir: The theme directory to look in
|
|
|
|
* @param icon_name: The icon name to look for
|
|
|
|
* @return Returns the icon cloest matching the given information or NULL if
|
|
|
|
* none found
|
|
|
|
* @brief Tries to find the file closest matching the given icon
|
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_lookup_directory(Efreet_Icon_Theme *theme,
|
|
|
|
Efreet_Icon_Theme_Directory *dir,
|
2007-03-26 15:28:28 -07:00
|
|
|
const char *icon_name)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2009-03-22 21:58:31 -07:00
|
|
|
Eina_List *l;
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *icon = NULL;
|
2009-03-22 21:58:31 -07:00
|
|
|
const char *path;
|
2010-11-08 10:09:25 -08:00
|
|
|
const char *tmp;
|
|
|
|
|
|
|
|
tmp = eina_stringshare_add(icon_name);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2009-03-22 21:58:31 -07:00
|
|
|
EINA_LIST_FOREACH(theme->paths, l, path)
|
|
|
|
{
|
2010-11-08 10:09:25 -08:00
|
|
|
icon = efreet_icon_lookup_directory_helper(dir, path, tmp);
|
|
|
|
if (icon) break;
|
2009-03-22 21:58:31 -07:00
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-11-08 10:09:25 -08:00
|
|
|
eina_stringshare_del(tmp);
|
|
|
|
return icon;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param dir: The theme directory to work with
|
|
|
|
* @param size: The size to check
|
|
|
|
* @return Returns true if the size matches for the given directory, 0
|
|
|
|
* otherwise
|
|
|
|
* @brief Checks if the size matches for the given directory or not
|
|
|
|
*/
|
|
|
|
static int
|
2007-07-26 04:30:10 -07:00
|
|
|
efreet_icon_directory_size_match(Efreet_Icon_Theme_Directory *dir,
|
2007-02-03 05:05:30 -08:00
|
|
|
unsigned int size)
|
|
|
|
{
|
|
|
|
if (dir->type == EFREET_ICON_SIZE_TYPE_FIXED)
|
|
|
|
return (dir->size.normal == size);
|
|
|
|
|
2010-05-16 14:02:52 -07:00
|
|
|
if ((dir->type == EFREET_ICON_SIZE_TYPE_SCALABLE) ||
|
2010-05-17 12:45:20 -07:00
|
|
|
(dir->type == EFREET_ICON_SIZE_TYPE_THRESHOLD))
|
2007-02-03 05:05:30 -08:00
|
|
|
return ((dir->size.min < size) && (size < dir->size.max));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param dir: The directory to work with
|
|
|
|
* @param size: The size to check for
|
|
|
|
* @return Returns the distance this size is away from the desired size
|
|
|
|
* @brief Returns the distance the given size is away from the desired size
|
|
|
|
*/
|
2010-05-16 11:41:56 -07:00
|
|
|
static double
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_directory_size_distance(Efreet_Icon_Theme_Directory *dir,
|
|
|
|
unsigned int size)
|
|
|
|
{
|
|
|
|
if (dir->type == EFREET_ICON_SIZE_TYPE_FIXED)
|
|
|
|
return (abs(dir->size.normal - size));
|
|
|
|
|
2010-05-16 14:02:52 -07:00
|
|
|
if ((dir->type == EFREET_ICON_SIZE_TYPE_SCALABLE) ||
|
2010-05-17 12:45:20 -07:00
|
|
|
(dir->type == EFREET_ICON_SIZE_TYPE_THRESHOLD))
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2010-05-16 11:41:56 -07:00
|
|
|
#ifdef STRICT_SPEC
|
2010-05-17 12:45:20 -07:00
|
|
|
if (size < dir->size.min)
|
|
|
|
return (dir->size.min - size);
|
|
|
|
if (dir->size.max < size)
|
|
|
|
return (size - dir->size.max);
|
2010-05-16 11:41:56 -07:00
|
|
|
#else
|
2010-05-17 12:45:20 -07:00
|
|
|
if (size < dir->size.min)
|
|
|
|
return (dir->size.min / (double)size);
|
|
|
|
if (dir->size.max < size)
|
|
|
|
return (size / (double)dir->size.max);
|
2010-05-16 11:41:56 -07:00
|
|
|
#endif
|
2010-05-17 12:45:20 -07:00
|
|
|
return 0;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param icon_name: The icon name to look for
|
|
|
|
* @return Returns the Efreet_Icon for the given name or NULL if none found
|
|
|
|
* @brief Looks for the un-themed icon in the base directories
|
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_fallback_icon(const char *icon_name)
|
|
|
|
{
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *icon;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
if (!icon_name) return NULL;
|
2010-08-04 05:23:00 -07:00
|
|
|
icon = efreet_icon_cache_check(NULL, icon_name, 0);
|
2008-08-14 12:47:48 -07:00
|
|
|
if (icon) return icon;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-04-14 21:51:37 -07:00
|
|
|
icon = efreet_icon_fallback_dir_scan(efreet_icon_deprecated_user_dir_get(), icon_name);
|
|
|
|
if (!icon)
|
|
|
|
icon = efreet_icon_fallback_dir_scan(efreet_icon_user_dir_get(), icon_name);
|
2007-02-03 05:05:30 -08:00
|
|
|
if (!icon)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *xdg_dirs, *l;
|
2007-02-03 05:05:30 -08:00
|
|
|
const char *dir;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(efreet_extra_icon_dirs, l, dir)
|
2007-03-30 20:20:53 -07:00
|
|
|
{
|
|
|
|
icon = efreet_icon_fallback_dir_scan(dir, icon_name);
|
2008-08-14 12:47:48 -07:00
|
|
|
if (icon)
|
|
|
|
{
|
2010-08-04 05:23:00 -07:00
|
|
|
efreet_icon_cache_add(NULL, icon_name, 0, icon);
|
2008-08-14 12:47:48 -07:00
|
|
|
return icon;
|
|
|
|
}
|
2007-03-30 20:20:53 -07:00
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
xdg_dirs = efreet_data_dirs_get();
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(xdg_dirs, l, dir)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2009-12-23 12:55:23 -08:00
|
|
|
snprintf(path, sizeof(path), "%s/icons", dir);
|
2010-11-09 12:15:55 -08:00
|
|
|
efreet_icon_fallback_dir_scan(path, icon_name);
|
2008-08-14 12:47:48 -07:00
|
|
|
if (icon)
|
|
|
|
{
|
2010-08-04 05:23:00 -07:00
|
|
|
efreet_icon_cache_add(NULL, icon_name, 0, icon);
|
2008-08-14 12:47:48 -07:00
|
|
|
return icon;
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
2009-10-04 14:55:13 -07:00
|
|
|
EINA_LIST_FOREACH(xdg_dirs, l, dir)
|
|
|
|
{
|
2009-12-23 12:55:23 -08:00
|
|
|
snprintf(path, sizeof(path), "%s/pixmaps", dir);
|
2009-10-04 14:55:13 -07:00
|
|
|
icon = efreet_icon_fallback_dir_scan(path, icon_name);
|
|
|
|
if (icon)
|
|
|
|
{
|
2010-08-04 05:23:00 -07:00
|
|
|
efreet_icon_cache_add(NULL, icon_name, 0, icon);
|
2009-10-04 14:55:13 -07:00
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-14 20:01:55 -07:00
|
|
|
EINA_LIST_FOREACH(xdg_dirs, l, dir)
|
|
|
|
{
|
|
|
|
snprintf(path, PATH_MAX, "%s/pixmaps", dir);
|
|
|
|
icon = efreet_icon_fallback_dir_scan(path, icon_name);
|
|
|
|
if (icon)
|
|
|
|
{
|
2010-08-15 12:54:08 -07:00
|
|
|
efreet_icon_cache_add(NULL, icon_name, 0, icon);
|
2010-08-14 20:01:55 -07:00
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
icon = efreet_icon_fallback_dir_scan("/usr/share/pixmaps", icon_name);
|
|
|
|
}
|
|
|
|
|
2010-08-04 05:23:00 -07:00
|
|
|
efreet_icon_cache_add(NULL, icon_name, 0, icon);
|
2007-02-03 05:05:30 -08:00
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param dir: The directory to scan
|
|
|
|
* @param icon_name: The icon to look for
|
|
|
|
* @return Returns the icon for the given name or NULL on failure
|
|
|
|
* @brief Scans the given @a dir for the given @a icon_name returning the
|
|
|
|
* Efreet_icon if found, NULL otherwise.
|
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_fallback_dir_scan(const char *dir, const char *icon_name)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *icon = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
char path[PATH_MAX], *ext;
|
2008-07-29 11:52:27 -07:00
|
|
|
const char *icon_path[] = { dir, "/", icon_name, NULL };
|
|
|
|
size_t size;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
if (!dir || !icon_name) return NULL;
|
|
|
|
|
2008-07-29 11:52:27 -07:00
|
|
|
size = efreet_array_cat(path, sizeof(path), icon_path);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(efreet_icon_extensions, l, ext)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2010-01-30 14:13:16 -08:00
|
|
|
eina_strlcpy(path + size, ext, sizeof(path) - size);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
if (ecore_file_exists(path))
|
|
|
|
{
|
2010-11-09 12:15:55 -08:00
|
|
|
icon = eina_stringshare_add(path);
|
2007-02-03 05:05:30 -08:00
|
|
|
if (icon) break;
|
|
|
|
}
|
2008-07-29 11:52:27 -07:00
|
|
|
*(path + size) = '\0';
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
/* This is to catch non-conforming .desktop files */
|
2007-04-04 04:52:46 -07:00
|
|
|
#ifdef SLOPPY_SPEC
|
2007-02-03 05:05:30 -08:00
|
|
|
if (!icon)
|
|
|
|
{
|
2009-03-17 06:42:21 -07:00
|
|
|
if ((ecore_file_exists(path)) && (!ecore_file_is_dir(path)))
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2010-11-09 12:15:55 -08:00
|
|
|
icon = eina_stringshare_add(path);
|
2007-04-04 03:41:53 -07:00
|
|
|
#ifdef STRICT_SPEC
|
2007-02-03 05:05:30 -08:00
|
|
|
if (icon)
|
2009-09-21 09:36:29 -07:00
|
|
|
WRN("[Efreet]: Found an icon that already has an extension: %s", path);
|
2007-02-03 05:05:30 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2007-04-04 04:52:46 -07:00
|
|
|
#endif
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The theme to work with
|
|
|
|
* @param dir: The theme directory to work with
|
|
|
|
* @param path: The partial path to use
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Caches the icons in the given theme directory path at the given
|
|
|
|
* size
|
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *
|
2007-07-26 04:30:10 -07:00
|
|
|
efreet_icon_lookup_directory_helper(Efreet_Icon_Theme_Directory *dir,
|
|
|
|
const char *path, const char *icon_name)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *icon = NULL;
|
2007-07-26 04:30:10 -07:00
|
|
|
char file_path[PATH_MAX];
|
2010-11-08 10:09:25 -08:00
|
|
|
const char *ext;
|
2008-07-29 11:52:27 -07:00
|
|
|
size_t len;
|
|
|
|
|
2010-11-08 10:09:25 -08:00
|
|
|
/* build "$(path)/$(dir->name)/$(icon_name) */
|
|
|
|
len = eina_stringshare_strlen(path);
|
|
|
|
memcpy(file_path, path, len);
|
|
|
|
file_path[len++] = '/';
|
|
|
|
memcpy(file_path + len, dir->name, eina_stringshare_strlen(dir->name));
|
|
|
|
len += eina_stringshare_strlen(dir->name);
|
|
|
|
file_path[len++] = '/';
|
|
|
|
memcpy(file_path + len, icon_name, eina_stringshare_strlen(icon_name));
|
|
|
|
len += eina_stringshare_strlen(icon_name);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(efreet_icon_extensions, l, ext)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2010-11-08 10:09:25 -08:00
|
|
|
memcpy(file_path + len, ext, eina_stringshare_strlen(ext) + 1);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-07-26 04:30:10 -07:00
|
|
|
if (ecore_file_exists(file_path))
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
2010-11-09 12:15:55 -08:00
|
|
|
icon = eina_stringshare_add(file_path);
|
2007-07-26 04:30:10 -07:00
|
|
|
break;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @return Returns a new Efreet_Icon struct on success or NULL on failure
|
|
|
|
* @brief Creates a new Efreet_Icon struct
|
|
|
|
*/
|
|
|
|
static Efreet_Icon *
|
|
|
|
efreet_icon_new(const char *path)
|
|
|
|
{
|
|
|
|
Efreet_Icon *icon;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
icon = NEW(Efreet_Icon, 1);
|
2010-08-03 12:31:44 -07:00
|
|
|
if (!icon) return NULL;
|
2010-04-01 12:41:03 -07:00
|
|
|
icon->path = eina_stringshare_add(path);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
/* load the .icon file if it's available */
|
|
|
|
p = strrchr(icon->path, '.');
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
char ico_path[PATH_MAX];
|
|
|
|
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
snprintf(ico_path, sizeof(ico_path), "%s.icon", icon->path);
|
|
|
|
*p = '.';
|
|
|
|
|
|
|
|
if (ecore_file_exists(ico_path))
|
|
|
|
efreet_icon_populate(icon, ico_path);
|
|
|
|
}
|
|
|
|
|
2007-05-29 13:18:21 -07:00
|
|
|
if (!icon->name)
|
|
|
|
{
|
2007-06-06 18:22:48 -07:00
|
|
|
const char *file;
|
2007-05-29 13:18:21 -07:00
|
|
|
|
2007-07-25 10:01:04 -07:00
|
|
|
file = ecore_file_file_get(icon->path);
|
2007-05-29 13:18:21 -07:00
|
|
|
p = strrchr(icon->path, '.');
|
|
|
|
if (p) *p = '\0';
|
2010-04-01 12:41:03 -07:00
|
|
|
icon->name = eina_stringshare_add(file);
|
2007-05-29 13:18:21 -07:00
|
|
|
if (p) *p = '.';
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param icon: The Efreet_Icon to cleanup
|
|
|
|
* @return Returns no value.
|
|
|
|
* @brief Free's the given icon and all its internal data.
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI void
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_free(Efreet_Icon *icon)
|
|
|
|
{
|
2007-07-26 04:30:10 -07:00
|
|
|
if (!icon) return;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
icon->ref_count --;
|
|
|
|
if (icon->ref_count > 0) return;
|
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
IF_RELEASE(icon->path);
|
|
|
|
IF_RELEASE(icon->name);
|
2009-03-23 05:19:31 -07:00
|
|
|
IF_FREE_LIST(icon->attach_points, free);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
FREE(icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param icon: The icon to populate
|
|
|
|
* @param file: The file to populate from
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Tries to populate the icon information from the given file
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_icon_populate(Efreet_Icon *icon, const char *file)
|
|
|
|
{
|
|
|
|
Efreet_Ini *ini;
|
|
|
|
const char *tmp;
|
|
|
|
|
|
|
|
ini = efreet_ini_new(file);
|
2010-08-04 12:15:38 -07:00
|
|
|
if (!ini) return;
|
2007-02-03 05:05:30 -08:00
|
|
|
if (!ini->data)
|
|
|
|
{
|
|
|
|
efreet_ini_free(ini);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
efreet_ini_section_set(ini, "Icon Data");
|
|
|
|
tmp = efreet_ini_localestring_get(ini, "DisplayName");
|
2010-04-01 12:41:03 -07:00
|
|
|
if (tmp) icon->name = eina_stringshare_add(tmp);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
tmp = efreet_ini_string_get(ini, "EmbeddedTextRectangle");
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
int points[4];
|
|
|
|
char *t, *s, *p;
|
|
|
|
int i;
|
2010-04-01 12:41:03 -07:00
|
|
|
size_t len;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
len = strlen(tmp) + 1;
|
|
|
|
t = alloca(len);
|
|
|
|
memcpy(t, tmp, len);
|
2007-02-03 05:05:30 -08:00
|
|
|
s = t;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
2007-05-29 13:24:27 -07:00
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
p = strchr(s, ',');
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-05-29 13:24:27 -07:00
|
|
|
if (p) *p = '\0';
|
|
|
|
points[i] = atoi(s);
|
|
|
|
|
|
|
|
if (p) s = ++p;
|
|
|
|
else s = NULL;
|
|
|
|
}
|
|
|
|
else
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
points[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
icon->has_embedded_text_rectangle = 1;
|
|
|
|
icon->embedded_text_rectangle.x0 = points[0];
|
|
|
|
icon->embedded_text_rectangle.y0 = points[1];
|
|
|
|
icon->embedded_text_rectangle.x1 = points[2];
|
|
|
|
icon->embedded_text_rectangle.y1 = points[3];
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = efreet_ini_string_get(ini, "AttachPoints");
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
char *t, *s, *p;
|
2010-04-01 12:41:03 -07:00
|
|
|
size_t len;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
len = strlen(tmp) + 1;
|
|
|
|
t = alloca(len);
|
|
|
|
memcpy(t, tmp, len);
|
2007-02-03 05:05:30 -08:00
|
|
|
s = t;
|
2007-05-29 12:29:46 -07:00
|
|
|
while (s)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
Efreet_Icon_Point *point;
|
|
|
|
|
|
|
|
p = strchr(s, ',');
|
2007-05-29 12:29:46 -07:00
|
|
|
/* If this happens there is something wrong with the .icon file */
|
2007-02-03 05:05:30 -08:00
|
|
|
if (!p) break;
|
|
|
|
|
|
|
|
point = NEW(Efreet_Icon_Point, 1);
|
2010-08-03 12:31:44 -07:00
|
|
|
if (!point) goto error;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
*p = '\0';
|
|
|
|
point->x = atoi(s);
|
|
|
|
|
|
|
|
s = ++p;
|
|
|
|
p = strchr(s, '|');
|
2007-05-29 12:29:46 -07:00
|
|
|
if (p) *p = '\0';
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
point->y = atoi(s);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
|
|
|
icon->attach_points = eina_list_append(icon->attach_points, point);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-05-29 12:29:46 -07:00
|
|
|
if (p) s = ++p;
|
|
|
|
else s = NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-03 12:31:44 -07:00
|
|
|
error:
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_ini_free(ini);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @return Returns a new Efreet_Icon_Theme on success or NULL on failure
|
|
|
|
* @brief Creates a new Efreet_Icon_Theme structure
|
|
|
|
*/
|
|
|
|
static Efreet_Icon_Theme *
|
|
|
|
efreet_icon_theme_new(void)
|
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *theme;
|
|
|
|
|
|
|
|
theme = NEW(Efreet_Icon_Theme, 1);
|
2010-08-03 12:31:44 -07:00
|
|
|
if (!theme) return NULL;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
return theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The theme to free
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Frees up the @a theme structure.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_icon_theme_free(Efreet_Icon_Theme *theme)
|
|
|
|
{
|
2009-03-23 05:19:31 -07:00
|
|
|
if (!theme) return;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2009-03-23 05:19:31 -07:00
|
|
|
IF_RELEASE(theme->name.internal);
|
|
|
|
IF_RELEASE(theme->name.name);
|
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
IF_RELEASE(theme->comment);
|
|
|
|
IF_RELEASE(theme->example_icon);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
IF_FREE_LIST(theme->paths, eina_stringshare_del);
|
|
|
|
IF_FREE_LIST(theme->inherits, eina_stringshare_del);
|
2009-03-23 05:19:31 -07:00
|
|
|
IF_FREE_LIST(theme->directories, efreet_icon_theme_directory_free);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2009-03-23 05:19:31 -07:00
|
|
|
FREE(theme);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The theme to work with
|
|
|
|
* @param path: The path to add
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief This will correctly add the given path to the list of theme paths.
|
|
|
|
* @Note Assumes you've already verified that @a path is a valid directory.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_icon_theme_path_add(Efreet_Icon_Theme *theme, const char *path)
|
|
|
|
{
|
|
|
|
if (!theme || !path) return;
|
|
|
|
|
2010-02-04 12:02:56 -08:00
|
|
|
if (!eina_list_search_unsorted(theme->paths, EINA_COMPARE_CB(strcmp), path))
|
2010-04-01 12:41:03 -07:00
|
|
|
theme->paths = eina_list_append(theme->paths, eina_stringshare_add(path));
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief This validates that our cache is still valid.
|
|
|
|
*
|
|
|
|
* This is checked by the following algorithm:
|
|
|
|
* - if we've check less then 5 seconds ago we're good
|
|
|
|
* - if the mtime on the dir is less then our last check time we're good
|
|
|
|
* - otherwise, invalidate the caches
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_icon_theme_cache_check(Efreet_Icon_Theme *theme)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2007-02-03 05:05:30 -08:00
|
|
|
double new_check;
|
|
|
|
|
|
|
|
new_check = ecore_time_get();
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
/* we're within 5 seconds of the last time we checked the cache */
|
|
|
|
if ((new_check - 5) <= theme->last_cache_check) return;
|
|
|
|
|
|
|
|
if (theme->fake)
|
|
|
|
efreet_icon_theme_dir_scan_all(theme->name.internal);
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
else
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(theme->paths, l, path)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
if (!efreet_icon_theme_cache_check_dir(theme, path))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-08-14 12:47:48 -07:00
|
|
|
theme->last_cache_check = new_check;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The icon theme to check
|
|
|
|
* @param dir: The directory to check
|
|
|
|
* @return Returns 1 if the cache is still valid, 0 otherwise
|
|
|
|
* @brief This will check if the theme cache is still valid. If it isn't the
|
|
|
|
* cache will be invalided and 0 returned.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
efreet_icon_theme_cache_check_dir(Efreet_Icon_Theme *theme, const char *dir)
|
|
|
|
{
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
/* have we modified this directory since our last cache check? */
|
|
|
|
if (stat(dir, &buf) || (buf.st_mtime > theme->last_cache_check))
|
|
|
|
{
|
2010-08-04 14:01:09 -07:00
|
|
|
char key[4096];
|
|
|
|
char *elem;
|
|
|
|
Eina_Iterator *it;
|
|
|
|
Eina_List *keys = NULL;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
snprintf(key, sizeof(key), "%s::", theme->name.internal);
|
|
|
|
len = strlen(key);
|
|
|
|
|
|
|
|
it = eina_hash_iterator_key_new(efreet_icon_cache);
|
|
|
|
EINA_ITERATOR_FOREACH(it, elem)
|
|
|
|
if (!strncmp(elem, key, len))
|
|
|
|
keys = eina_list_append(keys, elem);
|
|
|
|
eina_iterator_free(it);
|
|
|
|
|
|
|
|
EINA_LIST_FREE(keys, elem)
|
|
|
|
eina_hash_del_by_key(efreet_icon_cache, elem);
|
2007-02-03 05:05:30 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme_name: The theme to scan for
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Scans the theme directories. If @a theme_name is NULL it will load
|
|
|
|
* up all theme data. If @a theme_name is not NULL it will look for that
|
|
|
|
* specific theme data
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_icon_theme_dir_scan_all(const char *theme_name)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *xdg_dirs, *l;
|
2007-02-03 05:05:30 -08:00
|
|
|
char path[PATH_MAX], *dir;
|
|
|
|
|
2007-04-14 21:51:37 -07:00
|
|
|
efreet_icon_theme_dir_scan(efreet_icon_deprecated_user_dir_get(), theme_name);
|
|
|
|
efreet_icon_theme_dir_scan(efreet_icon_user_dir_get(), theme_name);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
xdg_dirs = efreet_data_dirs_get();
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(xdg_dirs, l, dir)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
snprintf(path, sizeof(path), "%s/icons", dir);
|
|
|
|
efreet_icon_theme_dir_scan(path, theme_name);
|
|
|
|
}
|
|
|
|
|
2010-11-15 13:04:42 -08:00
|
|
|
#ifndef STRICT_SPEC
|
2009-10-04 14:55:13 -07:00
|
|
|
EINA_LIST_FOREACH(xdg_dirs, l, dir)
|
|
|
|
{
|
|
|
|
snprintf(path, sizeof(path), "%s/pixmaps", dir);
|
|
|
|
efreet_icon_theme_dir_scan(path, theme_name);
|
|
|
|
}
|
2010-11-15 13:04:42 -08:00
|
|
|
#endif
|
2010-08-14 20:01:55 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_icon_theme_dir_scan("/usr/share/pixmaps", theme_name);
|
2010-10-25 13:20:41 -07:00
|
|
|
|
|
|
|
/* if we were given a theme name we want to make sure that that given
|
|
|
|
* theme is valid before finishing, unless it's a fake theme */
|
|
|
|
if (theme_name)
|
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *theme;
|
|
|
|
|
|
|
|
theme = eina_hash_find(efreet_icon_themes, theme_name);
|
|
|
|
if (theme && !theme->valid && !theme->fake)
|
|
|
|
eina_hash_del(efreet_icon_themes, theme_name, theme);
|
|
|
|
}
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param search_dir: The directory to scan
|
|
|
|
* @param theme_name: Scan for this specific theme, set to NULL to find all
|
|
|
|
* themes.
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Scans the given directory and adds non-hidden icon themes to the
|
2010-09-08 04:27:59 -07:00
|
|
|
* given list. If the theme isn't' in our cache then load the index.theme and
|
2007-02-03 05:05:30 -08:00
|
|
|
* add to the cache.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_icon_theme_dir_scan(const char *search_dir, const char *theme_name)
|
|
|
|
{
|
|
|
|
DIR *dirs;
|
|
|
|
struct dirent *dir;
|
|
|
|
|
|
|
|
if (!search_dir) return;
|
|
|
|
|
|
|
|
dirs = opendir(search_dir);
|
|
|
|
if (!dirs) return;
|
|
|
|
|
|
|
|
while ((dir = readdir(dirs)))
|
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *theme;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
const char *key;
|
|
|
|
|
|
|
|
if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, "..")) continue;
|
|
|
|
|
|
|
|
/* only care if this is a directory or the theme name matches the
|
|
|
|
* given name */
|
|
|
|
snprintf(path, sizeof(path), "%s/%s", search_dir, dir->d_name);
|
2010-08-21 06:52:25 -07:00
|
|
|
if (((theme_name) && (strcmp(theme_name, dir->d_name)))
|
2007-07-26 04:30:10 -07:00
|
|
|
|| !ecore_file_is_dir(path))
|
2007-02-03 05:05:30 -08:00
|
|
|
continue;
|
|
|
|
|
2008-10-15 07:48:03 -07:00
|
|
|
key = eina_stringshare_add(dir->d_name);
|
2008-12-17 07:33:43 -08:00
|
|
|
theme = eina_hash_find(efreet_icon_themes, key);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
if (!theme)
|
|
|
|
{
|
|
|
|
theme = efreet_icon_theme_new();
|
2010-08-03 13:46:36 -07:00
|
|
|
if (!theme) goto error;
|
2007-02-03 05:05:30 -08:00
|
|
|
theme->name.internal = key;
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_add(efreet_icon_themes,
|
|
|
|
(void *)theme->name.internal, theme);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (theme->fake)
|
|
|
|
theme->fake = 0;
|
2008-10-15 07:48:03 -07:00
|
|
|
eina_stringshare_del(key);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
efreet_icon_theme_path_add(theme, path);
|
|
|
|
|
|
|
|
/* we're already valid so no reason to check for an index.theme file */
|
|
|
|
if (theme->valid) continue;
|
|
|
|
|
|
|
|
/* if the index.theme file exists we parse it into the theme */
|
|
|
|
strncat(path, "/index.theme", sizeof(path));
|
|
|
|
if (ecore_file_exists(path))
|
|
|
|
efreet_icon_theme_index_read(theme, path);
|
|
|
|
}
|
2010-08-03 13:46:36 -07:00
|
|
|
error:
|
2007-02-03 05:05:30 -08:00
|
|
|
closedir(dirs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param theme: The theme to set the values into
|
|
|
|
* @param path: The path to the index.theme file for this theme
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief This will load up the theme with the data in the index.theme file
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_icon_theme_index_read(Efreet_Icon_Theme *theme, const char *path)
|
|
|
|
{
|
2010-08-03 13:46:36 -07:00
|
|
|
/* TODO: return error value */
|
2007-02-03 05:05:30 -08:00
|
|
|
Efreet_Ini *ini;
|
2010-08-03 13:46:36 -07:00
|
|
|
Efreet_Icon_Theme_Directory *dir;
|
2007-02-03 05:05:30 -08:00
|
|
|
const char *tmp;
|
|
|
|
|
|
|
|
if (!theme || !path) return;
|
|
|
|
|
|
|
|
ini = efreet_ini_new(path);
|
2010-08-04 12:15:38 -07:00
|
|
|
if (!ini) return;
|
2007-02-03 05:05:30 -08:00
|
|
|
if (!ini->data)
|
|
|
|
{
|
|
|
|
efreet_ini_free(ini);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
efreet_ini_section_set(ini, "Icon Theme");
|
|
|
|
tmp = efreet_ini_localestring_get(ini, "Name");
|
2008-10-15 07:48:03 -07:00
|
|
|
if (tmp) theme->name.name = eina_stringshare_add(tmp);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
tmp = efreet_ini_localestring_get(ini, "Comment");
|
2010-04-01 12:41:03 -07:00
|
|
|
if (tmp) theme->comment = eina_stringshare_add(tmp);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2007-07-26 04:30:10 -07:00
|
|
|
tmp = efreet_ini_string_get(ini, "Example");
|
2010-04-01 12:41:03 -07:00
|
|
|
if (tmp) theme->example_icon = eina_stringshare_add(tmp);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
theme->hidden = efreet_ini_boolean_get(ini, "Hidden");
|
|
|
|
|
|
|
|
theme->valid = 1;
|
|
|
|
|
|
|
|
/* Check the inheritance. If there is none we inherit from the hicolor theme */
|
|
|
|
tmp = efreet_ini_string_get(ini, "Inherits");
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
char *t, *s, *p;
|
2010-04-01 12:41:03 -07:00
|
|
|
size_t len;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
len = strlen(tmp) + 1;
|
|
|
|
t = alloca(len);
|
|
|
|
memcpy(t, tmp, len);
|
2007-02-03 05:05:30 -08:00
|
|
|
s = t;
|
|
|
|
p = strchr(s, ',');
|
|
|
|
|
|
|
|
while (p)
|
|
|
|
{
|
|
|
|
*p = '\0';
|
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
theme->inherits = eina_list_append(theme->inherits, eina_stringshare_add(s));
|
2007-02-03 05:05:30 -08:00
|
|
|
s = ++p;
|
|
|
|
p = strchr(s, ',');
|
|
|
|
}
|
2010-04-01 12:41:03 -07:00
|
|
|
theme->inherits = eina_list_append(theme->inherits, eina_stringshare_add(s));
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure this one is done last as setting the directory will change
|
|
|
|
* the ini section ... */
|
|
|
|
tmp = efreet_ini_string_get(ini, "Directories");
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
char *t, *s, *p;
|
2010-04-01 12:41:03 -07:00
|
|
|
size_t len;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
len = strlen(tmp) + 1;
|
|
|
|
t = alloca(len);
|
|
|
|
memcpy(t, tmp, len);
|
2007-02-03 05:05:30 -08:00
|
|
|
s = t;
|
|
|
|
p = s;
|
|
|
|
|
2008-07-29 11:55:41 -07:00
|
|
|
while (p)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
p = strchr(s, ',');
|
|
|
|
|
2008-07-29 11:55:41 -07:00
|
|
|
if (p) *p = '\0';
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-08-03 13:46:36 -07:00
|
|
|
dir = efreet_icon_theme_directory_new(ini, s);
|
|
|
|
if (!dir) goto error;
|
|
|
|
theme->directories = eina_list_append(theme->directories, dir);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2008-07-29 11:55:41 -07:00
|
|
|
if (p) s = ++p;
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-03 13:46:36 -07:00
|
|
|
error:
|
2007-02-03 05:05:30 -08:00
|
|
|
efreet_ini_free(ini);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Because the theme icon directories can be spread over multiple
|
|
|
|
* base directories we may need to create the icon theme strucutre before
|
|
|
|
* finding the index.theme file. It may also be that we never find an
|
|
|
|
* index.theme file as this isn't a valid theme. This function makes sure
|
|
|
|
* that everything we've got in our hash has a valid key to it.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
efreet_icon_theme_dir_validity_check(void)
|
|
|
|
{
|
2009-02-25 08:46:51 -08:00
|
|
|
Eina_List *keys;
|
2007-02-03 05:05:30 -08:00
|
|
|
const char *name;
|
2008-12-17 07:33:43 -08:00
|
|
|
Eina_Iterator *it;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
keys = NULL;
|
2008-12-17 07:33:43 -08:00
|
|
|
it = eina_hash_iterator_key_new(efreet_icon_themes);
|
2010-08-11 07:32:30 -07:00
|
|
|
eina_iterator_foreach(it, EINA_EACH_CB(_hash_keys), &keys);
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_iterator_free(it);
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
2009-02-25 08:46:51 -08:00
|
|
|
EINA_LIST_FREE(keys, name)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *theme;
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
theme = eina_hash_find(efreet_icon_themes, name);
|
|
|
|
if (theme && !theme->valid && !theme->fake)
|
|
|
|
eina_hash_del(efreet_icon_themes, name, theme);
|
2007-02-03 05:05:30 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param ini: The ini file with information on this directory
|
|
|
|
* @param name: The name of the directory
|
|
|
|
* @return Returns a new Efreet_Icon_Theme_Directory based on the
|
|
|
|
* information in @a ini.
|
|
|
|
* @brief Creates and initialises an icon theme directory from the given ini
|
|
|
|
* information
|
|
|
|
*/
|
|
|
|
static Efreet_Icon_Theme_Directory *
|
|
|
|
efreet_icon_theme_directory_new(Efreet_Ini *ini, const char *name)
|
|
|
|
{
|
|
|
|
Efreet_Icon_Theme_Directory *dir;
|
|
|
|
int val;
|
|
|
|
const char *tmp;
|
|
|
|
|
|
|
|
if (!ini) return NULL;
|
|
|
|
|
|
|
|
dir = NEW(Efreet_Icon_Theme_Directory, 1);
|
2010-08-03 12:31:44 -07:00
|
|
|
if (!dir) return NULL;
|
2010-04-01 12:41:03 -07:00
|
|
|
dir->name = eina_stringshare_add(name);
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
efreet_ini_section_set(ini, name);
|
|
|
|
|
|
|
|
tmp = efreet_ini_string_get(ini, "Context");
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
if (!strcasecmp(tmp, "Actions"))
|
|
|
|
dir->context = EFREET_ICON_THEME_CONTEXT_ACTIONS;
|
|
|
|
|
|
|
|
else if (!strcasecmp(tmp, "Devices"))
|
|
|
|
dir->context = EFREET_ICON_THEME_CONTEXT_DEVICES;
|
|
|
|
|
|
|
|
else if (!strcasecmp(tmp, "FileSystems"))
|
|
|
|
dir->context = EFREET_ICON_THEME_CONTEXT_FILESYSTEMS;
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
else if (!strcasecmp(tmp, "MimeTypes"))
|
|
|
|
dir->context = EFREET_ICON_THEME_CONTEXT_MIMETYPES;
|
|
|
|
}
|
2007-07-26 04:30:10 -07:00
|
|
|
|
2010-05-16 14:02:52 -07:00
|
|
|
/* Threshold is fallback */
|
|
|
|
dir->type = EFREET_ICON_SIZE_TYPE_THRESHOLD;
|
2010-05-17 12:45:20 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
tmp = efreet_ini_string_get(ini, "Type");
|
|
|
|
if (tmp)
|
2010-05-17 12:45:20 -07:00
|
|
|
{
|
2007-02-03 05:05:30 -08:00
|
|
|
if (!strcasecmp(tmp, "Fixed"))
|
|
|
|
dir->type = EFREET_ICON_SIZE_TYPE_FIXED;
|
|
|
|
|
|
|
|
else if (!strcasecmp(tmp, "Scalable"))
|
|
|
|
dir->type = EFREET_ICON_SIZE_TYPE_SCALABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dir->size.normal = efreet_ini_int_get(ini, "Size");
|
|
|
|
|
2010-05-16 14:02:52 -07:00
|
|
|
if (dir->type == EFREET_ICON_SIZE_TYPE_THRESHOLD)
|
|
|
|
{
|
2010-05-17 12:45:20 -07:00
|
|
|
val = efreet_ini_int_get(ini, "Threshold");
|
|
|
|
if (val < 0) val = 2;
|
|
|
|
dir->size.max = dir->size.normal + val;
|
|
|
|
dir->size.min = dir->size.normal - val;
|
2010-05-16 14:02:52 -07:00
|
|
|
}
|
2010-05-16 14:11:21 -07:00
|
|
|
else if (dir->type == EFREET_ICON_SIZE_TYPE_SCALABLE)
|
2010-05-16 14:02:52 -07:00
|
|
|
{
|
2010-05-17 12:45:20 -07:00
|
|
|
val = efreet_ini_int_get(ini, "MinSize");
|
|
|
|
if (val < 0) dir->size.min = dir->size.normal;
|
|
|
|
else dir->size.min = val;
|
2007-02-03 05:05:30 -08:00
|
|
|
|
2010-05-17 12:45:20 -07:00
|
|
|
val = efreet_ini_int_get(ini, "MaxSize");
|
|
|
|
if (val < 0) dir->size.max = dir->size.normal;
|
|
|
|
else dir->size.max = val;
|
2010-05-16 14:02:52 -07:00
|
|
|
}
|
2010-05-17 12:45:20 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
2009-03-23 05:19:31 -07:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @param dir: The Efreet_Icon_Theme_Directory to free
|
|
|
|
* @return Returns no value
|
|
|
|
* @brief Frees the given directory @a dir
|
|
|
|
*/
|
2009-03-23 03:27:54 -07:00
|
|
|
static void
|
|
|
|
efreet_icon_theme_directory_free(Efreet_Icon_Theme_Directory *dir)
|
|
|
|
{
|
2009-03-23 05:19:31 -07:00
|
|
|
if (!dir) return;
|
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
IF_RELEASE(dir->name);
|
2009-03-23 05:19:31 -07:00
|
|
|
FREE(dir);
|
2009-03-23 03:27:54 -07:00
|
|
|
}
|
|
|
|
|
2007-08-14 22:33:04 -07:00
|
|
|
static void
|
|
|
|
efreet_icon_cache_free(Efreet_Icon_Cache *value)
|
|
|
|
{
|
|
|
|
if (!value) return;
|
|
|
|
|
2010-04-01 12:41:03 -07:00
|
|
|
IF_RELEASE(value->key);
|
|
|
|
IF_RELEASE(value->path);
|
2007-08-14 22:33:04 -07:00
|
|
|
free(value);
|
|
|
|
}
|
2008-08-14 12:47:48 -07:00
|
|
|
|
2010-11-09 12:15:55 -08:00
|
|
|
static const char *
|
2008-08-14 13:02:07 -07:00
|
|
|
efreet_icon_cache_check(Efreet_Icon_Theme *theme, const char *icon, unsigned int size)
|
2008-08-14 12:47:48 -07:00
|
|
|
{
|
|
|
|
Efreet_Icon_Cache *cache;
|
|
|
|
char key[4096];
|
|
|
|
struct stat st;
|
|
|
|
|
2010-08-04 05:23:00 -07:00
|
|
|
if (theme)
|
|
|
|
snprintf(key, sizeof(key), "%s::%s::%d", theme->name.internal, icon, size);
|
|
|
|
else
|
|
|
|
snprintf(key, sizeof(key), "(null)::%s::%d", icon, size);
|
2008-08-14 12:47:48 -07:00
|
|
|
|
2010-08-04 05:23:00 -07:00
|
|
|
cache = eina_hash_find(efreet_icon_cache, key);
|
2008-08-14 12:47:48 -07:00
|
|
|
if (cache)
|
|
|
|
{
|
|
|
|
if (!cache->path)
|
2008-08-18 23:32:40 -07:00
|
|
|
return NON_EXISTING;
|
2008-08-14 12:47:48 -07:00
|
|
|
else if (!stat(cache->path, &st) && st.st_mtime == cache->lasttime)
|
2010-11-09 12:15:55 -08:00
|
|
|
return cache->path;
|
2010-08-04 05:23:00 -07:00
|
|
|
eina_hash_del_by_key(efreet_icon_cache, key);
|
2008-08-14 12:47:48 -07:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-08-14 13:02:07 -07:00
|
|
|
efreet_icon_cache_add(Efreet_Icon_Theme *theme, const char *icon, unsigned int size, const char *value)
|
2008-08-14 12:47:48 -07:00
|
|
|
{
|
|
|
|
Efreet_Icon_Cache *cache;
|
|
|
|
char key[4096];
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
cache = NEW(Efreet_Icon_Cache, 1);
|
2010-08-03 12:31:44 -07:00
|
|
|
if (!cache) return;
|
2010-08-04 05:23:00 -07:00
|
|
|
if (theme)
|
|
|
|
snprintf(key, sizeof(key), "%s::%s::%d", theme->name.internal, icon, size);
|
|
|
|
else
|
|
|
|
snprintf(key, sizeof(key), "(null)::%s::%d", icon, size);
|
|
|
|
|
2008-08-14 12:47:48 -07:00
|
|
|
if ((value) && !stat(value, &st))
|
|
|
|
{
|
2010-11-09 12:15:55 -08:00
|
|
|
cache->path = value;
|
2008-08-14 12:47:48 -07:00
|
|
|
cache->lasttime = st.st_mtime;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cache->lasttime = ecore_time_get();
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
2010-08-04 05:23:00 -07:00
|
|
|
eina_hash_set(efreet_icon_cache, key, cache);
|
2008-08-14 12:47:48 -07:00
|
|
|
}
|