From b7736bae2f37675be55b1c89d33b03e8603b2946 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 12 Jan 2014 17:07:34 +0000 Subject: split gui operations into core and window and move more operations into tables --- monkey/browser.c | 39 +++++++++++++++++++++++++-------------- monkey/browser.h | 10 ++-------- monkey/main.c | 11 +++-------- 3 files changed, 30 insertions(+), 30 deletions(-) (limited to 'monkey') diff --git a/monkey/browser.c b/monkey/browser.c index b9e583c1f..ed0398142 100644 --- a/monkey/browser.c +++ b/monkey/browser.c @@ -87,7 +87,7 @@ monkey_kill_browser_windows(void) } } -struct gui_window * +static struct gui_window * gui_window_create(struct browser_window *bw, struct browser_window *clone, bool new_tab) @@ -112,7 +112,7 @@ gui_window_create(struct browser_window *bw, return ret; } -void +static void gui_window_destroy(struct gui_window *g) { fprintf(stdout, "WINDOW DESTROY WIN %u\n", g->win_num); @@ -120,7 +120,7 @@ gui_window_destroy(struct gui_window *g) free(g); } -void +static void gui_window_set_title(struct gui_window *g, const char *title) { fprintf(stdout, "WINDOW TITLE WIN %u STR %s\n", g->win_num, title); @@ -148,19 +148,19 @@ gui_window_new_content(struct gui_window *g) fprintf(stdout, "WINDOW NEW_CONTENT WIN %u\n", g->win_num); } -void +static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon) { fprintf(stdout, "WINDOW NEW_ICON WIN %u\n", g->win_num); } -void +static void gui_window_start_throbber(struct gui_window *g) { fprintf(stdout, "WINDOW START_THROBBER WIN %u\n", g->win_num); } -void +static void gui_window_stop_throbber(struct gui_window *g) { fprintf(stdout, "WINDOW STOP_THROBBER WIN %u\n", g->win_num); @@ -270,7 +270,7 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) fprintf(stdout, "WINDOW SET_POINTER WIN %u POINTER %s\n", g->win_num, ptr_name); } -void +static void gui_window_set_url(struct gui_window *g, const char *url) { fprintf(stdout, "WINDOW SET_URL WIN %u URL %s\n", g->win_num, url); @@ -301,11 +301,6 @@ gui_window_scroll_start(struct gui_window *g) return true; } -void -gui_window_set_search_ico(hlcache_handle *ico) -{ -} - void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int y1) @@ -367,7 +362,7 @@ gui_window_remove_caret(struct gui_window *g) fprintf(stdout, "WINDOW REMOVE_CARET WIN %u\n", g->win_num); } -bool +static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type, const struct rect *rect) { @@ -383,7 +378,7 @@ gui_create_form_select_menu(struct browser_window *bw, bw->window->win_num); } -void +static void gui_window_save_link(struct gui_window *g, const char *url, const char *title) { @@ -567,3 +562,19 @@ monkey_window_handle_command(int argc, char **argv) } } + +static struct gui_window_table gui_window_table = { + .create = gui_window_create, + .destroy = gui_window_destroy, + + .set_title = gui_window_set_title, + .set_url = gui_window_set_url, + .set_icon = gui_window_set_icon, + + .drag_start = gui_window_drag_start, + .save_link = gui_window_save_link, + .start_throbber = gui_window_start_throbber, + .stop_throbber = gui_window_stop_throbber, +}; + +struct gui_window_table *monkey_gui_window_table = &gui_window_table; diff --git a/monkey/browser.h b/monkey/browser.h index ab4e59bbb..892c615ab 100644 --- a/monkey/browser.h +++ b/monkey/browser.h @@ -36,6 +36,8 @@ struct gui_window { }; +extern struct gui_window_table *monkey_gui_window_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); @@ -43,12 +45,4 @@ 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); -void gui_window_set_title(struct gui_window *g, const char *title); -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); - #endif /* NETSURF_MONKEY_BROWSER_H */ diff --git a/monkey/main.c b/monkey/main.c index 73803f536..c6aa60f10 100644 --- a/monkey/main.c +++ b/monkey/main.c @@ -116,14 +116,6 @@ static bool nslog_stream_configure(FILE *fptr) static struct gui_table monkey_gui_table = { .poll = monkey_poll, .quit = monkey_quit, - - .window_create = gui_window_create, - .window_destroy = gui_window_destroy, - - .window_set_title = gui_window_set_title, - .window_set_url = gui_window_set_url, - .window_start_throbber = gui_window_start_throbber, - .window_stop_throbber = gui_window_stop_throbber, }; int @@ -159,6 +151,9 @@ main(int argc, char **argv) /* common initialisation */ messages = filepath_find(respaths, "Messages"); + + monkey_gui_table.window = monkey_gui_window_table; + ret = netsurf_init(messages, &monkey_gui_table); free(messages); if (ret != NSERROR_OK) { -- cgit v1.2.3