summaryrefslogtreecommitdiff
path: root/frontends/riscos
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/riscos')
-rw-r--r--frontends/riscos/cookies.c517
-rw-r--r--frontends/riscos/cookies.h49
-rw-r--r--frontends/riscos/dialog.c2
-rw-r--r--frontends/riscos/gui.c5
-rw-r--r--frontends/riscos/gui/button_bar.h7
-rw-r--r--frontends/riscos/gui/url_bar.h1
-rw-r--r--frontends/riscos/iconbar.c2
-rw-r--r--frontends/riscos/window.c2
8 files changed, 362 insertions, 223 deletions
diff --git a/frontends/riscos/cookies.c b/frontends/riscos/cookies.c
index 26374a567..38963ab3a 100644
--- a/frontends/riscos/cookies.c
+++ b/frontends/riscos/cookies.c
@@ -1,6 +1,5 @@
/*
- * Copyright 2006 Richard Wilson <info@tinct.net>
- * Copyright 2010 Stephen Fryatt <stevef@netsurf-browser.org>
+ * Copyright 2016 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -17,176 +16,120 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Cookies (implementation).
+/**
+ * \file
+ * Implementation of RISC OS cookie manager.
*/
-#include <assert.h>
-#include <stdbool.h>
-#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include "oslib/wimp.h"
-#include "oslib/wimpspriteop.h"
+#include <oslib/wimp.h>
+#include "utils/log.h"
#include "utils/nsoption.h"
#include "utils/messages.h"
-#include "utils/log.h"
+#include "netsurf/plotters.h"
#include "netsurf/keypress.h"
#include "desktop/cookie_manager.h"
-#include "desktop/tree.h"
-#include "riscos/cookies.h"
-#include "riscos/dialog.h"
-#include "riscos/menus.h"
-#include "riscos/toolbar.h"
-#include "riscos/treeview.h"
+#include "riscos/gui.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
+#include "riscos/dialog.h"
+#include "riscos/toolbar.h"
+#include "riscos/corewindow.h"
+#include "riscos/cookies.h"
-static void ro_gui_cookies_toolbar_update_buttons(void);
-static void ro_gui_cookies_toolbar_save_buttons(char *config);
-static bool ro_gui_cookies_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_pointer *pointer);
-static void ro_gui_cookies_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_selection *selection, menu_action action);
-static bool ro_gui_cookies_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_selection *selection, menu_action action);
-static void ro_gui_cookies_toolbar_click(button_bar_action action);
-
-struct ro_treeview_callbacks ro_cookies_treeview_callbacks = {
- ro_gui_cookies_toolbar_click,
- ro_gui_cookies_toolbar_update_buttons,
- ro_gui_cookies_toolbar_save_buttons
+struct ro_cookie_window {
+ struct ro_corewindow core;
+ wimp_menu *menu;
};
-/* The RISC OS cookie window, toolbar and treeview data. */
+/** cookie window is a singleton */
+static struct ro_cookie_window *cookie_window = NULL;
-static struct ro_cookies_window {
- wimp_w window;
- struct toolbar *toolbar;
- ro_treeview *tv;
- wimp_menu *menu;
-} cookies_window;
+/** riscos template for cookie window */
+static wimp_window *dialog_cookie_template;
-/**
- * Pre-Initialise the cookies tree. This is called for things that
- * need to be done at the gui_init() stage, such as loading templates.
- */
-
-void ro_gui_cookies_preinitialise(void)
-{
- /* Create our window. */
-
- cookies_window.window = ro_gui_dialog_create("tree");
- ro_gui_set_window_title(cookies_window.window,
- messages_get("Cookies"));
-}
/**
- * Initialise cookies tree, at the gui_init2() stage.
+ * callback to draw on drawable area of ro cookie window
+ *
+ * \param ro_cw The riscos core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \param originx The risc os plotter x origin.
+ * \param originy The risc os plotter y origin.
+ * \return NSERROR_OK on success otherwise apropriate error code
*/
-
-void ro_gui_cookies_postinitialise(void)
+static nserror
+cookie_draw(struct ro_corewindow *ro_cw,
+ int originx,
+ int originy,
+ struct rect *r)
{
- /* Create our toolbar. */
-
- cookies_window.toolbar = ro_toolbar_create(NULL, cookies_window.window,
- THEME_STYLE_COOKIES_TOOLBAR, TOOLBAR_FLAGS_NONE,
- ro_treeview_get_toolbar_callbacks(), NULL,
- "HelpCookiesToolbar");
- if (cookies_window.toolbar != NULL) {
- ro_toolbar_add_buttons(cookies_window.toolbar,
- cookies_toolbar_buttons,
- nsoption_charp(toolbar_cookies));
- ro_toolbar_rebuild(cookies_window.toolbar);
- }
-
- /* Create the treeview with the window and toolbar. */
-
- cookies_window.tv = ro_treeview_create(cookies_window.window,
- cookies_window.toolbar, &ro_cookies_treeview_callbacks,
- TREE_COOKIES);
- if (cookies_window.tv == NULL) {
- LOG("Failed to allocate treeview");
- return;
- }
-
- ro_toolbar_update_client_data(cookies_window.toolbar,
- cookies_window.tv);
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &ro_plotters
+ };
- /* Build the cookies window menu. */
+ ro_plot_origin_x = originx;
+ ro_plot_origin_y = originy;
+ no_font_blending = true;
+ cookie_manager_redraw(0, 0, r, &ctx);
+ no_font_blending = false;
- static const struct ns_menu cookies_definition = {
- "Cookies", {
- { "Cookies", NO_ACTION, 0 },
- { "Cookies.Expand", TREE_EXPAND_ALL, 0 },
- { "Cookies.Expand.All", TREE_EXPAND_ALL, 0 },
- { "Cookies.Expand.Folders", TREE_EXPAND_FOLDERS, 0 },
- { "Cookies.Expand.Links", TREE_EXPAND_LINKS, 0 },
- { "Cookies.Collapse", TREE_COLLAPSE_ALL, 0 },
- { "Cookies.Collapse.All", TREE_COLLAPSE_ALL, 0 },
- { "Cookies.Collapse.Folders", TREE_COLLAPSE_FOLDERS, 0 },
- { "Cookies.Collapse.Links", TREE_COLLAPSE_LINKS, 0 },
- { "Cookies.Toolbars", NO_ACTION, 0 },
- { "_Cookies.Toolbars.ToolButtons", TOOLBAR_BUTTONS, 0 },
- { "Cookies.Toolbars.EditToolbar",TOOLBAR_EDIT, 0 },
- { "Selection", TREE_SELECTION, 0 },
- { "Selection.Delete", TREE_SELECTION_DELETE, 0 },
- { "SelectAll", TREE_SELECT_ALL, 0 },
- { "Clear", TREE_CLEAR_SELECTION, 0 },
- {NULL, 0, 0}
- }
- };
- cookies_window.menu = ro_gui_menu_define_menu(&cookies_definition);
-
- ro_gui_wimp_event_register_menu(cookies_window.window,
- cookies_window.menu, false, false);
- ro_gui_wimp_event_register_menu_prepare(cookies_window.window,
- ro_gui_cookies_menu_prepare);
- ro_gui_wimp_event_register_menu_selection(cookies_window.window,
- ro_gui_cookies_menu_select);
- ro_gui_wimp_event_register_menu_warning(cookies_window.window,
- ro_gui_cookies_menu_warning);
+ return NSERROR_OK;
}
+
/**
- * Destroy the cookies window.
+ * callback for keypress on ro cookie window
+ *
+ * \param ro_cw The ro core window structure.
+ * \param nskey The netsurf key code.
+ * \return NSERROR_OK if key processed,
+ * NSERROR_NOT_IMPLEMENTED if key not processed
+ * otherwise apropriate error code
*/
-
-void ro_gui_cookies_destroy(void)
+static nserror cookie_key(struct ro_corewindow *ro_cw, uint32_t nskey)
{
- if (cookies_window.tv == NULL)
- return;
-
- ro_treeview_destroy(cookies_window.tv);
+ if (cookie_manager_keypress(nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
}
+
/**
- * Open the cookies window.
+ * callback for mouse event on ro cookie window
*
+ * \param ro_cw The ro core window structure.
+ * \param mouse_state mouse state
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on sucess otherwise apropriate error code.
*/
-
-void ro_gui_cookies_open(void)
+static nserror
+cookie_mouse(struct ro_corewindow *ro_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
{
- ro_gui_cookies_toolbar_update_buttons();
+ cookie_manager_mouse_action(mouse_state, x, y);
- if (!ro_gui_dialog_open_top(cookies_window.window,
- cookies_window.toolbar, 600, 800)) {
- ro_treeview_set_origin(cookies_window.tv, 0,
- -(ro_toolbar_height(cookies_window.toolbar)));
- }
+ return NSERROR_OK;
}
/**
- * Handle toolbar button clicks.
+ * handle clicks in ro core window toolbar.
*
- * \param action The action to handle
+ * \param ro_cw The ro core window structure.
+ * \param action The button bar action.
+ * \return NSERROR_OK if config saved, otherwise apropriate error code
*/
-
-void ro_gui_cookies_toolbar_click(button_bar_action action)
+static nserror
+cookie_toolbar_click(struct ro_corewindow *ro_cw, button_bar_action action)
{
switch (action) {
case TOOLBAR_BUTTON_DELETE:
@@ -212,139 +155,178 @@ void ro_gui_cookies_toolbar_click(button_bar_action action)
default:
break;
}
+
+ return NSERROR_OK;
}
/**
- * Update the button state in the cookies toolbar.
+ * Handle updating state of buttons in ro core window toolbar.
+ *
+ * \param ro_cw The ro core window structure.
+ * \return NSERROR_OK if config saved, otherwise apropriate error code
*/
-
-void ro_gui_cookies_toolbar_update_buttons(void)
+static nserror cookie_toolbar_update(struct ro_corewindow *ro_cw)
{
- ro_toolbar_set_button_shaded_state(cookies_window.toolbar,
+ ro_toolbar_set_button_shaded_state(ro_cw->toolbar,
TOOLBAR_BUTTON_DELETE,
!cookie_manager_has_selection());
+ return NSERROR_OK;
}
/**
- * Save a new button arrangement in the cookies toolbar.
+ * callback for saving of toolbar state in ro cookie window
*
- * \param *config The new button configuration string.
+ * \param ro_cw The ro core window structure.
+ * \param config The new toolbar configuration.
+ * \return NSERROR_OK if config saved, otherwise apropriate error code
*/
-
-void ro_gui_cookies_toolbar_save_buttons(char *config)
+static nserror cookie_toolbar_save(struct ro_corewindow *ro_cw, char *config)
{
nsoption_set_charp(toolbar_cookies, config);
ro_gui_save_options();
+
+ return NSERROR_OK;
}
/**
- * Prepare the cookies menu for opening
+ * Prepare the cookie meu for display
*
- * \param w The window owning the menu.
- * \param i The icon owning the menu.
- * \param *menu The menu about to be opened.
- * \param *pointer Pointer to the relevant wimp event block, or
- * NULL for an Adjust click.
- * \return true if the event was handled; else false.
+ * \param w The window owning the menu.
+ * \param i The icon owning the menu.
+ * \param menu The menu from which the selection was made.
+ * \param pointer The pointer shape
+ * \return true if action accepted; else false.
*/
-
-bool ro_gui_cookies_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_pointer *pointer)
+static bool
+cookie_menu_prepare(wimp_w w,
+ wimp_i i,
+ wimp_menu *menu,
+ wimp_pointer *pointer)
{
bool selection;
+ struct ro_cookie_window *cookiew;
- if (menu != cookies_window.menu)
+ cookiew = (struct ro_cookie_window *)ro_gui_wimp_event_get_user_data(w);
+
+ if ((cookiew == NULL) ||
+ (menu != cookiew->menu)) {
return false;
+ }
selection = cookie_manager_has_selection();
- ro_gui_menu_set_entry_shaded(cookies_window.menu,
- TREE_SELECTION, !selection);
- ro_gui_menu_set_entry_shaded(cookies_window.menu,
- TREE_CLEAR_SELECTION, !selection);
+ ro_gui_menu_set_entry_shaded(menu, TREE_SELECTION, !selection);
+ ro_gui_menu_set_entry_shaded(menu, TREE_CLEAR_SELECTION, !selection);
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_BUTTONS,
- ro_toolbar_menu_option_shade(cookies_window.toolbar));
+ ro_toolbar_menu_option_shade(cookiew->core.toolbar));
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_BUTTONS,
- ro_toolbar_menu_buttons_tick(cookies_window.toolbar));
+ ro_toolbar_menu_buttons_tick(cookiew->core.toolbar));
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_EDIT,
- ro_toolbar_menu_edit_shade(cookies_window.toolbar));
+ ro_toolbar_menu_edit_shade(cookiew->core.toolbar));
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_EDIT,
- ro_toolbar_menu_edit_tick(cookies_window.toolbar));
+ ro_toolbar_menu_edit_tick(cookiew->core.toolbar));
return true;
}
+
/**
* Handle submenu warnings for the cookies menu
*
- * \param w The window owning the menu.
- * \param i The icon owning the menu.
- * \param *menu The menu to which the warning applies.
- * \param *selection The wimp menu selection data.
- * \param action The selected menu action.
+ * \param w The window owning the menu.
+ * \param i The icon owning the menu.
+ * \param menu The menu to which the warning applies.
+ * \param selection The wimp menu selection data.
+ * \param action The selected menu action.
*/
-
-void ro_gui_cookies_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_selection *selection, menu_action action)
+static void
+cookie_menu_warning(wimp_w w,
+ wimp_i i,
+ wimp_menu *menu,
+ wimp_selection *selection,
+ menu_action action)
{
/* Do nothing */
}
+
/**
* Handle selections from the cookies menu
*
- * \param w The window owning the menu.
- * \param i The icon owning the menu.
- * \param *menu The menu from which the selection was made.
- * \param *selection The wimp menu selection data.
- * \param action The selected menu action.
- * \return true if action accepted; else false.
+ * \param w The window owning the menu.
+ * \param i The icon owning the menu.
+ * \param menu The menu from which the selection was made.
+ * \param selection The wimp menu selection data.
+ * \param action The selected menu action.
+ * \return true if action accepted; else false.
*/
-
-bool ro_gui_cookies_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
- wimp_selection *selection, menu_action action)
+static bool
+cookie_menu_select(wimp_w w,
+ wimp_i i,
+ wimp_menu *menu,
+ wimp_selection *selection,
+ menu_action action)
{
+ struct ro_cookie_window *cookiew;
+
+ cookiew = (struct ro_cookie_window *)ro_gui_wimp_event_get_user_data(w);
+
+ if ((cookiew == NULL) ||
+ (menu != cookiew->menu)) {
+ return false;
+ }
+
switch (action) {
case TREE_EXPAND_ALL:
cookie_manager_expand(false);
return true;
+
case TREE_EXPAND_FOLDERS:
cookie_manager_expand(true);
return true;
+
case TREE_EXPAND_LINKS:
cookie_manager_expand(false);
return true;
+
case TREE_COLLAPSE_ALL:
cookie_manager_contract(true);
return true;
+
case TREE_COLLAPSE_FOLDERS:
cookie_manager_contract(true);
return true;
+
case TREE_COLLAPSE_LINKS:
cookie_manager_contract(false);
return true;
+
case TREE_SELECTION_DELETE:
cookie_manager_keypress(NS_KEY_DELETE_LEFT);
return true;
+
case TREE_SELECT_ALL:
cookie_manager_keypress(NS_KEY_SELECT_ALL);
return true;
+
case TREE_CLEAR_SELECTION:
cookie_manager_keypress(NS_KEY_CLEAR_SELECTION);
return true;
+
case TOOLBAR_BUTTONS:
- ro_toolbar_set_display_buttons(cookies_window.toolbar,
- !ro_toolbar_get_display_buttons(
- cookies_window.toolbar));
+ ro_toolbar_set_display_buttons(cookiew->core.toolbar,
+ !ro_toolbar_get_display_buttons(cookiew->core.toolbar));
return true;
+
case TOOLBAR_EDIT:
- ro_toolbar_toggle_edit(cookies_window.toolbar);
+ ro_toolbar_toggle_edit(cookiew->core.toolbar);
return true;
+
default:
return false;
}
@@ -352,33 +334,174 @@ bool ro_gui_cookies_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
return false;
}
+
/**
- * Check if a particular window handle is the cookies window
+ * Creates the window for the cookie tree.
*
- * \param window the window in question
- * \return true if this window is the cookies
+ * \return NSERROR_OK on success else appropriate error code on faliure.
*/
+static nserror ro_cookie_init(void)
+{
+ struct ro_cookie_window *ncwin;
+ nserror res;
+ static const struct ns_menu cookie_menu_def = {
+ "Cookies", {
+ { "Cookies", NO_ACTION, 0 },
+ { "Cookies.Expand", TREE_EXPAND_ALL, 0 },
+ { "Cookies.Expand.All", TREE_EXPAND_ALL, 0 },
+ { "Cookies.Expand.Folders", TREE_EXPAND_FOLDERS, 0 },
+ { "Cookies.Expand.Links", TREE_EXPAND_LINKS, 0 },
+ { "Cookies.Collapse", TREE_COLLAPSE_ALL, 0 },
+ { "Cookies.Collapse.All", TREE_COLLAPSE_ALL, 0 },
+ { "Cookies.Collapse.Folders", TREE_COLLAPSE_FOLDERS, 0 },
+ { "Cookies.Collapse.Links", TREE_COLLAPSE_LINKS, 0 },
+ { "Cookies.Toolbars", NO_ACTION, 0 },
+ { "_Cookies.Toolbars.ToolButtons", TOOLBAR_BUTTONS, 0 },
+ { "Cookies.Toolbars.EditToolbar",TOOLBAR_EDIT, 0 },
+ { "Selection", TREE_SELECTION, 0 },
+ { "Selection.Delete", TREE_SELECTION_DELETE, 0 },
+ { "SelectAll", TREE_SELECT_ALL, 0 },
+ { "Clear", TREE_CLEAR_SELECTION, 0 },
+ { NULL, 0, 0}
+ }
+ };
-bool ro_gui_cookies_check_window(wimp_w window)
+ static const struct button_bar_buttons cookies_toolbar_buttons[] = {
+ { "delete", TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_NONE, '0', "0"},
+ { "expand", TOOLBAR_BUTTON_EXPAND, TOOLBAR_BUTTON_COLLAPSE, '1', "1"},
+ { "open", TOOLBAR_BUTTON_OPEN, TOOLBAR_BUTTON_CLOSE, '2', "2"},
+ { NULL, TOOLBAR_BUTTON_NONE, TOOLBAR_BUTTON_NONE, '\0', ""}
+ };
+
+ if (cookie_window != NULL) {
+ return NSERROR_OK;
+ }
+
+ ncwin = malloc(sizeof(struct ro_cookie_window));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ /* create window from template */
+ ncwin->core.wh = wimp_create_window(dialog_cookie_template);
+
+ ro_gui_set_window_title(ncwin->core.wh, messages_get("Cookies"));
+
+ ncwin->core.draw = cookie_draw;
+ ncwin->core.key = cookie_key;
+ ncwin->core.mouse = cookie_mouse;
+ ncwin->core.toolbar_click = cookie_toolbar_click;
+ ncwin->core.toolbar_save = cookie_toolbar_save;
+ /* update is not valid untill cookie manager is initialised */
+ ncwin->core.toolbar_update = NULL;
+
+ /* initialise core window */
+ res = ro_corewindow_init(&ncwin->core,
+ cookies_toolbar_buttons,
+ nsoption_charp(toolbar_cookies),
+ THEME_STYLE_COOKIES_TOOLBAR,
+ "HelpCookiesToolbar");
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ res = cookie_manager_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ /* setup toolbar update post cookie manager initialisation */
+ ncwin->core.toolbar_update = cookie_toolbar_update;
+ cookie_toolbar_update(&ncwin->core);
+
+ /* Build the cookies window menu. */
+ ncwin->menu = ro_gui_menu_define_menu(&cookie_menu_def);
+
+ ro_gui_wimp_event_register_menu(ncwin->core.wh,
+ ncwin->menu, false, false);
+ ro_gui_wimp_event_register_menu_prepare(ncwin->core.wh,
+ cookie_menu_prepare);
+ ro_gui_wimp_event_register_menu_selection(ncwin->core.wh,
+ cookie_menu_select);
+ ro_gui_wimp_event_register_menu_warning(ncwin->core.wh,
+ cookie_menu_warning);
+
+ /* memoise window so it can be represented when necessary
+ * instead of recreating every time.
+ */
+ cookie_window = ncwin;
+
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in riscos/cookies.h */
+nserror ro_gui_cookies_present(void)
+{
+ nserror res;
+
+ res = ro_cookie_init();
+ if (res == NSERROR_OK) {
+ LOG("Presenting");
+ ro_gui_dialog_open_top(cookie_window->core.wh,
+ cookie_window->core.toolbar,
+ 600, 800);
+ } else {
+ LOG("Failed presenting code %d", res);
+ }
+
+ return res;
+}
+
+
+/* exported interface documented in riscos/cookies.h */
+void ro_gui_cookies_initialise(void)
+{
+ dialog_cookie_template = ro_gui_dialog_load_template("tree");
+}
+
+
+/* exported interface documented in riscos/cookies.h */
+nserror ro_gui_cookies_finalise(void)
+{
+ nserror res;
+
+ if (cookie_window == NULL) {
+ return NSERROR_OK;
+ }
+
+ res = cookie_manager_fini();
+ if (res == NSERROR_OK) {
+ res = ro_corewindow_fini(&cookie_window->core);
+
+ free(cookie_window);
+ cookie_window = NULL;
+ }
+
+ return res;
+}
+
+
+/* exported interface documented in riscos/cookies.h */
+bool ro_gui_cookies_check_window(wimp_w wh)
{
- if (cookies_window.window == window)
+ if ((cookie_window != NULL) &&
+ (cookie_window->core.wh == wh)) {
return true;
- else
- return false;
+ }
+ return false;
}
-/**
- * Check if a particular menu handle is the cookies menu
- *
- * \param *menu The menu in question.
- * \return true if this menu is the cookies menu
- */
+/* exported interface documented in riscos/cookies.h */
bool ro_gui_cookies_check_menu(wimp_menu *menu)
{
- if (cookies_window.menu == menu)
+ if ((cookie_window != NULL) &&
+ (cookie_window->menu == menu)) {
return true;
- else
- return false;
+ }
+ return false;
}
-
diff --git a/frontends/riscos/cookies.h b/frontends/riscos/cookies.h
index b7313393e..1b07d2122 100644
--- a/frontends/riscos/cookies.h
+++ b/frontends/riscos/cookies.h
@@ -17,22 +17,47 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Cookies (interface).
+/**
+ * \file
+ * Interface to riscos cookie viewing using riscos core window.
+ *
+ * The interface assumes there is only a single cookie window which is
+ * presented (shown) when asked for and hidden by usual toolkit
+ * mechanics.
+ *
+ * The destructor is called once during browser shutdown
*/
-#ifndef _NETSURF_RISCOS_COOKIES_H_
-#define _NETSURF_RISCOS_COOKIES_H_
+#ifndef NETSURF_RISCOS_COOKIES_H
+#define NETSURF_RISCOS_COOKIES_H
-#include "riscos/menus.h"
+/**
+ * initialise the cookies window template ready for subsequent use.
+ */
+void ro_gui_cookies_initialise(void);
-void ro_gui_cookies_preinitialise(void);
-void ro_gui_cookies_postinitialise(void);
-void ro_gui_cookies_destroy(void);
-bool ro_gui_cookies_check_window(wimp_w window);
-bool ro_gui_cookies_check_menu(wimp_menu *menu);
+/**
+ * make the cookie window visible.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+nserror ro_gui_cookies_present(void);
-void ro_gui_cookies_open(void);
+/**
+ * Free any resources allocated for the cookie window.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+nserror ro_gui_cookies_finalise(void);
-#endif
+/**
+ * check if window handle is for the cookies window
+ */
+bool ro_gui_cookies_check_window(wimp_w window);
+
+/**
+ * check if menu handle is for the cookies menu
+ */
+bool ro_gui_cookies_check_menu(wimp_menu *menu);
+#endif /* NETSURF_RISCOS_COOKIES_H */
diff --git a/frontends/riscos/dialog.c b/frontends/riscos/dialog.c
index 2b258bbca..e58a61dbe 100644
--- a/frontends/riscos/dialog.c
+++ b/frontends/riscos/dialog.c
@@ -190,7 +190,7 @@ void ro_gui_dialog_init(void)
ro_gui_global_history_preinitialise();
/* cookies window */
- ro_gui_cookies_preinitialise();
+ ro_gui_cookies_initialise();
}
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 7e508a8cf..f5126f8b4 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -1277,9 +1277,6 @@ static nserror gui_init(int argc, char** argv)
/* global history window */
ro_gui_global_history_postinitialise();
- /* cookies window */
- ro_gui_cookies_postinitialise();
-
open_window = nsoption_bool(open_browser_at_startup);
/* parse command-line arguments */
@@ -1569,7 +1566,7 @@ static void gui_quit(void)
ro_gui_window_quit();
ro_gui_global_history_destroy();
ro_gui_hotlist_destroy();
- ro_gui_cookies_destroy();
+ ro_gui_cookies_finalise();
ro_gui_saveas_quit();
ro_gui_url_bar_fini();
rufl_quit();
diff --git a/frontends/riscos/gui/button_bar.h b/frontends/riscos/gui/button_bar.h
index a1f7e8b9f..fb8ee790a 100644
--- a/frontends/riscos/gui/button_bar.h
+++ b/frontends/riscos/gui/button_bar.h
@@ -95,13 +95,6 @@ static const struct button_bar_buttons brower_toolbar_buttons[] = {
{NULL, TOOLBAR_BUTTON_NONE, TOOLBAR_BUTTON_NONE, '\0', ""}
};
-static const struct button_bar_buttons cookies_toolbar_buttons[] = {
- {"delete", TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_NONE, '0', "0"},
- {"expand", TOOLBAR_BUTTON_EXPAND, TOOLBAR_BUTTON_COLLAPSE, '1', "1"},
- {"open", TOOLBAR_BUTTON_OPEN, TOOLBAR_BUTTON_CLOSE, '2', "2"},
- {NULL, TOOLBAR_BUTTON_NONE, TOOLBAR_BUTTON_NONE, '\0', ""}
-};
-
static const struct button_bar_buttons global_history_toolbar_buttons[] = {
{"delete", TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_NONE, '0', "0"},
{"expand", TOOLBAR_BUTTON_EXPAND, TOOLBAR_BUTTON_COLLAPSE, '1', "1"},
diff --git a/frontends/riscos/gui/url_bar.h b/frontends/riscos/gui/url_bar.h
index 981afb35f..9486e214d 100644
--- a/frontends/riscos/gui/url_bar.h
+++ b/frontends/riscos/gui/url_bar.h
@@ -40,6 +40,7 @@ typedef enum {
struct url_bar;
struct hlcache_handle;
+struct gui_window;
/**
* Initialise the url bar module.
diff --git a/frontends/riscos/iconbar.c b/frontends/riscos/iconbar.c
index 8582a4539..146f23261 100644
--- a/frontends/riscos/iconbar.c
+++ b/frontends/riscos/iconbar.c
@@ -230,7 +230,7 @@ bool ro_gui_iconbar_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
ro_gui_global_history_open();
return true;
case COOKIES_SHOW:
- ro_gui_cookies_open();
+ ro_gui_cookies_present();
return true;
case CHOICES_SHOW:
ro_gui_configure_show();
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index 58cd86e49..488c3f591 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -2709,7 +2709,7 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
/* cookies actions */
case COOKIES_SHOW:
- ro_gui_cookies_open();
+ ro_gui_cookies_present();
break;
case COOKIES_DELETE: