move window creation and destruction into table

This commit is contained in:
Vincent Sanders 2014-01-11 22:34:12 +00:00
parent d3c392c3d3
commit c8496df3df
22 changed files with 118 additions and 61 deletions

View File

@ -3083,8 +3083,10 @@ nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
return NSERROR_OK;
}
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone, bool new_tab)
static struct gui_window *
gui_window_create(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
{
struct gui_window *g = NULL;
bool closegadg=TRUE;
@ -3788,7 +3790,7 @@ void ami_close_all_tabs(struct gui_window_2 *gwin)
}
}
void gui_window_destroy(struct gui_window *g)
static void gui_window_destroy(struct gui_window *g)
{
struct Node *ptab;
ULONG ptabnum = 0;
@ -5091,8 +5093,10 @@ void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
}
static struct gui_table ami_gui_table = {
.poll = &gui_poll,
.quit = &gui_quit,
.poll = gui_poll,
.quit = gui_quit,
.window_create = gui_window_create,
.window_destroy = gui_window_destroy,
};
/** Normal entry point from OS */

View File

@ -186,10 +186,10 @@ static void gui_poll(bool active)
}
struct gui_window *
gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone,
bool new_tab) {
static struct gui_window *
gui_window_create(struct browser_window *bw,
struct browser_window *clone,
bool new_tab) {
struct gui_window *gw=NULL;
LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
(int)new_tab
@ -233,7 +233,7 @@ gui_create_browser_window(struct browser_window *bw,
}
void gui_window_destroy(struct gui_window *w)
static void gui_window_destroy(struct gui_window *w)
{
if (w == NULL)
return;
@ -1101,13 +1101,15 @@ static void gui_init2(int argc, char** argv)
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget)
{
LOG(("File open dialog rquest for %p/%p", g, gadget));
/* browser_window_set_gadget_filename(bw, gadget, "filename"); */
LOG(("File open dialog rquest for %p/%p", g, gadget));
/* browser_window_set_gadget_filename(bw, gadget, "filename"); */
}
static struct gui_table atari_gui_table = {
.poll = &gui_poll,
.quit = &gui_quit,
.poll = gui_poll,
.quit = gui_quit,
.window_create = gui_window_create,
.window_destroy = gui_window_destroy,
};
/* #define WITH_DBG_LOGFILE 1 */

View File

@ -1087,8 +1087,10 @@ void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
static struct gui_table beos_gui_table = {
.poll = &gui_poll,
.quit = &gui_quit,
.poll = gui_poll,
.quit = gui_quit,
.window_create = gui_window_create,
.window_destroy = gui_window_destroy,
};

View File

@ -335,8 +335,9 @@ float nsbeos_get_scale_for_gui(struct gui_window *g)
}
/* Create a gui_window */
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone, bool new_tab)
struct gui_window *gui_window_create(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
{
struct gui_window *g; /**< what we're creating to return */

View File

@ -61,4 +61,10 @@ void nsbeos_window_destroy_browser(struct gui_window *g);
struct browser_window *nsbeos_get_browser_window(struct gui_window *g);
struct gui_window *gui_window_create(struct browser_window *bw,
struct browser_window *clone,
bool new_tab);
void gui_window_destroy(struct gui_window *g);
#endif /* NETSURF_BEOS_WINDOW_H */

View File

@ -70,8 +70,9 @@ static void gui_poll(bool active)
struct browser_window;
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone, bool new_tab)
static struct gui_window *gui_window_create(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
{
BrowserWindowController *window = nil;
@ -93,7 +94,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
return (struct gui_window *)result;
}
void gui_window_destroy(struct gui_window *g)
static void gui_window_destroy(struct gui_window *g)
{
BrowserViewController *vc = (BrowserViewController *)g;
@ -329,6 +330,8 @@ void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
static struct gui_table gui_table = {
.poll = &gui_poll,
.window_create = gui_window_create,
.window_destroy = gui_window_destroy,
};
struct gui_table *cocoa_gui_table = &gui_table;

View File

@ -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) {

View File

@ -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,

View File

@ -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) {

View File

@ -1501,10 +1501,10 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width)
}
struct gui_window *
gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
static struct gui_window *
gui_window_create(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
{
struct gui_window *gw;
@ -1527,7 +1527,7 @@ gui_create_browser_window(struct browser_window *bw,
return gw;
}
void
static void
gui_window_destroy(struct gui_window *gw)
{
fbtk_destroy_widget(gw->window);
@ -1901,8 +1901,10 @@ void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
static struct gui_table framebuffer_gui_table = {
.poll = &gui_poll,
.quit = &gui_quit,
.poll = gui_poll,
.quit = gui_quit,
.window_create = gui_window_create,
.window_destroy = gui_window_destroy,
};
/** Entry point from OS.

View File

@ -1133,8 +1133,10 @@ bool path_add_part(char *path, int length, const char *newpart)
static struct gui_table nsgtk_gui_table = {
.poll = &gui_poll,
.quit = &gui_quit,
.poll = gui_poll,
.quit = gui_quit,
.window_create = gui_window_create,
.window_destroy = gui_window_destroy,
};
/**

View File

@ -655,10 +655,11 @@ static void window_destroy(GtkWidget *widget, gpointer data)
browser_window_destroy(gw->bw);
}
/* Core interface docuemnted in desktop/gui.h to create a gui_window */
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
/* Core interface documented in desktop/gui.h to create a gui_window */
struct gui_window *
gui_window_create(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
{
struct gui_window *g; /**< what we're creating to return */
GError* error = NULL;

View File

@ -48,5 +48,7 @@ struct gui_window *nsgtk_window_iterate(struct gui_window *g);
GtkWidget *nsgtk_window_get_tab(struct gui_window *g);
void nsgtk_window_set_tab(struct gui_window *g, GtkWidget *w);
struct gui_window *gui_window_create(struct browser_window *bw, struct browser_window *clone, bool new_tab);
void gui_window_destroy(struct gui_window *g);
#endif /* NETSURF_GTK_WINDOW_H */

View File

@ -88,8 +88,9 @@ monkey_kill_browser_windows(void)
}
struct gui_window *
gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone, bool new_tab)
gui_window_create(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
{
struct gui_window *ret = calloc(sizeof(*ret), 1);
if (ret == NULL)

View File

@ -42,4 +42,9 @@ void monkey_window_process_reformats(void);
void monkey_window_handle_command(int argc, char **argv);
void monkey_kill_browser_windows(void);
struct gui_window *gui_window_create(struct browser_window *bw, struct browser_window *clone, bool new_tab);
void gui_window_destroy(struct gui_window *g);
#endif /* NETSURF_MONKEY_BROWSER_H */

View File

@ -55,7 +55,7 @@ nsmonkey_init_resource(const char *resource_path)
return respath;
}
static void gui_quit(void)
static void monkey_quit(void)
{
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
@ -114,8 +114,10 @@ static bool nslog_stream_configure(FILE *fptr)
}
static struct gui_table monkey_gui_table = {
.poll = &monkey_poll,
.quit = &gui_quit,
.poll = monkey_poll,
.quit = monkey_quit,
.window_create = gui_window_create,
.window_destroy = gui_window_destroy,
};
int

View File

@ -838,8 +838,10 @@ static bool nslog_stream_configure(FILE *fptr)
}
static struct gui_table riscos_gui_table = {
.poll = &gui_poll,
.quit = &gui_quit,
.poll = gui_poll,
.quit = gui_quit,
.window_create = gui_window_create,
.window_destroy = gui_window_destroy,
};

View File

@ -379,7 +379,7 @@ void ro_gui_window_initialise(void)
* \return gui_window, or 0 on error and error reported
*/
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct gui_window *gui_window_create(struct browser_window *bw,
struct browser_window *clone, bool new_tab)
{
int screen_width, screen_height, win_width, win_height, scroll_width;

View File

@ -29,5 +29,9 @@ void ro_gui_window_initialise(void);
bool ro_gui_window_check_menu(wimp_menu *menu);
struct gui_window *gui_window_create(struct browser_window *bw, struct browser_window *clone, bool new_tab);
void gui_window_destroy(struct gui_window *g);
#endif

View File

@ -80,7 +80,7 @@ void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
/* browser_window_set_gadget_filename(bw, gadget, "filename"); */
}
void gui_poll(bool active)
static void gui_poll(bool active)
{
MSG Msg; /* message from system */
BOOL bRet; /* message fetch result */
@ -1220,10 +1220,10 @@ static HWND nsws_window_create(struct gui_window *gw)
* create a new gui_window to contain a browser_window
* \param bw the browser_window to connect to the new gui_window
*/
struct gui_window *
gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
static struct gui_window *
gui_window_create(struct browser_window *bw,
struct browser_window *clone,
bool new_tab)
{
struct gui_window *gw;
@ -1399,7 +1399,7 @@ struct browser_window *gui_window_browser_window(struct gui_window *w)
/**
* window cleanup code
*/
void gui_window_destroy(struct gui_window *w)
static void gui_window_destroy(struct gui_window *w)
{
if (w == NULL)
return;
@ -1883,3 +1883,11 @@ nsws_create_main_class(HINSTANCE hinstance) {
return ret;
}
static struct gui_table gui_table = {
.poll = gui_poll,
.window_create = gui_window_create,
.window_destroy = gui_window_destroy,
};
struct gui_table *win32_gui_table = &gui_table;

View File

@ -24,6 +24,8 @@
#include "desktop/gui.h"
#include "windows/localhistory.h"
extern struct gui_table *win32_gui_table;
extern HINSTANCE hInstance;
/* bounding box */

View File

@ -91,9 +91,6 @@ static nserror set_defaults(struct nsoption_s *defaults)
return NSERROR_OK;
}
static struct gui_table win32_gui_table = {
.poll = &gui_poll,
};
/**
@ -157,7 +154,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
/* common initialisation */
messages = filepath_find(respaths, "messages");
ret = netsurf_init(messages, &win32_gui_table);
ret = netsurf_init(messages, win32_gui_table);
free(messages);
if (ret != NSERROR_OK) {
free(options_file_location);