From 09d74e32220dde418141333ac5ff7cc0c9742924 Mon Sep 17 00:00:00 2001 From: NicJA Date: Sun, 14 Apr 2013 00:11:16 +0000 Subject: [PATCH] fix localeprefs language display after behaviour changes in the code for native name support. change internal references to country to 'region' to prevent legal/political issues (after discussion with a number of non-english users on IRC, and online discussions regarding cases such as china/taiwan) git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@47228 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/prefs/locale/catalogs/czech.ct | 3 +- workbench/prefs/locale/catalogs/dansk.ct | 2 +- workbench/prefs/locale/catalogs/deutsch.ct | 2 +- .../prefs/locale/catalogs/espa\303\261ol.ct" | 2 +- .../prefs/locale/catalogs/fran\303\247ais.ct" | 4 +- workbench/prefs/locale/catalogs/hrvatski.ct | 4 +- workbench/prefs/locale/catalogs/italiano.ct | 2 +- workbench/prefs/locale/catalogs/locale.cd | 4 +- workbench/prefs/locale/catalogs/polski.ct | 4 +- .../prefs/locale/catalogs/portugu\303\252s.ct" | 2 +- workbench/prefs/locale/catalogs/russian.ct | 2 +- workbench/prefs/locale/catalogs/suomi.ct | 2 +- workbench/prefs/locale/catalogs/svenska.ct | 2 +- workbench/prefs/locale/main.c | 9 +- workbench/prefs/locale/mmakefile.src | 2 +- workbench/prefs/locale/page_language.c | 59 +++++------ .../prefs/locale/{page_country.c => page_region.c} | 56 +++++------ .../prefs/locale/{page_country.h => page_region.h} | 12 +-- workbench/prefs/locale/prefs.c | 109 +++++++++++---------- workbench/prefs/locale/prefs.h | 7 +- workbench/prefs/locale/registertab.c | 52 +++++----- 21 files changed, 167 insertions(+), 174 deletions(-) rename workbench/prefs/locale/{page_country.c => page_region.c} (77%) rename workbench/prefs/locale/{page_country.h => page_region.h} (61%) diff --git a/workbench/prefs/locale/catalogs/czech.ct b/workbench/prefs/locale/catalogs/czech.ct index cfaa06e5ef..db13a7a003 100644 --- a/workbench/prefs/locale/catalogs/czech.ct +++ b/workbench/prefs/locale/catalogs/czech.ct @@ -115,7 +115,7 @@ MSG_GAD_TAB_LANGUAGE Jazyky ; Language ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION Zemì ; Country ; @@ -147,4 +147,3 @@ MSG_GMT_CLOCK Pou¾ít univerzální èas ; Hardware clock stores GMT ; - diff --git a/workbench/prefs/locale/catalogs/dansk.ct b/workbench/prefs/locale/catalogs/dansk.ct index 31e9418cd0..1f8d7bfab3 100644 --- a/workbench/prefs/locale/catalogs/dansk.ct +++ b/workbench/prefs/locale/catalogs/dansk.ct @@ -116,7 +116,7 @@ MSG_GAD_TAB_LANGUAGE Sprog ; Language ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION Land ; Country ; diff --git a/workbench/prefs/locale/catalogs/deutsch.ct b/workbench/prefs/locale/catalogs/deutsch.ct index 0532fa3ef5..3f15fd140f 100644 --- a/workbench/prefs/locale/catalogs/deutsch.ct +++ b/workbench/prefs/locale/catalogs/deutsch.ct @@ -115,7 +115,7 @@ MSG_GAD_TAB_LANGUAGE Sprache ; Language ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION Land ; Country ; diff --git "a/workbench/prefs/locale/catalogs/espa\303\261ol.ct" "b/workbench/prefs/locale/catalogs/espa\303\261ol.ct" index ac948fafd6..b51ba1bc3c 100644 --- "a/workbench/prefs/locale/catalogs/espa\303\261ol.ct" +++ "b/workbench/prefs/locale/catalogs/espa\303\261ol.ct" @@ -116,7 +116,7 @@ MSG_GAD_TAB_LANGUAGE Idioma ;Language ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION País ;Country ; diff --git "a/workbench/prefs/locale/catalogs/fran\303\247ais.ct" "b/workbench/prefs/locale/catalogs/fran\303\247ais.ct" index 3b00d5ed78..81626c308a 100644 --- "a/workbench/prefs/locale/catalogs/fran\303\247ais.ct" +++ "b/workbench/prefs/locale/catalogs/fran\303\247ais.ct" @@ -86,8 +86,8 @@ Annuler MSG_GAD_TAB_LANGUAGE Langue ; -MSG_GAD_TAB_COUNTRY -Pays +MSG_GAD_TAB_REGION +Région ; MSG_GAD_TAB_TIMEZONE Fuseau horaire diff --git a/workbench/prefs/locale/catalogs/hrvatski.ct b/workbench/prefs/locale/catalogs/hrvatski.ct index a05ba29691..41fe63e2a0 100644 --- a/workbench/prefs/locale/catalogs/hrvatski.ct +++ b/workbench/prefs/locale/catalogs/hrvatski.ct @@ -115,9 +115,9 @@ MSG_GAD_TAB_LANGUAGE Jezik ; Language ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION Zemlja -; Country +; Region ; MSG_GAD_TAB_TIMEZONE Vremenska Zona diff --git a/workbench/prefs/locale/catalogs/italiano.ct b/workbench/prefs/locale/catalogs/italiano.ct index 5396e876fc..424626c19e 100644 --- a/workbench/prefs/locale/catalogs/italiano.ct +++ b/workbench/prefs/locale/catalogs/italiano.ct @@ -86,7 +86,7 @@ Annulla MSG_GAD_TAB_LANGUAGE Lingua ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION Stato ; MSG_GAD_TAB_TIMEZONE diff --git a/workbench/prefs/locale/catalogs/locale.cd b/workbench/prefs/locale/catalogs/locale.cd index 0c4797b9a7..2d18c8c366 100644 --- a/workbench/prefs/locale/catalogs/locale.cd +++ b/workbench/prefs/locale/catalogs/locale.cd @@ -83,8 +83,8 @@ Cancel MSG_GAD_TAB_LANGUAGE (//) Language ; -MSG_GAD_TAB_COUNTRY (//) -Country +MSG_GAD_TAB_REGION (//) +Region ; MSG_GAD_TAB_TIMEZONE (//) Time Zone diff --git a/workbench/prefs/locale/catalogs/polski.ct b/workbench/prefs/locale/catalogs/polski.ct index 85c4502112..51725bee6e 100644 --- a/workbench/prefs/locale/catalogs/polski.ct +++ b/workbench/prefs/locale/catalogs/polski.ct @@ -114,9 +114,9 @@ MSG_GAD_TAB_LANGUAGE Jêzyk ; Language ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION Kraj -; Country +; Region ; MSG_GAD_TAB_TIMEZONE Strefa czasowa diff --git "a/workbench/prefs/locale/catalogs/portugu\303\252s.ct" "b/workbench/prefs/locale/catalogs/portugu\303\252s.ct" index ed546f2489..0134de473c 100644 --- "a/workbench/prefs/locale/catalogs/portugu\303\252s.ct" +++ "b/workbench/prefs/locale/catalogs/portugu\303\252s.ct" @@ -116,7 +116,7 @@ MSG_GAD_TAB_LANGUAGE Língua ;Language ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION País ;Country ; diff --git a/workbench/prefs/locale/catalogs/russian.ct b/workbench/prefs/locale/catalogs/russian.ct index 20c047359f..9b14687def 100644 --- a/workbench/prefs/locale/catalogs/russian.ct +++ b/workbench/prefs/locale/catalogs/russian.ct @@ -86,7 +86,7 @@ MSG_GAD_CANCEL MSG_GAD_TAB_LANGUAGE ßçûê ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION Ñòðàíà ; MSG_GAD_TAB_TIMEZONE diff --git a/workbench/prefs/locale/catalogs/suomi.ct b/workbench/prefs/locale/catalogs/suomi.ct index efcc16b0ae..0a96ae1cb2 100644 --- a/workbench/prefs/locale/catalogs/suomi.ct +++ b/workbench/prefs/locale/catalogs/suomi.ct @@ -115,7 +115,7 @@ MSG_GAD_TAB_LANGUAGE Kieli ; Language ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION Maa ; Country ; diff --git a/workbench/prefs/locale/catalogs/svenska.ct b/workbench/prefs/locale/catalogs/svenska.ct index 1d20e11f9f..da799677b6 100644 --- a/workbench/prefs/locale/catalogs/svenska.ct +++ b/workbench/prefs/locale/catalogs/svenska.ct @@ -115,7 +115,7 @@ MSG_GAD_TAB_LANGUAGE Språk ; Language ; -MSG_GAD_TAB_COUNTRY +MSG_GAD_TAB_REGION Land ; Country ; diff --git a/workbench/prefs/locale/main.c b/workbench/prefs/locale/main.c index 32f28da192..868a18ec21 100644 --- a/workbench/prefs/locale/main.c +++ b/workbench/prefs/locale/main.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. + Copyright © 1995-2013, The AROS Development Team. All rights reserved. $Id$ */ @@ -7,6 +7,8 @@ #define MUIMASTER_YES_INLINE_STDARG +#include + #include #include #include @@ -17,14 +19,11 @@ #include "locale.h" #include "registertab.h" #include "page_language.h" -#include "page_country.h" +#include "page_region.h" #include "page_timezone.h" #include "args.h" #include "prefs.h" -//#define DEBUG 1 -#include - #define VERSION "$VER: Locale 2.2 (24.05.2011) AROS Dev Team" /*********************************************************************************************/ diff --git a/workbench/prefs/locale/mmakefile.src b/workbench/prefs/locale/mmakefile.src index d6248105c7..0d6c87be92 100644 --- a/workbench/prefs/locale/mmakefile.src +++ b/workbench/prefs/locale/mmakefile.src @@ -5,7 +5,7 @@ include $(TOP)/config/make.cfg FILES := main args misc locale \ - page_language page_country page_timezone prefs registertab + page_language page_region page_timezone prefs registertab EXEDIR := $(AROSDIR)/Prefs diff --git a/workbench/prefs/locale/page_language.c b/workbench/prefs/locale/page_language.c index 71703712a8..e48dfe179b 100644 --- a/workbench/prefs/locale/page_language.c +++ b/workbench/prefs/locale/page_language.c @@ -3,11 +3,7 @@ $Id$ */ -// #define MUIMASTER_YES_INLINE_STDARG - -//#define DEBUG 1 -#include -#include +#include #include #include @@ -15,7 +11,8 @@ #include #include -#include +#include +#include #include "locale.h" #include "prefs.h" @@ -67,12 +64,12 @@ STATIC VOID update_language_lists(struct Language_DATA *data) { if(entry->preferred) { - data->strings_preferred[p] = entry->lve.name; + data->strings_preferred[p] = entry->lve.node.ln_Name; p++; } else { - data->strings_available[a] = entry->lve.name; + data->strings_available[a] = entry->lve.node.ln_Name; a++; } } @@ -89,27 +86,23 @@ STATIC VOID init_language_lists(struct Language_DATA *data) data->nr_languages = 0; ForeachNode(&language_list, entry) { - D(bug("entry->lve.name: %s\n",entry->lve.name)); + D(bug("[LocalePrefs-LanguageClass] language %s\n",entry->lve.node.ln_Name)); entry->preferred = FALSE; - i = 0; - D(bug("[language class] language %s\n",entry->lve.name)); - while (i < 10 && /* max 10 preferred langs, see prefs/locale.h */ - entry->preferred == FALSE && - localeprefs.lp_PreferredLanguages[i][0]) - { - if (Stricmp(localeprefs.lp_PreferredLanguages[i], entry->lve.name) == 0) + /* max 10 preferred langs, see prefs/locale.h */ + for (i = 0; i < 10 && entry->preferred == FALSE && localeprefs.lp_PreferredLanguages[i][0]; i++) + { + if (Stricmp(localeprefs.lp_PreferredLanguages[i], entry->lve.node.ln_Name) == 0) { - D(bug("[language class] %s is preferred\n", - entry->lve.name)); + D(bug("[LocalePrefs-LanguageClass] %s is preferred\n", + entry->lve.node.ln_Name)); entry->preferred = TRUE; } - i++; } data->nr_languages++; } - D(bug("[language class]: nr of languages: %d\n",data->nr_languages)); + D(bug("[LocalePrefs-LanguageClass]: nr of languages: %d\n",data->nr_languages)); data->strings_available = AllocVec(sizeof(char *) * (data->nr_languages+1), MEMF_CLEAR); data->strings_preferred = AllocVec(sizeof(char *) * (data->nr_languages+1), MEMF_CLEAR); @@ -136,15 +129,15 @@ STATIC VOID func_move_to_selected(char* selstr, struct Language_DATA *data) unsigned int i = 0; char *test; - D(bug("func_move_to_selected(%s,..)\n",selstr)); + D(bug("[LocalePrefs-LanguageClass] func_move_to_selected(%s,..)\n", selstr)); if(selstr) { ForeachNode(&language_list, entry) { - if (stricmp(selstr, entry->lve.name) == 0) + if (stricmp(selstr, entry->lve.node.ln_Name) == 0) { DoMethod(data->preferred, - MUIM_List_InsertSingle, entry->lve.name, + MUIM_List_InsertSingle, entry->lve.node.ln_Name, MUIV_List_Insert_Bottom); entry->preferred = TRUE; @@ -183,7 +176,7 @@ AROS_UFH2 struct Language_DATA *data= hook->h_Data; char *selstr; - D(bug("[register class] hook_func_available\n")); + D(bug("[LocalePrefs-LanguageClass] hook_func_available\n")); DoMethod(obj,MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &selstr); @@ -206,7 +199,7 @@ AROS_UFH2 char *selstr; struct LanguageEntry *entry; - D(bug("[register class] hook_func_preferred\n")); + D(bug("[LocalePrefs-LanguageClass] hook_func_preferred\n")); DoMethod(obj,MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &selstr); @@ -217,10 +210,10 @@ AROS_UFH2 ForeachNode(&language_list, entry) { - if (strcmp(selstr, entry->lve.name) == 0) + if (strcmp(selstr, entry->lve.node.ln_Name) == 0) { DoMethod(data->available, - MUIM_List_InsertSingle, entry->lve.name, + MUIM_List_InsertSingle, entry->lve.node.ln_Name, MUIV_List_Insert_Sorted); entry->preferred = FALSE; } @@ -235,7 +228,7 @@ STATIC VOID func_clear(struct Language_DATA *data) { struct LanguageEntry *entry; - D(bug("[register class] func_clear\n")); + D(bug("[LocalePrefs-LanguageClass] func_clear\n")); /* clear it */ DoMethod(data->preferred, MUIM_List_Clear); @@ -248,7 +241,7 @@ STATIC VOID func_clear(struct Language_DATA *data) { entry->preferred = FALSE; DoMethod(data->available, - MUIM_List_InsertSingle, entry->lve.name, + MUIM_List_InsertSingle, entry->lve.node.ln_Name, MUIV_List_Insert_Bottom); } } @@ -380,7 +373,7 @@ static Object *handle_New_error(Object *obj, struct IClass *cl, char *error) struct Language_DATA *data; ShowMessage(error); - D(bug("[Language class] %s\n")); + D(bug("[LocalePrefs-LanguageClass] %s\n")); if(!obj) return NULL; @@ -442,7 +435,7 @@ Object *Language__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) struct Language_DATA *data; struct TagItem *tstate, *tag; - D(bug("[language class] Language Class New\n")); + D(bug("[LocalePrefs-LanguageClass] Language Class New\n")); /* * we create self first and then create the child, @@ -615,7 +608,7 @@ static IPTR Language__OM_GET(struct IClass *cl, Object *obj, struct opGet *msg) break; case MUIA_Language_Characterset: GetAttr(MUIA_List_Active, data->cslist, (IPTR *)&i); - D(bug("[Language::Get] Active character set entry is %d\n", i)); + D(bug("[LocalePrefs-LanguageClass] Get: Active character set entry is %d\n", i)); if ((i == 0) || (i == MUIV_List_Active_Off)) *msg->opg_Storage = 0; else @@ -684,7 +677,7 @@ static IPTR Language__OM_DISPOSE(struct IClass *cl, Object *obj, Msg msg) { struct Language_DATA *data = INST_DATA(cl, obj); - D(bug("Language_Dispose\n")); + D(bug("[LocalePrefs-LanguageClass] OM_DISPOSE()\n")); free_strings(data); diff --git a/workbench/prefs/locale/page_country.c b/workbench/prefs/locale/page_region.c similarity index 77% rename from workbench/prefs/locale/page_country.c rename to workbench/prefs/locale/page_region.c index ea51570d44..25b731dfe6 100644 --- a/workbench/prefs/locale/page_country.c +++ b/workbench/prefs/locale/page_region.c @@ -3,8 +3,7 @@ $Id$ */ -#include -#include +#include #include #include @@ -14,19 +13,20 @@ #include #include -#include +#include +#include -#include +#include #include "prefs.h" -#include "page_country.h" +#include "page_region.h" #include "registertab.h" static struct Hook display_hook; /*** Instance Data **********************************************************/ -struct Country_DATA +struct Region_DATA { Object *me; Object *child; @@ -34,14 +34,14 @@ struct Country_DATA ULONG active; }; -struct MUI_CustomClass *Country_CLASS; +struct MUI_CustomClass *Region_CLASS; /*** Helpers *****************************************************************/ /************************************************* * The display function for the KeyTypes listview *************************************************/ -STATIC VOID country_display_func(struct Hook *h, char **array, struct ListviewEntry *entry) +STATIC VOID region_display_func(struct Hook *h, char **array, struct ListviewEntry *entry) { *array++ = entry->displayflag; *array = entry->node.ln_Name; @@ -51,19 +51,19 @@ STATIC VOID country_display_func(struct Hook *h, char **array, struct ListviewEn * */ -Object *Country__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) +Object *Region__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) { - struct Country_DATA *data; + struct Region_DATA *data; struct TagItem *tstate, *tag; - struct CountryEntry *entry; + struct RegionEntry *entry; - D(bug("[country class] Country Class New\n")); + D(bug("[LocalePrefs-RegionClass] Region Class New\n")); display_hook.h_Entry = HookEntry; - display_hook.h_SubEntry = (HOOKFUNC)country_display_func; + display_hook.h_SubEntry = (HOOKFUNC)region_display_func; /* - * country flags are at the moment 17 pixels high + * region flags are at the moment 17 pixels high * MUIA_List_MinLineHeight, 19 leaves at least two * pixel space between the images * If images ever get bigger, this should be @@ -83,7 +83,7 @@ Object *Country__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) if (obj == NULL) { - D(bug("ERROR: [country class] DoSuperNewTags failed!\n")); + D(bug("[LocalePrefs-RegionClass] ERROR: DoSuperNewTags failed!\n")); return NULL; } @@ -102,7 +102,7 @@ Object *Country__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) data->child = obj; - ForeachNode(&country_list, entry) + ForeachNode(®ion_list, entry) { DoMethod ( @@ -123,10 +123,10 @@ Object *Country__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) } /*** Get ******************************************************************/ -static IPTR Country__OM_GET(struct IClass *cl, Object *obj, struct opGet *msg) +static IPTR Region__OM_GET(struct IClass *cl, Object *obj, struct opGet *msg) { - struct Country_DATA *data = INST_DATA(cl, obj); - struct CountryEntry *entry; + struct Region_DATA *data = INST_DATA(cl, obj); + struct RegionEntry *entry; IPTR rc; IPTR nr = 0; ULONG i; @@ -134,11 +134,11 @@ static IPTR Country__OM_GET(struct IClass *cl, Object *obj, struct opGet *msg) switch (msg->opg_AttrID) { - case MUIA_Country_Countryname: + case MUIA_Region_Regionname: GET(data->child, MUIA_List_Active, &nr); rc = -1; i = 0; - ForeachNode(&country_list, entry) + ForeachNode(®ion_list, entry) { if (i == nr) { @@ -163,11 +163,11 @@ static IPTR Country__OM_GET(struct IClass *cl, Object *obj, struct opGet *msg) } /*** Set ******************************************************************/ -static IPTR Country__OM_SET(struct IClass *cl, Object *obj, struct opSet *msg) +static IPTR Region__OM_SET(struct IClass *cl, Object *obj, struct opSet *msg) { - struct Country_DATA *data = INST_DATA(cl, obj); + struct Region_DATA *data = INST_DATA(cl, obj); struct TagItem *tstate, *tag; - struct CountryEntry *entry; + struct RegionEntry *entry; ULONG update; ULONG nr; ULONG i; @@ -179,11 +179,11 @@ static IPTR Country__OM_SET(struct IClass *cl, Object *obj, struct opSet *msg) { switch (tag->ti_Tag) { - case MUIA_Country_Countryname: + case MUIA_Region_Regionname: nr = -1; i = 0; - ForeachNode(&country_list, entry) + ForeachNode(®ion_list, entry) { if (!stricmp(entry->lve.realname, (STRPTR)tag->ti_Data)) { @@ -194,7 +194,7 @@ static IPTR Country__OM_SET(struct IClass *cl, Object *obj, struct opSet *msg) if (nr < 0) { - D(bug("ERROR: [country class] could not find >%s< !?\n",tag->ti_Data)); + D(bug("[LocalePrefs-RegionClass] ERROR: could not find >%s< !?\n",tag->ti_Data)); } else { @@ -219,7 +219,7 @@ static IPTR Country__OM_SET(struct IClass *cl, Object *obj, struct opSet *msg) /*** Setup ******************************************************************/ ZUNE_CUSTOMCLASS_3 ( - Country, NULL, MUIC_List, NULL, + Region, NULL, MUIC_List, NULL, OM_NEW, struct opSet *, OM_SET, struct opSet *, OM_GET, struct opGet * diff --git a/workbench/prefs/locale/page_country.h b/workbench/prefs/locale/page_region.h similarity index 61% rename from workbench/prefs/locale/page_country.h rename to workbench/prefs/locale/page_region.h index 8300167aad..f5e94618b2 100644 --- a/workbench/prefs/locale/page_country.h +++ b/workbench/prefs/locale/page_region.h @@ -2,7 +2,7 @@ #define _LCOUNTRY_H_ /* - Copyright © 2008-2010, The AROS Development Team. All rights reserved. + Copyright © 2008-2013, The AROS Development Team. All rights reserved. $Id$ */ @@ -10,18 +10,18 @@ #include /*** Identifier base ********************************************************/ -#define MUIB_Country (TAG_USER | 0x40000000) +#define MUIB_Region (TAG_USER | 0x40000000) /*** Attributes *************************************************************/ -#define MUIA_Country_Countryname (MUIB_Country | 0) +#define MUIA_Region_Regionname (MUIB_Region | 0) /*** Methods ****************************************************************/ -#define MUIM_Country_Fill (MUIB_Country | 0) +#define MUIM_Region_Fill (MUIB_Region | 0) /*** Variables **************************************************************/ -extern struct MUI_CustomClass *Country_CLASS; +extern struct MUI_CustomClass *Region_CLASS; /*** Macros *****************************************************************/ -#define CountryObject BOOPSIOBJMACRO_START(Country_CLASS->mcc_Class) +#define RegionObject BOOPSIOBJMACRO_START(Region_CLASS->mcc_Class) #endif /* _LCOUNTRY_H_ */ diff --git a/workbench/prefs/locale/prefs.c b/workbench/prefs/locale/prefs.c index b3c8d8a9c3..c62cf8de1e 100644 --- a/workbench/prefs/locale/prefs.c +++ b/workbench/prefs/locale/prefs.c @@ -5,16 +5,8 @@ /*********************************************************************************************/ -#include -#include -#include - -#include - #include -#include - #include #include #include @@ -22,6 +14,14 @@ #include #include +#include + +#include + +#include +#include +#include + #include "prefs.h" #include "misc.h" @@ -44,7 +44,7 @@ struct FilePrefHeader struct LocalePrefs localeprefs; char character_set[CHARACTER_SET_LEN]; char restore_charset[CHARACTER_SET_LEN]; -struct List country_list; +struct List region_list; struct List language_list; struct List pref_language_list; @@ -81,7 +81,7 @@ STATIC VOID SortInNode(struct List *list, struct Node *node) /*********************************************************************************************/ -char *GetAROSCountryAttribs(struct AnchorPath *ap, char **countryNamePtr) +char *GetAROSRegionAttribs(struct AnchorPath *ap, char **regionNamePtr) { char *lockFlag = NULL; struct IFFHandle *iff; @@ -105,14 +105,14 @@ char *GetAROSCountryAttribs(struct AnchorPath *ap, char **countryNamePtr) parse_mode = IFFPARSE_STEP; cn = CurrentChunk(iff); - D(bug("[LocalePrefs] GetAROSCountryAttribs: Chunk ID %08x. %d bytes\n", cn->cn_ID, cn->cn_Size)); + D(bug("[LocalePrefs] GetAROSRegionAttribs: Chunk ID %08x. %d bytes\n", cn->cn_ID, cn->cn_Size)); if (cn->cn_ID == MAKE_ID('N','N','A','M')) { - FreeVecPooled(mempool, *countryNamePtr); - *countryNamePtr = AllocVecPooled(mempool, cn->cn_Size); - ReadChunkBytes(iff, *countryNamePtr, cn->cn_Size); - D(bug("[LocalePrefs] GetAROSCountryAttribs: NativeNames '%s'\n", *countryNamePtr)); + FreeVecPooled(mempool, *regionNamePtr); + *regionNamePtr = AllocVecPooled(mempool, cn->cn_Size); + ReadChunkBytes(iff, *regionNamePtr, cn->cn_Size); + D(bug("[LocalePrefs] GetAROSRegionAttribs: NativeNames '%s'\n", *regionNamePtr)); } if (cn->cn_ID == MAKE_ID('F','L','A','G')) @@ -121,7 +121,7 @@ char *GetAROSCountryAttribs(struct AnchorPath *ap, char **countryNamePtr) sprintf(lockFlag, flagpathstr); ReadChunkBytes(iff, lockFlag + 18, cn->cn_Size); lockFlag[cn->cn_Size + 17] = ']'; - D(bug("[LocalePrefs] GetAROSCountryAttribs: Flag '%s'\n", lockFlag)); + D(bug("[LocalePrefs] GetAROSRegionAttribs: Flag '%s'\n", lockFlag)); } } } while ((error != IFFERR_EOF) && (error != IFFERR_NOTIFF)); @@ -142,14 +142,14 @@ STATIC VOID ScanDirectory(char *pattern, struct List *list, LONG entrysize) { struct AnchorPath ap; struct ListviewEntry *entry; - BPTR curdir; + BPTR curdir = BNULL; char *sp; LONG error; memset(&ap, 0, sizeof(ap)); - error = MatchFirst(pattern, &ap); - curdir = CurrentDir(ap.ap_Current->an_Lock); + if ((error = MatchFirst(pattern, &ap)) == 0) + curdir = CurrentDir(ap.ap_Current->an_Lock); while((error == 0)) { @@ -167,12 +167,18 @@ STATIC VOID ScanDirectory(char *pattern, struct List *list, LONG entrysize) strcpy(entry->realname, entry->node.ln_Name); - D(bug("[LocalePrefs] ScanDir: Checking for FLAG chunk\n")); - - if (!(entry->displayflag = GetAROSCountryAttribs(&ap, &entry->node.ln_Name))) + if (entrysize == sizeof(struct RegionEntry)) + { + D(bug("[LocalePrefs] ScanDir: Checking for FLAG chunk\n")); + if (!(entry->displayflag = GetAROSRegionAttribs(&ap, &entry->node.ln_Name))) + { + entry->displayflag = AllocVec(strlen(entry->realname) + strlen(flagpathstr) + 12, MEMF_CLEAR); + sprintf(entry->displayflag, "%sCountries/%s]", flagpathstr, entry->realname); + } + } + else if (entrysize == sizeof(struct LanguageEntry)) { - entry->displayflag = AllocVec(strlen(entry->realname) + strlen(flagpathstr) + 12, MEMF_CLEAR); - sprintf(entry->displayflag, "%sCountries/%s]", flagpathstr, entry->realname); + // TODO: handle translating english language name -> native name. } sp = entry->node.ln_Name; @@ -194,20 +200,21 @@ STATIC VOID ScanDirectory(char *pattern, struct List *list, LONG entrysize) } error = MatchNext(&ap); } - CurrentDir(curdir); + if (curdir != BNULL) + CurrentDir(curdir); MatchEnd(&ap); } /*********************************************************************************************/ #if !AROS_BIG_ENDIAN -STATIC VOID FixCountryEndianess(struct CountryPrefs *country) +STATIC VOID FixCountryEndianess(struct CountryPrefs *region) { - country->cp_Reserved[0] = AROS_BE2LONG(country->cp_Reserved[0]); - country->cp_Reserved[1] = AROS_BE2LONG(country->cp_Reserved[1]); - country->cp_Reserved[2] = AROS_BE2LONG(country->cp_Reserved[2]); - country->cp_Reserved[3] = AROS_BE2LONG(country->cp_Reserved[3]); - country->cp_CountryCode = AROS_BE2LONG(country->cp_CountryCode); + region->cp_Reserved[0] = AROS_BE2LONG(region->cp_Reserved[0]); + region->cp_Reserved[1] = AROS_BE2LONG(region->cp_Reserved[1]); + region->cp_Reserved[2] = AROS_BE2LONG(region->cp_Reserved[2]); + region->cp_Reserved[3] = AROS_BE2LONG(region->cp_Reserved[3]); + region->cp_CountryCode = AROS_BE2LONG(region->cp_CountryCode); } #endif @@ -227,9 +234,9 @@ STATIC VOID FixLocaleEndianess(struct LocalePrefs *localeprefs) /*********************************************************************************************/ -BOOL Prefs_LoadCountry(STRPTR name, struct CountryPrefs *country) +BOOL Prefs_LoadRegion(STRPTR name, struct CountryPrefs *region) { - static struct CountryPrefs loadcountry; + static struct CountryPrefs loadregion; struct IFFHandle *iff; struct ContextNode *cn; LONG parse_mode = IFFPARSE_SCAN, error; @@ -240,23 +247,23 @@ BOOL Prefs_LoadCountry(STRPTR name, struct CountryPrefs *country) AddPart(fullname, name, 100); strcat(fullname, ".country"); - D(bug("[LocalePrefs] LoadCountry: Trying to open \"%s\"\n", fullname)); + D(bug("[LocalePrefs] LoadRegion: Trying to open \"%s\"\n", fullname)); if ((iff = AllocIFF())) { if ((iff->iff_Stream = (IPTR)Open(fullname, MODE_OLDFILE))) { - D(bug("[LocalePrefs] LoadCountry: stream opened.\n")); + D(bug("[LocalePrefs] LoadRegion: stream opened.\n")); InitIFFasDOS(iff); if (!OpenIFF(iff, IFFF_READ)) { - D(bug("[LocalePrefs] LoadCountry: OpenIFF okay.\n")); + D(bug("[LocalePrefs] LoadRegion: OpenIFF okay.\n")); if (!StopChunk(iff, ID_PREF, ID_PRHD)) { - D(bug("[LocalePrefs] LoadCountry: StopChunk okay.\n")); + D(bug("[LocalePrefs] LoadRegion: StopChunk okay.\n")); do { @@ -264,27 +271,27 @@ BOOL Prefs_LoadCountry(STRPTR name, struct CountryPrefs *country) { parse_mode = IFFPARSE_STEP; - D(bug("[LocalePrefs] LoadCountry: ParseIFF okay.\n")); + D(bug("[LocalePrefs] LoadRegion: ParseIFF okay.\n")); cn = CurrentChunk(iff); - D(bug("[LocalePrefs] LoadCountry: Chunk ID %08x.\n", cn->cn_ID)); + D(bug("[LocalePrefs] LoadRegion: Chunk ID %08x.\n", cn->cn_ID)); if ((cn->cn_ID == ID_CTRY) && (cn->cn_Size == sizeof(struct CountryPrefs))) { - D(bug("[LocalePrefs] LoadCountry: Chunk ID_CTRY (size okay).\n")); + D(bug("[LocalePrefs] LoadRegion: Chunk ID_CTRY (size okay).\n")); - if (ReadChunkBytes(iff, &loadcountry, sizeof(struct CountryPrefs)) == sizeof(struct CountryPrefs)) + if (ReadChunkBytes(iff, &loadregion, sizeof(struct CountryPrefs)) == sizeof(struct CountryPrefs)) { - D(bug("[LocalePrefs] LoadCountry: Reading chunk successful.\n")); + D(bug("[LocalePrefs] LoadRegion: Reading chunk successful.\n")); - *country = loadcountry; + *region = loadregion; #if !AROS_BIG_ENDIAN - FixCountryEndianess(country); + FixCountryEndianess(region); #endif - D(bug("[LocalePrefs] LoadCountry: Everything okay :-)\n")); + D(bug("[LocalePrefs] LoadRegion: Everything okay :-)\n")); retval = TRUE; error = IFFERR_EOF; @@ -539,7 +546,7 @@ BOOL Prefs_HandleArgs(STRPTR from, BOOL use, BOOL save) if (use || save) { - Prefs_LoadCountry(localeprefs.lp_CountryName, &localeprefs.lp_CountryData); + Prefs_LoadRegion(localeprefs.lp_CountryName, &localeprefs.lp_CountryData); fh = Open(PREFS_PATH_ENV, MODE_NEWFILE); if (fh) { @@ -583,20 +590,20 @@ BOOL Prefs_Initialize(VOID) return FALSE; } - NewList(&country_list); + NewList(®ion_list); NewList(&language_list); NewList(&pref_language_list); - ScanDirectory("LOCALE:Countries/~(#?.info)", &country_list, sizeof(struct CountryEntry)); + ScanDirectory("LOCALE:Countries/~(#?.info)", ®ion_list, sizeof(struct RegionEntry)); ScanDirectory("LOCALE:Languages/#?.language", &language_list, sizeof(struct LanguageEntry)); /* English language is always available */ if ((entry = AllocPooled(mempool, sizeof(struct LanguageEntry)))) { - strcpy( entry->lve.name, "English"); + entry->lve.node.ln_Name = AllocVecPooled(mempool, 8); + strcpy( entry->lve.node.ln_Name, "English"); strcpy( entry->lve.realname, "English"); - entry->lve.node.ln_Name = entry->lve.name; SortInNode(&language_list, &entry->lve.node); } @@ -641,7 +648,7 @@ BOOL Prefs_Default(VOID) localeprefs.lp_GMTOffset = 5 * 60; localeprefs.lp_Flags = 0; - if (Prefs_LoadCountry((STRPTR) "united_states", &localeprefs.lp_CountryData)) + if (Prefs_LoadRegion((STRPTR) "united_states", &localeprefs.lp_CountryData)) { retval = TRUE; } diff --git a/workbench/prefs/locale/prefs.h b/workbench/prefs/locale/prefs.h index 9ebbbf860f..8b6c1108e3 100644 --- a/workbench/prefs/locale/prefs.h +++ b/workbench/prefs/locale/prefs.h @@ -22,7 +22,7 @@ BOOL Prefs_ImportFH(BPTR fh); BOOL Prefs_ExportFH(BPTR fh); BOOL Prefs_SaveCharset(BOOL envarc); BOOL Prefs_Default(VOID); -BOOL Prefs_LoadCountry(STRPTR name, struct CountryPrefs *country); +BOOL Prefs_LoadRegion(STRPTR name, struct CountryPrefs *country); /*********************************************************************************************/ @@ -33,12 +33,11 @@ extern struct LocalePrefs localeprefs; struct ListviewEntry { struct Node node; - char name[30]; char realname[30]; char *displayflag; }; -struct CountryEntry +struct RegionEntry { struct ListviewEntry lve; struct BitMap *flagbm; @@ -57,7 +56,7 @@ struct LanguageEntry #define CHARACTER_SET_LEN 255 -extern struct List country_list, language_list, pref_language_list; +extern struct List region_list, language_list, pref_language_list; extern struct LocalePrefs localeprefs; extern char character_set[CHARACTER_SET_LEN]; diff --git a/workbench/prefs/locale/registertab.c b/workbench/prefs/locale/registertab.c index 017e3b6cca..4fa9680c89 100644 --- a/workbench/prefs/locale/registertab.c +++ b/workbench/prefs/locale/registertab.c @@ -1,32 +1,28 @@ /* - Copyright © 2003-2011, The AROS Development Team. All rights reserved. + Copyright © 2003-2013, The AROS Development Team. All rights reserved. $Id$ */ -// #define MUIMASTER_YES_INLINE_STDARG +#include -////#define DEBUG 1 +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include - #include -#include - #include "locale.h" #include "registertab.h" #include "misc.h" #include "prefs.h" #include "page_language.h" -#include "page_country.h" +#include "page_region.h" #include "page_timezone.h" /*** Instance Data **********************************************************/ @@ -37,7 +33,7 @@ struct LocaleRegister_DATA Object *child; Object *language; - Object *country; + Object *region; Object *timezone; const char *LocaleRegisterLabels[3]; @@ -74,11 +70,11 @@ static Object *handle_New_error(Object *obj, struct IClass *cl, char *error) data->language = NULL; } - if(data->country) + if(data->region) { - D(bug("[Register class] DisposeObject(data->country);\n")); - DisposeObject(data->country); - data->country = NULL; + D(bug("[Register class] DisposeObject(data->region);\n")); + DisposeObject(data->region); + data->region = NULL; } if(data->timezone) @@ -129,14 +125,14 @@ Object *LocaleRegister__OM_NEW(Class *CLASS, Object *self, struct opSet *message if(!data->language) return handle_New_error(self, CLASS, "ERROR: Unable to create language object!\n"); - data->country = ListviewObject, MUIA_Listview_List, - NewObject(Country_CLASS->mcc_Class, 0, + data->region = ListviewObject, MUIA_Listview_List, + NewObject(Region_CLASS->mcc_Class, 0, MUIA_UserData, self, TAG_DONE), End; - if(!data->country) - return handle_New_error(self, CLASS, "ERROR: Unable to create country object!\n"); + if(!data->region) + return handle_New_error(self, CLASS, "ERROR: Unable to create region object!\n"); data->timezone = NewObject(Timezone_CLASS->mcc_Class, NULL, MUIA_UserData, self, @@ -154,14 +150,14 @@ Object *LocaleRegister__OM_NEW(Class *CLASS, Object *self, struct opSet *message * but for me it's easier this way ;) */ data->tab_label = AllocVec( strlen(_(MSG_GAD_TAB_LANGUAGE)) + - strlen(_(MSG_GAD_TAB_COUNTRY)) + + strlen(_(MSG_GAD_TAB_REGION)) + strlen(" / ") + 1, MEMF_ANY); if(!data->tab_label) return handle_New_error(self, CLASS, "ERROR: Unable to allocate tab_label!\n"); - sprintf(data->tab_label, "%s / %s", _(MSG_GAD_TAB_COUNTRY), + sprintf(data->tab_label, "%s / %s", _(MSG_GAD_TAB_REGION), _(MSG_GAD_TAB_LANGUAGE)); data->LocaleRegisterLabels[0] = data->tab_label; @@ -174,8 +170,8 @@ Object *LocaleRegister__OM_NEW(Class *CLASS, Object *self, struct opSet *message MUIA_Group_SameSize, TRUE, Child, HGroup, MUIA_Frame, MUIV_Frame_Group, - MUIA_FrameTitle, _(MSG_GAD_TAB_COUNTRY), - Child, data->country, + MUIA_FrameTitle, _(MSG_GAD_TAB_REGION), + Child, data->region, End, Child, HGroup, MUIA_Frame, MUIV_Frame_Group, @@ -191,7 +187,7 @@ Object *LocaleRegister__OM_NEW(Class *CLASS, Object *self, struct opSet *message DoMethod(self, OM_ADDMEMBER, data->child); - DoMethod(data->country, MUIM_Country_Fill); + DoMethod(data->region, MUIM_Region_Fill); LocalePrefs2Gadgets(data); @@ -223,10 +219,10 @@ STATIC VOID Gadgets2LocalePrefs (struct LocaleRegister_DATA *data) ULONG newflags; BOOL sync_clock = FALSE; - if (GetAttr(MUIA_Country_Countryname, data->country, (IPTR *)&tmp)) + if (GetAttr(MUIA_Region_Regionname, data->region, (IPTR *)&tmp)) { strncpy(localeprefs.lp_CountryName, tmp, 32); - Prefs_LoadCountry(localeprefs.lp_CountryName, &localeprefs.lp_CountryData); + Prefs_LoadRegion(localeprefs.lp_CountryName, &localeprefs.lp_CountryData); } if(GET(data->language, MUIA_Language_Preferred, &preferred)) @@ -320,7 +316,7 @@ STATIC VOID Gadgets2LocalePrefs (struct LocaleRegister_DATA *data) STATIC VOID LocalePrefs2Gadgets(struct LocaleRegister_DATA *data) { - SET(data->country, MUIA_Country_Countryname, localeprefs.lp_CountryName); + SET(data->region, MUIA_Region_Regionname, localeprefs.lp_CountryName); SET(data->language, MUIA_Language_Preferred, TRUE); SET(data->language, MUIA_Language_Characterset, character_set); -- 2.11.4.GIT