From c14ddad660d3c07f8dbdc8f8db902e5767821d9c Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 2 Nov 2014 22:30:45 +0000 Subject: change url setting api to take an nsurl instead of a text string --- amiga/gui.c | 15 +++++++++------ atari/gui.c | 12 ++++++------ cocoa/gui.m | 4 ++-- desktop/browser.c | 2 +- desktop/gui_factory.c | 2 +- desktop/gui_window.h | 2 +- framebuffer/gui.c | 4 ++-- gtk/scaffolding.c | 4 ++-- gtk/scaffolding.h | 3 ++- monkey/browser.c | 4 ++-- riscos/gui/url_bar.c | 4 ++-- riscos/window.c | 7 ++++--- riscos/window.h | 2 +- windows/gui.c | 4 ++-- 14 files changed, 37 insertions(+), 32 deletions(-) diff --git a/amiga/gui.c b/amiga/gui.c index 1c15b4a83..231bcb3e4 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -4774,19 +4774,22 @@ static void gui_window_set_status(struct gui_window *g, const char *text) } } -static nserror gui_window_set_url(struct gui_window *g, const char *url) +static nserror gui_window_set_url(struct gui_window *g, nsurl *url) { int cur_tab = 0; if(!g) return; - if(g->tab_node && (g->shared->tabs > 1)) GetAttr(CLICKTAB_Current, - g->shared->objects[GID_TABS], (ULONG *)&cur_tab); + if ((g->tab_node) && (g->shared->tabs > 1)) { + GetAttr(CLICKTAB_Current, + g->shared->objects[GID_TABS], + (ULONG *)&cur_tab); + } - if((cur_tab == g->tab) || (g->shared->tabs <= 1)) - { + if ((cur_tab == g->tab) || (g->shared->tabs <= 1)) { RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_URL], - g->shared->win, NULL, STRINGA_TextVal, url, TAG_DONE); + g->shared->win, NULL, STRINGA_TextVal, + nsurl_access(url), TAG_DONE); } ami_update_buttons(g->shared); diff --git a/atari/gui.c b/atari/gui.c index cb071a161..c077df895 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -115,7 +115,7 @@ EVMULT_OUT aes_event_out; short aes_msg_out[8]; bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy); -static nserror gui_window_set_url(struct gui_window *w, const char *url); +static nserror gui_window_set_url(struct gui_window *w, nsurl *url); /** * Core atari event processing. @@ -220,7 +220,7 @@ gui_window_create(struct browser_window *bw, option_window_x, option_window_y, option_window_width, option_window_height }; - gui_window_set_url(gw, ""); + gui_window_set_url(gw, corestring_nsurl_about_blank); gui_window_set_pointer(gw, BROWSER_POINTER_DEFAULT); gui_set_input_gui_window(gw); window_open(gw->root, gw, pos); @@ -553,24 +553,24 @@ void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape) } -static nserror gui_window_set_url(struct gui_window *w, const char *url) +static nserror gui_window_set_url(struct gui_window *w, nsurl *url) { int l; if (w == NULL) return; - l = strlen(url)+1; + l = strlen(nsurl_access(url))+1; if (w->url == NULL) { w->url = malloc(l); } else { w->url = realloc(w->url, l); } - strncpy(w->url, url, l); + strncpy(w->url, nsurl_access(url), l); w->url[l] = 0; if(input_window == w->root->active_gui_window) { - toolbar_set_url(w->root->toolbar, url); + toolbar_set_url(w->root->toolbar, nsurl_access(url)); } return NSERROR_OK; diff --git a/cocoa/gui.m b/cocoa/gui.m index c9cef1508..2bce0cd2b 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -194,9 +194,9 @@ static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape } } -static nserror gui_window_set_url(struct gui_window *g, const char *url) +static nserror gui_window_set_url(struct gui_window *g, struct nsurl *url) { - [(BrowserViewController *)g setUrl: [NSString stringWithUTF8String: url]]; + [(BrowserViewController *)g setUrl: [NSString stringWithUTF8String: nsurl_access(url)]]; return NSERROR_OK; } diff --git a/desktop/browser.c b/desktop/browser.c index 82585ab0d..ada46cdd3 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1811,7 +1811,7 @@ browser_window_refresh_url_bar_internal(struct browser_window *bw, nsurl *url) return NSERROR_OK; } - return guit->window->set_url(bw->window, nsurl_access(url)); + return guit->window->set_url(bw->window, url); } diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index e26eccb2d..9be1773c4 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -42,7 +42,7 @@ static void gui_default_window_set_title(struct gui_window *g, const char *title { } -static nserror gui_default_window_set_url(struct gui_window *g, const char *url) +static nserror gui_default_window_set_url(struct gui_window *g, struct nsurl *url) { return NSERROR_OK; } diff --git a/desktop/gui_window.h b/desktop/gui_window.h index 38432f567..a8071a4e9 100644 --- a/desktop/gui_window.h +++ b/desktop/gui_window.h @@ -184,7 +184,7 @@ struct gui_window_table { * \param gw window to update. * \param url The url to use as icon. */ - nserror (*set_url)(struct gui_window *gw, const char *url); + nserror (*set_url)(struct gui_window *gw, struct nsurl *url); /** * Set a favicon for a gui window. diff --git a/framebuffer/gui.c b/framebuffer/gui.c index df7b0e7c7..986c2aee6 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -1896,9 +1896,9 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) } static nserror -gui_window_set_url(struct gui_window *g, const char *url) +gui_window_set_url(struct gui_window *g, nsurl *url) { - fbtk_set_text(g->url, url); + fbtk_set_text(g->url, nsurl_access(url)); return NSERROR_OK; } diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c index e5da52be4..ce3dae962 100644 --- a/gtk/scaffolding.c +++ b/gtk/scaffolding.c @@ -2291,13 +2291,13 @@ void gui_window_set_title(struct gui_window *gw, const char *title) } -nserror gui_window_set_url(struct gui_window *gw, const char *url) +nserror gui_window_set_url(struct gui_window *gw, nsurl *url) { struct nsgtk_scaffolding *g; g = nsgtk_get_scaffold(gw); if (g->top_level == gw) { - gtk_entry_set_text(GTK_ENTRY(g->url_bar), url); + gtk_entry_set_text(GTK_ENTRY(g->url_bar), nsurl_access(url)); gtk_editable_set_position(GTK_EDITABLE(g->url_bar), -1); } return NSERROR_OK; diff --git a/gtk/scaffolding.h b/gtk/scaffolding.h index 07433bffa..7d21a68d7 100644 --- a/gtk/scaffolding.h +++ b/gtk/scaffolding.h @@ -26,6 +26,7 @@ struct bitmap; struct hlcache_handle; struct gui_window; struct gui_search_web_table; +struct nsurl; extern struct gui_search_web_table *nsgtk_search_web_table; @@ -235,7 +236,7 @@ nserror nsgtk_scaffolding_new_tab(struct gui_window *gw); /* core acessors */ void gui_window_set_title(struct gui_window *g, const char *title); -nserror gui_window_set_url(struct gui_window *g, const char *url); +nserror gui_window_set_url(struct gui_window *g, struct nsurl *url); void gui_window_start_throbber(struct gui_window *g); void gui_window_stop_throbber(struct gui_window *g); diff --git a/monkey/browser.c b/monkey/browser.c index 1ebdaecf9..4e9472fa5 100644 --- a/monkey/browser.c +++ b/monkey/browser.c @@ -252,9 +252,9 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) } static nserror -gui_window_set_url(struct gui_window *g, const char *url) +gui_window_set_url(struct gui_window *g, nsurl *url) { - fprintf(stdout, "WINDOW SET_URL WIN %u URL %s\n", g->win_num, url); + fprintf(stdout, "WINDOW SET_URL WIN %u URL %s\n", g->win_num, nsurl_access(url)); return NSERROR_OK; } diff --git a/riscos/gui/url_bar.c b/riscos/gui/url_bar.c index 406fa9da7..b5f6a6e14 100644 --- a/riscos/gui/url_bar.c +++ b/riscos/gui/url_bar.c @@ -851,12 +851,12 @@ bool ro_gui_url_bar_menu_select(struct url_bar *url_bar, wimp_i i, nsurl *url; nserror error; - gui_window_set_url(g, urltxt); - error = nsurl_create(urltxt, &url); if (error != NSERROR_OK) { warn_user(messages_get_errorcode(error), 0); } else { + gui_window_set_url(g, url); + browser_window_navigate(g->bw, url, NULL, diff --git a/riscos/window.c b/riscos/window.c index 74d514693..e247bad5f 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -1051,10 +1051,10 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) /* exported function documented in riscos/window.h */ -nserror gui_window_set_url(struct gui_window *g, const char *url) +nserror gui_window_set_url(struct gui_window *g, nsurl *url) { if (g->toolbar) { - ro_toolbar_set_url(g->toolbar, url, true, false); + ro_toolbar_set_url(g->toolbar, nsurl_access(url), true, false); ro_gui_url_complete_start(g->toolbar); } @@ -3913,12 +3913,13 @@ void ro_gui_window_launch_url(struct gui_window *g, const char *url1) return; ro_gui_url_complete_close(); - gui_window_set_url(g, url1); error = nsurl_create(url1, &url); if (error != NSERROR_OK) { warn_user(messages_get_errorcode(error), 0); } else { + gui_window_set_url(g, url); + browser_window_navigate(g->bw, url, NULL, BW_NAVIGATE_HISTORY, NULL, NULL, NULL); diff --git a/riscos/window.h b/riscos/window.h index ea31fcb9b..08eddb3f7 100644 --- a/riscos/window.h +++ b/riscos/window.h @@ -39,7 +39,7 @@ bool ro_gui_window_check_menu(wimp_menu *menu); * \param g gui_window to update * \param url new url for address bar */ -nserror gui_window_set_url(struct gui_window *g, const char *url); +nserror gui_window_set_url(struct gui_window *g, nsurl *url); #endif diff --git a/windows/gui.c b/windows/gui.c index cc0c05699..653bf44e1 100644 --- a/windows/gui.c +++ b/windows/gui.c @@ -1662,9 +1662,9 @@ struct nsws_pointers *nsws_get_pointers(void) return &nsws_pointer; } -static nserror gui_window_set_url(struct gui_window *w, const char *url) +static nserror gui_window_set_url(struct gui_window *w, nsurl *url) { - SendMessage(w->urlbar, WM_SETTEXT, 0, (LPARAM) url); + SendMessage(w->urlbar, WM_SETTEXT, 0, (LPARAM) nsurl_access(url)); return NSERROR_OK; } -- cgit v1.2.3