mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 20:16:54 +03:00
second pass at startup refactor removing the gui_init callback
svn path=/trunk/netsurf/; revision=10205
This commit is contained in:
parent
7e67527267
commit
e00fb7bd2d
14
amiga/gui.c
14
amiga/gui.c
@ -202,10 +202,9 @@ STRPTR ami_locale_langs(void)
|
||||
return acceptlangs;
|
||||
}
|
||||
|
||||
void ami_messages_load(void)
|
||||
void ami_messages_load(char *lang)
|
||||
{
|
||||
struct Locale *locale;
|
||||
char lang[100];
|
||||
int i;
|
||||
BPTR lock = 0;
|
||||
bool found=FALSE;
|
||||
@ -245,8 +244,6 @@ void ami_messages_load(void)
|
||||
}
|
||||
|
||||
CloseLocale(locale);
|
||||
|
||||
messages_load(lang);
|
||||
}
|
||||
|
||||
void ami_open_resources(void)
|
||||
@ -408,8 +405,6 @@ void gui_init(int argc, char** argv)
|
||||
ami_print_init();
|
||||
ami_clipboard_init();
|
||||
|
||||
options_read("PROGDIR:Resources/Options");
|
||||
ami_messages_load();
|
||||
ami_set_options(); /* check options and set defaults where required */
|
||||
|
||||
win_destroyed = false;
|
||||
@ -685,8 +680,13 @@ static void gui_init2(int argc, char** argv)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
setbuf(stderr, NULL);
|
||||
char messages[100];
|
||||
|
||||
netsurf_init(argc, argv);
|
||||
ami_messages_load(messages);
|
||||
|
||||
netsurf_init(argc, argv, "PROGDIR:Resources/Options", messages);
|
||||
|
||||
gui_init(argc, argv);
|
||||
|
||||
gui_init2(argc, argv);
|
||||
|
||||
|
@ -61,7 +61,6 @@ typedef enum { GUI_POINTER_DEFAULT, GUI_POINTER_POINT, GUI_POINTER_CARET,
|
||||
#include "desktop/search.h"
|
||||
|
||||
void gui_stdout(void);
|
||||
void gui_init(int argc, char** argv);
|
||||
void gui_multitask(void);
|
||||
void gui_poll(bool active);
|
||||
void gui_quit(void);
|
||||
|
@ -38,10 +38,12 @@
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/options.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/messages.h"
|
||||
|
||||
bool netsurf_quit = false;
|
||||
bool verbose_log = false;
|
||||
@ -55,7 +57,10 @@ static void *netsurf_lwc_alloc(void *ptr, size_t len, void *pw)
|
||||
* Initialise components used by gui NetSurf.
|
||||
*/
|
||||
|
||||
void netsurf_init(int argc, char** argv)
|
||||
nserror netsurf_init(int *pargc,
|
||||
char ***pargv,
|
||||
const char *options,
|
||||
const char *messages)
|
||||
{
|
||||
struct utsname utsname;
|
||||
|
||||
@ -75,13 +80,16 @@ void netsurf_init(int argc, char** argv)
|
||||
stdout = stderr;
|
||||
#endif
|
||||
|
||||
if ((argc > 1) && (argv[1][0] == '-') && (argv[1][1] == 'v') && (argv[1][2] == 0)) {
|
||||
if (((*pargc) > 1) &&
|
||||
((*pargv)[1][0] == '-') &&
|
||||
((*pargv)[1][1] == 'v') &&
|
||||
((*pargv)[1][2] == 0)) {
|
||||
int argcmv;
|
||||
verbose_log = true;
|
||||
for (argcmv = 2; argcmv < argc; argcmv++) {
|
||||
argv[argcmv - 1] = argv[argcmv];
|
||||
for (argcmv = 2; argcmv < (*pargc); argcmv++) {
|
||||
(*pargv)[argcmv - 1] = (*pargv)[argcmv];
|
||||
}
|
||||
argc--;
|
||||
(*pargc)--;
|
||||
|
||||
#ifndef HAVE_STDOUT
|
||||
gui_stdout();
|
||||
@ -100,13 +108,24 @@ void netsurf_init(int argc, char** argv)
|
||||
utsname.nodename, utsname.release,
|
||||
utsname.version, utsname.machine));
|
||||
|
||||
LOG(("Using '%s' for Options file", options));
|
||||
options_read(options);
|
||||
|
||||
LOG(("Using '%s' as Messages file", messages));
|
||||
messages_load(messages);
|
||||
|
||||
lwc_initialise(netsurf_lwc_alloc, NULL, 0);
|
||||
|
||||
url_init();
|
||||
gui_init(argc, argv);
|
||||
|
||||
setlocale(LC_ALL, "C");
|
||||
|
||||
fetch_init();
|
||||
|
||||
/** \todo The frontend needs to provide the llcache_query_handler */
|
||||
llcache_initialise(NULL, NULL);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define _NETSURF_DESKTOP_NETSURF_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "utils/errors.h"
|
||||
|
||||
extern bool netsurf_quit;
|
||||
extern bool verbose_log;
|
||||
@ -27,7 +28,7 @@ extern const char * const netsurf_version;
|
||||
extern const int netsurf_version_major;
|
||||
extern const int netsurf_version_minor;
|
||||
|
||||
extern void netsurf_init(int argc, char** argv);
|
||||
nserror netsurf_init(int *argc, char ***argv, const char *options, const char *messages);
|
||||
extern void netsurf_exit(void);
|
||||
extern int netsurf_main_loop(void);
|
||||
|
||||
|
@ -391,7 +391,7 @@ static bool process_cmdline(int argc, char** argv)
|
||||
}
|
||||
|
||||
|
||||
void gui_init(int argc, char** argv)
|
||||
static void gui_init(int argc, char** argv)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
nsfb_t *nsfb;
|
||||
@ -401,19 +401,8 @@ void gui_init(int argc, char** argv)
|
||||
if (hubbub_initialise(buf, myrealloc, NULL) != HUBBUB_OK)
|
||||
die("Unable to initialise HTML parsing library.\n");
|
||||
|
||||
/* load browser messages */
|
||||
fb_find_resource(buf, "messages", "./framebuffer/res/messages");
|
||||
LOG(("Using '%s' as Messages file", buf));
|
||||
messages_load(buf);
|
||||
|
||||
option_core_select_menu = true;
|
||||
|
||||
/* load browser options */
|
||||
fb_find_resource(buf, "Choices-fb", "~/.netsurf/Choices-fb");
|
||||
LOG(("Using '%s' as Preferences file", buf));
|
||||
options_file_location = strdup(buf);
|
||||
options_read(buf);
|
||||
|
||||
/* set up stylesheet urls */
|
||||
fb_find_resource(buf, "default.css", "./framebuffer/res/default.css");
|
||||
default_stylesheet_url = path_to_url(buf);
|
||||
@ -454,9 +443,18 @@ static void gui_init2(int argc, char** argv)
|
||||
*/
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
char options[PATH_MAX];
|
||||
char messages[PATH_MAX];
|
||||
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
netsurf_init(argc, argv);
|
||||
fb_find_resource(messages, "messages", "./framebuffer/res/messages");
|
||||
fb_find_resource(options, "Choices-fb", "~/.netsurf/Choices-fb");
|
||||
options_file_location = strdup(options);
|
||||
|
||||
netsurf_init(&argc, &argv, options, messages);
|
||||
|
||||
gui_init(argc, argv);
|
||||
|
||||
gui_init2(argc, argv);
|
||||
|
||||
|
@ -119,9 +119,11 @@ static void nsgtk_PDF_no_pass(GtkButton *w, gpointer data);
|
||||
/**
|
||||
* Initialize GTK interface.
|
||||
*/
|
||||
void gui_init(int argc, char** argv)
|
||||
static void gui_init(int argc, char** argv)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
struct browser_window *bw;
|
||||
const char *addr = NETSURF_HOMEPAGE;
|
||||
|
||||
nsgtk_check_homedir();
|
||||
|
||||
@ -147,11 +149,6 @@ void gui_init(int argc, char** argv)
|
||||
|
||||
option_core_select_menu = true;
|
||||
|
||||
nsgtk_find_resource(buf, "Choices", "~/.netsurf/Choices");
|
||||
LOG(("Using '%s' as Preferences file", buf));
|
||||
options_file_location = strdup(buf);
|
||||
options_read(buf);
|
||||
|
||||
/* check what the font settings are, setting them to a default font
|
||||
* if they're not set - stops Pango whinging
|
||||
*/
|
||||
@ -193,9 +190,6 @@ void gui_init(int argc, char** argv)
|
||||
option_downloads_directory = home;
|
||||
}
|
||||
|
||||
nsgtk_find_resource(buf, "messages", "./gtk/res/messages");
|
||||
LOG(("Using '%s' as Messages file", buf));
|
||||
messages_load(buf);
|
||||
|
||||
nsgtk_find_resource(buf, "mime.types", "/etc/mime.types");
|
||||
gtk_fetch_filetype_init(buf);
|
||||
@ -233,6 +227,18 @@ void gui_init(int argc, char** argv)
|
||||
|
||||
nsgtk_history_init();
|
||||
nsgtk_download_init();
|
||||
|
||||
|
||||
if (option_homepage_url != NULL && option_homepage_url[0] != '\0')
|
||||
addr = option_homepage_url;
|
||||
|
||||
if (2 <= argc)
|
||||
addr = argv[1];
|
||||
|
||||
/* Last step of initialization. Opens the main browser window. */
|
||||
|
||||
bw = browser_window_create(addr, 0, 0, true, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -297,39 +303,27 @@ void nsgtk_init_glade(void)
|
||||
wndWarning = GTK_WINDOW(glade_xml_get_widget(gladeWarning, "wndWarning"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Last step of initialization.
|
||||
*
|
||||
* Opens the main browser window.
|
||||
*/
|
||||
static void gui_init2(int argc, char** argv)
|
||||
{
|
||||
struct browser_window *bw;
|
||||
const char *addr = NETSURF_HOMEPAGE;
|
||||
|
||||
if (option_homepage_url != NULL && option_homepage_url[0] != '\0')
|
||||
addr = option_homepage_url;
|
||||
|
||||
if (2 <= argc)
|
||||
addr = argv[1];
|
||||
|
||||
bw = browser_window_create(addr, 0, 0, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main entry point from OS.
|
||||
*/
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
gtk_init(&argc, &argv);
|
||||
char options[PATH_MAX];
|
||||
char messages[PATH_MAX];
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
/* set standard error to be non-buffering */
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
/* initialise netsurf */
|
||||
netsurf_init(argc, argv);
|
||||
nsgtk_find_resource(messages, "messages", "./gtk/res/messages");
|
||||
nsgtk_find_resource(options, "Choices", "~/.netsurf/Choices");
|
||||
options_file_location = strdup(options);
|
||||
|
||||
gui_init2(argc, argv);
|
||||
/* initialise netsurf */
|
||||
netsurf_init(&argc, &argv, options, messages);
|
||||
|
||||
gui_init(argc, argv);
|
||||
|
||||
netsurf_main_loop();
|
||||
|
||||
|
34
riscos/gui.c
34
riscos/gui.c
@ -280,7 +280,7 @@ static void *myrealloc(void *ptr, size_t len, void *pw)
|
||||
* Initialise the gui (RISC OS specific part).
|
||||
*/
|
||||
|
||||
void gui_init(int argc, char** argv)
|
||||
static void gui_init(int argc, char** argv)
|
||||
{
|
||||
char path[40];
|
||||
os_error *error;
|
||||
@ -319,20 +319,6 @@ void gui_init(int argc, char** argv)
|
||||
HUBBUB_OK)
|
||||
die("Failed to initialise HTML parsing library.");
|
||||
|
||||
/* Read in the options */
|
||||
options_read("NetSurf:Choices");
|
||||
|
||||
/* Choose the interface language to use */
|
||||
ro_gui_choose_language();
|
||||
|
||||
/* Load in our language-specific Messages */
|
||||
if ((length = snprintf(path, sizeof(path),
|
||||
"NetSurf:Resources.%s.Messages",
|
||||
option_language)) < 0 || length >= (int)sizeof(path))
|
||||
die("Failed to locate Messages resource.");
|
||||
messages_load(path);
|
||||
messages_load("NetSurf:Resources.LangNames");
|
||||
|
||||
/* Set defaults for absent option strings */
|
||||
if (!option_theme)
|
||||
option_theme = strdup("Aletheia");
|
||||
@ -762,8 +748,22 @@ int main(int argc, char** argv)
|
||||
{
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
/* initialise netsurf */
|
||||
netsurf_init(argc, argv);
|
||||
#if RISCOS_MESSAGES_CHOICE
|
||||
/* Choose the interface language to use */
|
||||
ro_gui_choose_language();
|
||||
|
||||
/* Load in our language-specific Messages */
|
||||
if ((length = snprintf(path, sizeof(path),
|
||||
"NetSurf:Resources.%s.Messages",
|
||||
option_language)) < 0 || length >= (int)sizeof(path))
|
||||
die("Failed to locate Messages resource.");
|
||||
messages_load(path);
|
||||
messages_load("NetSurf:Resources.LangNames");
|
||||
#endif
|
||||
|
||||
netsurf_init(&argc, &argv, "NetSurf:Choices", messages);
|
||||
|
||||
gui_init(argc, argv);
|
||||
|
||||
gui_init2(argc, argv);
|
||||
|
||||
|
@ -2365,7 +2365,7 @@ void gui_quit(void)
|
||||
hubbub_finalise(myrealloc, NULL);
|
||||
}
|
||||
|
||||
void gui_init(int argc, char** argv)
|
||||
static void gui_init(int argc, char** argv)
|
||||
{
|
||||
char buf[PATH_MAX], sbuf[PATH_MAX];
|
||||
int len;
|
||||
@ -2380,17 +2380,6 @@ void gui_init(int argc, char** argv)
|
||||
if (he != HUBBUB_OK)
|
||||
die("Unable to initialise HTML parsing library.\n");
|
||||
|
||||
/* load browser messages */
|
||||
nsws_find_resource(buf, "messages", "./windows/res/messages");
|
||||
LOG(("Using '%s' as Messages file", buf));
|
||||
messages_load(buf);
|
||||
|
||||
/* load browser options */
|
||||
nsws_find_resource(buf, "preferences", "~/.netsurf/preferences");
|
||||
LOG(("Using '%s' as Preferences file", buf));
|
||||
options_file_location = strdup(buf);
|
||||
options_read(buf);
|
||||
|
||||
/* set up stylesheet urls */
|
||||
getcwd(sbuf, PATH_MAX);
|
||||
len = strlen(sbuf);
|
||||
@ -2451,6 +2440,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
|
||||
int argc = 0, argctemp = 0;
|
||||
size_t len;
|
||||
LPWSTR * argvw;
|
||||
char options[PATH_MAX];
|
||||
char messages[PATH_MAX];
|
||||
|
||||
if (SLEN(lpcli) > 0) {
|
||||
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
@ -2478,8 +2469,17 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
|
||||
argctemp++;
|
||||
}
|
||||
|
||||
/* load browser messages */
|
||||
nsws_find_resource(messages, "messages", "./windows/res/messages");
|
||||
|
||||
/* load browser options */
|
||||
nsws_find_resource(options, "preferences", "~/.netsurf/preferences");
|
||||
options_file_location = strdup(options);
|
||||
|
||||
/* initialise netsurf */
|
||||
netsurf_init(argc, argv);
|
||||
netsurf_init(&argc, &argv, options, messages);
|
||||
|
||||
gui_init(argc, argv);
|
||||
|
||||
gui_init2(argc, argv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user