From 244c49df26ba943dc7cef60413126fbaf52a4428 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 22 May 2020 18:52:29 +0100 Subject: [PATCH] Amiga: Add page info window Currently untested but builds OK --- frontends/amiga/Makefile | 2 +- frontends/amiga/gui.c | 11 +- frontends/amiga/pageinfo.c | 282 +++++++++++++++++++++++++++++++++++++ frontends/amiga/pageinfo.h | 31 ++++ resources/FatMessages | 19 +-- 5 files changed, 333 insertions(+), 12 deletions(-) create mode 100644 frontends/amiga/pageinfo.c create mode 100644 frontends/amiga/pageinfo.h diff --git a/frontends/amiga/Makefile b/frontends/amiga/Makefile index 17af11efa..99745c90e 100644 --- a/frontends/amiga/Makefile +++ b/frontends/amiga/Makefile @@ -53,7 +53,7 @@ S_FRONTEND := gui.c history.c hotlist.c schedule.c file.c \ stringview/stringview.c stringview/urlhistory.c rtg.c \ agclass/amigaguide_class.c os3support.c font_diskfont.c \ selectmenu.c hash/xxhash.c font_cache.c font_bullet.c \ - nsoption.c corewindow.c gui_menu.c + nsoption.c corewindow.c gui_menu.c pageinfo.c # This is the final source build list # Note this is deliberately *not* expanded here as common and image diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index bb7478c8e..1dde68727 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -1,5 +1,5 @@ /* - * Copyright 2008-2019 Chris Young + * Copyright 2008-2020 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -152,6 +152,7 @@ #include "amiga/menu.h" #include "amiga/misc.h" #include "amiga/nsoption.h" +#include "amiga/pageinfo.h" #include "amiga/plotters.h" #include "amiga/plugin_hack.h" #include "amiga/print.h" @@ -2998,6 +2999,12 @@ static BOOL ami_gui_event(void *w) ami_gui_history(gwin, false); break; + case GID_PAGEINFO: + if(ami_pageinfo_open(gwin->gw->bw) != NSERROR_OK) { + NSLOG(netsurf, INFO, "Unable to open page info window"); + } + break; + case GID_FAVE: GetAttr(STRINGA_TextVal, (Object *)gwin->objects[GID_URL], @@ -5019,7 +5026,7 @@ gui_window_create(struct browser_window *bw, LAYOUT_AddChild, g->shared->objects[GID_PAGEINFO] = ButtonObj, GA_ID, GID_PAGEINFO, GA_RelVerify, TRUE, - GA_ReadOnly, TRUE, + GA_ReadOnly, FALSE, BUTTON_RenderImage, g->shared->objects[GID_PAGEINFO_INTERNAL_BM], ButtonEnd, CHILD_WeightedWidth, 0, diff --git a/frontends/amiga/pageinfo.c b/frontends/amiga/pageinfo.c new file mode 100644 index 000000000..9a2b04910 --- /dev/null +++ b/frontends/amiga/pageinfo.c @@ -0,0 +1,282 @@ +/* + * Copyright 2020 Chris Young + * + * 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 . + */ + +/** + * \file + * Amiga implementation of page info using core windows. + */ + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "utils/log.h" +#include "netsurf/keypress.h" +#include "netsurf/plotters.h" +#include "desktop/page-info.h" +#include "utils/messages.h" +#include "utils/nsoption.h" + +#include "amiga/corewindow.h" +#include "amiga/libs.h" +#include "amiga/pageinfo.h" +#include "amiga/schedule.h" +#include "amiga/utf8.h" + + +/** + * Amiga page info window context + */ +struct ami_pageinfo_window { + /** Amiga core window context */ + struct ami_corewindow core; + /** core pageinfo */ + struct page_info *pi; +}; + +/** + * destroy a previously created pageinfo window + */ +static void +ami_pageinfo_destroy(struct ami_corewindow *ami_cw) +{ + nserror res; + struct ami_pageinfo_window *pageinfo_win = (struct ami_pageinfo_window *)ami_cw; + res = page_info_destroy(pageinfo_win->pi); + if (res == NSERROR_OK) { + ami_corewindow_fini(&pageinfo_win->core); /* closes the window for us */ + } +} + +/** + * close pageinfo window (callback) + */ +static void +ami_pageinfo_close_cb(void *p) +{ + ami_pageinfo_destroy((struct ami_corewindow *)p); +} + +/** + * callback for unknown events on Amiga core window + * (result & WMHI_CLASSMASK) gives the class of event (eg. WMHI_GADGETUP) + * (result & WMHI_GADGETMASK) gives the gadget ID (eg. GID_SSLCERT_ACCEPT) + * + * \param ami_cw The Amiga core window structure. + * \param result event as returned by RA_HandleInput() + * \return TRUE if window closed during event processing + */ +static BOOL +ami_pageinfo_event(struct ami_corewindow *ami_cw, ULONG result) +{ + /* we don't have any events on this window yet */ + return FALSE; +} + +/** + * callback for mouse action for pageinfo on core window + * + * \param ami_cw The Amiga core window structure. + * \param mouse_state netsurf mouse state on event + * \param x location of event + * \param y location of event + * \return NSERROR_OK on success otherwise apropriate error code + */ +static nserror +ami_pageinfo_mouse(struct ami_corewindow *ami_cw, + browser_mouse_state mouse_state, + int x, int y) +{ + bool did_something = false; + struct ami_pageinfo_window *pageinfo_win = (struct ami_pageinfo_window *)ami_cw; + + if(page_info_mouse_action(pageinfo_win->pi, mouse_state, x, y, &did_something) == NSERROR_OK) + if (did_something == true) { + /* Something happened so we need to close ourselves */ + ami_schedule(0, ami_pageinfo_close_cb, pageinfo_win); + } + + return NSERROR_OK; +} + +/** + * callback for keypress for pageinfo on core window + * + * \param ami_cw The Amiga core window structure. + * \param nskey The netsurf key code + * \return NSERROR_OK on success otherwise apropriate error code + */ +static nserror +ami_pageinfo_key(struct ami_corewindow *ami_cw, uint32_t nskey) +{ + struct ami_pageinfo_window *pageinfo_win = (struct ami_pageinfo_window *)ami_cw; + + if (page_info_keypress(pageinfo_win->pi, nskey)) { + return NSERROR_OK; + } + return NSERROR_NOT_IMPLEMENTED; +} + +/** + * callback on draw event for pageinfo on core window + * + * \param ami_cw The Amiga core window structure. + * \param x the x coordinate to draw + * \param y the y coordinate to draw + * \param r The rectangle of the window that needs updating. + * \param ctx The drawing context + * \return NSERROR_OK on success otherwise apropriate error code + */ +static nserror +ami_pageinfo_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx) +{ + struct ami_pageinfo_window *pageinfo_win = (struct ami_pageinfo_window *)ami_cw; + + page_info_redraw(pageinfo_win->pi, x, y, r, ctx); + + return NSERROR_OK; +} + +static nserror +ami_pageinfo_create_window(struct ami_pageinfo_window *pageinfo_win) +{ + struct ami_corewindow *ami_cw = (struct ami_corewindow *)&pageinfo_win->core; + ULONG refresh_mode = WA_SmartRefresh; + struct Screen *scrn = ami_gui_get_screen(); + + if(nsoption_bool(window_simple_refresh) == true) { + refresh_mode = WA_SimpleRefresh; + } + + ami_cw->objects[GID_CW_WIN] = WindowObj, + WA_ScreenTitle, ami_gui_get_screen_title(), + WA_Title, ami_cw->wintitle, + WA_Activate, TRUE, + WA_DepthGadget, TRUE, + WA_DragBar, TRUE, + WA_CloseGadget, FALSE, + WA_SizeGadget, TRUE, + WA_SizeBBottom, TRUE, + WA_Height, scrn->Height / 2, + WA_PubScreen, scrn, + WA_ReportMouse, TRUE, + refresh_mode, TRUE, + WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | + IDCMP_RAWKEY | IDCMP_IDCMPUPDATE | + IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW, + WINDOW_IDCMPHook, &ami_cw->idcmp_hook, + WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE | + IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW, + WINDOW_SharedPort, ami_gui_get_shared_msgport(), + WINDOW_UserData, pageinfo_win, + WINDOW_IconifyGadget, FALSE, + WINDOW_Position, WPOS_CENTERSCREEN, + WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj, + LAYOUT_AddChild, ami_cw->objects[GID_CW_HSCROLLLAYOUT] = LayoutVObj, + LAYOUT_AddChild, ami_cw->objects[GID_CW_VSCROLLLAYOUT] = LayoutHObj, + LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj, + GA_ID, GID_CW_DRAW, + SPACE_Transparent, TRUE, + SPACE_BevelStyle, BVS_DISPLAY, + GA_RelVerify, TRUE, + SpaceEnd, + LAYOUT_AddChild, ami_cw->objects[GID_CW_VSCROLL] = ScrollerObj, + GA_ID, GID_CW_VSCROLL, + GA_RelVerify, TRUE, + ICA_TARGET, ICTARGET_IDCMP, + ScrollerEnd, + LayoutEnd, + LAYOUT_AddChild, ami_cw->objects[GID_CW_HSCROLL] = ScrollerObj, + GA_ID, GID_CW_HSCROLL, + GA_RelVerify, TRUE, + ICA_TARGET, ICTARGET_IDCMP, + SCROLLER_Orientation, SORIENT_HORIZ, + ScrollerEnd, + LayoutEnd, + CHILD_WeightedHeight, 0, + EndGroup, + EndWindow; + + if(ami_cw->objects[GID_CW_WIN] == NULL) { + return NSERROR_NOMEM; + } + + return NSERROR_OK; +} + +/* exported interface documented in amiga/pageinfo.h */ +nserror ami_pageinfo_open(struct browser_window *bw) +{ + struct ami_pageinfo_window *ncwin; + nserror res; + + ncwin = calloc(1, sizeof(struct ami_pageinfo_window)); + if (ncwin == NULL) { + return NSERROR_NOMEM; + } + + ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("PageInfo")); + + res = ami_pageinfo_create_window(ncwin); + if (res != NSERROR_OK) { + NSLOG(netsurf, INFO, "Page info init failed"); + ami_utf8_free(ncwin->core.wintitle); + free(ncwin); + return res; + } + + /* initialise Amiga core window */ + ncwin->core.draw = ami_pageinfo_draw; + ncwin->core.key = ami_pageinfo_key; + ncwin->core.mouse = ami_pageinfo_mouse; + ncwin->core.close = ami_pageinfo_destroy; + ncwin->core.event = ami_pageinfo_event; + + res = ami_corewindow_init(&ncwin->core); + if (res != NSERROR_OK) { + ami_utf8_free(ncwin->core.wintitle); + DisposeObject(ncwin->core.objects[GID_CW_WIN]); + free(ncwin); + return res; + } + + res = page_info_create(ncwin->core.cb_table, + (struct core_window *)ncwin, + bw, + &ncwin->pi); + + if (res != NSERROR_OK) { + ami_utf8_free(ncwin->core.wintitle); + DisposeObject(ncwin->core.objects[GID_CW_WIN]); + free(ncwin); + return res; + } + + return NSERROR_OK; +} + diff --git a/frontends/amiga/pageinfo.h b/frontends/amiga/pageinfo.h new file mode 100644 index 000000000..7737b258e --- /dev/null +++ b/frontends/amiga/pageinfo.h @@ -0,0 +1,31 @@ +/* + * Copyright 2020 Chris Young + * + * 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 . + */ + +#ifndef AMIGA_PAGEINFO_H +#define AMIGA_PAGEINFO_H + +/** + * Open the page info window + * + * \param bw the browser window + * \return NSERROR_OK or error code if window creation failed. + */ +nserror ami_pageinfo_open(struct browser_window *bw); + +#endif + diff --git a/resources/FatMessages b/resources/FatMessages index cbbead236..a6e21b832 100644 --- a/resources/FatMessages +++ b/resources/FatMessages @@ -1888,7 +1888,7 @@ it.beos.ViewSrcAccel:U # en.ro.Draw:Draw ⇑^F3 fr.ro.Draw:Dessiner ⇑^F3 -it.ro.Draw:Draw ^F3 +it.ro.Draw:Draw �^F3 nl.ro.Draw:Draw-bestand ⇑^F3 en.all.PDF:PDF @@ -1991,21 +1991,21 @@ fr.all.Back:Retour it.all.Back:Indietro nl.all.Back:Vorige pagina en.beos.BackAccel:← -it.beos.BackAccel: +it.beos.BackAccel:� en.all.Forward:Forward one page de.all.Forward:Eine Seite vor fr.all.Forward:Avancer it.all.Forward:Avanti nl.all.Forward:Volgende pagina en.beos.ForwardAccel:→ -it.beos.ForwardAccel: +it.beos.ForwardAccel:� en.all.UpLevel:Up one level de.all.UpLevel:Eine Ebene hoch fr.all.UpLevel:Remonter d'un niveau it.all.UpLevel:Livello superiore nl.all.UpLevel:Niveau omhoog en.beos.UpLevelAccel:↑ -it.beos.UpLevelAccel: +it.beos.UpLevelAccel:� en.ro.Reload:Reload this page ^F5 de.ro.Reload:Seite erneut laden ^F5 fr.ro.Reload:Recharger cette page ^F5 @@ -2749,17 +2749,17 @@ nl.all.ExternalApp:Open in ander programma en.all.Download:%s of %s • %s/s • %s remaining de.all.Download:%s von %s • %s/s • noch %s fr.all.Download:%s de %s • %s/s • %s restants -it.all.Download:%s di %s %s/s %s al termine +it.all.Download:%s di %s � %s/s � %s al termine nl.all.Download:%s van %s • %s/s • nog %s en.all.DownloadU:%s of unknown • %s/s • %s total de.all.DownloadU:%s von unbekannt • %s/s • bisher %s fr.all.DownloadU:%s sur inconnu • %s/s • %s total -it.all.DownloadU:%s sconosciuto %s/s %s totale +it.all.DownloadU:%s sconosciuto � %s/s � %s totale nl.all.DownloadU:%s van onbekend • %s/s • %s totaal en.all.Downloaded:%s complete • average %s/s • %s total de.all.Downloaded:%s komplett • etwa %s/s • gesamt %s fr.all.Downloaded:%s effectués • moyenne %s/s • %s total -it.all.Downloaded:%s completato average %s/s %s totale +it.all.Downloaded:%s completato � average %s/s � %s totale nl.all.Downloaded:%s compleet • gemiddeld %s/s • %s totaal en.all.Unwritten:Writing data to file failed. de.all.Unwritten:Schreiben der Datei ist fehlgeschlagen. @@ -5829,7 +5829,7 @@ nl.ro.HelpLanguageConfig:Diverse taalinstellingen kunnen in dit venster gewijzig en.ro.HelpLanguageConfig3:\Tcurrently selected interface language.|MThe interface language is the language used for NetSurf's messages and dialogue boxes. de.ro.HelpLanguageConfig3:Das ist die aktuell eingestellte Sprache für die Bedienoberfläche.|MDiese Sprache wird genutzt, um NetSurf's Meldungen, Texte der Dialogboxen, Menüs darzustellen. fr.ro.HelpLanguageConfig3:\Tla langue d'interface sélectionnée actuellement.|MLa langue d'interface est la langue utilisée pour les messages et les boîtes de dialogue de Netsurf. -it.ro.HelpLanguageConfig3:\Tla lingua dell'interfaccia correntemente selezionata.|MLa lingua dell'interfaccia la lingua utilizzata per i messaggi e le finestre di dialogo di NetSurf. +it.ro.HelpLanguageConfig3:\Tla lingua dell'interfaccia correntemente selezionata.|MLa lingua dell'interfaccia � la lingua utilizzata per i messaggi e le finestre di dialogo di NetSurf. nl.ro.HelpLanguageConfig3:Dit is momenteel de geselecteerde gebruikersinterfacetaal.|MDe interfacetaal is de taal voor de melding- en dialoogvensters. en.ro.HelpLanguageConfig4:\Sselect an interface language. de.ro.HelpLanguageConfig4:Klicken mit AUSWAHL zum Auswählen einer Oberflächensprache. @@ -5870,7 +5870,7 @@ nl.ro.HelpSecurityConfig:De privacy- en veiligheidsinstellingen kunnen in dit ve en.ro.HelpSecurityConfig2:This indicates whether NetSurf will send site referral information to web servers.|MWhen this is enabled NetSurf will tell the web server of a new page the address of the site you came from, after following a link. de.ro.HelpSecurityConfig2:NetSurf sendet Seitenreferenzinformationen an Webserver.|MIst diese Option gewählt, schickt NetSurf an den Server einer neuen Webseite die Adresse der Seite von der aus die aktuelle über einen Link aufgerufen wurde. fr.ro.HelpSecurityConfig2:Ceci indique si Netsurf doit envoyer l'information de renvoi de site aux serveurs web.|MLorsque ceci est activé Netsurf signalera au serveur web d'une nouvelle page l'adresse du site d'où vous venez, après avoir suivi un lien. -it.ro.HelpSecurityConfig2:Indica se NetSurf invierà le informazioni di riferimento del sito ai server Web.|MQuando questo abilitato, NetSurf comunicherà al server Web di una nuova pagina l'indirizzo del sito dal quale proveniva, dopo aver seguito un link. +it.ro.HelpSecurityConfig2:Indica se NetSurf invierà le informazioni di riferimento del sito ai server Web.|MQuando questo � abilitato, NetSurf comunicherà al server Web di una nuova pagina l'indirizzo del sito dal quale proveniva, dopo aver seguito un link. nl.ro.HelpSecurityConfig2:Deze optie geeft aan of site-gerelateerde informatie naar webservers wordt meegezonden.|MIndien toegestaan, ontvangt de webserver informatie over de vorige pagina waar, via een koppeling, vandaan is gekomen. en.ro.HelpSecurityConfig6:You can enter the length of time that items are stored in global history here. de.ro.HelpSecurityConfig6:Hier kann die Zeitdauer in Tagen angegeben werden, bis zu deren Ablauf Objekte in der globalen History gespeichert bleiben. @@ -5973,6 +5973,7 @@ de.ami.HelpToolbarAddTab:Tab hinzufügen. fr.ami.HelpToolbarAddTab:Add tab\nLMB: Adds a new blank tab it.ami.HelpToolbarAddTab:Apri una nuova scheda nl.ami.HelpToolbarAddTab:Tabblad toevoegen\nLMB: Een nieuwe leeg tabblad wordt geopend +en.ami.PageInfo:Page info en.ami.PageInfoInsecure:Insecure it.ami.PageInfoInsecure:Non sicuro en.ami.PageInfoLocal:Local