summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2014-01-16 13:37:14 +0000
committerVincent Sanders <vince@netsurf-browser.org>2014-01-16 13:37:14 +0000
commita1361f22b43e78b00cdddab3a0a2b9e4871965f7 (patch)
tree0d7a34e8035a06a8cbffa9678ad8689f953281d2
parent444d3ac94a1d19a30963c38ad605deec778f3c27 (diff)
parenta2247a75a3dab9d583617299a88d0e76c923f83b (diff)
downloadnetsurf-a1361f22b43e78b00cdddab3a0a2b9e4871965f7.tar.gz
netsurf-a1361f22b43e78b00cdddab3a0a2b9e4871965f7.tar.bz2
Merge branch 'vince/guivtable'
-rw-r--r--amiga/clipboard.c11
-rwxr-xr-xamiga/clipboard.h5
-rwxr-xr-xamiga/context_menu.h3
-rw-r--r--amiga/download.c17
-rwxr-xr-xamiga/download.h5
-rw-r--r--amiga/drag.c4
-rw-r--r--amiga/drag.h3
-rw-r--r--amiga/gui.c441
-rwxr-xr-xamiga/launch.h3
-rwxr-xr-xamiga/login.c1
-rwxr-xr-xamiga/login.h4
-rwxr-xr-xamiga/misc.c27
-rw-r--r--amiga/sslcert.h4
-rw-r--r--amiga/theme.c5
-rw-r--r--amiga/theme.h5
-rw-r--r--atari/ctxmenu.c1
-rwxr-xr-xatari/download.c19
-rwxr-xr-xatari/download.h2
-rw-r--r--atari/gui.c207
-rwxr-xr-xatari/gui.h5
-rwxr-xr-xatari/login.c3
-rwxr-xr-xatari/misc.c22
-rwxr-xr-xatari/misc.h2
-rwxr-xr-xatari/rootwin.c2
-rw-r--r--beos/download.cpp17
-rw-r--r--beos/download.h1
-rw-r--r--beos/gui.cpp298
-rw-r--r--beos/gui.h3
-rw-r--r--beos/login.cpp1
-rw-r--r--beos/scaffolding.cpp13
-rw-r--r--beos/scaffolding.h6
-rw-r--r--beos/window.cpp92
-rw-r--r--beos/window.h6
-rw-r--r--cocoa/DownloadWindowController.h2
-rw-r--r--cocoa/DownloadWindowController.m17
-rw-r--r--cocoa/NetsurfApp.m8
-rw-r--r--cocoa/gui.h4
-rw-r--r--cocoa/gui.m160
-rw-r--r--cocoa/selection.h2
-rw-r--r--cocoa/selection.m10
-rw-r--r--cocoa/utils.m13
-rw-r--r--content/fetchers/curl.c3
-rw-r--r--content/fetchers/file.c3
-rw-r--r--content/fetchers/resource.c3
-rw-r--r--desktop/Makefile2
-rw-r--r--desktop/browser.c92
-rw-r--r--desktop/download.c9
-rw-r--r--desktop/gui.h408
-rw-r--r--desktop/gui_factory.c440
-rw-r--r--desktop/gui_factory.h (renamed from desktop/401login.h)26
-rw-r--r--desktop/netsurf.c18
-rw-r--r--desktop/netsurf.h4
-rw-r--r--desktop/save_complete.c7
-rw-r--r--desktop/searchweb.c3
-rw-r--r--desktop/selection.c9
-rw-r--r--desktop/textarea.c6
-rw-r--r--desktop/textinput.c8
-rw-r--r--framebuffer/Makefile.target2
-rw-r--r--framebuffer/clipboard.c13
-rw-r--r--framebuffer/clipboard.h (renamed from framebuffer/login.c)11
-rw-r--r--framebuffer/findfile.h4
-rw-r--r--framebuffer/gui.c385
-rw-r--r--framebuffer/misc.c37
-rw-r--r--gtk/dialogs/preferences.c4
-rw-r--r--gtk/download.c30
-rw-r--r--gtk/download.h2
-rw-r--r--gtk/gui.c240
-rw-r--r--gtk/gui.h6
-rw-r--r--gtk/login.c1
-rw-r--r--gtk/scaffolding.c5
-rw-r--r--gtk/scaffolding.h7
-rw-r--r--gtk/selection.c11
-rw-r--r--gtk/selection.h4
-rw-r--r--gtk/toolbar.c4
-rw-r--r--gtk/window.c137
-rw-r--r--gtk/window.h3
-rw-r--r--monkey/401login.c3
-rw-r--r--monkey/401login.h9
-rw-r--r--monkey/browser.c142
-rw-r--r--monkey/browser.h4
-rw-r--r--monkey/cert.c6
-rw-r--r--monkey/cert.h4
-rw-r--r--monkey/download.c17
-rw-r--r--monkey/main.c65
-rw-r--r--monkey/poll.c2
-rw-r--r--monkey/poll.h2
-rw-r--r--monkey/utils.c38
-rw-r--r--render/html_interaction.c3
-rw-r--r--riscos/401login.c1
-rw-r--r--riscos/download.c17
-rw-r--r--riscos/gui.c191
-rw-r--r--riscos/gui.h14
-rw-r--r--riscos/print.c1
-rw-r--r--riscos/query.h4
-rw-r--r--riscos/save.c4
-rw-r--r--riscos/save.h3
-rw-r--r--riscos/textselection.c14
-rw-r--r--riscos/textselection.h2
-rw-r--r--riscos/window.c149
-rw-r--r--riscos/window.h2
-rw-r--r--utils/utils.h6
-rw-r--r--windows/Makefile.target2
-rw-r--r--windows/download.c18
-rw-r--r--windows/download.h2
-rw-r--r--windows/drawable.c2
-rw-r--r--windows/gui.c221
-rw-r--r--windows/gui.h4
-rw-r--r--windows/login.c25
-rw-r--r--windows/main.c22
-rw-r--r--windows/misc.c38
110 files changed, 2555 insertions, 1883 deletions
diff --git a/amiga/clipboard.c b/amiga/clipboard.c
index d37fb1aec..18598798c 100644
--- a/amiga/clipboard.c
+++ b/amiga/clipboard.c
@@ -107,17 +107,6 @@ void gui_start_selection(struct gui_window *g)
OnMenu(g->shared->win, AMI_MENU_CUT);
}
-void gui_clear_selection(struct gui_window *g)
-{
- if(!g) return;
- if(!g->shared->win) return;
- if(nsoption_bool(kiosk_mode) == true) return;
-
- OffMenu(g->shared->win, AMI_MENU_CLEAR);
- OffMenu(g->shared->win, AMI_MENU_CUT);
- OffMenu(g->shared->win, AMI_MENU_COPY);
-}
-
char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length)
{
struct CollectionItem *ci_new = NULL, *ci_next, *ci_curr = ci;
diff --git a/amiga/clipboard.h b/amiga/clipboard.h
index cf3f74087..57004547d 100755
--- a/amiga/clipboard.h
+++ b/amiga/clipboard.h
@@ -26,6 +26,11 @@ struct selection;
struct gui_window;
struct gui_window_2;
+void gui_start_selection(struct gui_window *g);
+void gui_get_clipboard(char **buffer, size_t *length);
+void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles);
+
+
void ami_clipboard_init(void);
void ami_clipboard_free(void);
void ami_drag_selection(struct gui_window *g);
diff --git a/amiga/context_menu.h b/amiga/context_menu.h
index 60224f4e6..69ccdff68 100755
--- a/amiga/context_menu.h
+++ b/amiga/context_menu.h
@@ -27,4 +27,7 @@ void ami_context_menu_free(void);
BOOL ami_context_menu_mouse_trap(struct gui_window_2 *gwin, BOOL trap);
void ami_context_menu_show(struct gui_window_2 *gwin, int x, int y);
void ami_context_menu_show_tree(struct tree *tree, struct Window *win, int type);
+
+void gui_create_form_select_menu(struct browser_window *bw, struct form_control *control);
+
#endif
diff --git a/amiga/download.c b/amiga/download.c
index d33b723d1..4f4c39b20 100644
--- a/amiga/download.c
+++ b/amiga/download.c
@@ -85,7 +85,7 @@ enum {
int downloads_in_progress = 0;
-struct gui_download_window *gui_download_window_create(download_context *ctx,
+static struct gui_download_window *gui_download_window_create(download_context *ctx,
struct gui_window *gui)
{
const char *url = download_context_get_url(ctx);
@@ -193,7 +193,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
return dw;
}
-nserror gui_download_window_data(struct gui_download_window *dw,
+static nserror gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
APTR va[3];
@@ -227,7 +227,7 @@ nserror gui_download_window_data(struct gui_download_window *dw,
return NSERROR_OK;
}
-void gui_download_window_error(struct gui_download_window *dw,
+static void gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
warn_user("Unwritten","");
@@ -242,7 +242,7 @@ void ami_download_window_abort(struct gui_download_window *dw)
gui_download_window_done(dw);
}
-void gui_download_window_done(struct gui_download_window *dw)
+static void gui_download_window_done(struct gui_download_window *dw)
{
struct dlnode *dln,*dln2 = NULL;
struct browser_window *bw = dw->bw;
@@ -432,3 +432,12 @@ BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG si
if(res == 1) return TRUE;
else return FALSE;
}
+
+static struct gui_download_table download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
+
+struct gui_download_table *amiga_download_table = &download_table;
diff --git a/amiga/download.h b/amiga/download.h
index ed09a8057..95d71ecfe 100755
--- a/amiga/download.h
+++ b/amiga/download.h
@@ -23,6 +23,8 @@
#include "amiga/gui.h"
+extern struct gui_download_table *amiga_download_table;
+
struct download_context;
struct gui_download_window;
@@ -36,4 +38,7 @@ void ami_download_window_abort(struct gui_download_window *dw);
BOOL ami_download_window_event(struct gui_download_window *dw);
void ami_free_download_list(struct List *dllist);
BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG size);
+
+void gui_window_save_link(struct gui_window *g, const char *url, const char *title);
+
#endif
diff --git a/amiga/drag.c b/amiga/drag.c
index 1123ba265..f8944d3a5 100644
--- a/amiga/drag.c
+++ b/amiga/drag.c
@@ -50,8 +50,8 @@ ULONG drag_icon_width;
ULONG drag_icon_height;
BOOL drag_in_progress = FALSE;
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *g)
+void gui_drag_save_object(struct gui_window *g, hlcache_handle *c,
+ gui_save_type type)
{
const char *filetype = NULL;
diff --git a/amiga/drag.h b/amiga/drag.h
index 218aa67f8..cfe9719ce 100644
--- a/amiga/drag.h
+++ b/amiga/drag.h
@@ -26,6 +26,9 @@ int drag_save;
void *drag_save_data;
struct gui_window *drag_save_gui;
+void gui_drag_save_selection(struct gui_window *g, const char *selection);
+void gui_drag_save_object(struct gui_window *g, hlcache_handle *c, gui_save_type type);
+
void ami_drag_save(struct Window *win);
void ami_drag_icon_show(struct Window *win, const char *type);
void ami_drag_icon_close(struct Window *win);
diff --git a/amiga/gui.c b/amiga/gui.c
index 3140bb61e..ad172207b 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -200,12 +200,42 @@ static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw);
static void ami_do_redraw(struct gui_window_2 *g);
static void ami_schedule_redraw_remove(struct gui_window_2 *gwin);
+static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy);
+static void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
+
/* accessors for default options - user option is updated if it is set as per default */
#define nsoption_default_set_int(OPTION, VALUE) \
if (nsoptions_default[NSOPTION_##OPTION].value.i == nsoptions[NSOPTION_##OPTION].value.i) \
nsoptions[NSOPTION_##OPTION].value.i = VALUE; \
nsoptions_default[NSOPTION_##OPTION].value.i = VALUE
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+
+static char *filename_from_path(char *path)
+{
+ return strdup(FilePart(path));
+}
+
+/**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+
+static bool path_add_part(char *path, int length, const char *newpart)
+{
+ if(AddPart(path, newpart, length)) return true;
+ else return false;
+}
+
STRPTR ami_locale_langs(void)
{
struct Locale *locale;
@@ -621,7 +651,7 @@ void ami_amiupdate(void)
}
}
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
char buf[1024];
char path2[1024];
@@ -993,93 +1023,6 @@ static void gui_init2(int argc, char** argv)
}
}
-/** Normal entry point from OS */
-int main(int argc, char** argv)
-{
- setbuf(stderr, NULL);
- char messages[100];
- char script[1024];
- char temp[1024];
- BPTR lock = 0;
- int32 user = 0;
- nserror ret;
- Object *splash_window = ami_gui_splash_open();
-
- /* Open popupmenu.library just to check the version.
- * Versions older than 53.11 are dangerous, so we
- * forcibly disable context menus if these are in use.
- */
- popupmenu_lib_ok = FALSE;
- if(PopupMenuBase = OpenLibrary("popupmenu.library", 53)) {
- LOG(("popupmenu.library v%d.%d",
- PopupMenuBase->lib_Version, PopupMenuBase->lib_Revision));
- if(LIB_IS_AT_LEAST((struct Library *)PopupMenuBase, 53, 11))
- popupmenu_lib_ok = TRUE;
- CloseLibrary(PopupMenuBase);
- }
-
- user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
- current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
- current_user_dir = ASPrintf("PROGDIR:Users/%s", current_user);
-
- if(lock = CreateDirTree(current_user_dir))
- UnLock(lock);
-
- current_user_options = ASPrintf("%s/Choices", current_user_dir);
-
- ami_mime_init("PROGDIR:Resources/mimetypes");
- sprintf(temp, "%s/mimetypes.user", current_user_dir);
- ami_mime_init(temp);
- ami_schedule_open_timer();
- ami_schedule_create();
-
- amiga_plugin_hack_init();
- amiga_datatypes_init();
-
- /* initialise logging. Not fatal if it fails but not much we
- * can do about it either.
- */
- nslog_init(NULL, &argc, argv);
-
- /* user options setup */
- ret = nsoption_init(ami_set_options, &nsoptions, &nsoptions_default);
- if (ret != NSERROR_OK) {
- die("Options failed to initialise");
- }
- nsoption_read(current_user_options, NULL);
- nsoption_commandline(&argc, argv, NULL);
-
- if(ami_locate_resource(messages, "Messages") == false)
- die("Cannot open Messages file");
-
- ret = netsurf_init(messages);
- if (ret != NSERROR_OK) {
- die("NetSurf failed to initialise");
- }
-
- amiga_icon_init();
-
- gui_init(argc, argv);
- gui_init2(argc, argv);
-
- ami_gui_splash_close(splash_window);
-
- strlcpy(script, nsoption_charp(arexx_dir), 1024);
- AddPart(script, nsoption_charp(arexx_startup), 1024);
- ami_arexx_execute(script);
-
- netsurf_main_loop();
-
- strlcpy(script, nsoption_charp(arexx_dir), 1024);
- AddPart(script, nsoption_charp(arexx_shutdown), 1024);
- ami_arexx_execute(script);
-
- netsurf_exit();
-
- ami_mime_free();
-
- return 0;
-}
void ami_gui_history(struct gui_window_2 *gwin, bool back)
{
@@ -1405,6 +1348,69 @@ void ami_gui_menu_update_all(void)
} while(node = nnode);
}
+/**
+ * function to add retrieved favicon to gui
+ */
+static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
+{
+ struct BitMap *bm = NULL;
+ struct IBox *bbox;
+ ULONG cur_tab = 0;
+ struct bitmap *icon_bitmap;
+
+ if(nsoption_bool(kiosk_mode) == true) return;
+ if(!g) return;
+
+ if(g->tab_node && (g->shared->tabs > 1)) GetAttr(CLICKTAB_Current,
+ g->shared->objects[GID_TABS],
+ (ULONG *)&cur_tab);
+
+ if ((icon != NULL) && ((icon_bitmap = content_get_bitmap(icon)) != NULL))
+ {
+ bm = ami_bitmap_get_native(icon_bitmap, 16, 16,
+ g->shared->win->RPort->BitMap);
+ }
+
+ if((cur_tab == g->tab) || (g->shared->tabs <= 1))
+ {
+ GetAttr(SPACE_AreaBox, g->shared->objects[GID_ICON], (ULONG *)&bbox);
+
+ RefreshGList((struct Gadget *)g->shared->objects[GID_ICON],
+ g->shared->win, NULL, 1);
+
+ if(bm)
+ {
+ ULONG tag, tag_data, minterm;
+
+ if(ami_plot_screen_is_palettemapped() == false) {
+ tag = BLITA_UseSrcAlpha;
+ tag_data = !icon_bitmap->opaque;
+ minterm = 0xc0;
+ } else {
+ tag = BLITA_MaskPlane;
+ tag_data = (ULONG)ami_bitmap_get_mask(icon_bitmap, 16, 16, bm);
+ minterm = (ABC|ABNC|ANBC);
+ }
+
+ BltBitMapTags(BLITA_SrcX, 0,
+ BLITA_SrcY, 0,
+ BLITA_DestX, bbox->Left,
+ BLITA_DestY, bbox->Top,
+ BLITA_Width, 16,
+ BLITA_Height, 16,
+ BLITA_Source, bm,
+ BLITA_Dest, g->shared->win->RPort,
+ BLITA_SrcType, BLITT_BITMAP,
+ BLITA_DestType, BLITT_RASTPORT,
+ BLITA_Minterm, minterm,
+ tag, tag_data,
+ TAG_DONE);
+ }
+ }
+
+ g->favicon = icon;
+}
+
void ami_handle_msg(void)
{
struct IntuiMessage *message = NULL;
@@ -2253,7 +2259,7 @@ void ami_handle_msg(void)
if(refresh_search_ico)
{
- gui_window_set_search_ico(NULL);
+ gui_set_search_ico(NULL);
refresh_search_ico = FALSE;
}
@@ -2567,7 +2573,7 @@ static void ami_gui_fetch_callback(void *p)
*/
}
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
if(active) schedule(0, ami_gui_fetch_callback, NULL);
ami_get_msg();
@@ -2749,7 +2755,7 @@ void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen)
CloseScreen(scrn);
}
-void gui_quit(void)
+static void gui_quit(void)
{
int i;
@@ -3170,8 +3176,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;
@@ -3875,7 +3883,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;
@@ -3981,7 +3989,7 @@ void gui_window_destroy(struct gui_window *g)
win_destroyed = true;
}
-void gui_window_set_title(struct gui_window *g, const char *title)
+static void gui_window_set_title(struct gui_window *g, const char *title)
{
struct Node *node;
ULONG cur_tab = 0;
@@ -4206,7 +4214,7 @@ static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw
return;
}
-void gui_window_redraw_window(struct gui_window *g)
+static void gui_window_redraw_window(struct gui_window *g)
{
ULONG cur_tab = 0;
@@ -4284,7 +4292,7 @@ struct nsObject *nnode;
return true;
}
-void gui_window_update_box(struct gui_window *g, const struct rect *rect)
+static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
{
struct nsObject *nsobj;
struct rect *deferred_rect;
@@ -4502,13 +4510,13 @@ void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys)
*ys /= gwin->bw->scale;
}
-bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
ami_get_hscroll_pos(g->shared, (ULONG *)sx);
ami_get_vscroll_pos(g->shared, (ULONG *)sy);
}
-void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
struct IBox *bbox;
ULONG cur_tab = 0;
@@ -4567,13 +4575,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
// g->shared->new_content = false;
}
-void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
- int x1, int y1)
-{
- gui_window_set_scroll(g, x0, y0);
-}
-
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
{
struct IBox *bbox;
@@ -4591,7 +4593,7 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
}
}
-void gui_window_update_extent(struct gui_window *g)
+static void gui_window_update_extent(struct gui_window *g)
{
struct IBox *bbox, zbox;
ULONG cur_tab = 0;
@@ -4638,7 +4640,7 @@ void gui_window_update_extent(struct gui_window *g)
g->shared->new_content = true;
}
-void gui_window_set_status(struct gui_window *g, const char *text)
+static void gui_window_set_status(struct gui_window *g, const char *text)
{
ULONG cur_tab = 0;
char *utf8text;
@@ -4677,7 +4679,7 @@ void gui_window_set_status(struct gui_window *g, const char *text)
}
}
-void gui_window_set_url(struct gui_window *g, const char *url)
+static void gui_window_set_url(struct gui_window *g, const char *url)
{
ULONG cur_tab = 0;
@@ -4696,68 +4698,6 @@ void gui_window_set_url(struct gui_window *g, const char *url)
ami_update_buttons(g->shared);
}
-/**
- * function to add retrieved favicon to gui
- */
-void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
-{
- struct BitMap *bm = NULL;
- struct IBox *bbox;
- ULONG cur_tab = 0;
- struct bitmap *icon_bitmap;
-
- if(nsoption_bool(kiosk_mode) == true) return;
- if(!g) return;
-
- if(g->tab_node && (g->shared->tabs > 1)) GetAttr(CLICKTAB_Current,
- g->shared->objects[GID_TABS],
- (ULONG *)&cur_tab);
-
- if ((icon != NULL) && ((icon_bitmap = content_get_bitmap(icon)) != NULL))
- {
- bm = ami_bitmap_get_native(icon_bitmap, 16, 16,
- g->shared->win->RPort->BitMap);
- }
-
- if((cur_tab == g->tab) || (g->shared->tabs <= 1))
- {
- GetAttr(SPACE_AreaBox, g->shared->objects[GID_ICON], (ULONG *)&bbox);
-
- RefreshGList((struct Gadget *)g->shared->objects[GID_ICON],
- g->shared->win, NULL, 1);
-
- if(bm)
- {
- ULONG tag, tag_data, minterm;
-
- if(ami_plot_screen_is_palettemapped() == false) {
- tag = BLITA_UseSrcAlpha;
- tag_data = !icon_bitmap->opaque;
- minterm = 0xc0;
- } else {
- tag = BLITA_MaskPlane;
- tag_data = (ULONG)ami_bitmap_get_mask(icon_bitmap, 16, 16, bm);
- minterm = (ABC|ABNC|ANBC);
- }
-
- BltBitMapTags(BLITA_SrcX, 0,
- BLITA_SrcY, 0,
- BLITA_DestX, bbox->Left,
- BLITA_DestY, bbox->Top,
- BLITA_Width, 16,
- BLITA_Height, 16,
- BLITA_Source, bm,
- BLITA_Dest, g->shared->win->RPort,
- BLITA_SrcType, BLITT_BITMAP,
- BLITA_DestType, BLITT_RASTPORT,
- BLITA_Minterm, minterm,
- tag, tag_data,
- TAG_DONE);
- }
- }
-
- g->favicon = icon;
-}
static uint32 ami_set_favicon_render_hook(struct Hook *hook, APTR space,
struct gpRender *msg)
@@ -4772,7 +4712,7 @@ static uint32 ami_set_favicon_render_hook(struct Hook *hook, APTR space,
* \param ico may be NULL for local calls; then access current cache from
* search_web_ico()
*/
-void gui_window_set_search_ico(hlcache_handle *ico)
+static void gui_set_search_ico(hlcache_handle *ico)
{
struct BitMap *bm = NULL;
struct IBox *bbox;
@@ -4855,7 +4795,7 @@ static uint32 ami_set_throbber_render_hook(struct Hook *hook, APTR space,
return 0;
}
-void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
+static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
struct IBox *bbox;
@@ -4892,7 +4832,7 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
OnMenu(g->shared->win, AMI_MENU_PASTE);
}
-void gui_window_remove_caret(struct gui_window *g)
+static void gui_window_remove_caret(struct gui_window *g)
{
struct IBox *bbox;
int xs,ys;
@@ -4909,7 +4849,7 @@ void gui_window_remove_caret(struct gui_window *g)
g->c_h = 0;
}
-void gui_window_new_content(struct gui_window *g)
+static void gui_window_new_content(struct gui_window *g)
{
hlcache_handle *c;
@@ -4929,12 +4869,7 @@ void gui_window_new_content(struct gui_window *g)
ami_gui_update_hotlist_button(g->shared);
}
-bool gui_window_scroll_start(struct gui_window *g)
-{
- return true;
-}
-
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
const struct rect *rect)
{
g->shared->drag_op = type;
@@ -5158,7 +5093,7 @@ void ami_gui_splash_close(Object *win_obj)
if(win_obj) DisposeObject(win_obj);
}
-void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
+static 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));
@@ -5177,3 +5112,145 @@ void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
}
}
+static struct gui_window_table amiga_window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .set_icon = gui_window_set_icon,
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .set_status = gui_window_set_status,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .drag_start = gui_window_drag_start,
+ .new_content = gui_window_new_content,
+ .file_gadget_open = gui_file_gadget_open,
+ .drag_save_object = gui_drag_save_object,
+ .drag_save_selection =gui_drag_save_selection,
+ .start_selection = gui_start_selection,
+
+ /* from theme */
+ .set_pointer = gui_window_set_pointer,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+
+ /* from download */
+ .save_link = gui_window_save_link,
+};
+
+static struct gui_clipboard_table amiga_clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+static struct gui_browser_table amiga_browser_table = {
+ .poll = gui_poll,
+ .quit = gui_quit,
+ .set_search_ico = gui_set_search_ico,
+ .get_resource_url = gui_get_resource_url,
+ .launch_url = gui_launch_url,
+ .create_form_select_menu = gui_create_form_select_menu,
+ .cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+ .login = gui_401login_open,
+};
+
+/** Normal entry point from OS */
+int main(int argc, char** argv)
+{
+ setbuf(stderr, NULL);
+ char messages[100];
+ char script[1024];
+ char temp[1024];
+ BPTR lock = 0;
+ int32 user = 0;
+ nserror ret;
+ Object *splash_window = ami_gui_splash_open();
+ struct gui_table amiga_gui_table = {
+ .browser = &amiga_browser_table,
+ .window = &amiga_window_table,
+ .clipboard = &amiga_clipboard_table,
+ .download = amiga_download_table,
+ };
+
+ /* Open popupmenu.library just to check the version.
+ * Versions older than 53.11 are dangerous, so we
+ * forcibly disable context menus if these are in use.
+ */
+ popupmenu_lib_ok = FALSE;
+ if(PopupMenuBase = OpenLibrary("popupmenu.library", 53)) {
+ LOG(("popupmenu.library v%d.%d",
+ PopupMenuBase->lib_Version, PopupMenuBase->lib_Revision));
+ if(LIB_IS_AT_LEAST((struct Library *)PopupMenuBase, 53, 11))
+ popupmenu_lib_ok = TRUE;
+ CloseLibrary(PopupMenuBase);
+ }
+
+ user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
+ current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
+ current_user_dir = ASPrintf("PROGDIR:Users/%s", current_user);
+
+ if(lock = CreateDirTree(current_user_dir))
+ UnLock(lock);
+
+ current_user_options = ASPrintf("%s/Choices", current_user_dir);
+
+ ami_mime_init("PROGDIR:Resources/mimetypes");
+ sprintf(temp, "%s/mimetypes.user", current_user_dir);
+ ami_mime_init(temp);
+ ami_schedule_open_timer();
+ ami_schedule_create();
+
+ amiga_plugin_hack_init();
+ amiga_datatypes_init();
+
+ /* initialise logging. Not fatal if it fails but not much we
+ * can do about it either.
+ */
+ nslog_init(NULL, &argc, argv);
+
+ /* user options setup */
+ ret = nsoption_init(ami_set_options, &nsoptions, &nsoptions_default);
+ if (ret != NSERROR_OK) {
+ die("Options failed to initialise");
+ }
+ nsoption_read(current_user_options, NULL);
+ nsoption_commandline(&argc, argv, NULL);
+
+ if (ami_locate_resource(messages, "Messages") == false)
+ die("Cannot open Messages file");
+ ret = netsurf_init(messages, &amiga_gui_table);
+ if (ret != NSERROR_OK) {
+ die("NetSurf failed to initialise");
+ }
+
+ amiga_icon_init();
+
+ gui_init(argc, argv);
+ gui_init2(argc, argv);
+
+ ami_gui_splash_close(splash_window);
+
+ strlcpy(script, nsoption_charp(arexx_dir), 1024);
+ AddPart(script, nsoption_charp(arexx_startup), 1024);
+ ami_arexx_execute(script);
+
+ netsurf_main_loop();
+
+ strlcpy(script, nsoption_charp(arexx_dir), 1024);
+ AddPart(script, nsoption_charp(arexx_shutdown), 1024);
+ ami_arexx_execute(script);
+
+ netsurf_exit();
+
+ ami_mime_free();
+
+ return 0;
+}
diff --git a/amiga/launch.h b/amiga/launch.h
index 40f7dae30..7baa6ca27 100755
--- a/amiga/launch.h
+++ b/amiga/launch.h
@@ -25,4 +25,7 @@
void ami_openurl_open(void);
void ami_openurl_close(void);
+
+void gui_launch_url(const char *url);
+
#endif
diff --git a/amiga/login.c b/amiga/login.c
index 816ece675..05d5d2470 100755
--- a/amiga/login.c
+++ b/amiga/login.c
@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/401login.h"
#include "amiga/os3support.h"
#include "amiga/gui.h"
#include "amiga/object.h"
diff --git a/amiga/login.h b/amiga/login.h
index 2ad5d8bdc..e3f77901f 100755
--- a/amiga/login.h
+++ b/amiga/login.h
@@ -24,4 +24,8 @@
struct gui_login_window;
BOOL ami_401login_event(struct gui_login_window *lw);
+
+void gui_401login_open(nsurl *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
+
#endif
diff --git a/amiga/misc.c b/amiga/misc.c
index 003a5fb6e..ac9d2453e 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -173,33 +173,6 @@ char *path_to_url(const char *path)
}
/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-
-char *filename_from_path(char *path)
-{
- return strdup(FilePart(path));
-}
-
-/**
- * Add a path component/filename to an existing path
- *
- * \param path buffer containing path + free space
- * \param length length of buffer "path"
- * \param newpart string containing path component to add to path
- * \return true on success
- */
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- if(AddPart(path, newpart, length)) return true;
- else return false;
-}
-
-/**
* returns a string with escape chars translated.
* (based on remove_underscores from utils.c)
*/
diff --git a/amiga/sslcert.h b/amiga/sslcert.h
index e308f6231..b55cac8b6 100644
--- a/amiga/sslcert.h
+++ b/amiga/sslcert.h
@@ -19,5 +19,9 @@
#ifndef AMIGA_SSLCERT_H
#define AMIGA_SSLCERT_H
+void gui_cert_verify(nsurl *url,
+ const struct ssl_cert_info *certs, unsigned long num,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
+
void ami_ssl_free(struct treeview_window *twin);
#endif
diff --git a/amiga/theme.c b/amiga/theme.c
index 03ce01aeb..0da15acee 100644
--- a/amiga/theme.c
+++ b/amiga/theme.c
@@ -275,11 +275,6 @@ void ami_update_pointer(struct Window *win, gui_pointer_shape shape)
}
}
-void gui_window_hide_pointer(struct gui_window *g)
-{
- ami_set_pointer(g->shared, AMI_GUI_POINTER_BLANK, true);
-}
-
void ami_init_mouse_pointers(void)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 53, 42)) return;
diff --git a/amiga/theme.h b/amiga/theme.h
index 3c3931c12..e81db33dd 100644
--- a/amiga/theme.h
+++ b/amiga/theme.h
@@ -41,4 +41,9 @@ void ami_reset_pointer(struct gui_window_2 *gwin);
* and ALWAYS in preference to SetWindowPointer(), as it features more pointers and uses
* the correct ones specified in user preferences. */
void ami_update_pointer(struct Window *win, gui_pointer_shape shape);
+
+void gui_window_start_throbber(struct gui_window *g);
+void gui_window_stop_throbber(struct gui_window *g);
+void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape);
+
#endif
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c
index fb687b809..ae918c6a5 100644
--- a/atari/ctxmenu.c
+++ b/atari/ctxmenu.c
@@ -58,6 +58,7 @@
#define CNT_INTERACTIVE 512
#define CNT_IMG 1024
+bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
struct s_context_info {
unsigned long flags;
diff --git a/atari/download.c b/atari/download.c
index e4a45e82e..8d4786e23 100755
--- a/atari/download.c
+++ b/atari/download.c
@@ -246,8 +246,8 @@ static char * select_filepath( const char * path, const char * filename )
return(ret);
}
-struct gui_download_window * gui_download_window_create(download_context *ctx,
- struct gui_window *parent)
+static struct gui_download_window *
+gui_download_window_create(download_context *ctx, struct gui_window *parent)
{
const char *filename;
char *destination;
@@ -359,7 +359,7 @@ struct gui_download_window * gui_download_window_create(download_context *ctx,
}
-nserror gui_download_window_data(struct gui_download_window *dw,
+static nserror gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
@@ -415,7 +415,7 @@ nserror gui_download_window_data(struct gui_download_window *dw,
return NSERROR_OK;
}
-void gui_download_window_error(struct gui_download_window *dw,
+static void gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
LOG(("%s", error_msg));
@@ -426,7 +426,7 @@ void gui_download_window_error(struct gui_download_window *dw,
// TODO: change abort to close
}
-void gui_download_window_done(struct gui_download_window *dw)
+static void gui_download_window_done(struct gui_download_window *dw)
{
OBJECT * tree;
LOG((""));
@@ -454,3 +454,12 @@ void gui_download_window_done(struct gui_download_window *dw)
}
gui_window_set_status(input_window, messages_get("Done") );
}
+
+static struct gui_download_table download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
+
+struct gui_download_table *atari_download_table = &download_table;
diff --git a/atari/download.h b/atari/download.h
index e25893d4a..82f89c050 100755
--- a/atari/download.h
+++ b/atari/download.h
@@ -19,6 +19,8 @@
#ifndef NS_ATARI_DOWNLOAD_H
#define NS_ATARI_DOWNLOAD_H
+extern struct gui_download_table *atari_download_table;
+
#define MAX_SLEN_LBL_DONE 64
#define MAX_SLEN_LBL_PERCENT 5
#define MAX_SLEN_LBL_SPEED 13
diff --git a/atari/gui.c b/atari/gui.c
index e02c5434a..95cfe55ed 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -38,7 +38,6 @@
#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "desktop/netsurf.h"
-#include "desktop/401login.h"
#include "utils/nsoption.h"
#include "desktop/save_complete.h"
@@ -113,9 +112,31 @@ EVMULT_IN aes_event_in = {
EVMULT_OUT aes_event_out;
short aes_msg_out[8];
+bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
+
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+static char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '\\');
+ if( !leafname )
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
struct gui_window *tmp;
@@ -186,10 +207,10 @@ 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 +254,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;
@@ -277,8 +298,11 @@ void gui_window_destroy(struct gui_window *w)
}
}
-void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
- bool scaled)
+static void
+gui_window_get_dimensions(struct gui_window *w,
+ int *width,
+ int *height,
+ bool scaled)
{
if (w == NULL)
return;
@@ -288,7 +312,7 @@ void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
*height = rect.g_h;
}
-void gui_window_set_title(struct gui_window *gw, const char *title)
+static void gui_window_set_title(struct gui_window *gw, const char *title)
{
if (gw == NULL)
@@ -363,7 +387,7 @@ void gui_window_set_scale(struct gui_window *gw, float scale)
browser_window_reformat(gw->browser->bw, false, width, heigth);
}
-void gui_window_redraw_window(struct gui_window *gw)
+static void gui_window_redraw_window(struct gui_window *gw)
{
CMP_BROWSER b;
GRECT rect;
@@ -374,7 +398,7 @@ void gui_window_redraw_window(struct gui_window *gw)
window_schedule_redraw_grect(gw->root, &rect);
}
-void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
+static void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
{
GRECT area;
struct gemtk_wm_scroll_info_s *slid;
@@ -404,7 +428,7 @@ bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
return( true );
}
-void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
+static void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
{
int units = 0;
if ((w == NULL)
@@ -418,18 +442,11 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
}
-void gui_window_scroll_visible(struct gui_window *w, int x0, int y0, int x1, int y1)
-{
- LOG(("%s:(%p, %d, %d, %d, %d)", __func__, w, x0, y0, x1, y1));
- gui_window_set_scroll(w,x0,y0);
-}
-
-
/* It seems this method is called when content size got adjusted,
so that we can adjust scroll info. We also have to call it when tab
change occurs.
*/
-void gui_window_update_extent(struct gui_window *gw)
+static void gui_window_update_extent(struct gui_window *gw)
{
if( gw->browser->bw->current_content != NULL ) {
@@ -448,13 +465,6 @@ void gui_window_update_extent(struct gui_window *gw)
}
-void gui_clear_selection(struct gui_window *g)
-{
-
-}
-
-
-
/**
* set the pointer shape
*/
@@ -534,13 +544,8 @@ void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape)
}
}
-void gui_window_hide_pointer(struct gui_window *w)
-{
- TODO();
-}
-
-void gui_window_set_url(struct gui_window *w, const char *url)
+static void gui_window_set_url(struct gui_window *w, const char *url)
{
int l;
@@ -594,7 +599,7 @@ static void throbber_advance( void * data )
schedule(100, throbber_advance, gw );
}
-void gui_window_start_throbber(struct gui_window *w)
+static void gui_window_start_throbber(struct gui_window *w)
{
GRECT work;
if (w == NULL)
@@ -605,7 +610,7 @@ void gui_window_start_throbber(struct gui_window *w)
rendering = true;
}
-void gui_window_stop_throbber(struct gui_window *w)
+static void gui_window_stop_throbber(struct gui_window *w)
{
if (w == NULL)
return;
@@ -620,7 +625,7 @@ void gui_window_stop_throbber(struct gui_window *w)
}
/* Place caret in window */
-void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
+static void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
const struct rect *clip)
{
window_place_caret(w->root, 1, x, y, height, NULL);
@@ -632,7 +637,7 @@ void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
/**
* clear window caret
*/
-void
+static void
gui_window_remove_caret(struct gui_window *w)
{
if (w == NULL)
@@ -646,7 +651,7 @@ gui_window_remove_caret(struct gui_window *w)
return;
}
-void
+static void
gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
{
struct bitmap *bmp_icon;
@@ -658,13 +663,7 @@ gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
}
}
-void
-gui_window_set_search_ico(hlcache_handle *ico)
-{
- TODO();
-}
-
-void gui_window_new_content(struct gui_window *w)
+static void gui_window_new_content(struct gui_window *w)
{
struct gemtk_wm_scroll_info_s *slid = gemtk_wm_get_scroll_info(w->root->win);
slid->x_pos = 0;
@@ -673,44 +672,6 @@ void gui_window_new_content(struct gui_window *w)
gui_window_redraw_window(w);
}
-bool gui_window_scroll_start(struct gui_window *w)
-{
- TODO();
- return true;
-}
-
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
-{
- TODO();
- return true;
-}
-
-void gui_window_save_link(struct gui_window *g, const char *url,
- const char *title)
-{
- LOG(("%s -> %s", title, url ));
- TODO();
-}
-
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *w)
-{
- LOG((""));
- TODO();
-}
-
-void gui_drag_save_selection(struct gui_window *g, const char *selection)
-{
- LOG((""));
- TODO();
-}
-
-void gui_start_selection(struct gui_window *w)
-{
-
-}
-
/**
* Core asks front end for clipboard contents.
@@ -718,7 +679,7 @@ void gui_start_selection(struct gui_window *w)
* \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
* \param length Byte length of UTF-8 text in buffer
*/
-void gui_get_clipboard(char **buffer, size_t *length)
+static void gui_get_clipboard(char **buffer, size_t *length)
{
char *clip;
size_t clip_len;
@@ -760,7 +721,7 @@ void gui_get_clipboard(char **buffer, size_t *length)
* \param styles Array of styles given to text runs, owned by core, or NULL
* \param n_styles Number of text run styles in array
*/
-void gui_set_clipboard(const char *buffer, size_t length,
+static void gui_set_clipboard(const char *buffer, size_t length,
nsclipboard_styles styles[], int n_styles)
{
if (length > 0 && buffer != NULL) {
@@ -780,23 +741,7 @@ void gui_set_clipboard(const char *buffer, size_t length,
}
}
-
-void gui_create_form_select_menu(struct browser_window *bw,
- struct form_control *control)
-{
- TODO();
-}
-
-/**
- * Broadcast an URL that we can't handle.
- */
-void gui_launch_url(const char *url)
-{
- TODO();
- LOG(("launch file: %s\n", url));
-}
-
-void gui_401login_open(nsurl *url, const char *realm,
+static void gui_401login_open(nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
bool bres;
@@ -815,7 +760,7 @@ void gui_401login_open(nsurl *url, const char *realm,
}
-void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
+static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
{
@@ -854,7 +799,7 @@ struct gui_window * gui_get_input_window(void)
return(input_window);
}
-void gui_quit(void)
+static void gui_quit(void)
{
LOG((""));
@@ -972,7 +917,7 @@ static inline void create_cursor(int flags, short mode, void * form,
}
}
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
char buf[PATH_MAX];
char *raw;
@@ -1098,12 +1043,42 @@ static void gui_init2(int argc, char** argv)
toolbar_init();
}
-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"); */
-}
+static struct gui_window_table atari_window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .set_icon = gui_window_set_icon,
+ .set_status = gui_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .new_content = gui_window_new_content,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+};
+
+static struct gui_clipboard_table atari_clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+static struct gui_browser_table atari_browser_table = {
+ .poll = gui_poll,
+ .quit = gui_quit,
+ .get_resource_url = gui_get_resource_url,
+ .cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+ .login = gui_401login_open,
+};
/* #define WITH_DBG_LOGFILE 1 */
/** Entry point from OS.
@@ -1120,6 +1095,12 @@ int main(int argc, char** argv)
struct stat stat_buf;
nsurl *url;
nserror ret;
+ struct gui_table atari_gui_table = {
+ .browser = &atari_browser_table,
+ .window = &atari_window_table,
+ .clipboard = &atari_clipboard_table,
+ .download = atari_download_table,
+ };
/* @todo logging file descriptor update belongs in a nslog_init callback */
setbuf(stderr, NULL);
@@ -1153,7 +1134,7 @@ int main(int argc, char** argv)
/* common initialisation */
LOG(("Initialising core..."));
- ret = netsurf_init(messages);
+ ret = netsurf_init(messages, &atari_gui_table);
if (ret != NSERROR_OK) {
die("NetSurf failed to initialise");
}
diff --git a/atari/gui.h b/atari/gui.h
index a1519f375..d552bc87b 100755
--- a/atari/gui.h
+++ b/atari/gui.h
@@ -163,6 +163,9 @@ extern struct gui_window *window_list;
void gui_set_input_gui_window(struct gui_window *gw);
struct gui_window *gui_get_input_window(void);
char *gui_window_get_url(struct gui_window *gw);
-char * gui_window_get_title(struct gui_window *gw);
+char *gui_window_get_title(struct gui_window *gw);
+
+void gui_window_set_status(struct gui_window *w, const char *text);
+void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape);
#endif
diff --git a/atari/login.c b/atari/login.c
index 461a2f985..81636aebb 100755
--- a/atari/login.c
+++ b/atari/login.c
@@ -16,18 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/401login.h"
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <cflib.h>
+
#include "utils/config.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/browser.h"
-#include "desktop/401login.h"
#include "desktop/gui.h"
#include "utils/errors.h"
#include "utils/utils.h"
diff --git a/atari/misc.c b/atari/misc.c
index d330859b9..ca9e993d9 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -71,28 +71,6 @@ void die(const char *error)
}
/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-
-char *filename_from_path(char *path)
-{
- char *leafname;
-
- leafname = strrchr(path, '\\');
- if( !leafname )
- leafname = strrchr(path, '/');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
-
- return strdup(leafname);
-}
-
-/**
* Add a path component/filename to an existing path
*
* \param path buffer containing path + free space
diff --git a/atari/misc.h b/atari/misc.h
index 8d1719ce8..1bb5e8131 100755
--- a/atari/misc.h
+++ b/atari/misc.h
@@ -66,4 +66,6 @@ const char * file_select(const char * title, const char * name);
*/
long nkc_to_input_key(short nkc, long * ucs4_out);
+bool path_add_part(char *path, int length, const char *newpart);
+
#endif
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 3c89e6d55..0f3413c3d 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -85,6 +85,8 @@ static bool on_content_mouse_click(ROOTWIN *rootwin);
static bool on_content_mouse_move(ROOTWIN *rootwin, GRECT *content_area);
static void toolbar_redraw_cb(GUIWIN *win, uint16_t msg, GRECT *clip);
+bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
+
static bool redraw_active = false;
static const struct redraw_context rootwin_rdrw_ctx = {
diff --git a/beos/download.cpp b/beos/download.cpp
index e20281c2f..2e259bccf 100644
--- a/beos/download.cpp
+++ b/beos/download.cpp
@@ -178,7 +178,7 @@ NSDownloadWindow::Failure(const char* error)
}
-struct gui_download_window *gui_download_window_create(download_context *ctx,
+static struct gui_download_window *gui_download_window_create(download_context *ctx,
struct gui_window *parent)
{
struct gui_download_window *download = (struct gui_download_window*)malloc(sizeof *download);
@@ -209,7 +209,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
}
-nserror gui_download_window_data(struct gui_download_window *dw,
+static nserror gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
dw->window->Progress(size);
@@ -222,7 +222,7 @@ nserror gui_download_window_data(struct gui_download_window *dw,
}
-void gui_download_window_error(struct gui_download_window *dw,
+static void gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
dw->window->Failure(error_msg);
@@ -232,7 +232,7 @@ void gui_download_window_error(struct gui_download_window *dw,
}
-void gui_download_window_done(struct gui_download_window *dw)
+static void gui_download_window_done(struct gui_download_window *dw)
{
dw->window->Success();
@@ -248,3 +248,12 @@ void gui_download_window_done(struct gui_download_window *dw)
dw->storageLock->Unlock();
}
+static struct gui_download_table download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
+
+struct gui_download_table *beos_download_table = &download_table;
+
diff --git a/beos/download.h b/beos/download.h
index 9c8d3adcd..245ee8641 100644
--- a/beos/download.h
+++ b/beos/download.h
@@ -16,3 +16,4 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+struct gui_download_table *beos_download_table;
diff --git a/beos/gui.cpp b/beos/gui.cpp
index 32bd3a2d5..4a6475894 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -49,7 +49,6 @@ extern "C" {
#include "content/fetchers/curl.h"
#include "content/fetchers/resource.h"
#include "content/urldb.h"
-#include "desktop/401login.h"
#include "desktop/browser_private.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
@@ -78,8 +77,6 @@ extern "C" {
static void *myrealloc(void *ptr, size_t len, void *pw);
-void gui_init(int argc, char** argv);
-
/* Where to search for shared resources. Must have trailing / */
#define RESPATH "/boot/apps/netsurf/res/"
@@ -348,7 +345,7 @@ static int32 bapp_thread(void *arg)
return 0;
}
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
nsurl *url = NULL;
BString u("rsrc:///");
@@ -367,42 +364,6 @@ nsurl *gui_get_resource_url(const char *path)
return url;
}
-static void gui_init2(int argc, char** argv)
-{
- const char *addr;
- nsurl *url;
- nserror error;
-
- if (argc > 1) {
- addr = argv[1];
- } else if (nsoption_charp(homepage_url) != NULL) {
- addr = nsoption_charp(homepage_url);
- } else {
- addr = NETSURF_HOMEPAGE;
- }
-
- /* create an initial browser window */
- error = nsurl_create(addr, &url);
- if (error == NSERROR_OK) {
- error = browser_window_create((browser_window_nav_flags)
- (BROWSER_WINDOW_VERIFIABLE | BROWSER_WINDOW_HISTORY),
- url,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- }
-
- if (gFirstRefsReceived) {
- // resend the refs we got before having a window to send them to
- be_app_messenger.SendMessage(gFirstRefsReceived);
- delete gFirstRefsReceived;
- gFirstRefsReceived = NULL;
- }
-}
#if !defined(__HAIKU__) && !defined(B_BEOS_VERSION_DANO)
@@ -532,91 +493,12 @@ static BPath get_messages_path()
return p;
}
-/** Normal entry point from OS */
-int main(int argc, char** argv)
-{
- nserror ret;
- BPath options;
- if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) {
- options.Append("x-vnd.NetSurf");
- }
-
- if (!replicated) {
- // create the Application object before trying to use messages
- // so we can open an alert in case of error.
- new NSBrowserApplication;
- }
-
- /* initialise logging. Not fatal if it fails but not much we
- * can do about it either.
- */
- nslog_init(nslog_stream_configure, &argc, argv);
- /* user options setup */
- ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
- if (ret != NSERROR_OK) {
- die("Options failed to initialise");
- }
- nsoption_read(options.Path(), NULL);
- nsoption_commandline(&argc, argv, NULL);
-
- /* common initialisation */
- BPath messages = get_messages_path();
- ret = netsurf_init(messages.Path());
- if (ret != NSERROR_OK) {
- die("NetSurf failed to initialise");
- }
-
- gui_init(argc, argv);
- gui_init2(argc, argv);
-
- netsurf_main_loop();
-
- netsurf_exit();
-
- return 0;
-}
-
-/** called when replicated from NSBaseView::Instantiate() */
-int gui_init_replicant(int argc, char** argv)
-{
- nserror ret;
- BPath options;
- if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) {
- options.Append("x-vnd.NetSurf");
- }
-
- /* initialise logging. Not fatal if it fails but not much we
- * can do about it either.
- */
- nslog_init(nslog_stream_configure, &argc, argv);
-
- // FIXME: use options as readonly for replicants
- /* user options setup */
- ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
- if (ret != NSERROR_OK) {
- // FIXME: must not die when in replicant!
- die("Options failed to initialise");
- }
- nsoption_read(options.Path(), NULL);
- nsoption_commandline(&argc, argv, NULL);
-
- /* common initialisation */
- BPath messages = get_messages_path();
- ret = netsurf_init(messages.Path());
- if (ret != NSERROR_OK) {
- // FIXME: must not die when in replicant!
- die("NetSurf failed to initialise");
- }
-
- gui_init(argc, argv);
- gui_init2(argc, argv);
-
- return 0;
-}
-
-void gui_init(int argc, char** argv)
+static void gui_init(int argc, char** argv)
{
+ const char *addr;
+ nsurl *url;
+ nserror error;
char buf[PATH_MAX];
if (pipe(sEventPipe) < 0)
@@ -746,6 +628,36 @@ void gui_init(int argc, char** argv)
if (!replicated)
be_app->Unlock();
+ if (argc > 1) {
+ addr = argv[1];
+ } else if (nsoption_charp(homepage_url) != NULL) {
+ addr = nsoption_charp(homepage_url);
+ } else {
+ addr = NETSURF_HOMEPAGE;
+ }
+
+ /* create an initial browser window */
+ error = nsurl_create(addr, &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create((browser_window_nav_flags)
+ (BROWSER_WINDOW_VERIFIABLE | BROWSER_WINDOW_HISTORY),
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
+
+ if (gFirstRefsReceived) {
+ // resend the refs we got before having a window to send them to
+ be_app_messenger.SendMessage(gFirstRefsReceived);
+ delete gFirstRefsReceived;
+ gFirstRefsReceived = NULL;
+ }
+
}
@@ -783,7 +695,7 @@ void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaf
}
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
CURLMcode code;
fd_set read_fd_set, write_fd_set, exc_fd_set;
@@ -858,7 +770,7 @@ void gui_poll(bool active)
}
-void gui_quit(void)
+static void gui_quit(void)
{
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
@@ -871,18 +783,6 @@ void gui_quit(void)
}
-
-void gui_create_form_select_menu(struct browser_window *bw,
- struct form_control *control)
-{
- CALLED();
-}
-
-void
-gui_window_save_link(struct gui_window *g, const char *url, const char *title)
-{
-}
-
/**
* Send the source of a content to a text editor.
*/
@@ -980,7 +880,7 @@ void nsbeos_gui_view_source(struct hlcache_handle *content)
* Broadcast an URL that we can't handle.
*/
-void gui_launch_url(const char *url)
+static void gui_launch_url(const char *url)
{
status_t status;
// try to open it as an URI
@@ -1041,13 +941,6 @@ void die(const char * const error)
exit(EXIT_FAILURE);
}
-void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
- unsigned long num, nserror (*cb)(bool proceed, void *pw),
- void *cbpw)
-{
- CALLED();
-}
-
static void nsbeos_create_ssl_verify_window(struct browser_window *bw,
hlcache_handle *c, const struct ssl_cert_info *certs,
unsigned long num)
@@ -1133,7 +1026,7 @@ static void *myrealloc(void *ptr, size_t len, void *pw)
* \return filename (will be freed with free())
*/
-char *filename_from_path(char *path)
+static char *filename_from_path(char *path)
{
char *leafname;
@@ -1155,7 +1048,7 @@ char *filename_from_path(char *path)
* \return true on success
*/
-bool path_add_part(char *path, int length, const char *newpart)
+static bool path_add_part(char *path, int length, const char *newpart)
{
if(path[strlen(path) - 1] != '/')
strncat(path, "/", length);
@@ -1165,10 +1058,113 @@ bool path_add_part(char *path, int length, const char *newpart)
return true;
}
-void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
- struct form_control *gadget)
+static struct gui_clipboard_table beos_clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+static struct gui_browser_table beos_browser_table = {
+ .poll = gui_poll,
+ .quit = gui_quit,
+ .get_resource_url = gui_get_resource_url,
+ .launch_url = gui_launch_url,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+ .login = gui_401login_open,
+};
+
+
+/** Normal entry point from OS */
+int main(int argc, char** argv)
{
- LOG(("File open dialog rquest for %p/%p", g, gadget));
- /* browser_window_set_gadget_filename(bw, gadget, "filename"); */
+ nserror ret;
+ BPath options;
+ struct gui_table beos_gui_table = {
+ .browser = &beos_browser_table,
+ .window = beos_window_table,
+ .clipboard = &beos_clipboard_table,
+ .download = beos_download_table,
+ };
+
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) {
+ options.Append("x-vnd.NetSurf");
+ }
+
+ if (!replicated) {
+ // create the Application object before trying to use messages
+ // so we can open an alert in case of error.
+ new NSBrowserApplication;
+ }
+
+ /* initialise logging. Not fatal if it fails but not much we
+ * can do about it either.
+ */
+ nslog_init(nslog_stream_configure, &argc, argv);
+
+ /* user options setup */
+ ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
+ if (ret != NSERROR_OK) {
+ die("Options failed to initialise");
+ }
+ nsoption_read(options.Path(), NULL);
+ nsoption_commandline(&argc, argv, NULL);
+
+ /* common initialisation */
+ BPath messages = get_messages_path();
+ ret = netsurf_init(messages.Path(), &beos_gui_table);
+ if (ret != NSERROR_OK) {
+ die("NetSurf failed to initialise");
+ }
+
+ gui_init(argc, argv);
+
+ netsurf_main_loop();
+
+ netsurf_exit();
+
+ return 0;
}
+/** called when replicated from NSBaseView::Instantiate() */
+int gui_init_replicant(int argc, char** argv)
+{
+ nserror ret;
+ BPath options;
+ struct gui_table beos_gui_table = {
+ .browser = &beos_browser_table,
+ .window = beos_window_table,
+ .clipboard = &beos_clipboard_table,
+ .download = beos_download_table,
+ };
+
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) {
+ options.Append("x-vnd.NetSurf");
+ }
+
+ /* initialise logging. Not fatal if it fails but not much we
+ * can do about it either.
+ */
+ nslog_init(nslog_stream_configure, &argc, argv);
+
+ // FIXME: use options as readonly for replicants
+ /* user options setup */
+ ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
+ if (ret != NSERROR_OK) {
+ // FIXME: must not die when in replicant!
+ die("Options failed to initialise");
+ }
+ nsoption_read(options.Path(), NULL);
+ nsoption_commandline(&argc, argv, NULL);
+
+ /* common initialisation */
+ BPath messages = get_messages_path();
+ ret = netsurf_init(messages.Path(), &beos_gui_table);
+ if (ret != NSERROR_OK) {
+ // FIXME: must not die when in replicant!
+ die("NetSurf failed to initialise");
+ }
+
+ gui_init(argc, argv);
+
+ return 0;
+}
diff --git a/beos/gui.h b/beos/gui.h
index b9d66320c..ea1a8ad3a 100644
--- a/beos/gui.h
+++ b/beos/gui.h
@@ -32,6 +32,9 @@
extern bool replicated;
int gui_init_replicant(int argc, char** argv);
+extern "C" void gui_401login_open(nsurl *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
+
extern char *options_file_location;
diff --git a/beos/login.cpp b/beos/login.cpp
index 90cadde7b..5cd7a3c83 100644
--- a/beos/login.cpp
+++ b/beos/login.cpp
@@ -31,7 +31,6 @@ extern "C" {
#include "content/content.h"
#include "content/urldb.h"
#include "desktop/browser.h"
-#include "desktop/401login.h"
#include "desktop/gui.h"
#include "utils/messages.h"
#include "utils/url.h"
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 06184f24e..f302efcb4 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -558,10 +558,6 @@ NSBaseView::Instantiate(BMessage *archive)
replicated = true;
//TODO:FIXME: fix replicants
- // netsurf_init() needs different args now...
- //netsurf_init(2, info->args);
- //return NULL;
-
// do as much as possible in this thread to avoid deadlocks
gui_init_replicant(2, info->args);
@@ -2198,15 +2194,6 @@ void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon)
g->top_view->UnlockLooper();
}
-/**
-* set gui display of a retrieved favicon representing the search provider
-* \param ico may be NULL for local calls; then access current cache from
-* search_web_ico()
-*/
-void gui_window_set_search_ico(hlcache_handle *ico)
-{
-}
-
void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where)
{
diff --git a/beos/scaffolding.h b/beos/scaffolding.h
index 1b78d54a8..2dd364d08 100644
--- a/beos/scaffolding.h
+++ b/beos/scaffolding.h
@@ -200,5 +200,11 @@ void nsbeos_scaffolding_destroy(nsbeos_scaffolding *scaffold);
void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where);
+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_set_icon(struct gui_window *_g, hlcache_handle *icon);
+void gui_window_set_status(struct gui_window *_g, const char *text);
+void gui_window_start_throbber(struct gui_window* _g);
+void gui_window_stop_throbber(struct gui_window* _g);
#endif /* NETSURF_BEOS_SCAFFOLDING_H */
diff --git a/beos/window.cpp b/beos/window.cpp
index b743ec0c2..fc46eba96 100644
--- a/beos/window.cpp
+++ b/beos/window.cpp
@@ -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)
+static 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 */
@@ -405,12 +406,6 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
}
-void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
- int x1, int y1)
-{
- gui_window_set_scroll(g, x0, y0);
-}
-
void nsbeos_dispatch_event(BMessage *message)
{
struct gui_window *gui = NULL;
@@ -956,7 +951,7 @@ void nsbeos_window_destroy_browser(struct gui_window *g)
browser_window_destroy(g->bw);
}
-void gui_window_destroy(struct gui_window *g)
+static void gui_window_destroy(struct gui_window *g)
{
if (!g)
return;
@@ -1019,7 +1014,7 @@ void nsbeos_redraw_caret(struct gui_window *g)
g->view->UnlockLooper();
}
-void gui_window_redraw_window(struct gui_window *g)
+static void gui_window_redraw_window(struct gui_window *g)
{
if (g->view == NULL)
return;
@@ -1034,7 +1029,7 @@ void gui_window_redraw_window(struct gui_window *g)
g->view->UnlockLooper();
}
-void gui_window_update_box(struct gui_window *g, const struct rect *rect)
+static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
{
hlcache_handle *c = g->bw->current_content;
@@ -1056,7 +1051,7 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect)
g->view->UnlockLooper();
}
-bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
//CALLED();
if (g->view == NULL)
@@ -1074,7 +1069,7 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
//CALLED();
if (g->view == NULL)
@@ -1092,7 +1087,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
}
-void gui_window_update_extent(struct gui_window *g)
+static void gui_window_update_extent(struct gui_window *g)
{
//CALLED();
if (!g->bw->current_content)
@@ -1174,7 +1169,7 @@ const uint8 kWatch2CursorBits[] = {
};
-void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
+static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
BCursor *cursor = NULL;
bool allocated = false;
@@ -1214,12 +1209,7 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
delete cursor;
}
-void gui_window_hide_pointer(struct gui_window *g)
-{
- //XXX no BView::HideCursor... use empty one
-}
-
-void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
+static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
//CALLED();
@@ -1240,7 +1230,7 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
g->view->UnlockLooper();
}
-void gui_window_remove_caret(struct gui_window *g)
+static void gui_window_remove_caret(struct gui_window *g)
{
int oh = g->careth;
@@ -1262,7 +1252,7 @@ void gui_window_remove_caret(struct gui_window *g)
g->view->UnlockLooper();
}
-void gui_window_new_content(struct gui_window *g)
+static void gui_window_new_content(struct gui_window *g)
{
if (!g->toplevel)
return;
@@ -1278,29 +1268,7 @@ void gui_window_new_content(struct gui_window *g)
g->view->UnlockLooper();
}
-bool gui_window_scroll_start(struct gui_window *g)
-{
- return true;
-}
-
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
-{
- return true;
-}
-
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *g)
-{
-
-}
-
-void gui_drag_save_selection(struct gui_window *g, const char *selection)
-{
-
-}
-
-void gui_start_selection(struct gui_window *g)
+static void gui_start_selection(struct gui_window *g)
{
if (!g->view->LockLooper())
return;
@@ -1310,10 +1278,6 @@ void gui_start_selection(struct gui_window *g)
g->view->UnlockLooper();
}
-void gui_clear_selection(struct gui_window *g)
-{
-}
-
void gui_get_clipboard(char **buffer, size_t *length)
{
BMessage *clip;
@@ -1368,7 +1332,7 @@ void gui_set_clipboard(const char *buffer, size_t length,
}
}
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
{
if (g->view && g->view->LockLooper()) {
@@ -1383,3 +1347,29 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
}
}
+static struct gui_window_table window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .new_content = gui_window_new_content,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .start_selection = gui_start_selection,
+
+ /* from scaffold */
+ .set_icon = gui_window_set_icon,
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .set_status = gui_window_set_status,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+};
+
+struct gui_window_table *beos_window_table = &window_table;
diff --git a/beos/window.h b/beos/window.h
index fc8a4f832..fb67517d2 100644
--- a/beos/window.h
+++ b/beos/window.h
@@ -25,6 +25,8 @@ extern "C" {
}
#include "beos/scaffolding.h"
+extern struct gui_window_table *beos_window_table;
+
class NSBrowserFrameView : public BView {
public:
NSBrowserFrameView(BRect frame, struct gui_window *gui);
@@ -48,7 +50,6 @@ private:
void nsbeos_dispatch_event(BMessage *message);
-
void nsbeos_reflow_all_windows(void);
void nsbeos_window_process_reformats(void);
@@ -61,4 +62,7 @@ void nsbeos_window_destroy_browser(struct gui_window *g);
struct browser_window *nsbeos_get_browser_window(struct gui_window *g);
+void gui_get_clipboard(char **buffer, size_t *length);
+void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles);
+
#endif /* NETSURF_BEOS_WINDOW_H */
diff --git a/cocoa/DownloadWindowController.h b/cocoa/DownloadWindowController.h
index b93c24c65..0d049da15 100644
--- a/cocoa/DownloadWindowController.h
+++ b/cocoa/DownloadWindowController.h
@@ -18,6 +18,7 @@
#import <Cocoa/Cocoa.h>
+struct gui_download_table *cocoa_gui_download_table;
@interface DownloadWindowController : NSWindowController {
struct download_context *context;
@@ -50,3 +51,4 @@
- (void) abort;
@end
+
diff --git a/cocoa/DownloadWindowController.m b/cocoa/DownloadWindowController.m
index 82be52e51..634257008 100644
--- a/cocoa/DownloadWindowController.m
+++ b/cocoa/DownloadWindowController.m
@@ -327,7 +327,7 @@ static NSString *cocoa_time_string( unsigned seconds )
#pragma mark -
#pragma mark NetSurf interface functions
-struct gui_download_window *gui_download_window_create(download_context *ctx,
+static struct gui_download_window *gui_download_window_create(download_context *ctx,
struct gui_window *parent)
{
DownloadWindowController * const window = [[DownloadWindowController alloc] initWithContext: ctx];
@@ -338,21 +338,21 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
return (struct gui_download_window *)window;
}
-nserror gui_download_window_data(struct gui_download_window *dw,
+static nserror gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
DownloadWindowController * const window = (DownloadWindowController *)dw;
return [window receivedData: [NSData dataWithBytes: data length: size]] ? NSERROR_OK : NSERROR_SAVE_FAILED;
}
-void gui_download_window_error(struct gui_download_window *dw,
+static void gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
DownloadWindowController * const window = (DownloadWindowController *)dw;
[window showError: [NSString stringWithUTF8String: error_msg]];
}
-void gui_download_window_done(struct gui_download_window *dw)
+static void gui_download_window_done(struct gui_download_window *dw)
{
DownloadWindowController * const window = (DownloadWindowController *)dw;
[window downloadDone];
@@ -376,3 +376,12 @@ static void cocoa_unregister_download( DownloadWindowController *download )
[cocoa_all_downloads removeObject: download];
}
+
+static struct gui_download_table gui_download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
+
+struct gui_download_table *cocoa_gui_download_table = &gui_download_table;
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index 33e3bfa43..62f684ddc 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -183,6 +183,12 @@ int main( int argc, char **argv )
{
nsurl *url;
nserror error;
+ struct gui_table cocoa_gui_table = {
+ .browser = cocoa_browser_table,
+ .window = cocoa_window_table,
+ .clipboard = cocoa_clipboard_table,
+ .download = cocoa_download_table,
+ };
cocoa_autorelease();
@@ -203,7 +209,7 @@ int main( int argc, char **argv )
nsoption_commandline(&argc, argv, NULL);
/* common initialisation */
- error = netsurf_init(messages);
+ error = netsurf_init(messages, &cocoa_gui_table);
if (error != NSERROR_OK) {
die("NetSurf failed to initialise");
}
diff --git a/cocoa/gui.h b/cocoa/gui.h
index 413727fe6..757140030 100644
--- a/cocoa/gui.h
+++ b/cocoa/gui.h
@@ -18,6 +18,10 @@
#import <Cocoa/Cocoa.h>
+extern struct gui_window_table *cocoa_window_table;
+extern struct gui_clipboard_table *cocoa_clipboard_table;
+extern struct gui_browser_table *cocoa_browser_table;
+
extern NSString * const kCookiesFileOption;
extern NSString * const kURLsFileOption;
extern NSString * const kHotlistFileOption;
diff --git a/cocoa/gui.m b/cocoa/gui.m
index 72f64bf04..a49ea9ea2 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -24,13 +24,13 @@
#import "cocoa/BrowserViewController.h"
#import "cocoa/BrowserWindowController.h"
#import "cocoa/FormSelectMenu.h"
+#import "cocoa/selection.h"
#import "desktop/gui.h"
#import "desktop/netsurf.h"
#import "desktop/browser_private.h"
#import "utils/nsoption.h"
#import "desktop/textinput.h"
-#import "desktop/401login.h"
#import "utils/utils.h"
#import "utils/log.h"
#import "image/ico.h"
@@ -46,7 +46,7 @@ NSString * const kAlwaysCloseMultipleTabs = @"AlwaysCloseMultipleTabs";
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
nsurl *url = NULL;
NSString *nspath = [[NSBundle mainBundle] pathForResource: [NSString stringWithUTF8String: path] ofType: @""];
@@ -55,7 +55,7 @@ nsurl *gui_get_resource_url(const char *path)
return url;
}
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
cocoa_autorelease();
@@ -68,15 +68,11 @@ void gui_poll(bool active)
}
}
-void gui_quit(void)
-{
- // nothing to do
-}
-
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;
@@ -98,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;
@@ -106,17 +102,17 @@ void gui_window_destroy(struct gui_window *g)
[vc release];
}
-void gui_window_set_title(struct gui_window *g, const char *title)
+static void gui_window_set_title(struct gui_window *g, const char *title)
{
[(BrowserViewController *)g setTitle: [NSString stringWithUTF8String: title]];
}
-void gui_window_redraw_window(struct gui_window *g)
+static void gui_window_redraw_window(struct gui_window *g)
{
[[(BrowserViewController *)g browserView] setNeedsDisplay: YES];
}
-void gui_window_update_box(struct gui_window *g, const struct rect *rect)
+static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
{
const NSRect nsrect = cocoa_scaled_rect_wh( [(BrowserViewController *)g browser]->scale,
rect->x0, rect->y0,
@@ -124,7 +120,7 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect)
[[(BrowserViewController *)g browserView] setNeedsDisplayInRect: nsrect];
}
-bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
NSCParameterAssert( g != NULL && sx != NULL && sy != NULL );
@@ -134,18 +130,12 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
[[(BrowserViewController *)g browserView] scrollPoint: cocoa_point( sx, sy )];
}
-void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
- int x1, int y1)
-{
- gui_window_set_scroll( g, x0, y0 );
-}
-
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
{
NSCParameterAssert( width != NULL && height != NULL );
@@ -160,7 +150,7 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
*height = cocoa_pt_to_px( NSHeight( frame ) );
}
-void gui_window_update_extent(struct gui_window *g)
+static void gui_window_update_extent(struct gui_window *g)
{
BrowserViewController * const window = (BrowserViewController *)g;
@@ -171,12 +161,12 @@ void gui_window_update_extent(struct gui_window *g)
[[window browserView] setMinimumSize: cocoa_scaled_size( browser->scale, width, height )];
}
-void gui_window_set_status(struct gui_window *g, const char *text)
+static void gui_window_set_status(struct gui_window *g, const char *text)
{
[(BrowserViewController *)g setStatus: [NSString stringWithUTF8String: text]];
}
-void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
+static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
switch (shape) {
case GUI_POINTER_DEFAULT:
@@ -209,28 +199,24 @@ 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)
+static void gui_window_set_url(struct gui_window *g, const char *url)
{
[(BrowserViewController *)g setUrl: [NSString stringWithUTF8String: url]];
}
-void gui_window_start_throbber(struct gui_window *g)
+static void gui_window_start_throbber(struct gui_window *g)
{
[(BrowserViewController *)g setIsProcessing: YES];
[(BrowserViewController *)g updateBackForward];
}
-void gui_window_stop_throbber(struct gui_window *g)
+static void gui_window_stop_throbber(struct gui_window *g)
{
[(BrowserViewController *)g setIsProcessing: NO];
[(BrowserViewController *)g updateBackForward];
}
-void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
+static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
{
NSBitmapImageRep *bmp = icon != NULL ? (NSBitmapImageRep *)content_get_bitmap( icon ) : NULL;
@@ -247,56 +233,25 @@ void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
[image release];
}
-void gui_window_set_search_ico(hlcache_handle *ico)
-{
- UNIMPL();
-}
-
-void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
+static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
[[(BrowserViewController *)g browserView] addCaretAt: cocoa_point( x, y )
height: cocoa_px_to_pt( height )];
}
-void gui_window_remove_caret(struct gui_window *g)
+static void gui_window_remove_caret(struct gui_window *g)
{
[[(BrowserViewController *)g browserView] removeCaret];
}
-void gui_window_new_content(struct gui_window *g)
+static void gui_window_new_content(struct gui_window *g)
{
[(BrowserViewController *)g contentUpdated];
}
-bool gui_window_scroll_start(struct gui_window *g)
-{
- return true;
-}
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
-{
- return true;
-}
-
-void gui_window_save_link(struct gui_window *g, const char *url,
- const char *title)
-{
- UNIMPL();
-}
-
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *g)
-{
-}
-
-void gui_drag_save_selection(struct gui_window *g, const char *selection)
-{
-}
-
-
-void gui_create_form_select_menu(struct browser_window *bw,
+static void gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control)
{
FormSelectMenu *menu = [[FormSelectMenu alloc] initWithControl: control forWindow: bw];
@@ -304,31 +259,78 @@ void gui_create_form_select_menu(struct browser_window *bw,
[menu release];
}
-void gui_launch_url(const char *url)
+static void gui_launch_url(const char *url)
{
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: [NSString stringWithUTF8String: url]]];
}
struct ssl_cert_info;
-void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
+static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
{
cb( false, cbpw );
}
-
-void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
+static char *filename_from_path(char *path)
{
- cb( false, cbpw );
+ return strdup( [[[NSString stringWithUTF8String: path] lastPathComponent] UTF8String] );
}
-void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
- struct form_control *gadget)
+static bool path_add_part(char *path, int length, const char *newpart)
{
- LOG(("File open dialog rquest for %p/%p", g, gadget));
- /* browser_window_set_gadget_filename(bw, gadget, "filename"); */
+ NSString *newPath = [[NSString stringWithUTF8String: path] stringByAppendingPathComponent: [NSString stringWithUTF8String: newpart]];
+
+ strncpy( path, [newPath UTF8String], length );
+
+ return true;
}
+
+static struct gui_window_table window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .set_icon = gui_window_set_icon,
+ .set_status = gui_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .new_content = gui_window_new_content,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+};
+
+struct gui_window_table *cocoa_window_table = &window_table;
+
+
+static struct gui_clipboard_table clipboard_table = {
+ .get_clipboard = gui_get_clipboard,
+ .set_clipboard = gui_set_clipboard,
+};
+
+struct gui_clipboard_table *cocoa_clipboard_table = &clipboard_table;
+
+
+static struct gui_browser_table browser_table = {
+ .poll = gui_poll,
+ .get_resource_url = gui_get_resource_url,
+ .launch_url = gui_launch_url,
+ .create_form_select_menu = gui_create_form_select_menu,
+ .cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+};
+
+struct gui_browser_table *cocoa_browser_table = &browser_table;
+
+
diff --git a/cocoa/selection.h b/cocoa/selection.h
new file mode 100644
index 000000000..14b6e763f
--- /dev/null
+++ b/cocoa/selection.h
@@ -0,0 +1,2 @@
+void gui_get_clipboard(char **buffer, size_t *length);
+void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles);
diff --git a/cocoa/selection.m b/cocoa/selection.m
index 237c61ce2..e95a78441 100644
--- a/cocoa/selection.m
+++ b/cocoa/selection.m
@@ -19,21 +19,13 @@
#import <Cocoa/Cocoa.h>
#import "cocoa/BrowserViewController.h"
+#import "cocoa/selection.h"
#import "desktop/browser_private.h"
static NSMutableString *cocoa_clipboard_string;
-void gui_start_selection(struct gui_window *g)
-{
-}
-
-void gui_clear_selection(struct gui_window *g)
-{
-}
-
-
/**
* Core asks front end for clipboard contents.
*
diff --git a/cocoa/utils.m b/cocoa/utils.m
index cd9313d34..61226ad2a 100644
--- a/cocoa/utils.m
+++ b/cocoa/utils.m
@@ -41,16 +41,3 @@ void PDF_Password(char **owner_pass, char **user_pass, char *path)
UNIMPL();
}
-char *filename_from_path(char *path)
-{
- return strdup( [[[NSString stringWithUTF8String: path] lastPathComponent] UTF8String] );
-}
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- NSString *newPath = [[NSString stringWithUTF8String: path] stringByAppendingPathComponent: [NSString stringWithUTF8String: newpart]];
-
- strncpy( path, [newPath UTF8String], length );
-
- return true;
-}
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 7578ad4cb..92d4625b5 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -45,6 +45,7 @@
#include "content/fetchers/curl.h"
#include "content/urldb.h"
#include "desktop/netsurf.h"
+#include "desktop/gui_factory.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -1268,7 +1269,7 @@ fetch_curl_post_convert(const struct fetch_multipart_data *control)
if (control->file) {
char *leafname = 0;
- leafname = filename_from_path(control->value);
+ leafname = guit->browser->filename_from_path(control->value);
if (leafname == NULL)
continue;
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index c574c2160..26ef9069b 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -47,6 +47,7 @@
#include "content/fetchers/file.h"
#include "content/urldb.h"
#include "desktop/netsurf.h"
+#include "desktop/gui_factory.h"
#include "utils/nsoption.h"
#include "utils/errors.h"
#include "utils/log.h"
@@ -574,7 +575,7 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx,
continue;
strncpy(urlpath, ctx->path, sizeof urlpath);
- if (path_add_part(urlpath, sizeof urlpath,
+ if (guit->browser->path_add_part(urlpath, sizeof urlpath,
ent->d_name) == false)
continue;
diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c
index 0119c6b3b..d1b21b741 100644
--- a/content/fetchers/resource.c
+++ b/content/fetchers/resource.c
@@ -42,6 +42,7 @@
#include "content/fetchers/resource.h"
#include "content/urldb.h"
#include "desktop/gui.h"
+#include "desktop/gui_factory.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -206,7 +207,7 @@ static bool fetch_resource_initialise(lwc_string *scheme)
}
}
- e->url = gui_get_resource_url(fetch_resource_paths[i]);
+ e->url = guit->browser->get_resource_url(fetch_resource_paths[i]);
if (e->url == NULL) {
lwc_string_unref(e->path);
} else {
diff --git a/desktop/Makefile b/desktop/Makefile
index f7020074e..0e2e460de 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -13,7 +13,7 @@ desktop/version.c: testament utils/testament.h
# S_BROWSER are sources related to full browsers but are common
# between RISC OS, GTK, BeOS and AmigaOS builds
S_BROWSER := browser.c download.c frames.c local_history.c netsurf.c \
- save_complete.c save_text.c selection.c textinput.c
+ save_complete.c save_text.c selection.c textinput.c gui_factory.c
S_BROWSER := $(addprefix desktop/,$(S_BROWSER))
diff --git a/desktop/browser.c b/desktop/browser.c
index 6ec31d22f..f66e27576 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -41,12 +41,12 @@
#include "content/fetch.h"
#include "content/hlcache.h"
#include "content/urldb.h"
-#include "desktop/401login.h"
#include "desktop/browser_private.h"
#include "desktop/download.h"
#include "desktop/frames.h"
#include "desktop/global_history.h"
#include "desktop/gui.h"
+#include "desktop/gui_factory.h"
#include "desktop/hotlist.h"
#include "desktop/knockout.h"
#include "desktop/local_history.h"
@@ -300,7 +300,7 @@ void browser_window_update_extent(struct browser_window *bw)
{
if (bw->window != NULL)
/* Front end window */
- gui_window_update_extent(bw->window);
+ guit->window->update_extent(bw->window);
else
/* Core-managed browser window */
browser_window_handle_scrollbars(bw);
@@ -391,7 +391,7 @@ void browser_window_set_drag_type(struct browser_window *bw,
break;
}
- gui_window_drag_start(top_bw->window, gtype, rect);
+ guit->window->drag_start(top_bw->window, gtype, rect);
}
}
@@ -484,7 +484,7 @@ void browser_window_scroll_visible(struct browser_window *bw,
if (bw->window != NULL) {
/* Front end window */
- gui_window_scroll_visible(bw->window,
+ guit->window->scroll_visible(bw->window,
rect->x0, rect->y0, rect->x1, rect->y1);
} else {
/* Core managed browser window */
@@ -499,7 +499,7 @@ void browser_window_scroll_visible(struct browser_window *bw,
void browser_window_set_scroll(struct browser_window *bw, int x, int y)
{
if (bw->window != NULL) {
- gui_window_set_scroll(bw->window, x, y);
+ guit->window->set_scroll(bw->window, x, y);
} else {
if (bw->scroll_x != NULL)
scrollbar_set(bw->scroll_x, x, false);
@@ -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);
@@ -815,7 +813,7 @@ browser_window_download(struct browser_window *bw,
NULL, NULL, &l);
if (error == NSERROR_NO_FETCH_HANDLER) {
/* no internal handler for this type, call out to frontend */
- gui_launch_url(nsurl_access(url));
+ guit->browser->launch_url(nsurl_access(url));
} else if (error != NSERROR_OK) {
LOG(("Failed to fetch download: %d", error));
} else {
@@ -868,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);
}
@@ -885,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);
+ }
}
@@ -919,7 +918,7 @@ static nserror browser_window_favicon_callback(hlcache_handle *c,
/* content_get_bitmap on the hlcache_handle should give
* us the favicon bitmap at this point
*/
- gui_window_set_icon(bw->window, c);
+ guit->window->set_icon(bw->window, c);
break;
case CONTENT_MSG_ERROR:
@@ -1234,7 +1233,7 @@ static nserror browser_window_callback(hlcache_handle *c,
browser_window_remove_caret(bw, false);
if (bw->window != NULL) {
- gui_window_new_content(bw->window);
+ guit->window->new_content(bw->window);
browser_window_refresh_url_bar(bw,
hlcache_handle_get_url(bw->current_content),
@@ -1485,20 +1484,23 @@ static nserror browser_window_callback(hlcache_handle *c,
switch(event->data.dragsave.type) {
case CONTENT_SAVE_ORIG:
- gui_drag_save_object(GUI_SAVE_OBJECT_ORIG, save,
- root->window);
+ guit->window->drag_save_object(root->window, save,
+ GUI_SAVE_OBJECT_ORIG);
break;
+
case CONTENT_SAVE_NATIVE:
- gui_drag_save_object(GUI_SAVE_OBJECT_NATIVE, save,
- root->window);
+ guit->window->drag_save_object(root->window, save,
+ GUI_SAVE_OBJECT_NATIVE);
break;
+
case CONTENT_SAVE_COMPLETE:
- gui_drag_save_object(GUI_SAVE_COMPLETE, save,
- root->window);
+ guit->window->drag_save_object(root->window, save,
+ GUI_SAVE_COMPLETE);
break;
+
case CONTENT_SAVE_SOURCE:
- gui_drag_save_object(GUI_SAVE_SOURCE, save,
- root->window);
+ guit->window->drag_save_object(root->window, save,
+ GUI_SAVE_SOURCE);
break;
}
}
@@ -1508,7 +1510,7 @@ static nserror browser_window_callback(hlcache_handle *c,
{
/* Content wants a link to be saved */
struct browser_window *root = browser_window_get_root(bw);
- gui_window_save_link(root->window,
+ guit->window->save_link(root->window,
event->data.savelink.url,
event->data.savelink.title);
}
@@ -1564,7 +1566,7 @@ static nserror browser_window_callback(hlcache_handle *c,
case CONTENT_MSG_GADGETCLICK:
if (event->data.gadget_click.gadget->type == GADGET_FILE) {
- gui_file_gadget_open(bw->window, c,
+ guit->window->file_gadget_open(bw->window, c,
event->data.gadget_click.gadget);
}
@@ -1644,7 +1646,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) {
@@ -1870,7 +1872,7 @@ nserror browser_window_navigate(struct browser_window *bw,
case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */
/** @todo does this always try and download even unverifiable content? */
- gui_launch_url(nsurl_access(url));
+ guit->browser->launch_url(nsurl_access(url));
break;
default: /* report error to user */
@@ -1913,7 +1915,7 @@ void browser_window_get_dimensions(struct browser_window *bw,
*height = bw->height;
} else {
/* Front end window */
- gui_window_get_dimensions(bw->window, width, height, scaled);
+ guit->window->get_dimensions(bw->window, width, height, scaled);
}
}
@@ -1960,7 +1962,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);
@@ -1975,7 +1977,7 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top)
browser_window_set_scroll(bw, x, y);
}
- gui_window_redraw_window(bw->window);
+ guit->window->redraw(bw->window);
break;
@@ -2041,7 +2043,7 @@ void browser_window_update_box(struct browser_window *bw, struct rect *rect)
if (bw->window != NULL) {
/* Front end window */
- gui_window_update_box(bw->window, rect);
+ guit->window->update(bw->window, rect);
} else {
/* Core managed browser window */
browser_window_get_position(bw, true, &pos_x, &pos_y);
@@ -2053,7 +2055,7 @@ void browser_window_update_box(struct browser_window *bw, struct rect *rect)
rect->x1 += pos_x / bw->scale;
rect->y1 += pos_y / bw->scale;
- gui_window_update_box(top->window, rect);
+ guit->window->update(top->window, rect);
}
}
@@ -2194,7 +2196,7 @@ void browser_window_set_status(struct browser_window *bw, const char *text)
}
bw->status_miss++;
- gui_window_set_status(bw->window, bw->status_text);
+ guit->window->set_status(bw->window, bw->status_text);
}
@@ -2236,7 +2238,7 @@ void browser_window_set_pointer(struct browser_window *bw,
gui_shape = (gui_pointer_shape)shape;
}
- gui_window_set_pointer(root->window, gui_shape);
+ guit->window->set_pointer(root->window, gui_shape);
}
@@ -2360,7 +2362,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;
@@ -2371,7 +2373,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);
}
}
@@ -2894,14 +2896,14 @@ void browser_window_mouse_click(struct browser_window *bw,
break;
default:
if (mouse & BROWSER_MOUSE_MOD_2) {
- if (mouse & BROWSER_MOUSE_DRAG_2)
- gui_drag_save_object(GUI_SAVE_OBJECT_NATIVE, c,
- bw->window);
- else if (mouse & BROWSER_MOUSE_DRAG_1)
- gui_drag_save_object(GUI_SAVE_OBJECT_ORIG, c,
- bw->window);
- }
- else if (mouse & (BROWSER_MOUSE_DRAG_1 |
+ if (mouse & BROWSER_MOUSE_DRAG_2) {
+ guit->window->drag_save_object(bw->window, c,
+ GUI_SAVE_OBJECT_NATIVE);
+ } else if (mouse & BROWSER_MOUSE_DRAG_1) {
+ guit->window->drag_save_object(bw->window, c,
+ GUI_SAVE_OBJECT_ORIG);
+ }
+ } else if (mouse & (BROWSER_MOUSE_DRAG_1 |
BROWSER_MOUSE_DRAG_2)) {
browser_window_page_drag_start(bw, x, y);
browser_window_set_pointer(bw, BROWSER_POINTER_MOVE);
@@ -2947,10 +2949,10 @@ void browser_window_page_drag_start(struct browser_window *bw, int x, int y)
if (bw->window != NULL) {
/* Front end window */
- gui_window_get_scroll(bw->window, &bw->drag_start_scroll_x,
+ guit->window->get_scroll(bw->window, &bw->drag_start_scroll_x,
&bw->drag_start_scroll_y);
- gui_window_scroll_start(bw->window);
+ guit->window->scroll_start(bw->window);
} else {
/* Core managed browser window */
bw->drag_start_scroll_x = scrollbar_get_offset(bw->scroll_x);
diff --git a/desktop/download.c b/desktop/download.c
index b775eb18e..14390c78a 100644
--- a/desktop/download.c
+++ b/desktop/download.c
@@ -27,6 +27,7 @@
#include "content/llcache.h"
#include "desktop/download.h"
#include "desktop/gui.h"
+#include "desktop/gui_factory.h"
#include "utils/http.h"
#include "utils/url.h"
#include "utils/utils.h"
@@ -160,7 +161,7 @@ static nserror download_context_process_headers(download_context *ctx)
}
/* Create the frontend window */
- ctx->window = gui_download_window_create(ctx, ctx->parent);
+ ctx->window = guit->download->create(ctx, ctx->parent);
if (ctx->window == NULL) {
free(ctx->filename);
ctx->filename = NULL;
@@ -210,7 +211,7 @@ static nserror download_callback(llcache_handle *handle,
if (error == NSERROR_OK) {
/** \todo Lose ugly cast */
- error = gui_download_window_data(ctx->window,
+ error = guit->download->data(ctx->window,
(char *) event->data.data.buf,
event->data.data.len);
if (error != NSERROR_OK)
@@ -222,7 +223,7 @@ static nserror download_callback(llcache_handle *handle,
case LLCACHE_EVENT_DONE:
/* There may be no associated window if there was no data or headers */
if (ctx->window != NULL)
- gui_download_window_done(ctx->window);
+ guit->download->done(ctx->window);
else
download_context_destroy(ctx);
@@ -230,7 +231,7 @@ static nserror download_callback(llcache_handle *handle,
case LLCACHE_EVENT_ERROR:
if (ctx->window != NULL)
- gui_download_window_error(ctx->window, event->data.msg);
+ guit->download->error(ctx->window, event->data.msg);
else
download_context_destroy(ctx);
diff --git a/desktop/gui.h b/desktop/gui.h
index 9317e8576..5252737f9 100644
--- a/desktop/gui.h
+++ b/desktop/gui.h
@@ -1,6 +1,5 @@
/*
- * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
- * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
+ * Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -24,6 +23,12 @@
#ifndef _NETSURF_DESKTOP_GUI_H_
#define _NETSURF_DESKTOP_GUI_H_
+#include <stdbool.h>
+
+#include "content/hlcache.h"
+#include "desktop/download.h"
+#include "utils/errors.h"
+
typedef enum {
GUI_SAVE_SOURCE,
GUI_SAVE_DRAW,
@@ -52,121 +57,330 @@ struct gui_window;
struct gui_download_window;
struct browser_window;
struct form_control;
+struct ssl_cert_info;
-#include <stdbool.h>
+typedef struct nsnsclipboard_styles {
+ size_t start; /**< Start of run */
-#include <libwapcaplet/libwapcaplet.h>
-#include <libcss/libcss.h>
+ plot_font_style_t style; /**< Style to give text run */
+} nsclipboard_styles;
-#include "utils/config.h"
-#include "content/hlcache.h"
-#include "desktop/download.h"
-#include "desktop/mouse.h"
-#include "desktop/search.h"
-#include "utils/errors.h"
+/** Graphical user interface window function table
+ *
+ * function table implementing window operations
+ */
+struct gui_window_table {
+
+ /* Mandantory entries */
+
+ /** create a gui window for a browsing context */
+ struct gui_window *(*create)(struct browser_window *bw, struct browser_window *clone, bool new_tab);
+
+ /** destroy previously created gui window */
+ void (*destroy)(struct gui_window *g);
+
+ /**
+ * Force a redraw of the entire contents of a window.
+ *
+ * @todo this API should be merged with update.
+ *
+ * \param g gui_window to redraw
+ */
+ void (*redraw)(struct gui_window *g);
+
+ /**
+ * Redraw an area of a window.
+ *
+ * \param g gui_window
+ * \param rect area to redraw
+ */
+ void (*update)(struct gui_window *g, const struct rect *rect);
+
+ /**
+ * Get the scroll position of a browser window.
+ *
+ * \param g gui_window
+ * \param sx receives x ordinate of point at top-left of window
+ * \param sy receives y ordinate of point at top-left of window
+ * \return true iff successful
+ */
+ bool (*get_scroll)(struct gui_window *g, int *sx, int *sy);
+
+ /**
+ * Set the scroll position of a browser window.
+ *
+ * \param g gui_window to scroll
+ * \param sx point to place at top-left of window
+ * \param sy point to place at top-left of window
+ */
+ void (*set_scroll)(struct gui_window *g, int sx, int sy);
+
+ /**
+ * Find the current dimensions of a browser window's content area.
+ *
+ * @todo The implementations of this are buggy and its only
+ * used from frames code.
+ *
+ * \param g gui_window to measure
+ * \param width receives width of window
+ * \param height receives height of window
+ * \param scaled whether to return scaled values
+ */
+ void (*get_dimensions)(struct gui_window *g, int *width, int *height, bool scaled);
+
+ /**
+ * Update the extent of the inside of a browser window to that of the
+ * current content.
+ *
+ * @todo this is used to update scroll bars does it need
+ * renaming? some frontends (windows) do not even implement it.
+ *
+ * \param g gui_window to update the extent of
+ */
+ void (*update_extent)(struct gui_window *g);
+
+
+
+ /* Optional entries */
+
+ /**
+ * Set the title of a window.
+ *
+ * \param g window to update
+ * \param title new window title
+ */
+ void (*set_title)(struct gui_window *g, const char *title);
+
+ /** set the navigation url. */
+ void (*set_url)(struct gui_window *g, const char *url);
+
+ /** set favicon */
+ void (*set_icon)(struct gui_window *g, hlcache_handle *icon);
+
+ /**
+ * Set the status bar of a browser window.
+ *
+ * \param g gui_window to update
+ * \param text new status text
+ */
+ void (*set_status)(struct gui_window *g, const char *text);
+
+ /**
+ * Change mouse pointer shape
+ */
+ void (*set_pointer)(struct gui_window *g, gui_pointer_shape shape);
+
+ /**
+ * Place the caret in a browser window.
+ *
+ * \param g window with caret
+ * \param x coordinates of caret
+ * \param y coordinates of caret
+ * \param height height of caret
+ * \param clip clip rectangle, or NULL if none
+ */
+ void (*place_caret)(struct gui_window *g, int x, int y, int height, const struct rect *clip);
+
+ /**
+ * Remove the caret, if present.
+ *
+ * \param g window with caret
+ */
+ void (*remove_caret)(struct gui_window *g);
-void gui_poll(bool active);
-void gui_quit(void);
-
-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,
- const struct rect *rect);
-bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy);
-void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
-void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
- int x1, int y1);
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
- bool scaled);
-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,
- const struct rect *clip);
-void gui_window_remove_caret(struct gui_window *g);
-void gui_window_new_content(struct gui_window *g);
-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,
- 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,
- const char *data, unsigned int size);
-void gui_download_window_error(struct gui_download_window *dw,
- const char *error_msg);
-void gui_download_window_done(struct gui_download_window *dw);
-
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *g);
-void gui_drag_save_selection(struct gui_window *g, const char *selection);
-void gui_start_selection(struct gui_window *g);
-void gui_clear_selection(struct gui_window *g);
-
-void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
- struct form_control *gadget);
+ /** start the navigation throbber. */
+ void (*start_throbber)(struct gui_window *g);
+
+ /** stop the navigation throbber. */
+ void (*stop_throbber)(struct gui_window *g);
+
+ /** start a drag operation within a window */
+ bool (*drag_start)(struct gui_window *g, gui_drag_type type, const struct rect *rect);
+
+ /** save link operation */
+ void (*save_link)(struct gui_window *g, const char *url, const char *title);
+
+ /**
+ * Scrolls the specified area of a browser window into view.
+ *
+ * @todo investigate if this can be merged with set_scroll
+ * which is what the default implementation used by most
+ * toolkits uses.
+ *
+ * \param g gui_window to scroll
+ * \param x0 left point to ensure visible
+ * \param y0 bottom point to ensure visible
+ * \param x1 right point to ensure visible
+ * \param y1 top point to ensure visible
+ */
+ void (*scroll_visible)(struct gui_window *g, int x0, int y0, int x1, int y1);
+
+ /**
+ * Starts drag scrolling of a browser window
+ *
+ * \param g the window to scroll
+ */
+ bool (*scroll_start)(struct gui_window *g);
+
+ /**
+ * Called when the gui_window has new content.
+ *
+ * \param g the gui_window that has new content
+ */
+ void (*new_content)(struct gui_window *g);
+
+ /**
+ * Called when file chooser gadget is activated
+ */
+ void (*file_gadget_open)(struct gui_window *g, hlcache_handle *hl, struct form_control *gadget);
+
+ /** object dragged to window*/
+ void (*drag_save_object)(struct gui_window *g, hlcache_handle *c, gui_save_type type);
+
+ /** drag selection save */
+ void (*drag_save_selection)(struct gui_window *g, const char *selection);
+
+ /** selection started */
+ void (*start_selection)(struct gui_window *g);
+};
/**
- * Core asks front end for clipboard contents.
- *
- * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
- * \param length Byte length of UTF-8 text in buffer
+ * function table for download windows
*/
-void gui_get_clipboard(char **buffer, size_t *length);
+struct gui_download_table {
+ struct gui_download_window *(*create)(download_context *ctx, struct gui_window *parent);
-typedef struct nsnsclipboard_styles {
- size_t start; /**< Start of run */
+ nserror (*data)(struct gui_download_window *dw, const char *data, unsigned int size);
+
+ void (*error)(struct gui_download_window *dw, const char *error_msg);
+
+ void (*done)(struct gui_download_window *dw);
+};
- plot_font_style_t style; /**< Style to give text run */
-} nsclipboard_styles;
/**
- * Core tells front end to put given text in clipboard
+ * function table for clipboard operations
+ */
+struct gui_clipboard_table {
+ /**
+ * Core asks front end for clipboard contents.
+ *
+ * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
+ * \param length Byte length of UTF-8 text in buffer
+ */
+ void (*get)(char **buffer, size_t *length);
+
+ /**
+ * Core tells front end to put given text in clipboard
+ *
+ * \param buffer UTF-8 text, owned by core
+ * \param length Byte length of UTF-8 text in buffer
+ * \param styles Array of styles given to text runs, owned by core, or NULL
+ * \param n_styles Number of text run styles in array
+ */
+ void (*set)(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles);
+};
+
+/** Graphical user interface browser misc function table
*
- * \param buffer UTF-8 text, owned by core
- * \param length Byte length of UTF-8 text in buffer
- * \param styles Array of styles given to text runs, owned by core, or NULL
- * \param n_styles Number of text run styles in array
+ * function table implementing GUI interface to miscelaneous browser
+ * functionality
*/
-void gui_set_clipboard(const char *buffer, size_t length,
- nsclipboard_styles styles[], int n_styles);
+struct gui_browser_table {
+ /* Mandantory entries */
+ /**
+ * called to let the frontend update its state and run any
+ * I/O operations.
+ */
+ void (*poll)(bool active);
+ /**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+ char *(*filename_from_path)(char *path);
-void gui_create_form_select_menu(struct browser_window *bw,
- struct form_control *control);
+ /**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+ bool (*path_add_part)(char *path, int length, const char *newpart);
-void gui_launch_url(const char *url);
+ /* Optional entries */
-struct ssl_cert_info;
+ /** called to allow the gui to cleanup */
+ void (*quit)(void);
-void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
- unsigned long num, nserror (*cb)(bool proceed, void *pw),
- void *cbpw);
+ /**
+ * set gui display of a retrieved favicon representing the
+ * search provider
+ *
+ * \param ico may be NULL for local calls; then access current
+ * cache from search_web_ico()
+ */
+ void (*set_search_ico)(hlcache_handle *ico);
-/**
- * Callback to translate resource to full url.
- *
- * Transforms a resource: path into a full URL. The returned URL
- * is used as the target for a redirect. The caller takes ownership of
- * the returned nsurl including unrefing it when finished with it.
+ /**
+ * Callback to translate resource to full url.
+ *
+ * Transforms a resource: path into a full URL. The returned URL
+ * is used as the target for a redirect. The caller takes ownership of
+ * the returned nsurl including unrefing it when finished with it.
+ *
+ * \param path The path of the resource to locate.
+ * \return A string containing the full URL of the target object or
+ * NULL if no suitable resource can be found.
+ */
+ nsurl* (*get_resource_url)(const char *path);
+
+ /**
+ * core has no fetcher for url
+ */
+ void (*launch_url)(const char *url);
+
+ /**
+ * create a form select menu
+ */
+ void (*create_form_select_menu)(struct browser_window *bw, struct form_control *control);
+
+ /**
+ * verify certificate
+ */
+ void (*cert_verify)(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw);
+
+ /**
+ * Prompt user for login
+ */
+ void (*login)(nsurl *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
+
+};
+
+
+/** Graphical user interface function table
*
- * \param path The path of the resource to locate.
- * \return A string containing the full URL of the target object or
- * NULL if no suitable resource can be found.
+ * function table implementing GUI interface to browser core
*/
-nsurl* gui_get_resource_url(const char *path);
+struct gui_table {
+
+ /** Browser table */
+ struct gui_browser_table *browser;
+
+ /** Window table */
+ struct gui_window_table *window;
+
+ /** Download table */
+ struct gui_download_table *download;
+
+ /** Clipboard table */
+ struct gui_clipboard_table *clipboard;
+};
+
#endif
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
new file mode 100644
index 000000000..104f4906d
--- /dev/null
+++ b/desktop/gui_factory.c
@@ -0,0 +1,440 @@
+/*
+ * Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "desktop/gui.h"
+#include "desktop/gui_factory.h"
+
+/** The global GUI interface table */
+struct gui_table *guit = NULL;
+
+
+
+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)
+{
+}
+
+static bool gui_default_window_drag_start(struct gui_window *g,
+ gui_drag_type type,
+ const struct rect *rect)
+{
+ return true;
+}
+
+static void gui_default_window_save_link(struct gui_window *g,
+ const char *url,
+ const char *title)
+{
+}
+
+static void gui_default_window_set_icon(struct gui_window *g,
+ hlcache_handle *icon)
+{
+}
+
+static void gui_default_window_scroll_visible(struct gui_window *g,
+ int x0, int y0,
+ int x1, int y1)
+{
+ guit->window->set_scroll(g, x0, y0);
+}
+
+static void gui_default_window_new_content(struct gui_window *g)
+{
+}
+
+
+static bool gui_default_window_scroll_start(struct gui_window *g)
+{
+ return true;
+}
+
+static void gui_default_window_set_pointer(struct gui_window *g,
+ gui_pointer_shape shape)
+{
+}
+
+static void gui_default_window_set_status(struct gui_window *g,
+ const char *text)
+{
+}
+
+static void gui_default_window_place_caret(struct gui_window *g,
+ int x, int y, int height,
+ const struct rect *clip)
+{
+}
+
+static void gui_default_window_remove_caret(struct gui_window *g)
+{
+}
+
+static void gui_default_window_file_gadget_open(struct gui_window *g,
+ hlcache_handle *hl,
+ struct form_control *gadget)
+{
+}
+
+static void gui_default_window_drag_save_object(struct gui_window *g,
+ hlcache_handle *c,
+ gui_save_type type)
+{
+}
+
+static void gui_default_window_drag_save_selection(struct gui_window *g,
+ const char *selection)
+{
+}
+
+static void gui_default_window_start_selection(struct gui_window *g)
+{
+}
+
+
+/** verify window table is valid */
+static nserror verify_window_register(struct gui_window_table *gwt)
+{
+ /* check table is present */
+ if (gwt == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ /* check the mandantory fields are set */
+ if (gwt->create == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gwt->destroy == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gwt->redraw == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gwt->update == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gwt->get_scroll == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gwt->set_scroll == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gwt->get_dimensions == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gwt->update_extent == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+
+ /* fill in the optional entries with defaults */
+ if (gwt->set_title == NULL) {
+ gwt->set_title = gui_default_window_set_title;
+ }
+ if (gwt->set_url == NULL) {
+ gwt->set_url = gui_default_window_set_url;
+ }
+ if (gwt->set_icon == NULL) {
+ gwt->set_icon = gui_default_window_set_icon;
+ }
+ if (gwt->set_status == NULL) {
+ gwt->set_status = gui_default_window_set_status;
+ }
+ if (gwt->set_pointer == NULL) {
+ gwt->set_pointer = gui_default_window_set_pointer;
+ }
+ if (gwt->place_caret == NULL) {
+ gwt->place_caret = gui_default_window_place_caret;
+ }
+ if (gwt->remove_caret == NULL) {
+ gwt->remove_caret = gui_default_window_remove_caret;
+ }
+ if (gwt->start_throbber == NULL) {
+ gwt->start_throbber = gui_default_window_start_throbber;
+ }
+ if (gwt->stop_throbber == NULL) {
+ gwt->stop_throbber = gui_default_window_stop_throbber;
+ }
+ if (gwt->drag_start == NULL) {
+ gwt->drag_start = gui_default_window_drag_start;
+ }
+ if (gwt->save_link == NULL) {
+ gwt->save_link = gui_default_window_save_link;
+ }
+ if (gwt->scroll_visible == NULL) {
+ gwt->scroll_visible = gui_default_window_scroll_visible;
+ }
+ if (gwt->new_content == NULL) {
+ gwt->new_content = gui_default_window_new_content;
+ }
+ if (gwt->scroll_start == NULL) {
+ gwt->scroll_start = gui_default_window_scroll_start;
+ }
+ if (gwt->file_gadget_open == NULL) {
+ gwt->file_gadget_open = gui_default_window_file_gadget_open;
+ }
+ if (gwt->drag_save_object == NULL) {
+ gwt->drag_save_object = gui_default_window_drag_save_object;
+ }
+ if (gwt->drag_save_selection == NULL) {
+ gwt->drag_save_selection = gui_default_window_drag_save_selection;
+ }
+ if (gwt->start_selection == NULL) {
+ gwt->start_selection = gui_default_window_start_selection;
+ }
+
+ return NSERROR_OK;
+}
+
+
+
+static struct gui_download_window *
+gui_default_download_create(download_context *ctx, struct gui_window *parent)
+{
+ return NULL;
+}
+
+static nserror gui_default_download_data(struct gui_download_window *dw,
+ const char *data, unsigned int size)
+{
+ return NSERROR_OK;
+}
+
+static void gui_default_download_error(struct gui_download_window *dw,
+ const char *error_msg)
+{
+}
+
+static void gui_default_download_done(struct gui_download_window *dw)
+{
+}
+
+
+/** verify download window table is valid */
+static nserror verify_download_register(struct gui_download_table *gdt)
+{
+ /* check table is present */
+ if (gdt == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ /* all enties are mandantory */
+ if (gdt->create == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gdt->data == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gdt->error == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gdt->done == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ return NSERROR_OK;
+}
+
+static void gui_default_get_clipboard(char **buffer, size_t *length)
+{
+ *buffer = NULL;
+ *length = 0;
+}
+
+static void gui_default_set_clipboard(const char *buffer, size_t length,
+ nsclipboard_styles styles[], int n_styles)
+{
+}
+
+/** verify clipboard table is valid */
+static nserror verify_clipboard_register(struct gui_clipboard_table *gct)
+{
+ /* check table is present */
+ if (gct == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ /* optional operations */
+ if (gct->get == NULL) {
+ gct->get = gui_default_get_clipboard;
+ }
+ if (gct->set == NULL) {
+ gct->set = gui_default_set_clipboard;
+ }
+ return NSERROR_OK;
+}
+
+
+static void gui_default_quit(void)
+{
+}
+
+static void gui_default_set_search_ico(hlcache_handle *ico)
+{
+}
+
+static nsurl *gui_default_get_resource_url(const char *path)
+{
+ return NULL;
+}
+
+static void gui_default_launch_url(const char *url)
+{
+}
+
+static void gui_default_create_form_select_menu(struct browser_window *bw,
+ struct form_control *control)
+{
+}
+
+
+static void gui_default_cert_verify(nsurl *url,
+ const struct ssl_cert_info *certs,
+ unsigned long num,
+ nserror (*cb)(bool proceed, void *pw),
+ void *cbpw)
+{
+ cb(false, cbpw);
+}
+
+static void gui_default_401login_open(nsurl *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw)
+{
+ cb(false, cbpw);
+}
+
+/** verify browser table is valid */
+static nserror verify_browser_register(struct gui_browser_table *gbt)
+{
+ /* check table is present */
+ if (gbt == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ /* check the mandantory fields are set */
+ if (gbt->poll == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gbt->filename_from_path == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gbt->path_add_part == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+
+ /* fill in the optional entries with defaults */
+ if (gbt->quit == NULL) {
+ gbt->quit = gui_default_quit;
+ }
+ if (gbt->set_search_ico == NULL) {
+ gbt->set_search_ico = gui_default_set_search_ico;
+ }
+ if (gbt->get_resource_url == NULL) {
+ gbt->get_resource_url = gui_default_get_resource_url;
+ }
+ if (gbt->launch_url == NULL) {
+ gbt->launch_url = gui_default_launch_url;
+ }
+ if (gbt->create_form_select_menu == NULL) {
+ gbt->create_form_select_menu = gui_default_create_form_select_menu;
+ }
+ if (gbt->cert_verify == NULL) {
+ gbt->cert_verify = gui_default_cert_verify;
+ }
+ if (gbt->login == NULL) {
+ gbt->login = gui_default_401login_open;
+ }
+ return NSERROR_OK;
+}
+
+
+
+static struct gui_download_table default_download_table = {
+ .create = gui_default_download_create,
+ .data = gui_default_download_data,
+ .error = gui_default_download_error,
+ .done = gui_default_download_done,
+};
+
+static struct gui_clipboard_table default_clipboard_table = {
+ .get = gui_default_get_clipboard,
+ .set = gui_default_set_clipboard,
+};
+
+/* exported interface documented in desktop/gui_factory.h */
+nserror gui_factory_register(struct gui_table *gt)
+{
+ nserror err;
+
+ /* ensure not already initialised */
+ if (guit != NULL) {
+ return NSERROR_INIT_FAILED;
+ }
+
+ /* check table is present */
+ if (gt == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ /* browser table */
+ err = verify_browser_register(gt->browser);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
+ /* window table */
+ err = verify_window_register(gt->window);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
+ /* download table */
+ if (gt->download == NULL) {
+ /* set default download table */
+ gt->download = &default_download_table;
+ }
+ err = verify_download_register(gt->download);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
+ /* clipboard table */
+ if (gt->clipboard == NULL) {
+ /* set default clipboard table */
+ gt->clipboard = &default_clipboard_table;
+ }
+ err = verify_clipboard_register(gt->clipboard);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
+ guit = gt;
+
+ return NSERROR_OK;
+}
diff --git a/desktop/401login.h b/desktop/gui_factory.h
index 1c8140bae..dc94b3a16 100644
--- a/desktop/401login.h
+++ b/desktop/gui_factory.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
+ * Copyright 2014 vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -16,16 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NETSURF_DESKTOP_401LOGIN_H
-#define NETSURF_DESKTOP_401LOGIN_H
+/** \file
+ * Interface to gui interface factory
+ */
+
+#ifndef _NETSURF_DESKTOP_GUI_FACTORY_H_
+#define _NETSURF_DESKTOP_GUI_FACTORY_H_
-#include <stdbool.h>
+#include "desktop/gui.h"
-#include "utils/config.h"
-#include "utils/nsurl.h"
-#include "utils/errors.h"
+/** The global operation table */
+extern struct gui_table *guit;
-void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw);
+/** register and verify global operation table
+ *
+ * @param gt The global table to register
+ * @return NSERROR_OK on success or error code on faliure. On faliure
+ * global table will not be initialised
+ */
+nserror gui_factory_register(struct gui_table *gt);
#endif
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 36b0b589a..d294073ba 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -37,10 +37,9 @@
#include "image/image.h"
#include "image/image_cache.h"
#include "desktop/netsurf.h"
-#include "desktop/401login.h"
#include "desktop/browser.h"
#include "desktop/system_colour.h"
-#include "desktop/gui.h"
+#include "desktop/gui_factory.h"
#include "utils/nsoption.h"
#include "desktop/searchweb.h"
@@ -95,14 +94,14 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query,
{
switch (query->type) {
case LLCACHE_QUERY_AUTH:
- gui_401login_open(query->url, query->data.auth.realm, cb, cbpw);
+ guit->browser->login(query->url, query->data.auth.realm, cb, cbpw);
break;
case LLCACHE_QUERY_REDIRECT:
/** \todo Need redirect query dialog */
/* For now, do nothing, as this query type isn't emitted yet */
break;
case LLCACHE_QUERY_SSL:
- gui_cert_verify(query->url, query->data.ssl.certs,
+ guit->browser->cert_verify(query->url, query->data.ssl.certs,
query->data.ssl.num, cb, cbpw);
break;
}
@@ -116,7 +115,7 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query,
* Initialise components used by gui NetSurf.
*/
-nserror netsurf_init(const char *messages)
+nserror netsurf_init(const char *messages, struct gui_table *gt)
{
nserror error;
struct utsname utsname;
@@ -150,6 +149,11 @@ nserror netsurf_init(const char *messages)
utsname.nodename, utsname.release,
utsname.version, utsname.machine));
+ /* register the gui handlers */
+ error = gui_factory_register(gt);
+ if (error != NSERROR_OK)
+ return error;
+
messages_load(messages);
/* corestrings init */
@@ -228,7 +232,7 @@ nserror netsurf_init(const char *messages)
int netsurf_main_loop(void)
{
while (!netsurf_quit) {
- gui_poll(fetch_active);
+ guit->browser->poll(fetch_active);
hlcache_poll();
}
@@ -244,7 +248,7 @@ void netsurf_exit(void)
hlcache_stop();
LOG(("Closing GUI"));
- gui_quit();
+ guit->browser->quit();
LOG(("Finalising JavaScript"));
js_finalise();
diff --git a/desktop/netsurf.h b/desktop/netsurf.h
index aa1796f7c..e6858ad66 100644
--- a/desktop/netsurf.h
+++ b/desktop/netsurf.h
@@ -28,8 +28,10 @@ extern const char * const netsurf_version;
extern const int netsurf_version_major;
extern const int netsurf_version_minor;
+struct gui_table;
+
/** Initialise netsurf core */
-nserror netsurf_init(const char *messages);
+nserror netsurf_init(const char *messages, struct gui_table *gt);
/** Run primary event loop */
extern int netsurf_main_loop(void);
diff --git a/desktop/save_complete.c b/desktop/save_complete.c
index 3e5234af4..bd2ed4dea 100644
--- a/desktop/save_complete.c
+++ b/desktop/save_complete.c
@@ -37,6 +37,7 @@
#include "content/hlcache.h"
#include "css/css.h"
#include "desktop/save_complete.h"
+#include "desktop/gui_factory.h"
#include "render/box.h"
#include "render/html.h"
#include "utils/corestrings.h"
@@ -147,7 +148,7 @@ static bool save_complete_save_buffer(save_complete_ctx *ctx,
char fullpath[PATH_MAX];
strncpy(fullpath, ctx->path, sizeof fullpath);
- error = path_add_part(fullpath, sizeof fullpath, leafname);
+ error = guit->browser->path_add_part(fullpath, sizeof fullpath, leafname);
if (error == false) {
warn_user("NoMemory", NULL);
return false;
@@ -1048,7 +1049,7 @@ static bool save_complete_save_html_document(save_complete_ctx *ctx,
else
snprintf(filename, sizeof filename, "%p", c);
- error = path_add_part(fullpath, sizeof fullpath, filename);
+ error = guit->browser->path_add_part(fullpath, sizeof fullpath, filename);
if (error == false) {
warn_user("NoMemory", NULL);
return false;
@@ -1125,7 +1126,7 @@ static bool save_complete_inventory(save_complete_ctx *ctx)
char fullpath[PATH_MAX];
strncpy(fullpath, ctx->path, sizeof fullpath);
- error = path_add_part(fullpath, sizeof fullpath, "Inventory");
+ error = guit->browser->path_add_part(fullpath, sizeof fullpath, "Inventory");
if (error == false) {
warn_user("NoMemory", NULL);
return false;
diff --git a/desktop/searchweb.c b/desktop/searchweb.c
index 4c050d97a..30b424cb3 100644
--- a/desktop/searchweb.c
+++ b/desktop/searchweb.c
@@ -27,6 +27,7 @@
#include "content/hlcache.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
+#include "desktop/gui_factory.h"
#include "utils/nsoption.h"
#include "desktop/searchweb.h"
#include "utils/config.h"
@@ -307,7 +308,7 @@ nserror search_web_ico_callback(hlcache_handle *ico,
case CONTENT_MSG_DONE:
LOG(("got favicon '%s'", nsurl_access(hlcache_handle_get_url(ico))));
- gui_window_set_search_ico(search_ico);
+ guit->browser->set_search_ico(search_ico);
break;
case CONTENT_MSG_ERROR:
diff --git a/desktop/selection.c b/desktop/selection.c
index 13a1293e3..96c7e0c3c 100644
--- a/desktop/selection.c
+++ b/desktop/selection.c
@@ -30,6 +30,7 @@
#include "desktop/browser_private.h"
#include "desktop/gui.h"
+#include "desktop/gui_factory.h"
#include "desktop/mouse.h"
#include "desktop/plotters.h"
#include "desktop/save_text.h"
@@ -274,7 +275,7 @@ bool selection_click(struct selection *s, browser_mouse_state mouse,
(modkeys && (mouse & BROWSER_MOUSE_DRAG_2)))) {
/* drag-saving selection */
char *sel = selection_get_copy(s);
- gui_drag_save_selection(top->window, sel);
+ guit->window->drag_save_selection(top->window, sel);
free(sel);
}
else if (!modkeys) {
@@ -293,7 +294,7 @@ bool selection_click(struct selection *s, browser_mouse_state mouse,
s->drag_state = DRAG_END;
- gui_start_selection(top->window);
+ guit->window->start_selection(top->window);
}
else if (mouse & BROWSER_MOUSE_DRAG_2) {
@@ -312,7 +313,7 @@ bool selection_click(struct selection *s, browser_mouse_state mouse,
s->drag_state = DRAG_START;
}
- gui_start_selection(top->window);
+ guit->window->start_selection(top->window);
}
else if (mouse & BROWSER_MOUSE_CLICK_2) {
@@ -844,7 +845,7 @@ bool selection_copy_to_clipboard(struct selection *s)
return false;
}
- gui_set_clipboard(sel_string.buffer, sel_string.length,
+ guit->clipboard->set(sel_string.buffer, sel_string.length,
sel_string.styles, sel_string.n_styles);
free(sel_string.buffer);
diff --git a/desktop/textarea.c b/desktop/textarea.c
index f9712ac84..209a6c6d7 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -24,11 +24,13 @@
#include <stdint.h>
#include <string.h>
#include "css/utils.h"
+
#include "desktop/mouse.h"
#include "desktop/textarea.h"
#include "desktop/textinput.h"
#include "desktop/plotters.h"
#include "desktop/scrollbar.h"
+#include "desktop/gui_factory.h"
#include "render/font.h"
#include "utils/log.h"
#include "utils/utf8.h"
@@ -1417,7 +1419,7 @@ static bool textarea_replace_text_internal(struct textarea *ta, size_t b_start,
/* Place CUTs on clipboard */
if (add_to_clipboard) {
- gui_set_clipboard(ta->show->data + b_start, b_end - b_start,
+ guit->clipboard->set(ta->show->data + b_start, b_end - b_start,
NULL, 0);
}
@@ -2484,7 +2486,7 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
if (readonly)
break;
- gui_get_clipboard(&clipboard, &clipboard_length);
+ guit->clipboard->get(&clipboard, &clipboard_length);
if (clipboard == NULL)
return false;
diff --git a/desktop/textinput.c b/desktop/textinput.c
index e804829fa..c61b838fe 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -31,6 +31,7 @@
#include "desktop/browser_private.h"
#include "desktop/gui.h"
+#include "desktop/gui_factory.h"
#include "desktop/mouse.h"
#include "desktop/scrollbar.h"
#include "desktop/selection.h"
@@ -85,7 +86,7 @@ void browser_window_place_caret(struct browser_window *bw, int x, int y,
/* TODO: intersect with bw viewport */
- gui_window_place_caret(root_bw->window, x, y, height * bw->scale, crp);
+ guit->window->place_caret(root_bw->window, x, y, height * bw->scale, crp);
/* Set focus browser window */
root_bw->focus = bw;
@@ -110,8 +111,9 @@ void browser_window_remove_caret(struct browser_window *bw, bool only_hide)
else
root_bw->can_edit = false;
- if (root_bw->window)
- gui_window_remove_caret(root_bw->window);
+ if (root_bw->window) {
+ guit->window->remove_caret(root_bw->window);
+ }
}
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target
index 5c658925e..58a504b17 100644
--- a/framebuffer/Makefile.target
+++ b/framebuffer/Makefile.target
@@ -135,7 +135,7 @@ $(eval $(foreach V,$(filter FB_IMAGE_%,$(.VARIABLES)),$(call convert_image,$($(V
# S_FRAMEBUFFER are sources purely for the framebuffer build
S_FRAMEBUFFER := gui.c framebuffer.c schedule.c \
- thumbnail.c misc.c bitmap.c filetype.c login.c findfile.c \
+ thumbnail.c misc.c bitmap.c filetype.c findfile.c \
localhistory.c clipboard.c
S_FRAMEBUFFER_FBTK := fbtk.c event.c fill.c bitmap.c user.c window.c \
diff --git a/framebuffer/clipboard.c b/framebuffer/clipboard.c
index 46a1bb018..b4bd296c6 100644
--- a/framebuffer/clipboard.c
+++ b/framebuffer/clipboard.c
@@ -26,6 +26,7 @@
#include "desktop/browser.h"
#include "desktop/gui.h"
#include "framebuffer/gui.h"
+#include "framebuffer/clipboard.h"
#include "utils/log.h"
@@ -36,15 +37,13 @@ static struct gui_clipboard {
} gui_clipboard;
-
-
/**
* Core asks front end for clipboard contents.
*
* \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
* \param length Byte length of UTF-8 text in buffer
*/
-void gui_get_clipboard(char **buffer, size_t *length)
+static void gui_get_clipboard(char **buffer, size_t *length)
{
*buffer = NULL;
*length = 0;
@@ -73,7 +72,7 @@ void gui_get_clipboard(char **buffer, size_t *length)
* \param styles Array of styles given to text runs, owned by core, or NULL
* \param n_styles Number of text run styles in array
*/
-void gui_set_clipboard(const char *buffer, size_t length,
+static void gui_set_clipboard(const char *buffer, size_t length,
nsclipboard_styles styles[], int n_styles)
{
if (gui_clipboard.buffer_len < length + 1) {
@@ -95,3 +94,9 @@ void gui_set_clipboard(const char *buffer, size_t length,
gui_clipboard.buffer[gui_clipboard.length] = '\0';
}
+static struct gui_clipboard_table clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+struct gui_clipboard_table *framebuffer_clipboard_table = &clipboard_table;
diff --git a/framebuffer/login.c b/framebuffer/clipboard.h
index 7a5e195f4..b5f7b0f29 100644
--- a/framebuffer/login.c
+++ b/framebuffer/clipboard.h
@@ -16,10 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/401login.h"
+#ifndef NETSURF_FB_CLIPBOARD_H
+#define NETSURF_FB_CLIPBOARD_H
-void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
-{
- cb(false, cbpw);
-}
+extern struct gui_clipboard_table *framebuffer_clipboard_table;
+
+#endif
diff --git a/framebuffer/findfile.h b/framebuffer/findfile.h
index 1f3db6eb1..ca40c7751 100644
--- a/framebuffer/findfile.h
+++ b/framebuffer/findfile.h
@@ -19,6 +19,8 @@
#ifndef NETSURF_FB_FINDFILE_H
#define NETSURF_FB_FINDFILE_H
+#include "utils/nsurl.h"
+
extern char **respaths;
/** Create an array of valid paths to search for resources.
@@ -29,4 +31,6 @@ extern char **respaths;
*/
char **fb_init_resource(const char *resource_path);
+nsurl *gui_get_resource_url(const char *path);
+
#endif /* NETSURF_FB_FINDFILE_H */
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 08cb31318..d89315957 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -54,6 +54,7 @@
#include "framebuffer/findfile.h"
#include "framebuffer/image_data.h"
#include "framebuffer/font.h"
+#include "framebuffer/clipboard.h"
#include "content/urldb.h"
#include "desktop/local_history.h"
@@ -555,104 +556,9 @@ static bool nslog_stream_configure(FILE *fptr)
return true;
}
-/** Entry point from OS.
- *
- * /param argc The number of arguments in the string vector.
- * /param argv The argument string vector.
- * /return The return code to the OS
- */
-int
-main(int argc, char** argv)
-{
- struct browser_window *bw;
- char *options;
- char *messages;
- nsurl *url;
- nserror ret;
- nsfb_t *nsfb;
-
- respaths = fb_init_resource(NETSURF_FB_RESPATH":"NETSURF_FB_FONTPATH);
-
- /* initialise logging. Not fatal if it fails but not much we
- * can do about it either.
- */
- nslog_init(nslog_stream_configure, &argc, argv);
-
- /* user options setup */
- ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
- if (ret != NSERROR_OK) {
- die("Options failed to initialise");
- }
- options = filepath_find(respaths, "Choices");
- nsoption_read(options, nsoptions);
- free(options);
- nsoption_commandline(&argc, argv, nsoptions);
-
- /* common initialisation */
- messages = filepath_find(respaths, "Messages");
- ret = netsurf_init(messages);
- free(messages);
- if (ret != NSERROR_OK) {
- die("NetSurf failed to initialise");
- }
-
- /* Override, since we have no support for non-core SELECT menu */
- nsoption_set_bool(core_select_menu, true);
-
- if (process_cmdline(argc,argv) != true)
- die("unable to process command line.\n");
-
- nsfb = framebuffer_initialise(fename, fewidth, feheight, febpp);
- if (nsfb == NULL)
- die("Unable to initialise framebuffer");
-
- framebuffer_set_cursor(&pointer_image);
-
- if (fb_font_init() == false)
- die("Unable to initialise the font system");
-
- fbtk = fbtk_init(nsfb);
-
- fbtk_enable_oskb(fbtk);
-
- urldb_load_cookies(nsoption_charp(cookie_file));
-
- /* create an initial browser window */
-
- LOG(("calling browser_window_create"));
- ret = nsurl_create(feurl, &url);
- if (ret == NSERROR_OK) {
- ret = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
- url,
- NULL,
- NULL,
- &bw);
- nsurl_unref(url);
- }
- if (ret != NSERROR_OK) {
- warn_user(messages_get_errorcode(ret), 0);
- } else {
- netsurf_main_loop();
-
- browser_window_destroy(bw);
- }
-
- netsurf_exit();
-
- if (fb_font_finalise() == false)
- LOG(("Font finalisation failed."));
-
- /* finalise options */
- nsoption_finalise(nsoptions, nsoptions_default);
-
- return 0;
-}
-
-void
-gui_poll(bool active)
+static void gui_poll(bool active)
{
nsfb_event_t event;
int timeout; /* timeout in miliseconds */
@@ -678,8 +584,7 @@ gui_poll(bool active)
}
-void
-gui_quit(void)
+static void gui_quit(void)
{
LOG(("gui_quit"));
@@ -1597,10 +1502,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;
@@ -1623,7 +1528,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);
@@ -1631,19 +1536,13 @@ gui_window_destroy(struct gui_window *gw)
free(gw);
}
-void
-gui_window_set_title(struct gui_window *g, const char *title)
-{
- LOG(("%p, %s", g, title));
-}
-
-void
+static void
gui_window_redraw_window(struct gui_window *g)
{
fb_queue_redraw(g->browser, 0, 0, fbtk_get_width(g->browser), fbtk_get_height(g->browser) );
}
-void
+static void
gui_window_update_box(struct gui_window *g, const struct rect *rect)
{
struct browser_widget_s *bwidget = fbtk_get_userpw(g->browser);
@@ -1654,7 +1553,7 @@ gui_window_update_box(struct gui_window *g, const struct rect *rect)
rect->y1 - bwidget->scrolly);
}
-bool
+static bool
gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
struct browser_widget_s *bwidget = fbtk_get_userpw(g->browser);
@@ -1665,7 +1564,7 @@ gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-void
+static void
gui_window_set_scroll(struct gui_window *gw, int sx, int sy)
{
struct browser_widget_s *bwidget = fbtk_get_userpw(gw->browser);
@@ -1676,14 +1575,8 @@ gui_window_set_scroll(struct gui_window *gw, int sx, int sy)
widget_scroll_y(gw, sy * gw->bw->scale, true);
}
-void
-gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
- int x1, int y1)
-{
- LOG(("%s:(%p, %d, %d, %d, %d)", __func__, g, x0, y0, x1, y1));
-}
-void
+static void
gui_window_get_dimensions(struct gui_window *g,
int *width,
int *height,
@@ -1698,7 +1591,7 @@ gui_window_get_dimensions(struct gui_window *g,
}
}
-void
+static void
gui_window_update_extent(struct gui_window *gw)
{
float scale = gw->bw->scale;
@@ -1712,13 +1605,13 @@ gui_window_update_extent(struct gui_window *gw)
fbtk_get_height(gw->browser), 100);
}
-void
+static void
gui_window_set_status(struct gui_window *g, const char *text)
{
fbtk_set_text(g->status, text);
}
-void
+static void
gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
switch (shape) {
@@ -1748,12 +1641,7 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
}
}
-void
-gui_window_hide_pointer(struct gui_window *g)
-{
-}
-
-void
+static void
gui_window_set_url(struct gui_window *g, const char *url)
{
fbtk_set_text(g->url, url);
@@ -1816,14 +1704,14 @@ throbber_advance(void *pw)
}
}
-void
+static void
gui_window_start_throbber(struct gui_window *g)
{
g->throbber_index = 0;
schedule(10, throbber_advance, g);
}
-void
+static void
gui_window_stop_throbber(struct gui_window *gw)
{
gw->throbber_index = -1;
@@ -1850,7 +1738,7 @@ gui_window_remove_caret_cb(fbtk_widget_t *widget)
}
}
-void
+static void
gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
@@ -1868,7 +1756,7 @@ gui_window_place_caret(struct gui_window *g, int x, int y, int height,
y + height - bwidget->scrolly);
}
-void
+static void
gui_window_remove_caret(struct gui_window *g)
{
int c_x, c_y, c_h;
@@ -1879,122 +1767,173 @@ gui_window_remove_caret(struct gui_window *g)
}
}
-void
-gui_window_new_content(struct gui_window *g)
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+static char *filename_from_path(char *path)
{
-}
+ char *leafname;
-bool
-gui_window_scroll_start(struct gui_window *g)
-{
- return true;
-}
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
-bool
-gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
-{
- return true;
-}
-
-void
-gui_window_save_link(struct gui_window *g, const char *url, const char *title)
-{
+ return strdup(leafname);
}
/**
- * set favicon
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
*/
-void
-gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
+
+static bool path_add_part(char *path, int length, const char *newpart)
{
+ if(path[strlen(path) - 1] != '/')
+ strncat(path, "/", length);
+
+ strncat(path, newpart, length);
+
+ return true;
}
-/**
- * set gui display of a retrieved favicon representing the search provider
- * \param ico may be NULL for local calls; then access current cache from
- * search_web_ico()
+static struct gui_window_table framebuffer_window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .set_url = gui_window_set_url,
+ .set_status = gui_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+};
+
+static struct gui_browser_table framebuffer_browser_table = {
+ .poll = gui_poll,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+
+ .quit = gui_quit,
+ .get_resource_url = gui_get_resource_url,
+};
+
+/** Entry point from OS.
+ *
+ * /param argc The number of arguments in the string vector.
+ * /param argv The argument string vector.
+ * /return The return code to the OS
*/
-void
-gui_window_set_search_ico(hlcache_handle *ico)
+int
+main(int argc, char** argv)
{
-}
+ struct browser_window *bw;
+ char *options;
+ char *messages;
+ nsurl *url;
+ nserror ret;
+ nsfb_t *nsfb;
+ struct gui_table framebuffer_gui_table = {
+ .browser = &framebuffer_browser_table,
+ .window = &framebuffer_window_table,
+ .clipboard = framebuffer_clipboard_table,
+ };
-struct gui_download_window *
-gui_download_window_create(download_context *ctx, struct gui_window *parent)
-{
- return NULL;
-}
+ respaths = fb_init_resource(NETSURF_FB_RESPATH":"NETSURF_FB_FONTPATH);
-nserror
-gui_download_window_data(struct gui_download_window *dw,
- const char *data,
- unsigned int size)
-{
- return NSERROR_OK;
-}
+ /* initialise logging. Not fatal if it fails but not much we
+ * can do about it either.
+ */
+ nslog_init(nslog_stream_configure, &argc, argv);
-void
-gui_download_window_error(struct gui_download_window *dw,
- const char *error_msg)
-{
-}
+ /* user options setup */
+ ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
+ if (ret != NSERROR_OK) {
+ die("Options failed to initialise");
+ }
+ options = filepath_find(respaths, "Choices");
+ nsoption_read(options, nsoptions);
+ free(options);
+ nsoption_commandline(&argc, argv, nsoptions);
-void
-gui_download_window_done(struct gui_download_window *dw)
-{
-}
+ /* common initialisation */
+ messages = filepath_find(respaths, "Messages");
+ ret = netsurf_init(messages, &framebuffer_gui_table);
+ free(messages);
+ if (ret != NSERROR_OK) {
+ die("NetSurf failed to initialise");
+ }
-void
-gui_drag_save_object(gui_save_type type,
- hlcache_handle *c,
- struct gui_window *w)
-{
-}
+ /* Override, since we have no support for non-core SELECT menu */
+ nsoption_set_bool(core_select_menu, true);
-void
-gui_drag_save_selection(struct gui_window *g, const char *selection)
-{
-}
+ if (process_cmdline(argc,argv) != true)
+ die("unable to process command line.\n");
-void
-gui_start_selection(struct gui_window *g)
-{
-}
+ nsfb = framebuffer_initialise(fename, fewidth, feheight, febpp);
+ if (nsfb == NULL)
+ die("Unable to initialise framebuffer");
-void
-gui_clear_selection(struct gui_window *g)
-{
-}
+ framebuffer_set_cursor(&pointer_image);
-void
-gui_create_form_select_menu(struct browser_window *bw,
- struct form_control *control)
-{
-}
+ if (fb_font_init() == false)
+ die("Unable to initialise the font system");
-void
-gui_launch_url(const char *url)
-{
-}
+ fbtk = fbtk_init(nsfb);
-void
-gui_cert_verify(nsurl *url,
- const struct ssl_cert_info *certs,
- unsigned long num,
- nserror (*cb)(bool proceed, void *pw),
- void *cbpw)
-{
- cb(false, cbpw);
-}
+ fbtk_enable_oskb(fbtk);
-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"); */
+ urldb_load_cookies(nsoption_charp(cookie_file));
+
+ /* create an initial browser window */
+
+ LOG(("calling browser_window_create"));
+
+ ret = nsurl_create(feurl, &url);
+ if (ret == NSERROR_OK) {
+ ret = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
+ BROWSER_WINDOW_HISTORY,
+ url,
+ NULL,
+ NULL,
+ &bw);
+ nsurl_unref(url);
+ }
+ if (ret != NSERROR_OK) {
+ warn_user(messages_get_errorcode(ret), 0);
+ } else {
+ netsurf_main_loop();
+
+ browser_window_destroy(bw);
+ }
+
+ netsurf_exit();
+
+ if (fb_font_finalise() == false)
+ LOG(("Font finalisation failed."));
+
+ /* finalise options */
+ nsoption_finalise(nsoptions, nsoptions_default);
+
+ return 0;
}
+
/*
* Local Variables:
* c-basic-offset:8
diff --git a/framebuffer/misc.c b/framebuffer/misc.c
index 2dd03677d..f5ad045a0 100644
--- a/framebuffer/misc.c
+++ b/framebuffer/misc.c
@@ -37,40 +37,3 @@ void die(const char *error)
exit(1);
}
-/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-char *filename_from_path(char *path)
-{
- char *leafname;
-
- leafname = strrchr(path, '/');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
-
- return strdup(leafname);
-}
-
-/**
- * Add a path component/filename to an existing path
- *
- * \param path buffer containing path + free space
- * \param length length of buffer "path"
- * \param newpart string containing path component to add to path
- * \return true on success
- */
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- if(path[strlen(path) - 1] != '/')
- strncat(path, "/", length);
-
- strncat(path, newpart, length);
-
- return true;
-}
diff --git a/gtk/dialogs/preferences.c b/gtk/dialogs/preferences.c
index 0669f8d9f..18c8d7b6c 100644
--- a/gtk/dialogs/preferences.c
+++ b/gtk/dialogs/preferences.c
@@ -944,9 +944,7 @@ nsgtk_preferences_comboSearch_changed(GtkComboBox *widget, struct ppref *priv)
search_web_retrieve_ico(false);
/* callback may handle changing gui */
- if (search_web_ico() != NULL) {
- gui_window_set_search_ico(search_web_ico());
- }
+ gui_set_search_ico(search_web_ico());
/* set entry */
name = search_web_provider_name();
diff --git a/gtk/download.c b/gtk/download.c
index e882ec798..3d287d4d2 100644
--- a/gtk/download.c
+++ b/gtk/download.c
@@ -712,8 +712,8 @@ static void nsgtk_download_store_create_item (struct gui_download_window *dl)
NSGTK_DOWNLOAD, dl, -1);
}
-struct gui_download_window *gui_download_window_create(download_context *ctx,
- struct gui_window *gui)
+static struct gui_download_window *
+gui_download_window_create(download_context *ctx, struct gui_window *gui)
{
const char *url = download_context_get_url(ctx);
unsigned long total_size = download_context_get_total_length(ctx);
@@ -797,7 +797,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
}
-nserror gui_download_window_data(struct gui_download_window *dw,
+static nserror gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
g_io_channel_write_chars(dw->write, data, size, NULL, &dw->error);
@@ -820,13 +820,13 @@ nserror gui_download_window_data(struct gui_download_window *dw,
}
-void gui_download_window_error(struct gui_download_window *dw,
+static void gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
}
-void gui_download_window_done(struct gui_download_window *dw)
+static void gui_download_window_done(struct gui_download_window *dw)
{
g_io_channel_shutdown(dw->write, TRUE, &dw->error);
g_io_channel_unref(dw->write);
@@ -845,17 +845,11 @@ void gui_download_window_done(struct gui_download_window *dw)
}
+static struct gui_download_table download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
-
-
-
-
-
-
-
-
-
-
-
-
-
+struct gui_download_table *nsgtk_download_table = &download_table;
diff --git a/gtk/download.h b/gtk/download.h
index e85c4126a..a6e624fbd 100644
--- a/gtk/download.h
+++ b/gtk/download.h
@@ -21,6 +21,8 @@
#include <gtk/gtk.h>
+struct gui_download_table *nsgtk_download_table;
+
bool nsgtk_download_init(const char *glade_file_location);
void nsgtk_download_destroy (void);
bool nsgtk_check_for_downloads(GtkWindow *parent);
diff --git a/gtk/gui.c b/gtk/gui.c
index 77b72f874..39dc885da 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -55,6 +55,7 @@
#include "desktop/textinput.h"
#include "desktop/tree.h"
#include "css/utils.h"
+
#include "gtk/compat.h"
#include "gtk/completion.h"
#include "gtk/cookies.h"
@@ -67,6 +68,7 @@
#include "gtk/treeview.h"
#include "gtk/window.h"
#include "gtk/schedule.h"
+#include "gtk/selection.h"
#include "render/form.h"
#include "utils/filepath.h"
@@ -183,7 +185,7 @@ nsgtk_new_ui(char **respath, const char *name, GtkBuilder **pglade)
filepath = filepath_find(respath, resname);
if (filepath == NULL) {
- snprintf(errorstr, NEW_GLADE_ERROR_SIZE,
+ snprintf(errorstr, NEW_GLADE_ERROR_SIZE,
"Unable to locate %s glade template file.\n", name);
die(errorstr);
}
@@ -192,7 +194,7 @@ nsgtk_new_ui(char **respath, const char *name, GtkBuilder **pglade)
if (!gtk_builder_add_from_file(builder, filepath, &error)) {
g_warning ("Couldn't load builder file: %s", error->message);
g_error_free (error);
- snprintf(errorstr, NEW_GLADE_ERROR_SIZE,
+ snprintf(errorstr, NEW_GLADE_ERROR_SIZE,
"Unable to load glade %s window definitions.\n", name);
die(errorstr);
@@ -212,7 +214,7 @@ nsgtk_new_ui(char **respath, const char *name, GtkBuilder **pglade)
/**
* Load definitions from glade files.
*/
-static void
+static void
nsgtk_init_glade(char **respath)
{
GtkBuilder *gladeWarning;
@@ -322,7 +324,7 @@ static void check_options(char **respath)
}
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
char buf[PATH_MAX];
char *raw;
@@ -334,7 +336,7 @@ nsurl *gui_get_resource_url(const char *path)
/* favicon.ico -> favicon.png */
if (strcmp(path, "favicon.ico") == 0)
- path = "favicon.png";
+ path = "favicon.png";
raw = path_to_url(filepath_sfind(respaths, buf, path));
if (raw != NULL) {
@@ -357,32 +359,32 @@ static void gui_init(int argc, char** argv, char **respath)
nsurl *url;
nserror error;
- /* find the languages file */
+ /* find the languages file */
languages_file_location = filepath_find(respath, "languages");
- if ((languages_file_location == NULL) ||
+ if ((languages_file_location == NULL) ||
(strlen(languages_file_location) < 10)) {
- die("Unable to find resources.\n");
+ die("Unable to find resources.\n");
}
- /* find the theme list file */
+ /* find the theme list file */
themelist_file_location = filepath_find(respath, "themelist");
if ((themelist_file_location != NULL) &&
(strlen(themelist_file_location) < 10)) {
free(themelist_file_location);
themelist_file_location = NULL;
}
- if (themelist_file_location == NULL) {
+ if (themelist_file_location == NULL) {
LOG(("Unable to find themelist - disabling"));
}
- /* Obtain resources path location.
+ /* Obtain resources path location.
*
* Uses the directory the languages file was found in,
* @todo find and slaughter all references to this!
*/
res_dir_location = calloc(1, strlen(languages_file_location) - 8);
- memcpy(res_dir_location,
- languages_file_location,
+ memcpy(res_dir_location,
+ languages_file_location,
strlen(languages_file_location) - 9);
LOG(("Using '%s' for resource path", res_dir_location));
@@ -411,7 +413,7 @@ static void gui_init(int argc, char** argv, char **respath)
free(resource_filename);
if (favicon_pixbuf == NULL) {
favicon_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 16,16);
-
+
}
}
@@ -419,7 +421,7 @@ static void gui_init(int argc, char** argv, char **respath)
toolbar_indices_file_location = filepath_find(respath, "toolbarIndices");
LOG(("Using '%s' as custom toolbar settings file", toolbar_indices_file_location));
- /* load throbber images */
+ /* load throbber images */
if (nsgtk_throbber_init(respath, THROBBER_FRAMES) == false)
die("Unable to load throbber image.\n");
@@ -535,75 +537,15 @@ static void nsgtk_check_homedir(void)
*/
static bool nslog_stream_configure(FILE *fptr)
{
- /* set log stream to be non-buffering */
+ /* set log stream to be non-buffering */
setbuf(fptr, NULL);
return true;
}
-/**
- * Main entry point from OS.
- */
-int main(int argc, char** argv)
-{
- char *messages;
- char *options;
- nserror ret;
-
- /* check home directory is available */
- nsgtk_check_homedir();
- respaths = nsgtk_init_resource("${HOME}/.netsurf/:${NETSURFRES}:"GTK_RESPATH":./gtk/res");
- gtk_init(&argc, &argv);
-
- /* initialise logging. Not fatal if it fails but not much we
- * can do about it either.
- */
- nslog_init(nslog_stream_configure, &argc, argv);
-
- /* user options setup */
- ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
- if (ret != NSERROR_OK) {
- fprintf(stderr, "Options failed to initialise (%s)\n",
- messages_get_errorcode(ret));
- return 1;
- }
- options = filepath_find(respaths, "Choices");
- nsoption_read(options, nsoptions);
- free(options);
- nsoption_commandline(&argc, argv, nsoptions);
- check_options(respaths); /* check user options */
-
- /* common initialisation */
- messages = filepath_find(respaths, "Messages");
- ret = netsurf_init(messages);
- free(messages);
- if (ret != NSERROR_OK) {
- fprintf(stderr, "NetSurf core failed to initialise (%s)\n",
- messages_get_errorcode(ret));
- return 1;
- }
-
- /* run the browser */
- gui_init(argc, argv, respaths);
-
- /* Ensure all scaffoldings are destroyed before we go into exit */
- while (scaf_list != NULL) {
- nsgtk_scaffolding_destroy(scaf_list);
- }
-
- /* common finalisation */
- netsurf_exit();
-
- /* finalise options */
- nsoption_finalise(nsoptions, nsoptions_default);
-
- return 0;
-}
-
-
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
CURLMcode code;
fd_set read_fd_set, write_fd_set, exc_fd_set;
@@ -613,7 +555,7 @@ void gui_poll(bool active)
bool block = true;
schedule_run();
-
+
if (browser_reformat_pending)
block = false;
@@ -666,8 +608,15 @@ void gui_poll(bool active)
}
-void gui_quit(void)
+static void gui_quit(void)
{
+ LOG(("Quitting GUI"));
+
+ /* Ensure all scaffoldings are destroyed before we go into exit */
+ while (scaf_list != NULL) {
+ nsgtk_scaffolding_destroy(scaf_list);
+ }
+
nsgtk_download_destroy();
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
@@ -688,7 +637,7 @@ static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
select_menu_control, (intptr_t)user_data);
}
-void gui_create_form_select_menu(struct browser_window *bw,
+static void gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control)
{
@@ -729,12 +678,7 @@ void gui_create_form_select_menu(struct browser_window *bw,
}
-void gui_window_save_link(struct gui_window *g, const char *url,
- const char *title)
-{
-}
-
-void gui_launch_url(const char *url)
+static void gui_launch_url(const char *url)
{
gboolean ok;
GError *error = NULL;
@@ -772,11 +716,11 @@ void die(const char * const error)
}
-void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
+static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
-{
- static struct nsgtk_treeview *ssl_window;
+{
+ static struct nsgtk_treeview *ssl_window;
struct sslcert_session_data *data;
GtkButton *accept, *reject;
void **session;
@@ -784,7 +728,7 @@ void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
GtkScrolledWindow *scrolled;
GtkDrawingArea *drawing_area;
GError* error = NULL;
- GtkBuilder* builder;
+ GtkBuilder* builder;
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file(builder, glade_file_location->ssl, &error)) {
@@ -808,28 +752,28 @@ void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
ssl_window = nsgtk_treeview_create(TREE_SSLCERT, window, scrolled,
drawing_area);
-
+
if (ssl_window == NULL) {
free(session);
return;
}
-
+
accept = GTK_BUTTON(gtk_builder_get_object(builder, "sslaccept"));
- reject = GTK_BUTTON(gtk_builder_get_object(builder, "sslreject"));
+ reject = GTK_BUTTON(gtk_builder_get_object(builder, "sslreject"));
session[0] = builder;
session[1] = ssl_window;
session[2] = data;
-
+
#define CONNECT(obj, sig, callback, ptr) \
- g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
-
+ g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
+
CONNECT(accept, "clicked", nsgtk_ssl_accept, session);
CONNECT(reject, "clicked", nsgtk_ssl_reject, session);
CONNECT(window, "delete_event", G_CALLBACK(nsgtk_ssl_delete_event),
(gpointer)session);
-
- gtk_widget_show(GTK_WIDGET(window));
+
+ gtk_widget_show(GTK_WIDGET(window));
}
void nsgtk_ssl_accept(GtkButton *w, gpointer data)
@@ -840,7 +784,7 @@ void nsgtk_ssl_accept(GtkButton *w, gpointer data)
struct sslcert_session_data *ssl_data = session[2];
sslcert_viewer_accept(ssl_data);
-
+
nsgtk_treeview_destroy(wnd);
g_object_unref(G_OBJECT(x));
free(session);
@@ -854,7 +798,7 @@ void nsgtk_ssl_reject(GtkWidget *w, gpointer data)
struct sslcert_session_data *ssl_data = session[2];
sslcert_viewer_reject(ssl_data);
-
+
nsgtk_treeview_destroy(wnd);
g_object_unref(G_OBJECT(x));
free(session);
@@ -906,7 +850,7 @@ char *path_to_url(const char *path)
if (path == NULL) {
return NULL;
}
-
+
urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1;
url = malloc(urllen);
@@ -916,7 +860,7 @@ char *path_to_url(const char *path)
if (*path == '/') {
path++; /* file: paths are already absolute */
- }
+ }
snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, path);
@@ -1057,7 +1001,7 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
* now. I hope.
*/
switch (key->keyval) {
-
+
case GDK_KEY(Tab):
return KEY_TAB;
@@ -1137,12 +1081,12 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
case GDK_KEY(Super_L):
case GDK_KEY(Super_R):
case GDK_KEY(Hyper_L):
- case GDK_KEY(Hyper_R):
+ case GDK_KEY(Hyper_R):
return 0;
- default:
+ default:
return gdk_keyval_to_unicode(key->keyval);
- }
+ }
}
/**
@@ -1152,7 +1096,7 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
* \return filename (will be freed with free())
*/
-char *filename_from_path(char *path)
+static char *filename_from_path(char *path)
{
char *leafname;
@@ -1174,7 +1118,7 @@ char *filename_from_path(char *path)
* \return true on success
*/
-bool path_add_part(char *path, int length, const char *newpart)
+static bool path_add_part(char *path, int length, const char *newpart)
{
if(path[strlen(path) - 1] != '/')
strncat(path, "/", length);
@@ -1183,3 +1127,83 @@ bool path_add_part(char *path, int length, const char *newpart)
return true;
}
+
+static struct gui_clipboard_table nsgtk_clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+static struct gui_browser_table nsgtk_browser_table = {
+ .poll = gui_poll,
+ .quit = gui_quit,
+ .set_search_ico = gui_set_search_ico,
+ .get_resource_url = gui_get_resource_url,
+ .launch_url = gui_launch_url,
+ .create_form_select_menu = gui_create_form_select_menu,
+ .cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+ .login = gui_401login_open,
+};
+
+/**
+ * Main entry point from OS.
+ */
+int main(int argc, char** argv)
+{
+ char *messages;
+ char *options;
+ nserror ret;
+ struct gui_table nsgtk_gui_table = {
+ .browser = &nsgtk_browser_table,
+ .window = nsgtk_window_table,
+ .clipboard = &nsgtk_clipboard_table,
+ .download = nsgtk_download_table,
+ };
+
+ /* check home directory is available */
+ nsgtk_check_homedir();
+
+ respaths = nsgtk_init_resource("${HOME}/.netsurf/:${NETSURFRES}:"GTK_RESPATH":./gtk/res");
+
+ gtk_init(&argc, &argv);
+
+ /* initialise logging. Not fatal if it fails but not much we
+ * can do about it either.
+ */
+ nslog_init(nslog_stream_configure, &argc, argv);
+
+ /* user options setup */
+ ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
+ if (ret != NSERROR_OK) {
+ fprintf(stderr, "Options failed to initialise (%s)\n",
+ messages_get_errorcode(ret));
+ return 1;
+ }
+ options = filepath_find(respaths, "Choices");
+ nsoption_read(options, nsoptions);
+ free(options);
+ nsoption_commandline(&argc, argv, nsoptions);
+ check_options(respaths); /* check user options */
+
+ /* common initialisation */
+ messages = filepath_find(respaths, "Messages");
+ ret = netsurf_init(messages, &nsgtk_gui_table);
+ free(messages);
+ if (ret != NSERROR_OK) {
+ fprintf(stderr, "NetSurf core failed to initialise (%s)\n",
+ messages_get_errorcode(ret));
+ return 1;
+ }
+
+ /* run the browser */
+ gui_init(argc, argv, respaths);
+
+ /* common finalisation */
+ netsurf_exit();
+
+ /* finalise options */
+ nsoption_finalise(nsoptions, nsoptions_default);
+
+ return 0;
+}
diff --git a/gtk/gui.h b/gtk/gui.h
index 72794b231..65a6e0742 100644
--- a/gtk/gui.h
+++ b/gtk/gui.h
@@ -29,7 +29,8 @@
#include <inttypes.h>
#include <stdbool.h>
#include <gtk/gtk.h>
-//#include <glade/glade.h>
+
+#include "utils/nsurl.h"
struct glade_file_location_s {
char *netsurf;
@@ -60,5 +61,8 @@ extern GdkPixbuf *favicon_pixbuf; /* favicon default pixbuf */
uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *);
+extern void gui_401login_open(nsurl *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
+
#endif /* GTK_GUI_H */
diff --git a/gtk/login.c b/gtk/login.c
index 3b8d68254..baf37d094 100644
--- a/gtk/login.c
+++ b/gtk/login.c
@@ -28,7 +28,6 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/browser.h"
-#include "desktop/401login.h"
#include "desktop/gui.h"
#include "utils/messages.h"
#include "utils/url.h"
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index b39283cc6..098d5e121 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -2147,8 +2147,7 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
nsgtk_theme_implement(g);
/* set web search ico */
- if (search_web_ico() != NULL)
- gui_window_set_search_ico(search_web_ico());
+ gui_set_search_ico(search_web_ico());
/* finally, show the window. */
gtk_widget_show(GTK_WIDGET(g->window));
@@ -2261,7 +2260,7 @@ nsgtk_scaffolding_set_icon(struct gui_window *gw)
gtk_widget_show_all(GTK_WIDGET(sc->buttons[URL_BAR_ITEM]->button));
}
-void gui_window_set_search_ico(hlcache_handle *ico)
+void gui_set_search_ico(hlcache_handle *ico)
{
struct bitmap *srch_bitmap;
nsgtk_scaffolding *current;
diff --git a/gtk/scaffolding.h b/gtk/scaffolding.h
index 79e3fa0df..43eb41b19 100644
--- a/gtk/scaffolding.h
+++ b/gtk/scaffolding.h
@@ -177,4 +177,11 @@ gboolean nsgtk_window_url_changed(GtkWidget *, GdkEventKey *, gpointer);
nserror nsgtk_scaffolding_new_tab(struct gui_window *gw);
+/* core acessors */
+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);
+void gui_set_search_ico(hlcache_handle *ico);
+
#endif /* NETSURF_GTK_SCAFFOLDING_H */
diff --git a/gtk/selection.c b/gtk/selection.c
index b0978b385..8bdc0f8c8 100644
--- a/gtk/selection.c
+++ b/gtk/selection.c
@@ -30,17 +30,6 @@ static GString *current_selection = NULL;
static GtkClipboard *clipboard;
-
-
-void gui_start_selection(struct gui_window *g)
-{
- gtk_widget_grab_focus(GTK_WIDGET(nsgtk_window_get_layout(g)));
-}
-
-void gui_clear_selection(struct gui_window *g)
-{
-}
-
/**
* Core asks front end for clipboard contents.
*
diff --git a/gtk/selection.h b/gtk/selection.h
index c2a0b35f4..0d3ec7371 100644
--- a/gtk/selection.h
+++ b/gtk/selection.h
@@ -22,4 +22,8 @@
#include <gtk/gtk.h>
#include "desktop/gui.h"
+void gui_get_clipboard(char **buffer, size_t *length);
+void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles);
+
+
#endif
diff --git a/gtk/toolbar.c b/gtk/toolbar.c
index d543ca5fd..8453f4e27 100644
--- a/gtk/toolbar.c
+++ b/gtk/toolbar.c
@@ -449,8 +449,8 @@ void nsgtk_toolbar_close(nsgtk_scaffolding *g)
TRUE);
/* update favicon etc */
nsgtk_scaffolding_set_top_level(nsgtk_scaffolding_top_level(g));
- if (search_web_ico())
- gui_window_set_search_ico(search_web_ico());
+
+ gui_set_search_ico(search_web_ico());
}
/**
diff --git a/gtk/window.c b/gtk/window.c
index 8f05c3799..0ba3c5052 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -28,6 +28,7 @@
#include "content/hlcache.h"
#include "gtk/window.h"
+#include "gtk/selection.h"
#include "desktop/browser_private.h"
#include "desktop/mouse.h"
#include "utils/nsoption.h"
@@ -655,10 +656,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 */
+static 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;
@@ -837,7 +839,7 @@ void nsgtk_window_destroy_browser(struct gui_window *gw)
gtk_widget_destroy(gw->container);
}
-void gui_window_destroy(struct gui_window *g)
+static void gui_window_destroy(struct gui_window *g)
{
LOG(("gui_window: %p", g));
assert(g != NULL);
@@ -860,7 +862,7 @@ void gui_window_destroy(struct gui_window *g)
/**
* set favicon
*/
-void gui_window_set_icon(struct gui_window *gw, hlcache_handle *icon)
+static void gui_window_set_icon(struct gui_window *gw, hlcache_handle *icon)
{
struct bitmap *icon_bitmap = NULL;
@@ -887,6 +889,20 @@ void gui_window_set_icon(struct gui_window *gw, hlcache_handle *icon)
nsgtk_scaffolding_set_icon(gw);
}
+static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+{
+ GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout);
+ GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout);
+
+ assert(vadj);
+ assert(hadj);
+
+ *sy = (int)(gtk_adjustment_get_value(vadj));
+ *sx = (int)(gtk_adjustment_get_value(hadj));
+
+ return true;
+}
+
static void nsgtk_redraw_caret(struct gui_window *g)
{
int sx, sy;
@@ -901,7 +917,7 @@ static void nsgtk_redraw_caret(struct gui_window *g)
}
-void gui_window_remove_caret(struct gui_window *g)
+static void gui_window_remove_caret(struct gui_window *g)
{
int sx, sy;
int oh = g->careth;
@@ -918,12 +934,12 @@ void gui_window_remove_caret(struct gui_window *g)
}
-void gui_window_redraw_window(struct gui_window *g)
+static void gui_window_redraw_window(struct gui_window *g)
{
gtk_widget_queue_draw(GTK_WIDGET(g->layout));
}
-void gui_window_update_box(struct gui_window *g, const struct rect *rect)
+static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
{
int sx, sy;
hlcache_handle *c = g->bw->current_content;
@@ -940,28 +956,15 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect)
(rect->y1 - rect->y0) * g->bw->scale);
}
-void gui_window_set_status(struct gui_window *g, const char *text)
+static void gui_window_set_status(struct gui_window *g, const char *text)
{
assert(g);
assert(g->status_bar);
gtk_label_set_text(g->status_bar, text);
}
-bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
-{
- GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout);
- GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout);
-
- assert(vadj);
- assert(hadj);
-
- *sy = (int)(gtk_adjustment_get_value(vadj));
- *sx = (int)(gtk_adjustment_get_value(hadj));
- return true;
-}
-
-void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout);
GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout);
@@ -986,14 +989,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
gtk_adjustment_set_value(hadj, x);
}
-void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
- int x1, int y1)
-{
- gui_window_set_scroll(g,x0,y0);
-}
-
-
-void gui_window_update_extent(struct gui_window *g)
+static void gui_window_update_extent(struct gui_window *g)
{
if (!g->bw->current_content)
return;
@@ -1014,7 +1010,8 @@ static GdkCursor *nsgtk_create_menu_cursor(void)
return cursor;
}
-void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
+static void gui_window_set_pointer(struct gui_window *g,
+ gui_pointer_shape shape)
{
GdkCursor *cursor = NULL;
GdkCursorType cursortype;
@@ -1098,12 +1095,8 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
nsgdk_cursor_unref(cursor);
}
-void gui_window_hide_pointer(struct gui_window *g)
-{
-}
-
-void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
+static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
nsgtk_redraw_caret(g);
@@ -1117,34 +1110,8 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
gtk_widget_grab_focus(GTK_WIDGET(g->layout));
}
-void gui_window_new_content(struct gui_window *g)
-{
-
-}
-
-bool gui_window_scroll_start(struct gui_window *g)
-{
- return true;
-}
-
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
-{
- return true;
-}
-
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *g)
-{
-}
-
-void gui_drag_save_selection(struct gui_window *g, const char *selection)
-{
-
-}
-
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
{
GtkAllocation alloc;
@@ -1163,13 +1130,18 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
LOG(("height: %i", *height));
}
-void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
- struct form_control *gadget)
+static void gui_window_start_selection(struct gui_window *g)
+{
+ gtk_widget_grab_focus(GTK_WIDGET(g->layout));
+}
+
+static void
+gui_window_file_gadget_open(struct gui_window *g,
+ hlcache_handle *hl,
+ struct form_control *gadget)
{
GtkWidget *dialog;
- LOG(("Awooga."));
-
dialog = gtk_file_chooser_dialog_new("Select File",
nsgtk_scaffolding_window(g->scaffold),
GTK_FILE_CHOOSER_ACTION_OPEN,
@@ -1194,3 +1166,30 @@ void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
gtk_widget_destroy(dialog);
}
+
+static struct gui_window_table window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .set_icon = gui_window_set_icon,
+ .set_status = gui_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .file_gadget_open = gui_window_file_gadget_open,
+ .start_selection = gui_window_start_selection,
+
+ /* from scaffold */
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+};
+
+struct gui_window_table *nsgtk_window_table = &window_table;
diff --git a/gtk/window.h b/gtk/window.h
index 2def42dd5..e242b6e7a 100644
--- a/gtk/window.h
+++ b/gtk/window.h
@@ -23,6 +23,7 @@
#include "desktop/browser.h"
#include "gtk/scaffolding.h"
+extern struct gui_window_table *nsgtk_window_table;
typedef enum nsgtk_window_signals {
NSGTK_WINDOW_SIGNAL_CLICK,
@@ -33,7 +34,6 @@ typedef enum nsgtk_window_signals {
extern struct gui_window *window_list;
extern int temp_open_background;
-
struct browser_window *nsgtk_get_browser_window(struct gui_window *g);
nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g);
GdkPixbuf *nsgtk_get_icon(struct gui_window *gw);
@@ -48,5 +48,4 @@ 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);
-
#endif /* NETSURF_GTK_WINDOW_H */
diff --git a/monkey/401login.c b/monkey/401login.c
index 605a21aa9..8b4d33d7d 100644
--- a/monkey/401login.c
+++ b/monkey/401login.c
@@ -16,12 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/401login.h"
#include "utils/ring.h"
#include <stdlib.h>
#include <stdio.h>
+#include "monkey/401login.h"
+
typedef struct monkey401 {
struct monkey401 *r_next, *r_prev;
uint32_t num;
diff --git a/monkey/401login.h b/monkey/401login.h
new file mode 100644
index 000000000..e78355ea2
--- /dev/null
+++ b/monkey/401login.h
@@ -0,0 +1,9 @@
+
+#include <stdbool.h>
+
+#include "utils/nsurl.h"
+#include "utils/errors.h"
+
+
+void gui_401login_open(nsurl *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
diff --git a/monkey/browser.c b/monkey/browser.c
index 73549f36a..85e25d9ea 100644
--- a/monkey/browser.c
+++ b/monkey/browser.c
@@ -87,9 +87,10 @@ monkey_kill_browser_windows(void)
}
}
-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 *ret = calloc(sizeof(*ret), 1);
if (ret == NULL)
@@ -111,7 +112,7 @@ gui_create_browser_window(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);
@@ -119,19 +120,19 @@ 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);
}
-void
+static void
gui_window_redraw_window(struct gui_window *g)
{
fprintf(stdout, "WINDOW REDRAW WIN %u\n", g->win_num);
}
-void
+static void
gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
{
@@ -141,31 +142,31 @@ gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
*height = g->height;
}
-void
+static void
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);
}
-void
+static void
gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
g->scrollx = sx;
@@ -173,7 +174,7 @@ gui_window_set_scroll(struct gui_window *g, int sx, int sy)
fprintf(stdout, "WINDOW SET_SCROLL WIN %u X %d Y %d\n", g->win_num, sx, sy);
}
-void
+static void
gui_window_update_box(struct gui_window *g, const struct rect *rect)
{
fprintf(stdout, "WINDOW UPDATE_BOX WIN %u X %d Y %d WIDTH %d HEIGHT %d\n",
@@ -182,7 +183,7 @@ gui_window_update_box(struct gui_window *g, const struct rect *rect)
}
-void
+static void
gui_window_update_extent(struct gui_window *g)
{
if (!g->bw->current_content)
@@ -194,13 +195,13 @@ gui_window_update_extent(struct gui_window *g)
content_get_height(g->bw->current_content));
}
-void
+static void
gui_window_set_status(struct gui_window *g, const char *text)
{
fprintf(stdout, "WINDOW SET_STATUS WIN %u STR %s\n", g->win_num, text);
}
-void
+static void
gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
const char *ptr_name = "UNKNOWN";
@@ -269,20 +270,13 @@ 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);
}
-void
-gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *g)
-{
- /* Ignore? */
-}
-
-bool
+static bool
gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
fprintf(stdout, "WINDOW GET_SCROLL WIN %u X %d Y %d\n",
@@ -292,7 +286,7 @@ gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-bool
+static bool
gui_window_scroll_start(struct gui_window *g)
{
fprintf(stdout, "WINDOW SCROLL_START WIN %u\n", g->win_num);
@@ -300,12 +294,7 @@ gui_window_scroll_start(struct gui_window *g)
return true;
}
-void
-gui_window_set_search_ico(hlcache_handle *ico)
-{
-}
-
-void
+static void
gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
int x1, int y1)
{
@@ -313,46 +302,7 @@ gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
g->win_num, x0, y0, x1, y1);
}
-void
-gui_drag_save_selection(struct gui_window *g, const char *selection)
-{
-}
-
-void
-gui_start_selection(struct gui_window *g)
-{
-}
-
-void
-gui_clear_selection(struct gui_window *g)
-{
-}
-
-/**
- * Core asks front end for clipboard contents.
- *
- * \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
- * \param length Byte length of UTF-8 text in buffer
- */
-void gui_get_clipboard(char **buffer, size_t *length)
-{
-}
-
-
-/**
- * Core tells front end to put given text in clipboard
- *
- * \param buffer UTF-8 text, owned by core
- * \param length Byte length of UTF-8 text in buffer
- * \param styles Array of styles given to text runs, owned by core, or NULL
- * \param n_styles Number of text run styles in array
- */
-void gui_set_clipboard(const char *buffer, size_t length,
- nsclipboard_styles styles[], int n_styles)
-{
-}
-
-void
+static void
gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
@@ -360,13 +310,13 @@ gui_window_place_caret(struct gui_window *g, int x, int y, int height,
g->win_num, x, y, height);
}
-void
+static void
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)
{
@@ -374,15 +324,7 @@ gui_window_drag_start(struct gui_window *g, gui_drag_type type,
return false;
}
-void
-gui_create_form_select_menu(struct browser_window *bw,
- struct form_control *control)
-{
- fprintf(stdout, "WINDOW SELECT_MENU WIN %u\n",
- bw->window->win_num);
-}
-
-void
+static void
gui_window_save_link(struct gui_window *g, const char *url,
const char *title)
{
@@ -390,12 +332,6 @@ gui_window_save_link(struct gui_window *g, const char *url,
g->win_num, url, title);
}
-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"); */
-}
/**** Handlers ****/
@@ -566,3 +502,31 @@ monkey_window_handle_command(int argc, char **argv)
}
}
+
+static struct gui_window_table window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .set_icon = gui_window_set_icon,
+ .set_status = gui_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .drag_start = gui_window_drag_start,
+ .save_link = gui_window_save_link,
+ .scroll_visible = gui_window_scroll_visible,
+ .scroll_start = gui_window_scroll_start,
+ .new_content = gui_window_new_content,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+};
+
+struct gui_window_table *monkey_window_table = &window_table;
diff --git a/monkey/browser.h b/monkey/browser.h
index 3ccbe7a91..959c6a1e6 100644
--- a/monkey/browser.h
+++ b/monkey/browser.h
@@ -22,6 +22,9 @@
#include "desktop/browser.h"
#include "content/hlcache.h"
+extern struct gui_window_table *monkey_window_table;
+extern struct gui_download_table *monkey_download_table;
+
struct gui_window {
struct gui_window *r_next;
struct gui_window *r_prev;
@@ -42,4 +45,5 @@ void monkey_window_process_reformats(void);
void monkey_window_handle_command(int argc, char **argv);
void monkey_kill_browser_windows(void);
+
#endif /* NETSURF_MONKEY_BROWSER_H */
diff --git a/monkey/cert.c b/monkey/cert.c
index 0aa01f3a7..48359e8c2 100644
--- a/monkey/cert.c
+++ b/monkey/cert.c
@@ -16,11 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
+#include <stdio.h>
+
#include "desktop/gui.h"
#include "utils/ring.h"
-#include <stdlib.h>
-#include <stdio.h>
+#include "monkey/cert.h"
typedef struct monkey_cert {
struct monkey_cert *r_next, *r_prev;
diff --git a/monkey/cert.h b/monkey/cert.h
new file mode 100644
index 000000000..2780f4f57
--- /dev/null
+++ b/monkey/cert.h
@@ -0,0 +1,4 @@
+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/monkey/download.c b/monkey/download.c
index d706dd6e0..d2e3b4b24 100644
--- a/monkey/download.c
+++ b/monkey/download.c
@@ -34,7 +34,7 @@ struct gui_download_window {
static struct gui_download_window *dw_ring = NULL;
-struct gui_download_window *
+static struct gui_download_window *
gui_download_window_create(download_context *ctx,
struct gui_window *parent)
{
@@ -52,7 +52,7 @@ gui_download_window_create(download_context *ctx,
return ret;
}
-nserror
+static nserror
gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
@@ -61,7 +61,7 @@ gui_download_window_data(struct gui_download_window *dw,
return NSERROR_OK;
}
-void
+static void
gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
@@ -69,7 +69,7 @@ gui_download_window_error(struct gui_download_window *dw,
dw->dwin_num, error_msg);
}
-void
+static void
gui_download_window_done(struct gui_download_window *dw)
{
fprintf(stdout, "DOWNLOAD_WINDOW DONE DWIN %u\n",
@@ -77,3 +77,12 @@ gui_download_window_done(struct gui_download_window *dw)
RING_REMOVE(dw_ring, dw);
free(dw);
}
+
+static struct gui_download_table download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
+
+struct gui_download_table *monkey_download_table = &download_table;
diff --git a/monkey/main.c b/monkey/main.c
index 95432e3c7..b6f5c434d 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -25,6 +25,8 @@
#include "monkey/poll.h"
#include "monkey/dispatch.h"
#include "monkey/browser.h"
+#include "monkey/cert.h"
+#include "monkey/401login.h"
#include "content/urldb.h"
#include "content/fetchers/resource.h"
@@ -55,7 +57,7 @@ nsmonkey_init_resource(const char *resource_path)
return respath;
}
-void gui_quit(void)
+static void monkey_quit(void)
{
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_file));
@@ -64,7 +66,7 @@ void gui_quit(void)
gtk_fetch_filetype_fin();
}
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
char buf[PATH_MAX];
char *raw;
@@ -79,7 +81,7 @@ nsurl *gui_get_resource_url(const char *path)
return url;
}
-void
+static void
gui_launch_url(const char *url)
{
fprintf(stdout, "GENERIC LAUNCH URL %s\n", url);
@@ -113,6 +115,56 @@ static bool nslog_stream_configure(FILE *fptr)
return true;
}
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+
+static char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}
+
+/**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+
+static bool path_add_part(char *path, int length, const char *newpart)
+{
+ if(path[strlen(path) - 1] != '/')
+ strncat(path, "/", length);
+
+ strncat(path, newpart, length);
+
+ return true;
+}
+
+static struct gui_browser_table monkey_browser_table = {
+ .poll = monkey_poll,
+ .quit = monkey_quit,
+ .get_resource_url = gui_get_resource_url,
+ .launch_url = gui_launch_url,
+ .cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+ .login = gui_401login_open,
+};
+
int
main(int argc, char **argv)
{
@@ -120,6 +172,11 @@ main(int argc, char **argv)
char *options;
char buf[PATH_MAX];
nserror ret;
+ struct gui_table monkey_gui_table = {
+ .browser = &monkey_browser_table,
+ .window = monkey_window_table,
+ .download = monkey_download_table,
+ };
/* Unbuffer stdin/out/err */
setbuf(stdin, NULL);
@@ -146,7 +203,7 @@ main(int argc, char **argv)
/* common initialisation */
messages = filepath_find(respaths, "Messages");
- ret = netsurf_init(messages);
+ ret = netsurf_init(messages, &monkey_gui_table);
free(messages);
if (ret != NSERROR_OK) {
die("NetSurf failed to initialise");
diff --git a/monkey/poll.c b/monkey/poll.c
index 024005b89..414d458bd 100644
--- a/monkey/poll.c
+++ b/monkey/poll.c
@@ -88,7 +88,7 @@ monkey_prepare_input(void)
}
void
-gui_poll(bool active)
+monkey_poll(bool active)
{
CURLMcode code;
fd_set read_fd_set, write_fd_set, exc_fd_set;
diff --git a/monkey/poll.h b/monkey/poll.h
index 1aebe6856..4195958c9 100644
--- a/monkey/poll.h
+++ b/monkey/poll.h
@@ -21,4 +21,6 @@
void monkey_prepare_input(void);
+void monkey_poll(bool active);
+
#endif /* NETSURF_MONKEY_POLL_H */
diff --git a/monkey/utils.c b/monkey/utils.c
index 3e09106f7..aa7245533 100644
--- a/monkey/utils.c
+++ b/monkey/utils.c
@@ -70,44 +70,6 @@ char *url_to_path(const char *url)
return respath;
}
-/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-
-char *filename_from_path(char *path)
-{
- char *leafname;
-
- leafname = strrchr(path, '/');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
-
- return strdup(leafname);
-}
-
-/**
- * Add a path component/filename to an existing path
- *
- * \param path buffer containing path + free space
- * \param length length of buffer "path"
- * \param newpart string containing path component to add to path
- * \return true on success
- */
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- if(path[strlen(path) - 1] != '/')
- strncat(path, "/", length);
-
- strncat(path, newpart, length);
-
- return true;
-}
void warn_user(const char *warning, const char *detail)
{
diff --git a/render/html_interaction.c b/render/html_interaction.c
index 84c64ca20..415e7b1cf 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -30,6 +30,7 @@
#include "content/content.h"
#include "desktop/browser.h"
+#include "desktop/gui_factory.h"
#include "desktop/frames.h"
#include "desktop/mouse.h"
#include "utils/nsoption.h"
@@ -654,7 +655,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
c);
pointer = BROWSER_POINTER_DEFAULT;
} else if (mouse & BROWSER_MOUSE_CLICK_1)
- gui_create_form_select_menu(bw, gadget);
+ guit->browser->create_form_select_menu(bw, gadget);
break;
case GADGET_CHECKBOX:
status = messages_get("FormCheckbox");
diff --git a/riscos/401login.c b/riscos/401login.c
index 6740f54e5..e6772b820 100644
--- a/riscos/401login.c
+++ b/riscos/401login.c
@@ -27,7 +27,6 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/browser.h"
-#include "desktop/401login.h"
#include "desktop/gui.h"
#include "riscos/dialog.h"
#include "riscos/wimp_event.h"
diff --git a/riscos/download.c b/riscos/download.c
index ebd981dca..3a02c9c90 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -215,7 +215,7 @@ const char *ro_gui_download_temp_name(struct gui_download_window *dw)
* reported
*/
-struct gui_download_window *gui_download_window_create(download_context *ctx,
+static struct gui_download_window *gui_download_window_create(download_context *ctx,
struct gui_window *gui)
{
const char *url = download_context_get_url(ctx);
@@ -445,7 +445,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror gui_download_window_data(struct gui_download_window *dw,
+static nserror gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
while (true) {
@@ -714,7 +714,7 @@ void ro_gui_download_window_hide_caret(struct gui_download_window *dw)
* \param error_msg error message
*/
-void gui_download_window_error(struct gui_download_window *dw,
+static void gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
os_error *error;
@@ -766,7 +766,7 @@ void gui_download_window_error(struct gui_download_window *dw,
* \param dw download window
*/
-void gui_download_window_done(struct gui_download_window *dw)
+static void gui_download_window_done(struct gui_download_window *dw)
{
os_error *error;
@@ -1631,3 +1631,12 @@ bool ro_gui_download_prequit(void)
}
return true;
}
+
+static struct gui_download_table download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
+
+struct gui_download_table *riscos_download_table = &download_table;
diff --git a/riscos/gui.c b/riscos/gui.c
index ae5ea383e..f7dc6c962 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -252,7 +252,7 @@ static void ro_msg_save_desktop(wimp_message *message);
static void ro_msg_window_info(wimp_message *message);
static void ro_gui_view_source_bounce(wimp_message *message);
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
static const char base_url[] = "file:///NetSurf:/Resources/";
size_t path_len, length;
@@ -837,89 +837,13 @@ static bool nslog_stream_configure(FILE *fptr)
return true;
}
-/** Normal entry point from OS */
-int main(int argc, char** argv)
-{
- char path[40];
- int length;
- char logging_env[2];
- os_var_type type;
- int used = -1; /* slightly better with older OSLib versions */
- os_error *error;
- nserror ret;
-
- /* Consult NetSurf$Logging environment variable to decide if logging
- * is required. */
- error = xos_read_var_val_size("NetSurf$Logging", 0, os_VARTYPE_STRING,
- &used, NULL, &type);
- if (error != NULL || type != os_VARTYPE_STRING || used != -2) {
- verbose_log = true;
- } else {
- error = xos_read_var_val("NetSurf$Logging", logging_env,
- sizeof(logging_env), 0, os_VARTYPE_STRING,
- &used, NULL, &type);
- if (error != NULL || logging_env[0] != '0') {
- verbose_log = true;
- } else {
- verbose_log = false;
- }
- }
-
- /* initialise logging. Not fatal if it fails but not much we
- * can do about it either.
- */
- nslog_init(nslog_stream_configure, &argc, argv);
-
- /* user options setup */
- ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
- if (ret != NSERROR_OK) {
- die("Options failed to initialise");
- }
- nsoption_read("NetSurf:Choices", NULL);
- nsoption_commandline(&argc, argv, NULL);
-
- /* Choose the interface language to use */
- ro_gui_choose_language();
-
- /* select language-specific Messages */
- if (((length = snprintf(path,
- sizeof(path),
- "NetSurf:Resources.%s.Messages",
- nsoption_charp(language))) < 0) ||
- (length >= (int)sizeof(path))) {
- die("Failed to locate Messages resource.");
- }
-
- /* common initialisation */
- ret = netsurf_init(path);
- if (ret != NSERROR_OK) {
- die("NetSurf failed to initialise");
- }
-
- artworks_init();
- draw_init();
- sprite_init();
-
- /* Load some extra RISC OS specific Messages */
- messages_load("NetSurf:Resources.LangNames");
-
- gui_init(argc, argv);
-
- gui_init2(argc, argv);
-
- netsurf_main_loop();
-
- netsurf_exit();
-
- return 0;
-}
/**
* Close down the gui (RISC OS).
*/
-void gui_quit(void)
+static void gui_quit(void)
{
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_save));
@@ -1024,7 +948,7 @@ void ro_gui_cleanup(void)
* \param active return as soon as possible
*/
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
wimp_event_no event;
wimp_block block;
@@ -2263,7 +2187,7 @@ void ro_gui_dump_browser_window(struct browser_window *bw)
* Broadcast an URL that we can't handle.
*/
-void gui_launch_url(const char *url)
+static void gui_launch_url(const char *url)
{
/* Try ant broadcast first */
ro_url_broadcast(url);
@@ -2364,7 +2288,7 @@ void PDF_Password(char **owner_pass, char **user_pass, char *path)
* \return filename (will be freed with free())
*/
-char *filename_from_path(char *path)
+static char *filename_from_path(char *path)
{
char *leafname;
char *temp;
@@ -2402,7 +2326,7 @@ char *filename_from_path(char *path)
* \return true on success
*/
-bool path_add_part(char *path, int length, const char *newpart)
+static bool path_add_part(char *path, int length, const char *newpart)
{
size_t path_len = strlen(path);
@@ -2424,10 +2348,103 @@ bool path_add_part(char *path, int length, const char *newpart)
return true;
}
-void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
- struct form_control *gadget)
+static struct gui_clipboard_table riscos_clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+static struct gui_browser_table riscos_browser_table = {
+ .poll = gui_poll,
+ .quit = gui_quit,
+ .get_resource_url = gui_get_resource_url,
+ .launch_url = gui_launch_url,
+ .create_form_select_menu = gui_create_form_select_menu,
+ .cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+ .login = gui_401login_open,
+};
+
+
+/** Normal entry point from OS */
+int main(int argc, char** argv)
{
- LOG(("File open dialog rquest for %p/%p", g, gadget));
- /* browser_window_set_gadget_filename(bw, gadget, "filename"); */
-}
+ char path[40];
+ int length;
+ char logging_env[2];
+ os_var_type type;
+ int used = -1; /* slightly better with older OSLib versions */
+ os_error *error;
+ nserror ret;
+ struct gui_table riscos_gui_table = {
+ .browser = &riscos_browser_table,
+ .window = riscos_window_table,
+ .clipboard = &riscos_clipboard_table,
+ .download = riscos_download_table,
+ };
+ /* Consult NetSurf$Logging environment variable to decide if logging
+ * is required. */
+ error = xos_read_var_val_size("NetSurf$Logging", 0, os_VARTYPE_STRING,
+ &used, NULL, &type);
+ if (error != NULL || type != os_VARTYPE_STRING || used != -2) {
+ verbose_log = true;
+ } else {
+ error = xos_read_var_val("NetSurf$Logging", logging_env,
+ sizeof(logging_env), 0, os_VARTYPE_STRING,
+ &used, NULL, &type);
+ if (error != NULL || logging_env[0] != '0') {
+ verbose_log = true;
+ } else {
+ verbose_log = false;
+ }
+ }
+
+ /* initialise logging. Not fatal if it fails but not much we
+ * can do about it either.
+ */
+ nslog_init(nslog_stream_configure, &argc, argv);
+
+ /* user options setup */
+ ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
+ if (ret != NSERROR_OK) {
+ die("Options failed to initialise");
+ }
+ nsoption_read("NetSurf:Choices", NULL);
+ nsoption_commandline(&argc, argv, NULL);
+
+ /* Choose the interface language to use */
+ ro_gui_choose_language();
+
+ /* select language-specific Messages */
+ if (((length = snprintf(path,
+ sizeof(path),
+ "NetSurf:Resources.%s.Messages",
+ nsoption_charp(language))) < 0) ||
+ (length >= (int)sizeof(path))) {
+ die("Failed to locate Messages resource.");
+ }
+
+ /* common initialisation */
+ ret = netsurf_init(path, &riscos_gui_table);
+ if (ret != NSERROR_OK) {
+ die("NetSurf failed to initialise");
+ }
+
+ artworks_init();
+ draw_init();
+ sprite_init();
+
+ /* Load some extra RISC OS specific Messages */
+ messages_load("NetSurf:Resources.LangNames");
+
+ gui_init(argc, argv);
+
+ gui_init2(argc, argv);
+
+ netsurf_main_loop();
+
+ netsurf_exit();
+
+ return 0;
+}
diff --git a/riscos/gui.h b/riscos/gui.h
index 827af8108..89a539300 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -123,9 +123,12 @@ const char *ro_gui_default_language(void);
void ro_gui_download_init(void);
void ro_gui_download_datasave_ack(wimp_message *message);
bool ro_gui_download_prequit(void);
+extern struct gui_download_table *riscos_download_table;
/* in 401login.c */
void ro_gui_401login_init(void);
+void gui_401login_open(nsurl *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
/* in window.c */
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message);
@@ -154,6 +157,8 @@ browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons,
bool ro_gui_shift_pressed(void);
bool ro_gui_ctrl_pressed(void);
bool ro_gui_alt_pressed(void);
+void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape);
+void gui_create_form_select_menu(struct browser_window *bw, struct form_control *control);
/* in history.c */
void ro_gui_history_init(void);
@@ -199,6 +204,15 @@ extern int ro_plot_origin_y;
/* in theme_install.c */
bool ro_gui_theme_install_apply(wimp_w w);
+/* in textselection.c */
+void gui_get_clipboard(char **buffer, size_t *length);
+void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles);
+
+/* in sslcert.c */
+void gui_cert_verify(nsurl *url,
+ const struct ssl_cert_info *certs, unsigned long num,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
+
/* icon numbers */
#define ICON_STATUS_RESIZE 0
#define ICON_STATUS_TEXT 1
diff --git a/riscos/print.c b/riscos/print.c
index 0df77ef6b..09d4aaefb 100644
--- a/riscos/print.c
+++ b/riscos/print.c
@@ -90,6 +90,7 @@ static unsigned int print_fonts_count;
/** Error in print_fonts_plot_text() or print_fonts_callback(). */
static const char *print_fonts_error;
+void gui_window_redraw_window(struct gui_window *g);
static bool ro_gui_print_click(wimp_pointer *pointer);
static bool ro_gui_print_apply(wimp_w w);
diff --git a/riscos/query.h b/riscos/query.h
index 92e3e292e..10a67e73b 100644
--- a/riscos/query.h
+++ b/riscos/query.h
@@ -29,4 +29,8 @@ query_id query_user_xy(const char *query, const char *detail,
void ro_gui_query_init(void);
void ro_gui_query_window_bring_to_front(query_id id);
+query_id query_user(const char *query, const char *detail,
+ const query_callback *cb, void *pw, const char *yes, const char *no);
+void query_close(query_id);
+
#endif
diff --git a/riscos/save.c b/riscos/save.c
index 4d1740397..59222c49a 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -357,8 +357,8 @@ bool ro_gui_save_ok(wimp_w w)
* \param g gui window
*/
-void gui_drag_save_object(gui_save_type save_type, hlcache_handle *c,
- struct gui_window *g)
+void gui_drag_save_object(struct gui_window *g, hlcache_handle *c,
+ gui_save_type save_type)
{
wimp_pointer pointer;
char icon_buf[20];
diff --git a/riscos/save.h b/riscos/save.h
index 34a4a6ba9..0c917664a 100644
--- a/riscos/save.h
+++ b/riscos/save.h
@@ -27,6 +27,9 @@
#include "oslib/wimp.h"
#include "desktop/gui.h"
+void gui_drag_save_object(struct gui_window *g, hlcache_handle *c, gui_save_type save_type);
+void gui_drag_save_selection(struct gui_window *g, const char *selection);
+
wimp_w ro_gui_saveas_create(const char *template_name);
void ro_gui_saveas_quit(void);
void ro_gui_save_prepare(gui_save_type save_type, struct hlcache_handle *h,
diff --git a/riscos/textselection.c b/riscos/textselection.c
index ab8ea5c3a..73b5246e3 100644
--- a/riscos/textselection.c
+++ b/riscos/textselection.c
@@ -186,20 +186,6 @@ static void ro_gui_selection_drag_end(wimp_dragged *drag, void *data)
browser_window_mouse_track(g->bw, 0, pos.x, pos.y);
}
-
-/**
- * Perform tasks after a selection has been cleared.
- *
- * \param g gui window
- */
-
-void gui_clear_selection(struct gui_window *g)
-{
- /* Refresh any open menu, in case it's the browser window menu. */
- ro_gui_menu_refresh(0);
-}
-
-
/**
* Core tells front end to put given text in clipboard
*
diff --git a/riscos/textselection.h b/riscos/textselection.h
index c6f96f0e9..a4f436ddc 100644
--- a/riscos/textselection.h
+++ b/riscos/textselection.h
@@ -26,6 +26,8 @@
#include "oslib/wimp.h"
#include "desktop/gui.h"
+void gui_start_selection(struct gui_window *g);
+
typedef void (*ro_gui_selection_prepare_paste_cb)(void *pw);
void ro_gui_selection_prepare_paste(wimp_w w,
diff --git a/riscos/window.c b/riscos/window.c
index c08f0277b..0d31b663a 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -89,6 +89,7 @@
#include "utils/utils.h"
#include "utils/messages.h"
+void gui_window_redraw_window(struct gui_window *g);
static void gui_window_set_extent(struct gui_window *g, int width, int height);
@@ -372,6 +373,30 @@ void ro_gui_window_initialise(void)
*/
/**
+ * Place the caret in a browser window.
+ *
+ * \param g window with caret
+ * \param x coordinates of caret
+ * \param y coordinates of caret
+ * \param height height of caret
+ * \param clip clip rectangle, or NULL if none
+ */
+
+static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
+ const struct rect *clip)
+{
+ os_error *error;
+
+ error = xwimp_set_caret_position(g->window, -1,
+ x * 2, -(y + height) * 2, height * 2, -1);
+ if (error) {
+ LOG(("xwimp_set_caret_position: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("WimpError", error->errmess);
+ }
+}
+
+/**
* Create and open a new browser window.
*
* \param bw browser_window structure to update
@@ -379,7 +404,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,
+static 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;
@@ -600,7 +625,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
* \param g gui_window to destroy
*/
-void gui_window_destroy(struct gui_window *g)
+static void gui_window_destroy(struct gui_window *g)
{
os_error *error;
wimp_w w;
@@ -651,7 +676,7 @@ void gui_window_destroy(struct gui_window *g)
* \param title new window title, copied
*/
-void gui_window_set_title(struct gui_window *g, const char *title)
+static void gui_window_set_title(struct gui_window *g, const char *title)
{
int scale_disp;
@@ -710,7 +735,7 @@ void gui_window_redraw_window(struct gui_window *g)
* \param data content_msg_data union with filled in redraw data
*/
-void gui_window_update_box(struct gui_window *g, const struct rect *rect)
+static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
{
bool use_buffer;
int x0, y0, x1, y1;
@@ -765,7 +790,7 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect)
* \return true iff successful
*/
-bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
wimp_window_state state;
os_error *error;
@@ -798,7 +823,7 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
* \param sy point to place at top-left of window
*/
-void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
wimp_window_state state;
os_error *error;
@@ -831,7 +856,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
* \param x1 right point to ensure visible
* \param y1 top point to ensure visible
*/
-void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int y1)
+static void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int y1)
{
wimp_window_state state;
os_error *error;
@@ -915,7 +940,7 @@ void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int
* \param scaled whether to return scaled values
*/
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled)
+static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled)
{
/* use the cached window sizes */
*width = g->old_width / 2;
@@ -934,7 +959,7 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bo
* \param g gui_window to update the extent of
*/
-void gui_window_update_extent(struct gui_window *g)
+static void gui_window_update_extent(struct gui_window *g)
{
os_error *error;
wimp_window_info info;
@@ -986,7 +1011,7 @@ void gui_window_update_extent(struct gui_window *g)
* \param text new status text
*/
-void gui_window_set_status(struct gui_window *g, const char *text)
+static void gui_window_set_status(struct gui_window *g, const char *text)
{
if (g->status_bar)
ro_gui_status_bar_set_text(g->status_bar, text);
@@ -1038,30 +1063,13 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
/**
- * Remove the mouse pointer from the screen
- */
-
-void gui_window_hide_pointer(struct gui_window *g)
-{
- os_error *error;
-
- error = xwimpspriteop_set_pointer_shape(NULL, 0x30, 0, 0, 0, 0);
- if (error) {
- LOG(("xwimpspriteop_set_pointer_shape: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- }
-}
-
-
-/**
* Set the contents of a window's address bar.
*
* \param g gui_window to update
* \param url new url for address bar
*/
-void gui_window_set_url(struct gui_window *g, const char *url)
+static void gui_window_set_url(struct gui_window *g, const char *url)
{
if (!g->toolbar)
return;
@@ -1077,7 +1085,7 @@ void gui_window_set_url(struct gui_window *g, const char *url)
* \param g window with start of load
*/
-void gui_window_start_throbber(struct gui_window *g)
+static void gui_window_start_throbber(struct gui_window *g)
{
ro_gui_window_update_toolbar_buttons(g);
ro_gui_menu_refresh(ro_gui_browser_window_menu);
@@ -1093,7 +1101,7 @@ void gui_window_start_throbber(struct gui_window *g)
* \param g window with start of load
*/
-void gui_window_stop_throbber(struct gui_window *g)
+static void gui_window_stop_throbber(struct gui_window *g)
{
ro_gui_window_update_toolbar_buttons(g);
ro_gui_menu_refresh(ro_gui_browser_window_menu);
@@ -1105,7 +1113,7 @@ void gui_window_stop_throbber(struct gui_window *g)
* set favicon
*/
-void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
+static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
{
if (g == NULL || g->toolbar == NULL)
return;
@@ -1113,38 +1121,6 @@ void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
ro_toolbar_set_site_favicon(g->toolbar, icon);
}
-/**
-* set gui display of a retrieved favicon representing the search provider
-* \param ico may be NULL for local calls; then access current cache from
-* search_web_ico()
-*/
-void gui_window_set_search_ico(hlcache_handle *ico)
-{
-}
-
-/**
- * Place the caret in a browser window.
- *
- * \param g window with caret
- * \param x coordinates of caret
- * \param y coordinates of caret
- * \param height height of caret
- * \param clip clip rectangle, or NULL if none
- */
-
-void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
- const struct rect *clip)
-{
- os_error *error;
-
- error = xwimp_set_caret_position(g->window, -1,
- x * 2, -(y + height) * 2, height * 2, -1);
- if (error) {
- LOG(("xwimp_set_caret_position: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
- }
-}
/**
@@ -1153,7 +1129,7 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
* \param g window with caret
*/
-void gui_window_remove_caret(struct gui_window *g)
+static void gui_window_remove_caret(struct gui_window *g)
{
wimp_caret caret;
os_error *error;
@@ -1181,7 +1157,7 @@ void gui_window_remove_caret(struct gui_window *g)
* \param g the gui_window that has new content
*/
-void gui_window_new_content(struct gui_window *g)
+static void gui_window_new_content(struct gui_window *g)
{
ro_gui_menu_refresh(ro_gui_browser_window_menu);
ro_gui_window_update_toolbar_buttons(g);
@@ -1193,10 +1169,10 @@ void gui_window_new_content(struct gui_window *g)
/**
* Starts drag scrolling of a browser window
*
- * \param gw gui window
+ * \param g the window to scroll
*/
-bool gui_window_scroll_start(struct gui_window *g)
+static bool gui_window_scroll_start(struct gui_window *g)
{
wimp_window_info_base info;
wimp_pointer pointer;
@@ -1260,7 +1236,7 @@ bool gui_window_scroll_start(struct gui_window *g)
* \return true iff succesful
*/
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
+static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
const struct rect *rect)
{
wimp_pointer pointer;
@@ -1319,7 +1295,7 @@ bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
* \param g gui_window containing the content
* \param c the content to save
*/
-void gui_window_save_link(struct gui_window *g, const char *url,
+static void gui_window_save_link(struct gui_window *g, const char *url,
const char *title)
{
ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL, url, title);
@@ -5263,3 +5239,38 @@ bool ro_gui_alt_pressed(void)
xosbyte1(osbyte_SCAN_KEYBOARD, 2 ^ 0x80, 0, &alt);
return (alt == 0xff);
}
+
+static struct gui_window_table gui_window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .set_icon = gui_window_set_icon,
+ .set_status = gui_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .save_link = gui_window_save_link,
+ .drag_start = gui_window_drag_start,
+ .scroll_visible = gui_window_scroll_visible,
+ .scroll_start = gui_window_scroll_start,
+ .new_content = gui_window_new_content,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+
+ /* from save */
+ .drag_save_object = gui_drag_save_object,
+ .drag_save_selection =gui_drag_save_selection,
+
+ /* from textselection */
+ .start_selection = gui_start_selection,
+};
+
+struct gui_window_table *riscos_gui_window_table = &gui_window_table;
diff --git a/riscos/window.h b/riscos/window.h
index adbd999f9..679fa9801 100644
--- a/riscos/window.h
+++ b/riscos/window.h
@@ -25,6 +25,8 @@
#ifndef _NETSURF_RISCOS_WINDOW_H_
#define _NETSURF_RISCOS_WINDOW_H_
+extern struct gui_window_table *riscos_gui_window_table;
+
void ro_gui_window_initialise(void);
bool ro_gui_window_check_menu(wimp_menu *menu);
diff --git a/utils/utils.h b/utils/utils.h
index f2241ae07..ed19cb33f 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -184,10 +184,6 @@ inline static char digit2uppercase_hex(unsigned char digit) {
/* Platform specific functions */
void die(const char * const error);
void warn_user(const char *warning, const char *detail);
-query_id query_user(const char *query, const char *detail,
- const query_callback *cb, void *pw, const char *yes, const char *no);
-void query_close(query_id);
void PDF_Password(char **owner_pass, char **user_pass, char *path);
-char *filename_from_path(char *path);
-bool path_add_part(char *path, int length, const char *newpart);
+
#endif
diff --git a/windows/Makefile.target b/windows/Makefile.target
index cad28b575..87544e3db 100644
--- a/windows/Makefile.target
+++ b/windows/Makefile.target
@@ -65,7 +65,7 @@ S_RESOURCES := windows_resource.o
# S_WINDOWS are sources purely for the windows build
S_WINDOWS := main.c window.c gui.c drawable.c misc.c plot.c findfile.c \
font.c bitmap.c about.c prefs.c download.c filetype.c \
- localhistory.c login.c schedule.c thumbnail.c windbg.c
+ localhistory.c schedule.c thumbnail.c windbg.c
S_WINDOWS := $(addprefix windows/,$(S_WINDOWS))
# This is the final source build list
diff --git a/windows/download.c b/windows/download.c
index 635e3b604..189baa819 100644
--- a/windows/download.c
+++ b/windows/download.c
@@ -45,7 +45,7 @@ static void nsws_download_update_label(void *p);
static void nsws_download_update_progress(void *p);
static void nsws_download_clear_data(struct gui_download_window *w);
-struct gui_download_window *
+static struct gui_download_window *
gui_download_window_create(download_context *ctx, struct gui_window *gui)
{
if (downloading) {
@@ -259,7 +259,8 @@ void nsws_download_clear_data(struct gui_download_window *w)
}
-nserror gui_download_window_data(struct gui_download_window *w, const char *data,
+static nserror
+gui_download_window_data(struct gui_download_window *w, const char *data,
unsigned int size)
{
if ((w == NULL) || (w->file == NULL))
@@ -279,13 +280,13 @@ nserror gui_download_window_data(struct gui_download_window *w, const char *data
return NSERROR_OK;
}
-void gui_download_window_error(struct gui_download_window *w,
+static void gui_download_window_error(struct gui_download_window *w,
const char *error_msg)
{
LOG(("error %s", error_msg));
}
-void gui_download_window_done(struct gui_download_window *w)
+static void gui_download_window_done(struct gui_download_window *w)
{
if (w == NULL)
return;
@@ -295,3 +296,12 @@ void gui_download_window_done(struct gui_download_window *w)
nsws_download_clear_data(w);
}
+static struct gui_download_table download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
+
+struct gui_download_table *win32_download_table = &download_table;
+
diff --git a/windows/download.h b/windows/download.h
index 777777da5..a53fab89f 100644
--- a/windows/download.h
+++ b/windows/download.h
@@ -23,6 +23,8 @@
#include <windows.h>
#include "desktop/gui.h"
+struct gui_download_table *win32_download_table;
+
typedef enum {
DOWNLOAD_NONE,
DOWNLOAD_WORKING,
diff --git a/windows/drawable.c b/windows/drawable.c
index 8e35d306c..34b8958dc 100644
--- a/windows/drawable.c
+++ b/windows/drawable.c
@@ -37,6 +37,8 @@
static const char windowclassname_drawable[] = "nswsdrawablewindow";
+void gui_window_set_scroll(struct gui_window *w, int sx, int sy);
+
/**
* Handle wheel scroll messages.
*/
diff --git a/windows/gui.c b/windows/gui.c
index e20369a65..40124671d 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -73,14 +73,11 @@ static const char windowclassname_main[] = "nswsmainwindow";
static struct nsws_pointers nsws_pointer;
-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"); */
-}
+void gui_window_set_scroll(struct gui_window *w, int sx, int sy);
+static bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
+
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
MSG Msg; /* message from system */
BOOL bRet; /* message fetch result */
@@ -723,6 +720,18 @@ nsws_window_resize(struct gui_window *gw,
return 0;
}
+/**
+ * redraw the whole window
+ */
+static void gui_window_redraw_window(struct gui_window *gw)
+{
+ /* LOG(("gw:%p", gw)); */
+ if (gw == NULL)
+ return;
+
+ RedrawWindow(gw->drawingarea, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE);
+}
+
static LRESULT
nsws_window_command(HWND hwnd,
@@ -1220,10 +1229,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 +1408,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;
@@ -1422,7 +1431,7 @@ void gui_window_destroy(struct gui_window *w)
* set window title
* \param title the [url]
*/
-void gui_window_set_title(struct gui_window *w, const char *title)
+static void gui_window_set_title(struct gui_window *w, const char *title)
{
if (w == NULL)
return;
@@ -1439,19 +1448,7 @@ void gui_window_set_title(struct gui_window *w, const char *title)
free(fulltitle);
}
-/**
- * redraw the whole window
- */
-void gui_window_redraw_window(struct gui_window *gw)
-{
- /* LOG(("gw:%p", gw)); */
- if (gw == NULL)
- return;
-
- RedrawWindow(gw->drawingarea, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE);
-}
-
-void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
+static void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
{
/* LOG(("gw:%p %f,%f %f,%f", gw, data->redraw.x, data->redraw.y, data->redraw.width, data->redraw.height)); */
@@ -1469,7 +1466,7 @@ void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
}
-bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
+static bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
{
LOG(("get scroll"));
if (w == NULL)
@@ -1543,13 +1540,7 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
}
-void gui_window_scroll_visible(struct gui_window *w, int x0, int y0,
- int x1, int y1)
-{
- LOG(("scroll visible (%p, %d, %d, %d, %d)", w, x0, y0, x1, y1));
-}
-
-void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
+static void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
bool scaled)
{
if (w == NULL)
@@ -1561,7 +1552,7 @@ void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
*height = w->height;
}
-void gui_window_update_extent(struct gui_window *w)
+static void gui_window_update_extent(struct gui_window *w)
{
}
@@ -1569,7 +1560,7 @@ void gui_window_update_extent(struct gui_window *w)
/**
* set the status bar message
*/
-void gui_window_set_status(struct gui_window *w, const char *text)
+static void gui_window_set_status(struct gui_window *w, const char *text)
{
if (w == NULL)
return;
@@ -1579,7 +1570,7 @@ void gui_window_set_status(struct gui_window *w, const char *text)
/**
* set the pointer shape
*/
-void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
+static void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
{
if (w == NULL)
return;
@@ -1650,11 +1641,7 @@ struct nsws_pointers *nsws_get_pointers(void)
return &nsws_pointer;
}
-void gui_window_hide_pointer(struct gui_window *w)
-{
-}
-
-void gui_window_set_url(struct gui_window *w, const char *url)
+static void gui_window_set_url(struct gui_window *w, const char *url)
{
if (w == NULL)
return;
@@ -1662,7 +1649,7 @@ void gui_window_set_url(struct gui_window *w, const char *url)
}
-void gui_window_start_throbber(struct gui_window *w)
+static void gui_window_start_throbber(struct gui_window *w)
{
if (w == NULL)
return;
@@ -1687,7 +1674,7 @@ void gui_window_start_throbber(struct gui_window *w)
Animate_Play(w->throbber, 0, -1, -1);
}
-void gui_window_stop_throbber(struct gui_window *w)
+static void gui_window_stop_throbber(struct gui_window *w)
{
if (w == NULL)
return;
@@ -1715,8 +1702,8 @@ void gui_window_stop_throbber(struct gui_window *w)
/**
* place caret in window
*/
-void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
- const struct rect *clip)
+static void gui_window_place_caret(struct gui_window *w, int x, int y,
+ int height, const struct rect *clip)
{
if (w == NULL)
return;
@@ -1729,69 +1716,20 @@ void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
/**
* clear window caret
*/
-void
-gui_window_remove_caret(struct gui_window *w)
+static void gui_window_remove_caret(struct gui_window *w)
{
if (w == NULL)
return;
HideCaret(w->drawingarea);
}
-void
-gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
-{
-}
-
-void
-gui_window_set_search_ico(hlcache_handle *ico)
-{
-}
-
-void gui_window_new_content(struct gui_window *w)
-{
-}
-
-bool gui_window_scroll_start(struct gui_window *w)
-{
- return true;
-}
-
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
-{
- return true;
-}
-
-void gui_window_save_link(struct gui_window *g, const char *url,
- const char *title)
-{
-}
-
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *w)
-{
-}
-
-
-void gui_drag_save_selection(struct gui_window *g, const char *selection)
-{
-}
-
-void gui_start_selection(struct gui_window *w)
-{
-}
-
-void gui_clear_selection(struct gui_window *w)
-{
-}
-
/**
* Core asks front end for clipboard contents.
*
* \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
* \param length Byte length of UTF-8 text in buffer
*/
-void gui_get_clipboard(char **buffer, size_t *length)
+static void gui_get_clipboard(char **buffer, size_t *length)
{
/* TODO: Implement this */
HANDLE clipboard_handle;
@@ -1813,7 +1751,7 @@ void gui_get_clipboard(char **buffer, size_t *length)
* \param styles Array of styles given to text runs, owned by core, or NULL
* \param n_styles Number of text run styles in array
*/
-void gui_set_clipboard(const char *buffer, size_t length,
+static void gui_set_clipboard(const char *buffer, size_t length,
nsclipboard_styles styles[], int n_styles)
{
/* TODO: Implement this */
@@ -1839,19 +1777,6 @@ void gui_set_clipboard(const char *buffer, size_t length,
}
-void gui_create_form_select_menu(struct browser_window *bw,
- struct form_control *control)
-{
-}
-
-
-void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
- unsigned long num,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
-{
- cb(false, cbpw);
-}
-
/**
* Create the main window class.
*/
@@ -1883,3 +1808,77 @@ nsws_create_main_class(HINSTANCE hinstance) {
return ret;
}
+
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+static char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '\\');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}
+
+/**
+ * Add a path component/filename to an existing path
+ *
+ * \param path buffer containing path + free space
+ * \param length length of buffer "path"
+ * \param newpart string containing path component to add to path
+ * \return true on success
+ */
+static bool path_add_part(char *path, int length, const char *newpart)
+{
+ if(path[strlen(path) - 1] != '\\')
+ strncat(path, "\\", length);
+
+ strncat(path, newpart, length);
+
+ return true;
+}
+
+static struct gui_window_table window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .set_status = gui_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+};
+
+struct gui_window_table *win32_window_table = &window_table;
+
+static struct gui_clipboard_table clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+struct gui_clipboard_table *win32_clipboard_table = &clipboard_table;
+
+static struct gui_table browser_table = {
+ .poll = gui_poll,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+};
+
+struct gui_browser_table *win32_browser_table = &browser_table;
diff --git a/windows/gui.h b/windows/gui.h
index 9bcba592e..3372dcc21 100644
--- a/windows/gui.h
+++ b/windows/gui.h
@@ -24,6 +24,10 @@
#include "desktop/gui.h"
#include "windows/localhistory.h"
+extern struct gui_window_table *win32_window_table;
+extern struct gui_clipboard_table *win32_clipboard_table;
+extern struct gui_browser_table *win32_browser_table;
+
extern HINSTANCE hInstance;
/* bounding box */
diff --git a/windows/login.c b/windows/login.c
deleted file mode 100644
index 7a5e195f4..000000000
--- a/windows/login.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "desktop/401login.h"
-
-void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
-{
- cb(false, cbpw);
-}
diff --git a/windows/main.c b/windows/main.c
index 69a152d9b..638db6c5c 100644
--- a/windows/main.c
+++ b/windows/main.c
@@ -41,7 +41,7 @@ static char **respaths; /** resource search path vector. */
char *options_file_location;
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
char buf[PATH_MAX];
char *raw;
@@ -56,15 +56,6 @@ nsurl *gui_get_resource_url(const char *path)
return url;
}
-void gui_launch_url(const char *url)
-{
-}
-
-void gui_quit(void)
-{
- LOG(("gui_quit"));
-}
-
/**
* Ensures output logging stream is available
*/
@@ -96,6 +87,8 @@ static nserror set_defaults(struct nsoption_s *defaults)
return NSERROR_OK;
}
+
+
/**
* Entry point from operating system
**/
@@ -111,6 +104,13 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
const char *addr;
nsurl *url;
nserror error;
+ struct gui_table win32_gui_table = {
+ .browser = win32_browser_table,
+ .window = win32_window_table,
+ .clipboard = win32_clipboard_table,
+ .download = win32_download_table,
+ };
+ win32_gui_table->browser->get_resource_url = get_resource_url;
if (SLEN(lpcli) > 0) {
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
@@ -157,7 +157,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
/* common initialisation */
messages = filepath_find(respaths, "messages");
- ret = netsurf_init(messages);
+ ret = netsurf_init(messages, &win32_gui_table);
free(messages);
if (ret != NSERROR_OK) {
free(options_file_location);
diff --git a/windows/misc.c b/windows/misc.c
index d820a5bca..b60eb512c 100644
--- a/windows/misc.c
+++ b/windows/misc.c
@@ -43,41 +43,3 @@ void die(const char *error)
exit(1);
}
-/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-
-char *filename_from_path(char *path)
-{
- char *leafname;
-
- leafname = strrchr(path, '\\');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
-
- return strdup(leafname);
-}
-
-/**
- * Add a path component/filename to an existing path
- *
- * \param path buffer containing path + free space
- * \param length length of buffer "path"
- * \param newpart string containing path component to add to path
- * \return true on success
- */
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- if(path[strlen(path) - 1] != '\\')
- strncat(path, "\\", length);
-
- strncat(path, newpart, length);
-
- return true;
-}