Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: E.h backgrounds.c config.c cursors.c draw.c extinitwin.c file.c iclass.c lang.c menus-misc.c sound.c text.c Log Message: Only look for localized versions of theme config files (not image, sound, etc.). Cleanups. =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v retrieving revision 1.471 retrieving revision 1.472 diff -u -3 -r1.471 -r1.472 --- E.h 16 Jul 2005 16:57:32 -0000 1.471 +++ E.h 17 Jul 2005 12:55:10 -0000 1.472 @@ -795,6 +795,12 @@ } grabs; struct { + const char *lang; + char utf8_int; /* Use UTF-8 internally */ + char utf8_loc; /* Locale is UTF-8 */ + } locale; + struct + { unsigned int numlock; unsigned int scrollock; unsigned int mod_combos[8]; @@ -813,11 +819,6 @@ } place; struct { - char utf8_int; /* Use UTF-8 internally */ - char utf8_loc; /* Locale is UTF-8 */ - } text; - struct - { char *path; } theme; struct @@ -1102,8 +1103,9 @@ int ConfigSkipIfExists(FILE * fs, const char *name, int type); char *GetLine(char *s, int size, FILE * f); void ConfigAlertLoad(const char *txt); -char *FindFile(const char *file, const char *themepath); -char *ThemeFileFind(const char *file); +char *FindFile(const char *file, const char *themepath, + int localized); +char *ThemeFileFind(const char *file, int localized); char *ConfigFileFind(const char *name, const char *themepath, int pp); int ConfigFileLoad(const char *name, const char *themepath, @@ -1374,9 +1376,7 @@ char *pathtofile(const char *file); const char *FileExtension(const char *file); char *field(char *s, int fieldno); -int fillfield(char *s, int fieldno, char *buf); void fword(char *s, int num, char *wd); -int findLocalizedFile(char *fname); /* finders.c */ EWin *EwinFindByPtr(const EWin * ewin); @@ -1883,5 +1883,3 @@ extern VirtRoot VRoot; extern EConf Conf; extern EMode Mode; - -#define FILEPATH_LEN_MAX 4096 =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/backgrounds.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -3 -r1.33 -r1.34 --- backgrounds.c 16 Jul 2005 16:57:38 -0000 1.33 +++ backgrounds.c 17 Jul 2005 12:55:11 -0000 1.34 @@ -78,7 +78,7 @@ { char *f; - f = ThemeFileFind(bg->bg.file); + f = ThemeFileFind(bg->bg.file, 0); if (f) { f1 = fileinode(f); @@ -91,7 +91,7 @@ { char *f; - f = ThemeFileFind(bg->top.file); + f = ThemeFileFind(bg->top.file, 0); if (f) { f4 = fileinode(f); @@ -242,7 +242,7 @@ /* And delete the actual image files */ if (bg->bg.file) { - f = ThemeFileFind(bg->bg.file); + f = ThemeFileFind(bg->bg.file, 0); if (f) { E_rm(f); @@ -251,7 +251,7 @@ } if (bg->top.file) { - f = ThemeFileFind(bg->top.file); + f = ThemeFileFind(bg->top.file, 0); if (f) { E_rm(f); @@ -494,14 +494,14 @@ if (bg->bg.file && !bg->bg.im) { if (!bg->bg.real_file) - bg->bg.real_file = ThemeFileFind(bg->bg.file); + bg->bg.real_file = ThemeFileFind(bg->bg.file, 0); bg->bg.im = ELoadImage(bg->bg.real_file); } if (bg->top.file && !bg->top.im) { if (!bg->top.real_file) - bg->top.real_file = ThemeFileFind(bg->top.file); + bg->top.real_file = ThemeFileFind(bg->top.file, 0); bg->top.im = ELoadImage(bg->top.real_file); } @@ -950,7 +950,7 @@ /* check first if we can actually find the files */ if (bg1) { - tmp = ThemeFileFind(bg1); + tmp = ThemeFileFind(bg1, 0); if (!tmp) { ok = 0; @@ -962,7 +962,7 @@ } if (bg2) { - tmp = ThemeFileFind(bg2); + tmp = ThemeFileFind(bg2, 0); if (!tmp) { ok = 0; @@ -1148,10 +1148,10 @@ fprintf(fs, "560 %d %d %d\n", r, g, b); if ((bglist[i]->bg.file) && (!bglist[i]->bg.real_file)) - bglist[i]->bg.real_file = ThemeFileFind(bglist[i]->bg.file); + bglist[i]->bg.real_file = ThemeFileFind(bglist[i]->bg.file, 0); if ((bglist[i]->top.file) && (!bglist[i]->top.real_file)) - bglist[i]->top.real_file = ThemeFileFind(bglist[i]->top.file); + bglist[i]->top.real_file = ThemeFileFind(bglist[i]->top.file, 0); if ((bglist[i]->bg.file) && (bglist[i]->bg.real_file)) { =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/config.c,v retrieving revision 1.133 retrieving revision 1.134 diff -u -3 -r1.133 -r1.134 --- config.c 17 Apr 2005 14:08:42 -0000 1.133 +++ config.c 17 Jul 2005 12:55:11 -0000 1.134 @@ -377,46 +377,95 @@ return 0; } +static char * +FindFileLocalized(const char *name, const char *path, int localized) +{ + char s[FILEPATH_LEN_MAX]; + const char *lang; + char *p[4]; + int i, len; + + if (path) + len = Esnprintf(s, sizeof(s), "%s/%s", path, name); + else + len = Esnprintf(s, sizeof(s), "%s", name); + if (len <= 0) + return NULL; + + lang = Mode.locale.lang; + if (!localized || !lang) + { + if (isfile(s)) + return Estrdup(s); + else + return NULL; + } + + if (len + 1 + strlen(lang) >= sizeof(s)) + return NULL; + + s[len] = '.'; + strcpy(s + len + 1, lang); + + p[0] = s + len + 1 + strlen(lang); /* .da_DK.UTF-8 */ + p[1] = strchr(s + len + 1, '.'); /* .da_DK */ + p[2] = strchr(s + len + 1, '_'); /* .da */ + p[3] = s + len; + + for (i = 0; i < 4; i++) + { + if (p[i] == NULL) + continue; + + *p[i] = '\0'; + if (isfile(s)) + return Estrdup(s); + } + + return NULL; +} + char * -FindFile(const char *file, const char *themepath) +FindFile(const char *file, const char *themepath, int localized) { char s[FILEPATH_LEN_MAX]; + char *p; /* if absolute path - and file exists - return it */ if (isabspath(file)) { - strcpy(s, file); - if (findLocalizedFile(s) || isfile(s)) - return Estrdup(s); + p = FindFileLocalized(file, NULL, localized); + if (p) + return p; } /* look in ~/.e16 first */ - - Esnprintf(s, sizeof(s), "%s/%s", EDirUser(), file); - if (findLocalizedFile(s) || isfile(s)) - return Estrdup(s); + p = FindFileLocalized(file, EDirUser(), localized); + if (p) + return p; if (themepath) { /* look in theme dir */ - Esnprintf(s, sizeof(s), "%s/%s", themepath, file); - if (findLocalizedFile(s) || isfile(s)) - return Estrdup(s); + p = FindFileLocalized(file, themepath, localized); + if (p) + return p; } /* look in system config dir */ - Esnprintf(s, sizeof(s), "%s/config/%s", EDirRoot(), file); - if (findLocalizedFile(s) || isfile(s)) - return Estrdup(s); + Esnprintf(s, sizeof(s), "%s/config", EDirRoot()); + p = FindFileLocalized(file, s, localized); + if (p) + return p; /* not found.... NULL */ return NULL; } char * -ThemeFileFind(const char *file) +ThemeFileFind(const char *file, int localized) { - return FindFile(file, Mode.theme.path); + return FindFile(file, Mode.theme.path, localized); } char * @@ -426,7 +475,7 @@ char *fullname, *file, *ppfile; int i, err; - fullname = FindFile(name, themepath); + fullname = FindFile(name, themepath, 1); if (!fullname) return NULL; =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/cursors.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -3 -r1.27 -r1.28 --- cursors.c 16 Jul 2005 16:57:39 -0000 1.27 +++ cursors.c 17 Jul 2005 12:55:12 -0000 1.28 @@ -54,7 +54,7 @@ if (image) { - img = FindFile(image, Mode.theme.path); + img = FindFile(image, Mode.theme.path, 0); if (!img) return NULL; =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/draw.c,v retrieving revision 1.79 retrieving revision 1.80 diff -u -3 -r1.79 -r1.80 --- draw.c 16 Jul 2005 16:57:40 -0000 1.79 +++ draw.c 17 Jul 2005 12:55:12 -0000 1.80 @@ -1060,7 +1060,7 @@ ELoadImage(const char *file) { Imlib_Image *im; - char *f = NULL; + char *f; if (!file) return NULL; @@ -1071,7 +1071,7 @@ return im; } - f = ThemeFileFind(file); + f = ThemeFileFind(file, 0); if (f) { im = imlib_load_image(f); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/extinitwin.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- extinitwin.c 16 Jul 2005 16:57:40 -0000 1.10 +++ extinitwin.c 17 Jul 2005 12:55:13 -0000 1.11 @@ -85,7 +85,7 @@ { Window w2, ww; - char *f, s[1024]; + char s[1024]; Imlib_Image *im; struct timeval tv; int dd, x, y; @@ -123,14 +123,7 @@ if (EventDebug(EDBUG_TYPE_SESSION)) Eprintf("ExtInitWinCreate - child %s\n", s); - f = ThemeFileFind(s); - im = NULL; - if (f) - { - im = imlib_load_image(f); - Efree(f); - } - + im = ELoadImage(s); if (im) { imlib_context_set_image(im); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/file.c,v retrieving revision 1.69 retrieving revision 1.70 diff -u -3 -r1.69 -r1.70 --- file.c 15 Apr 2005 21:07:45 -0000 1.69 +++ file.c 17 Jul 2005 12:55:13 -0000 1.70 @@ -650,25 +650,6 @@ } int -fillfield(char *s, int fieldno, char *buf) -{ - if (!buf) - return 0; - buf[0] = 0; - fword(s, fieldno + 1, buf); - if (buf[0]) - { - if ((!strcmp(buf, "NULL")) || (!strcmp(buf, "(null)"))) - { - buf[0] = 0; - return 0; - } - return 1; - } - return 0; -} - -int canread(const char *s) { if ((!s) || (!*s)) @@ -832,40 +813,3 @@ } return NULL; } - -int -findLocalizedFile(char *fname) -{ - char *tmp, *lang, *p[3]; - int i; - - if (!(lang = setlocale(LC_MESSAGES, NULL))) - return 0; - - tmp = Estrdup(fname); - lang = Estrdup(lang); /* lang may be in static space, thus it must - * * * be duplicated before we change it below */ - p[0] = lang + strlen(lang); - p[1] = strchr(lang, '.'); - p[2] = strchr(lang, '_'); - - for (i = 0; i < 3; i++) - { - if (p[i] == NULL) - continue; - - *p[i] = '\0'; - sprintf(fname, "%s.%s", tmp, lang); - if (isfile(fname)) - { - free(tmp); - free(lang); - return 1; - } - } - strcpy(fname, tmp); - free(tmp); - free(lang); - - return 0; -} =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/iclass.c,v retrieving revision 1.70 retrieving revision 1.71 diff -u -3 -r1.70 -r1.71 --- iclass.c 16 Jul 2005 16:57:41 -0000 1.70 +++ iclass.c 17 Jul 2005 12:55:13 -0000 1.71 @@ -189,7 +189,7 @@ /* not loaded, load and setup */ if (!is->real_file) - is->real_file = ThemeFileFind(is->im_file); + is->real_file = ThemeFileFind(is->im_file, 0); is->im = ELoadImage(is->real_file); imlib_context_set_image(is->im); @@ -1402,27 +1402,14 @@ ic = ImageclassFind(param1, 0); if (ic) { - Imlib_Image *im = NULL; - - if (ic->norm.normal->im_file) + ImagestateRealize(ic->norm.normal); + if (ic->norm.normal->im) { - if (!ic->norm.normal->real_file) - ic->norm.normal->real_file = - ThemeFileFind(ic->norm.normal->im_file); - if (ic->norm.normal->real_file) - im = imlib_load_image(ic->norm.normal->real_file); - if (im) - { - imlib_context_set_image(im); - IpcPrintf("%i %i\n", imlib_image_get_width(), - imlib_image_get_height()); - imlib_free_image(); - } - else - IpcPrintf("Error: Image does not exist\n"); + imlib_context_set_image(ic->norm.normal->im); + IpcPrintf("%i %i\n", imlib_image_get_width(), + imlib_image_get_height()); + imlib_free_image(); } - else - IpcPrintf("Error: Image does not exist\n"); } else IpcPrintf("Error: Imageclass does not exist\n"); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/lang.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- lang.c 23 Mar 2005 19:40:56 -0000 1.7 +++ lang.c 17 Jul 2005 12:55:13 -0000 1.8 @@ -99,7 +99,7 @@ EstrInt2Enc(const char *str, int want_utf8) { #if HAVE_ICONV - if (Mode.text.utf8_int == want_utf8) + if (Mode.locale.utf8_int == want_utf8) return str; if (str == NULL) @@ -119,7 +119,7 @@ EstrInt2EncFree(const char *str, int want_utf8) { #if HAVE_ICONV - if (Mode.text.utf8_int == want_utf8) + if (Mode.locale.utf8_int == want_utf8) return; if (str) @@ -159,6 +159,7 @@ else enc_int = enc_loc; + Mode.locale.lang = setlocale(LC_MESSAGES, NULL); if (EventDebug(EDBUG_TYPE_VERBOSE)) { Eprintf("Locale: %s\n", setlocale(LC_ALL, NULL)); @@ -167,12 +168,12 @@ } if (!strcasecmp(enc_loc, "utf8") || !strcasecmp(enc_loc, "utf-8")) - Mode.text.utf8_loc = 1; + Mode.locale.utf8_loc = 1; if (!strcasecmp(enc_int, "utf8") || !strcasecmp(enc_int, "utf-8")) - Mode.text.utf8_int = 1; + Mode.locale.utf8_int = 1; #if HAVE_ICONV - if (Mode.text.utf8_int) + if (Mode.locale.utf8_int) { iconv_cd_loc2int = iconv_open("UTF-8", enc_loc); iconv_cd_int2loc = iconv_open(enc_loc, "UTF-8"); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/menus-misc.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- menus-misc.c 16 Jul 2005 16:57:43 -0000 1.15 +++ menus-misc.c 17 Jul 2005 12:55:13 -0000 1.16 @@ -379,7 +379,7 @@ return NULL; calls++; - ff = FindFile(file, NULL); + ff = FindFile(file, NULL, 0); if (!ff) goto done; @@ -408,13 +408,12 @@ Menu *m, *mm; int i, num; char **list, s[4096], ss[4096]; - MenuItem *mi; FILE *f; - char *lang, name_buf[20]; + char name_buf[20]; - if ((lang = setlocale(LC_MESSAGES, NULL)) != NULL) - Esnprintf(name_buf, sizeof(name_buf), "Name[%s]=", lang); + if (Mode.locale.lang) + Esnprintf(name_buf, sizeof(name_buf), "Name[%s]=", Mode.locale.lang); else name_buf[0] = '\0'; =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/sound.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -3 -r1.32 -r1.33 --- sound.c 16 Jul 2005 16:57:44 -0000 1.32 +++ sound.c 17 Jul 2005 12:55:13 -0000 1.33 @@ -74,7 +74,7 @@ int bytes_per_frame, frames_read; double in_rate; - find = FindFile(file, Mode.theme.path); + find = FindFile(file, Mode.theme.path, 0); if (!find) { DialogOK(_("Error finding sound file"), =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/text.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -3 -r1.57 -r1.58 --- text.c 16 Jul 2005 16:57:44 -0000 1.57 +++ text.c 17 Jul 2005 12:55:13 -0000 1.58 @@ -148,7 +148,7 @@ if ((ts->efont) || (ts->xfont) || (ts->xfontset)) return; - ts->need_utf8 = Mode.text.utf8_int; + ts->need_utf8 = Mode.locale.utf8_int; /* Try FreeType */ { ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs