Initial import of Scalos. To decrease size I have
[AROS-Contrib.git] / scalos / main / ScalosLocale.c
blob2e5107ba8a58efd76995ae19258c25beb713dbf3
1 // ScalosLocale.c
2 // $Date$
3 // $Revision$
6 #include <exec/types.h>
7 #include <exec/execbase.h>
8 #include <libraries/locale.h>
10 #define __USE_SYSBASE
12 #include <proto/dos.h>
13 #include <proto/exec.h>
14 #include <proto/intuition.h>
15 #include <proto/utility.h>
16 #include <proto/locale.h>
17 #include "debug.h"
18 #include <proto/scalos.h>
20 #include <clib/alib_protos.h>
22 #include <defs.h>
23 #include <Year.h> // +jmc+
25 #include <scalos/scalos.h>
27 #include <string.h>
28 #include <stdio.h>
29 #include <stdarg.h>
30 #include <limits.h>
32 #include "scalos_structures.h"
33 #include "locale.h"
34 #include "functions.h"
35 #include "Variables.h"
37 //----------------------------------------------------------------------------
39 void NewLocalePrefs(struct internalScaWindowTask *iwt, struct NotifyMessage *msg)
41 struct SM_NewPreferences *smnp;
43 d1(KPrintF("%s/%s/%ld: smnp_PrefsFlags=%08lx\n", __FILE__, __FUNC__, __LINE__, SMNPFLAGF_LOCALEPREFS));
45 smnp = (struct SM_NewPreferences *) SCA_AllocMessage(MTYP_NewPreferences, 0);
46 if (smnp)
48 smnp->smnp_PrefsFlags = SMNPFLAGF_LOCALEPREFS;
49 PutMsg(iInfos.xii_iinfos.ii_MainMsgPort, &smnp->ScalosMessage.sm_Message);
54 BOOL ChangedLocalePrefs(struct MainTask *mt)
56 ///
57 struct internalScaWindowTask *iwtMain = (struct internalScaWindowTask *) iInfos.xii_iinfos.ii_MainWindowStruct->ws_WindowTask;
58 BOOL Changed = FALSE;
60 CleanupLocale();
62 Delay(3 * 50); // Wait till locale.libary took notice of changed locale preferences
64 InitLocale();
66 // AppIcons will not get re-created like other icons,
67 // so we do a ReLayout here
68 DoMethod(iwtMain->iwt_WindowTask.mt_MainObject, SCCM_IconWin_Redraw, REDRAWF_ReLayoutIcons);
70 return Changed;
71 ///
75 void InitLocale(void)
77 ///
78 d1(kprintf("%s/%s/%ld: LocaleBase=%08lx\n", __FILE__, __FUNC__, __LINE__, LocaleBase));
80 if (NULL == LocaleBase)
81 return;
83 ScalosLocale = OpenLocale(NULL);
84 d1(kprintf("%s/%s/%ld: ScalosLocale=%08lx\n", __FILE__, __FUNC__, __LINE__, ScalosLocale));
85 if (NULL == ScalosLocale)
86 return;
88 d1(kprintf("%s/%s/%ld: LocaleName=<%s> Language=<%s>\n", \
89 __FILE__, __FUNC__, __LINE__, ScalosLocale->loc_LocaleName, ScalosLocale->loc_LanguageName));
91 if (ScalosLocale->loc_GroupSeparator)
92 CurrentPrefs.pref_GroupSeparator = *ScalosLocale->loc_GroupSeparator;
94 ScalosCatalog = OpenCatalogA(ScalosLocale, (STRPTR) "Scalos/Scalos.catalog", NULL);
96 d1(kprintf("%s/%s/%ld: ScalosCatalog=%08lx\n", __FILE__, __FUNC__, __LINE__, ScalosCatalog));
97 if (ScalosCatalog)
99 d1(kprintf("%s/%s/%ld: cat_Version=%ld\n", __FILE__, __FUNC__, __LINE__, ScalosCatalog->cat_Version));
101 if (ScalosCatalog->cat_Version < 40)
103 CloseCatalog(ScalosCatalog);
104 ScalosCatalog = NULL;
111 void CleanupLocale(void)
113 if (LocaleBase)
115 if (ScalosCatalog)
116 CloseCatalog(ScalosCatalog);
117 if (ScalosLocale)
118 CloseLocale(ScalosLocale);
120 ScalosCatalog = NULL;
121 ScalosLocale = NULL;