Enlightenment CVS committal Author : onefang Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_apps.c e_fdo_menu_to_order.c Log Message: Create symlinks in ~/.e/e/applications/all to system .desktop files, then we don't need full paths in .order files. Full paths still supported. =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_apps.c,v retrieving revision 1.154 retrieving revision 1.155 diff -u -3 -r1.154 -r1.155 --- e_apps.c 26 Aug 2006 01:24:27 -0000 1.154 +++ e_apps.c 30 Aug 2006 05:00:58 -0000 1.155 @@ -65,6 +65,7 @@ #endif static void _e_app_check_order(const char *file); static int _e_app_order_contains(E_App *a, const char *file); +static void _e_app_resolve_file_name(char *buf, size_t size, const char *path, const char *file); /* local subsystem globals */ static Evas_Hash *_e_apps = NULL; @@ -289,10 +290,12 @@ goto error; } else - return NULL; + { + return NULL; + } _e_apps = evas_hash_add(_e_apps, a->path, a); _e_apps_list = evas_list_prepend(_e_apps_list, a); - + ac = e_app_cache_generate(a); e_app_cache_save(ac, a->path); e_app_cache_free(ac); @@ -388,10 +391,7 @@ a2 = NULL; - if (s[0] == '/') - snprintf(buf, sizeof(buf), "%s", s); - else - snprintf(buf, sizeof(buf), "%s/%s", a->path, s); + _e_app_resolve_file_name(buf, sizeof(buf), a->path, s); if (ecore_file_exists(buf)) { a2 = e_app_new(buf, scan_subdirs); @@ -409,10 +409,7 @@ pl = _e_apps_repositories; while ((!a2) && (pl)) { - if (s[0] == '/') - snprintf(buf, sizeof(buf), "%s", s); - else - snprintf(buf, sizeof(buf), "%s/%s", (char *)pl->data, s); + _e_app_resolve_file_name(buf, sizeof(buf), (char *)pl->data, s); a2 = e_app_new(buf, scan_subdirs); pl = pl->next; } @@ -1154,13 +1151,12 @@ } if (!path) path = a->path; - ext = strchr(path, '.'); + ext = strrchr(path, '.'); if ((ext) && (strcmp(ext, ".desktop") == 0)) { /* It's a .desktop file. */ Ecore_Desktop *desktop; desktop = ecore_desktop_get(path, lang); - if (!desktop) return; if (desktop) { if (desktop->name) a->name = evas_stringshare_add(desktop->name); @@ -1952,10 +1948,7 @@ else { /* If we still haven't found it, it is new! */ - if (s[0] == '/') - snprintf(buf, sizeof(buf), "%s", s); - else - snprintf(buf, sizeof(buf), "%s/%s", app->path, s); + _e_app_resolve_file_name(buf, sizeof(buf), app->path, s); a2 = e_app_new(buf, 1); if (a2) { @@ -1977,10 +1970,7 @@ pl = _e_apps_repositories; while ((!a2) && (pl)) { - if (s[0] == '/') - snprintf(buf, sizeof(buf), "%s", s); - else - snprintf(buf, sizeof(buf), "%s/%s", (char *)pl->data, s); + _e_app_resolve_file_name(buf, sizeof(buf), (char *)pl->data, s); a2 = e_app_new(buf, 1); pl = pl->next; } @@ -2329,10 +2319,7 @@ // printf("Cache scan finish.\n"); return 0; } - if (s[0] == '/') - snprintf(buf, sizeof(buf), "%s", s); - else - snprintf(buf, sizeof(buf), "%s/%s", sc->path, s); + _e_app_resolve_file_name(buf, sizeof(buf), sc->path, s); is_dir = ecore_file_is_dir(buf); if (_e_app_is_eapp(s) || is_dir) { @@ -2386,10 +2373,7 @@ E_App *a2; ac2 = l->data; - if (ac2->file[0] == '/') - snprintf(buf, sizeof(buf), "%s", ac2->file); - else - snprintf(buf, sizeof(buf), "%s/%s", path, ac2->file); + _e_app_resolve_file_name(buf, sizeof(buf), path, ac2->file); if ((ac2->is_dir) && (scan_subdirs)) { a2 = e_app_new(buf, scan_subdirs); @@ -2424,10 +2408,7 @@ a2 = NULL; while ((!a2) && (pl)) { - if (ac2->file[0] == '/') - snprintf(buf, sizeof(buf), "%s", ac2->file); - else - snprintf(buf, sizeof(buf), "%s/%s", (char *)pl->data, ac2->file); + _e_app_resolve_file_name(buf, sizeof(buf), (char *)pl->data, ac2->file); a2 = e_app_new(buf, scan_subdirs); pl = pl->next; } @@ -2556,4 +2537,19 @@ } fclose(f); return ret; +} + + +static void +_e_app_resolve_file_name(char *buf, size_t size, const char *path, const char *file) +{ + size_t length; + + length = strlen(path); + if (file[0] == '/') + snprintf(buf, size, "%s", file); + else if ((length > 0) && (path[length - 1] == '/')) + snprintf(buf, size, "%s%s", path, file); + else + snprintf(buf, size, "%s/%s", path, file); } =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_fdo_menu_to_order.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- e_fdo_menu_to_order.c 22 Aug 2006 23:39:08 -0000 1.3 +++ e_fdo_menu_to_order.c 30 Aug 2006 05:00:58 -0000 1.4 @@ -90,7 +90,7 @@ { Ecore_Hash_Node *node; Ecore_Desktop *desktop; - char *file, *path; + const char *file, *path; path = (char *)user_data; node = (Ecore_Hash_Node *) value; @@ -110,6 +110,10 @@ FILE *f; Ecore_List *list = NULL; + snprintf(path2, sizeof(path2), "%s/.e/e/applications/all/%s", ecore_desktop_home_get(), ecore_file_get_file(file)); + if (!ecore_file_exists(path2)) + ecore_file_symlink(file, path2); + file = ecore_file_get_file(file); snprintf(order_path, sizeof(order_path), "%s/.e/e/applications/menu/all/%s", ecore_desktop_home_get(), path); if (!ecore_file_exists(order_path)) { @@ -151,7 +155,7 @@ } fclose(f2); /* If We Had To Create This Order Then Just Add The file */ - if (!ecore_list_append(list, file)) + if (!ecore_list_append(list, strdup(file))) { fprintf(stderr, "ERROR: Ecore List Append Failed !!\n"); return; @@ -188,7 +192,7 @@ /* Add This file To List Of Existing ? */ if (!_e_search_list(list, file)) { - if (!ecore_list_append(list, file)) + if (!ecore_list_append(list, strdup(file))) { fprintf(stderr, "ERROR: Ecore List Append Failed !!\n"); return; ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs