From c8496df3df7d059528f2d5e735be5c55bfa75ef6 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 11 Jan 2014 22:34:12 +0000 Subject: move window creation and destruction into table --- desktop/browser.c | 6 ++---- desktop/gui.h | 14 ++++++++++---- desktop/gui_factory.c | 9 ++++++++- 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index 6ec31d22f..aceb8fb65 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -732,9 +732,7 @@ browser_window_create(enum browser_window_nav_flags flags, * so find that. */ top = browser_window_get_root(clone); - bw->window = gui_create_browser_window(bw, - top, - ((flags & BROWSER_WINDOW_TAB) != 0)); + bw->window = guit->window_create(bw, top, ((flags & BROWSER_WINDOW_TAB) != 0)); if (bw->window == NULL) { browser_window_destroy(bw); @@ -1644,7 +1642,7 @@ void browser_window_destroy_internal(struct browser_window *bw) if (bw->window) { /* Only the root window has a GUI window */ - gui_window_destroy(bw->window); + guit->window_destroy(bw->window); } if (bw->loading_content != NULL) { diff --git a/desktop/gui.h b/desktop/gui.h index 2bda996fd..940eef0a5 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -75,16 +75,22 @@ struct gui_table { */ void (*poll)(bool active); /* Mandantory */ + /** 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 */ + + /** destroy previously created gui window */ + void (*window_destroy)(struct gui_window *g); /* Mandantory */ + + /** called to allow the gui to cleanup */ - void (*quit)(void); /* optional */ + void (*quit)(void); /* Optional */ }; extern struct gui_table *guit; /* the gui vtable */ -struct gui_window *gui_create_browser_window(struct browser_window *bw, - struct browser_window *clone, bool new_tab); -void gui_window_destroy(struct gui_window *g); 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, diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index fe7536353..9a4fa396a 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -16,11 +16,18 @@ nserror gui_factory_register(struct gui_table *gt) return NSERROR_INIT_FAILED; } - /* check the mandantory fields are set */ + /* check the mandantory fields are set */ if (gt->poll == NULL) { return NSERROR_BAD_PARAMETER; } + if (gt->window_create == NULL) { + return NSERROR_BAD_PARAMETER; + } + if (gt->window_destroy == NULL) { + return NSERROR_BAD_PARAMETER; + } + /* fill in the optional entries with defaults */ if (gt->quit == NULL) { -- cgit v1.2.3