Index: xfce-icontheme.c =================================================================== RCS file: /var/cvs/xfce/xfce4/libxfcegui4/libxfcegui4/xfce-icontheme.c,v retrieving revision 1.30.2.1 diff -u -r1.30.2.1 xfce-icontheme.c --- xfce-icontheme.c 9 Jan 2005 18:52:50 -0000 1.30.2.1 +++ xfce-icontheme.c 18 Jan 2005 01:45:31 -0000 @@ -171,6 +171,66 @@ icon_list_free((GList *)value); } +static gchar * +theme_index_extract_name(const gchar *index_file) +{ + FILE *fp; + gchar buf[4096]; + + fp = fopen(index_file, "r"); + if(!fp) + return NULL; + + while(fgets(buf, 4096, fp)) { + if(strncmp(buf, "Name=", 5)) + continue; + + if(buf[strlen(buf)-1] == '\n') + buf[strlen(buf)-1] = 0; + if(buf[strlen(buf)-1] == '\r') + buf[strlen(buf)-1] = 0; + + fclose(fp); + return g_strdup(buf+5); + } + + fclose(fp); + + return NULL; +} + +static gchar * +theme_name_to_dir(const gchar *base_path, const gchar *theme_name) +{ + GDir *dir; + gchar fullpath[PATH_MAX], *idx_theme_name; + XfceRc *rcfile; + const gchar *file; + + dir = g_dir_open(base_path, 0, NULL); + if(dir) { + const gchar *file; + while((file = g_dir_read_name(dir))) { + g_snprintf(fullpath, PATH_MAX, "%s/%s/", base_path, file); + if(!g_file_test(fullpath, G_FILE_TEST_IS_DIR)) + continue; + + g_strlcat(fullpath, "index.theme", PATH_MAX); + idx_theme_name = theme_index_extract_name(fullpath); + if(!idx_theme_name) + continue; + + if(!strcmp(theme_name, idx_theme_name)) { + g_free(idx_theme_name); + return g_strdup(file); + } else + g_free(idx_theme_name); + } + } + + return NULL; +} + static void theme_add_all(XfceIconThemeSingleton *singleton, const gchar *base_path, const gchar *theme_name, gboolean is_in_theme) @@ -211,8 +271,13 @@ inherits = xfce_rc_read_list_entry(themerc, "Inherits", ","); if(inherits) { - for(j = 0; inherits[j]; j++) - theme_add_all(singleton, base_path, inherits[j], FALSE); + gchar *inherit_themedir; + for(j = 0; inherits[j]; j++) { + if((inherit_themedir = theme_name_to_dir(base_path, inherits[j]))) { + theme_add_all(singleton, base_path, inherit_themedir, FALSE); + g_free(inherit_themedir); + } + } g_strfreev(inherits); }