diff options
43 files changed, 323 insertions, 208 deletions
diff --git a/amiga/download.c b/amiga/download.c index 60190ce17..4f4c39b20 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -433,11 +433,11 @@ BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG si else return FALSE; } -static struct gui_download_table gui_download_table = { +static struct gui_download_table download_table = { .create = gui_download_window_create, .data = gui_download_window_data, .error = gui_download_window_error, .done = gui_download_window_done, }; -struct gui_download_table *amiga_gui_download_table = &gui_download_table; +struct gui_download_table *amiga_download_table = &download_table; diff --git a/amiga/download.h b/amiga/download.h index d9e637ede..95d71ecfe 100755 --- a/amiga/download.h +++ b/amiga/download.h @@ -23,7 +23,7 @@ #include "amiga/gui.h" -extern struct gui_download_table *amiga_gui_download_table; +extern struct gui_download_table *amiga_download_table; struct download_context; struct gui_download_window; diff --git a/amiga/gui.c b/amiga/gui.c index 9e433101e..27e747a05 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -5085,7 +5085,7 @@ static void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl, } } -static struct gui_window_table ami_window_table = { +static struct gui_window_table amiga_window_table = { .create = gui_window_create, .destroy = gui_window_destroy, .redraw = gui_window_redraw_window, @@ -5117,19 +5117,19 @@ static struct gui_window_table ami_window_table = { .save_link = gui_window_save_link, }; +static struct gui_clipboard_table amiga_clipboard_table = { + .get = gui_get_clipboard, + .set = gui_set_clipboard, +}; -static struct gui_table ami_gui_table = { +static struct gui_browser_table amiga_browser_table = { .poll = gui_poll, .quit = gui_quit, .set_search_ico = gui_set_search_ico, .get_resource_url = gui_get_resource_url, .launch_url = gui_launch_url, .create_form_select_menu = gui_create_form_select_menu, - .get_clipboard = gui_get_clipboard, - .set_clipboard = gui_set_clipboard, .cert_verify = gui_cert_verify, - - .window = &ami_window_table, }; /** Normal entry point from OS */ @@ -5143,6 +5143,12 @@ int main(int argc, char** argv) int32 user = 0; nserror ret; Object *splash_window = ami_gui_splash_open(); + struct gui_table amiga_gui_table = { + .browser = &amiga_browser_table, + .window = &amiga_window_table, + .clipboard = &amiga_clipboard_table, + .download = amiga_download_table, + }; /* Open popupmenu.library just to check the version. * Versions older than 53.11 are dangerous, so we @@ -5190,10 +5196,7 @@ int main(int argc, char** argv) if (ami_locate_resource(messages, "Messages") == false) die("Cannot open Messages file"); - - ami_gui_table.download = amiga_gui_download_table; - - ret = netsurf_init(messages, &ami_gui_table); + ret = netsurf_init(messages, &amiga_gui_table); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); } diff --git a/atari/download.c b/atari/download.c index 4da9ef345..8d4786e23 100755 --- a/atari/download.c +++ b/atari/download.c @@ -455,12 +455,11 @@ static void gui_download_window_done(struct gui_download_window *dw) gui_window_set_status(input_window, messages_get("Done") );
}
-static struct gui_download_table gui_download_table = { +static struct gui_download_table download_table = { .create = gui_download_window_create, .data = gui_download_window_data, .error = gui_download_window_error, .done = gui_download_window_done, }; -struct gui_download_table *atari_gui_download_table = &gui_download_table; - +struct gui_download_table *atari_download_table = &download_table; diff --git a/atari/download.h b/atari/download.h index a5da60538..82f89c050 100755 --- a/atari/download.h +++ b/atari/download.h @@ -19,6 +19,8 @@ #ifndef NS_ATARI_DOWNLOAD_H
#define NS_ATARI_DOWNLOAD_H
+extern struct gui_download_table *atari_download_table; + #define MAX_SLEN_LBL_DONE 64
#define MAX_SLEN_LBL_PERCENT 5
#define MAX_SLEN_LBL_SPEED 13
@@ -58,6 +60,4 @@ struct gui_download_window { bool close_on_finish;
};
-struct gui_download_table *atari_gui_download_table; - #endif
diff --git a/atari/gui.c b/atari/gui.c index 924ac686a..49e3046e2 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -1045,15 +1045,16 @@ static struct gui_window_table atari_window_table = { .stop_throbber = gui_window_stop_throbber, }; -static struct gui_table atari_gui_table = { +static struct gui_clipboard_table atari_clipboard_table = { + .get = gui_get_clipboard, + .set = gui_set_clipboard, +}; + +static struct gui_browser_table atari_browser_table = { .poll = gui_poll, .quit = gui_quit, .get_resource_url = gui_get_resource_url, - .get_clipboard = gui_get_clipboard, - .set_clipboard = gui_set_clipboard, .cert_verify = gui_cert_verify, - - .window = &atari_window_table; }; /* #define WITH_DBG_LOGFILE 1 */ @@ -1071,6 +1072,12 @@ int main(int argc, char** argv) struct stat stat_buf; nsurl *url; nserror ret; + struct gui_table atari_gui_table = { + .browser = &atari_browser_table, + .window = &atari_window_table, + .clipboard = &atari_clipboard_table, + .download = atari_download_table, + }; /* @todo logging file descriptor update belongs in a nslog_init callback */ setbuf(stderr, NULL); @@ -1104,10 +1111,7 @@ int main(int argc, char** argv) /* common initialisation */ LOG(("Initialising core...")); - - atari_gui_table.download = nsgtk_gui_download_table; - - ret = netsurf_init(messages, atari_gui_table); + ret = netsurf_init(messages, &atari_gui_table); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); } diff --git a/beos/download.cpp b/beos/download.cpp index b62ab2ffb..2e259bccf 100644 --- a/beos/download.cpp +++ b/beos/download.cpp @@ -248,12 +248,12 @@ static void gui_download_window_done(struct gui_download_window *dw) dw->storageLock->Unlock(); } -static struct gui_download_table gui_download_table = { +static struct gui_download_table download_table = { .create = gui_download_window_create, .data = gui_download_window_data, .error = gui_download_window_error, .done = gui_download_window_done, }; -struct gui_download_table *beos_gui_download_table = &gui_download_table; +struct gui_download_table *beos_download_table = &download_table; diff --git a/beos/download.h b/beos/download.h index 962f3b7d9..245ee8641 100644 --- a/beos/download.h +++ b/beos/download.h @@ -16,4 +16,4 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -struct gui_download_table *beos_gui_download_table; +struct gui_download_table *beos_download_table; diff --git a/beos/gui.cpp b/beos/gui.cpp index 33337d8ff..3ee47c9e9 100644 --- a/beos/gui.cpp +++ b/beos/gui.cpp @@ -1059,15 +1059,17 @@ bool path_add_part(char *path, int length, const char *newpart) return true; } -static struct gui_table beos_gui_table = { +static struct gui_clipboard_table beos_clipboard_table = { + .get = gui_get_clipboard, + .set = gui_set_clipboard, +}; + +static struct gui_browser_table beos_browser_table = { .poll = gui_poll, .quit = gui_quit, .get_resource_url = gui_get_resource_url, .launch_url = gui_launch_url, - - .get_clipboard = gui_get_clipboard, - .set_clipboard = gui_set_clipboard, }; @@ -1076,6 +1078,13 @@ int main(int argc, char** argv) { nserror ret; BPath options; + struct gui_table beos_gui_table = { + .browser = &beos_browser_table, + .window = beos_window_table, + .clipboard = &beos_clipboard_table, + .download = beos_download_table, + }; + if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) { options.Append("x-vnd.NetSurf"); } @@ -1101,10 +1110,6 @@ int main(int argc, char** argv) /* common initialisation */ BPath messages = get_messages_path(); - - beos_gui_table.window = beos_gui_window_table; - beos_gui_table.download = beos_gui_download_table; - ret = netsurf_init(messages.Path(), &beos_gui_table); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); @@ -1124,6 +1129,13 @@ int gui_init_replicant(int argc, char** argv) { nserror ret; BPath options; + struct gui_table beos_gui_table = { + .browser = &beos_browser_table, + .window = beos_window_table, + .clipboard = &beos_clipboard_table, + .download = beos_download_table, + }; + if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) { options.Append("x-vnd.NetSurf"); } @@ -1145,10 +1157,6 @@ int gui_init_replicant(int argc, char** argv) /* common initialisation */ BPath messages = get_messages_path(); - - beos_gui_table.window = beos_gui_window_table; - beos_gui_table.download = beos_gui_download_table; - ret = netsurf_init(messages.Path(), &beos_gui_table); if (ret != NSERROR_OK) { // FIXME: must not die when in replicant! diff --git a/beos/window.cpp b/beos/window.cpp index a7bdf411e..fc46eba96 100644 --- a/beos/window.cpp +++ b/beos/window.cpp @@ -1347,7 +1347,7 @@ static void gui_window_get_dimensions(struct gui_window *g, int *width, int *hei } } -static struct gui_window_table gui_window_table = { +static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, .redraw = gui_window_redraw_window, @@ -1372,4 +1372,4 @@ static struct gui_window_table gui_window_table = { .stop_throbber = gui_window_stop_throbber, }; -struct gui_window_table *beos_gui_window_table = &gui_window_table; +struct gui_window_table *beos_window_table = &window_table; diff --git a/beos/window.h b/beos/window.h index 8e98841c7..fb67517d2 100644 --- a/beos/window.h +++ b/beos/window.h @@ -25,7 +25,7 @@ extern "C" { } #include "beos/scaffolding.h" -extern struct gui_window_table *beos_gui_window_table; +extern struct gui_window_table *beos_window_table; class NSBrowserFrameView : public BView { public: diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m index a64c99376..62f684ddc 100644 --- a/cocoa/NetsurfApp.m +++ b/cocoa/NetsurfApp.m @@ -183,6 +183,12 @@ int main( int argc, char **argv ) { nsurl *url; nserror error; + struct gui_table cocoa_gui_table = { + .browser = cocoa_browser_table, + .window = cocoa_window_table, + .clipboard = cocoa_clipboard_table, + .download = cocoa_download_table, + }; cocoa_autorelease(); @@ -203,9 +209,7 @@ int main( int argc, char **argv ) nsoption_commandline(&argc, argv, NULL); /* common initialisation */ - cocoa_gui_table->download = cocoa_gui_download_table; - - error = netsurf_init(messages, cocoa_gui_table); + error = netsurf_init(messages, &cocoa_gui_table); if (error != NSERROR_OK) { die("NetSurf failed to initialise"); } diff --git a/cocoa/gui.h b/cocoa/gui.h index 6ceefa848..757140030 100644 --- a/cocoa/gui.h +++ b/cocoa/gui.h @@ -18,6 +18,10 @@ #import <Cocoa/Cocoa.h> +extern struct gui_window_table *cocoa_window_table; +extern struct gui_clipboard_table *cocoa_clipboard_table; +extern struct gui_browser_table *cocoa_browser_table; + extern NSString * const kCookiesFileOption; extern NSString * const kURLsFileOption; extern NSString * const kHotlistFileOption; @@ -27,5 +31,3 @@ extern NSString * const kAlwaysCancelDownload; extern NSString * const kAlwaysCloseMultipleTabs; void cocoa_autorelease( void ); - -extern struct gui_table *cocoa_gui_table; diff --git a/cocoa/gui.m b/cocoa/gui.m index 2c3680994..c2cadfe5a 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -282,7 +282,7 @@ void gui_401login_open(nsurl *url, const char *realm, } -static struct gui_window_table cocoa_window_table = { +static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, .redraw = gui_window_redraw_window, @@ -304,18 +304,25 @@ static struct gui_window_table cocoa_window_table = { .stop_throbber = gui_window_stop_throbber, }; -static struct gui_table gui_table = { +struct gui_window_table *cocoa_window_table = &window_table; + + +static struct gui_clipboard_table clipboard_table = { + .get_clipboard = gui_get_clipboard, + .set_clipboard = gui_set_clipboard, +}; + +struct gui_clipboard_table *cocoa_clipboard_table = &clipboard_table; + + +static struct gui_browser_table browser_table = { .poll = gui_poll, .get_resource_url = gui_get_resource_url, .launch_url = gui_launch_url, .create_form_select_menu = gui_create_form_select_menu, .cert_verify = gui_cert_verify, - - .get_clipboard = gui_get_clipboard, - .set_clipboard = gui_set_clipboard, - - .window = &cocoa_window_table, }; -struct gui_table *cocoa_gui_table = &gui_table; +struct gui_browser_table *cocoa_browser_table = &browser_table; + diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c index 5dca8b378..d1b21b741 100644 --- a/content/fetchers/resource.c +++ b/content/fetchers/resource.c @@ -207,7 +207,7 @@ static bool fetch_resource_initialise(lwc_string *scheme) } } - e->url = guit->get_resource_url(fetch_resource_paths[i]); + e->url = guit->browser->get_resource_url(fetch_resource_paths[i]); if (e->url == NULL) { lwc_string_unref(e->path); } else { diff --git a/desktop/browser.c b/desktop/browser.c index 55cb779bf..d65033097 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -814,7 +814,7 @@ browser_window_download(struct browser_window *bw, NULL, NULL, &l); if (error == NSERROR_NO_FETCH_HANDLER) { /* no internal handler for this type, call out to frontend */ - guit->launch_url(nsurl_access(url)); + guit->browser->launch_url(nsurl_access(url)); } else if (error != NSERROR_OK) { LOG(("Failed to fetch download: %d", error)); } else { @@ -1873,7 +1873,7 @@ nserror browser_window_navigate(struct browser_window *bw, case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */ /** @todo does this always try and download even unverifiable content? */ - guit->launch_url(nsurl_access(url)); + guit->browser->launch_url(nsurl_access(url)); break; default: /* report error to user */ diff --git a/desktop/gui.h b/desktop/gui.h index 12cf91a50..686bb59d4 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -264,20 +264,35 @@ struct gui_download_table { void (*done)(struct gui_download_window *dw); }; -/** Graphical user interface function table - * - * function table implementing GUI interface to browser core +/** + * function table for clipboard operations */ -struct gui_table { - - /* sub tables */ - - /** Window sub table */ - struct gui_window_table *window; +struct gui_clipboard_table { + /** + * Core asks front end for clipboard contents. + * + * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core + * \param length Byte length of UTF-8 text in buffer + */ + void (*get)(char **buffer, size_t *length); - /** Downlaod sub table */ - struct gui_download_table *download; + /** + * Core tells front end to put given text in clipboard + * + * \param buffer UTF-8 text, owned by core + * \param length Byte length of UTF-8 text in buffer + * \param styles Array of styles given to text runs, owned by core, or NULL + * \param n_styles Number of text run styles in array + */ + void (*set)(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles); +}; +/** Graphical user interface browser misc function table + * + * function table implementing GUI interface to miscelaneous browser + * functionality + */ +struct gui_browser_table { /* Mandantory entries */ /** @@ -318,31 +333,13 @@ struct gui_table { * core has no fetcher for url */ void (*launch_url)(const char *url); - + /** * create a form select menu */ void (*create_form_select_menu)(struct browser_window *bw, struct form_control *control); /** - * Core asks front end for clipboard contents. - * - * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core - * \param length Byte length of UTF-8 text in buffer - */ - void (*get_clipboard)(char **buffer, size_t *length); - - /** - * Core tells front end to put given text in clipboard - * - * \param buffer UTF-8 text, owned by core - * \param length Byte length of UTF-8 text in buffer - * \param styles Array of styles given to text runs, owned by core, or NULL - * \param n_styles Number of text run styles in array - */ - void (*set_clipboard)(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles); - - /** * verify certificate */ void (*cert_verify)(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw); @@ -350,8 +347,24 @@ struct gui_table { }; +/** Graphical user interface function table + * + * function table implementing GUI interface to browser core + */ +struct gui_table { + + /** Browser table */ + struct gui_browser_table *browser; + + /** Window table */ + struct gui_window_table *window; + /** Download table */ + struct gui_download_table *download; + /** Clipboard table */ + struct gui_clipboard_table *clipboard; +}; #endif diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index cb01fc45e..f47b73007 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -195,6 +195,7 @@ static nserror verify_window_register(struct gui_window_table *gwt) } + static struct gui_download_window * gui_default_download_create(download_context *ctx, struct gui_window *parent) { @@ -216,12 +217,6 @@ static void gui_default_download_done(struct gui_download_window *dw) { } -static struct gui_download_table default_download_table = { - .create = gui_default_download_create, - .data = gui_default_download_data, - .error = gui_default_download_error, - .done = gui_default_download_done, -}; /** verify download window table is valid */ static nserror verify_download_register(struct gui_download_table *gdt) @@ -248,6 +243,35 @@ static nserror verify_download_register(struct gui_download_table *gdt) return NSERROR_OK; } +static void gui_default_get_clipboard(char **buffer, size_t *length) +{ + *buffer = NULL; + *length = 0; +} + +static void gui_default_set_clipboard(const char *buffer, size_t length, + nsclipboard_styles styles[], int n_styles) +{ +} + +static nserror verify_clipboard_register(struct gui_clipboard_table *gct) +{ + /* check table is present */ + if (gct == NULL) { + return NSERROR_BAD_PARAMETER; + } + + /* optional operations */ + if (gct->get == NULL) { + gct->get = gui_default_get_clipboard; + } + if (gct->set == NULL) { + gct->set = gui_default_set_clipboard; + } + return NSERROR_OK; +} + + static void gui_default_quit(void) { } @@ -270,16 +294,6 @@ static void gui_default_create_form_select_menu(struct browser_window *bw, { } -static void gui_default_get_clipboard(char **buffer, size_t *length) -{ - *buffer = NULL; - *length = 0; -} - -static void gui_default_set_clipboard(const char *buffer, size_t length, - nsclipboard_styles styles[], int n_styles) -{ -} static void gui_default_cert_verify(nsurl *url, const struct ssl_cert_info *certs, @@ -290,6 +304,55 @@ static void gui_default_cert_verify(nsurl *url, cb(false, cbpw); } + +static nserror verify_browser_register(struct gui_browser_table *gbt) +{ + /* check table is present */ + if (gbt == NULL) { + return NSERROR_BAD_PARAMETER; + } + + /* check the mandantory fields are set */ + if (gbt->poll == NULL) { + return NSERROR_BAD_PARAMETER; + } + + /* fill in the optional entries with defaults */ + if (gbt->quit == NULL) { + gbt->quit = gui_default_quit; + } + if (gbt->set_search_ico == NULL) { + gbt->set_search_ico = gui_default_set_search_ico; + } + if (gbt->get_resource_url == NULL) { + gbt->get_resource_url = gui_default_get_resource_url; + } + if (gbt->launch_url == NULL) { + gbt->launch_url = gui_default_launch_url; + } + if (gbt->create_form_select_menu == NULL) { + gbt->create_form_select_menu = gui_default_create_form_select_menu; + } + if (gbt->cert_verify == NULL) { + gbt->cert_verify = gui_default_cert_verify; + } + return NSERROR_OK; +} + + + +static struct gui_download_table default_download_table = { + .create = gui_default_download_create, + .data = gui_default_download_data, + .error = gui_default_download_error, + .done = gui_default_download_done, +}; + +static struct gui_clipboard_table default_clipboard_table = { + .get = gui_default_get_clipboard, + .set = gui_default_set_clipboard, +}; + nserror gui_factory_register(struct gui_table *gt) { nserror err; @@ -304,11 +367,19 @@ nserror gui_factory_register(struct gui_table *gt) return NSERROR_BAD_PARAMETER; } - /* check subtables */ + /* browser table */ + err = verify_browser_register(gt->browser); + if (err != NSERROR_OK) { + return err; + } + + /* window table */ err = verify_window_register(gt->window); if (err != NSERROR_OK) { return err; } + + /* download table */ if (gt->download == NULL) { /* set default download table */ gt->download = &default_download_table; @@ -318,35 +389,14 @@ nserror gui_factory_register(struct gui_table *gt) return err; } - /* check the mandantory fields are set */ - if (gt->poll == NULL) { - return NSERROR_BAD_PARAMETER; - } - - /* fill in the optional entries with defaults */ - if (gt->quit == NULL) { - gt->quit = gui_default_quit; - } - if (gt->set_search_ico == NULL) { - gt->set_search_ico = gui_default_set_search_ico; - } - if (gt->get_resource_url == NULL) { - gt->get_resource_url = gui_default_get_resource_url; - } - if (gt->launch_url == NULL) { - gt->launch_url = gui_default_launch_url; + /* clipboard table */ + if (gt->clipboard == NULL) { + /* set default clipboard table */ + gt->clipboard = &default_clipboard_table; } - if (gt->create_form_select_menu == NULL) { - gt->create_form_select_menu = gui_default_create_form_select_menu; - } - if (gt->get_clipboard == NULL) { - gt->get_clipboard = gui_default_get_clipboard; - } - if (gt->set_clipboard == NULL) { - gt->set_clipboard = gui_default_set_clipboard; - } - if (gt->cert_verify == NULL) { - gt->cert_verify = gui_default_cert_verify; + err = verify_clipboard_register(gt->clipboard); + if (err != NSERROR_OK) { + return err; } guit = gt; diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 1c36a3fe7..5589f51a5 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -103,7 +103,7 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query, /* For now, do nothing, as this query type isn't emitted yet */ break; case LLCACHE_QUERY_SSL: - guit->cert_verify(query->url, query->data.ssl.certs, + guit->browser->cert_verify(query->url, query->data.ssl.certs, query->data.ssl.num, cb, cbpw); break; } @@ -234,7 +234,7 @@ nserror netsurf_init(const char *messages, struct gui_table *gt) int netsurf_main_loop(void) { while (!netsurf_quit) { - guit->poll(fetch_active); + guit->browser->poll(fetch_active); hlcache_poll(); } @@ -250,7 +250,7 @@ void netsurf_exit(void) hlcache_stop(); LOG(("Closing GUI")); - guit->quit(); + guit->browser->quit(); LOG(("Finalising JavaScript")); js_finalise(); diff --git a/desktop/searchweb.c b/desktop/searchweb.c index 63e17ee90..30b424cb3 100644 --- a/desktop/searchweb.c +++ b/desktop/searchweb.c @@ -308,7 +308,7 @@ nserror search_web_ico_callback(hlcache_handle *ico, case CONTENT_MSG_DONE: LOG(("got favicon '%s'", nsurl_access(hlcache_handle_get_url(ico)))); - guit->set_search_ico(search_ico); + guit->browser->set_search_ico(search_ico); break; case CONTENT_MSG_ERROR: diff --git a/desktop/selection.c b/desktop/selection.c index 7535f6915..96c7e0c3c 100644 --- a/desktop/selection.c +++ b/desktop/selection.c @@ -845,7 +845,7 @@ bool selection_copy_to_clipboard(struct selection *s) return false; } - guit->set_clipboard(sel_string.buffer, sel_string.length, + guit->clipboard->set(sel_string.buffer, sel_string.length, sel_string.styles, sel_string.n_styles); free(sel_string.buffer); diff --git a/desktop/textarea.c b/desktop/textarea.c index 14747252d..209a6c6d7 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -1419,7 +1419,7 @@ static bool textarea_replace_text_internal(struct textarea *ta, size_t b_start, /* Place CUTs on clipboard */ if (add_to_clipboard) { - guit->set_clipboard(ta->show->data + b_start, b_end - b_start, + guit->clipboard->set(ta->show->data + b_start, b_end - b_start, NULL, 0); } @@ -2486,7 +2486,7 @@ bool textarea_keypress(struct textarea *ta, uint32_t key) if (readonly) break; - guit->get_clipboard(&clipboard, &clipboard_length); + guit->clipboard->get(&clipboard, &clipboard_length); if (clipboard == NULL) return false; diff --git a/framebuffer/clipboard.c b/framebuffer/clipboard.c index 4f9831340..b4bd296c6 100644 --- a/framebuffer/clipboard.c +++ b/framebuffer/clipboard.c @@ -43,7 +43,7 @@ static struct gui_clipboard { * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core * \param length Byte length of UTF-8 text in buffer */ -void gui_get_clipboard(char **buffer, size_t *length) +static void gui_get_clipboard(char **buffer, size_t *length) { *buffer = NULL; *length = 0; @@ -72,7 +72,7 @@ void gui_get_clipboard(char **buffer, size_t *length) * \param styles Array of styles given to text runs, owned by core, or NULL * \param n_styles Number of text run styles in array */ -void gui_set_clipboard(const char *buffer, size_t length, +static void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles) { if (gui_clipboard.buffer_len < length + 1) { @@ -94,3 +94,9 @@ void gui_set_clipboard(const char *buffer, size_t length, gui_clipboard.buffer[gui_clipboard.length] = '\0'; } +static struct gui_clipboard_table clipboard_table = { + .get = gui_get_clipboard, + .set = gui_set_clipboard, +}; + +struct gui_clipboard_table *framebuffer_clipboard_table = &clipboard_table; diff --git a/framebuffer/clipboard.h b/framebuffer/clipboard.h index bc71a5565..b5f7b0f29 100644 --- a/framebuffer/clipboard.h +++ b/framebuffer/clipboard.h @@ -19,8 +19,6 @@ #ifndef NETSURF_FB_CLIPBOARD_H #define NETSURF_FB_CLIPBOARD_H -void gui_get_clipboard(char **buffer, size_t *length); -void gui_set_clipboard(const char *buffer, size_t length, - nsclipboard_styles styles[], int n_styles); +extern struct gui_clipboard_table *framebuffer_clipboard_table; #endif diff --git a/framebuffer/gui.c b/framebuffer/gui.c index 8b90b52f7..b2edc030a 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -1768,7 +1768,7 @@ gui_window_remove_caret(struct gui_window *g) } -static struct gui_window_table framebuffer_gui_window_table = { +static struct gui_window_table framebuffer_window_table = { .create = gui_window_create, .destroy = gui_window_destroy, .redraw = gui_window_redraw_window, @@ -1787,14 +1787,10 @@ static struct gui_window_table framebuffer_gui_window_table = { .stop_throbber = gui_window_stop_throbber, }; -static struct gui_table framebuffer_gui_table = { +static struct gui_browser_table framebuffer_browser_table = { .poll = gui_poll, .quit = gui_quit, .get_resource_url = gui_get_resource_url, - .get_clipboard = gui_get_clipboard, - .set_clipboard = gui_set_clipboard, - - .window = &framebuffer_gui_window_table, }; /** Entry point from OS. @@ -1812,6 +1808,11 @@ main(int argc, char** argv) nsurl *url; nserror ret; nsfb_t *nsfb; + struct gui_table framebuffer_gui_table = { + .browser = &framebuffer_browser_table, + .window = &framebuffer_window_table, + .clipboard = framebuffer_clipboard_table, + }; respaths = fb_init_resource(NETSURF_FB_RESPATH":"NETSURF_FB_FONTPATH); diff --git a/gtk/download.c b/gtk/download.c index 1eb53403e..3d287d4d2 100644 --- a/gtk/download.c +++ b/gtk/download.c @@ -845,11 +845,11 @@ static void gui_download_window_done(struct gui_download_window *dw) } -static struct gui_download_table gui_download_table = { +static struct gui_download_table download_table = { .create = gui_download_window_create, .data = gui_download_window_data, .error = gui_download_window_error, .done = gui_download_window_done, }; -struct gui_download_table *nsgtk_gui_download_table = &gui_download_table; +struct gui_download_table *nsgtk_download_table = &download_table; diff --git a/gtk/download.h b/gtk/download.h index 393009dc4..a6e624fbd 100644 --- a/gtk/download.h +++ b/gtk/download.h @@ -21,12 +21,12 @@ #include <gtk/gtk.h> +struct gui_download_table *nsgtk_download_table; + bool nsgtk_download_init(const char *glade_file_location); void nsgtk_download_destroy (void); bool nsgtk_check_for_downloads(GtkWindow *parent); void nsgtk_download_show(GtkWindow *parent); void nsgtk_download_add(gchar *url, gchar *destination); -struct gui_download_table *nsgtk_gui_download_table; - #endif @@ -1128,17 +1128,18 @@ bool path_add_part(char *path, int length, const char *newpart) return true; } +static struct gui_clipboard_table nsgtk_clipboard_table = { + .get = gui_get_clipboard, + .set = gui_set_clipboard, +}; - -static struct gui_table nsgtk_gui_table = { +static struct gui_browser_table nsgtk_browser_table = { .poll = gui_poll, .quit = gui_quit, .set_search_ico = gui_set_search_ico, .get_resource_url = gui_get_resource_url, .launch_url = gui_launch_url, .create_form_select_menu = gui_create_form_select_menu, - .get_clipboard = gui_get_clipboard, - .set_clipboard = gui_set_clipboard, .cert_verify = gui_cert_verify, }; @@ -1150,6 +1151,12 @@ int main(int argc, char** argv) char *messages; char *options; nserror ret; + struct gui_table nsgtk_gui_table = { + .browser = &nsgtk_browser_table, + .window = nsgtk_window_table, + .clipboard = &nsgtk_clipboard_table, + .download = nsgtk_download_table, + }; /* check home directory is available */ nsgtk_check_homedir(); @@ -1178,10 +1185,6 @@ int main(int argc, char** argv) /* common initialisation */ messages = filepath_find(respaths, "Messages"); - - nsgtk_gui_table.window = nsgtk_gui_window_table; - nsgtk_gui_table.download = nsgtk_gui_download_table; - ret = netsurf_init(messages, &nsgtk_gui_table); free(messages); if (ret != NSERROR_OK) { diff --git a/gtk/window.c b/gtk/window.c index 8b66be60d..0ba3c5052 100644 --- a/gtk/window.c +++ b/gtk/window.c @@ -1167,7 +1167,7 @@ gui_window_file_gadget_open(struct gui_window *g, gtk_widget_destroy(dialog); } -static struct gui_window_table gui_window_table = { +static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, .redraw = gui_window_redraw_window, @@ -1192,4 +1192,4 @@ static struct gui_window_table gui_window_table = { .stop_throbber = gui_window_stop_throbber, }; -struct gui_window_table *nsgtk_gui_window_table = &gui_window_table; +struct gui_window_table *nsgtk_window_table = &window_table; diff --git a/gtk/window.h b/gtk/window.h index b6953a99e..e242b6e7a 100644 --- a/gtk/window.h +++ b/gtk/window.h @@ -23,6 +23,7 @@ #include "desktop/browser.h" #include "gtk/scaffolding.h" +extern struct gui_window_table *nsgtk_window_table; typedef enum nsgtk_window_signals { NSGTK_WINDOW_SIGNAL_CLICK, @@ -32,7 +33,6 @@ typedef enum nsgtk_window_signals { extern struct gui_window *window_list; extern int temp_open_background; -extern struct gui_window_table *nsgtk_gui_window_table; struct browser_window *nsgtk_get_browser_window(struct gui_window *g); nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g); diff --git a/monkey/browser.c b/monkey/browser.c index 97bd0be8b..85e25d9ea 100644 --- a/monkey/browser.c +++ b/monkey/browser.c @@ -503,7 +503,7 @@ monkey_window_handle_command(int argc, char **argv) } -static struct gui_window_table gui_window_table = { +static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, .redraw = gui_window_redraw_window, @@ -529,4 +529,4 @@ static struct gui_window_table gui_window_table = { .stop_throbber = gui_window_stop_throbber, }; -struct gui_window_table *monkey_gui_window_table = &gui_window_table; +struct gui_window_table *monkey_window_table = &window_table; diff --git a/monkey/browser.h b/monkey/browser.h index 6c74a412c..959c6a1e6 100644 --- a/monkey/browser.h +++ b/monkey/browser.h @@ -22,6 +22,9 @@ #include "desktop/browser.h" #include "content/hlcache.h" +extern struct gui_window_table *monkey_window_table; +extern struct gui_download_table *monkey_download_table; + struct gui_window { struct gui_window *r_next; struct gui_window *r_prev; @@ -36,9 +39,6 @@ struct gui_window { }; -extern struct gui_window_table *monkey_gui_window_table; -extern struct gui_download_table *monkey_gui_download_table; - struct gui_window *monkey_find_window_by_num(uint32_t win_num); struct gui_window *monkey_find_window_by_content(hlcache_handle *content); void monkey_window_process_reformats(void); diff --git a/monkey/download.c b/monkey/download.c index 46d54dc0c..d2e3b4b24 100644 --- a/monkey/download.c +++ b/monkey/download.c @@ -78,11 +78,11 @@ gui_download_window_done(struct gui_download_window *dw) free(dw); } -static struct gui_download_table gui_download_table = { +static struct gui_download_table download_table = { .create = gui_download_window_create, .data = gui_download_window_data, .error = gui_download_window_error, .done = gui_download_window_done, }; -struct gui_download_table *monkey_gui_download_table = &gui_download_table; +struct gui_download_table *monkey_download_table = &download_table; diff --git a/monkey/main.c b/monkey/main.c index 419543e29..22aaf1e06 100644 --- a/monkey/main.c +++ b/monkey/main.c @@ -114,7 +114,7 @@ static bool nslog_stream_configure(FILE *fptr) return true; } -static struct gui_table monkey_gui_table = { +static struct gui_browser_table monkey_browser_table = { .poll = monkey_poll, .quit = monkey_quit, .get_resource_url = gui_get_resource_url, @@ -129,6 +129,11 @@ main(int argc, char **argv) char *options; char buf[PATH_MAX]; nserror ret; + struct gui_table monkey_gui_table = { + .browser = &monkey_browser_table, + .window = monkey_window_table, + .download = monkey_download_table, + }; /* Unbuffer stdin/out/err */ setbuf(stdin, NULL); @@ -155,10 +160,6 @@ main(int argc, char **argv) /* common initialisation */ messages = filepath_find(respaths, "Messages"); - - monkey_gui_table.window = monkey_gui_window_table; - monkey_gui_table.download = monkey_gui_download_table; - ret = netsurf_init(messages, &monkey_gui_table); free(messages); if (ret != NSERROR_OK) { diff --git a/render/html_interaction.c b/render/html_interaction.c index 0170c8d8d..415e7b1cf 100644 --- a/render/html_interaction.c +++ b/render/html_interaction.c @@ -655,7 +655,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw, c); pointer = BROWSER_POINTER_DEFAULT; } else if (mouse & BROWSER_MOUSE_CLICK_1) - guit->create_form_select_menu(bw, gadget); + guit->browser->create_form_select_menu(bw, gadget); break; case GADGET_CHECKBOX: status = messages_get("FormCheckbox"); diff --git a/riscos/download.c b/riscos/download.c index aeeeeffbd..3a02c9c90 100644 --- a/riscos/download.c +++ b/riscos/download.c @@ -1632,11 +1632,11 @@ bool ro_gui_download_prequit(void) return true; } -static struct gui_download_table gui_download_table = { +static struct gui_download_table download_table = { .create = gui_download_window_create, .data = gui_download_window_data, .error = gui_download_window_error, .done = gui_download_window_done, }; -struct gui_download_table *riscos_gui_download_table = &gui_download_table; +struct gui_download_table *riscos_download_table = &download_table; diff --git a/riscos/gui.c b/riscos/gui.c index ccf07e5d9..50c1bdf62 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -2348,14 +2348,17 @@ bool path_add_part(char *path, int length, const char *newpart) return true; } -static struct gui_table riscos_gui_table = { +static struct gui_clipboard_table riscos_clipboard_table = { + .get = gui_get_clipboard, + .set = gui_set_clipboard, +}; + +static struct gui_browser_table riscos_browser_table = { .poll = gui_poll, .quit = gui_quit, .get_resource_url = gui_get_resource_url, .launch_url = gui_launch_url, .create_form_select_menu = gui_create_form_select_menu, - .get_clipboard = gui_get_clipboard, - .set_clipboard = gui_set_clipboard, .cert_verify = gui_cert_verify, }; @@ -2370,6 +2373,12 @@ int main(int argc, char** argv) int used = -1; /* slightly better with older OSLib versions */ os_error *error; nserror ret; + struct gui_table riscos_gui_table = { + .browser = &riscos_browser_table, + .window = riscos_window_table, + .clipboard = &riscos_clipboard_table, + .download = riscos_download_table, + }; /* Consult NetSurf$Logging environment variable to decide if logging * is required. */ @@ -2414,9 +2423,6 @@ int main(int argc, char** argv) } /* common initialisation */ - riscos_gui_table.window = riscos_gui_window_table; - riscos_gui_table.download = riscos_gui_download_table; - ret = netsurf_init(path, &riscos_gui_table); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); diff --git a/riscos/gui.h b/riscos/gui.h index 9fbc2eb28..b45bd472c 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -123,7 +123,7 @@ const char *ro_gui_default_language(void); void ro_gui_download_init(void); void ro_gui_download_datasave_ack(wimp_message *message); bool ro_gui_download_prequit(void); -extern struct gui_download_table *riscos_gui_download_table; +extern struct gui_download_table *riscos_download_table; /* in 401login.c */ void ro_gui_401login_init(void); diff --git a/windows/download.c b/windows/download.c index 5bf9798aa..189baa819 100644 --- a/windows/download.c +++ b/windows/download.c @@ -296,12 +296,12 @@ static void gui_download_window_done(struct gui_download_window *w) nsws_download_clear_data(w); } -static struct gui_download_table gui_download_table = { +static struct gui_download_table download_table = { .create = gui_download_window_create, .data = gui_download_window_data, .error = gui_download_window_error, .done = gui_download_window_done, }; -struct gui_download_table *win32_gui_download_table = &gui_download_table; +struct gui_download_table *win32_download_table = &download_table; diff --git a/windows/download.h b/windows/download.h index c1b13bf65..a53fab89f 100644 --- a/windows/download.h +++ b/windows/download.h @@ -23,6 +23,8 @@ #include <windows.h> #include "desktop/gui.h" +struct gui_download_table *win32_download_table; + typedef enum { DOWNLOAD_NONE, DOWNLOAD_WORKING, @@ -60,6 +62,4 @@ struct gui_download_window { void nsws_download_window_init(struct gui_window *); -struct gui_download_table *win32_gui_download_table; - #endif diff --git a/windows/gui.c b/windows/gui.c index fc0af679e..fa748254c 100644 --- a/windows/gui.c +++ b/windows/gui.c @@ -1809,7 +1809,7 @@ nsws_create_main_class(HINSTANCE hinstance) { return ret; } -static struct gui_window_table win32_window_table = { +static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, .redraw = gui_window_redraw_window, @@ -1829,12 +1829,17 @@ static struct gui_window_table win32_window_table = { .stop_throbber = gui_window_stop_throbber, }; -static struct gui_table gui_table = { - .poll = gui_poll, - .get_clipboard = gui_get_clipboard, - .set_clipboard = gui_set_clipboard, +struct gui_window_table *win32_window_table = &window_table; + +static struct gui_clipboard_table clipboard_table = { + .get = gui_get_clipboard, + .set = gui_set_clipboard, +}; - .window = &win32_window_table, +struct gui_clipboard_table *win32_clipboard_table = &clipboard_table; + +static struct gui_table browser_table = { + .poll = gui_poll, }; -struct gui_table *win32_gui_table = &gui_table; +struct gui_browser_table *win32_browser_table = &browser_table; diff --git a/windows/gui.h b/windows/gui.h index 29c7f8485..3372dcc21 100644 --- a/windows/gui.h +++ b/windows/gui.h @@ -24,7 +24,9 @@ #include "desktop/gui.h" #include "windows/localhistory.h" -extern struct gui_table *win32_gui_table; +extern struct gui_window_table *win32_window_table; +extern struct gui_clipboard_table *win32_clipboard_table; +extern struct gui_browser_table *win32_browser_table; extern HINSTANCE hInstance; diff --git a/windows/main.c b/windows/main.c index 997d98120..638db6c5c 100644 --- a/windows/main.c +++ b/windows/main.c @@ -104,6 +104,13 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) const char *addr; nsurl *url; nserror error; + struct gui_table win32_gui_table = { + .browser = win32_browser_table, + .window = win32_window_table, + .clipboard = win32_clipboard_table, + .download = win32_download_table, + }; + win32_gui_table->browser->get_resource_url = get_resource_url; if (SLEN(lpcli) > 0) { argvw = CommandLineToArgvW(GetCommandLineW(), &argc); @@ -150,11 +157,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) /* common initialisation */ messages = filepath_find(respaths, "messages"); - - win32_gui_table->download = nsgtk_gui_download_table; - win32_gui_table->get_resource_url = get_resource_url; - - ret = netsurf_init(messages, win32_gui_table); + ret = netsurf_init(messages, &win32_gui_table); free(messages); if (ret != NSERROR_OK) { free(options_file_location); |