Enlightenment CVS committal
Author : kwo
Project : e16
Module : e
Dir : e16/e/src
Modified Files:
actions.c econfig.c lang.c lang.h main.c mod-misc.c session.c
Log Message:
Enable configuring internal and exported language.
===================================================================
RCS file: /cvs/e/e16/e/src/actions.c,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -3 -r1.198 -r1.199
--- actions.c 17 Apr 2006 15:55:24 -0000 1.198
+++ actions.c 21 Apr 2006 23:47:30 -0000 1.199
@@ -40,6 +40,8 @@
for (fd = 3; fd < 1024; fd++)
close(fd);
+ LangExport();
+
sh = usershell(getuid());
if (exe)
{
@@ -174,6 +176,8 @@
/* Close all file descriptors except the std 3 */
for (fd = 3; fd < 1024; fd++)
close(fd);
+
+ LangExport();
execvp(argv[0], argv);
===================================================================
RCS file: /cvs/e/e16/e/src/econfig.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- econfig.c 21 Apr 2006 22:52:58 -0000 1.10
+++ econfig.c 21 Apr 2006 23:47:30 -0000 1.11
@@ -407,6 +407,8 @@
case ITEM_TYPE_STRING:
if (*(char **)ci->ptr)
Efree(*(char **)ci->ptr);
+ if (*str == '\0')
+ str = NULL;
*((char **)ci->ptr) = Estrdup(str);
break;
}
===================================================================
RCS file: /cvs/e/e16/e/src/lang.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- lang.c 19 Apr 2006 19:13:46 -0000 1.10
+++ lang.c 21 Apr 2006 23:47:30 -0000 1.11
@@ -22,6 +22,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "E.h"
+#include "emodule.h"
#include "lang.h"
#ifdef HAVE_LOCALE_H
@@ -121,6 +122,7 @@
return Eiconv(iconv_cd_int2loc, str, strlen(str));
#else
+ want_utf8 = 0;
return str;
#endif
}
@@ -135,16 +137,83 @@
if (str)
Efree((char *)str);
+#else
+ str = NULL;
+ want_utf8 = 0;
#endif
}
+static struct
+{
+ char *internal;
+ char *exported;
+} Conf_locale =
+{
+NULL, NULL};
+
+static struct
+{
+ char init;
+ char *env_language;
+ char *env_lc_all;
+ char *env_lc_messages;
+ char *env_lang;
+} locale_data;
+
+static void
+LangEnvironmentSetup(const char *locale)
+{
+ /* Precedence: LANGUAGE, LC_ALL, LC_MESSAGES, LANG */
+ if (locale)
+ {
+ /* Set requested */
+ Esetenv("LANGUAGE", locale);
+ Esetenv("LC_ALL", locale);
+ Esetenv("LANG", locale);
+ }
+ else
+ {
+ /* Restore saved */
+ Esetenv("LANGUAGE", locale_data.env_language);
+ Esetenv("LC_ALL", locale_data.env_lc_all);
+ Esetenv("LC_MESSAGES", locale_data.env_lc_messages);
+ Esetenv("LANG", locale_data.env_lang);
+ }
+}
+
+static void
+LangEnvironmentSave(void)
+{
+ if (locale_data.init)
+ return;
+ locale_data.init = 1;
+
+ locale_data.env_language = Estrdup(getenv("LANGUAGE"));
+ locale_data.env_lc_all = Estrdup(getenv("LC_ALL"));
+ locale_data.env_lc_messages = Estrdup(getenv("LC_MESSAGES"));
+ locale_data.env_lang = Estrdup(getenv("LANG"));
+}
+
+void
+LangExport(void)
+{
+ if (Conf_locale.exported)
+ LangEnvironmentSetup(Conf_locale.exported);
+ else if (Conf_locale.internal)
+ LangEnvironmentSetup(NULL);
+}
+
void
LangInit(void)
{
const char *enc_loc, *enc_int;
- /* Set up things according to env vars */
- setlocale(LC_ALL, "");
+ if (!locale_data.init)
+ LangEnvironmentSave();
+
+ LangEnvironmentSetup(Conf_locale.internal);
+
+ setlocale(LC_ALL, ""); /* Set up things according to env vars */
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@@ -199,13 +268,44 @@
#endif
}
-#if 0 /* Not used yet */
+void
+LangExit(void)
+{
+#if HAVE_ICONV
+ if (iconv_cd_int2utf8)
+ iconv_close(iconv_cd_int2utf8);
+ if (iconv_cd_utf82int)
+ iconv_close(iconv_cd_utf82int);
+ if (iconv_cd_int2loc)
+ iconv_close(iconv_cd_int2loc);
+ if (iconv_cd_loc2int)
+ iconv_close(iconv_cd_loc2int);
+ iconv_cd_int2utf8 = iconv_cd_utf82int = NULL;
+ iconv_cd_int2loc = iconv_cd_loc2int = NULL;
+#endif
+
+ LangEnvironmentSetup(NULL);
+}
static void
-LangExit(void)
+LangCfgChange(void *item __UNUSED__, const char *locale)
{
- if (iconv_cd)
- iconv_close(iconv_cd);
+ if (*locale == '\0')
+ locale = NULL;
+ LangExit();
+ _EFDUP(Conf_locale.internal, locale);
+ LangInit();
}
-#endif
+static const CfgItem LocaleCfgItems[] = {
+ CFG_FUNC_STR(Conf_locale, internal, LangCfgChange),
+ CFG_ITEM_STR(Conf_locale, exported),
+};
+#define N_CFG_ITEMS (sizeof(LocaleCfgItems)/sizeof(CfgItem))
+
+const EModule ModLocale = {
+ "locale", NULL,
+ NULL,
+ {0, NULL},
+ {N_CFG_ITEMS, LocaleCfgItems}
+};
===================================================================
RCS file: /cvs/e/e16/e/src/lang.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- lang.h 19 Apr 2006 19:13:46 -0000 1.1
+++ lang.h 21 Apr 2006 23:47:30 -0000 1.2
@@ -41,6 +41,9 @@
/* lang.c */
void LangInit(void);
+void LangExit(void);
+void LangExport(void);
+
char *EstrLoc2Int(const char *str, int len);
char *EstrUtf82Int(const char *str, int len);
const char *EstrInt2Enc(const char *str, int want_utf8);
===================================================================
RCS file: /cvs/e/e16/e/src/main.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -3 -r1.145 -r1.146
--- main.c 21 Apr 2006 15:51:46 -0000 1.145
+++ main.c 21 Apr 2006 23:47:30 -0000 1.146
@@ -212,21 +212,21 @@
}
}
- /* Initialise internationalisation */
- LangInit();
+ SignalsSetup(); /* Install signal handlers */
- /* run most of the setup */
- SignalsSetup();
SetupX(dstr); /* This is where the we fork per screen */
/* X is now running, and we have forked per screen */
+ /* So far nothing should rely on a selected settings or theme. */
+ ConfigurationLoad(); /* Load settings */
+
+ /* Initialise internationalisation */
+ LangInit();
+
ECheckEprog("epp");
ECheckEprog("eesh");
EDirsSetup();
- /* So far nothing should rely on a selected settings or theme. */
- ConfigurationLoad(); /* Load settings */
-
/* The theme path must now be available for config file loading. */
ThemePathFind();
@@ -466,11 +466,12 @@
static void
RunMenuGen(void)
{
-
char file[FILEPATH_LEN_MAX];
if (fork())
return;
+
+ LangExport();
Esnprintf(file, sizeof(file), "exec %s/scripts/e_gen_menu", EDirRoot());
execl(usershell(getuid()), usershell(getuid()), "-c", (char *)file, NULL);
===================================================================
RCS file: /cvs/e/e16/e/src/mod-misc.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -3 -r1.33 -r1.34
--- mod-misc.c 21 Apr 2006 22:52:59 -0000 1.33
+++ mod-misc.c 21 Apr 2006 23:47:30 -0000 1.34
@@ -45,6 +45,7 @@
extern const EModule ModGroups;
extern const EModule ModImageclass;
extern const EModule ModIconboxes;
+extern const EModule ModLocale;
extern const EModule ModMenus;
extern const EModule ModMisc;
extern const EModule ModPagers;
@@ -75,6 +76,7 @@
&ModGroups,
&ModIconboxes,
&ModImageclass,
+ &ModLocale,
&ModMenus,
&ModMisc,
&ModPagers,
===================================================================
RCS file: /cvs/e/e16/e/src/session.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -3 -r1.120 -r1.121
--- session.c 19 Apr 2006 19:13:46 -0000 1.120
+++ session.c 21 Apr 2006 23:47:30 -0000 1.121
@@ -513,6 +513,8 @@
if (mode != EEXIT_THEME && mode != EEXIT_RESTART)
SessionHelper(ESESSION_STOP);
+ LangExit();
+
if (disp)
{
/* We may get here from HandleXIOError */
-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs