From: Enlightenment C. <no...@cv...> - 2006-04-26 01:44:54
|
Enlightenment CVS committal Author : onefang Project : e17 Module : apps/e_utils Dir : e17/apps/e_utils/src/bin/e17genmenu Modified Files: eaps.c eaps.h global.h parse.c Log Message: Cleanup the eap writing a bit. Still needs some work. If the .desktop file includes a window class (hardly ever happens) include that class in the eap. =================================================================== RCS file: /cvs/e/e17/apps/e_utils/src/bin/e17genmenu/eaps.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- eaps.c 21 Mar 2006 02:27:29 -0000 1.3 +++ eaps.c 26 Apr 2006 01:44:06 -0000 1.4 @@ -2,27 +2,32 @@ #include "config.h" #include "icons.h" #include "eaps.h" +#include "parse.h" #define DEBUG 1 +static void _write_eap(Eet_File *ef, char *section, char *value); + + /* Create a .directory.eap for this dir */ void create_dir_eap(char *path, char *cat) { char path2[MAX_PATH]; - char *icon; + G_Eap eap; + memset(&eap, 0, sizeof(G_Eap)); + eap.name = cat; snprintf(path2, sizeof(path2), "%s/.directory.eap", path); if (!ecore_file_exists(path2)) { - icon = set_icon(cat); - if (!icon) + eap.icon_path = set_icon(cat); + if (!eap.icon_path) { fprintf(stderr, "ERROR: Cannot Find Icon For %s\n", cat); return; } - write_icon(path2, icon); - write_eap(path2, "app/info/name", cat); + write_icon(path2, &eap); } } @@ -63,24 +68,26 @@ } void -write_icon(char *f, char *i) +write_icon(char *file, G_Eap *eap) { Engrave_File *eet; Engrave_Image *image; Engrave_Group *grp; Engrave_Part *part; Engrave_Part_State *ps; + Eet_File *ef; - char *idir, *ifile, *icomp; + char *idir, *ifile, *icomp, *exec; #ifdef DEBUG - fprintf(stderr, "\tWriting Icon %s\n", i); + fprintf(stderr, "\tWriting file %s\n", file); + fprintf(stderr, "\t\tIcon %s\n", eap->icon_path); #endif /* FIXME: This does not seem to be catching all the problems. Further head scratching is needed. */ - if ((!i) || (i[0] == '\0')) - i = DEFAULTICON; - ifile = ecore_file_get_file(i); - idir = ecore_file_get_dir(i); + if ((!eap->icon_path) || (eap->icon_path[0] == '\0')) + eap->icon_path = DEFAULTICON; + ifile = ecore_file_get_file(eap->icon_path); + idir = ecore_file_get_dir(eap->icon_path); eet = engrave_file_new(); engrave_file_image_dir_set(eet, idir); @@ -109,7 +116,7 @@ engrave_part_state_image_normal_set(ps, image); engrave_part_state_add(part, ps); - engrave_edj_output(eet, f); + engrave_edj_output(eet, file); engrave_file_free(eet); // if (icomp) @@ -118,22 +125,56 @@ // free(idir); // if (ifile) // free(ifile); + + /* FIXME: This is probably why creating eaps takes so long. + * We should just create it right in the first place, rather + * than creating a basic one, then rewriting it several times + * each time we find a new little bit of info. + */ + ef = eet_open(file, EET_FILE_MODE_READ_WRITE); + if (ef) + { + /* Set Eap Values. Trap For Name Not Being Set */ + if (eap->name != NULL) + _write_eap(ef, "app/info/name", eap->name); + else if (eap->eap_name != NULL) + _write_eap(ef, "app/info/name", eap->eap_name); + + if (eap->generic != NULL) + _write_eap(ef, "app/info/generic", eap->generic); + if (eap->comment != NULL) + _write_eap(ef, "app/info/comments", eap->comment); + + /* Parse Exec string for %'s that messup eap write */ + exec = NULL; + if (eap->exec != NULL) + { + exec = parse_exec(eap->exec); + if (exec != NULL) + { + _write_eap(ef, "app/info/exe", exec); + _write_eap(ef, "app/icon/class", exec); + } + } + + if (eap->startup != NULL) + _write_eap(ef, "app/info/startup_notify", eap->startup); + if (eap->window_class != NULL) + _write_eap(ef, "app/window/class", eap->window_class); + eet_close(ef); + } } -void -write_eap(char *file, char *section, char *value) + +static void +_write_eap(Eet_File *ef, char *section, char *value) { int i; - Eet_File *ef; #ifdef DEBUG - fprintf(stderr, "\tWriting %s %s:%s\n", strdup(file), strdup(section), strdup(value)); + fprintf(stderr, "\t\t%s:%s\n", strdup(section), strdup(value)); #endif - ef = eet_open(file, EET_FILE_MODE_READ_WRITE); - if (!ef) - return; - if (!strcmp(section, "app/info/startup_notify")) { if (!value) @@ -152,8 +193,7 @@ { i = eet_write(ef, strdup(section), strdup(value), strlen(value), 0); if (i == 0) - fprintf(stderr, "Failed To Write %s To %s Of %s\n", value, section, file); + fprintf(stderr, "Failed To Write %s To %s\n", value, section); } } - eet_close(ef); } =================================================================== RCS file: /cvs/e/e17/apps/e_utils/src/bin/e17genmenu/eaps.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- eaps.h 7 Mar 2006 21:58:24 -0000 1.1 +++ eaps.h 26 Apr 2006 01:44:06 -0000 1.2 @@ -9,7 +9,6 @@ void create_dir_eap(char *path, char *cat); char *get_window_class(char *file); -void write_icon(char *f, char *i); -void write_eap(char *file, char *section, char *value); +void write_icon(char *file, G_Eap *eap); #endif =================================================================== RCS file: /cvs/e/e17/apps/e_utils/src/bin/e17genmenu/global.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- global.h 9 Mar 2006 03:06:25 -0000 1.2 +++ global.h 26 Apr 2006 01:44:06 -0000 1.3 @@ -23,6 +23,7 @@ char *categories; char *exec; char *icon; + char *icon_path; char *startup; char *type; char *window_class; =================================================================== RCS file: /cvs/e/e17/apps/e_utils/src/bin/e17genmenu/parse.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- parse.c 21 Mar 2006 03:50:43 -0000 1.3 +++ parse.c 26 Apr 2006 01:44:06 -0000 1.4 @@ -171,6 +171,9 @@ value = (char *)ecore_hash_get(desktop->group, "StartupNotify"); if (value) eap->startup = (!strcmp(value, "true")) ? "1" : "0"; + value = (char *)ecore_hash_get(desktop->group, "StartupWMClass"); + if (value) + eap->window_class = strdup(value); } /* Check If We Process */ @@ -212,7 +215,7 @@ void process_file(char *file, char *menu_path, G_Eap *eap) { - char *home, *window_class, *exec, *category, *icon; + char *home, *category; char path[MAX_PATH], order_path[MAX_PATH]; int overwrite; @@ -227,54 +230,18 @@ overwrite = get_overwrite(); snprintf(path, sizeof(path), "%s" EAPPDIR "/%s", home, eap->eap_name); - window_class = get_window_class(path); + if (eap->window_class == NULL) + eap->window_class = get_window_class(path); if (eap->icon != NULL) - icon = find_icon(strdup(eap->icon)); + eap->icon_path = find_icon(strdup(eap->icon)); if (eap->icon == NULL) - icon = strdup(DEFAULTICON); + eap->icon_path = strdup(DEFAULTICON); if ((ecore_file_exists(path)) && (!overwrite)) - { not_over_count++; - } else - { - /* FIXME: This is probably why creating eaps takes so long. - * We should just create it right in the first place, rather - * than creating a basic one, then rewriting it several times - * each time we find a new little bit of info. - */ - /* Start Making The Eap */ - write_icon(path, icon); - /* Set Eap Values. Trap For Name Not Being Set */ - if (eap->name != NULL) - write_eap(path, "app/info/name", eap->name); - else if (eap->eap_name != NULL) - write_eap(path, "app/info/name", eap->eap_name); - - if (eap->generic != NULL) - write_eap(path, "app/info/generic", eap->generic); - if (eap->comment != NULL) - write_eap(path, "app/info/comments", eap->comment); - - /* Parse Exec string for %'s that messup eap write */ - exec = NULL; - if (eap->exec != NULL) - { - exec = parse_exec(eap->exec); - if (exec != NULL) - { - write_eap(path, "app/info/exe", exec); - write_eap(path, "app/icon/class", exec); - } - } - - if (eap->startup != NULL) - write_eap(path, "app/info/startup_notify", eap->startup); - if (window_class != NULL) - write_eap(path, "app/window/class", window_class); - } + write_icon(path, eap); category = NULL; if (menu_path != NULL) |