rename global resource path variables in win32 frontend
This commit is contained in:
parent
56ddeed96c
commit
77d184913b
|
@ -79,7 +79,7 @@ static nsurl *nsw32_get_resource_url(const char *path)
|
|||
char buf[PATH_MAX];
|
||||
nsurl *url = NULL;
|
||||
|
||||
netsurf_path_to_nsurl(filepath_sfind(respaths, buf, path), &url);
|
||||
netsurf_path_to_nsurl(filepath_sfind(G_resource_pathv, buf, path), &url);
|
||||
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -41,13 +41,15 @@
|
|||
#include "windows/window.h"
|
||||
#include "windows/gui.h"
|
||||
|
||||
/**
|
||||
* win32 application instance handle.
|
||||
*
|
||||
* This handle is set in the main windows entry point.
|
||||
*/
|
||||
/* exported global defined in windows/gui.h */
|
||||
HINSTANCE hinst;
|
||||
|
||||
/* exported global defined in windows/gui.h */
|
||||
char **G_resource_pathv;
|
||||
|
||||
/* exported global defined in windows/gui.h */
|
||||
char *G_config_path;
|
||||
|
||||
static bool win32_quit = false;
|
||||
|
||||
struct dialog_list_entry {
|
||||
|
|
|
@ -22,13 +22,22 @@
|
|||
|
||||
struct gui_window;
|
||||
|
||||
/**
|
||||
* win32 application instance handle.
|
||||
*
|
||||
* This handle is set in the main windows entry point.
|
||||
*/
|
||||
extern HINSTANCE hinst;
|
||||
|
||||
/** Directory where all configuration files are held. */
|
||||
extern char *nsw32_config_home;
|
||||
/**
|
||||
* path to where all user config files are held.
|
||||
*/
|
||||
extern char *G_config_path;
|
||||
|
||||
/** resource search path vector. */
|
||||
extern char **respaths;
|
||||
/**
|
||||
* resource search path vector.
|
||||
*/
|
||||
extern char **G_resource_pathv;
|
||||
|
||||
/* bounding box */
|
||||
typedef struct bbox_s {
|
||||
|
|
|
@ -57,9 +57,6 @@
|
|||
#include "windows/clipboard.h"
|
||||
#include "windows/gui.h"
|
||||
|
||||
char **respaths; /** exported global defined in windows/gui.h */
|
||||
|
||||
char *nsw32_config_home; /* exported global defined in windows/gui.h */
|
||||
|
||||
/**
|
||||
* Obtain the DPI of the display.
|
||||
|
@ -224,28 +221,28 @@ static nserror set_defaults(struct nsoption_s *defaults)
|
|||
|
||||
/* cookie file default */
|
||||
fname = NULL;
|
||||
netsurf_mkpath(&fname, NULL, 2, nsw32_config_home, "Cookies");
|
||||
netsurf_mkpath(&fname, NULL, 2, G_config_path, "Cookies");
|
||||
if (fname != NULL) {
|
||||
nsoption_setnull_charp(cookie_file, fname);
|
||||
}
|
||||
|
||||
/* cookie jar default */
|
||||
fname = NULL;
|
||||
netsurf_mkpath(&fname, NULL, 2, nsw32_config_home, "Cookies");
|
||||
netsurf_mkpath(&fname, NULL, 2, G_config_path, "Cookies");
|
||||
if (fname != NULL) {
|
||||
nsoption_setnull_charp(cookie_jar, fname);
|
||||
}
|
||||
|
||||
/* url database default */
|
||||
fname = NULL;
|
||||
netsurf_mkpath(&fname, NULL, 2, nsw32_config_home, "URLs");
|
||||
netsurf_mkpath(&fname, NULL, 2, G_config_path, "URLs");
|
||||
if (fname != NULL) {
|
||||
nsoption_setnull_charp(url_file, fname);
|
||||
}
|
||||
|
||||
/* bookmark database default */
|
||||
fname = NULL;
|
||||
netsurf_mkpath(&fname, NULL, 2, nsw32_config_home, "Hotlist");
|
||||
netsurf_mkpath(&fname, NULL, 2, G_config_path, "Hotlist");
|
||||
if (fname != NULL) {
|
||||
nsoption_setnull_charp(hotlist_path, fname);
|
||||
}
|
||||
|
@ -257,11 +254,16 @@ static nserror set_defaults(struct nsoption_s *defaults)
|
|||
/**
|
||||
* Initialise user options location and contents
|
||||
*/
|
||||
static nserror nsw32_option_init(int *pargc, char** argv)
|
||||
static nserror
|
||||
nsw32_option_init(int *pargc, char** argv, char **respaths, char *config_path)
|
||||
{
|
||||
nserror ret;
|
||||
char *choices = NULL;
|
||||
|
||||
/* set the globals that will be used in the set_defaults() callback */
|
||||
G_resource_pathv = respaths;
|
||||
G_config_path = config_path;
|
||||
|
||||
/* user options setup */
|
||||
ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
|
||||
if (ret != NSERROR_OK) {
|
||||
|
@ -269,7 +271,7 @@ static nserror nsw32_option_init(int *pargc, char** argv)
|
|||
}
|
||||
|
||||
/* Attempt to load the user choices */
|
||||
ret = netsurf_mkpath(&choices, NULL, 2, nsw32_config_home, "Choices");
|
||||
ret = netsurf_mkpath(&choices, NULL, 2, config_path, "Choices");
|
||||
if (ret == NSERROR_OK) {
|
||||
nsoption_read(choices, nsoptions);
|
||||
free(choices);
|
||||
|
@ -311,6 +313,10 @@ static nserror nsw32_messages_init(char **respaths)
|
|||
|
||||
/**
|
||||
* Construct a unix style argc/argv
|
||||
*
|
||||
* \param argc_out number of commandline arguments
|
||||
* \param argv_out string vector of command line arguments
|
||||
* \return NSERROR_OK on success else error code
|
||||
*/
|
||||
static nserror win32_to_unix_commandline(int *argc_out, char ***argv_out)
|
||||
{
|
||||
|
@ -318,6 +324,7 @@ static nserror win32_to_unix_commandline(int *argc_out, char ***argv_out)
|
|||
char **argv;
|
||||
int cura;
|
||||
LPWSTR *argvw;
|
||||
size_t len;
|
||||
|
||||
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
if (argvw == NULL) {
|
||||
|
@ -367,9 +374,10 @@ static struct gui_misc_table win32_misc_table = {
|
|||
int WINAPI
|
||||
WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
|
||||
{
|
||||
char **argv = NULL;
|
||||
int argc = 0;
|
||||
size_t len;
|
||||
int argc;
|
||||
char **argv;
|
||||
char **respaths;
|
||||
char *nsw32_config_home = NULL;
|
||||
nserror ret;
|
||||
const char *addr;
|
||||
nsurl *url;
|
||||
|
@ -414,13 +422,12 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
|
|||
if (ret != NSERROR_OK) {
|
||||
NSLOG(netsurf, INFO,
|
||||
"Unable to locate a configuration directory.");
|
||||
nsw32_config_home = NULL;
|
||||
}
|
||||
|
||||
/* Initialise user options */
|
||||
ret = nsw32_option_init(&argc, argv);
|
||||
ret = nsw32_option_init(&argc, argv, respaths, nsw32_config_home);
|
||||
if (ret != NSERROR_OK) {
|
||||
NSLOG(netsurf, INFO, "Options failed to initialise (%s)\n",
|
||||
NSLOG(netsurf, ERROR, "Options failed to initialise (%s)\n",
|
||||
messages_get_errorcode(ret));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -699,7 +699,7 @@ nserror nsws_prefs_save(void)
|
|||
char *choices = NULL;
|
||||
nserror res;
|
||||
|
||||
res = netsurf_mkpath(&choices, NULL, 2, nsw32_config_home, "Choices");
|
||||
res = netsurf_mkpath(&choices, NULL, 2, G_config_path, "Choices");
|
||||
if (res == NSERROR_OK) {
|
||||
nsoption_write(choices, NULL, NULL);
|
||||
free(choices);
|
||||
|
|
Loading…
Reference in New Issue