From 56bb9582b16dfd45bbd1665adaf87c6c5986aed3 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 12 Jan 2014 10:27:41 +0000 Subject: move set title, set url, start and stop throbber window operations to gui table --- desktop/browser.c | 13 +++++++------ desktop/gui.h | 39 +++++++++++++++++++++++++-------------- desktop/gui_factory.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 61 insertions(+), 21 deletions(-) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index aceb8fb65..e01595fcc 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -866,7 +866,7 @@ static void browser_window_start_throbber(struct browser_window *bw) while (bw->parent) bw = bw->parent; - gui_window_start_throbber(bw->window); + guit->window_start_throbber(bw->window); } @@ -883,8 +883,9 @@ static void browser_window_stop_throbber(struct browser_window *bw) while (bw->parent) bw = bw->parent; - if (!browser_window_check_throbber(bw)) - gui_window_stop_throbber(bw->window); + if (!browser_window_check_throbber(bw)) { + guit->window_stop_throbber(bw->window); + } } @@ -1958,7 +1959,7 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top) case BROWSER_WINDOW_NORMAL: /* Root browser window, constituting a front end window/tab */ - gui_window_set_title(bw->window, + guit->window_set_title(bw->window, content_get_title(bw->current_content)); browser_window_update_extent(bw); @@ -2358,7 +2359,7 @@ void browser_window_refresh_url_bar(struct browser_window *bw, nsurl *url, /* With no fragment, we may as well pass url straight through * saving a malloc, copy, free cycle. */ - gui_window_set_url(bw->window, nsurl_access(url)); + guit->window_set_url(bw->window, nsurl_access(url)); } else { nsurl *display_url; nserror error; @@ -2369,7 +2370,7 @@ void browser_window_refresh_url_bar(struct browser_window *bw, nsurl *url, return; } - gui_window_set_url(bw->window, nsurl_access(display_url)); + guit->window_set_url(bw->window, nsurl_access(display_url)); nsurl_unref(display_url); } } diff --git a/desktop/gui.h b/desktop/gui.h index 940eef0a5..26e1792f8 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -70,28 +70,42 @@ struct form_control; * function table implementing GUI interface to browser core */ struct gui_table { + + /* Mandantory entries */ + /** called to let the frontend update its state and run any * I/O operations. */ - void (*poll)(bool active); /* Mandantory */ + void (*poll)(bool active); - /** create a gui window for a browser window */ - struct gui_window *(*window_create)(struct browser_window *bw, - struct browser_window *clone, - bool new_tab); /* Mandantory */ + /** create a gui window for a browsing context */ + struct gui_window *(*window_create)(struct browser_window *bw, struct browser_window *clone, bool new_tab); /** destroy previously created gui window */ - void (*window_destroy)(struct gui_window *g); /* Mandantory */ + void (*window_destroy)(struct gui_window *g); + /* Optional entries */ + /** called to allow the gui to cleanup */ - void (*quit)(void); /* Optional */ + void (*quit)(void); + + /** set the window title. */ + void (*window_set_title)(struct gui_window *g, const char *title); + + /** set the navigation url. */ + void (*window_set_url)(struct gui_window *g, const char *url); + + /** start the navigation throbber. */ + void (*window_start_throbber)(struct gui_window *g); + + /** stop the navigation throbber. */ + void (*window_stop_throbber)(struct gui_window *g); }; extern struct gui_table *guit; /* the gui vtable */ -void gui_window_set_title(struct gui_window *g, const char *title); void gui_window_redraw_window(struct gui_window *g); void gui_window_update_box(struct gui_window *g, const struct rect *rect); @@ -105,9 +119,6 @@ void gui_window_update_extent(struct gui_window *g); void gui_window_set_status(struct gui_window *g, const char *text); void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape); void gui_window_hide_pointer(struct gui_window *g); -void gui_window_set_url(struct gui_window *g, const char *url); -void gui_window_start_throbber(struct gui_window *g); -void gui_window_stop_throbber(struct gui_window *g); void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon); void gui_window_set_search_ico(hlcache_handle *ico); void gui_window_place_caret(struct gui_window *g, int x, int y, int height, @@ -119,12 +130,12 @@ bool gui_window_scroll_start(struct gui_window *g); bool gui_window_drag_start(struct gui_window *g, gui_drag_type type, const struct rect *rect); -void gui_window_save_link(struct gui_window *g, const char *url, +void gui_window_save_link(struct gui_window *g, const char *url, const char *title); struct gui_download_window *gui_download_window_create(download_context *ctx, struct gui_window *parent); -nserror gui_download_window_data(struct gui_download_window *dw, +nserror gui_download_window_data(struct gui_download_window *dw, const char *data, unsigned int size); void gui_download_window_error(struct gui_download_window *dw, const char *error_msg); @@ -172,7 +183,7 @@ void gui_launch_url(const char *url); struct ssl_cert_info; -void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, +void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw); diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index 9a4fa396a..c760218ec 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -9,6 +9,22 @@ static void gui_default_quit(void) { } +static void gui_default_window_set_title(struct gui_window *g, const char *title) +{ +} + +static void gui_default_window_set_url(struct gui_window *g, const char *url) +{ +} + +static void gui_default_window_start_throbber(struct gui_window *g) +{ +} + +static void gui_default_window_stop_throbber(struct gui_window *g) +{ +} + nserror gui_factory_register(struct gui_table *gt) { /* ensure not already initialised */ @@ -31,7 +47,19 @@ nserror gui_factory_register(struct gui_table *gt) /* fill in the optional entries with defaults */ if (gt->quit == NULL) { - gt->quit = &gui_default_quit; + gt->quit = gui_default_quit; + } + if (gt->window_set_title == NULL) { + gt->window_set_title = gui_default_window_set_title; + } + if (gt->window_set_url == NULL) { + gt->window_set_url = gui_default_window_set_url; + } + if (gt->window_start_throbber == NULL) { + gt->window_start_throbber = gui_default_window_start_throbber; + } + if (gt->window_stop_throbber == NULL) { + gt->window_stop_throbber = gui_default_window_stop_throbber; } guit = gt; -- cgit v1.2.3