summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/page-info.c21
-rw-r--r--desktop/page-info.h12
-rw-r--r--frontends/riscos/Makefile1
-rw-r--r--frontends/riscos/dialog.c4
-rw-r--r--frontends/riscos/gui.c2
-rw-r--r--frontends/riscos/pageinfo.c325
-rw-r--r--frontends/riscos/pageinfo.h48
-rw-r--r--frontends/riscos/templates/de26
-rw-r--r--frontends/riscos/templates/en26
-rw-r--r--frontends/riscos/templates/fr26
-rw-r--r--frontends/riscos/templates/nl26
-rw-r--r--frontends/riscos/window.c5
12 files changed, 518 insertions, 4 deletions
diff --git a/desktop/page-info.c b/desktop/page-info.c
index 49b11a1dd..d698c2b0b 100644
--- a/desktop/page-info.c
+++ b/desktop/page-info.c
@@ -571,13 +571,30 @@ nserror page_info_create(
}
/* Exported interface documented in desktop/page_info.h */
-void page_info_destroy(
- struct page_info *pi)
+nserror page_info_destroy(struct page_info *pi)
{
if (pi->domain != NULL) {
lwc_string_unref(pi->domain);
}
free(pi);
+ return NSERROR_OK;
+}
+
+/* Exported interface documented in desktop/page_info.h */
+nserror page_info_set(struct page_info *pgi, struct browser_window *bw)
+{
+ nserror res;
+
+ if (pgi->domain != NULL) {
+ lwc_string_unref(pgi->domain);
+ }
+
+ res = page_info__create_from_bw(pgi, bw);
+ if (res == NSERROR_OK) {
+ res = page_info__layout(pgi);
+ }
+
+ return res;
}
/**
diff --git a/desktop/page-info.h b/desktop/page-info.h
index 4504e578b..152a88496 100644
--- a/desktop/page-info.h
+++ b/desktop/page-info.h
@@ -76,8 +76,16 @@ nserror page_info_create(
*
* \param[in] pi The page info window handle.
*/
-void page_info_destroy(
- struct page_info *pi);
+nserror page_info_destroy(struct page_info *pi);
+
+/**
+ * change the browser window the page information refers to
+ *
+ * \param[in] pgi The page info window context
+ * \param[in] bw The new browser window
+ * \return NSERROR_OK on sucess else error code.
+ */
+nserror page_info_set(struct page_info *pgi, struct browser_window *bw);
/**
* Redraw the page info window.
diff --git a/frontends/riscos/Makefile b/frontends/riscos/Makefile
index 5192ac739..c028ed789 100644
--- a/frontends/riscos/Makefile
+++ b/frontends/riscos/Makefile
@@ -67,6 +67,7 @@ S_FRONTEND := \
menus.c \
message.c \
mouse.c \
+ pageinfo.c \
palettes.c \
plotters.c \
print.c \
diff --git a/frontends/riscos/dialog.c b/frontends/riscos/dialog.c
index df5770c34..3b5f0bc95 100644
--- a/frontends/riscos/dialog.c
+++ b/frontends/riscos/dialog.c
@@ -49,6 +49,7 @@
#include "riscos/gui.h"
#include "riscos/window.h"
#include "riscos/hotlist.h"
+#include "riscos/pageinfo.h"
#include "riscos/menus.h"
#include "riscos/save.h"
#include "riscos/toolbar.h"
@@ -188,6 +189,9 @@ void ro_gui_dialog_init(void)
/* cookies window */
ro_gui_cookies_initialise();
+
+ /* page info window */
+ ro_gui_pageinfo_initialise();
}
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 458f49108..52081b218 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -76,6 +76,7 @@
#include "riscos/local_history.h"
#include "riscos/global_history.h"
#include "riscos/cookies.h"
+#include "riscos/pageinfo.h"
#include "riscos/wimp_event.h"
#include "riscos/uri.h"
#include "riscos/url_protocol.h"
@@ -1592,6 +1593,7 @@ static void gui_quit(void)
ro_gui_window_quit();
ro_gui_local_history_finalise();
ro_gui_global_history_finalise();
+ ro_gui_pageinfo_finalise();
ro_gui_hotlist_finalise();
ro_gui_cookies_finalise();
ro_gui_saveas_quit();
diff --git a/frontends/riscos/pageinfo.c b/frontends/riscos/pageinfo.c
new file mode 100644
index 000000000..7ce09591b
--- /dev/null
+++ b/frontends/riscos/pageinfo.c
@@ -0,0 +1,325 @@
+/*
+ * Copyright 2020 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/>.
+ */
+
+/**
+ * \file
+ * Implementation of RISC OS page info core window.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <oslib/wimp.h>
+
+#include "utils/log.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
+#include "desktop/page-info.h"
+
+#include "riscos/gui.h"
+#include "riscos/dialog.h"
+#include "riscos/toolbar.h"
+#include "riscos/wimputils.h"
+#include "riscos/corewindow.h"
+#include "riscos/pageinfo.h"
+
+
+/**
+ * Page info window container for RISC OS.
+ */
+struct ro_pageinfo_window {
+ struct ro_corewindow core;
+ /** Core page-info window */
+ struct page_info *pgi;
+};
+
+/** page info window is a singleton */
+static struct ro_pageinfo_window *pageinfo_window = NULL;
+
+/** riscos template for pageinfo window */
+static wimp_window *dialog_pageinfo_template;
+
+/**
+ * callback to draw on drawable area of ro page info 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
+ */
+static nserror
+ro_pageinfo_draw(struct ro_corewindow *ro_cw,
+ int originx,
+ int originy,
+ struct rect *r)
+{
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &ro_plotters
+ };
+ struct ro_pageinfo_window *lhw;
+
+ lhw = (struct ro_pageinfo_window *)ro_cw;
+
+ ro_plot_origin_x = originx;
+ ro_plot_origin_y = originy;
+ no_font_blending = true;
+ page_info_redraw(lhw->pgi, 0, 0, r, &ctx);
+ no_font_blending = false;
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * callback for keypress on ro coookie 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
+ */
+static nserror
+ro_pageinfo_key(struct ro_corewindow *ro_cw, uint32_t nskey)
+{
+ struct ro_pageinfo_window *lhw;
+
+ lhw = (struct ro_pageinfo_window *)ro_cw;
+
+ if (page_info_keypress(lhw->pgi, nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
+}
+
+
+/**
+ * callback for mouse event on ro page info 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.
+ */
+static nserror
+ro_pageinfo_mouse(struct ro_corewindow *ro_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
+{
+ struct ro_pageinfo_window *pgiw;
+
+ pgiw = (struct ro_pageinfo_window *)ro_cw;
+ bool did_something = false;
+
+ if (page_info_mouse_action(pgiw->pgi, mouse_state, x, y, &did_something) == NSERROR_OK) {
+ if (did_something == true) {
+ /* Something happened so we need to close ourselves */
+ ro_gui_dialog_close(ro_cw->wh);
+ }
+ }
+
+ if ((mouse_state & BROWSER_MOUSE_LEAVE) != 0) {
+ ro_gui_dialog_close(ro_cw->wh);
+ }
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * Creates the window for the page info tree.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+static nserror
+ro_pageinfo_init(struct browser_window *bw,
+ struct ro_pageinfo_window **win_out)
+{
+ os_error *error;
+ struct ro_pageinfo_window *ncwin;
+ nserror res;
+
+ /* memoise window so it can be represented when necessary
+ * instead of recreating every time.
+ */
+ if ((*win_out) != NULL) {
+ res = page_info_set((*win_out)->pgi, bw);
+ return res;
+ }
+
+ ncwin = calloc(1, sizeof(*ncwin));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ /* create window from template */
+ error = xwimp_create_window(dialog_pageinfo_template,
+ &ncwin->core.wh);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ free(ncwin);
+ return NSERROR_NOMEM;
+ }
+
+ /* initialise callbacks */
+ ncwin->core.draw = ro_pageinfo_draw;
+ ncwin->core.key = ro_pageinfo_key;
+ ncwin->core.mouse = ro_pageinfo_mouse;
+
+ /* initialise core window */
+ res = ro_corewindow_init(&ncwin->core,
+ NULL,
+ NULL,
+ 0,
+ NULL);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ res = page_info_create(ncwin->core.cb_table,
+ (struct core_window *)ncwin,
+ bw,
+ &ncwin->pgi);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ *win_out = ncwin;
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * open RISC OS page info window at the correct size
+ */
+static nserror
+ro_pageinfo_open(struct ro_pageinfo_window *lhw, wimp_w parent)
+{
+ nserror res;
+ int width, height;
+ os_box box = {0, 0, 0, 0};
+ wimp_window_state state;
+ os_error *error;
+
+ res = page_info_get_size(lhw->pgi, &width, &height);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ width *= 2;
+ height *= 2;
+
+ /* set extent */
+ box.x1 = width;
+ box.y0 = -height;
+ error = xwimp_set_extent(lhw->core.wh, &box);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_set_extent: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+
+ /* open full size */
+ state.w = lhw->core.wh;
+ error = xwimp_get_window_state(&state);
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+ state.visible.x0 = 0;
+ state.visible.y0 = 0;
+ state.visible.x1 = width;
+ state.visible.y1 = height;
+ state.next = wimp_HIDDEN;
+ error = xwimp_open_window(PTR_WIMP_OPEN(&state));
+ if (error) {
+ NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess);
+ ro_warn_user("WimpError", error->errmess);
+ return NSERROR_NOMEM;
+ }
+
+ ro_gui_dialog_open_persistent(parent, lhw->core.wh, true);
+
+ /* Give the window focus. */
+ error = xwimp_set_caret_position(lhw->core.wh, -1, 0, 0, -1, 0);
+ if (error) {
+ NSLOG(netsurf, INFO,
+ "xwimp_set_caret_position: 0x%x : %s",
+ error->errnum,
+ error->errmess);
+ }
+
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in riscos/pageinfo.h */
+nserror ro_gui_pageinfo_initialise(void)
+{
+ dialog_pageinfo_template = ro_gui_dialog_load_template("corepginfo");
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in riscos/pageinfo.h */
+nserror ro_gui_pageinfo_present(struct gui_window *gw)
+{
+ nserror res;
+
+ res = ro_pageinfo_init(gw->bw, &pageinfo_window);
+ if (res == NSERROR_OK) {
+ NSLOG(netsurf, INFO, "Presenting");
+ res = ro_pageinfo_open(pageinfo_window, gw->window);
+ } else {
+ NSLOG(netsurf, INFO, "Failed presenting error code %d", res);
+ }
+
+ return res;
+}
+
+/* exported interface documented in riscos/pageinfo.h */
+nserror ro_gui_pageinfo_finalise(void)
+{
+ nserror res;
+
+ if (pageinfo_window == NULL) {
+ return NSERROR_OK;
+ }
+
+ res = page_info_destroy(pageinfo_window->pgi);
+ if (res == NSERROR_OK) {
+ res = ro_corewindow_fini(&pageinfo_window->core);
+
+ free(pageinfo_window);
+ pageinfo_window = NULL;
+ }
+
+ return res;
+}
diff --git a/frontends/riscos/pageinfo.h b/frontends/riscos/pageinfo.h
new file mode 100644
index 000000000..e5581c27e
--- /dev/null
+++ b/frontends/riscos/pageinfo.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2020 Vincent Sanders <vince@nesurf-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/>.
+ */
+
+/**
+ * \file
+ * Interface to page info core window for RISC OS
+ */
+
+#ifndef NETSURF_RISCOS_PAGEINFO_H_
+#define NETSURF_RISCOS_PAGEINFO_H_
+
+struct gui_window;
+
+/**
+ * initialise the pageinfo window template ready for subsequent use.
+ */
+nserror ro_gui_pageinfo_initialise(void);
+
+/**
+ * make the pageinfo window visible.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+nserror ro_gui_pageinfo_present(struct gui_window *gw);
+
+/**
+ * Free any resources allocated for the page info window.
+ *
+ * \return NSERROR_OK on success else appropriate error code on faliure.
+ */
+nserror ro_gui_pageinfo_finalise(void);
+
+#endif
diff --git a/frontends/riscos/templates/de b/frontends/riscos/templates/de
index 954853cba..19a23e330 100644
--- a/frontends/riscos/templates/de
+++ b/frontends/riscos/templates/de
@@ -1241,6 +1241,32 @@ wimp_window {
}
wimp_window {
+ template_name:"corepginfo"
+ visible:252,388,1152,808
+ xscroll:0
+ yscroll:0
+ next:wimp_TOP
+ window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_NEW_FORMAT
+ title_fg:wimp_COLOUR_BLACK
+ title_bg:wimp_COLOUR_LIGHT_GREY
+ work_fg:wimp_COLOUR_BLACK
+ work_bg:wimp_COLOUR_WHITE
+ scroll_outer:wimp_COLOUR_MID_LIGHT_GREY
+ scroll_inner:wimp_COLOUR_VERY_LIGHT_GREY
+ highlight_bg:wimp_COLOUR_CREAM
+ extra_flags:
+ extent:0,-880,1236,0
+ title_flags:wimp_ICON_TEXT | wimp_ICON_BORDER | wimp_ICON_HCENTRED | wimp_ICON_VCENTRED | wimp_ICON_FILLED | wimp_ICON_INDIRECTED | 0x27000000
+ work_flags:wimp_BUTTON_CLICK
+ sprite_area:&1
+ xmin:0
+ ymin:0
+ text.text:"Page Info"
+ text.size:*
+ text.validation:""
+}
+
+wimp_window {
template_name:"info"
visible:268,838,888,1086
xscroll:0
diff --git a/frontends/riscos/templates/en b/frontends/riscos/templates/en
index e17827959..d5259d922 100644
--- a/frontends/riscos/templates/en
+++ b/frontends/riscos/templates/en
@@ -1451,6 +1451,32 @@ wimp_window {
}
wimp_window {
+ template_name:"corepginfo"
+ visible:252,388,1152,808
+ xscroll:0
+ yscroll:0
+ next:wimp_TOP
+ window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_NEW_FORMAT
+ title_fg:wimp_COLOUR_BLACK
+ title_bg:wimp_COLOUR_LIGHT_GREY
+ work_fg:wimp_COLOUR_BLACK
+ work_bg:wimp_COLOUR_WHITE
+ scroll_outer:wimp_COLOUR_MID_LIGHT_GREY
+ scroll_inner:wimp_COLOUR_VERY_LIGHT_GREY
+ highlight_bg:wimp_COLOUR_CREAM
+ extra_flags:
+ extent:0,-880,1236,0
+ title_flags:wimp_ICON_TEXT | wimp_ICON_BORDER | wimp_ICON_HCENTRED | wimp_ICON_VCENTRED | wimp_ICON_FILLED | wimp_ICON_INDIRECTED | 0x27000000
+ work_flags:wimp_BUTTON_CLICK
+ sprite_area:&1
+ xmin:0
+ ymin:0
+ text.text:"Page Info"
+ text.size:*
+ text.validation:""
+}
+
+wimp_window {
template_name:"info"
visible:752,452,1372,700
xscroll:0
diff --git a/frontends/riscos/templates/fr b/frontends/riscos/templates/fr
index 22a577d10..76a4611bf 100644
--- a/frontends/riscos/templates/fr
+++ b/frontends/riscos/templates/fr
@@ -1241,6 +1241,32 @@ wimp_window {
}
wimp_window {
+ template_name:"corepginfo"
+ visible:252,388,1152,808
+ xscroll:0
+ yscroll:0
+ next:wimp_TOP
+ window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_NEW_FORMAT
+ title_fg:wimp_COLOUR_BLACK
+ title_bg:wimp_COLOUR_LIGHT_GREY
+ work_fg:wimp_COLOUR_BLACK
+ work_bg:wimp_COLOUR_WHITE
+ scroll_outer:wimp_COLOUR_MID_LIGHT_GREY
+ scroll_inner:wimp_COLOUR_VERY_LIGHT_GREY
+ highlight_bg:wimp_COLOUR_CREAM
+ extra_flags:
+ extent:0,-880,1236,0
+ title_flags:wimp_ICON_TEXT | wimp_ICON_BORDER | wimp_ICON_HCENTRED | wimp_ICON_VCENTRED | wimp_ICON_FILLED | wimp_ICON_INDIRECTED | 0x27000000
+ work_flags:wimp_BUTTON_CLICK
+ sprite_area:&1
+ xmin:0
+ ymin:0
+ text.text:"Page Info"
+ text.size:*
+ text.validation:""
+}
+
+wimp_window {
template_name:"info"
visible:506,58,1126,306
xscroll:0
diff --git a/frontends/riscos/templates/nl b/frontends/riscos/templates/nl
index 0fa95b5ff..01188b097 100644
--- a/frontends/riscos/templates/nl
+++ b/frontends/riscos/templates/nl
@@ -1455,6 +1455,32 @@ wimp_window {
}
wimp_window {
+ template_name:"corepginfo"
+ visible:252,388,1152,808
+ xscroll:0
+ yscroll:0
+ next:wimp_TOP
+ window_flags:wimp_WINDOW_MOVEABLE | wimp_WINDOW_SCROLL_REPEAT | wimp_WINDOW_NEW_FORMAT
+ title_fg:wimp_COLOUR_BLACK
+ title_bg:wimp_COLOUR_LIGHT_GREY
+ work_fg:wimp_COLOUR_BLACK
+ work_bg:wimp_COLOUR_WHITE
+ scroll_outer:wimp_COLOUR_MID_LIGHT_GREY
+ scroll_inner:wimp_COLOUR_VERY_LIGHT_GREY
+ highlight_bg:wimp_COLOUR_CREAM
+ extra_flags:
+ extent:0,-880,1236,0
+ title_flags:wimp_ICON_TEXT | wimp_ICON_BORDER | wimp_ICON_HCENTRED | wimp_ICON_VCENTRED | wimp_ICON_FILLED | wimp_ICON_INDIRECTED | 0x27000000
+ work_flags:wimp_BUTTON_CLICK
+ sprite_area:&1
+ xmin:0
+ ymin:0
+ text.text:"Page Info"
+ text.size:*
+ text.validation:""
+}
+
+wimp_window {
template_name:"info"
visible:752,332,1412,700
xscroll:0
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index fcb6b08f2..d3bd52945 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -71,6 +71,7 @@
#include "riscos/dialog.h"
#include "riscos/local_history.h"
#include "riscos/global_history.h"
+#include "riscos/pageinfo.h"
#include "riscos/gui.h"
#include "riscos/gui/status_bar.h"
#include "riscos/help.h"
@@ -866,6 +867,10 @@ ro_gui_window_toolbar_click(void *data,
ro_gui_window_action_remove_bookmark(g);
break;
+ case TOOLBAR_URL_SELECT_PGINFO:
+ case TOOLBAR_URL_ADJUST_PGINFO:
+ ro_gui_pageinfo_present(g);
+
default:
break;
}