mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-23 14:59:47 +03:00
[project @ 2004-02-27 14:09:15 by bursa]
Implement option_language. svn path=/import/netsurf/; revision=574
This commit is contained in:
parent
c8589034e9
commit
37cf580743
@ -18,6 +18,4 @@ const char * const COOKIE_URL = "file:///%3CWimp$ScrapDir%3E/WWW/NetSurf/Cookies
|
||||
#endif
|
||||
|
||||
const char * const GESTURES_URL = "file:///%3CNetSurf$Dir%3E/Resources/gestures";
|
||||
const char * const HOME_URL = "file:///%3CNetSurf$Dir%3E/Docs/en/intro";
|
||||
const char * const HELP_URL = "file:///%3CNetSurf$Dir%3E/Docs/en/index";
|
||||
const char * const THEMES_URL = "http://netsurf.sourceforge.net/themes/";
|
||||
|
@ -19,8 +19,6 @@ extern const char * const COOKIE_URL;
|
||||
#endif
|
||||
#endif
|
||||
extern const char * const GESTURES_URL;
|
||||
extern const char * const HOME_URL;
|
||||
extern const char * const HELP_URL;
|
||||
extern const char * const THEMES_URL;
|
||||
|
||||
#endif
|
||||
|
@ -233,8 +233,6 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
|
||||
|
||||
void ro_gui_dialog_click_config_br(wimp_pointer *pointer)
|
||||
{
|
||||
struct browser_window* bw;
|
||||
|
||||
switch (pointer->i) {
|
||||
case ICON_CONFIG_BR_OK:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT)
|
||||
@ -320,8 +318,6 @@ void ro_gui_dialog_click_config_prox(wimp_pointer *pointer)
|
||||
|
||||
void ro_gui_dialog_click_config_th(wimp_pointer *pointer)
|
||||
{
|
||||
struct browser_window* bw;
|
||||
|
||||
switch (pointer->i) {
|
||||
case ICON_CONFIG_TH_OK:
|
||||
if (pointer->buttons == wimp_CLICK_SELECT)
|
||||
|
84
riscos/gui.c
84
riscos/gui.c
@ -17,6 +17,7 @@
|
||||
#include "oslib/hourglass.h"
|
||||
#include "oslib/inetsuite.h"
|
||||
#include "oslib/os.h"
|
||||
#include "oslib/osbyte.h"
|
||||
#include "oslib/osfile.h"
|
||||
#include "oslib/plugin.h"
|
||||
#include "oslib/wimp.h"
|
||||
@ -103,6 +104,7 @@ struct ro_gui_poll_block {
|
||||
struct ro_gui_poll_block *ro_gui_poll_queued_blocks = 0;
|
||||
|
||||
|
||||
static void ro_gui_choose_language(void);
|
||||
static void ro_gui_icon_bar_create(void);
|
||||
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
|
||||
static void ro_gui_poll_queue(wimp_event_no event, wimp_block* block);
|
||||
@ -128,13 +130,19 @@ static char *ro_path_to_url(const char *path);
|
||||
|
||||
void gui_init(int argc, char** argv)
|
||||
{
|
||||
char path[40];
|
||||
char theme_fname[256];
|
||||
os_error *e;
|
||||
os_error *error;
|
||||
|
||||
xhourglass_start(1);
|
||||
|
||||
options_read("Choices:WWW.NetSurf.Choices");
|
||||
|
||||
ro_gui_choose_language();
|
||||
|
||||
NETSURF_DIR = getenv("NetSurf$Dir");
|
||||
messages_load("<NetSurf$Dir>.Resources.en.Messages");
|
||||
sprintf(path, "<NetSurf$Dir>.Resources.%s.Messages", option_language);
|
||||
messages_load(path);
|
||||
|
||||
task_handle = wimp_initialise(wimp_VERSION_RO38, "NetSurf",
|
||||
(wimp_message_list*) &task_messages, 0);
|
||||
@ -143,8 +151,6 @@ void gui_init(int argc, char** argv)
|
||||
if (getenv("NetSurf$Start_URI_Handler"))
|
||||
xwimp_start_task("Desktop", 0);
|
||||
|
||||
options_read("Choices:WWW.NetSurf.Choices");
|
||||
|
||||
if (option_theme) {
|
||||
snprintf(theme_fname, sizeof(theme_fname),
|
||||
"<NetSurf$Dir>.Themes.%s", option_theme);
|
||||
@ -159,9 +165,13 @@ void gui_init(int argc, char** argv)
|
||||
}
|
||||
ro_theme_load(theme_fname);
|
||||
|
||||
e = xwimp_open_template("<NetSurf$Dir>.Resources.en.Templates");
|
||||
if(e) {
|
||||
die(e->errmess);
|
||||
sprintf(path, "<NetSurf$Dir>.Resources.%s.Templates", option_language);
|
||||
error = xwimp_open_template(path);
|
||||
if (error) {
|
||||
LOG(("xwimp_open_template failed: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
warn_user(error->errmess);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ro_gui_dialog_init();
|
||||
ro_gui_download_init();
|
||||
@ -175,6 +185,56 @@ void gui_init(int argc, char** argv)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the language to use.
|
||||
*
|
||||
* RISC OS has no standard way of determining which language the user prefers.
|
||||
* We have to guess from the 'Country' setting.
|
||||
*/
|
||||
|
||||
void ro_gui_choose_language(void)
|
||||
{
|
||||
char path[40];
|
||||
const char *lang;
|
||||
int country;
|
||||
os_error *error;
|
||||
|
||||
/* if option_language exists and is valid, use that */
|
||||
if (option_language) {
|
||||
if (2 < strlen(option_language))
|
||||
option_language[2] = 0;
|
||||
sprintf(path, "<NetSurf$Dir>.Resources.%s", option_language);
|
||||
if (is_dir(path))
|
||||
return;
|
||||
free(option_language);
|
||||
option_language = 0;
|
||||
}
|
||||
|
||||
/* choose a language from the configured country number */
|
||||
error = xosbyte_read(osbyte_VAR_COUNTRY_NUMBER, &country);
|
||||
if (error) {
|
||||
LOG(("xosbyte_read failed: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
country = 1;
|
||||
}
|
||||
switch (country) {
|
||||
case 6: /* France */
|
||||
case 18: /* Canada2 (French Canada?) */
|
||||
lang = "fr";
|
||||
break;
|
||||
default:
|
||||
lang = "en";
|
||||
break;
|
||||
}
|
||||
sprintf(path, "<NetSurf$Dir>.Resources.%s", lang);
|
||||
if (is_dir(path))
|
||||
option_language = strdup(lang);
|
||||
else
|
||||
option_language = strdup("en");
|
||||
assert(option_language);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an iconbar icon.
|
||||
*/
|
||||
@ -500,7 +560,10 @@ void ro_gui_icon_bar_click(wimp_pointer *pointer)
|
||||
ro_gui_create_menu(iconbar_menu, pointer->pos.x - 64,
|
||||
96 + iconbar_menu_height, NULL);
|
||||
} else if (pointer->buttons == wimp_CLICK_SELECT) {
|
||||
browser_window_create(HOME_URL);
|
||||
char url[80];
|
||||
sprintf(url, "file:///%%3CNetSurf$Dir%%3E/Docs/intro.%s",
|
||||
option_language);
|
||||
browser_window_create(url);
|
||||
}
|
||||
}
|
||||
|
||||
@ -865,7 +928,10 @@ void ro_gui_screen_size(int *width, int *height)
|
||||
|
||||
void ro_gui_open_help_page(void)
|
||||
{
|
||||
browser_window_create(HELP_URL);
|
||||
char url[80];
|
||||
sprintf(url, "file:///%%3CNetSurf$Dir%%3E/Docs/docs.%s",
|
||||
option_language);
|
||||
browser_window_create(url);
|
||||
}
|
||||
|
||||
|
||||
|
@ -252,8 +252,6 @@ void ro_gui_menu_selection(wimp_selection *selection)
|
||||
case 0: /* Open URL... */
|
||||
break;
|
||||
case 1: /* Home */
|
||||
browser_window_go(current_gui->data.browser.bw,
|
||||
HOME_URL);
|
||||
break;
|
||||
case 2: /* Back */
|
||||
history_back(current_gui->data.browser.bw,
|
||||
|
@ -19,17 +19,20 @@ extern bool option_use_mouse_gestures;
|
||||
extern bool option_allow_text_selection;
|
||||
extern bool option_show_toolbar;
|
||||
extern char *option_theme;
|
||||
extern char *option_language;
|
||||
|
||||
#define EXTRA_OPTION_DEFINE \
|
||||
bool option_use_mouse_gestures = false;\
|
||||
bool option_allow_text_selection = true;\
|
||||
bool option_show_toolbar = true;\
|
||||
char *option_theme = 0;
|
||||
char *option_theme = 0;\
|
||||
char *option_language = 0;
|
||||
|
||||
#define EXTRA_OPTION_TABLE \
|
||||
{ "use_mouse_gestures", OPTION_BOOL, &option_use_mouse_gestures },\
|
||||
{ "allow_text_selection", OPTION_BOOL, &option_allow_text_selection },\
|
||||
{ "show_toolbar", OPTION_BOOL, &option_show_toolbar },\
|
||||
{ "theme", OPTION_STRING, &option_theme }
|
||||
{ "theme", OPTION_STRING, &option_theme },\
|
||||
{ "language", OPTION_STRING, &option_language }
|
||||
|
||||
#endif
|
||||
|
@ -216,19 +216,12 @@ char *url_join(char *rel_url, char *base_url)
|
||||
return xstrdup(ABOUT_URL);
|
||||
}
|
||||
#ifdef WITH_COOKIES
|
||||
else if (strcasecmp(rel_url, "about:cookies") == 0) {
|
||||
if (strcasecmp(rel_url, "about:cookies") == 0) {
|
||||
cookie_create();
|
||||
return xstrdup(COOKIE_URL);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
#endif
|
||||
if (strcasecmp(rel_url, "help:") == 0) {
|
||||
return xstrdup(HELP_URL);
|
||||
}
|
||||
else if (strcasecmp(rel_url, "home:") == 0) {
|
||||
return xstrdup(HOME_URL);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!base_url) {
|
||||
|
Loading…
Reference in New Issue
Block a user