forked from enlightenment/efl
parent
116abd7310
commit
d408b3f055
|
@ -83,6 +83,7 @@ struct _Ecore_Desktop_Icon_Theme
|
||||||
char *inherits;
|
char *inherits;
|
||||||
char *directories;
|
char *directories;
|
||||||
int hidden;
|
int hidden;
|
||||||
|
unsigned char hicolor:1;
|
||||||
/* Actually calling this st_mtime causes compile issues, must be some strange macros at work. */
|
/* Actually calling this st_mtime causes compile issues, must be some strange macros at work. */
|
||||||
time_t mtime; /* For checking if the cache is valid. */
|
time_t mtime; /* For checking if the cache is valid. */
|
||||||
};
|
};
|
||||||
|
|
|
@ -164,6 +164,8 @@ _ecore_desktop_icon_find0(const char *icon, const char *icon_size,
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
int wanted_size;
|
int wanted_size;
|
||||||
int minimal_size = INT_MAX;
|
int minimal_size = INT_MAX;
|
||||||
|
int has_ext = 0;
|
||||||
|
int has_icon_ext = 0;
|
||||||
int i;
|
int i;
|
||||||
char *closest = NULL;
|
char *closest = NULL;
|
||||||
Ecore_Desktop_Icon_Theme_Directory *directory;
|
Ecore_Desktop_Icon_Theme_Directory *directory;
|
||||||
|
@ -171,6 +173,22 @@ _ecore_desktop_icon_find0(const char *icon, const char *icon_size,
|
||||||
if ((icon == NULL) || (icon[0] == '\0'))
|
if ((icon == NULL) || (icon[0] == '\0'))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Check the file extension, if any. */
|
||||||
|
found = strrchr(icon, '.');
|
||||||
|
if (found != NULL)
|
||||||
|
{
|
||||||
|
has_ext = 1;
|
||||||
|
for (i = 0; ext[i] != NULL; i++)
|
||||||
|
{
|
||||||
|
if (strcmp(found, ext[i]) == 0)
|
||||||
|
{
|
||||||
|
has_icon_ext = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
found = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "\tTrying To Find Icon %s (%s) in theme %s\n", icon,
|
fprintf(stderr, "\tTrying To Find Icon %s (%s) in theme %s\n", icon,
|
||||||
icon_size, icon_theme);
|
icon_size, icon_theme);
|
||||||
|
@ -186,8 +204,8 @@ _ecore_desktop_icon_find0(const char *icon, const char *icon_size,
|
||||||
if (!theme->Directories) goto done;
|
if (!theme->Directories) goto done;
|
||||||
|
|
||||||
wanted_size = atoi(icon_size);
|
wanted_size = atoi(icon_size);
|
||||||
/* Loop through the themes directories. */
|
|
||||||
|
|
||||||
|
/* Loop through the themes directories. */
|
||||||
ecore_list_goto_first(theme->Directories);
|
ecore_list_goto_first(theme->Directories);
|
||||||
while ((directory = ecore_list_next(theme->Directories)) != NULL)
|
while ((directory = ecore_list_next(theme->Directories)) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -221,44 +239,48 @@ _ecore_desktop_icon_find0(const char *icon, const char *icon_size,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look for icon with all extensions. */
|
/* Do we need to check this directory? */
|
||||||
for (i = 0; ext[i] != NULL; i++)
|
if ((match) || (result_size < minimal_size))
|
||||||
{
|
{
|
||||||
/* Check if there will be an extension. */
|
/* Look for icon with all extensions. */
|
||||||
if ((ext[i][0] == '\0') && (strrchr(icon, '.') == NULL))
|
for (i = 0; ext[i] != NULL; i++)
|
||||||
continue;
|
{
|
||||||
snprintf(path, PATH_MAX, "%s/%s/%s%s",
|
/* Check if there will be an extension to check. */
|
||||||
icon_theme, directory->path, icon, ext[i]);
|
if ((ext[i][0] == '\0') && (!has_ext))
|
||||||
|
continue;
|
||||||
|
if ((ext[i][0] != '\0') && (has_icon_ext))
|
||||||
|
continue;
|
||||||
|
snprintf(path, PATH_MAX, "%s/%s/%s%s", icon_theme, directory->path, icon, ext[i]);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("FDO icon = %s\n", path);
|
printf("FDO icon = %s\n", path);
|
||||||
#endif
|
#endif
|
||||||
found = ecore_desktop_paths_file_find(ecore_desktop_paths_icons, path,
|
found = ecore_desktop_paths_file_find(ecore_desktop_paths_icons, path, 0, NULL, NULL);
|
||||||
0, NULL, NULL);
|
if (found)
|
||||||
if (found)
|
{
|
||||||
{
|
if (ecore_file_is_dir(found))
|
||||||
if (ecore_file_is_dir(found))
|
{
|
||||||
{
|
free(found);
|
||||||
free(found);
|
found = NULL;
|
||||||
found = NULL;
|
}
|
||||||
}
|
else if (match) /* If there is a match in sizes, return the icon. */
|
||||||
else if (match) /* If there is a match in sizes, return the icon. */
|
goto done;
|
||||||
goto done;
|
else if (result_size < minimal_size) /* While we are here, figure out our next fallback strategy. */
|
||||||
else if (result_size < minimal_size) /* While we are here, figure out our next fallback strategy. */
|
{
|
||||||
{
|
minimal_size = result_size;
|
||||||
minimal_size = result_size;
|
if (closest) free(closest);
|
||||||
if (closest) free(closest);
|
closest = found;
|
||||||
closest = found;
|
found = NULL;
|
||||||
found = NULL;
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
free(found);
|
||||||
free(found);
|
found = NULL;
|
||||||
found = NULL;
|
}
|
||||||
}
|
}
|
||||||
}
|
} /* for (i = 0; ext[i] != NULL; i++) */
|
||||||
}
|
} /* if ((match) || (result_size < minimal_size)) */
|
||||||
}
|
} /* if (directory->size) */
|
||||||
} /* while ((directory = ecore_list_next(directory_paths)) != NULL) */
|
} /* while ((directory = ecore_list_next(directory_paths)) != NULL) */
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
|
@ -271,37 +293,39 @@ _ecore_desktop_icon_find0(const char *icon, const char *icon_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fall back strategy #2, Try again with the parent themes. */
|
/* Fall back strategy #2, Try again with the parent themes. */
|
||||||
if ((theme->Inherits) && (strcmp(icon_theme, "hicolor") != 0))
|
if (!theme->hicolor)
|
||||||
{
|
{
|
||||||
char *inherits;
|
if (theme->Inherits)
|
||||||
|
|
||||||
ecore_list_goto_first(theme->Inherits);
|
|
||||||
while ((inherits = ecore_list_next(theme->Inherits)) != NULL)
|
|
||||||
{
|
{
|
||||||
found = _ecore_desktop_icon_find0(icon, icon_size, inherits);
|
char *inherits;
|
||||||
if (found) goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fall back strategy #3, Try the default hicolor theme. */
|
ecore_list_goto_first(theme->Inherits);
|
||||||
if ((!(theme->Inherits)) && (strcmp(icon_theme, "hicolor") != 0))
|
while ((inherits = ecore_list_next(theme->Inherits)) != NULL)
|
||||||
{
|
{
|
||||||
found = _ecore_desktop_icon_find0(icon, icon_size, "hicolor");
|
found = _ecore_desktop_icon_find0(icon, icon_size, inherits);
|
||||||
if (found) goto done;
|
if (found) goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else /* Fall back strategy #3, Try the default hicolor theme. */
|
||||||
|
{
|
||||||
|
found = _ecore_desktop_icon_find0(icon, icon_size, "hicolor");
|
||||||
|
if (found) goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fall back strategy #4, Just search in the base of the icon directories. */
|
/* Fall back strategy #4, Just search in the base of the icon directories. */
|
||||||
for (i = 0; ext[i] != NULL; i++)
|
for (i = 0; ext[i] != NULL; i++)
|
||||||
{
|
{
|
||||||
/* Check if there will be an extension. */
|
/* Check if there will be an extension to check. */
|
||||||
if ((ext[i][0] == '\0') && (strrchr(icon, '.') == NULL))
|
if ((ext[i][0] == '\0') && (!has_ext))
|
||||||
continue;
|
continue;
|
||||||
|
if ((ext[i][0] != '\0') && (has_icon_ext))
|
||||||
|
continue;
|
||||||
snprintf(path, PATH_MAX, "%s%s", icon, ext[i]);
|
snprintf(path, PATH_MAX, "%s%s", icon, ext[i]);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("FDO icon = %s\n", path);
|
printf("FDO icon = %s\n", path);
|
||||||
#endif
|
#endif
|
||||||
found = ecore_desktop_paths_file_find(ecore_desktop_paths_icons,
|
found = ecore_desktop_paths_file_find(ecore_desktop_paths_icons, path, 0, NULL, NULL);
|
||||||
path, 0, NULL, NULL);
|
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
if (ecore_file_is_dir(found))
|
if (ecore_file_is_dir(found))
|
||||||
|
@ -456,6 +480,9 @@ ecore_desktop_icon_theme_get(const char *icon_theme, const char *lang)
|
||||||
result->group = ecore_hash_get(result->data, "Icon Theme");
|
result->group = ecore_hash_get(result->data, "Icon Theme");
|
||||||
if (!result->group) goto error;
|
if (!result->group) goto error;
|
||||||
|
|
||||||
|
if ((strcmp(icon_theme, "hicolor") == 0))
|
||||||
|
result->hicolor = 1;
|
||||||
|
|
||||||
/* According to the spec, name and comment are required, but we can fake those easily enough. */
|
/* According to the spec, name and comment are required, but we can fake those easily enough. */
|
||||||
value = ecore_hash_get(result->group, "Name");
|
value = ecore_hash_get(result->group, "Name");
|
||||||
if (!value) value = (char *) icon_theme;
|
if (!value) value = (char *) icon_theme;
|
||||||
|
|
Loading…
Reference in New Issue