forked from enlightenment/efl
*Back to the icon review.
*Rearrange and shuffle the code a bit to get the icon stuff all together. *Make sure that all paths through the icon finding code get counted and timed properly, because speeding things up is next after the icon review. SVN revision: 26139
This commit is contained in:
parent
9865a4fadb
commit
208068dfbf
|
@ -217,9 +217,6 @@ _ecore_desktop_get(const char *file, const char *lang)
|
||||||
result->group = ecore_hash_get(result->data, "KDE Desktop Entry");
|
result->group = ecore_hash_get(result->data, "KDE Desktop Entry");
|
||||||
if (result->group)
|
if (result->group)
|
||||||
{
|
{
|
||||||
char *eap_name = NULL;
|
|
||||||
char *exe = NULL;
|
|
||||||
char *categories = NULL;
|
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
value = (char *) ecore_file_get_file(result->original_path);
|
value = (char *) ecore_file_get_file(result->original_path);
|
||||||
|
@ -235,7 +232,6 @@ _ecore_desktop_get(const char *file, const char *lang)
|
||||||
sprintf(result->eap_name, "%s.edj", value);
|
sprintf(result->eap_name, "%s.edj", value);
|
||||||
if (temp) *temp = '.';
|
if (temp) *temp = '.';
|
||||||
}
|
}
|
||||||
eap_name = result->eap_name;
|
|
||||||
|
|
||||||
IFGETDUP(value, "Name", result->name);
|
IFGETDUP(value, "Name", result->name);
|
||||||
IFGETDUP(value, "GenericName", result->generic);
|
IFGETDUP(value, "GenericName", result->generic);
|
||||||
|
@ -249,6 +245,8 @@ _ecore_desktop_get(const char *file, const char *lang)
|
||||||
IFGETDUP(value, "Exec", result->exec);
|
IFGETDUP(value, "Exec", result->exec);
|
||||||
if (result->exec)
|
if (result->exec)
|
||||||
{
|
{
|
||||||
|
char *exe = NULL;
|
||||||
|
|
||||||
exe = strchr(result->exec, ' ');
|
exe = strchr(result->exec, ' ');
|
||||||
if (exe)
|
if (exe)
|
||||||
{
|
{
|
||||||
|
@ -256,7 +254,6 @@ _ecore_desktop_get(const char *file, const char *lang)
|
||||||
exe++;
|
exe++;
|
||||||
result->exec_params = strdup(exe);
|
result->exec_params = strdup(exe);
|
||||||
}
|
}
|
||||||
exe = result->exec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IFGETDUP(value, "StartupWMClass", result->window_class);
|
IFGETDUP(value, "StartupWMClass", result->window_class);
|
||||||
|
@ -287,6 +284,10 @@ _ecore_desktop_get(const char *file, const char *lang)
|
||||||
IFGETDUP(value, "X-Enlightenment-WindowTitle", result->window_title);
|
IFGETDUP(value, "X-Enlightenment-WindowTitle", result->window_title);
|
||||||
IFGETDUP(value, "X-Enlightenment-WindowRole", result->window_role);
|
IFGETDUP(value, "X-Enlightenment-WindowRole", result->window_role);
|
||||||
|
|
||||||
|
IFGETDUP(value, "Categories", result->categories);
|
||||||
|
if (result->categories)
|
||||||
|
result->Categories =
|
||||||
|
ecore_desktop_paths_to_hash(result->categories);
|
||||||
IFGETDUP(value, "Icon", result->icon);
|
IFGETDUP(value, "Icon", result->icon);
|
||||||
IFGETDUP(value, "X-Enlightenment-IconTheme", result->icon_theme);
|
IFGETDUP(value, "X-Enlightenment-IconTheme", result->icon_theme);
|
||||||
IFGETDUP(value, "X-Enlightenment-IconClass", result->icon_class);
|
IFGETDUP(value, "X-Enlightenment-IconClass", result->icon_class);
|
||||||
|
@ -325,11 +326,91 @@ _ecore_desktop_get(const char *file, const char *lang)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IFGETDUP(value, "Categories", result->categories);
|
/* icon/class is a list of standard icons from the theme that can override the icon created above.
|
||||||
if (result->categories)
|
* Use (from .desktop) name,exe name,categories. It's case sensitive, the reccomendation is to lowercase it.
|
||||||
result->Categories =
|
* It should be most specific to most generic. firefox,browser,internet for instance
|
||||||
ecore_desktop_paths_to_hash(result->categories);
|
*/
|
||||||
categories = result->categories;
|
|
||||||
|
/* If the icon in the file is not a full path, just put it first in the class, greatly simplifies things.
|
||||||
|
* Otherwise, put that full path into the icon_path member.
|
||||||
|
*/
|
||||||
|
if (!result->icon_class)
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
if ((result->icon) && (strchr(result->icon, '/') == NULL))
|
||||||
|
size += strlen(result->icon) + 1;
|
||||||
|
if (result->eap_name)
|
||||||
|
size += strlen(result->eap_name) + 1;
|
||||||
|
if (result->exec)
|
||||||
|
size += strlen(result->exec) + 1;
|
||||||
|
if (result->categories)
|
||||||
|
size += strlen(result->categories) + 1;
|
||||||
|
result->icon_class = malloc(size + 1);
|
||||||
|
if (result->icon_class)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
int done = 0;
|
||||||
|
|
||||||
|
result->icon_class[0] = '\0';
|
||||||
|
if ((result->icon) && (strchr(result->icon, '/') == NULL) &&
|
||||||
|
(result->icon[0] != '\0'))
|
||||||
|
{
|
||||||
|
strcat(result->icon_class, result->icon);
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
/* We do this here coz we don't want to lower case the result->icon part later. */
|
||||||
|
p = result->icon_class;
|
||||||
|
p += strlen(result->icon_class);
|
||||||
|
if ((result->eap_name) && (result->eap_name[0] != '\0'))
|
||||||
|
{
|
||||||
|
if (done)
|
||||||
|
strcat(result->icon_class, ",");
|
||||||
|
strcat(result->icon_class, result->eap_name);
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
if ((result->exec) && (result->exec[0] != '\0'))
|
||||||
|
{
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
tmp = strdup(ecore_file_get_file(result->exec));
|
||||||
|
if (tmp)
|
||||||
|
{
|
||||||
|
char *p2;
|
||||||
|
|
||||||
|
p2 = tmp;
|
||||||
|
while (*p2 != '\0')
|
||||||
|
{
|
||||||
|
if (*p2 == ' ')
|
||||||
|
{
|
||||||
|
*p2 = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p2++;
|
||||||
|
}
|
||||||
|
if (done)
|
||||||
|
strcat(result->icon_class, ",");
|
||||||
|
strcat(result->icon_class, tmp);
|
||||||
|
done = 1;
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((result->categories) && (result->categories[0] != '\0'))
|
||||||
|
{
|
||||||
|
if (done)
|
||||||
|
strcat(result->icon_class, ",");
|
||||||
|
strcat(result->icon_class, result->categories);
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
while (*p != '\0')
|
||||||
|
{
|
||||||
|
if (*p == ';')
|
||||||
|
*p = ',';
|
||||||
|
else
|
||||||
|
*p = tolower(*p);
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
value = ecore_hash_get(result->group, "OnlyShowIn");
|
value = ecore_hash_get(result->group, "OnlyShowIn");
|
||||||
if (value)
|
if (value)
|
||||||
|
@ -355,92 +436,6 @@ _ecore_desktop_get(const char *file, const char *lang)
|
||||||
if (value)
|
if (value)
|
||||||
result->hidden = (strcmp(value, "true") == 0);
|
result->hidden = (strcmp(value, "true") == 0);
|
||||||
|
|
||||||
/*
|
|
||||||
* icon/class is a list of standard icons from the theme that can override the icon created above.
|
|
||||||
* Use (from .desktop) eap name,exe name,categories. It's case sensitive, the reccomendation is to lowercase it.
|
|
||||||
* It should be most specific to most generic. firefox,browser,internet for instance
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* If the icon in the file is not a full path, just put it first in the class, greatly simplifies things.
|
|
||||||
* Otherwise, put that full path into the icon_path member.
|
|
||||||
*/
|
|
||||||
if (!result->icon_class)
|
|
||||||
{
|
|
||||||
size = 0;
|
|
||||||
if ((result->icon) && (strchr(result->icon, '/') == NULL))
|
|
||||||
size += strlen(result->icon) + 1;
|
|
||||||
if (eap_name)
|
|
||||||
size += strlen(eap_name) + 1;
|
|
||||||
if (exe)
|
|
||||||
size += strlen(exe) + 1;
|
|
||||||
if (categories)
|
|
||||||
size += strlen(categories) + 1;
|
|
||||||
result->icon_class = malloc(size + 1);
|
|
||||||
if (result->icon_class)
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
int done = 0;
|
|
||||||
|
|
||||||
result->icon_class[0] = '\0';
|
|
||||||
if ((result->icon) && (strchr(result->icon, '/') == NULL) &&
|
|
||||||
(result->icon[0] != '\0'))
|
|
||||||
{
|
|
||||||
strcat(result->icon_class, result->icon);
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
/* We do this here coz we don't want to lower case the result->icon part later. */
|
|
||||||
p = result->icon_class;
|
|
||||||
p += strlen(result->icon_class);
|
|
||||||
if ((eap_name) && (eap_name[0] != '\0'))
|
|
||||||
{
|
|
||||||
if (done)
|
|
||||||
strcat(result->icon_class, ",");
|
|
||||||
strcat(result->icon_class, eap_name);
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
if ((exe) && (exe[0] != '\0'))
|
|
||||||
{
|
|
||||||
char *tmp;
|
|
||||||
|
|
||||||
tmp = strdup(ecore_file_get_file(exe));
|
|
||||||
if (tmp)
|
|
||||||
{
|
|
||||||
char *p2;
|
|
||||||
|
|
||||||
p2 = tmp;
|
|
||||||
while (*p2 != '\0')
|
|
||||||
{
|
|
||||||
if (*p2 == ' ')
|
|
||||||
{
|
|
||||||
*p2 = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
p2++;
|
|
||||||
}
|
|
||||||
if (done)
|
|
||||||
strcat(result->icon_class, ",");
|
|
||||||
strcat(result->icon_class, tmp);
|
|
||||||
done = 1;
|
|
||||||
free(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((categories) && (categories[0] != '\0'))
|
|
||||||
{
|
|
||||||
if (done)
|
|
||||||
strcat(result->icon_class, ",");
|
|
||||||
strcat(result->icon_class, categories);
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
while (*p != '\0')
|
|
||||||
{
|
|
||||||
if (*p == ';')
|
|
||||||
*p = ',';
|
|
||||||
else
|
|
||||||
*p = tolower(*p);
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,45 +53,50 @@ EAPI char *
|
||||||
ecore_desktop_icon_find(const char *icon, const char *icon_size,
|
ecore_desktop_icon_find(const char *icon, const char *icon_size,
|
||||||
const char *icon_theme)
|
const char *icon_theme)
|
||||||
{
|
{
|
||||||
char *dir = NULL, *icn;
|
char *result = NULL, *icn;
|
||||||
Ecore_List *icons;
|
Ecore_List *icons;
|
||||||
int in_cache = 0;
|
int in_cache = 0;
|
||||||
double begin;
|
double begin;
|
||||||
|
|
||||||
begin = ecore_time_get();
|
begin = ecore_time_get();
|
||||||
if (icon == NULL)
|
if (icon)
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Easy check first, was a full path supplied? */
|
|
||||||
if ((icon[0] == '/') && (ecore_file_exists(icon)))
|
|
||||||
return strdup(icon);
|
|
||||||
|
|
||||||
if (icon_size == NULL)
|
|
||||||
icon_size = "48x48";
|
|
||||||
if (icon_theme == NULL)
|
|
||||||
icon_theme = "hicolor";
|
|
||||||
|
|
||||||
icons = ecore_desktop_paths_to_list(icon);
|
|
||||||
if (!icons)
|
|
||||||
return NULL;
|
|
||||||
ecore_list_goto_first(icons);
|
|
||||||
while ((icn = ecore_list_next(icons)))
|
|
||||||
{
|
{
|
||||||
char *ext;
|
/* Easy check first, was a full path supplied? */
|
||||||
|
if ((icon[0] == '/') && (ecore_file_exists(icon)))
|
||||||
|
result = strdup(icon);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
icons = ecore_desktop_paths_to_list(icon);
|
||||||
|
if (icons)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (icon_size == NULL)
|
||||||
|
icon_size = "48x48";
|
||||||
|
if (icon_theme == NULL)
|
||||||
|
icon_theme = "hicolor";
|
||||||
|
ecore_list_goto_first(icons);
|
||||||
|
while ((icn = ecore_list_next(icons)))
|
||||||
|
{
|
||||||
|
char *ext;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "\tTrying To Find Icon %s\n", icn);
|
fprintf(stderr, "\tTrying To Find Icon %s\n", icn);
|
||||||
#endif
|
#endif
|
||||||
ext = strrchr(icn, '.');
|
ext = strrchr(icn, '.');
|
||||||
/* Check for unsupported extension */
|
/* Check for unsupported extension */
|
||||||
if ((ext) && (!strcmp(ext, ".ico"))) continue;
|
if ((ext) && (!strcmp(ext, ".ico")))
|
||||||
|
continue;
|
||||||
|
|
||||||
dir = _ecore_desktop_icon_find0(icn, icon_size, icon_theme);
|
result = _ecore_desktop_icon_find0(icn, icon_size, icon_theme);
|
||||||
if (dir)
|
if (result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ecore_list_destroy(icons);
|
ecore_list_destroy(icons);
|
||||||
|
|
||||||
if (dir)
|
} /* if (icons) */
|
||||||
|
} /* if ((icon[0] == '/') && (ecore_file_exists(icon))) ; else */
|
||||||
|
} /* if (icon) */
|
||||||
|
|
||||||
|
if (result)
|
||||||
{
|
{
|
||||||
if (in_cache)
|
if (in_cache)
|
||||||
{
|
{
|
||||||
|
@ -109,7 +114,8 @@ ecore_desktop_icon_find(const char *icon, const char *icon_size,
|
||||||
instrumentation.icons_not_found_time += ecore_time_get() - begin;
|
instrumentation.icons_not_found_time += ecore_time_get() - begin;
|
||||||
instrumentation.icons_not_found++;
|
instrumentation.icons_not_found++;
|
||||||
}
|
}
|
||||||
return dir;
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Search for an icon the fdo way.
|
/** Search for an icon the fdo way.
|
||||||
|
|
Loading…
Reference in New Issue