Enlightenment CVS committal Author : onefang Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_desktop Modified Files: ecore_desktop.c ecore_desktop_icon.c Log Message: *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. =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop.c,v retrieving revision 1.49 retrieving revision 1.50 diff -u -3 -r1.49 -r1.50 --- ecore_desktop.c 24 Sep 2006 20:03:31 -0000 1.49 +++ ecore_desktop.c 25 Sep 2006 12:50:23 -0000 1.50 @@ -217,9 +217,6 @@ result->group = ecore_hash_get(result->data, "KDE Desktop Entry"); if (result->group) { - char *eap_name = NULL; - char *exe = NULL; - char *categories = NULL; int size = 0; value = (char *) ecore_file_get_file(result->original_path); @@ -235,7 +232,6 @@ sprintf(result->eap_name, "%s.edj", value); if (temp) *temp = '.'; } - eap_name = result->eap_name; IFGETDUP(value, "Name", result->name); IFGETDUP(value, "GenericName", result->generic); @@ -249,6 +245,8 @@ IFGETDUP(value, "Exec", result->exec); if (result->exec) { + char *exe = NULL; + exe = strchr(result->exec, ' '); if (exe) { @@ -256,7 +254,6 @@ exe++; result->exec_params = strdup(exe); } - exe = result->exec; } IFGETDUP(value, "StartupWMClass", result->window_class); @@ -287,6 +284,10 @@ IFGETDUP(value, "X-Enlightenment-WindowTitle", result->window_title); 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, "X-Enlightenment-IconTheme", result->icon_theme); IFGETDUP(value, "X-Enlightenment-IconClass", result->icon_class); @@ -325,39 +326,8 @@ } } - IFGETDUP(value, "Categories", result->categories); - if (result->categories) - result->Categories = - ecore_desktop_paths_to_hash(result->categories); - categories = result->categories; - - value = ecore_hash_get(result->group, "OnlyShowIn"); - if (value) - result->OnlyShowIn = - ecore_desktop_paths_to_hash(value); - value = ecore_hash_get(result->group, "NotShowIn"); - if (value) - result->NotShowIn = - ecore_desktop_paths_to_hash(value); - value = ecore_hash_get(result->group, "X-KDE-StartupNotify"); - if (value) - result->startup = (strcmp(value, "true") == 0); - value = ecore_hash_get(result->group, "StartupNotify"); - if (value) - result->startup = (strcmp(value, "true") == 0); - value = ecore_hash_get(result->group, "X-Enlightenment-WaitExit"); - if (value) - result->wait_exit = (strcmp(value, "true") == 0); - value = ecore_hash_get(result->group, "NoDisplay"); - if (value) - result->no_display = (strcmp(value, "true") == 0); - value = ecore_hash_get(result->group, "Hidden"); - if (value) - 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. + /* icon/class is a list of standard icons from the theme that can override the icon created above. + * Use (from .desktop) 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 */ @@ -369,12 +339,12 @@ 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; + 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) { @@ -391,18 +361,18 @@ /* 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 ((result->eap_name) && (result->eap_name[0] != '\0')) { if (done) strcat(result->icon_class, ","); - strcat(result->icon_class, eap_name); + strcat(result->icon_class, result->eap_name); done = 1; } - if ((exe) && (exe[0] != '\0')) + if ((result->exec) && (result->exec[0] != '\0')) { char *tmp; - tmp = strdup(ecore_file_get_file(exe)); + tmp = strdup(ecore_file_get_file(result->exec)); if (tmp) { char *p2; @@ -424,11 +394,11 @@ free(tmp); } } - if ((categories) && (categories[0] != '\0')) + if ((result->categories) && (result->categories[0] != '\0')) { if (done) strcat(result->icon_class, ","); - strcat(result->icon_class, categories); + strcat(result->icon_class, result->categories); done = 1; } while (*p != '\0') @@ -441,6 +411,31 @@ } } } + + value = ecore_hash_get(result->group, "OnlyShowIn"); + if (value) + result->OnlyShowIn = + ecore_desktop_paths_to_hash(value); + value = ecore_hash_get(result->group, "NotShowIn"); + if (value) + result->NotShowIn = + ecore_desktop_paths_to_hash(value); + value = ecore_hash_get(result->group, "X-KDE-StartupNotify"); + if (value) + result->startup = (strcmp(value, "true") == 0); + value = ecore_hash_get(result->group, "StartupNotify"); + if (value) + result->startup = (strcmp(value, "true") == 0); + value = ecore_hash_get(result->group, "X-Enlightenment-WaitExit"); + if (value) + result->wait_exit = (strcmp(value, "true") == 0); + value = ecore_hash_get(result->group, "NoDisplay"); + if (value) + result->no_display = (strcmp(value, "true") == 0); + value = ecore_hash_get(result->group, "Hidden"); + if (value) + result->hidden = (strcmp(value, "true") == 0); + } else { =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop_icon.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -3 -r1.37 -r1.38 --- ecore_desktop_icon.c 24 Sep 2006 21:17:09 -0000 1.37 +++ ecore_desktop_icon.c 25 Sep 2006 12:50:23 -0000 1.38 @@ -53,45 +53,50 @@ ecore_desktop_icon_find(const char *icon, const char *icon_size, const char *icon_theme) { - char *dir = NULL, *icn; + char *result = NULL, *icn; Ecore_List *icons; int in_cache = 0; double begin; begin = ecore_time_get(); - if (icon == NULL) - 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))) + if (icon) { - 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 - fprintf(stderr, "\tTrying To Find Icon %s\n", icn); + fprintf(stderr, "\tTrying To Find Icon %s\n", icn); #endif - ext = strrchr(icn, '.'); - /* Check for unsupported extension */ - if ((ext) && (!strcmp(ext, ".ico"))) continue; - - dir = _ecore_desktop_icon_find0(icn, icon_size, icon_theme); - if (dir) - break; - } - ecore_list_destroy(icons); + ext = strrchr(icn, '.'); + /* Check for unsupported extension */ + if ((ext) && (!strcmp(ext, ".ico"))) + continue; + + result = _ecore_desktop_icon_find0(icn, icon_size, icon_theme); + if (result) + break; + } + ecore_list_destroy(icons); + + } /* if (icons) */ + } /* if ((icon[0] == '/') && (ecore_file_exists(icon))) ; else */ + } /* if (icon) */ - if (dir) + if (result) { if (in_cache) { @@ -109,7 +114,8 @@ instrumentation.icons_not_found_time += ecore_time_get() - begin; instrumentation.icons_not_found++; } - return dir; + + return result; } /** Search for an icon the fdo way. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs