summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
Diffstat (limited to 'amiga')
-rw-r--r--amiga/Makefile.defaults79
-rw-r--r--amiga/Makefile.target16
-rw-r--r--[-rwxr-xr-x]amiga/agclass/amigaguide_class.c167
-rwxr-xr-xamiga/agclass/amigaguide_class.h7
-rw-r--r--amiga/arexx.c27
-rw-r--r--amiga/bitmap.c6
-rwxr-xr-xamiga/bitmap.h1
-rw-r--r--amiga/clipboard.c50
-rwxr-xr-xamiga/clipboard.h5
-rw-r--r--amiga/context_menu.c101
-rwxr-xr-xamiga/context_menu.h3
-rwxr-xr-xamiga/dist/Install339
-rwxr-xr-xamiga/dist/NetSurf.guide11
-rwxr-xr-xamiga/dist/netsurf.readme14
-rw-r--r--amiga/download.c76
-rwxr-xr-xamiga/download.h5
-rw-r--r--amiga/drag.c15
-rw-r--r--amiga/drag.h3
-rw-r--r--amiga/dt_anim.c14
-rw-r--r--amiga/dt_picture.c8
-rw-r--r--amiga/dt_sound.c4
-rw-r--r--amiga/file.c41
-rw-r--r--amiga/filetype.c37
-rw-r--r--amiga/filetype.h3
-rwxr-xr-xamiga/font.c73
-rw-r--r--amiga/font_scan.c6
-rwxr-xr-xamiga/font_scan.h2
-rw-r--r--amiga/gui.c1477
-rwxr-xr-xamiga/gui.h12
-rwxr-xr-xamiga/gui_options.c89
-rwxr-xr-xamiga/gui_options.h7
-rwxr-xr-xamiga/help.c21
-rwxr-xr-xamiga/help.h6
-rwxr-xr-xamiga/history_local.c21
-rw-r--r--amiga/icon.c16
-rw-r--r--amiga/iff_dr2d.c14
-rwxr-xr-xamiga/launch.c26
-rwxr-xr-xamiga/launch.h3
-rwxr-xr-xamiga/login.c4
-rwxr-xr-xamiga/login.h4
-rw-r--r--amiga/menu.c168
-rwxr-xr-xamiga/misc.c319
-rw-r--r--amiga/misc.h5
-rw-r--r--amiga/options.h3
-rwxr-xr-xamiga/plotters.c552
-rwxr-xr-xamiga/plotters.h7
-rw-r--r--amiga/plugin_hack.c2
-rw-r--r--amiga/plugin_hack.h2
-rw-r--r--amiga/print.c9
-rw-r--r--amiga/resources/Resource.map2
-rw-r--r--amiga/resources/Themes/AISS/Resource.map1
-rwxr-xr-xamiga/schedule.c220
-rwxr-xr-xamiga/schedule.h38
-rwxr-xr-xamiga/search.c24
-rwxr-xr-xamiga/search.h4
-rw-r--r--amiga/sslcert.h5
-rwxr-xr-xamiga/stringview/stringview.c1
-rw-r--r--amiga/theme.c113
-rw-r--r--amiga/theme.h7
-rwxr-xr-xamiga/thumbnail.c3
-rw-r--r--amiga/tree.c22
-rwxr-xr-xamiga/utf8.c71
-rwxr-xr-xamiga/utf8.h7
-rw-r--r--amiga/version.c9
64 files changed, 2154 insertions, 2253 deletions
diff --git a/amiga/Makefile.defaults b/amiga/Makefile.defaults
index 5ff1b69c3..20022bb98 100644
--- a/amiga/Makefile.defaults
+++ b/amiga/Makefile.defaults
@@ -2,45 +2,40 @@
# Amiga-specific options
# ----------------------------------------------------------------------------
- # Force using glibc internal iconv implementation instead of external libiconv
- # Valid options: YES, NO
- NETSURF_USE_LIBICONV_PLUG := YES
-
- # Enable NetSurf's use of librosprite for displaying RISC OS Sprites
- # Valid options: YES, NO, AUTO
- NETSURF_USE_ROSPRITE := NO
-
- # Enable NetSurf's use of libmng for displaying MNGs, JNGs and PNGs
- # Valid options: YES, NO (at least one of PNG/MNG/DT highly recommended)
- NETSURF_USE_MNG := NO
-
- # Enable NetSurf's use of libwebp for displaying WebPs
- # Valid options: YES, NO
- NETSURF_USE_WEBP := NO
-
- # Enable NetSurf to display Amiga icons
- # Valid options: YES, NO (recommended)
- NETSURF_USE_AMIGA_ICON := YES
-
- # Enable NetSurf's use of DataTypes for unknown filetypes
- # Valid options: YES, NO
- NETSURF_USE_AMIGA_DATATYPES := YES
-
- # Enable NetSurf's use of libsvgtiny for displaying SVGs
- # Valid options: YES, NO
- NETSURF_USE_NSSVG := YES
-
- # Enable NetSurf's use of libcairo for some plotter functions
- # This will also link NetSurf with shared objects, and
- # requires AmigaOS 4.1 or higher to run the resulting executable
- # Valid options: YES, NO, AUTO
- NETSURF_USE_AMIGA_CAIRO := AUTO
-
- # Enable NetSurf's use of Spidermonkey 1.80+
- # Only here to stop the build complaining;
- # enable NETSURF_USE_MOZJS instead for JavaScript support
- # Valid options: NO
- NETSURF_USE_JS := NO
-
- # Optimisation levels
- CFLAGS += -O2 -gstabs
+# Force using glibc internal iconv implementation instead of external libiconv
+# Valid options: YES, NO
+NETSURF_USE_LIBICONV_PLUG := YES
+
+# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
+# Valid options: YES, NO, AUTO
+NETSURF_USE_ROSPRITE := NO
+
+# Enable NetSurf's use of libwebp for displaying WebPs
+# Valid options: YES, NO
+NETSURF_USE_WEBP := NO
+
+# Enable NetSurf to display Amiga icons
+# Valid options: YES, NO (recommended)
+NETSURF_USE_AMIGA_ICON := YES
+
+# Enable NetSurf's use of DataTypes for unknown filetypes
+# Valid options: YES, NO
+NETSURF_USE_AMIGA_DATATYPES := YES
+
+# Enable NetSurf's use of libsvgtiny for displaying SVGs
+# Valid options: YES, NO
+NETSURF_USE_NSSVG := YES
+
+# Enable building the source object cache filesystem based backing store.
+# Valid options: YES, NO
+NETSURF_FS_BACKING_STORE := YES
+
+# Enable NetSurf's use of Spidermonkey 1.80+
+# Only here to stop the build complaining;
+# enable NETSURF_USE_MOZJS instead for JavaScript support
+# Valid options: NO
+NETSURF_USE_JS := NO
+
+# Optimisation levels
+CFLAGS += -O2 -gstabs
+
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index da9b252c9..ea765af36 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -2,7 +2,7 @@
# Amiga target setup
# ----------------------------------------------------------------------------
-CFLAGS += -std=c99 -Dnsamiga -DFETCHER_CURLL_SCHEDULED
+CFLAGS += -std=c99 -Dnsamiga
ifneq ($(SUBTARGET),os3)
CFLAGS += -U__STRICT_ANSI__ -D__USE_INLINE__ -D__USE_BASETYPE__
@@ -15,7 +15,6 @@ NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
NETSURF_FEATURE_WEBP_CFLAGS := -DWITH_WEBP
NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
NETSURF_FEATURE_VIDEO_CFLAGS := -DWITH_VIDEO
-NETSURF_FEATURE_AMIGA_CAIRO_CFLAGS := -DNS_AMIGA_CAIRO
ifeq ($(HOST),amiga)
$(eval $(call feature_enabled,ROSPRITE,-DWITH_NSSPRITE,-lrosprite,Sprite (librosprite)))
@@ -23,30 +22,23 @@ ifeq ($(HOST),amiga)
$(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif,GIF (libnsgif)))
$(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng) ))
$(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
- $(eval $(call feature_enabled,MNG,,-llcms -ljpeg,PNG/JNG/MNG (libmng)))
$(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp,WebP (libwebp)))
$(eval $(call feature_enabled,VIDEO,-DWITH_VIDEO -I /SDK/local/newlib/include/glib-2.0,-lgstreamer-0.10 -lglib-2.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lintl -lffi,Video (libgstreamer)))
$(eval $(call feature_enabled,JS,-DXP_UNIX -DWITH_JS -DJS_VERSION=185,-lstdc++ -lmozjs185,JavaScript))
$(eval $(call feature_enabled,MOZJS,-DXP_AMIGA -DWITH_MOZJS -DJS_VERSION=170 -DJSVERSION_LATEST=170 -DJSOPTION_JIT=0 -DJSCLASS_GLOBAL_FLAGS=0,-ljs -lfdlibm,JavaScript))
- $(eval $(call feature_enabled,AMIGA_CAIRO,-DNS_AMIGA_CAIRO,,Cairo))
$(eval $(call feature_enabled,AMIGA_ICON,-DWITH_AMIGA_ICON,,Amiga icon))
$(eval $(call feature_enabled,AMIGA_DATATYPES,-DWITH_AMIGA_DATATYPES,,DataTypes))
CFLAGS += -I /SDK/local/common/include/libpng12
LDFLAGS += -lcurl -lrtmp -lpthread -ltre -lintl -lauto -lpbl
LDFLAGS += -lssl -lcrypto -ldom -lhubbub -lcss -lparserutils -lwapcaplet
-
- ifeq ($(NETSURF_USE_AMIGA_CAIRO),YES)
- CFLAGS += -I /SDK/local/common/include/cairo
- LDFLAGS += -use-dynld -ldl -lcairo -lpixman-1 -lfreetype -lfontconfig -lpng -lexpat
- endif
else
$(eval $(call pkg_config_find_and_add_enabled,ROSPRITE,librosprite,Sprite))
$(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
$(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF))
$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
$(eval $(call pkg_config_find_and_add_enabled,NSSVG,libsvgtiny,NSSVG))
- $(eval $(call pkg_config_find_and_add_enabled,AMIGA_CAIRO,cairo,Cairo))
+ $(eval $(call feature_enabled,MOZJS,-DXP_AMIGA -DWITH_MOZJS -DJS_VERSION=170 -DJSVERSION_LATEST=170 -DJSOPTION_JIT=0 -DJSCLASS_GLOBAL_FLAGS=0,-ljs,JavaScript))
$(eval $(call feature_enabled,AMIGA_ICON,-DWITH_AMIGA_ICON,,Amiga icon))
$(eval $(call feature_enabled,AMIGA_DATATYPES,-DWITH_AMIGA_DATATYPES,,DataTypes))
@@ -54,7 +46,7 @@ else
CFLAGS += $(shell $(PKG_CONFIG) --cflags libcurl openssl)
CFLAGS += $(shell $(PKG_CONFIG) --cflags tre libdom libcss)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl openssl)
+ LDFLAGS += $(shell $(PKG_CONFIG) --static --libs libcurl openssl)
LDFLAGS += $(shell $(PKG_CONFIG) --libs tre libdom libcss)
LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
@@ -109,7 +101,7 @@ AMIGA_LIBRARIES := parserutils.library nsgif.library nsbmp.library iconv.library
AMIGA_LIBS := $(addprefix /Libs/,$(AMIGA_LIBRARIES))
AMIGA_SHARED_OBJS := libjpeg.so.12 libcurl.so.7 librtmp.so.0 libsvgtiny.so.0 \
libssl.so.1.0.0 libcrypto.so.1.0.0 libcss.so.0 libwapcaplet.so.0 libpng12.so \
- libdom.so.0 libhubbub.so.0 libtre.so.5 libintl.so
+ libdom.so.0 libhubbub.so.0 libtre.so.5 libintl.so libparserutils.so.0
AMIGA_SOBJS := $(addprefix /SObjs/,$(AMIGA_SHARED_OBJS))
AMIGA_DISTRIBUTION_FILES := amiga/dist/*
AMIGA_INSTALL_TARGET_DIR := NetSurf_Amiga
diff --git a/amiga/agclass/amigaguide_class.c b/amiga/agclass/amigaguide_class.c
index dfac7ad7a..9d69e96c2 100755..100644
--- a/amiga/agclass/amigaguide_class.c
+++ b/amiga/agclass/amigaguide_class.c
@@ -8,6 +8,8 @@
#include "amigaguide_class.h"
+
+
struct localObjectData
{
struct NewAmigaGuide nag;
@@ -15,7 +17,6 @@ struct localObjectData
AMIGAGUIDECONTEXT agHandle;
uint32 agContextID;
uint32 agSignal;
- BOOL agActive;
};
struct Library *AmigaGuideBase = NULL;
@@ -34,6 +35,7 @@ uint32 om_set(Class *, Object *, struct opSet *);
uint32 om_get(Class *, Object *, struct opGet *);
uint32 agm_open(Class *, Object *, Msg);
uint32 agm_close(Class *, Object *, Msg);
+uint32 agm_process(Class *, Object *, Msg);
/* *************************** class initialization and disposal ***************************** */
@@ -107,6 +109,9 @@ static uint32 dispatchAGClass(Class *cl, Object *o, Msg msg)
case AGM_CLOSE:
return agm_close(cl, o, msg);
+ case AGM_PROCESS:
+ return agm_process(cl, o, msg);
+
default:
return IIntuition->IDoSuperMethodA(cl, o, msg);
}
@@ -128,7 +133,6 @@ uint32 om_new(Class *cl, Object *o, struct opSet *msg)
if ( (lod = (struct localObjectData *)INST_DATA(cl, retVal)) )
{
// Initialize values.
- lod->agActive = FALSE;
lod->agHandle = NULL;
lod->agContextID = 0;
lod->nag.nag_Name = NULL;
@@ -169,10 +173,9 @@ uint32 om_dispose(Class *cl, Object *o, Msg msg)
uint32 om_set(Class *cl, Object *o, struct opSet *msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
- struct TagItem *tags, *ti;
-
-
- tags = msg->ops_AttrList;
+ struct TagItem *ti = NULL, *tags = msg->ops_AttrList;
+ uint32 retVal = 0L;
+
while ((ti = IUtility->NextTagItem (&tags)))
{
@@ -180,31 +183,32 @@ uint32 om_set(Class *cl, Object *o, struct opSet *msg)
{
case AMIGAGUIDE_Name:
lod->nag.nag_Name = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Database name has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_Screen:
lod->nag.nag_Screen = (struct Screen *)ti->ti_Data;
- lod->agActive = FALSE; // Screen pointer has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_PubScreen:
lod->nag.nag_PubScreen = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Pubscreen name has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_BaseName:
lod->nag.nag_BaseName = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Application basename has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_ContextArray:
lod->nag.nag_Context = (STRPTR *)ti->ti_Data;
- lod->agActive = FALSE; // Context array has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_ContextID:
lod->agContextID = (uint32)ti->ti_Data;
+ retVal++;
break;
default:
@@ -212,38 +216,7 @@ uint32 om_set(Class *cl, Object *o, struct opSet *msg)
}
}
-
- // Setup the help system, if not ready yet or needs changing.
- if ( lod->agActive == FALSE )
- {
- // Shut down help system should it already be running.
- if ( lod->agHandle ) agm_close(cl, o, (Msg)msg);
-
- // (Re)establish the AmigaGuide context and open the database asynchronously.
- if ( (lod->agHandle = IAmigaGuide->OpenAmigaGuideAsync(&(lod->nag), NULL)) )
- {
- if ( (lod->agSignal = IAmigaGuide->AmigaGuideSignal(lod->agHandle)) )
- {
- // Wait until the help system is up and running.
- IExec->Wait(lod->agSignal);
- while ( !(lod->agActive) )
- {
- while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
- {
- // The AmigaGuide process started OK.
- if ( lod->agm->agm_Type == ActiveToolID ) lod->agActive = TRUE;
-
- // Opening the guide file failed for some reason, continue as usual.
- if ( lod->agm->agm_Type == ToolStatusID && lod->agm->agm_Pri_Ret ) lod->agActive = TRUE;
-
- IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
- }
- }
- }
- }
- }
-
- return (uint32)lod->agHandle;
+ return retVal;
}
@@ -261,32 +234,37 @@ uint32 om_get(Class *cl, Object *o, struct opGet *msg)
{
case AMIGAGUIDE_Name:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Name;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_Screen:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Screen;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_PubScreen:
*(msg->opg_Storage) = (uint32)lod->nag.nag_PubScreen;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_BaseName:
*(msg->opg_Storage) = (uint32)lod->nag.nag_BaseName;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_ContextArray:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Context;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_ContextID:
*(msg->opg_Storage) = (uint32)lod->agContextID;
- retVal = 1;
+ retVal = 1L;
+ break;
+
+ case AMIGAGUIDE_Signal:
+ *(msg->opg_Storage) = (uint32)lod->agSignal;
+ retVal = 1L;
break;
default:
@@ -304,23 +282,47 @@ uint32 om_get(Class *cl, Object *o, struct opGet *msg)
uint32 agm_open(Class *cl, Object *o, Msg msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
- uint32 retVal = 0;
+ BOOL agActive = FALSE;
+ uint32 retVal = 0L;
- if ( (lod->agHandle) && (lod->agActive) )
- {
- if ( lod->nag.nag_Context )
- {
- // A context node array is provided = open the current context node.
- IAmigaGuide->SetAmigaGuideContext(lod->agHandle, lod->agContextID, NULL);
- retVal = IAmigaGuide->SendAmigaGuideContext(lod->agHandle, NULL);
- }
- else
+ // Close a previous instance.
+ if ( lod->agHandle ) agm_close(cl, o, msg);
+
+ // (Re)establish the AmigaGuide context and open the database asynchronously.
+ if ( (lod->agHandle = IAmigaGuide->OpenAmigaGuideAsync(&(lod->nag), NULL)) )
{
- // No context array is provided = open the main node.
- retVal = IAmigaGuide->SendAmigaGuideCmd(lod->agHandle, "LINK MAIN", TAG_DONE);
+ if ( (lod->agSignal = IAmigaGuide->AmigaGuideSignal(lod->agHandle)) )
+ {
+ // Wait until the database is displayed and ready.
+ IExec->Wait(lod->agSignal);
+ while ( agActive == FALSE )
+ {
+ while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
+ {
+ // The AmigaGuide process started OK.
+ if ( lod->agm->agm_Type == ActiveToolID ) agActive = TRUE;
+
+ // Opening the guide file failed for some reason, continue as usual.
+ if ( lod->agm->agm_Type == ToolStatusID && lod->agm->agm_Pri_Ret ) agActive = TRUE;
+
+ IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
+ }
+ }
+ if ( lod->nag.nag_Context )
+ {
+ // A context node array is provided = open the current context node.
+ IAmigaGuide->SetAmigaGuideContext(lod->agHandle, lod->agContextID, NULL);
+ retVal = IAmigaGuide->SendAmigaGuideContext(lod->agHandle, NULL);
+ }
+ else
+ {
+ // No context array is provided = open the main node.
+ retVal = IAmigaGuide->SendAmigaGuideCmd(lod->agHandle, "LINK MAIN", TAG_DONE);
+ }
+ }
}
- }
+
return retVal;
}
@@ -332,15 +334,52 @@ uint32 agm_open(Class *cl, Object *o, Msg msg)
uint32 agm_close(Class *cl, Object *o, Msg msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
+ uint32 retVal = 0L;
if ( lod->agHandle )
{
IAmigaGuide->CloseAmigaGuide(lod->agHandle);
lod->agHandle = NULL;
- lod->agActive = FALSE;
+ lod->agSignal = 0;
+ retVal = 1L;
}
- return (uint32)lod->agHandle;
+ return retVal;
+
+}
+
+
+
+
+
+
+uint32 agm_process(Class *cl, Object *o, Msg msg)
+{
+ struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
+ uint32 retVal = 0L;
+
+
+ if (lod->agHandle)
+ {
+ while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
+ {
+ switch (lod->agm->agm_Type)
+ {
+ case ShutdownMsgID:
+ agm_close(cl, o, msg);
+ retVal = 1L;
+ break;
+
+ default:
+ //printf("%d\n", lod->agm->agm_Type);
+ break;
+ }
+ IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
+ }
+ }
+ return retVal;
+
}
+
diff --git a/amiga/agclass/amigaguide_class.h b/amiga/agclass/amigaguide_class.h
index f122f35f7..ee7e55e60 100755
--- a/amiga/agclass/amigaguide_class.h
+++ b/amiga/agclass/amigaguide_class.h
@@ -27,10 +27,13 @@
#define AMIGAGUIDE_BaseName (AMIGAGUIDE_Dummy + 4) // Basename of the application that opens the help file.
#define AMIGAGUIDE_ContextArray (AMIGAGUIDE_Dummy + 5) // Context node array (must be NULL-terminated).
#define AMIGAGUIDE_ContextID (AMIGAGUIDE_Dummy + 6) // Index value of the node to display.
+#define AMIGAGUIDE_Signal (AMIGAGUIDE_Dummy + 7) // Signal mask to wait on
// method definition
-#define AGM_OPEN WM_OPEN
-#define AGM_CLOSE WM_CLOSE
+#define AGM_Dummy AMIGAGUIDE_Dummy + 100
+#define AGM_OPEN AGM_Dummy + 1
+#define AGM_CLOSE AGM_Dummy + 2
+#define AGM_PROCESS AGM_Dummy + 3
// function prototypes
Class *initAGClass(void);
diff --git a/amiga/arexx.c b/amiga/arexx.c
index 472aea1ce..3bac0c249 100644
--- a/amiga/arexx.c
+++ b/amiga/arexx.c
@@ -196,12 +196,12 @@ int ami_find_tab_bw(struct gui_window_2 *gwin, struct browser_window *bw)
struct browser_window *ami_find_tab(int window, int tab)
{
- int windows = 0, tabs = 0;
struct nsObject *node, *nnode;
- struct gui_window_2 *gwin;
if(!IsMinListEmpty(window_list))
{
+ int windows = 0;
+
node = (struct nsObject *)GetHead((struct List *)window_list);
do
@@ -248,8 +248,7 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
browser_window_navigate(curbw,
url,
NULL,
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
@@ -257,9 +256,8 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
}
else if(cmd->ac_ArgList[2])
{
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
bw,
@@ -267,8 +265,7 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
}
else if(cmd->ac_ArgList[1])
{
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -281,16 +278,14 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
}
else
{
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -510,8 +505,7 @@ STATIC VOID rx_home(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -575,7 +569,6 @@ STATIC VOID rx_windows(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((
STATIC VOID rx_active(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
{
- int windows = 0, tabs = 0;
int window = 0, tab = 0;
struct browser_window *bw = curbw;
struct nsObject *node, *nnode;
@@ -585,6 +578,8 @@ STATIC VOID rx_active(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((u
if(!IsMinListEmpty(window_list))
{
+ int windows = 0;
+
node = (struct nsObject *)GetHead((struct List *)window_list);
do
diff --git a/amiga/bitmap.c b/amiga/bitmap.c
index c07f45c67..271978b2e 100644
--- a/amiga/bitmap.c
+++ b/amiga/bitmap.c
@@ -152,7 +152,9 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
int err = 0;
Object *dto = NULL;
- if(!ami_download_check_overwrite(path, NULL, 0)) return false;
+ if ((flags & AMI_BITMAP_FORCE_OVERWRITE) == 0) {
+ if(!ami_download_check_overwrite(path, NULL, 0)) return false;
+ }
if(dto = ami_datatype_object_from_bitmap(bitmap))
{
@@ -453,7 +455,7 @@ static struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int width,
COMPTAG_DestHeight,height,
COMPTAG_OffsetX,0,
COMPTAG_OffsetY,0,
- COMPTAG_FriendBitMap,friendbm,
+ COMPTAG_FriendBitMap, scrn->RastPort.BitMap,
TAG_DONE);
#endif
}
diff --git a/amiga/bitmap.h b/amiga/bitmap.h
index 0435aec5b..6657d2f8a 100755
--- a/amiga/bitmap.h
+++ b/amiga/bitmap.h
@@ -26,6 +26,7 @@
#include <libraries/Picasso96.h>
#define AMI_BITMAP_FORMAT RGBFB_R8G8B8A8
+#define AMI_BITMAP_FORCE_OVERWRITE 0xFF
struct bitmap {
int width;
diff --git a/amiga/clipboard.c b/amiga/clipboard.c
index d37fb1aec..fa1d189d4 100644
--- a/amiga/clipboard.c
+++ b/amiga/clipboard.c
@@ -16,10 +16,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <proto/iffparse.h>
+#include <proto/intuition.h>
+#include <proto/exec.h>
+#include <proto/datatypes.h>
+#include <proto/diskfont.h>
+
+#include <diskfont/diskfonttag.h>
+#include <datatypes/textclass.h>
+#include <datatypes/pictureclass.h>
+
+#include "utils/nsoption.h"
+#include "utils/utf8.h"
#include "desktop/gui.h"
#include "desktop/plotters.h"
#include "desktop/textinput.h"
-#include "utils/nsoption.h"
#include "amiga/bitmap.h"
#include "amiga/clipboard.h"
@@ -31,18 +42,6 @@
#include "amiga/menu.h"
#include "amiga/utf8.h"
-#include "utils/utf8.h"
-
-#include <proto/iffparse.h>
-#include <proto/intuition.h>
-#include <proto/exec.h>
-#include <proto/datatypes.h>
-#include <proto/diskfont.h>
-
-#include <diskfont/diskfonttag.h>
-#include <datatypes/textclass.h>
-#include <datatypes/pictureclass.h>
-
#define ID_UTF8 MAKE_ID('U','T','F','8')
struct IFFHandle *iffh = NULL;
@@ -107,17 +106,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;
@@ -197,12 +185,10 @@ char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size
void gui_get_clipboard(char **buffer, size_t *length)
{
- struct ContextNode *cn;
struct CollectionItem *ci = NULL;
struct StoredProperty *sp = NULL;
ULONG rlen=0,error;
struct CSet *cset;
- LONG codeset = 0;
if(OpenIFF(iffh,IFFF_READ)) return;
@@ -216,6 +202,7 @@ void gui_get_clipboard(char **buffer, size_t *length)
if(ci = FindCollection(iffh, ID_FTXT, ID_UTF8)) {
*buffer = ami_clipboard_cat_collection(ci, 106, length);
} else if(ci = FindCollection(iffh, ID_FTXT, ID_CHRS)) {
+ LONG codeset = 0;
if(sp = FindProp(iffh, ID_FTXT, ID_CSET)) {
cset = (struct CSet *)sp->sp_Data;
codeset = cset->CodeSet;
@@ -226,7 +213,7 @@ void gui_get_clipboard(char **buffer, size_t *length)
CloseIFF(iffh);
}
-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)
{
char *text;
@@ -257,7 +244,7 @@ void gui_set_clipboard(const char *buffer, size_t length,
if(nsoption_bool(clipboard_write_utf8)) {
WriteChunkBytes(iffh, buffer, length);
} else {
- if(utf8_to_local_encoding(buffer, length, &text) == UTF8_CONVERT_OK) {
+ if(utf8_to_local_encoding(buffer, length, &text) == NSERROR_OK) {
char *p;
p = text;
@@ -387,3 +374,10 @@ bool ami_easy_clipboard_svg(struct hlcache_handle *c)
return true;
}
#endif
+
+static struct gui_clipboard_table clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+struct gui_clipboard_table *amiga_clipboard_table = &clipboard_table;
diff --git a/amiga/clipboard.h b/amiga/clipboard.h
index cf3f74087..db6fc35cc 100755
--- a/amiga/clipboard.h
+++ b/amiga/clipboard.h
@@ -25,6 +25,11 @@ struct hlcache_handle;
struct selection;
struct gui_window;
struct gui_window_2;
+struct gui_clipboard_table;
+
+extern struct gui_clipboard_table *amiga_clipboard_table;
+
+void gui_start_selection(struct gui_window *g);
void ami_clipboard_init(void);
void ami_clipboard_free(void);
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index 2ad2b89d9..b85824f2c 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -39,8 +39,8 @@
#include "amiga/theme.h"
#include "amiga/tree.h"
#include "amiga/utf8.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
-#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
@@ -53,7 +53,7 @@
static uint32 ami_context_menu_hook(struct Hook *hook, Object *item, APTR reserved);
static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR reserved);
-static bool ami_context_menu_history(const struct history *history, int x0, int y0,
+static bool ami_context_menu_history(const struct browser_window *bw, int x0, int y0,
int x1, int y1, const struct history_entry *entry, void *user_data);
static uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved);
@@ -269,7 +269,7 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat
PMIA_UserData, nsurl_access(hlcache_handle_get_url(userdata)),
PMIA_CommKey, "B",
TAG_DONE),
- TAG_DONE),
+ PMEND,
TAG_DONE),
~0);
break;
@@ -324,7 +324,7 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat
PMIA_UserData, userdata,
PMIA_Disabled, (content_get_type(userdata) != CONTENT_HTML),
TAG_DONE),
- TAG_DONE),
+ PMEND,
TAG_DONE),
~0);
break;
@@ -364,7 +364,7 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat
PMIA_UserData, userdata,
PMIA_Disabled, !browser_window_stop_available(userdata),
TAG_DONE),
- TAG_DONE),
+ PMEND,
TAG_DONE),
~0);
break;
@@ -410,7 +410,7 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat
PMIA_ID, CMID_SAVEURL,
PMIA_UserData, userdata,
TAG_DONE),
- TAG_DONE),
+ PMEND,
TAG_DONE),
~0);
break;
@@ -467,7 +467,7 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat
PMIA_UserData, userdata,
PMIA_Disabled, !ami_mime_content_to_cmd(userdata),
TAG_DONE),
- TAG_DONE),
+ PMEND,
TAG_DONE),
~0);
break;
@@ -598,8 +598,8 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y)
ctxmenuhook.h_SubEntry = NULL;
ctxmenuhook.h_Data = gwin;
- ctxmenuobj = NewObject( POPUPMENU_GetClass(), NULL,
- PMA_MenuHandler, &ctxmenuhook,
+ ctxmenuobj = NewObject( POPUPMENU_GetClass(), NULL,
+ PMA_MenuHandler, &ctxmenuhook,
TAG_DONE);
if(gwin->bw && gwin->bw->history &&
@@ -607,7 +607,7 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y)
gwin->win->MouseX, gwin->win->MouseY))
{
gwin->temp = 0;
- history_enumerate_back(gwin->bw->history, ami_context_menu_history, gwin);
+ browser_window_history_enumerate_back(gwin->bw, ami_context_menu_history, gwin);
IDoMethod(ctxmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
@@ -630,7 +630,7 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y)
gwin->win->MouseX, gwin->win->MouseY))
{
gwin->temp = 0;
- history_enumerate_forward(gwin->bw->history, ami_context_menu_history, gwin);
+ browser_window_history_enumerate_forward(gwin->bw, ami_context_menu_history, gwin);
IDoMethod(ctxmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
@@ -707,7 +707,7 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y)
static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved)
{
- int32 itemid = 0;
+ int32 itemid = 0;
struct gui_window_2 *gwin = hook->h_Data;
APTR userdata = NULL;
struct browser_window *bw;
@@ -718,10 +718,9 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
nsurl *url;
nserror error;
- if(GetAttrs(item,PMIA_ID,&itemid,
- PMIA_UserData,&userdata,
- TAG_DONE))
- {
+ if(GetAttrs(item, PMIA_ID, &itemid,
+ PMIA_UserData, &userdata,
+ TAG_DONE)) {
switch(itemid)
{
case CMID_SELECTFILE:
@@ -742,17 +741,11 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
strlcpy(fname,filereq->fr_Drawer,1024);
AddPart(fname,filereq->fr_File,1024);
- if(utf8_from_local_encoding(fname,0,&utf8_fn) != UTF8_CONVERT_OK)
- {
- warn_user("NoMemory","");
- break;
- }
-
browser_window_drop_file_at_point(
file_input->bw,
file_input->x,
file_input->y,
- utf8_fn);
+ fname);
}
break;
@@ -786,8 +779,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
case CMID_URLOPENWIN:
error = nsurl_create(userdata, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
url,
hlcache_handle_get_url(gwin->bw->current_content),
gwin->bw,
@@ -805,9 +797,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
case CMID_URLOPENTAB:
error = nsurl_create(userdata, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY | BW_CREATE_TAB,
url,
hlcache_handle_get_url(gwin->bw->current_content),
gwin->bw,
@@ -830,8 +820,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
browser_window_navigate(gwin->bw,
url,
hlcache_handle_get_url(gwin->bw->current_content),
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
@@ -845,8 +834,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
browser_window_navigate(gwin->bw,
hlcache_handle_get_url(userdata),
hlcache_handle_get_url(gwin->bw->current_content),
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -862,8 +850,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
browser_window_navigate(gwin->bw,
url,
hlcache_handle_get_url(gwin->bw->current_content),
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -923,7 +910,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
}
else
{
- history_go(gwin->bw, gwin->bw->history,
+ browser_window_history_go(gwin->bw,
(struct history_entry *)userdata, false);
}
break;
@@ -938,8 +925,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -996,27 +982,27 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
case CMID_SELSEARCH:
{
char *sel;
- char *urltxt;
- nsurl *url;
if(sel = browser_window_get_selection(gwin->bw))
{
- urltxt = search_web_from_term(sel);
-
- if (nsurl_create(urltxt, &url) != NSERROR_OK) {
- warn_user("NoMemory", 0);
- } else {
- browser_window_navigate(gwin->bw,
- url,
- NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
- NULL,
- NULL,
- NULL);
+ nserror ret;
+ nsurl *url;
+
+ ret = search_web_omni(sel, SEARCH_WEB_OMNI_SEARCHONLY, &url);
+ free(sel);
+ if (ret == NSERROR_OK) {
+ ret = browser_window_navigate(gwin->bw,
+ url,
+ NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL,
+ NULL,
+ NULL);
nsurl_unref(url);
}
- free(sel);
+ if (ret != NSERROR_OK) {
+ warn_user(messages_get_errorcode(ret), 0);
+ }
}
}
break;
@@ -1262,8 +1248,9 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r
return itemid;
}
-static bool ami_context_menu_history(const struct history *history, int x0, int y0,
- int x1, int y1, const struct history_entry *entry, void *user_data)
+static bool ami_context_menu_history(const struct browser_window *bw,
+ int x0, int y0, int x1, int y1,
+ const struct history_entry *entry, void *user_data)
{
struct gui_window_2 *gwin = (struct gui_window_2 *)user_data;
@@ -1272,7 +1259,7 @@ static bool ami_context_menu_history(const struct history *history, int x0, int
IDoMethod(ctxmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
- PMIA_Title, (ULONG)history_entry_get_title(entry),
+ PMIA_Title, (ULONG)browser_window_history_entry_get_title(entry),
PMIA_ID, CMID_HISTORY,
PMIA_UserData, entry,
TAG_DONE),
@@ -1288,7 +1275,7 @@ static uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved)
if(GetAttr(PMIA_ID, item, &itemid))
{
- form_select_process_selection(gwin->shared->bw->current_content,gwin->shared->control,itemid);
+ form_select_process_selection(gwin->shared->control,itemid);
}
return itemid;
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/dist/Install b/amiga/dist/Install
index 61defec03..96026a0ee 100755
--- a/amiga/dist/Install
+++ b/amiga/dist/Install
@@ -43,223 +43,6 @@
)
)
-(procedure p_failedsobjs
- (if #failedsobjs
- (message "The following shared objects failed to copy. These will be updated on next reboot.\n\n" #failedsobjs)
- )
-)
-
-(procedure p_schedulesobj #sobj
- (transcript "Scheduling update of " #sobj " for next reboot")
-
- (set #failedsobjs (cat #failedsobjs "\n" #sobj))
-
- (makedir "SObjs:so-installer")
-
- (copyfiles
- (source (tackon "SObjs" #sobj))
- (dest "SObjs:so-installer")
- )
-
- (startup "Shared object installer"
- (prompt "Adding commands to user-startup to schedule copy of " #sobj " on next reboot")
- (help @startup-help)
- (command "if EXISTS SObjs:so-installer\n")
- (command " copy SObjs:so-installer SObjs: CLONE FORCE QUIET\n")
- (command " delete SObjs:so-installer ALL FORCE QUIET\n")
- (command "endif\n")
- )
-)
-
-(procedure p_comparesobj2 #sobj1_full #sobj2_full
- (set #same 0)
-
- (set #sobj-version (getversion (#sobj1_full)))
- (if (= #sobj-version 0)
- (
- (if (exists (#sobj2_full))
- (
- (set #file-newer (earlier (#sobj2_full) (#sobj1_full)))
- (set #old-size (getsize (#sobj2_full)))
- (set #new-size (getsize (#sobj1_full)))
-
- (if (AND (= #old-size #new-size) (= #file-newer 0)) (set #same 1))
- )
- )
- )
- ; else if version info is available
- (
- (set #sobj-oldversion (getversion (#sobj2_full)))
-
- (if (<= #sobj-version #sobj-oldversion) (set #same 1))
- )
- )
-)
-
-(procedure p_comparesobj #sobj
- (set #sobj1 (tackon "SObjs/" #sobj))
- (set #sobj2 (tackon "SObjs:" #sobj))
-
- (p_comparesobj2 #sobj1 #sobj2)
-)
-
-(procedure p_linksobj #sobj #sobj_link
- (set #sobj2 (tackon "SObjs:" #sobj_link))
-
- (p_comparesobj2 (tackon "SObjs/" #sobj) #sobj2)
-
- (if (= #same 0) ;if #sobj is newer than that pointed to by #sobj_link
- (
- (if (exists (#sobj2))
- (transcript "Deleting " #sobj2)
- (delete #sobj2 (optional "force")) ;prevent dodgy recursive links
- )
- (set #linkcmd (cat "makelink " #sobj2 " SObjs:" #sobj " soft"))
- (transcript "Running " #linkcmd)
- (run #linkcmd)
- )
- )
-)
-
-(procedure p_copysobj #sobj
- (set #sobj-version (getversion (tackon "SObjs/" #sobj)))
-
- (if (= #sobj-version 0)
- (
- (transcript "Date compare " #sobj)
-
- (if (exists (tackon "SObjs:" #sobj))
- (
- (set #file-newer (earlier (tackon "SObjs:" #sobj) (tackon "SObjs/" #sobj)))
-
- (if (= #file-newer 0)
- (
- (set #newer-text "has an older datestamp")
- )
- ;else
- (
- (set #newer-text "has a newer datestamp")
- )
- )
-
- (set #old-size (getsize (tackon "SObjs:" #sobj)))
- (set #new-size (getsize (tackon "SObjs/" #sobj)))
-
- (if (AND (= #old-size #new-size) (= #file-newer 0))
- (
- (set #copy 0)
- )
- ;else
- (
- (if (OR (= @user-level 2) (AND (= @user-level 1) (<> #file-newer 0)))
-; Expert users are always prompted
-; Average users are prompted if the file trying to be copied is newer
-; Novice users are never prompted
-; This is roughly equivalent to (copylib (confirm))
-; No prompting occurs if the destination does not exist (silent copy)
-; or the files are the same size and the one being copied isn't newer (don't copy)
- (
- (set #copy
- (askbool
- (prompt "Copying " #sobj "...\n\n"
- "Version to install: " #new-size " bytes\n"
- "Version currently installed: " #old-size " bytes\n\n"
- "The file to copy " #newer-text)
- (help @askbool-help)
- (default #file-newer)
- (choices "Proceed with copy" "Skip this part")
- )
- )
- )
- ;else
- (
- (set #copy #file-newer)
- )
- )
- )
- )
- )
- ; else if dest file does not exist
- (
- (set #copy 1)
- )
- )
-
- (if (<> #copy 0)
- (
- (if (<> #AutoInstall 1)
- (
- (copyfiles
- (prompt "Copying " #sobj "...")
- (help @copyfiles-help)
- (source (tackon "SObjs/" #sobj))
- (dest "SObjs:")
- (optional "nofail" "force")
- )
- )
- ;else
- (
- (run "CopyStore SObjs/" #sobj " SObjs:")
- )
- )
-
- (p_comparesobj #sobj)
- (if (= #same 0)
- (
- (p_schedulesobj #sobj)
- )
- )
- )
- )
- )
- ; else if version info is available
- (
- (if (<> #AutoInstall 1)
- (
- (copylib
- (prompt "Copying " #sobj "...")
- (help @copylib-help)
- (source (tackon "SObjs/" #sobj))
- (dest "SObjs:")
- (optional "nofail" "force")
- (confirm "expert")
- )
- )
- ;else
- (
- (run "CopyStore SObjs/" #sobj " SObjs:")
- )
- )
-
- (p_comparesobj #sobj)
- (if (= #same 0)
- (
- (p_schedulesobj #sobj)
- )
- )
- )
- )
-)
-
-(procedure p_copylib #lib
- (if (<> #AutoInstall 1)
- (
- (copylib
- (prompt "Copying " #lib "...")
- (help @copylib-help)
- (source (tackon "Libs/" #lib))
- (dest "Libs:")
- (optional "nofail" "force")
- (confirm "expert")
- )
- )
- ;else
- (
- (run "CopyStore Libs/" #lib " Libs:")
- )
- )
-)
-
(procedure p_chk_launch-handler #protocol
(run "C:Search >T:NS_Install.tmp " (tackon "ENVARC:launch-handler/URL" #protocol) " NetSurf" (safe))
(set #has_entry (getsize "T:NS_Install.tmp"))
@@ -274,6 +57,9 @@
(if (<> #AutoInstall 1) (welcome))
+; (hopefully temporary) workaround for a bug in Installer:
+(if (= @language "dutch") (set @askdir-help ""))
+
(complete 0)
(set @default-dest (getenv "AppPaths/NetSurf"))
@@ -309,72 +95,9 @@
(set #icon-exists (exists (tackon @default-dest "NetSurf.info")))
(set osver (getversion))
(set osver (/ osver 65536))
-(set #versions-available 0)
-
-(set #static-filename "NetSurf")
-(set #cairo-filename "NetSurf")
-
-(if (exists "NetSurf")
- (
- (if (exists "SObjs")
- (
- (if (>= osver 53)
- (
- (set #cairo-name "Shared objects/part-Cairo")
- (set #versions-available (+ #versions-available 1))
- (set #cairo-version 1)
- )
- ;else
- (
- (set #cairo-version 0)
- (set #cairo-name "")
- )
- )
- )
- ;else
- (
- ; assume static if sobjs is not present
- (set #static-name "Static/graphics.library")
- (set #versions-available (+ #versions-available 1))
- (set #cairo-version 0)
- (set #static-filename "NetSurf")
- )
- )
- )
- ; else
- (
- (set #cairo-version 0)
- (set #cairo-name "")
- )
-)
-
-(transcript "Versions avaiable for install: " #versions-available " " #static-name " " #cairo-name)
-
-(if (= #versions-available 0)
- (
- (abort "Did not find any compatible versions of NetSurf to install!\n\n"
- "NetSurf requires AmigaOS 4.1 or higher.")
- )
-)
(complete 10)
-(if (AND (> @user-level 0) (> #versions-available 1))
- (
- (set #cairo-version
- (askchoice
- (prompt "Which version of NetSurf would you like to install?")
- (help "The Cairo version has anti-aliasing of graphical elements.\n\n"
- @askchoice-help)
- (choices #static-name #cairo-name)
- (default #cairo-version)
- )
- )
- )
-)
-
-(complete 15)
-
(set #user (getenv "user"))
(if (= #user "") (set #user "Default"))
@@ -415,7 +138,7 @@
)
)
-(complete 18)
+(complete 15)
(if (>= osver 53)
(
@@ -436,7 +159,7 @@
)
)
-(complete 19)
+(complete 20)
(set #runfixfonts
(askbool
@@ -449,9 +172,7 @@
)
)
-(complete 20)
-
-(set #netsurf-name (select #cairo-version #static-filename #cairo-filename))
+(complete 25)
(working "Installing NetSurf")
@@ -460,7 +181,7 @@
(copyfiles
(prompt "Copying NetSurf...")
(help @copyfiles-help)
- (source #netsurf-name)
+ (source "NetSurf")
(dest @default-dest)
(newname "NetSurf")
(optional "askuser" "force" "oknodelete")
@@ -473,7 +194,7 @@
)
)
-(complete 30)
+(complete 40)
(if #searchengines-exist
(rename (tackon @default-dest "Resources/SearchEngines") (tackon @default-dest "Resources/SearchEngines.backup"))
@@ -483,6 +204,8 @@
(run "c:filenote Rexx/ViewSource.nsrx \"View source\"")
(run "c:filenote Rexx/GetVideo.nsrx \"Get video\"")
+(complete 50)
+
(copyfiles
(prompt "Copying files")
(source "")
@@ -494,6 +217,8 @@
; (all)
)
+(complete 65)
+
(copyfiles
(prompt "Copying additional documentation")
(source "")
@@ -504,34 +229,7 @@
(optional "nofail")
)
-(set #complete 40)
-(working "Copying Libraries")
-
-(if (exists "Libs")
- (
- (foreach "Libs" "#?"
- (complete #complete)
- (p_copylib @each-name)
- (set #complete (+ #complete 2))
- )
- )
-)
-
-(set #complete 60)
-
-(if (= #cairo-version 1)
- (
- (working "Copying Shared Objects")
-
- (foreach "SObjs" "#?"
- (complete #complete)
- (p_copysobj @each-name)
- (set #complete (+ #complete 1))
- )
- )
-)
-
-(complete 90)
+(complete 70)
(if #themeshort
(
@@ -578,7 +276,7 @@
)
)
-(complete 95)
+(complete 75)
(if (= (exists "ENVARC:Sys/def_css.info") 0)
(copyfiles
@@ -591,7 +289,7 @@
)
)
-(complete 96)
+(complete 80)
(working "Setting MIME types")
(p_setmimetype "css" "text/css")
@@ -611,7 +309,7 @@
(p_setmimetype "zip" "application/x-zip")
(p_setmimetype "js" "application/javascript")
-(complete 97)
+(complete 85)
(if (>= osver 53)
(if (= (exists "Rexx:NetSurf") 0)
@@ -659,7 +357,7 @@
)
)
-(complete 98)
+(complete 90)
(if (= #addlaunchhandler 1)
(
@@ -691,7 +389,7 @@
)
)
-(complete 99)
+(complete 95)
(working "Running FixFonts")
@@ -708,7 +406,6 @@
(exit (quiet))
)
(
- (p_failedsobjs)
(exit)
)
)
diff --git a/amiga/dist/NetSurf.guide b/amiga/dist/NetSurf.guide
index 25310bdc1..2ea772e35 100755
--- a/amiga/dist/NetSurf.guide
+++ b/amiga/dist/NetSurf.guide
@@ -6,9 +6,6 @@
@{b}NetSurf@{ub} Amiga-specific documentation
http://www.netsurf-browser.org
-@{" Change Log " link ChangeLog/Main}
-@{" Licence " link COPYING/Main}
-
@{" GUI " link GUI}
@{" Preferences GUI " link Prefs}
@@ -121,7 +118,6 @@ There are a couple of Amiga-specific options which can only be changed directly
@{b}kiosk_mode@{ub} No gadgets
@{b}printer_unit@{ub} Specifies which printer.device unit to print to
@{b}drag_save_icons@{ub} Enables displaying Workbench-style transparent icons under the pointer when performing drag saves (ctrl-drag of objects available if NetSurf is running on the Workbench screen) and text selection drags. If set to 0 the pointer style will change instead. OS 4.0 users may want to set this to 0 as icons will appear opaque and obscure the drop position.
-@{b}cairo_renderer@{ub} Set rendering engine. -1 = palette-mapped (set automatically when required), 0 = graphics.library (default), 1 = Cairo/graphics.library mixed, 2 = Full Cairo.
@{b}monitor_aspect_x@{ub}/@{b}monitor_aspect_y@{ub} Correct aspect ratio for displays (default of 0 means "assume square pixels").
@{b}screen_compositing@{ub} Use compositing on NetSurf's own screen. 0=disable, 1=enable, 2=default (NB: This is indirectly modified by changing the "simple refresh" option in the GUI)
@{b}resize_with_contents@{ub} Set to 1 to respect GUI prefs' "resize with contents" option. Default is to use old-style "resize on release"
@@ -183,6 +179,7 @@ Commands are:
@{b}OPEN URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,W=WINDOW/K/N,T=TAB/K/N@{ub}
Opens URL in current window or a new window/tab if NEWWINDOW/NEWTAB is specified. Saves the location without displaying if SAVEAS and a filename is specified (SAVEAS available in 2.6325)
+Note that if the URL is non-ASCII it is expected to be encoded in UTF-8 (file: references should always be in local charset due to filesystem limitations). Usually this is not relevant, as all normalised URLs will be in their ASCII form.
@{b}SAVE FILENAME/A,W=WINDOW/K/N,T=TAB/K/N@{ub} (2.6027)
Saves current page source to FILENAME
@@ -255,6 +252,10 @@ Under OS4.1 Update 1, launch-handler is used in preference to OpenURL. The
Installer script can add the relevant configuration to launch URLs in NetSurf.
Please ensure your email application is configured in URL Prefs for mailto:
links clicked within NetSurf.
+
+Note that a helper script is installed in S:ARexx which can be used instead of
+the main executable, to stop the NetSurf executable from being loaded again if
+it is already running.
@endnode
@node hotlist "Hotlist menu"
@@ -367,8 +368,6 @@ There are a number of options which can be changed that will affect the speed of
@{b}Cache native versions@{ub} to @{b}Scaled@{ub} (or preferably @{b}All@{ub}, but this will use more graphics mem, and scaling images is a bigger performance hit)
Deselect @{b}Higher quality scaling@{ub}, this will be very slow if not done in hardware.@{lindent}
-@{lindent 2}* In @{"Options" link Options}, set cairo_renderer:1@{lindent}
-
@{lindent 2}* In @{"Options" link Options}, increase redraw_tile_size_x/y (increasing this value uses more graphics mem)@{lindent}
@{lindent 2}* In @{"Options" link Options}, set font_antialiasing:0@{lindent}
diff --git a/amiga/dist/netsurf.readme b/amiga/dist/netsurf.readme
index bd37b2e62..24d8df534 100755
--- a/amiga/dist/netsurf.readme
+++ b/amiga/dist/netsurf.readme
@@ -2,23 +2,21 @@ Short: Fast CSS capable web browser
Uploader: chris@unsatisfactorysoftware.co.uk (Chris Young)
Author: NetSurf contributors (OS4 port by Chris Young)
Type: comm/www
-Version: 3.1 development
+Version: 3.3
Architecture: ppc-amigaos >= 4.0.0
-This is a test build of NetSurf 3.1 for AmigaOS 4.
-It is beta software, which means it is unstable and missing
-features - use at your own risk!
-
-This is provided for testing purposes only. For the latest
-stable version, visit http://www.netsurf-browser.org
+This is NetSurf 3.3 for AmigaOS 4.
+For the latest version, visit http://www.netsurf-browser.org
Please report bugs to chris@unsatisfactorysoftware.co.uk,
on the Amigans.net forums or on the NetSurf mailing list.
-See http://www.netsurf-browser.org for more information about NetSurf.
+See http://www.netsurf-browser.org for more information about
+NetSurf.
This software is licensed under the GPL, and the sources are
available from http://www.netsurf-browser.org. A copy can
also be obtained directly from the maintainer of this port,
chris@unsatisfactorysoftware.co.uk, in the event that the
website is unavailable.
+
diff --git a/amiga/download.c b/amiga/download.c
index 52baedb24..7c0054f03 100644
--- a/amiga/download.c
+++ b/amiga/download.c
@@ -72,7 +72,7 @@ struct gui_download_window {
struct dlnode *dln;
struct browser_window *bw;
struct download_context *ctx;
- char *url;
+ const char *url;
char fname[1024];
int result;
};
@@ -85,13 +85,13 @@ 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);
- const char *mime_type = download_context_get_mime_type(ctx);
+ const char *url = nsurl_access(download_context_get_url(ctx));
unsigned long total_size = download_context_get_total_length(ctx);
struct gui_download_window *dw;
+ char *dl_filename = ami_utf8_easy(download_context_get_filename(ctx));
APTR va[3];
dw = AllocVecTags(sizeof(struct gui_download_window), AVT_ClearWithValue, 0, TAG_DONE);
@@ -107,9 +107,9 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
if(AslRequestTags(savereq,
ASLFR_Window, gui->shared->win,
ASLFR_SleepWindow, TRUE,
- ASLFR_TitleText,messages_get("NetSurf"),
- ASLFR_Screen,scrn,
- ASLFR_InitialFile, download_context_get_filename(ctx),
+ ASLFR_TitleText, messages_get("NetSurf"),
+ ASLFR_Screen, scrn,
+ ASLFR_InitialFile, dl_filename,
TAG_DONE))
{
strlcpy(dw->fname, savereq->fr_Drawer, 1024);
@@ -127,10 +127,11 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
}
}
+ if(dl_filename) ami_utf8_free(dl_filename);
dw->size = total_size;
dw->downloaded = 0;
if(gui) dw->bw = gui->shared->bw;
- dw->url = (char *)strdup((char *)url);
+ dw->url = url;
va[0] = (APTR)dw->downloaded;
va[1] = (APTR)dw->size;
@@ -191,7 +192,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];
@@ -225,29 +226,15 @@ nserror gui_download_window_data(struct gui_download_window *dw,
return NSERROR_OK;
}
-void gui_download_window_error(struct gui_download_window *dw,
- const char *error_msg)
-{
- warn_user("Unwritten","");
- dw->result = AMINS_DLOAD_ERROR;
- gui_download_window_done(dw);
-}
-
-void ami_download_window_abort(struct gui_download_window *dw)
-{
- download_context_abort(dw->ctx);
- dw->result = AMINS_DLOAD_ABORT;
- 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;
+ struct browser_window *bw;
bool queuedl = false;
STRPTR sendcmd = NULL;
if(!dw) return;
+ bw = dw->bw;
if((nsoption_bool(download_notify)) && (dw->result == AMINS_DLOAD_OK))
{
@@ -273,7 +260,6 @@ void gui_download_window_done(struct gui_download_window *dw)
FClose(dw->fh);
SetComment(dw->fname, dw->url);
- if(dw->url) free(dw->url);
downloads_in_progress--;
@@ -287,14 +273,29 @@ void gui_download_window_done(struct gui_download_window *dw)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
nsurl_unref(url);
}
}
+ ami_try_quit(); /* In case the only window open was this download */
+}
+
+static void gui_download_window_error(struct gui_download_window *dw,
+ const char *error_msg)
+{
+ warn_user("Unwritten","");
+ dw->result = AMINS_DLOAD_ERROR;
+ gui_download_window_done(dw);
+}
+
+void ami_download_window_abort(struct gui_download_window *dw)
+{
+ download_context_abort(dw->ctx);
+ dw->result = AMINS_DLOAD_ABORT;
+ gui_download_window_done(dw);
}
BOOL ami_download_window_event(struct gui_download_window *dw)
@@ -344,7 +345,6 @@ void ami_free_download_list(struct List *dllist)
void
gui_window_save_link(struct gui_window *g, const char *url, const char *title)
{
- BPTR fh = 0;
char fname[1024];
STRPTR openurlstring,linkname;
struct DiskObject *dobj = NULL;
@@ -366,6 +366,8 @@ gui_window_save_link(struct gui_window *g, const char *url, const char *title)
if(ami_download_check_overwrite(fname, g->shared->win, 0))
{
+ BPTR fh;
+
if(fh = FOpen(fname,MODE_NEWFILE,0))
{
/* TODO: Should be URLOpen on OS4.1 */
@@ -398,8 +400,6 @@ BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG si
/* Return TRUE if file can be (over-)written */
int32 res = 0;
BPTR lock = 0;
- BPTR fh = 0;
- int64 oldsize = 0;
char *overwritetext;
if(nsoption_bool(ask_overwrite) == false) return TRUE;
@@ -409,6 +409,9 @@ BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG si
if(lock)
{
if(size) {
+ BPTR fh;
+ int64 oldsize = 0;
+
if(fh = OpenFromLock(lock)) {
oldsize = GetFileSize(fh);
Close(fh);
@@ -430,3 +433,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..c7c5f4b77 100644
--- a/amiga/drag.c
+++ b/amiga/drag.c
@@ -50,11 +50,13 @@ 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;
+ /* Check we are running on Workbench */
+ if(nsoption_charp(pubscreen_name) == NULL) return;
if(strcmp(nsoption_charp(pubscreen_name), "Workbench")) return;
switch(type)
@@ -98,9 +100,8 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection)
void ami_drag_save(struct Window *win)
{
- ULONG which = WBO_NONE,type;
- char path[1025],dpath[1025];
- const char *source_data;
+ ULONG which = WBO_NONE, type;
+ char path[1025], dpath[1025];
ULONG source_size;
ami_drag_icon_close(NULL);
@@ -195,10 +196,8 @@ void ami_drag_save(struct Window *win)
void ami_drag_icon_show(struct Window *win, const char *type)
{
struct DiskObject *dobj = NULL;
- ULONG *icondata1;
ULONG width, height;
- long format = 0;
- int err = 0;
+ int err;
int deftype = WBPROJECT;
drag_in_progress = TRUE;
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/dt_anim.c b/amiga/dt_anim.c
index c84470052..4722d2dd2 100644
--- a/amiga/dt_anim.c
+++ b/amiga/dt_anim.c
@@ -92,7 +92,6 @@ static const content_handler amiga_dt_anim_content_handler = {
nserror amiga_dt_anim_init(void)
{
- char dt_mime[50];
struct DataType *dt, *prevdt = NULL;
lwc_string *type;
lwc_error lerror;
@@ -161,14 +160,11 @@ bool amiga_dt_anim_convert(struct content *c)
amiga_dt_anim_content *plugin = (amiga_dt_anim_content *) c;
union content_msg_data msg_data;
int width, height;
- char title[100];
const uint8 *data;
UBYTE *bm_buffer;
ULONG size;
- Object *dto;
struct BitMapHeader *bmh;
unsigned int bm_flags = BITMAP_NEW | BITMAP_OPAQUE;
- int bm_format = PBPAFMT_RGBA;
struct adtFrame adt_frame;
APTR clut;
@@ -341,20 +337,20 @@ APTR ami_colormap_to_clut(struct ColorMap *cmap)
{
int i;
UBYTE *clut = AllocVecTags(256 * 4, AVT_ClearWithValue, 0, TAG_DONE); /* NB: Was not MEMF_PRIVATE */
- ULONG colour[3 * 256];
+ ULONG colr[256 * 4];
if(!clut) return NULL;
/* Get the palette from the ColorMap */
- GetRGB32(cmap, 0, 256, (ULONG *)&colour);
+ GetRGB32(cmap, 0, 256, (ULONG *)&colr);
/* convert it to a table of ARGB values */
for(i = 0; i < 1024; i += 4)
{
clut[i] = (0xff << 24) |
- ((colour[i] & 0xff000000) >> 8) |
- ((colour[i + 1] & 0xff000000) >> 16) |
- ((colour[i + 2] & 0xff000000) >> 24);
+ ((colr[i] & 0xff000000) >> 8) |
+ ((colr[i + 1] & 0xff000000) >> 16) |
+ ((colr[i + 2] & 0xff000000) >> 24);
}
return clut;
diff --git a/amiga/dt_picture.c b/amiga/dt_picture.c
index 211d2215a..779e1bcf8 100644
--- a/amiga/dt_picture.c
+++ b/amiga/dt_picture.c
@@ -62,7 +62,6 @@ struct amiga_dt_picture_content {
nserror amiga_dt_picture_init(void)
{
- char dt_mime[50];
struct DataType *dt, *prevdt = NULL;
lwc_string *type;
lwc_error lerror;
@@ -175,7 +174,6 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
UBYTE *bm_buffer;
Object *dto;
struct bitmap *bitmap;
- unsigned int bm_flags = BITMAP_NEW;
#ifdef __amigaos4__
int bm_format = PBPAFMT_RGBA;
#else
@@ -185,7 +183,7 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
if(dto = amiga_dt_picture_newdtobject(adt))
{
- bitmap = bitmap_create(c->width, c->height, bm_flags);
+ bitmap = bitmap_create(c->width, c->height, BITMAP_NEW);
if (!bitmap) {
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
@@ -214,14 +212,10 @@ bool amiga_dt_picture_convert(struct content *c)
{
LOG(("amiga_dt_picture_convert"));
- union content_msg_data msg_data;
int width, height;
char *title;
- UBYTE *bm_buffer;
Object *dto;
struct BitMapHeader *bmh;
- unsigned int bm_flags = BITMAP_NEW;
- int bm_format = PBPAFMT_RGBA;
char *filetype;
if(dto = amiga_dt_picture_newdtobject((struct amiga_dt_picture_content *)c))
diff --git a/amiga/dt_sound.c b/amiga/dt_sound.c
index 3f8216914..a1daf03f5 100644
--- a/amiga/dt_sound.c
+++ b/amiga/dt_sound.c
@@ -77,7 +77,6 @@ void amiga_dt_sound_play(Object *dto)
nserror amiga_dt_sound_init(void)
{
- char dt_mime[50];
struct DataType *dt, *prevdt = NULL;
lwc_string *type;
lwc_error lerror;
@@ -146,12 +145,9 @@ bool amiga_dt_sound_convert(struct content *c)
LOG(("amiga_dt_sound_convert"));
amiga_dt_sound_content *plugin = (amiga_dt_sound_content *) c;
- union content_msg_data msg_data;
int width = 50, height = 50;
- char title[100];
const uint8 *data;
ULONG size;
- Object *dto;
data = (uint8 *)content__get_source_data(c, &size);
diff --git a/amiga/file.c b/amiga/file.c
index 937fb9052..b73dd1676 100644
--- a/amiga/file.c
+++ b/amiga/file.c
@@ -22,6 +22,7 @@
#include "amiga/filetype.h"
#include "amiga/icon.h"
#include "amiga/iff_dr2d.h"
+#include "amiga/misc.h"
#include "amiga/save_pdf.h"
#include "amiga/theme.h"
@@ -30,12 +31,12 @@
#include "desktop/browser_private.h"
#include "utils/nsoption.h"
+#include "utils/file.h"
#include "desktop/save_complete.h"
#include "desktop/save_pdf/pdf_plotters.h"
#include "desktop/save_text.h"
#include "utils/messages.h"
-#include "utils/url.h"
#include <proto/asl.h>
#include <proto/dos.h>
@@ -48,8 +49,6 @@ static struct Hook aslhookfunc;
static const ULONG ami_file_asl_mime_hook(struct Hook *mh,
struct FileRequester *fr, struct AnchorPathOld *ap)
{
- BPTR file = 0;
- char buffer[10];
char fname[1024];
BOOL ret = FALSE;
char *mt = NULL;
@@ -62,7 +61,7 @@ static const ULONG ami_file_asl_mime_hook(struct Hook *mh,
strcpy(fname,fr->fr_Drawer);
AddPart(fname,ap->ap_Info.fib_FileName,1024);
- mt = fetch_mimetype(fname);
+ mt = strdup(fetch_filetype(fname));
lerror = lwc_intern_string(mt, strlen(mt), &lwc_mt);
if (lerror != lwc_error_ok)
return FALSE;
@@ -78,7 +77,7 @@ static const ULONG ami_file_asl_mime_hook(struct Hook *mh,
void ami_file_open(struct gui_window_2 *gwin)
{
- char *temp, *temp2;
+ char *temp;
nsurl *url;
if(AslRequestTags(filereq,
@@ -95,23 +94,20 @@ void ami_file_open(struct gui_window_2 *gwin)
{
strlcpy(temp, filereq->fr_Drawer, 1024);
AddPart(temp, filereq->fr_File, 1024);
- temp2 = path_to_url(temp);
- if (nsurl_create(temp2, &url) != NSERROR_OK) {
+ if (netsurf_path_to_nsurl(temp, &url) != NSERROR_OK) {
warn_user("NoMemory", 0);
} else {
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
nsurl_unref(url);
}
- free(temp2);
FreeVec(temp);
}
}
@@ -151,23 +147,19 @@ void ami_file_save(int type, char *fname, struct Window *win,
struct hlcache_handle *object, struct hlcache_handle *favicon,
struct browser_window *bw)
{
- BPTR lock = 0;
+ BPTR lock, fh;
const char *source_data;
ULONG source_size;
struct bitmap *bm;
- BPTR fh=0;
ami_update_pointer(win, GUI_POINTER_WAIT);
- if(ami_download_check_overwrite(fname, win, 0))
- {
- switch(type)
- {
+ if(ami_download_check_overwrite(fname, win, 0)) {
+ switch(type) {
case AMINS_SAVE_SOURCE:
- if((source_data = content_get_source_data(object, &source_size)))
- {
- if(fh = FOpen(fname, MODE_NEWFILE,0))
- {
+ if((source_data = content_get_source_data(object, &source_size))) {
+ BPTR fh;
+ if(fh = FOpen(fname, MODE_NEWFILE,0)) {
FWrite(fh, source_data, 1, source_size);
FClose(fh);
}
@@ -179,8 +171,7 @@ void ami_file_save(int type, char *fname, struct Window *win,
break;
case AMINS_SAVE_COMPLETE:
- if(lock = CreateDir(fname))
- {
+ if(lock = CreateDir(fname)) {
UnLock(lock);
save_complete(object, fname, ami_file_set_type);
amiga_icon_superimpose_favicon(fname, favicon, NULL);
@@ -195,15 +186,13 @@ void ami_file_save(int type, char *fname, struct Window *win,
break;
case AMINS_SAVE_IFF:
- if((bm = content_get_bitmap(object)))
- {
+ if((bm = content_get_bitmap(object))) {
bm->url = (char *)nsurl_access(hlcache_handle_get_url(object));
bm->title = (char *)content_get_title(object);
bitmap_save(bm, fname, 0);
}
#ifdef WITH_NS_SVG
- else if(ami_mime_compare(object, "svg") == true)
- {
+ else if(ami_mime_compare(object, "svg") == true) {
ami_save_svg(object, fname);
}
#endif
diff --git a/amiga/filetype.c b/amiga/filetype.c
index 39e874ab0..2d55e1f8e 100644
--- a/amiga/filetype.c
+++ b/amiga/filetype.c
@@ -55,9 +55,7 @@ enum
const char *fetch_filetype(const char *unix_path)
{
static char mimetype[50];
- STRPTR ttype = NULL;
struct DiskObject *dobj = NULL;
- BPTR lock = 0;
struct DataType *dtn;
BOOL found = FALSE;
lwc_string *lwc_mimetype;
@@ -66,8 +64,7 @@ const char *fetch_filetype(const char *unix_path)
We'll just do a filename check here for quickness, although the
first word ought to be checked against WB_DISKMAGIC really. */
- if(strncmp(unix_path + strlen(unix_path) - 5, ".info", 5) == 0)
- {
+ if(strncmp(unix_path + strlen(unix_path) - 5, ".info", 5) == 0) {
strcpy(mimetype,"image/x-amiga-icon");
found = TRUE;
}
@@ -76,32 +73,26 @@ const char *fetch_filetype(const char *unix_path)
/* Secondly try getting a tooltype "MIMETYPE" and use that as the MIME type.
Will fail over to default icons if the file doesn't have a real icon. */
- if(!found)
- {
+ if(!found) {
if(dobj = GetIconTags(unix_path,ICONGETA_FailIfUnavailable,FALSE,
- TAG_DONE))
- {
+ TAG_DONE)) {
+ STRPTR ttype = NULL;
ttype = FindToolType(dobj->do_ToolTypes, "MIMETYPE");
- if(ttype)
- {
+ if(ttype) {
strcpy(mimetype,ttype);
found = TRUE;
}
-
FreeDiskObject(dobj);
}
}
/* If that didn't work, use the MIME file and DataTypes */
- if(!found)
- {
- if (lock = Lock (unix_path, ACCESS_READ))
- {
- if (dtn = ObtainDataTypeA (DTST_FILE, (APTR)lock, NULL))
- {
- if(ami_mime_from_datatype(dtn, &lwc_mimetype, NULL))
- {
+ if(!found) {
+ BPTR lock;
+ if (lock = Lock (unix_path, ACCESS_READ)) {
+ if (dtn = ObtainDataTypeA (DTST_FILE, (APTR)lock, NULL)) {
+ if(ami_mime_from_datatype(dtn, &lwc_mimetype, NULL)) {
strcpy(mimetype, lwc_string_data(lwc_mimetype));
found = TRUE;
ReleaseDataType(dtn);
@@ -144,12 +135,6 @@ const char *fetch_filetype(const char *unix_path)
return mimetype;
}
-
-char *fetch_mimetype(const char *ro_path)
-{
- return strdup(fetch_filetype(ro_path));
-}
-
const char *ami_content_type_to_file_type(content_type type)
{
switch(type)
@@ -179,9 +164,7 @@ const char *ami_content_type_to_file_type(content_type type)
nserror ami_mime_init(const char *mimefile)
{
- lwc_string *type;
lwc_error lerror;
- nserror error;
char buffer[256];
BPTR fh = 0;
struct RDArgs *rargs = NULL;
diff --git a/amiga/filetype.h b/amiga/filetype.h
index 851dddf36..e99f5950c 100644
--- a/amiga/filetype.h
+++ b/amiga/filetype.h
@@ -27,6 +27,8 @@
struct hlcache_handle;
struct ami_mime_entry;
+const char *fetch_filetype(const char *unix_path);
+
nserror ami_mime_init(const char *mimefile);
void ami_mime_free(void);
void ami_mime_entry_free(struct ami_mime_entry *mimeentry);
@@ -46,4 +48,5 @@ bool ami_mime_compare(struct hlcache_handle *c, const char *type);
/* deprecated */
const char *ami_content_type_to_file_type(content_type type);
+
#endif
diff --git a/amiga/font.c b/amiga/font.c
index 36c810428..de84a0420 100755
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -23,12 +23,12 @@
#include "amiga/gui.h"
#include "amiga/utf8.h"
#include "amiga/object.h"
+#include "amiga/schedule.h"
#include "utils/nsoption.h"
#include "css/css.h"
#include "css/utils.h"
#include "render/font.h"
#include "utils/log.h"
-#include "utils/schedule.h"
#include "utils/utf8.h"
#include "utils/utils.h"
@@ -149,9 +149,9 @@ ULONG ami_xdpi;
int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
uint16 *char1, uint16 *char2, uint32 x, uint32 y, uint32 emwidth, bool aa);
int32 ami_font_width_glyph(struct OutlineFont *ofont,
- uint16 *char1, uint16 *char2, uint32 emwidth);
+ const uint16 *char1, const uint16 *char2, uint32 emwidth);
struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
- uint16 *codepoint);
+ const uint16 *codepoint);
static void ami_font_cleanup(struct MinList *ami_font_list);
static bool nsfont_width(const plot_font_style_t *fstyle,
@@ -204,15 +204,13 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
FIXED kern = 0;
struct OutlineFont *ofont, *ufont = NULL;
uint32 tx=0,i=0;
- size_t len, utf8len = 0;
- uint8 *utf8;
int utf8_pos = 0;
uint32 co = 0;
int utf16charlen;
ULONG emwidth = (ULONG)NSA_FONT_EMWIDTH(fstyle->size);
int32 tempx;
- if(utf8_to_enc(string,"UTF-16",length,(char **)&utf16) != UTF8_CONVERT_OK) return false;
+ if(utf8_to_enc(string,"UTF-16",length,(char **)&utf16) != NSERROR_OK) return false;
outf16 = utf16;
if(!(ofont = ami_open_outline_font(fstyle, 0))) return false;
@@ -291,30 +289,35 @@ bool nsfont_split(const plot_font_style_t *fstyle,
int x, size_t *char_offset, int *actual_x)
{
ULONG co;
- uint16 *utf16 = NULL,*outf16 = NULL;
- uint16 *utf16next = NULL;
+ uint16 *utf16_str = NULL;
+ const uint16 *utf16 = NULL;
+ const uint16 *utf16next = NULL;
FIXED kern = 0;
- int utf16charlen = 0;
struct OutlineFont *ofont, *ufont = NULL;
uint32 tx=0;
int utf8_pos = 0;
int32 tempx = 0;
ULONG emwidth = (ULONG)NSA_FONT_EMWIDTH(fstyle->size);
- if(utf8_to_enc((char *)string,"UTF-16",length,(char **)&utf16) != UTF8_CONVERT_OK) return false;
- outf16 = utf16;
- if(!(ofont = ami_open_outline_font(fstyle, 0))) return false;
+ /* Get utf16 conversion of string for glyph measuring routines */
+ if (utf8_to_enc(string, "UTF-16", length, (char **)&utf16_str) !=
+ NSERROR_OK)
+ return false;
+
+ utf16 = utf16_str;
+ if (!(ofont = ami_open_outline_font(fstyle, 0)))
+ return false;
*char_offset = 0;
*actual_x = 0;
+ if (*utf16 == 0xFEFF) utf16++;
+
while (utf8_pos < length) {
if ((*utf16 < 0xD800) || (0xDBFF < *utf16))
- utf16charlen = 1;
+ utf16next = utf16 + 1;
else
- utf16charlen = 2;
-
- utf16next = &utf16[utf16charlen];
+ utf16next = utf16 + 2;
tempx = ami_font_width_glyph(ofont, utf16, utf16next, emwidth);
@@ -332,21 +335,13 @@ bool nsfont_split(const plot_font_style_t *fstyle,
/* Got a space */
*actual_x = tx;
*char_offset = utf8_pos;
-
- if (x < tx) {
- /* Beyond available width,
- * so don't look further */
- free(outf16);
- return true;
- }
}
tx += tempx;
-
if ((x < tx) && (*char_offset != 0)) {
/* Reached available width, and a space was found;
* split there. */
- free(outf16);
+ free(utf16_str);
return true;
}
@@ -354,14 +349,13 @@ bool nsfont_split(const plot_font_style_t *fstyle,
utf8_pos = utf8_next(string, length, utf8_pos);
}
- free(outf16);
+ free(utf16_str);
/* No spaces to split at, or everything fits */
assert(*char_offset == 0 || x >= tx);
*char_offset = length;
*actual_x = tx;
-
return true;
}
@@ -432,7 +426,7 @@ struct ami_font_node *ami_font_open(const char *font)
* \return outline font or NULL on error
*/
struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
- uint16 *codepoint)
+ const uint16 *codepoint)
{
struct ami_font_node *node;
struct OutlineFont *ofont;
@@ -642,13 +636,14 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
}
int32 ami_font_width_glyph(struct OutlineFont *ofont,
- uint16 *char1, uint16 *char2, uint32 emwidth)
+ const uint16 *char1, const uint16 *char2, uint32 emwidth)
{
int32 char_advance = 0;
FIXED kern = 0;
- struct MinList *gwlist;
- FIXED char1w;
+ struct MinList *gwlist = NULL;
+ FIXED char1w = 0;
struct GlyphWidthEntry *gwnode;
+ bool skip_c2 = false;
if ((*char1 >= 0xD800) && (*char1 <= 0xDBFF)) {
/* We don't support UTF-16 surrogates yet, so just return. */
@@ -657,9 +652,11 @@ int32 ami_font_width_glyph(struct OutlineFont *ofont,
if ((*char2 >= 0xD800) && (*char2 <= 0xDBFF)) {
/* Don't attempt to kern a UTF-16 surrogate */
- *char2 = 0;
+ skip_c2 = true;
}
-
+
+ if (*char2 < 0x0020) skip_c2 = true;
+
if(ESetInfo(&ofont->olf_EEngine,
OT_GlyphCode, *char1,
OT_GlyphCode2, *char1,
@@ -674,7 +671,7 @@ int32 ami_font_width_glyph(struct OutlineFont *ofont,
kern = 0;
- if(*char2) {
+ if(!skip_c2) {
if(ESetInfo(&ofont->olf_EEngine,
OT_GlyphCode, *char1,
OT_GlyphCode2, *char2,
@@ -687,7 +684,7 @@ int32 ami_font_width_glyph(struct OutlineFont *ofont,
}
char_advance = (ULONG)(((char1w - kern) * emwidth) / 65536);
- if(*char2) EReleaseInfo(&ofont->olf_EEngine,
+ if(!skip_c2) EReleaseInfo(&ofont->olf_EEngine,
OT_TextKernPair, kern,
TAG_END);
@@ -732,7 +729,7 @@ ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length,
if(!string || string[0]=='\0') return 0;
if(!length) return 0;
- if(utf8_to_enc(string,"UTF-16",length,(char **)&utf16) != UTF8_CONVERT_OK) return 0;
+ if(utf8_to_enc(string,"UTF-16",length,(char **)&utf16) != NSERROR_OK) return 0;
outf16 = utf16;
if(!(ofont = ami_open_outline_font(fstyle, 0))) return 0;
@@ -831,7 +828,7 @@ void ami_init_fonts(void)
NewList(&ami_diskfontlib_list);
/* run first cleanup in ten minutes */
- schedule(60000, (schedule_callback_fn)ami_font_cleanup, ami_font_list);
+ ami_schedule(600000, ami_font_cleanup, ami_font_list);
}
void ami_close_fonts(void)
@@ -875,7 +872,7 @@ static void ami_font_cleanup(struct MinList *ami_font_list)
}while(node=nnode);
/* reschedule to run in five minutes */
- schedule(30000, (schedule_callback_fn)ami_font_cleanup, ami_font_list);
+ ami_schedule(300000, ami_font_cleanup, ami_font_list);
}
void ami_font_setdevicedpi(int id)
diff --git a/amiga/font_scan.c b/amiga/font_scan.c
index f3ad36e6f..6a595b456 100644
--- a/amiga/font_scan.c
+++ b/amiga/font_scan.c
@@ -71,7 +71,7 @@ struct ami_font_scan_window {
* \param glypharray an array of 0xffff lwc_string pointers
* \return font name or NULL
*/
-const char *ami_font_scan_lookup(uint16 *code, lwc_string **glypharray)
+const char *ami_font_scan_lookup(const uint16 *code, lwc_string **glypharray)
{
if(*code >= 0xd800 && *code <= 0xdbff) {
/* This is a multi-byte character, we don't support falback for these yet. */
@@ -294,7 +294,7 @@ ULONG ami_font_scan_fonts(struct MinList *list,
*/
ULONG ami_font_scan_list(struct MinList *list)
{
- int afShortage, afSize = 100, i;
+ int afShortage, afSize = 100;
struct AvailFontsHeader *afh;
struct AvailFonts *af;
ULONG found = 0;
@@ -315,7 +315,7 @@ ULONG ami_font_scan_list(struct MinList *list)
if(afh) {
af = (struct AvailFonts *)&(afh[1]);
- for(i = 0; i < afh->afh_NumEntries; i++) {
+ for(int i = 0; i < afh->afh_NumEntries; i++) {
if(af[i].af_Attr.ta_Style == FS_NORMAL) {
if(af[i].af_Attr.ta_Name != NULL) {
node = (struct nsObject *)FindIName((struct List *)list,
diff --git a/amiga/font_scan.h b/amiga/font_scan.h
index 840f200e1..d29469742 100755
--- a/amiga/font_scan.h
+++ b/amiga/font_scan.h
@@ -25,6 +25,6 @@ void ami_font_scan_init(const char *filename, bool force_scan, bool save,
lwc_string **glypharray);
void ami_font_scan_fini(lwc_string **glypharray);
void ami_font_scan_save(const char *filename, lwc_string **glypharray);
-const char *ami_font_scan_lookup(uint16 *code, lwc_string **glypharray);
+const char *ami_font_scan_lookup(const uint16 *code, lwc_string **glypharray);
#endif
diff --git a/amiga/gui.c b/amiga/gui.c
index c28ea583f..7ababdf74 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2013 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2014 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -17,14 +17,16 @@
*/
/* NetSurf core includes */
+#include "content/backing_store.h"
+#include "content/fetchers.h"
+#include "content/fetchers/resource.h"
#include "content/urldb.h"
#include "css/utils.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
#include "desktop/hotlist.h"
-#include "desktop/local_history.h"
#include "desktop/mouse.h"
#include "desktop/netsurf.h"
-#include "utils/nsoption.h"
#include "desktop/save_complete.h"
#include "desktop/scrollbar.h"
#include "desktop/searchweb.h"
@@ -33,10 +35,11 @@
#include "image/ico.h"
#include "utils/log.h"
#include "utils/messages.h"
+#include "utils/nsoption.h"
#include "utils/utf8.h"
#include "utils/utils.h"
-#include "utils/url.h"
-#include "content/fetchers/resource.h"
+#include "utils/nsurl.h"
+#include "utils/file.h"
/* NetSurf Amiga platform includes */
#include "amiga/arexx.h"
@@ -69,6 +72,7 @@
#include "amiga/theme.h"
#include "amiga/tree.h"
#include "amiga/utf8.h"
+#include "amiga/sslcert.h"
/* Custom StringView class */
#include "amiga/stringview/stringview.h"
@@ -87,6 +91,7 @@
#include <proto/keymap.h>
#include <proto/locale.h>
#include <proto/Picasso96API.h>
+#include <proto/popupmenu.h>
#include <proto/utility.h>
#include <proto/wb.h>
@@ -109,6 +114,7 @@
#include <proto/bevel.h>
#include <proto/bitmap.h>
#include <proto/button.h>
+#include <proto/chooser.h>
#include <proto/clicktab.h>
#include <proto/layout.h>
#include <proto/space.h>
@@ -118,6 +124,7 @@
#include <classes/window.h>
#include <gadgets/button.h>
+#include <gadgets/chooser.h>
#include <gadgets/clicktab.h>
#include <gadgets/layout.h>
#include <gadgets/scroller.h>
@@ -143,6 +150,8 @@
#define EXTRADOWN (IECODE_5TH_BUTTON)
#define EXTRAUP (IECODE_5TH_BUTTON | IECODE_UP_PREFIX)
+extern struct gui_utf8_table *amiga_utf8_table;
+
struct ami_gui_tb_userdata {
struct List *sblist;
struct gui_window_2 *gw;
@@ -159,17 +168,20 @@ Class *urlStringClass;
BOOL locked_screen = FALSE;
BOOL screen_closed = FALSE;
+ULONG screen_signal = -1;
+
struct MsgPort *applibport = NULL;
ULONG applibsig = 0;
-BOOL refresh_search_ico = FALSE;
-BOOL refresh_favicon = FALSE;
-BOOL refresh_throbber = FALSE;
struct Hook newprefs_hook;
+STRPTR temp_homepage_url = NULL;
+bool cli_force = false;
+
static char *current_user;
static char *current_user_dir;
+static char *current_user_faviconcache;
-static const __attribute__((used)) char *stack_cookie = "\0$STACK:131072\0";
+static const __attribute__((used)) char *stack_cookie = "\0$STACK:98304\0";
const char * const versvn;
const char * const verdate;
@@ -186,8 +198,6 @@ void ami_try_quit(void);
void ami_quit_netsurf_delayed(void);
Object *ami_gui_splash_open(void);
void ami_gui_splash_close(Object *win_obj);
-static uint32 ami_set_search_ico_render_hook(struct Hook *hook, APTR space,
- struct gpRender *msg);
static uint32 ami_set_favicon_render_hook(struct Hook *hook, APTR space,
struct gpRender *msg);
static uint32 ami_set_throbber_render_hook(struct Hook *hook, APTR space,
@@ -198,22 +208,30 @@ 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);
+static void gui_window_remove_caret(struct gui_window *g);
+static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip);
+
+
+
/* 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
+
+
STRPTR ami_locale_langs(void)
{
struct Locale *locale;
- STRPTR acceptlangs = NULL, acceptlangs2 = NULL;
- int i;
+ STRPTR acceptlangs = NULL;
char *remapped;
if(locale = OpenLocale(NULL))
{
- for(i=0;i<10;i++)
+ for(int i = 0; i < 10; i++)
{
if(locale->loc_PrefLanguages[i])
{
@@ -222,7 +240,7 @@ STRPTR ami_locale_langs(void)
{
if(acceptlangs)
{
- acceptlangs2 = acceptlangs;
+ STRPTR acceptlangs2 = acceptlangs;
acceptlangs = ASPrintf("%s, %s",acceptlangs2, remapped);
FreeVec(acceptlangs2);
acceptlangs2 = NULL;
@@ -246,13 +264,15 @@ STRPTR ami_locale_langs(void)
bool ami_gui_map_filename(char **remapped, const char *path, const char *file, const char *map)
{
BPTR fh = 0;
- char mapfile[1024];
+ char *mapfile = NULL;
+ size_t mapfile_size = 0;
char buffer[1024];
char *realfname;
bool found = false;
- strcpy(mapfile, path);
- path_add_part(mapfile, 1024, map);
+ netsurf_mkpath(&mapfile, &mapfile_size, 2, path, map);
+
+ if(mapfile == NULL) return false;
if(fh = FOpen(mapfile, MODE_OLDFILE, 0))
{
@@ -280,18 +300,20 @@ bool ami_gui_map_filename(char **remapped, const char *path, const char *file, c
if(found == false) *remapped = strdup(file);
else LOG(("Remapped %s to %s in path %s using %s", file, *remapped, path, map));
+ free(mapfile);
+
return found;
}
bool ami_gui_check_resource(char *fullpath, const char *file)
{
- bool free_rmap = false;
bool found = false;
char *remapped;
BPTR lock = 0;
+ size_t fullpath_len = 1024;
ami_gui_map_filename(&remapped, fullpath, file, "Resource.map");
- path_add_part(fullpath, 1024, remapped);
+ netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped);
LOG(("Checking for %s", fullpath));
@@ -314,6 +336,7 @@ bool ami_locate_resource(char *fullpath, const char *file)
BPTR lock = 0;
bool found = false;
char *remapped;
+ size_t fullpath_len = 1024;
/* Check NetSurf user data area first */
@@ -341,7 +364,7 @@ bool ami_locate_resource(char *fullpath, const char *file)
{
ami_gui_map_filename(&remapped, "PROGDIR:Resources",
locale->loc_PrefLanguages[i], "LangNames");
- path_add_part(fullpath, 1024, remapped);
+ netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped);
found = ami_gui_check_resource(fullpath, file);
}
@@ -399,7 +422,6 @@ void ami_open_resources(void)
TAG_DONE))) die(messages_get("NoMemory"));
ami_file_req_init();
- //ami_help_init(NULL);
}
static UWORD ami_system_colour_scrollbar_fgpen(struct DrawInfo *drinfo)
@@ -421,7 +443,7 @@ colour_option_from_pen(UWORD pen,
struct Screen *screen,
colour def_colour)
{
- ULONG colour[3];
+ ULONG colr[3];
struct DrawInfo *drinfo;
if((option < NSOPTION_SYS_COLOUR_START) ||
@@ -437,12 +459,12 @@ colour_option_from_pen(UWORD pen,
if(pen == AMINS_SCROLLERPEN) pen = ami_system_colour_scrollbar_fgpen(drinfo);
/* Get the colour of the pen being used for "pen" */
- GetRGB32(screen->ViewPort.ColorMap, drinfo->dri_Pens[pen], 1, (ULONG *)&colour);
+ GetRGB32(screen->ViewPort.ColorMap, drinfo->dri_Pens[pen], 1, (ULONG *)&colr);
/* convert it to a color */
- def_colour = ((colour[0] & 0xff000000) >> 24) |
- ((colour[1] & 0xff000000) >> 16) |
- ((colour[2] & 0xff000000) >> 8);
+ def_colour = ((colr[0] & 0xff000000) >> 24) |
+ ((colr[1] & 0xff000000) >> 16) |
+ ((colr[2] & 0xff000000) >> 8);
FreeScreenDrawInfo(screen, drinfo);
}
@@ -506,7 +528,6 @@ static void ami_set_screen_defaults(struct Screen *screen)
static nserror ami_set_options(struct nsoption_s *defaults)
{
STRPTR tempacceptlangs;
- BPTR lock = 0;
char temp[1024];
/* The following line disables the popupmenu.class select menu
@@ -516,11 +537,6 @@ static nserror ami_set_options(struct nsoption_s *defaults)
nsoption_set_bool(core_select_menu, true);
- #ifndef NS_AMIGA_CAIRO
- /* Ensure we get some output when Cairo not available */
- nsoption_set_int(cairo_renderer, 0);
- #endif
-
if((!nsoption_charp(accept_language)) ||
(nsoption_charp(accept_language)[0] == '\0') ||
(nsoption_bool(accept_lang_locale) == true))
@@ -548,9 +564,6 @@ static nserror ami_set_options(struct nsoption_s *defaults)
nsoption_setnull_charp(ca_bundle,
(char *)strdup("PROGDIR:Resources/ca-bundle"));
-
- search_engines_file_location = nsoption_charp(search_engines_file);
-
sprintf(temp, "%s/FontGlyphCache", current_user_dir);
nsoption_setnull_charp(font_unicode_file,
(char *)strdup(temp));
@@ -564,15 +577,16 @@ static nserror ami_set_options(struct nsoption_s *defaults)
if (nsoption_charp(font_unicode) == NULL)
{
+ BPTR lock = 0;
/* Search for some likely candidates */
- if(lock=Lock("FONTS:Code2000.font",ACCESS_READ))
+ if(lock = Lock("FONTS:Code2000.font", ACCESS_READ))
{
UnLock(lock);
nsoption_set_charp(font_unicode,
(char *)strdup("Code2000"));
}
- else if(lock=Lock("FONTS:Bitstream Cyberbit.font",ACCESS_READ))
+ else if(lock = Lock("FONTS:Bitstream Cyberbit.font", ACCESS_READ))
{
UnLock(lock);
nsoption_set_charp(font_unicode,
@@ -580,9 +594,11 @@ static nserror ami_set_options(struct nsoption_s *defaults)
}
}
+ if(popupmenu_lib_ok == FALSE)
+ nsoption_set_bool(context_menu, false);
+
#ifndef __amigaos4__
nsoption_set_bool(download_notify, false);
- nsoption_set_bool(context_menu, false);
nsoption_set_bool(font_antialiasing, false);
nsoption_set_bool(truecolour_mouse_pointers, false);
#endif
@@ -594,7 +610,7 @@ void ami_amiupdate(void)
{
/* Create AppPath location for AmiUpdate use */
- BPTR lock = 0, amiupdatefh = 0;
+ BPTR lock = 0;
if(((lock = Lock("ENVARC:AppPaths",SHARED_LOCK)) == 0))
{
@@ -606,6 +622,7 @@ void ami_amiupdate(void)
if(lock = Lock("PROGDIR:", ACCESS_READ))
{
char filename[1024];
+ BPTR amiupdatefh;
DevNameFromLock(lock,(STRPTR)&filename,1024L,DN_FULLPATH);
@@ -616,11 +633,10 @@ 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];
- char *raw;
nsurl *url = NULL;
if(ami_locate_resource(buf, path) == false)
@@ -640,11 +656,7 @@ nsurl *gui_get_resource_url(const char *path)
else return NULL;
}
- raw = path_to_url(buf);
- if (raw != NULL) {
- nsurl_create(raw, &url);
- free(raw);
- }
+ netsurf_path_to_nsurl(buf, &url);
return url;
}
@@ -654,7 +666,6 @@ void gui_init(int argc, char** argv)
BPTR lock = 0;
ami_open_resources(); /* alloc ports/asl reqs, open libraries/devices */
- ami_print_init();
ami_clipboard_init();
ami_openurl_open();
@@ -720,11 +731,15 @@ void ami_openscreen(void)
}
}
+ if(screen_signal == -1) screen_signal = AllocSignal(-1);
+ LOG(("Screen signal %d", screen_signal));
scrn = OpenScreenTags(NULL,
SA_DisplayID, id,
SA_Title, nsscreentitle,
SA_Type, PUBLICSCREEN,
SA_PubName, "NetSurf",
+ SA_PubSig, screen_signal,
+ SA_PubTask, FindTask(0),
SA_LikeWorkbench, TRUE,
SA_Compositing, compositing,
TAG_DONE);
@@ -735,6 +750,9 @@ void ami_openscreen(void)
}
else
{
+ FreeSignal(screen_signal);
+ screen_signal = -1;
+
if(scrn = LockPubScreen("NetSurf"))
{
locked_screen = TRUE;
@@ -760,7 +778,7 @@ void ami_openscreen(void)
ami_font_setdevicedpi(id);
ami_set_screen_defaults(scrn);
- //ami_help_new_screen(scrn);
+ ami_help_new_screen(scrn);
}
void ami_openscreenfirst(void)
@@ -770,15 +788,10 @@ void ami_openscreenfirst(void)
ami_theme_throbber_setup();
}
-static void gui_init2(int argc, char** argv)
+static void ami_gui_commandline(int *argc, char **argv)
{
- struct Screen *screen;
- nsurl *url;
- nserror error;
- struct browser_window *bw = NULL;
+ int new_argc = 0;
struct RDArgs *args;
- STRPTR temp_homepage_url = NULL;
- BOOL notalreadyrunning;
STRPTR template = "NSOPTS/M,URL/K,FORCE/S";
long rarray[] = {0,0,0};
enum
@@ -788,6 +801,55 @@ static void gui_init2(int argc, char** argv)
A_FORCE
};
+ if(*argc == 0) return; // argc==0 is started from wb
+
+ if(args = ReadArgs(template, rarray, NULL)) {
+ if(rarray[A_URL]) {
+ LOG(("URL %s specified on command line", rarray[A_URL]));
+ temp_homepage_url = ami_to_utf8_easy((char *)rarray[A_URL]);
+ }
+
+ if(rarray[A_FORCE]) {
+ LOG(("FORCE specified on command line"));
+ cli_force = true;
+ }
+
+ if(rarray[A_NSOPTS]) {
+ /* The NSOPTS/M parameter specified in the ReadArgs template is
+ * special. The /M means it collects all arguments that can't
+ * be assigned to any other parameter, and stores them in an
+ * array. We collect these and pass them as a fake argc/argv
+ * to nsoption_commandline().
+ * This trickery is necessary because if ReadArgs() is called
+ * first, nsoption_commandline() can no longer parse (fetch?)
+ * the arguments. If nsoption_commandline() is called first,
+ * then ReadArgs cannot fetch the arguments.
+ */
+ char **p = (char **)rarray[A_NSOPTS];
+ do {
+ LOG(("Arg [%d] assigned to NSOPTS/M by ReadArgs: %s", new_argc, *p));
+ new_argc++;
+ p++;
+ } while(*p != NULL);
+
+ nsoption_commandline(&new_argc, (char **)rarray[A_NSOPTS], NULL);
+ }
+
+ FreeArgs(args);
+ } else {
+ LOG(("ReadArgs failed to parse command line"));
+ }
+}
+
+
+static void gui_init2(int argc, char** argv)
+{
+ struct Screen *screen;
+ BOOL notalreadyrunning;
+ nsurl *url;
+ nserror error;
+ struct browser_window *bw = NULL;
+
notalreadyrunning = ami_arexx_init();
/* Treeview init code ends up calling a font function which needs this */
@@ -808,59 +870,38 @@ static void gui_init2(int argc, char** argv)
ami_cookies_initialise();
ami_global_history_initialise();
- search_web_provider_details(nsoption_int(search_provider));
-
- if(argc) // argc==0 is started from wb
- {
- if(args = ReadArgs(template,rarray,NULL))
- {
- if (notalreadyrunning &&
- (nsoption_bool(startup_no_window) == false))
- ami_openscreenfirst();
-
- if(rarray[A_URL])
- {
- temp_homepage_url = (char *)strdup((char *)rarray[A_URL]);
-
- if(notalreadyrunning)
- {
- error = nsurl_create(temp_homepage_url, &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
- url,
- NULL,
- NULL,
- &bw);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- }
-
- free(temp_homepage_url);
- }
- }
+ search_web_select_provider(nsoption_int(search_provider));
- if(rarray[A_FORCE])
- {
- notalreadyrunning = TRUE;
- }
+ if (notalreadyrunning &&
+ (nsoption_bool(startup_no_window) == false))
+ ami_openscreenfirst();
- FreeArgs(args);
+ if(temp_homepage_url && notalreadyrunning) {
+ error = nsurl_create(temp_homepage_url, &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BW_CREATE_HISTORY,
+ url,
+ NULL,
+ NULL,
+ &bw);
+ nsurl_unref(url);
}
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
+ free(temp_homepage_url);
}
- else
- {
+
+ if(cli_force == true) {
+ notalreadyrunning = TRUE;
+ }
+
+ if(argc == 0) { // WB
struct WBStartup *WBenchMsg = (struct WBStartup *)argv;
struct WBArg *wbarg;
int first=0,i=0;
char fullpath[1024];
- if (notalreadyrunning &&
- (nsoption_bool(startup_no_window) == false))
- ami_openscreenfirst();
-
for(i=0,wbarg=WBenchMsg->sm_ArgList;i<WBenchMsg->sm_NumArgs;i++,wbarg++)
{
if(i==0) continue;
@@ -869,18 +910,22 @@ static void gui_init2(int argc, char** argv)
DevNameFromLock(wbarg->wa_Lock,fullpath,1024,DN_FULLPATH);
AddPart(fullpath,wbarg->wa_Name,1024);
- if(!temp_homepage_url) temp_homepage_url = path_to_url(fullpath);
+ if(!temp_homepage_url) {
+ nsurl *temp_url;
+ if (netsurf_path_to_nsurl(fullpath, &temp_url) == NSERROR_OK) {
+ temp_homepage_url = strdup(nsurl_access(temp_url));
+ nsurl_unref(temp_url);
+ }
+ }
if(notalreadyrunning)
{
error = nsurl_create(temp_homepage_url, &url);
-
if (error == NSERROR_OK) {
if(!first)
{
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -890,8 +935,7 @@ static void gui_init2(int argc, char** argv)
}
else
{
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
url,
NULL,
bw,
@@ -973,8 +1017,7 @@ static void gui_init2(int argc, char** argv)
if(!bw && (nsoption_bool(startup_no_window) == false)) {
error = nsurl_create(nsoption_charp(homepage_url), &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -987,92 +1030,18 @@ 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();
-
- 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)
{
if(back == true)
{
if(browser_window_back_available(gwin->bw))
- history_back(gwin->bw, gwin->bw->history);
+ browser_window_history_back(gwin->bw, false);
}
else
{
if(browser_window_forward_available(gwin->bw))
- history_forward(gwin->bw, gwin->bw->history);
+ browser_window_history_forward(gwin->bw, false);
}
ami_update_buttons(gwin);
@@ -1229,7 +1198,6 @@ bool ami_spacebox_to_ns_coords(struct gui_window_2 *gwin, int *x, int *y,
bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *x, int *y,
int mouse_x, int mouse_y)
{
- int xs, ys;
int ns_x, ns_y;
struct IBox *bbox;
@@ -1386,22 +1354,90 @@ 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;
+}
+
+static void ami_gui_refresh_favicon(void *p)
+{
+ struct gui_window_2 *gwin = (struct gui_window_2 *)p;
+ gui_window_set_icon(gwin->bw->window, gwin->bw->window->favicon);
+}
+
void ami_handle_msg(void)
{
- struct IntuiMessage *message = NULL;
ULONG class,result,storage = 0,x,y,xs,ys,width=800,height=600;
uint16 code,quals;
struct IBox *bbox;
struct nsObject *node;
struct nsObject *nnode;
struct gui_window_2 *gwin = NULL;
- struct MenuItem *item;
struct InputEvent *ie;
struct Node *tabnode;
- int i, nskey;
+ int nskey;
struct browser_window *closedbw;
struct timeval curtime;
static int drag_x_move = 0, drag_y_move = 0;
+ char *utf8 = NULL;
nsurl *url;
if(IsMinListEmpty(window_list))
@@ -1419,121 +1455,60 @@ void ami_handle_msg(void)
gwin = node->objstruct;
- if(node->Type == AMINS_TVWINDOW)
- {
- if(ami_tree_event((struct treeview_window *)gwin))
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ if(node->Type == AMINS_TVWINDOW) {
+ if(ami_tree_event((struct treeview_window *)gwin)) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_FINDWINDOW)
- {
- if(ami_search_event())
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ } else if(node->Type == AMINS_FINDWINDOW) {
+ if(ami_search_event()) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_HISTORYWINDOW)
- {
- if(ami_history_event((struct history_window *)gwin))
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ } else if(node->Type == AMINS_HISTORYWINDOW) {
+ if(ami_history_event((struct history_window *)gwin)) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_PRINTWINDOW)
- {
- if(ami_print_event((struct ami_print_window *)gwin))
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ } else if(node->Type == AMINS_PRINTWINDOW) {
+ if(ami_print_event((struct ami_print_window *)gwin)) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_GUIOPTSWINDOW)
- {
- if(ami_gui_opts_event())
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit with conditions ;) */
- if(scrn) ami_try_quit();
- }
+ } else if(node->Type == AMINS_GUIOPTSWINDOW) {
+ if(ami_gui_opts_event()) {
+ /* last window possibly closed, so exit with conditions ;) */
+ if(scrn) ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_DLWINDOW)
- {
- if(ami_download_window_event((struct gui_download_window *)gwin))
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ } else if(node->Type == AMINS_DLWINDOW) {
+ if(ami_download_window_event((struct gui_download_window *)gwin)) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_LOGINWINDOW)
- {
- if(ami_401login_event((struct gui_login_window *)gwin))
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ } else if(node->Type == AMINS_LOGINWINDOW) {
+ if(ami_401login_event((struct gui_login_window *)gwin)) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
@@ -1759,6 +1734,7 @@ void ami_handle_msg(void)
switch(result & WMHI_GADGETMASK)
{
case GID_TABS:
+ if(gwin->objects[GID_TABS] == NULL) break;
GetAttrs(gwin->objects[GID_TABS],
CLICKTAB_NodeClosed, &tabnode, TAG_DONE);
if(tabnode)
@@ -1780,76 +1756,74 @@ void ami_handle_msg(void)
break;
case GID_ADDTAB:
- {
- nserror error;
-
- error = nsurl_create(nsoption_charp(homepage_url), &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
- url,
- NULL,
- gwin->bw,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- }
- }
+ ami_gui_new_blank_tab(gwin);
break;
case GID_URL:
+ {
+ nserror ret;
+ nsurl *url;
GetAttr(STRINGA_TextVal,
(Object *)gwin->objects[GID_URL],
(ULONG *)&storage);
- if(search_is_url((char *)storage) == false)
- {
- storage = (ULONG)search_web_from_term((char *)storage);
- }
- {
- if (nsurl_create((char *)storage, &url) != NSERROR_OK) {
- warn_user("NoMemory", 0);
- } else {
+ utf8 = ami_to_utf8_easy((const char *)storage);
+
+ ret = search_web_omni(utf8, SEARCH_WEB_OMNI_NONE, &url);
+ ami_utf8_free(utf8);
+ if (ret == NSERROR_OK) {
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
nsurl_unref(url);
- }
}
+ if (ret != NSERROR_OK) {
+ warn_user(messages_get_errorcode(ret), 0);
+ }
+ }
break;
case GID_TOOLBARLAYOUT:
/* Need fixing: never gets here */
- search_web_retrieve_ico(false);
+ search_web_select_provider(-1);
+ break;
+
+ case GID_SEARCH_ICON:
+ GetAttr(CHOOSER_Selected, gwin->objects[GID_SEARCH_ICON], (ULONG *)&storage);
+ search_web_select_provider(storage);
break;
case GID_SEARCHSTRING:
+ {
+ nserror ret;
+ nsurl *url;
+
GetAttr(STRINGA_TextVal,
(Object *)gwin->objects[GID_SEARCHSTRING],
(ULONG *)&storage);
- storage = (ULONG)search_web_from_term((char *)storage);
- {
- if (nsurl_create((char *)storage, &url) != NSERROR_OK) {
- warn_user("NoMemory", 0);
- } else {
+
+ utf8 = ami_to_utf8_easy((const char *)storage);
+
+ ret = search_web_omni(utf8, SEARCH_WEB_OMNI_SEARCHONLY, &url);
+ ami_utf8_free(utf8);
+ if (ret == NSERROR_OK) {
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
- nsurl_unref(url);
- }
+ nsurl_unref(url);
}
+ if (ret != NSERROR_OK) {
+ warn_user(messages_get_errorcode(ret), 0);
+ }
+
+ }
break;
case GID_HOME:
@@ -1860,8 +1834,7 @@ void ami_handle_msg(void)
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1903,7 +1876,6 @@ void ami_handle_msg(void)
GetAttr(STRINGA_TextVal,
(Object *)gwin->objects[GID_URL],
(ULONG *)&storage);
-
if(nsurl_create((const char *)storage, &url) == NSERROR_OK) {
if(hotlist_has_url(url)) {
hotlist_remove_url(url);
@@ -1912,7 +1884,6 @@ void ami_handle_msg(void)
}
nsurl_unref(url);
}
-
ami_gui_update_hotlist_button(gwin);
break;
@@ -1948,8 +1919,7 @@ void ami_handle_msg(void)
error = nsurl_create(nsoption_charp(homepage_url), &urlns);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
urlns,
NULL,
gwin->bw,
@@ -1970,9 +1940,8 @@ void ami_handle_msg(void)
error = nsurl_create(nsoption_charp(homepage_url), &urlns);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
urlns,
NULL,
gwin->bw,
@@ -2064,13 +2033,12 @@ void ami_handle_msg(void)
if(browser_window_reload_available(gwin->bw))
browser_window_reload(gwin->bw,false);
break;
-/*
+
case 'u': // open url
if((nsoption_bool(kiosk_mode) == false))
ActivateLayoutGadget((struct Gadget *)gwin->objects[GID_MAIN],
gwin->win, NULL, (uint32)gwin->objects[GID_URL]);
break;
-*/
}
}
else
@@ -2137,7 +2105,7 @@ void ami_handle_msg(void)
break;
case RAWKEY_HELP: // help
- //ami_help_open(AMI_HELP_GUI);
+ ami_help_open(AMI_HELP_GUI, scrn);
break;
}
}
@@ -2152,7 +2120,7 @@ void ami_handle_msg(void)
case AMINS_WINDOW:
ami_set_border_gadget_balance(gwin);
- ami_update_throbber(gwin,true);
+ ami_throbber_redraw_schedule(0, gwin->bw->window);
if(gwin->tabs)
{
@@ -2164,11 +2132,11 @@ void ami_handle_msg(void)
GetClickTabNodeAttrs(tab,
TNA_UserData, &bw,
TAG_DONE);
- bw->reformat_pending = true;
} while(tab=ntab);
}
- gwin->bw->reformat_pending = true;
+ ami_schedule(0, ami_gui_refresh_favicon, gwin);
+ browser_window_schedule_reformat(gwin->bw);
ami_schedule_redraw(gwin, true);
break;
}
@@ -2180,7 +2148,6 @@ void ami_handle_msg(void)
case WMHI_ICONIFY:
{
- struct DiskObject *dobj;
struct bitmap *bm;
bm = urldb_get_thumbnail(hlcache_handle_get_url(gwin->bw->current_content));
@@ -2238,36 +2205,8 @@ void ami_handle_msg(void)
// ReplyMsg((struct Message *)message);
}
- if(node->Type == AMINS_WINDOW)
- {
- /* Catch any reformats tagged by the core - only used by scale? */
- if(gwin->bw->reformat_pending) {
- ami_schedule_redraw(gwin, true);
- }
-
- if(gwin->bw->window->throbbing)
- ami_update_throbber(gwin,false);
- }
} while(node = nnode);
- if(refresh_search_ico)
- {
- gui_window_set_search_ico(NULL);
- refresh_search_ico = FALSE;
- }
-
- if(refresh_favicon)
- {
- gui_window_set_icon(gwin->bw->window, gwin->bw->window->favicon);
- refresh_favicon = FALSE;
- }
-
- if(refresh_throbber)
- {
- ami_update_throbber(gwin, true);
- refresh_throbber = FALSE;
- }
-
if(ami_menu_window_close)
{
if(ami_menu_window_close == (void *)AMI_MENU_WINDOW_CLOSE_ALL)
@@ -2301,7 +2240,6 @@ void ami_handle_appmsg(void)
int x, y;
struct WBArg *appwinargs;
STRPTR filename;
- char *urlfilename;
int i = 0;
while(appmsg=(struct AppMessage *)GetMsg(appport))
@@ -2333,9 +2271,8 @@ void ami_handle_appmsg(void)
appmsg->am_MouseX, appmsg->am_MouseY) == false)
{
nsurl *url;
- urlfilename = path_to_url(filename);
- if (nsurl_create(urlfilename, &url) != NSERROR_OK) {
+ if (netsurf_path_to_nsurl(filename, &url) != NSERROR_OK) {
warn_user("NoMemory", 0);
}
else
@@ -2345,8 +2282,7 @@ void ami_handle_appmsg(void)
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -2355,9 +2291,8 @@ void ami_handle_appmsg(void)
}
else
{
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
gwin->bw,
@@ -2365,17 +2300,14 @@ void ami_handle_appmsg(void)
}
nsurl_unref(url);
}
-
- free(urlfilename);
}
else
{
if(browser_window_drop_file_at_point(gwin->bw, x, y, filename) == false)
{
nsurl *url;
- urlfilename = path_to_url(filename);
- if (nsurl_create(urlfilename, &url) != NSERROR_OK) {
+ if (netsurf_path_to_nsurl(filename, &url) != NSERROR_OK) {
warn_user("NoMemory", 0);
}
else
@@ -2386,8 +2318,7 @@ void ami_handle_appmsg(void)
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -2396,9 +2327,8 @@ void ami_handle_appmsg(void)
}
else
{
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
gwin->bw,
@@ -2407,7 +2337,6 @@ void ami_handle_appmsg(void)
}
nsurl_unref(url);
}
- free(urlfilename);
}
}
FreeVec(filename);
@@ -2437,8 +2366,7 @@ void ami_handle_applib(void)
error = nsurl_create(nsoption_charp(homepage_url), &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -2455,14 +2383,10 @@ void ami_handle_applib(void)
{
struct ApplicationOpenPrintDocMsg *applibopdmsg =
(struct ApplicationOpenPrintDocMsg *)applibmsg;
- char *tempurl;
-
- tempurl = path_to_url(applibopdmsg->fileName);
- error = nsurl_create(tempurl, &url);
+ error = netsurf_path_to_nsurl(applibopdmsg->fileName, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -2472,7 +2396,6 @@ void ami_handle_applib(void)
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
}
- free(tempurl);
}
break;
@@ -2514,16 +2437,40 @@ void ami_get_msg(void)
ULONG appsig = 1L << appport->mp_SigBit;
ULONG schedulesig = 1L << msgport->mp_SigBit;
ULONG ctrlcsig = SIGBREAKF_CTRL_C;
- ULONG signal;
+ uint32 signal = 0;
+ fd_set read_fd_set, write_fd_set, except_fd_set;
+ int max_fd = -1;
struct TimerRequest *timermsg = NULL;
struct MsgPort *printmsgport = ami_print_get_msgport();
- ULONG printsig = 1L << printmsgport->mp_SigBit;
- ULONG signalmask = winsignal | appsig | schedulesig | rxsig | printsig | applibsig | ctrlcsig;
+ ULONG printsig = 0;
+ ULONG helpsignal = ami_help_signal();
+ if(printmsgport) printsig = 1L << printmsgport->mp_SigBit;
+ uint32 signalmask = winsignal | appsig | schedulesig | rxsig |
+ printsig | applibsig | helpsignal;
+
+ if ((fetcher_fdset(&read_fd_set, &write_fd_set, &except_fd_set, &max_fd) == NSERROR_OK) &&
+ (max_fd != -1)) {
+ /* max_fd is the highest fd in use, but waitselect() needs to know how many
+ * are in use, so we add 1. */
+ if (waitselect(max_fd + 1, &read_fd_set, &write_fd_set, &except_fd_set,
+ NULL, (unsigned int *)&signalmask) != -1) {
+ signal = signalmask;
+ } else {
+ LOG(("waitselect() returned error"));
+ /* \todo Fix Ctrl-C handling.
+ * WaitSelect() from bsdsocket.library returns -1 if the task was
+ * signalled with a Ctrl-C. waitselect() from newlib.library does not.
+ * Adding the Ctrl-C signal to our user signal mask causes a Ctrl-C to
+ * occur sporadically. Otherwise we never get a -1 except on error.
+ * NetSurf still terminates at the Wait() when network activity is over.
+ */
+ }
+ } else {
+ /* If fetcher_fdset fails or no network activity, do it the old fashioned way. */
+ signalmask |= ctrlcsig;
+ signal = Wait(signalmask);
+ }
- signal = Wait(signalmask);
-/*
-printf("sig recvd %ld (%ld %ld %ld %ld %ld %ld)\n", signal, winsignal , appsig , schedulesig , rxsig , printsig , applibsig);
-*/
if(signal & winsignal)
ami_handle_msg();
@@ -2536,39 +2483,28 @@ printf("sig recvd %ld (%ld %ld %ld %ld %ld %ld)\n", signal, winsignal , appsig ,
if(signal & applibsig)
ami_handle_applib();
- if(signal & printsig)
- {
+ if(signal & printsig) {
while(GetMsg(printmsgport)); //ReplyMsg
ami_print_cont();
}
- if(signal & schedulesig)
- {
- if(timermsg = (struct TimerRequest *)GetMsg(msgport))
- {
+ if(signal & schedulesig) {
+ if(timermsg = (struct TimerRequest *)GetMsg(msgport)) {
ReplyMsg((struct Message *)timermsg);
schedule_run(FALSE);
}
}
+ if(signal & helpsignal)
+ ami_help_process();
+
if(signal & ctrlcsig)
- {
ami_quit_netsurf_delayed();
- }
}
-static void ami_gui_fetch_callback(void *p)
-{
- /* This doesn't need to do anything - the scheduled event will
- * send a message to trigger Wait() to return, thereby causing
- * the event function to return, and NetSurf to call
- * hlcache_poll() as part of the usual fetch/event loop.
- */
-}
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
- if(active) schedule(0, ami_gui_fetch_callback, NULL);
ami_get_msg();
}
@@ -2616,8 +2552,8 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw)
GetAttr(CLICKTAB_CurrentNode, (Object *)gwin->objects[GID_TABS],
(ULONG *)&tabnode);
GetClickTabNodeAttrs(tabnode,
- TNA_UserData, &gwin->bw,
- TAG_DONE);
+ TNA_UserData, &gwin->bw,
+ TAG_DONE);
curbw = gwin->bw;
GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER], (ULONG *)&bbox);
@@ -2641,31 +2577,15 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw)
p96RectFill(gwin->win->RPort, bbox->Left, bbox->Top,
bbox->Width+bbox->Left, bbox->Height+bbox->Top, 0xffffffff);
-
browser_window_update(gwin->bw, false);
gui_window_set_scroll(gwin->bw->window,
gwin->bw->window->scrollx, gwin->bw->window->scrolly);
gwin->redraw_scroll = false;
- browser_window_refresh_url_bar(gwin->bw,
- hlcache_handle_get_url(gwin->bw->current_content), gwin->bw->frag_id);
-
+ browser_window_refresh_url_bar(gwin->bw);
ami_gui_update_hotlist_button(gwin);
- }
-}
-
-void ami_try_quit(void)
-{
- if(nsoption_bool(close_no_quit) == false)
- {
- netsurf_quit = true;
- return;
- }
- else
- {
- if(locked_screen == FALSE)
- if(CloseScreen(scrn)) scrn = NULL;
+ ami_throbber_redraw_schedule(0, gwin->bw->window);
}
}
@@ -2675,34 +2595,39 @@ void ami_quit_netsurf(void)
struct nsObject *nnode;
struct gui_window_2 *gwin;
- if(!IsMinListEmpty(window_list))
- {
+ if(!IsMinListEmpty(window_list)) {
node = (struct nsObject *)GetHead((struct List *)window_list);
- do
- {
+ do {
nnode=(struct nsObject *)GetSucc((struct Node *)node);
gwin = node->objstruct;
- switch(node->Type)
- {
+ switch(node->Type) {
case AMINS_TVWINDOW:
ami_tree_close((struct treeview_window *)gwin);
break;
case AMINS_WINDOW:
+ /* This also closes windows that are attached to the
+ * gui_window, such as local history and find. */
ShowWindow(gwin->win, WINDOW_BACKMOST);
ami_close_all_tabs(gwin);
break;
- }
+ case AMINS_GUIOPTSWINDOW:
+ ami_gui_opts_close();
+ break;
+
+ case AMINS_DLWINDOW:
+ ami_download_window_abort((struct gui_download_window *)gwin);
+ break;
+ }
} while(node = nnode);
win_destroyed = true;
}
- if(IsMinListEmpty(window_list))
- {
+ if(IsMinListEmpty(window_list)) {
/* last window closed, so exit */
netsurf_quit = true;
}
@@ -2734,23 +2659,54 @@ void ami_quit_netsurf_delayed(void)
}
}
-void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen)
+void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen, BOOL donotwait)
{
if(scrn == NULL) return;
- if(CloseScreen(scrn)) return;
+ if(CloseScreen(scrn) == TRUE) {
+ if(locked_screen == FALSE) {
+ FreeSignal(screen_signal);
+ screen_signal = -1;
+ scrn = NULL;
+ }
+ return;
+ }
if(locked_screen == TRUE) return;
+ if(donotwait == TRUE) return;
/* If this is our own screen, wait for visitor windows to close */
- LOG(("Waiting for visitor windows to close..."));
- do {
+ if(screen_signal != -1) {
+ ULONG scrnsig = 1 << screen_signal;
+ LOG(("Waiting for visitor windows to close... (signal)"));
+ Wait(scrnsig);
+ }
+
+ while (CloseScreen(scrn) == FALSE) {
+ LOG(("Waiting for visitor windows to close... (polling)"));
Delay(50);
- } while (CloseScreen(scrn) == FALSE);
+ }
+
+ FreeSignal(screen_signal);
+ screen_signal = -1;
+ scrn = NULL;
}
-void gui_quit(void)
+void ami_try_quit(void)
{
- int i;
+ if(!IsMinListEmpty(window_list)) return;
+ if(nsoption_bool(close_no_quit) == false)
+ {
+ netsurf_quit = true;
+ return;
+ }
+ else
+ {
+ ami_gui_close_screen(scrn, locked_screen, TRUE);
+ }
+}
+
+static void gui_quit(void)
+{
ami_theme_throbber_free();
urldb_save(nsoption_charp(url_file));
@@ -2767,9 +2723,10 @@ void gui_quit(void)
ami_free_layers(&browserglob);
ami_close_fonts();
+ ami_help_free();
LOG(("Closing screen"));
- ami_gui_close_screen(scrn, locked_screen);
+ ami_gui_close_screen(scrn, locked_screen, FALSE);
FreeVec(nsscreentitle);
LOG(("Freeing menu items"));
@@ -2781,16 +2738,12 @@ void gui_quit(void)
LOG(("Freeing clipboard"));
ami_clipboard_free();
- ami_print_free();
-
FreeSysObject(ASOT_PORT,appport);
FreeSysObject(ASOT_PORT,sport);
- //ami_help_free();
ami_file_req_free();
-
ami_openurl_close();
- FreeStringClass(urlStringClass);
+ FreeStringClass(urlStringClass);
if(IApplication) DropInterface((struct Interface *)IApplication);
if(ApplicationBase) CloseLibrary(ApplicationBase);
@@ -2806,9 +2759,40 @@ void gui_quit(void)
FreeVec(current_user_options);
FreeVec(current_user_dir);
+ FreeVec(current_user_faviconcache);
FreeVec(current_user);
}
+char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail)
+{
+ STRPTR filename = NULL;
+ BPTR lock = 0;
+
+ if (filename = ASPrintf("%s/%x", current_user_faviconcache, nsurl_hash(url))) {
+ LOG(("favicon cache location: %s", filename));
+
+ if (only_if_avail == true) {
+ if(lock = Lock(filename, ACCESS_READ)) {
+ UnLock(lock);
+ return filename;
+ }
+ } else {
+ return filename;
+ }
+ }
+ return NULL;
+}
+
+static void ami_gui_cache_favicon(nsurl *url, struct bitmap *favicon)
+{
+ STRPTR filename = NULL;
+
+ if (filename = ami_gui_get_cache_favicon_name(url, false)) {
+ if(favicon) bitmap_save(favicon, filename, AMI_BITMAP_FORCE_OVERWRITE);
+ FreeVec(filename);
+ }
+}
+
void ami_gui_update_hotlist_button(struct gui_window_2 *gwin)
{
char *url;
@@ -2822,6 +2806,9 @@ void ami_gui_update_hotlist_button(struct gui_window_2 *gwin)
if(hotlist_has_url(nsurl)) {
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_FAVE], gwin->win, NULL,
BUTTON_RenderImage, gwin->objects[GID_FAVE_RMV], TAG_DONE);
+
+ if (gwin->bw->window->favicon)
+ ami_gui_cache_favicon(nsurl, content_get_bitmap(gwin->bw->window->favicon));
} else {
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_FAVE], gwin->win, NULL,
BUTTON_RenderImage, gwin->objects[GID_FAVE_ADD], TAG_DONE);
@@ -2961,7 +2948,6 @@ void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
gwin->win, NULL, TRUE);
if(gwin->bw) {
- gwin->bw->reformat_pending = true;
ami_schedule_redraw(gwin, true);
}
}
@@ -3003,7 +2989,6 @@ void ami_gui_hotlist_toolbar_remove(struct gui_window_2 *gwin)
RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
gwin->win, NULL, TRUE);
- gwin->bw->reformat_pending = true;
ami_schedule_redraw(gwin, true);
}
@@ -3032,7 +3017,10 @@ void ami_gui_hotlist_toolbar_update(struct gui_window_2 *gwin)
}
}
-void ami_gui_hotlist_toolbar_update_all(void)
+/**
+ * Update hotlist toolbar and recreate the menu for all windows
+ */
+void ami_gui_hotlist_update_all(void)
{
struct nsObject *node;
struct nsObject *nnode;
@@ -3049,6 +3037,7 @@ void ami_gui_hotlist_toolbar_update_all(void)
if(node->Type == AMINS_WINDOW)
{
ami_gui_hotlist_toolbar_update(gwin);
+ ami_menu_refresh(gwin);
}
} while(node = nnode);
}
@@ -3099,6 +3088,11 @@ void ami_toggletabbar(struct gui_window_2 *gwin, bool show)
IDoMethod(gwin->objects[GID_TABLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_ADDTAB]);
+
+ /* NB: We are NULLing these, but not disposing them as
+ * that causes an Intuition deadlock (TODO) */
+ gwin->objects[GID_TABS] = NULL;
+ gwin->objects[GID_ADDTAB] = NULL;
}
FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]);
@@ -3106,10 +3100,7 @@ void ami_toggletabbar(struct gui_window_2 *gwin, bool show)
RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN],
gwin->win, NULL, TRUE);
- if(gwin->bw) {
- gwin->bw->reformat_pending = true;
- ami_schedule_redraw(gwin, true);
- }
+ if(gwin->bw) browser_window_update(gwin->bw, false);
}
void ami_gui_tabs_toggle_all(void)
@@ -3139,12 +3130,41 @@ void ami_gui_tabs_toggle_all(void)
} while(node = nnode);
}
-struct gui_window *gui_create_browser_window(struct browser_window *bw,
- struct browser_window *clone, bool new_tab)
+void ami_gui_search_ico_refresh(void *p)
+{
+ search_web_select_provider(-1);
+}
+
+nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
+{
+ nsurl *url;
+ nserror error;
+ struct browser_window *bw = NULL;
+
+ error = nsurl_create(nsoption_charp(homepage_url), &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
+ url,
+ NULL,
+ gwin->bw,
+ &bw);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ return error;
+ }
+
+ return NSERROR_OK;
+}
+
+static struct gui_window *
+gui_window_create(struct browser_window *bw,
+ struct gui_window *existing,
+ gui_window_create_flags flags)
{
struct gui_window *g = NULL;
- bool closegadg=TRUE;
- struct Node *node;
ULONG curx=nsoption_int(window_x),cury=nsoption_int(window_y),curw=nsoption_int(window_width),curh=nsoption_int(window_height);
char nav_west[100],nav_west_s[100],nav_west_g[100];
char nav_east[100],nav_east_s[100],nav_east_g[100];
@@ -3160,19 +3180,16 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
if (!scrn) ami_openscreenfirst();
- if (nsoption_bool(kiosk_mode)) new_tab = false;
+ if (nsoption_bool(kiosk_mode)) flags &= ~GW_CREATE_TAB;
if (nsoption_bool(resize_with_contents)) idcmp_sizeverify = 0;
bw->scale = 1.0;
- if(clone)
+ if(existing)
{
- if(clone->window)
- {
- curx=clone->window->shared->win->LeftEdge;
- cury=clone->window->shared->win->TopEdge;
- curw=clone->window->shared->win->Width;
- curh=clone->window->shared->win->Height;
- }
+ curx=existing->shared->win->LeftEdge;
+ cury=existing->shared->win->TopEdge;
+ curw=existing->shared->win->Width;
+ curh=existing->shared->win->Height;
}
g = AllocVecTags(sizeof(struct gui_window), AVT_ClearWithValue, 0, TAG_DONE);
@@ -3186,13 +3203,15 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
NewList(&g->dllist);
g->deferred_rects = NewObjList();
- if(new_tab && clone)
+ if((flags & GW_CREATE_TAB) && existing)
{
- g->shared = clone->window->shared;
+ g->shared = existing->shared;
g->tab = g->shared->next_tab;
+ g->shared->tabs++; /* do this early so functions know to update the tabs */
- if((g->shared->tabs == 1) && (nsoption_bool(tab_always_show) == false))
+ if((g->shared->tabs == 2) && (nsoption_bool(tab_always_show) == false)) {
ami_toggletabbar(g->shared, true);
+ }
SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],
g->shared->win, NULL,
@@ -3211,12 +3230,12 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
}
else
{
- struct Node *insert_after = clone->window->tab_node;
+ struct Node *insert_after = existing->tab_node;
- if(clone->window->last_new_tab)
- insert_after = clone->window->last_new_tab;
+ if(existing->last_new_tab)
+ insert_after = existing->last_new_tab;
Insert(&g->shared->tab_list, g->tab_node, insert_after);
- clone->window->last_new_tab = g->tab_node;
+ existing->last_new_tab = g->tab_node;
}
RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],
@@ -3234,12 +3253,12 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
if(ClickTabBase->lib_Version < 53)
RethinkLayout((struct Gadget *)g->shared->objects[GID_TABLAYOUT],g->shared->win,NULL,TRUE);
- g->shared->tabs++;
g->shared->next_tab++;
if(nsoption_bool(new_tab_is_active)) ami_switch_tab(g->shared,false);
ami_update_buttons(g->shared);
+ ami_schedule(0, ami_gui_refresh_favicon, g->shared);
return g;
}
@@ -3257,9 +3276,6 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
g->shared->scrollerhook.h_Entry = (void *)ami_scroller_hook;
g->shared->scrollerhook.h_Data = g->shared;
- g->shared->search_ico_hook.h_Entry = (void *)ami_set_search_ico_render_hook;
- g->shared->search_ico_hook.h_Data = g->shared;
-
g->shared->favicon_hook.h_Entry = (void *)ami_set_favicon_render_hook;
g->shared->favicon_hook.h_Data = g->shared;
@@ -3294,6 +3310,9 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
TAG_DONE);
AddTail(&g->shared->tab_list,g->tab_node);
+ g->shared->web_search_list = ami_gui_opts_websearch();
+ g->shared->search_bm = NULL;
+
g->shared->tabs=1;
g->shared->next_tab=1;
@@ -3403,12 +3422,12 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
}
g->shared->objects[OID_MAIN] = WindowObject,
- WA_ScreenTitle,nsscreentitle,
- WA_Activate, TRUE,
- WA_DepthGadget, TRUE,
- WA_DragBar, TRUE,
- WA_CloseGadget, TRUE,
- WA_SizeGadget, TRUE,
+ WA_ScreenTitle,nsscreentitle,
+ WA_Activate, TRUE,
+ WA_DepthGadget, TRUE,
+ WA_DragBar, TRUE,
+ WA_CloseGadget, TRUE,
+ WA_SizeGadget, TRUE,
WA_Top,cury,
WA_Left,curx,
WA_Width,curw,
@@ -3417,12 +3436,12 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
WA_ReportMouse,TRUE,
refresh_mode, TRUE,
WA_SizeBBottom, TRUE,
- WA_IDCMP, IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
- IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
- IDCMP_RAWKEY | idcmp_sizeverify |
- IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
- IDCMP_REFRESHWINDOW |
- IDCMP_ACTIVEWINDOW | IDCMP_EXTENDEDMOUSE,
+ WA_IDCMP, IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
+ IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
+ IDCMP_RAWKEY | idcmp_sizeverify |
+ IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
+ IDCMP_REFRESHWINDOW |
+ IDCMP_ACTIVEWINDOW | IDCMP_EXTENDEDMOUSE,
WINDOW_IconifyGadget, iconifygadget,
WINDOW_NewMenu, g->shared->menu,
WINDOW_MenuUserData, WGUD_HOOK,
@@ -3435,8 +3454,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
WINDOW_BuiltInScroll, TRUE,
WINDOW_GadgetHelp, TRUE,
WINDOW_UserData, g->shared,
- WINDOW_ParentGroup, g->shared->objects[GID_MAIN] = VGroupObject,
- LAYOUT_SpaceOuter, TRUE,
+ WINDOW_ParentGroup, g->shared->objects[GID_MAIN] = VGroupObject,
+ LAYOUT_SpaceOuter, TRUE,
LAYOUT_AddChild, g->shared->objects[GID_TOOLBARLAYOUT] = HGroupObject,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_AddChild, g->shared->objects[GID_BACK] = ButtonObject,
@@ -3531,7 +3550,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
GA_TabCycle, TRUE,
STRINGA_Buffer, g->shared->svbuffer,
STRINGVIEW_Header, URLHistory_GetList(),
- StringEnd,
+ TAG_DONE),
LAYOUT_AddChild, g->shared->objects[GID_FAVE] = ButtonObject,
GA_ID, GID_FAVE,
@@ -3548,13 +3567,13 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
LAYOUT_WeightBar, TRUE,
LAYOUT_AddChild, HGroupObject,
LAYOUT_VertAlignment, LALIGN_CENTER,
- LAYOUT_AddChild, g->shared->objects[GID_SEARCH_ICON] = SpaceObject,
+ LAYOUT_AddChild, g->shared->objects[GID_SEARCH_ICON] = ChooserObject,
GA_ID, GID_SEARCH_ICON,
- SPACE_MinWidth, 16,
- SPACE_MinHeight, 16,
- SPACE_Transparent, FALSE,
- SPACE_RenderHook, &g->shared->search_ico_hook,
- SpaceEnd,
+ GA_RelVerify, TRUE,
+ CHOOSER_DropDown, TRUE,
+ CHOOSER_Labels, g->shared->web_search_list,
+ CHOOSER_MaxLabels, 40, /* Same as options GUI */
+ ChooserEnd,
CHILD_WeightedWidth,0,
CHILD_WeightedHeight,0,
LAYOUT_AddChild, g->shared->objects[GID_SEARCHSTRING] =StringObject,
@@ -3761,7 +3780,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
glob = &browserglob;
if(locked_screen) UnlockPubScreen(NULL,scrn);
- search_web_retrieve_ico(false);
+
+ ami_schedule(0, ami_gui_search_ico_refresh, NULL);
ScreenToFront(scrn);
@@ -3844,7 +3864,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;
@@ -3898,6 +3918,7 @@ void gui_window_destroy(struct gui_window *g)
g->shared->tabs--;
ami_switch_tab(g->shared,true);
+ ami_schedule(0, ami_gui_refresh_favicon, g->shared);
if((g->shared->tabs == 1) && (nsoption_bool(tab_always_show) == false))
ami_toggletabbar(g->shared, false);
@@ -3925,6 +3946,9 @@ void gui_window_destroy(struct gui_window *g)
DisposeObject(g->shared->objects[GID_FAVE_ADD]);
DisposeObject(g->shared->objects[GID_FAVE_RMV]);
+ ami_gui_opts_websearch_free(g->shared->web_search_list);
+ if(g->shared->search_bm) DisposeObject(g->shared->search_bm);
+
ami_free_menulabs(g->shared);
free(g->shared->wintitle);
ami_utf8_free(g->shared->status);
@@ -3950,7 +3974,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;
@@ -3961,7 +3985,7 @@ void gui_window_set_title(struct gui_window *g, const char *title)
utf8title = ami_utf8_easy((char *)title);
- if(g->tab_node && (g->shared->tabs > 1))
+ if(g->tab_node) // && (g->shared->tabs > 1))
{
node = g->tab_node;
@@ -3973,8 +3997,8 @@ void gui_window_set_title(struct gui_window *g, const char *title)
TAG_DONE);
SetClickTabNodeAttrs(node, TNA_Text, utf8title,
- TNA_HintInfo, utf8title,
- TAG_DONE);
+ TNA_HintInfo, utf8title,
+ TAG_DONE);
RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],
g->shared->win, NULL,
@@ -4008,7 +4032,7 @@ static void ami_redraw_callback(void *p)
{
struct gui_window_2 *gwin = (struct gui_window_2 *)p;
- if(gwin->redraw_required || gwin->bw->reformat_pending) {
+ if(gwin->redraw_required) {
ami_do_redraw(gwin);
}
@@ -4032,19 +4056,18 @@ static void ami_redraw_callback(void *p)
*/
void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw)
{
- int cs = 0;
+ int ms = 0;
if(full_redraw) gwin->redraw_required = true;
if(gwin->redraw_scheduled == true) return;
- if(gwin->bw->reformat_pending) cs = nsoption_int(reformat_delay);
- schedule(cs, ami_redraw_callback, gwin);
+ ami_schedule(ms, ami_redraw_callback, gwin);
gwin->redraw_scheduled = true;
}
static void ami_schedule_redraw_remove(struct gui_window_2 *gwin)
{
- schedule_remove(ami_redraw_callback, gwin);
+ ami_schedule(-1, ami_redraw_callback, gwin);
}
static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy,
@@ -4147,9 +4170,7 @@ static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw
struct IBox *bbox;
ULONG cur_tab = 0;
ULONG sx, sy;
- struct rect clip;
- struct RastPort *temprp;
- int posx, posy;
+
struct redraw_context ctx = {
.interactive = true,
.background_images = true,
@@ -4175,7 +4196,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;
@@ -4221,8 +4242,8 @@ static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw)
static bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
const struct rect *new_rect)
{
- struct nsObject *node;
- struct nsObject *nnode;
+struct nsObject *node;
+struct nsObject *nnode;
struct rect *rect;
if(IsMinListEmpty(deferred_rects)) return true;
@@ -4253,7 +4274,7 @@ static bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_re
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;
@@ -4270,15 +4291,27 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect)
ami_schedule_redraw(g->shared, false);
}
+/**
+ * callback from core to reformat a window.
+ */
+static void amiga_window_reformat(struct gui_window *gw)
+{
+ struct IBox *bbox;
+
+ if (gw != NULL) {
+ GetAttr(SPACE_AreaBox, (Object *)gw->shared->objects[GID_BROWSER], (ULONG *)&bbox);
+ browser_window_reformat(gw->shared->bw, false, bbox->Width, bbox->Height);
+
+ gw->shared->redraw_scroll = false;
+ }
+}
+
static void ami_do_redraw(struct gui_window_2 *gwin)
{
- struct Region *reg = NULL;
struct Rectangle rect;
- hlcache_handle *c;
ULONG hcurrent,vcurrent,xoffset,yoffset,width=800,height=600,x0=0,y0=0;
struct IBox *bbox;
ULONG oldh = gwin->oldh, oldv=gwin->oldv;
- bool morescroll = false;
struct RastPort *temprp;
if(browser_window_redraw_ready(gwin->bw) == false) return;
@@ -4290,20 +4323,11 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
gwin->bw->window->scrollx = hcurrent;
gwin->bw->window->scrolly = vcurrent;
- c = gwin->bw->current_content;
-
width=bbox->Width;
height=bbox->Height;
xoffset=bbox->Left;
yoffset=bbox->Top;
- if(gwin->bw->reformat_pending)
- {
- browser_window_reformat(gwin->bw, false, width, height);
- gwin->bw->reformat_pending = false;
- gwin->redraw_scroll = false;
- }
-
if(gwin->redraw_scroll)
{
if((abs(vcurrent-oldv) > height) || (abs(hcurrent-oldh) > width))
@@ -4316,7 +4340,6 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
if(gwin->redraw_scroll)
{
struct rect rect;
- int x0, y0, x1, y1;
gwin->bw->window->c_h_temp = gwin->bw->window->c_h;
gui_window_remove_caret(gwin->bw->window);
@@ -4407,7 +4430,7 @@ void ami_refresh_window(struct gui_window_2 *gwin)
struct IBox *bbox;
int x0, x1, y0, y1, sx, sy;
- struct RegionRectangle *regrect, *nregrect;
+ struct RegionRectangle *regrect;
sx = gwin->bw->window->scrollx;
sy = gwin->bw->window->scrolly;
@@ -4471,13 +4494,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;
@@ -4536,13 +4559,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;
@@ -4560,7 +4577,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;
@@ -4607,7 +4624,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;
@@ -4646,7 +4663,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;
@@ -4665,83 +4682,23 @@ 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)
{
- refresh_favicon = TRUE;
+ ami_schedule(0, ami_gui_refresh_favicon, hook->h_Data);
return 0;
}
/**
- * 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()
+ * Gui callback when search provider details are updated.
+ *
+ * \param provider_name The providers name.
+ * \param ico_bitmap The icon bitmap representing the provider.
+ * \return NSERROR_OK on success else error code.
*/
-void gui_window_set_search_ico(hlcache_handle *ico)
+static nserror gui_search_web_provider_update(const char *provider_name,
+ struct bitmap *ico_bitmap)
{
struct BitMap *bm = NULL;
struct IBox *bbox;
@@ -4749,16 +4706,13 @@ void gui_window_set_search_ico(hlcache_handle *ico)
struct nsObject *node;
struct nsObject *nnode;
struct gui_window_2 *gwin;
- char fname[100];
- struct bitmap *ico_bitmap;
- if(IsMinListEmpty(window_list)) return;
- if(nsoption_bool(kiosk_mode) == true) return;
+ if(IsMinListEmpty(window_list)) return NSERROR_BAD_PARAMETER;
+ if(nsoption_bool(kiosk_mode) == true) return NSERROR_BAD_PARAMETER;
- if (ico == NULL) ico = search_web_ico();
- ico_bitmap = content_get_bitmap(ico);
- if ((ico != NULL) && (ico_bitmap != NULL))
+ if (ico_bitmap != NULL) {
bm = ami_bitmap_get_native(ico_bitmap, 16, 16, NULL);
+ }
node = (struct nsObject *)GetHead((struct List *)window_list);
@@ -4768,63 +4722,36 @@ void gui_window_set_search_ico(hlcache_handle *ico)
if(node->Type == AMINS_WINDOW)
{
- GetAttr(SPACE_AreaBox, gwin->objects[GID_SEARCH_ICON], (ULONG *)&bbox);
+ if(gwin->search_bm != NULL)
+ DisposeObject(gwin->search_bm);
+
+ gwin->search_bm = BitMapObject,
+ BITMAP_Screen, scrn,
+ BITMAP_Width, 16,
+ BITMAP_Height, 16,
+ BITMAP_BitMap, bm,
+ BitMapEnd;
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCH_ICON],
gwin->win, NULL,
- GA_HintInfo, search_web_provider_name(),
+ GA_HintInfo, provider_name,
+ GA_Image, gwin->search_bm,
TAG_DONE);
-
- EraseRect(gwin->win->RPort, bbox->Left, bbox->Top,
- bbox->Left+16, bbox->Top+16);
-
- if(bm)
- {
- ULONG tag, tag_data, minterm;
-
- if(ami_plot_screen_is_palettemapped() == false) {
- tag = BLITA_UseSrcAlpha;
- tag_data = !ico_bitmap->opaque;
- minterm = 0xc0;
- } else {
- tag = BLITA_MaskPlane;
- tag_data = (ULONG)ami_bitmap_get_mask(ico_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, gwin->win->RPort,
- BLITA_SrcType, BLITT_BITMAP,
- BLITA_DestType, BLITT_RASTPORT,
- BLITA_Minterm, minterm,
- tag, tag_data,
- TAG_DONE);
- }
}
} while(node = nnode);
-}
-static uint32 ami_set_search_ico_render_hook(struct Hook *hook, APTR space,
- struct gpRender *msg)
-{
- refresh_search_ico = TRUE;
- return 0;
+ return NSERROR_OK;
}
static uint32 ami_set_throbber_render_hook(struct Hook *hook, APTR space,
struct gpRender *msg)
{
- refresh_throbber = TRUE;
+ struct gui_window_2 *gwin = hook->h_Data;
+ ami_throbber_redraw_schedule(0, gwin->bw->window);
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;
@@ -4861,11 +4788,8 @@ 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;
-
if(!g) return;
if(g->c_h == 0) return;
@@ -4878,7 +4802,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;
@@ -4898,12 +4822,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;
@@ -4929,9 +4848,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
ULONG gid;
struct gui_window_2 *gwin = hook->h_Data;
struct IntuiWheelData *wheel;
- Object *reqrefresh = NULL;
struct Node *node = NULL;
- char *urltxt;
nsurl *url;
switch(msg->Class)
@@ -4955,8 +4872,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
GetSpeedButtonNodeAttrs(node, SBNA_UserData, (ULONG *)&url, TAG_DONE);
if(gwin->key_state & BROWSER_MOUSE_MOD_2) {
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_TAB,
+ browser_window_create(BW_CREATE_TAB,
url,
NULL,
gwin->bw,
@@ -4965,8 +4881,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -5006,8 +4921,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y)
{
struct IBox *bbox;
- ULONG xs,ys,width,height;
- int box_x=0,box_y=0;
+ ULONG xs, ys, width, height;
struct contextual_content data;
GetAttr(SPACE_AreaBox, (Object *)gwin->objects[GID_BROWSER],
@@ -5126,3 +5040,192 @@ void ami_gui_splash_close(Object *win_obj)
{
if(win_obj) DisposeObject(win_obj);
}
+
+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));
+
+ if(AslRequestTags(filereq,
+ ASLFR_Window, g->shared->win,
+ ASLFR_SleepWindow, TRUE,
+ ASLFR_TitleText, messages_get("NetSurf"),
+ ASLFR_Screen, scrn,
+ ASLFR_DoSaveMode, FALSE,
+ TAG_DONE)) {
+ char fname[1024];
+ strlcpy(fname, filereq->fr_Drawer, 1024);
+ AddPart(fname, filereq->fr_File, 1024);
+ browser_window_set_gadget_filename(g->shared->bw, gadget, fname);
+ }
+}
+
+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,
+ .reformat = amiga_window_reformat,
+
+ .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_fetch_table amiga_fetch_table = {
+ .filetype = fetch_filetype,
+
+ .get_resource_url = gui_get_resource_url,
+};
+
+static struct gui_search_web_table amiga_search_web_table = {
+ .provider_update = gui_search_web_provider_update,
+};
+
+static struct gui_browser_table amiga_browser_table = {
+ .poll = gui_poll,
+ .schedule = ami_schedule,
+
+ .quit = gui_quit,
+ .launch_url = gui_launch_url,
+ .create_form_select_menu = gui_create_form_select_menu,
+ .cert_verify = gui_cert_verify,
+ .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];
+ STRPTR current_user_cache = NULL;
+ BPTR lock = 0;
+ int32 user = 0;
+ nserror ret;
+ Object *splash_window = ami_gui_splash_open();
+ struct netsurf_table amiga_table = {
+ .browser = &amiga_browser_table,
+ .window = &amiga_window_table,
+ .clipboard = amiga_clipboard_table,
+ .download = amiga_download_table,
+ .fetch = &amiga_fetch_table,
+ .file = amiga_file_table,
+ .utf8 = amiga_utf8_table,
+ .search = amiga_search_table,
+ .search_web = &amiga_search_web_table,
+ .llcache = filesystem_llcache_table,
+ };
+
+ signal(SIGINT, SIG_IGN);
+
+ ret = netsurf_register(&amiga_table);
+ if (ret != NSERROR_OK) {
+ die("NetSurf operation table failed registration");
+ }
+
+ /* 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);
+ current_user_cache = ASPrintf("%s/Cache", current_user_dir);
+ current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir);
+
+ if(lock = CreateDirTree(current_user_cache)) UnLock(lock);
+ if(lock = CreateDirTree(current_user_faviconcache)) UnLock(lock);
+
+ 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();
+ ret = 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);
+ ami_gui_commandline(&argc, argv); /* calls nsoption_commandline */
+
+ if (ami_locate_resource(messages, "Messages") == false)
+ die("Cannot open Messages file");
+ ret = netsurf_init(messages, current_user_cache);
+ if (ret != NSERROR_OK) {
+ die("NetSurf failed to initialise");
+ }
+
+ if(current_user_cache != NULL) FreeVec(current_user_cache);
+ ret = amiga_icon_init();
+
+ search_web_init(nsoption_charp(search_engines_file));
+
+ 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/gui.h b/amiga/gui.h
index 85e5854ea..c106455d1 100755
--- a/amiga/gui.h
+++ b/amiga/gui.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2012 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2014 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -111,6 +111,8 @@ struct gui_window_2 {
ULONG hotlist_items;
char *hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX];
struct List hotlist_toolbar_list;
+ struct List *web_search_list;
+ Object *search_bm;
char *svbuffer;
char *status;
char *wintitle;
@@ -120,7 +122,6 @@ struct gui_window_2 {
BOOL rmbtrapped;
struct AppIcon *appicon; /* iconify appicon */
struct DiskObject *dobj; /* iconify appicon */
- struct Hook search_ico_hook;
struct Hook favicon_hook;
struct Hook throbber_hook;
gui_drag_type drag_op;
@@ -153,6 +154,7 @@ struct gui_window
void ami_get_msg(void);
void ami_close_all_tabs(struct gui_window_2 *gwin);
+void ami_try_quit(void);
void ami_quit_netsurf(void);
void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw);
STRPTR ami_locale_langs(void);
@@ -160,10 +162,12 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie);
bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y);
BOOL ami_gadget_hit(Object *obj, int x, int y);
void ami_gui_history(struct gui_window_2 *gwin, bool back);
-void ami_gui_hotlist_toolbar_update_all(void);
+void ami_gui_hotlist_update_all(void);
void ami_gui_tabs_toggle_all(void);
bool ami_locate_resource(char *fullpath, const char *file);
void ami_gui_update_hotlist_button(struct gui_window_2 *gwin);
+nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin);
+char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail);
struct TextFont *origrpfont;
struct MinList *window_list;
@@ -175,4 +179,6 @@ struct browser_window *curbw;
struct gui_globals browserglob;
uint32 ami_appid;
BOOL ami_autoscroll;
+BOOL popupmenu_lib_ok;
#endif
+
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index 1bf20ad47..50f7b7cfd 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -198,7 +198,7 @@ enum
#define OPTS_MAX_TABS 10
#define OPTS_MAX_SCREEN 4
#define OPTS_MAX_PROXY 5
-#define OPTS_MAX_NATIVEBM 3
+#define OPTS_MAX_NATIVEBM 4
#define OPTS_MAX_DITHER 4
struct ami_gui_opts_window {
@@ -216,10 +216,7 @@ CONST_STRPTR nativebmopts[OPTS_MAX_NATIVEBM];
CONST_STRPTR ditheropts[OPTS_MAX_DITHER];
CONST_STRPTR fontopts[6];
CONST_STRPTR gadlab[OPTS_LAST];
-STRPTR *websearch_list;
-
-STRPTR *ami_gui_opts_websearch(void);
-void ami_gui_opts_websearch_free(STRPTR *websearchlist);
+struct List *websearch_list;
void ami_gui_opts_setup(void)
{
@@ -299,7 +296,7 @@ void ami_gui_opts_setup(void)
gadlab[GID_OPTS_FONT_MINSIZE] = (char *)ami_utf8_easy((char *)messages_get("Minimum"));
gadlab[GID_OPTS_FONT_ANTIALIASING] = (char *)ami_utf8_easy((char *)messages_get("FontAntialiasing"));
gadlab[GID_OPTS_CACHE_MEM] = (char *)ami_utf8_easy((char *)messages_get("Size"));
- gadlab[GID_OPTS_CACHE_DISC] = (char *)ami_utf8_easy((char *)messages_get("Duration"));
+ gadlab[GID_OPTS_CACHE_DISC] = (char *)ami_utf8_easy((char *)messages_get("Size"));
gadlab[GID_OPTS_OVERWRITE] = (char *)ami_utf8_easy((char *)messages_get("ConfirmOverwrite"));
gadlab[GID_OPTS_NOTIFY] = (char *)ami_utf8_easy((char *)messages_get("DownloadNotify"));
gadlab[GID_OPTS_DLDIR] = (char *)ami_utf8_easy((char *)messages_get("DownloadDir"));
@@ -406,9 +403,12 @@ void ami_gui_opts_open(void)
BOOL proxyhostdisabled = TRUE, proxyauthdisabled = TRUE, proxybypassdisabled = FALSE;
BOOL disableanims, animspeeddisabled = FALSE, acceptlangdisabled = FALSE;
BOOL scaleselected = nsoption_bool(scale_quality), scaledisabled = FALSE;
+ BOOL ditherdisable = TRUE;
BOOL download_notify_disabled = FALSE;
BOOL ptr_disable = FALSE;
char animspeed[10];
+ char *homepage_url_lc = ami_utf8_easy(nsoption_charp(homepage_url));
+
struct TextAttr fontsans, fontserif, fontmono, fontcursive, fontfantasy;
if(gow && gow->win)
@@ -446,6 +446,9 @@ void ami_gui_opts_open(void)
screenmodeid = strtoul(nsoption_charp(screen_modeid),NULL,0);
}
+ if(ami_plot_screen_is_palettemapped() == true)
+ ditherdisable = FALSE;
+
if(nsoption_bool(http_proxy) == true)
{
proxytype = nsoption_int(http_proxy_auth) + 1;
@@ -553,7 +556,7 @@ void ami_gui_opts_open(void)
LAYOUT_AddChild, gow->objects[GID_OPTS_HOMEPAGE] = StringObject,
GA_ID, GID_OPTS_HOMEPAGE,
GA_RelVerify, TRUE,
- STRINGA_TextVal, nsoption_charp(homepage_url),
+ STRINGA_TextVal, homepage_url_lc,
STRINGA_BufferPos,0,
StringEnd,
CHILD_Label, LabelObject,
@@ -907,6 +910,7 @@ void ami_gui_opts_open(void)
LAYOUT_AddChild, gow->objects[GID_OPTS_DITHERQ] = ChooserObject,
GA_ID, GID_OPTS_DITHERQ,
GA_RelVerify, TRUE,
+ GA_Disabled, ditherdisable,
CHOOSER_PopUp, TRUE,
CHOOSER_LabelArray, ditheropts,
CHOOSER_Selected, nsoption_int(dither_quality),
@@ -1150,15 +1154,14 @@ void ami_gui_opts_open(void)
LAYOUT_AddChild, gow->objects[GID_OPTS_CACHE_DISC] = IntegerObject,
GA_ID, GID_OPTS_CACHE_DISC,
GA_RelVerify, TRUE,
- GA_Disabled, TRUE,
- INTEGER_Number, nsoption_int(disc_cache_age),
+ INTEGER_Number, nsoption_uint(disc_cache_size) / 1048576,
INTEGER_Minimum, 0,
- INTEGER_Maximum, 366,
+ INTEGER_Maximum, 4096,
INTEGER_Arrows, TRUE,
IntegerEnd,
CHILD_WeightedWidth, 0,
CHILD_Label, LabelObject,
- LABEL_Text, gadlab[LAB_OPTS_DAYS],
+ LABEL_Text, gadlab[LAB_OPTS_MB],
LabelEnd,
LayoutEnd,
CHILD_Label, LabelObject,
@@ -1306,7 +1309,7 @@ void ami_gui_opts_open(void)
GA_ID, GID_OPTS_SEARCH_PROV,
GA_RelVerify, TRUE,
CHOOSER_PopUp, TRUE,
- CHOOSER_LabelArray, websearch_list,
+ CHOOSER_Labels, websearch_list,
CHOOSER_Selected, nsoption_int(search_provider),
CHOOSER_MaxLabels, 40,
ChooserEnd,
@@ -1328,6 +1331,7 @@ void ami_gui_opts_open(void)
GA_RelVerify, TRUE,
GA_Text, gadlab[GID_OPTS_CONTEXTMENU],
GA_Selected, nsoption_bool(context_menu),
+ GA_Disabled, !popupmenu_lib_ok,
CheckBoxEnd,
#endif
LAYOUT_AddChild, gow->objects[GID_OPTS_FASTSCROLL] = CheckBoxObject,
@@ -1523,6 +1527,7 @@ void ami_gui_opts_open(void)
gow->node = AddObject(window_list,AMINS_GUIOPTSWINDOW);
gow->node->objstruct = gow;
}
+ ami_utf8_free(homepage_url_lc);
}
void ami_gui_opts_use(bool save)
@@ -1537,7 +1542,7 @@ void ami_gui_opts_use(bool save)
ami_update_pointer(gow->win, GUI_POINTER_WAIT);
GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_HOMEPAGE],(ULONG *)&data);
- nsoption_set_charp(homepage_url, (char *)strdup((char *)data));
+ nsoption_set_charp(homepage_url, (char *)ami_to_utf8_easy((char *)data));
GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_CONTENTLANG],(ULONG *)&data);
nsoption_set_charp(accept_language, (char *)strdup((char *)data));
@@ -1742,7 +1747,8 @@ void ami_gui_opts_use(bool save)
GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_MEM],(ULONG *)&nsoption_int(memory_cache_size));
nsoption_set_int(memory_cache_size, nsoption_int(memory_cache_size) * 1048576);
- GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_int(disc_cache_age));
+ GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_uint(disc_cache_size));
+ nsoption_set_uint(disc_cache_size, nsoption_uint(disc_cache_size) * 1048576);
GetAttr(GA_Selected,gow->objects[GID_OPTS_OVERWRITE],(ULONG *)&data);
if (data) {
@@ -1802,8 +1808,7 @@ void ami_gui_opts_use(bool save)
ami_gui_tabs_toggle_all();
GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_SEARCH_PROV],(ULONG *)&nsoption_int(search_provider));
- search_web_provider_details(nsoption_int(search_provider));
- search_web_retrieve_ico(false);
+ search_web_select_provider(nsoption_int(search_provider));
GetAttr(GA_Selected,gow->objects[GID_OPTS_CLIPBOARD],(ULONG *)&data);
if (data) {
@@ -1929,10 +1934,10 @@ BOOL ami_gui_opts_event(void)
case WMHI_GADGETHELP:
if((result & WMHI_GADGETMASK) == 0) {
/* Pointer not over our window */
- ami_help_open(AMI_HELP_MAIN);
+ ami_help_open(AMI_HELP_MAIN, scrn);
} else {
/* TODO: Make this sensitive to the tab the user is currently on */
- ami_help_open(AMI_HELP_PREFS);
+ ami_help_open(AMI_HELP_PREFS, scrn);
}
break;
@@ -2110,39 +2115,41 @@ BOOL ami_gui_opts_event(void)
return FALSE;
}
-STRPTR *ami_gui_opts_websearch(void)
+struct List *ami_gui_opts_websearch(void)
{
- char buf[300];
- ULONG ref = 0;
- STRPTR *websearchlist;
+ struct List *list;
+ struct Node *node;
+ const char *name;
+ int iter;
- websearchlist = AllocVecTagList(200, NULL); /* NB: Was not MEMF_PRIVATE */
+ list = AllocVecTagList(sizeof(struct List), NULL);
+ NewList(list);
- if (nsoption_charp(search_engines_file) == NULL) return websearchlist;
+ if (nsoption_charp(search_engines_file) == NULL) return list;
- FILE *f = fopen(nsoption_charp(search_engines_file), "r");
- if (f == NULL) return websearchlist;
-
- while (fgets(buf, sizeof(buf), f) != NULL) {
- if (buf[0] == '\0') continue;
- buf[strlen(buf)-1] = '\0';
- websearchlist[ref] = strdup(strtok(buf, "|"));
- ref++;
+ for (iter = search_web_iterate_providers(0, &name);
+ iter != -1;
+ iter = search_web_iterate_providers(iter, &name)) {
+ node = AllocChooserNode(CNA_Text, name, TAG_DONE);
+ AddTail(list, node);
}
- fclose(f);
- websearchlist[ref] = NULL;
- return websearchlist;
+ return list;
}
-void ami_gui_opts_websearch_free(STRPTR *websearchlist)
+void ami_gui_opts_websearch_free(struct List *websearchlist)
{
- ULONG ref = 0;
+ struct Node *node;
+ struct Node *nnode;
- while (websearchlist[ref] != NULL) {
- free(websearchlist[ref]);
- ref++;
- }
+ if(IsListEmpty(websearchlist)) return;
+ node = GetHead(websearchlist);
+
+ do {
+ nnode = GetSucc(node);
+ Remove(node);
+ } while(node = nnode);
FreeVec(websearchlist);
}
+
diff --git a/amiga/gui_options.h b/amiga/gui_options.h
index 0fd0715a3..04c1be51e 100755
--- a/amiga/gui_options.h
+++ b/amiga/gui_options.h
@@ -18,8 +18,15 @@
#ifndef AMIGA_GUI_OPTIONS_H
#define AMIGA_GUI_OPTIONS_H
+/* Prefs GUI control */
void ami_gui_opts_open(void);
BOOL ami_gui_opts_event(void);
+void ami_gui_opts_close(void);
+
+/* Web search list */
+struct List *ami_gui_opts_websearch(void);
+void ami_gui_opts_websearch_free(struct List *websearchlist);
char *current_user_options;
#endif
+
diff --git a/amiga/help.c b/amiga/help.c
index 214e59d96..8914440be 100755
--- a/amiga/help.c
+++ b/amiga/help.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2013-4 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -45,8 +45,9 @@ void ami_help_init(struct Screen *screen)
TAG_DONE);
}
-void ami_help_open(ULONG node)
+void ami_help_open(ULONG node, struct Screen *screen)
{
+ if(AmigaGuideObject == NULL) ami_help_init(screen);
SetAttrs(AmigaGuideObject, AMIGAGUIDE_ContextID, node, TAG_DONE);
IDoMethod(AmigaGuideObject, AGM_OPEN, NULL);
}
@@ -62,5 +63,21 @@ void ami_help_free(void)
void ami_help_new_screen(struct Screen *screen)
{
+ if(AmigaGuideObject == NULL) return;
SetAttrs(AmigaGuideObject, AMIGAGUIDE_Screen, screen, TAG_DONE);
}
+
+ULONG ami_help_signal(void)
+{
+ ULONG ag_sig = 0;
+ if(AmigaGuideObject)
+ GetAttr(AMIGAGUIDE_Signal, AmigaGuideObject, &ag_sig);
+ return ag_sig;
+}
+
+void ami_help_process(void)
+{
+ ULONG ret = IDoMethod(AmigaGuideObject, AGM_PROCESS, NULL);
+ if(ret) ami_help_free();
+}
+
diff --git a/amiga/help.h b/amiga/help.h
index 4baa2a0e2..e405edd0c 100755
--- a/amiga/help.h
+++ b/amiga/help.h
@@ -29,8 +29,10 @@ enum {
struct Screen;
-void ami_help_init(struct Screen *screen);
-void ami_help_open(ULONG node);
+void ami_help_open(ULONG node, struct Screen *screen);
void ami_help_free(void);
void ami_help_new_screen(struct Screen *screen);
+ULONG ami_help_signal(void);
+void ami_help_process(void);
#endif
+
diff --git a/amiga/history_local.c b/amiga/history_local.c
index b5aba3825..9884ea3ec 100755
--- a/amiga/history_local.c
+++ b/amiga/history_local.c
@@ -25,14 +25,13 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
-#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "amiga/os3support.h"
#include "amiga/object.h"
#include "amiga/gui.h"
#include "utils/log.h"
-#include "utils/url.h"
#include "utils/utils.h"
#include <proto/intuition.h>
#include "amiga/history_local.h"
@@ -52,7 +51,7 @@
#include <reaction/reaction.h>
#include <reaction/reaction_macros.h>
-static struct history *history_current = 0;
+static struct browser_window *history_bw;
/* Last position of mouse in window. */
static int mouse_x = 0;
/* Last position of mouse in window. */
@@ -74,11 +73,10 @@ static void ami_history_scroller_hook(struct Hook *hook,Object *object,struct In
void ami_history_open(struct browser_window *bw, struct history *history)
{
int width, height;
- struct IBox *bbox;
assert(history);
- history_current = history;
+ history_bw = bw;
if(!hwindow)
{
@@ -87,7 +85,7 @@ void ami_history_open(struct browser_window *bw, struct history *history)
ami_init_layers(&hwindow->gg, scrn->Width, scrn->Height);
hwindow->bw = bw;
- history_size(history, &width, &height);
+ browser_window_history_size(bw, &width, &height);
hwindow->scrollerhook.h_Entry = (void *)ami_history_scroller_hook;
hwindow->scrollerhook.h_Data = hwindow;
@@ -173,7 +171,7 @@ void ami_history_redraw(struct history_window *hw)
SetRPAttrs(glob->rp, RPTAG_APenColor, 0xffffffff, TAG_DONE);
RectFill(glob->rp, 0, 0, bbox->Width - 1, bbox->Height - 1);
- history_redraw_rectangle(history_current, xs, ys,
+ browser_window_history_redraw_rectangle(history_bw, xs, ys,
bbox->Width + xs, bbox->Height + ys, 0, 0, &ctx);
glob = &browserglob;
@@ -210,13 +208,13 @@ bool ami_history_click(struct history_window *hw,uint16 code)
switch(code)
{
case SELECTUP:
- history_click(hw->bw,history_current,x,y,false);
+ browser_window_history_click(history_bw,x,y,false);
ami_history_redraw(hw);
ami_schedule_redraw(hw->bw->window->shared, true);
break;
case MIDDLEUP:
- history_click(hw->bw,history_current,x,y,true);
+ browser_window_history_click(history_bw,x,y,true);
ami_history_redraw(hw);
break;
@@ -239,7 +237,6 @@ BOOL ami_history_event(struct history_window *hw)
/* return TRUE if window destroyed */
ULONG class,result,relevent = 0;
uint16 code;
- struct MenuItem *item;
const char *url;
struct IBox *bbox;
ULONG xs, ys;
@@ -265,7 +262,7 @@ BOOL ami_history_event(struct history_window *hw)
GetAttr(SCROLLER_Top, hw->objects[OID_HSCROLL], (ULONG *)&xs);
GetAttr(SCROLLER_Top, hw->objects[OID_VSCROLL], (ULONG *)&ys);
- url = history_position_url(history_current,
+ url = browser_window_history_position_url(history_bw,
hw->win->MouseX - bbox->Left + xs,
hw->win->MouseY - bbox->Top + ys);
@@ -297,7 +294,7 @@ void ami_history_update_extent(struct history_window *hw)
struct IBox *bbox;
int width, height;
- history_size(hw->bw->history, &width, &height);
+ browser_window_history_size(hw->bw, &width, &height);
GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox);
RefreshSetGadgetAttrs((APTR)hw->objects[OID_VSCROLL],hw->win,NULL,
diff --git a/amiga/icon.c b/amiga/icon.c
index c5bc6ae1f..01802d308 100644
--- a/amiga/icon.c
+++ b/amiga/icon.c
@@ -39,6 +39,7 @@
#include "amiga/os3support.h"
#include "amiga/bitmap.h"
#include "amiga/icon.h"
+#include "amiga/misc.h"
#include "desktop/plotters.h"
#include "image/bitmap.h"
#include "content/content_protected.h"
@@ -46,6 +47,7 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/url.h"
+#include "utils/file.h"
#define THUMBNAIL_WIDTH 100 /* Icon sizes for thumbnails, usually the same as */
#define THUMBNAIL_HEIGHT 86 /* WIDTH/HEIGHT in desktop/thumbnail.c */
@@ -139,18 +141,15 @@ bool amiga_icon_convert(struct content *c)
ULONG size;
int width = 0, height = 0;
long format = 0;
- int err = 0;
+ int err;
uint8 r, g, b, a;
ULONG offset;
- const char *url;
- char *filename;
+ char *filename = NULL;
char *p;
ULONG trans, pals1;
struct ColorRegister *pal1;
- url = nsurl_access(content_get_url(c));
- filename = url_to_path(url);
-
+ netsurf_nsurl_to_path(content_get_url(c), &filename);
/* This loader will only work on local files, so fail if not a local path */
if(filename == NULL)
{
@@ -365,7 +364,7 @@ void amiga_icon_superimpose_favicon_internal(struct hlcache_handle *icon, struct
ULONG *icondata1, *icondata2;
ULONG width, height;
long format = 0;
- int err = 0;
+ int err;
if(dobj == NULL) return;
@@ -420,11 +419,10 @@ void amiga_icon_superimpose_favicon_internal(struct hlcache_handle *icon, struct
void amiga_icon_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type)
{
struct DiskObject *dobj = NULL;
- struct BitMap *bm = NULL;
ULONG *icondata1, *icondata2;
ULONG width, height;
long format = 0;
- int err = 0;
+ int err;
ULONG trans1, pals1;
ULONG trans2, pals2;
struct ColorRegister *pal1;
diff --git a/amiga/iff_dr2d.c b/amiga/iff_dr2d.c
index 0638b94a6..5709d418b 100644
--- a/amiga/iff_dr2d.c
+++ b/amiga/iff_dr2d.c
@@ -31,7 +31,7 @@ ULONG numcols;
ULONG findcolour(ULONG newcol)
{
ULONG i;
- ULONG colour = 0xFFFFFFFF;
+ ULONG colr = 0xFFFFFFFF;
UBYTE red,grn,blu;
red = svgtiny_RED(newcol);
@@ -41,21 +41,20 @@ ULONG findcolour(ULONG newcol)
for(i=0;i<numcols;i++)
{
if((cm[i].red == red) && (cm[i].green == grn) && (cm[i].blue == blu))
- colour = i;
+ colr = i;
}
- return colour;
+ return colr;
}
void addcolour(ULONG newcol)
{
- int i;
- ULONG colour;
+ ULONG colr;
UBYTE red,grn,blu;
- colour = findcolour(newcol);
+ colr = findcolour(newcol);
- if(colour == 0xFFFFFFFF)
+ if(colr == 0xFFFFFFFF)
{
cm[numcols].red = svgtiny_RED(newcol);
cm[numcols].green = svgtiny_GREEN(newcol);
@@ -342,7 +341,6 @@ int main(int argc, char **argv)
{
BPTR fh = 0;
char *buffer;
- size_t n;
struct IFFHandle *iffh = NULL;
int64 size;
LONG rarray[] = {0,0};
diff --git a/amiga/launch.c b/amiga/launch.c
index ebd82294a..d3c9ff11e 100755
--- a/amiga/launch.c
+++ b/amiga/launch.c
@@ -31,6 +31,7 @@
#include <proto/openurl.h>
#include "utils/nsoption.h"
+#include "utils/nsurl.h"
#include "utils/url.h"
struct Library *OpenURLBase = NULL;
@@ -49,7 +50,7 @@ struct ami_protocol *ami_openurl_add_protocol(const char *url)
struct ami_protocol *ami_p =
(struct ami_protocol *)AllocVecTagList(sizeof(struct ami_protocol), NULL);
- if(url_scheme(url, &ami_p->protocol) != URL_FUNC_OK)
+ if(url_scheme(url, &ami_p->protocol) != NSERROR_OK)
{
FreeVec(ami_p);
return NULL;
@@ -105,8 +106,6 @@ BOOL ami_openurl_check_list(struct MinList *list, const char *url)
void ami_openurl_open(void)
{
- struct ami_protocol *ami_p;
-
if(nsoption_bool(use_openurl_lib)) {
if(OpenURLBase = OpenLibrary("openurl.library",0))
IOpenURL = (struct OpenURLIFace *)GetInterface(OpenURLBase,"main",1,NULL);
@@ -124,26 +123,31 @@ void ami_openurl_close(const char *scheme)
ami_openurl_free_list(&ami_unsupportedprotocols);
}
-void gui_launch_url(const char *url)
+nserror gui_launch_url(struct nsurl *url)
{
APTR procwin = SetProcWindow((APTR)-1L);
char *launchurl = NULL;
- BPTR fptr = 0;
- if(ami_openurl_check_list(&ami_unsupportedprotocols, url) == FALSE)
+ if(ami_openurl_check_list(&ami_unsupportedprotocols, nsurl_access(url)) == FALSE)
{
if(IOpenURL)
{
URL_OpenA((STRPTR)url,NULL);
} else {
- if(launchurl = ASPrintf("URL:%s",url)) {
- fptr = Open(launchurl,MODE_OLDFILE);
- if(fptr) Close(fptr);
- else ami_openurl_add_protocol(url);
+ if(launchurl = ASPrintf("URL:%s", nsurl_access(url))) {
+ BPTR fptr = Open(launchurl,MODE_OLDFILE);
+ if(fptr)
+ {
+ Close(fptr);
+ } else {
+ ami_openurl_add_protocol(nsurl_access(url));
+ }
FreeVec(launchurl);
}
}
}
- SetProcWindow(procwin);
+ SetProcWindow(procwin);
+
+ return NSERROR_OK;
}
diff --git a/amiga/launch.h b/amiga/launch.h
index 40f7dae30..cab638b1d 100755
--- a/amiga/launch.h
+++ b/amiga/launch.h
@@ -25,4 +25,7 @@
void ami_openurl_open(void);
void ami_openurl_close(void);
+
+nserror gui_launch_url(struct nsurl *url);
+
#endif
diff --git a/amiga/login.c b/amiga/login.c
index 816ece675..c4bf5d92a 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"
@@ -24,7 +23,6 @@
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/utility.h>
-#include "utils/url.h"
#include "content/urldb.h"
#include "utils/messages.h"
#include "utils/errors.h"
@@ -93,7 +91,7 @@ void gui_401login_open(nsurl *url, const char *realm,
lw->objects[OID_MAIN] = WindowObject,
WA_ScreenTitle,nsscreentitle,
- WA_Title,lw->url,
+ WA_Title, nsurl_access(lw->url),
WA_Activate, TRUE,
WA_DepthGadget, TRUE,
WA_DragBar, TRUE,
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/menu.c b/amiga/menu.c
index a9185e823..19888f75b 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -35,8 +35,6 @@
#include <images/label.h>
#include <proto/bitmap.h>
#include <images/bitmap.h>
-#include <proto/glyph.h>
-#include <images/glyph.h>
#include <reaction/reaction_macros.h>
@@ -58,12 +56,19 @@
#include "amiga/theme.h"
#include "amiga/tree.h"
#include "amiga/utf8.h"
+#include "amiga/schedule.h"
#include "desktop/hotlist.h"
#include "desktop/browser_private.h"
#include "desktop/gui.h"
#include "desktop/textinput.h"
#include "utils/messages.h"
-#include "utils/schedule.h"
+
+/* This is here temporarily until we get a new SDK */
+#define LABEL_MenuMode (LABEL_Dummy+12)
+ /* (BOOL) Use highlighting that fits in better visually in a
+ menu. Defaults to FALSE. */
+/**/
+
enum {
NSA_GLYPH_SUBMENU,
@@ -357,13 +362,34 @@ void ami_menu_free_glyphs(void)
menu_glyphs_loaded = false;
}
+static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct RastPort *rp)
+{
+ int space_width = TextLength(rp, " ", 1);
+ int item_size;
+
+ item_size = TextLength(rp, gwin->menulab[j], strlen(gwin->menulab[j]));
+ item_size += space_width;
+
+ if(gwin->menukey[j]) {
+ item_size += TextLength(rp, &gwin->menukey[j], 1);
+ item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
+ /**TODO: take account of the size of other imagery too
+ */
+ }
+
+ return item_size;
+}
+
+
static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
{
int i, j;
- int txtlen = 0;
+ int txtlen = 0, subtxtlen = 0;
+ int left_posn;
struct RastPort *rp = &scrn->RastPort;
struct DrawInfo *dri = GetScreenDrawInfo(scrn);
-
+ int space_width = TextLength(rp, " ", 1);
+
if(menu_glyphs_loaded == false)
ami_menu_load_glyphs(dri);
@@ -372,18 +398,10 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
if(gwin->menutype[i] == NM_TITLE) {
j = i + 1;
txtlen = 0;
- int item_size = 0;
do {
if(gwin->menulab[j] != NM_BARLABEL) {
if(gwin->menutype[j] == NM_ITEM) {
- item_size = TextLength(rp, gwin->menulab[j], strlen(gwin->menulab[j]));
- if(gwin->menukey[j]) {
- item_size += TextLength(rp, &gwin->menukey[j], 1);
- item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
- /**TODO: take account of the size of other imagery too
- */
- }
-
+ int item_size = ami_menu_calc_item_width(gwin, j, rp);
if(item_size > txtlen) {
txtlen = item_size;
}
@@ -398,32 +416,76 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
using label.image if there's a bitmap associated with the item. */
if((gwin->menuicon[i] != NULL) && (gwin->menulab[i] != NM_BARLABEL)) {
int icon_width = 0;
+ Object *blank_space = NULL;
Object *submenuarrow = NULL;
Object *icon = BitMapObject,
BITMAP_Screen, scrn,
BITMAP_SourceFile, gwin->menuicon[i],
BITMAP_Masking, TRUE,
BitMapEnd;
+
+ /* \todo make this scale the bitmap to these dimensions */
+ SetAttrs(icon,
+ BITMAP_Width, 16,
+ BITMAP_Height, 16,
+ TAG_DONE);
+
GetAttr(IA_Width, icon, (ULONG *)&icon_width);
-
+
+ if(gwin->menutype[i] == NM_SUB) {
+ left_posn = subtxtlen;
+ } else {
+ left_posn = txtlen;
+ }
+
+ left_posn = left_posn -
+ TextLength(rp, gwin->menulab[i], strlen(gwin->menulab[i])) -
+ icon_width - space_width;
+
if((gwin->menutype[i] == NM_ITEM) && (gwin->menutype[i+1] == NM_SUB)) {
+ left_posn -= menu_glyph_width[NSA_GLYPH_SUBMENU];
+
submenuarrow = NewObject(NULL, "sysiclass",
- SYSIA_Which, MENUSUB,
- SYSIA_DrawInfo, dri,
- IA_Left, txtlen - TextLength(rp, gwin->menulab[i], strlen(gwin->menulab[i])) -
- menu_glyph_width[NSA_GLYPH_SUBMENU] - icon_width,
+ SYSIA_Which, MENUSUB,
+ SYSIA_DrawInfo, dri,
+ IA_Left, left_posn,
TAG_DONE);
+
+ j = i + 1;
+ subtxtlen = 0;
+ do {
+ if(gwin->menulab[j] != NM_BARLABEL) {
+ if(gwin->menutype[j] == NM_SUB) {
+ int item_size = ami_menu_calc_item_width(gwin, j, rp);
+ if(item_size > subtxtlen) {
+ subtxtlen = item_size;
+ }
+ }
+ }
+ j++;
+ } while((gwin->menutype[j] == NM_SUB));
}
/**TODO: Checkmark/MX images and keyboard shortcuts
*/
+
+ if(gwin->menutype[i] == NM_SUB) {
+ blank_space = NewObject(NULL, "fillrectclass",
+ IA_Height, 0,
+ IA_Width, left_posn + icon_width,
+ TAG_DONE);
+ }
gwin->menuobj[i] = LabelObject,
+ LABEL_MenuMode, TRUE,
LABEL_DrawInfo, dri,
LABEL_DisposeImage, TRUE,
LABEL_Image, icon,
+ LABEL_Text, " ",
LABEL_Text, gwin->menulab[i],
LABEL_DisposeImage, TRUE,
+ LABEL_Image, blank_space,
+ LABEL_DisposeImage, TRUE,
LABEL_Image, submenuarrow,
LabelEnd;
@@ -455,8 +517,6 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
struct NewMenu *ami_create_menu(struct gui_window_2 *gwin)
{
- int i;
-
gwin->menu = AllocVecTags(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1),
AVT_ClearWithValue, 0, TAG_DONE);
ami_init_menulabs(gwin);
@@ -479,10 +539,6 @@ struct NewMenu *ami_create_menu(struct gui_window_2 *gwin)
if(nsoption_bool(background_images) == true)
gwin->menu[M_IMGBACK].nm_Flags |= CHECKED;
- /* Set up scheduler to refresh the hotlist menu */
- if(nsoption_int(menu_refresh) > 0)
- schedule(nsoption_int(menu_refresh), (void *)ami_menu_refresh, gwin);
-
return(gwin->menu);
}
@@ -548,7 +604,7 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder)
{
UBYTE type;
- char *icon;
+ STRPTR icon;
struct gui_window_2 *gw = (struct gui_window_2 *)userdata;
if(item >= AMI_MENU_HOTLIST_MAX) return false;
@@ -567,9 +623,10 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
}
if(is_folder == true) {
- icon = "icons/directory.png";
+ icon = ASPrintf("icons/directory.png");
} else {
- icon = "icons/content.png";
+ icon = ami_gui_get_cache_favicon_name(url, true);
+ if (icon == NULL) icon = ASPrintf("icons/content.png");
}
ami_menu_alloc_item(gw, item, type, title,
@@ -577,6 +634,8 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
if((is_folder == true) && (type == NM_SUB))
gw->menu[item].nm_Flags = NM_ITEMDISABLED;
+ if(icon) FreeVec(icon);
+
return true;
}
@@ -697,8 +756,7 @@ static void ami_menu_item_project_newwin(struct Hook *hook, APTR window, struct
error = nsurl_create(nsoption_charp(homepage_url), &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -713,25 +771,10 @@ static void ami_menu_item_project_newwin(struct Hook *hook, APTR window, struct
static void ami_menu_item_project_newtab(struct Hook *hook, APTR window, struct IntuiMessage *msg)
{
struct gui_window_2 *gwin;
- nsurl *url;
nserror error;
- GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
-
- error = nsurl_create(nsoption_charp(homepage_url), &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
- url,
- NULL,
- gwin->bw,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- }
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
+ error = ami_gui_new_blank_tab(gwin);
}
static void ami_menu_item_project_open(struct Hook *hook, APTR window, struct IntuiMessage *msg)
@@ -801,18 +844,9 @@ static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct I
TDR_TitleString, messages_get("NetSurf"),
TDR_Window, gwin->win,
TDR_GadgetString, temp2,
-#ifndef NDEBUG
- TDR_FormatString,"NetSurf %s\n%s\nBuild date %s\n\nhttp://www.netsurf-browser.org",
-#else
- TDR_FormatString,"NetSurf %s\n%s\n\nhttp://www.netsurf-browser.org",
-#endif
+ TDR_FormatString,"NetSurf %s\nBuild date %s\n\nhttp://www.netsurf-browser.org",
TDR_Arg1,netsurf_version,
-#ifdef NS_AMIGA_CAIRO
- TDR_Arg2,"Cairo (OS4.1+) SObjs build",
-#else
- TDR_Arg2,"graphics.library static build",
-#endif
- TDR_Arg3,verdate,
+ TDR_Arg2,verdate,
TAG_DONE);
free(temp2);
@@ -825,8 +859,7 @@ static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct I
if(url) {
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -867,8 +900,12 @@ static void ami_menu_item_edit_copy(struct Hook *hook, APTR window, struct Intui
}
else if(bm = content_get_bitmap(gwin->bw->current_content))
{
- bm->url = (char *)nsurl_access(hlcache_handle_get_url(gwin->bw->current_content));
- bm->title = (char *)content_get_title(gwin->bw->current_content);
+ /** @todo It should be checked that the lifetime of
+ * the objects containing the values returned (and the
+ * constness cast away) is safe.
+ */
+ bm->url = (char *)nsurl_access(browser_window_get_url(gwin->bw));
+ bm->title = (char *)browser_window_get_title(gwin->bw);
ami_easy_clipboard_bitmap(bm);
}
#ifdef WITH_NS_SVG
@@ -1041,7 +1078,6 @@ static void ami_menu_item_hotlist_show(struct Hook *hook, APTR window, struct In
static void ami_menu_item_hotlist_entries(struct Hook *hook, APTR window, struct IntuiMessage *msg)
{
nsurl *url = hook->h_Data;
- nserror error;
struct gui_window_2 *gwin;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
@@ -1050,8 +1086,7 @@ static void ami_menu_item_hotlist_entries(struct Hook *hook, APTR window, struct
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1109,13 +1144,13 @@ static void ami_menu_item_arexx_entries(struct Hook *hook, APTR window, struct I
char *script = hook->h_Data;
char *temp;
struct gui_window_2 *gwin;
- BPTR lock = 0;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
if(script)
{
if(temp = AllocVecTagList(1024, NULL))
{
+ BPTR lock;
if(lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK)) {
DevNameFromLock(lock, temp, 1024, DN_FULLPATH);
AddPart(temp, script, 1024);
@@ -1126,3 +1161,4 @@ static void ami_menu_item_arexx_entries(struct Hook *hook, APTR window, struct I
}
}
}
+
diff --git a/amiga/misc.c b/amiga/misc.c
index 003a5fb6e..7d126c906 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -19,8 +19,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <proto/dos.h>
#include <proto/exec.h>
@@ -34,8 +36,10 @@
#include "amiga/utf8.h"
#include "desktop/cookie_manager.h"
#include "utils/log.h"
+#include "utils/corestrings.h"
#include "utils/messages.h"
#include "utils/url.h"
+#include "utils/file.h"
#include "utils/utils.h"
void warn_user(const char *warning, const char *detail)
@@ -43,7 +47,6 @@ void warn_user(const char *warning, const char *detail)
Object *req = NULL;
char *utf8warning = ami_utf8_easy(messages_get(warning));
STRPTR bodytext = NULL;
- LONG result = 0;
LOG(("%s %s", warning, detail));
@@ -63,7 +66,7 @@ void warn_user(const char *warning, const char *detail)
TAG_DONE);
if (req) {
- result = IDoMethod(req, RM_OPENREQ, NULL, NULL, scrn);
+ LONG result = IDoMethod(req, RM_OPENREQ, NULL, NULL, scrn);
DisposeObject(req);
}
@@ -106,54 +109,91 @@ void die(const char *error)
exit(1);
}
-char *url_to_path(const char *url)
+/**
+ * Create a path from a nsurl using amiga file handling.
+ *
+ * @param[in] url The url to encode.
+ * @param[out] path_out A string containing the result path which should
+ * be freed by the caller.
+ * @return NSERROR_OK and the path is written to \a path or error code
+ * on faliure.
+ */
+static nserror amiga_nsurl_to_path(struct nsurl *url, char **path_out)
{
- char *tmps, *unesc, *slash, *colon, *url2;
-
- if (strncmp(url, "file://", SLEN("file://")) != 0)
- return NULL;
-
- url += SLEN("file://");
+ lwc_string *urlpath;
+ char *path;
+ bool match;
+ lwc_string *scheme;
+ nserror res;
+ char *colon;
+ char *slash;
+
+ if ((url == NULL) || (path_out == NULL)) {
+ return NSERROR_BAD_PARAMETER;
+ }
- if (strncmp(url, "localhost", SLEN("localhost")) == 0)
- url += SLEN("localhost");
+ scheme = nsurl_get_component(url, NSURL_SCHEME);
- if (strncmp(url, "/", SLEN("/")) == 0)
- url += SLEN("/");
+ if (lwc_string_caseless_isequal(scheme, corestring_lwc_file,
+ &match) != lwc_error_ok)
+ {
+ return NSERROR_BAD_PARAMETER;
+ }
+ lwc_string_unref(scheme);
+ if (match == false) {
+ return NSERROR_BAD_PARAMETER;
+ }
- if(*url == '\0')
- return NULL; /* file:/// is not a valid path */
+ urlpath = nsurl_get_component(url, NSURL_PATH);
+ if (urlpath == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
- url2 = malloc(strlen(url) + 2);
- strcpy(url2, url);
+ res = url_unescape(lwc_string_data(urlpath) + 1, &path);
+ lwc_string_unref(urlpath);
+ if (res != NSERROR_OK) {
+ return res;
+ }
- colon = strchr(url2, ':');
+ colon = strchr(path, ':');
if(colon == NULL)
{
- if(slash = strchr(url2, '/'))
+ slash = strchr(path, '/');
+ if(slash)
{
*slash = ':';
}
else
{
- int len = strlen(url2);
- url2[len] = ':';
- url2[len + 1] = '\0';
+ int len = strlen(path);
+ path[len] = ':';
+ path[len + 1] = '\0';
}
}
- if(url_unescape(url2,&unesc) == URL_FUNC_OK)
- return unesc;
+ *path_out = path;
- return (char *)url2;
+ return NSERROR_OK;
}
-char *path_to_url(const char *path)
+/**
+ * Create a nsurl from a path using amiga file handling.
+ *
+ * Perform the necessary operations on a path to generate a nsurl.
+ *
+ * @param[in] path The path to convert.
+ * @param[out] url_out pointer to recive the nsurl, The returned url
+ * must be unreferenced by the caller.
+ * @return NSERROR_OK and the url is placed in \a url or error code on
+ * faliure.
+ */
+static nserror amiga_path_to_nsurl(const char *path, struct nsurl **url_out)
{
char *colon = NULL;
char *r = NULL;
char newpath[1024 + strlen(path)];
BPTR lock = 0;
+ nserror ret;
if(lock = Lock(path, MODE_OLDFILE))
{
@@ -163,40 +203,19 @@ char *path_to_url(const char *path)
else strlcpy(newpath, path, sizeof newpath);
r = malloc(strlen(newpath) + SLEN("file:///") + 1);
+ if (r == NULL) {
+ return NSERROR_NOMEM;
+ }
if(colon = strchr(newpath, ':')) *colon = '/';
strcpy(r, "file:///");
strcat(r, newpath);
- return r;
-}
+ ret = nsurl_create(r, url_out);
+ free(r);
-/**
- * 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;
+ return ret;
}
/**
@@ -224,3 +243,197 @@ char *translate_escape_chars(const char *s)
ret[ii] = '\0';
return ret;
}
+
+/**
+ * Generate a posix path from one or more component elemnts.
+ *
+ * If a string is allocated it must be freed by the caller.
+ *
+ * @param[in,out] str pointer to string pointer if this is NULL enough
+ * storage will be allocated for the complete path.
+ * @param[in,out] size The size of the space available if \a str not
+ * NULL on input and if not NULL set to the total
+ * output length on output.
+ * @param[in] nelm The number of elements.
+ * @param[in] ap The elements of the path as string pointers.
+ * @return NSERROR_OK and the complete path is written to str
+ * or error code on faliure.
+ */
+static nserror amiga_vmkpath(char **str, size_t *size, size_t nelm, va_list ap)
+{
+ const char *elm[16];
+ size_t elm_len[16];
+ size_t elm_idx;
+ char *fname;
+ size_t fname_len = 0;
+
+ /* check the parameters are all sensible */
+ if ((nelm == 0) || (nelm > 16)) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if ((*str != NULL) && (size == NULL)) {
+ /* if the caller is providing the buffer they must say
+ * how much space is available.
+ */
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ /* calculate how much storage we need for the complete path
+ * with all the elements.
+ */
+ for (elm_idx = 0; elm_idx < nelm; elm_idx++) {
+ elm[elm_idx] = va_arg(ap, const char *);
+ /* check the argument is not NULL */
+ if (elm[elm_idx] == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ elm_len[elm_idx] = strlen(elm[elm_idx]);
+ fname_len += elm_len[elm_idx];
+ }
+ fname_len += nelm; /* allow for separators and terminator */
+
+ /* ensure there is enough space */
+ fname = *str;
+ if (fname != NULL) {
+ if (fname_len > *size) {
+ return NSERROR_NOSPACE;
+ }
+ } else {
+ fname = malloc(fname_len);
+ if (fname == NULL) {
+ return NSERROR_NOMEM;
+ }
+ }
+
+ /* copy the first element complete */
+ memmove(fname, elm[0], elm_len[0]);
+ fname[elm_len[0]] = 0;
+
+ /* add the remaining elements */
+ for (elm_idx = 1; elm_idx < nelm; elm_idx++) {
+ if (!AddPart(fname, elm[elm_idx], fname_len)) {
+ break;
+ }
+ }
+
+ *str = fname;
+ if (size != NULL) {
+ *size = fname_len;
+ }
+
+ return NSERROR_OK;
+}
+
+/**
+ * Get the basename of a file using posix path handling.
+ *
+ * This gets the last element of a path and returns it.
+ *
+ * @param[in] path The path to extract the name from.
+ * @param[in,out] str Pointer to string pointer if this is NULL enough
+ * storage will be allocated for the path element.
+ * @param[in,out] size The size of the space available if \a
+ * str not NULL on input and set to the total
+ * output length on output.
+ * @return NSERROR_OK and the complete path is written to str
+ * or error code on faliure.
+ */
+static nserror amiga_basename(const char *path, char **str, size_t *size)
+{
+ const char *leafname;
+ char *fname;
+
+ if (path == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ leafname = FilePart(path);
+ if (leafname == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ fname = strdup(leafname);
+ if (fname == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ *str = fname;
+ if (size != NULL) {
+ *size = strlen(fname);
+ }
+ return NSERROR_OK;
+}
+
+/**
+ * Ensure that all directory elements needed to store a filename exist.
+ *
+ * @param fname The filename to ensure the path to exists.
+ * @return NSERROR_OK on success or error code on failure.
+ */
+static nserror amiga_mkdir_all(const char *fname)
+{
+ char *dname;
+ char *sep;
+ struct stat sb;
+
+ dname = strdup(fname);
+
+ sep = strrchr(dname, '/');
+ if (sep == NULL) {
+ /* no directory separator path is just filename so its ok */
+ free(dname);
+ return NSERROR_OK;
+ }
+
+ *sep = 0; /* null terminate directory path */
+
+ if (stat(dname, &sb) == 0) {
+ free(dname);
+ if (S_ISDIR(sb.st_mode)) {
+ /* path to file exists and is a directory */
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_DIRECTORY;
+ }
+ *sep = '/'; /* restore separator */
+
+ sep = dname;
+ while (*sep == '/') {
+ sep++;
+ }
+ while ((sep = strchr(sep, '/')) != NULL) {
+ *sep = 0;
+ if (stat(dname, &sb) != 0) {
+ if (nsmkdir(dname, S_IRWXU) != 0) {
+ /* could not create path element */
+ free(dname);
+ return NSERROR_NOT_FOUND;
+ }
+ } else {
+ if (! S_ISDIR(sb.st_mode)) {
+ /* path element not a directory */
+ free(dname);
+ return NSERROR_NOT_DIRECTORY;
+ }
+ }
+ *sep = '/'; /* restore separator */
+ /* skip directory separators */
+ while (*sep == '/') {
+ sep++;
+ }
+ }
+
+ free(dname);
+ return NSERROR_OK;
+}
+
+/* amiga file handling operations */
+static struct gui_file_table file_table = {
+ .mkpath = amiga_vmkpath,
+ .basename = amiga_basename,
+ .nsurl_to_path = amiga_nsurl_to_path,
+ .path_to_nsurl = amiga_path_to_nsurl,
+ .mkdir_all = amiga_mkdir_all,
+};
+
+struct gui_file_table *amiga_file_table = &file_table;
diff --git a/amiga/misc.h b/amiga/misc.h
index 34a85fa90..db559f78a 100644
--- a/amiga/misc.h
+++ b/amiga/misc.h
@@ -18,6 +18,11 @@
#ifndef AMIGA_MISC_H
#define AMIGA_MISC_H
+
+extern struct gui_file_table *amiga_file_table;
+
char *translate_escape_chars(const char *s);
int32 ami_warn_user_multi(const char *body, const char *opt1, const char *opt2, struct Window *win);
+
+
#endif
diff --git a/amiga/options.h b/amiga/options.h
index f595cd240..868e28fdb 100644
--- a/amiga/options.h
+++ b/amiga/options.h
@@ -77,7 +77,6 @@ NSOPTION_INTEGER(cookies_window_ypos, 0)
NSOPTION_INTEGER(cookies_window_xsize, 0)
NSOPTION_INTEGER(cookies_window_ysize, 0)
NSOPTION_INTEGER(web_search_width, 0)
-NSOPTION_INTEGER(cairo_renderer, 0)
NSOPTION_BOOL(direct_render, false)
NSOPTION_BOOL(window_simple_refresh, false)
NSOPTION_BOOL(resize_with_contents, false)
@@ -87,6 +86,4 @@ NSOPTION_INTEGER(redraw_tile_size_y, 0)
NSOPTION_INTEGER(monitor_aspect_x, 0)
NSOPTION_INTEGER(monitor_aspect_y, 0)
NSOPTION_BOOL(accept_lang_locale, true)
-NSOPTION_INTEGER(menu_refresh, 0)
-
diff --git a/amiga/plotters.c b/amiga/plotters.c
index 6683fc58b..cb7ccac78 100755
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -71,11 +71,6 @@ bool palette_mapped = false;
#define M_PI 3.14159265358979323846
#endif
-#ifdef NS_AMIGA_CAIRO
-#include <cairo/cairo.h>
-#include <cairo/cairo-amigaos.h>
-#endif
-
#define PATT_DOT 0xAAAA
#define PATT_DASH 0xCCCC
#define PATT_LINE 0xFFFF
@@ -102,42 +97,6 @@ const struct plotter_table amiplot = {
.option_knockout = true,
};
-
-#ifdef NS_AMIGA_CAIRO
-void ami_cairo_set_colour(cairo_t *cr,colour c)
-{
- int r, g, b;
-
- r = c & 0xff;
- g = (c & 0xff00) >> 8;
- b = (c & 0xff0000) >> 16;
-
- cairo_set_source_rgba(glob->cr, r / 255.0,
- g / 255.0, b / 255.0, 1.0);
-}
-
-void ami_cairo_set_solid(cairo_t *cr)
-{
- double dashes = 0;
-
- cairo_set_dash(glob->cr, &dashes, 0, 0);
-}
-
-void ami_cairo_set_dotted(cairo_t *cr)
-{
- double cdashes = 1;
-
- cairo_set_dash(glob->cr, &cdashes, 1, 0);
-}
-
-void ami_cairo_set_dashed(cairo_t *cr)
-{
- double cdashes = 3;
-
- cairo_set_dash(glob->cr, &cdashes, 1, 0);
-}
-#endif
-
void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
{
/* init shared bitmaps *
@@ -148,7 +107,7 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
struct BitMap *friend = NULL;
depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
- if((depth < 16) || (nsoption_int(cairo_renderer) == -1)) {
+ if(depth < 16) {
palette_mapped = true;
} else {
palette_mapped = false;
@@ -195,19 +154,10 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
if((!gg->tmprasbuf) || (!gg->rp->TmpRas)) warn_user("NoMemory","");
InitTmpRas(gg->rp->TmpRas, gg->tmprasbuf, width*height);
-
-#ifdef NS_AMIGA_CAIRO
- gg->surface = cairo_amigaos_surface_create(gg->rp->BitMap);
- gg->cr = cairo_create(gg->surface);
-#endif
}
void ami_free_layers(struct gui_globals *gg)
{
-#ifdef NS_AMIGA_CAIRO
- cairo_destroy(gg->cr);
- cairo_surface_destroy(gg->surface);
-#endif
if(gg->rp)
{
DeleteLayer(0,gg->rp->Layer);
@@ -239,16 +189,16 @@ void ami_clearclipreg(struct gui_globals *gg)
gg->rect.MaxY = scrn->Height-1;
}
-static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colour)
+static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colr)
{
struct ami_plot_pen *node;
ULONG pen = ObtainBestPenA(scrn->ViewPort.ColorMap,
- (colour & 0x000000ff) << 24,
- (colour & 0x0000ff00) << 16,
- (colour & 0x00ff0000) << 8,
+ (colr & 0x000000ff) << 24,
+ (colr & 0x0000ff00) << 16,
+ (colr & 0x00ff0000) << 8,
NULL);
- if(pen == -1) LOG(("WARNING: Cannot allocate pen for ABGR:%lx", colour));
+ if(pen == -1) LOG(("WARNING: Cannot allocate pen for ABGR:%lx", colr));
if(shared_pens != NULL) {
if(node = (struct ami_plot_pen *)AllocVecTagList(sizeof(struct ami_plot_pen), NULL)) {
@@ -278,26 +228,26 @@ void ami_plot_release_pens(struct MinList *shared_pens)
}while(node = nnode);
}
-static void ami_plot_setapen(ULONG colour)
+static void ami_plot_setapen(ULONG colr)
{
if(palette_mapped == false) {
SetRPAttrs(glob->rp, RPTAG_APenColor,
- ns_color_to_nscss(colour),
+ ns_color_to_nscss(colr),
TAG_DONE);
} else {
- ULONG pen = ami_plot_obtain_pen(glob->shared_pens, colour);
+ ULONG pen = ami_plot_obtain_pen(glob->shared_pens, colr);
if(pen != -1) SetAPen(glob->rp, pen);
}
}
-static void ami_plot_setopen(ULONG colour)
+static void ami_plot_setopen(ULONG colr)
{
if(palette_mapped == false) {
SetRPAttrs(glob->rp, RPTAG_OPenColor,
- ns_color_to_nscss(colour),
+ ns_color_to_nscss(colr),
TAG_DONE);
} else {
- ULONG pen = ami_plot_obtain_pen(glob->shared_pens, colour);
+ ULONG pen = ami_plot_obtain_pen(glob->shared_pens, colr);
if(pen != -1) SetOPen(glob->rp, pen);
}
}
@@ -309,90 +259,41 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
#endif
if (style->fill_type != PLOT_OP_TYPE_NONE) {
-
- if((nsoption_int(cairo_renderer) < 2) ||
- (palette_mapped == true))
- {
- ami_plot_setapen(style->fill_colour);
- RectFill(glob->rp, x0, y0, x1-1, y1-1);
- }
- else
- {
-#ifdef NS_AMIGA_CAIRO
- ami_cairo_set_colour(glob->cr, style->fill_colour);
- ami_cairo_set_solid(glob->cr);
-
- cairo_set_line_width(glob->cr, 0);
- cairo_rectangle(glob->cr, x0, y0, x1 - x0, y1 - y0);
- cairo_fill(glob->cr);
- cairo_stroke(glob->cr);
-#endif
- }
+ ami_plot_setapen(style->fill_colour);
+ RectFill(glob->rp, x0, y0, x1-1, y1-1);
}
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- if((nsoption_int(cairo_renderer) < 2) ||
- (palette_mapped == true))
- {
- glob->rp->PenWidth = style->stroke_width;
- glob->rp->PenHeight = style->stroke_width;
-
- switch (style->stroke_type) {
- case PLOT_OP_TYPE_SOLID: /**< Solid colour */
- default:
- glob->rp->LinePtrn = PATT_LINE;
- break;
-
- case PLOT_OP_TYPE_DOT: /**< Dotted plot */
- glob->rp->LinePtrn = PATT_DOT;
- break;
-
- case PLOT_OP_TYPE_DASH: /**< dashed plot */
- glob->rp->LinePtrn = PATT_DASH;
- break;
- }
-
- ami_plot_setapen(style->stroke_colour);
- Move(glob->rp, x0,y0);
- Draw(glob->rp, x1, y0);
- Draw(glob->rp, x1, y1);
- Draw(glob->rp, x0, y1);
- Draw(glob->rp, x0, y0);
-
- glob->rp->PenWidth = 1;
- glob->rp->PenHeight = 1;
- glob->rp->LinePtrn = PATT_LINE;
- }
- else
- {
-#ifdef NS_AMIGA_CAIRO
- ami_cairo_set_colour(glob->cr, style->stroke_colour);
-
- switch (style->stroke_type) {
- case PLOT_OP_TYPE_SOLID: /**< Solid colour */
- default:
- ami_cairo_set_solid(glob->cr);
- break;
-
- case PLOT_OP_TYPE_DOT: /**< Doted plot */
- ami_cairo_set_dotted(glob->cr);
- break;
-
- case PLOT_OP_TYPE_DASH: /**< dashed plot */
- ami_cairo_set_dashed(glob->cr);
- break;
- }
+ glob->rp->PenWidth = style->stroke_width;
+ glob->rp->PenHeight = style->stroke_width;
- if (style->stroke_width == 0)
- cairo_set_line_width(glob->cr, 1);
- else
- cairo_set_line_width(glob->cr, style->stroke_width);
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ glob->rp->LinePtrn = PATT_LINE;
+ break;
- cairo_rectangle(glob->cr, x0, y0, x1 - x0, y1 - y0);
- cairo_stroke(glob->cr);
-#endif
- }
+ case PLOT_OP_TYPE_DOT: /**< Dotted plot */
+ glob->rp->LinePtrn = PATT_DOT;
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
+ glob->rp->LinePtrn = PATT_DASH;
+ break;
+ }
+
+ ami_plot_setapen(style->stroke_colour);
+ Move(glob->rp, x0,y0);
+ Draw(glob->rp, x1, y0);
+ Draw(glob->rp, x1, y1);
+ Draw(glob->rp, x0, y1);
+ Draw(glob->rp, x0, y0);
+
+ glob->rp->PenWidth = 1;
+ glob->rp->PenHeight = 1;
+ glob->rp->LinePtrn = PATT_LINE;
}
+
return true;
}
@@ -402,12 +303,10 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
LOG(("[ami_plotter] Entered ami_line()"));
#endif
- if((nsoption_int(cairo_renderer) < 2) || (palette_mapped == true))
- {
- glob->rp->PenWidth = style->stroke_width;
- glob->rp->PenHeight = style->stroke_width;
+ glob->rp->PenWidth = style->stroke_width;
+ glob->rp->PenHeight = style->stroke_width;
- switch (style->stroke_type) {
+ switch (style->stroke_type) {
case PLOT_OP_TYPE_SOLID: /**< Solid colour */
default:
glob->rp->LinePtrn = PATT_LINE;
@@ -420,50 +319,16 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
case PLOT_OP_TYPE_DASH: /**< dashed plot */
glob->rp->LinePtrn = PATT_DASH;
break;
- }
-
- ami_plot_setapen(style->stroke_colour);
- Move(glob->rp,x0,y0);
- Draw(glob->rp,x1,y1);
-
- glob->rp->PenWidth = 1;
- glob->rp->PenHeight = 1;
- glob->rp->LinePtrn = PATT_LINE;
}
- else
- {
-#ifdef NS_AMIGA_CAIRO
- ami_cairo_set_colour(glob->cr, style->stroke_colour);
-
- switch (style->stroke_type) {
- case PLOT_OP_TYPE_SOLID: /**< Solid colour */
- default:
- ami_cairo_set_solid(glob->cr);
- break;
- case PLOT_OP_TYPE_DOT: /**< Doted plot */
- ami_cairo_set_dotted(glob->cr);
- break;
+ ami_plot_setapen(style->stroke_colour);
+ Move(glob->rp,x0,y0);
+ Draw(glob->rp,x1,y1);
- case PLOT_OP_TYPE_DASH: /**< dashed plot */
- ami_cairo_set_dashed(glob->cr);
- break;
- }
+ glob->rp->PenWidth = 1;
+ glob->rp->PenHeight = 1;
+ glob->rp->LinePtrn = PATT_LINE;
- if (style->stroke_width == 0)
- cairo_set_line_width(glob->cr, 1);
- else
- cairo_set_line_width(glob->cr, style->stroke_width);
-
- /* core expects horizontal and vertical lines to be on pixels, not
- * between pixels */
- cairo_move_to(glob->cr, (x0 == x1) ? x0 + 0.5 : x0,
- (y0 == y1) ? y0 + 0.5 : y0);
- cairo_line_to(glob->cr, (x0 == x1) ? x1 + 0.5 : x1,
- (y0 == y1) ? y1 + 0.5 : y1);
- cairo_stroke(glob->cr);
-#endif
- }
return true;
}
@@ -473,41 +338,21 @@ bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style)
LOG(("[ami_plotter] Entered ami_polygon()"));
#endif
- int k;
+ ULONG cx,cy;
- if((nsoption_int(cairo_renderer) < 1) || (palette_mapped == true))
- {
- ULONG cx,cy;
+ ami_plot_setapen(style->fill_colour);
- ami_plot_setapen(style->fill_colour);
-
- if(AreaMove(glob->rp,p[0],p[1]) == -1)
- LOG(("AreaMove: vector list full"));
+ if(AreaMove(glob->rp,p[0],p[1]) == -1)
+ LOG(("AreaMove: vector list full"));
- for(k=1;k<n;k++)
- {
- if(AreaDraw(glob->rp,p[k*2],p[(k*2)+1]) == -1)
- LOG(("AreaDraw: vector list full"));
- }
-
- if(AreaEnd(glob->rp) == -1)
- LOG(("AreaEnd: error"));
- }
- else
- {
-#ifdef NS_AMIGA_CAIRO
- ami_cairo_set_colour(glob->cr, style->fill_colour);
- ami_cairo_set_solid(glob->cr);
-
- cairo_set_line_width(glob->cr, 0);
- cairo_move_to(glob->cr, p[0], p[1]);
- for (k = 1; k != n; k++) {
- cairo_line_to(glob->cr, p[k * 2], p[k * 2 + 1]);
- }
- cairo_fill(glob->cr);
- cairo_stroke(glob->cr);
-#endif
+ for(int k = 1; k < n; k++) {
+ if(AreaDraw(glob->rp,p[k*2],p[(k*2)+1]) == -1)
+ LOG(("AreaDraw: vector list full"));
}
+
+ if(AreaEnd(glob->rp) == -1)
+ LOG(("AreaEnd: error"));
+
return true;
}
@@ -536,16 +381,6 @@ bool ami_clip(const struct rect *clip)
if(reg) DisposeRegion(reg);
}
-#ifdef NS_AMIGA_CAIRO
- if((nsoption_int(cairo_renderer) == 2) && (palette_mapped == false))
- {
- cairo_reset_clip(glob->cr);
- cairo_rectangle(glob->cr, clip->x0, clip->y0,
- clip->x1 - clip->x0, clip->y1 - clip->y0);
- cairo_clip(glob->cr);
- }
-#endif
-
return true;
}
@@ -573,43 +408,17 @@ bool ami_disc(int x, int y, int radius, const plot_style_t *style)
LOG(("[ami_plotter] Entered ami_disc()"));
#endif
- if((nsoption_int(cairo_renderer) < 2) || (palette_mapped == true))
- {
- if (style->fill_type != PLOT_OP_TYPE_NONE) {
- ami_plot_setapen(style->fill_colour);
- AreaCircle(glob->rp,x,y,radius);
- AreaEnd(glob->rp);
- }
-
- if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- ami_plot_setapen(style->stroke_colour);
- DrawEllipse(glob->rp,x,y,radius,radius);
- }
+ if (style->fill_type != PLOT_OP_TYPE_NONE) {
+ ami_plot_setapen(style->fill_colour);
+ AreaCircle(glob->rp,x,y,radius);
+ AreaEnd(glob->rp);
}
- else
- {
-#ifdef NS_AMIGA_CAIRO
- if (style->fill_type != PLOT_OP_TYPE_NONE) {
- ami_cairo_set_colour(glob->cr, style->fill_colour);
- ami_cairo_set_solid(glob->cr);
- cairo_set_line_width(glob->cr, 0);
-
- cairo_arc(glob->cr, x, y, radius, 0, M_PI * 2);
- cairo_fill(glob->cr);
- cairo_stroke(glob->cr);
- }
-
- if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- ami_cairo_set_colour(glob->cr, style->stroke_colour);
- ami_cairo_set_solid(glob->cr);
-
- cairo_set_line_width(glob->cr, 1);
- cairo_arc(glob->cr, x, y, radius, 0, M_PI * 2);
- cairo_stroke(glob->cr);
- }
-#endif
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+ ami_plot_setapen(style->stroke_colour);
+ DrawEllipse(glob->rp,x,y,radius,radius);
}
+
return true;
}
@@ -644,25 +453,10 @@ bool ami_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_
LOG(("[ami_plotter] Entered ami_arc()"));
#endif
- if((nsoption_int(cairo_renderer) <= 0) || (palette_mapped == true)) {
-
- if (angle2 < angle1) angle2 += 360;
-
- ami_plot_setapen(style->fill_colour);
+ if (angle2 < angle1) angle2 += 360;
- ami_arc_gfxlib(x, y, radius, angle1, angle2);
- } else {
-#ifdef NS_AMIGA_CAIRO
- ami_cairo_set_colour(glob->cr, style->fill_colour);
- ami_cairo_set_solid(glob->cr);
-
- cairo_set_line_width(glob->cr, 1);
- cairo_arc(glob->cr, x, y, radius,
- (angle1 + 90) * (M_PI / 180),
- (angle2 + 90) * (M_PI / 180));
- cairo_stroke(glob->cr);
-#endif
- }
+ ami_plot_setapen(style->fill_colour);
+ ami_arc_gfxlib(x, y, radius, angle1, angle2);
return true;
}
@@ -711,6 +505,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
COMPTAG_SrcHeight,height,
COMPTAG_OffsetX,x,
COMPTAG_OffsetY,y,
+ COMPTAG_FriendBitMap, scrn->RastPort.BitMap,
TAG_DONE);
#endif
}
@@ -873,6 +668,7 @@ static void ami_bitmap_tile_hook(struct Hook *hook,struct RastPort *rp,struct Ba
COMPTAG_SrcHeight,bfbm->height,
COMPTAG_OffsetX,xf,
COMPTAG_OffsetY,yf,
+ COMPTAG_FriendBitMap, scrn->RastPort.BitMap,
TAG_DONE);
#endif
}
@@ -943,7 +739,6 @@ bool ami_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6])
{
unsigned int i;
- struct bez_point *old_p;
struct bez_point start_p, cur_p, p_a, p_b, p_c, p_r;
#ifdef AMI_PLOTTER_DEBUG
@@ -958,153 +753,83 @@ bool ami_path(const float *p, unsigned int n, colour fill, float width,
return false;
}
- if((nsoption_int(cairo_renderer) >= 1) && (palette_mapped == false))
- {
-#ifdef NS_AMIGA_CAIRO
- cairo_matrix_t old_ctm, n_ctm;
-
- /* Save CTM */
- cairo_get_matrix(glob->cr, &old_ctm);
-
- /* Set up line style and width */
- cairo_set_line_width(glob->cr, 1);
- ami_cairo_set_solid(glob->cr);
-
- /* Load new CTM */
- n_ctm.xx = transform[0];
- n_ctm.yx = transform[1];
- n_ctm.xy = transform[2];
- n_ctm.yy = transform[3];
- n_ctm.x0 = transform[4];
- n_ctm.y0 = transform[5];
-
- cairo_set_matrix(glob->cr, &n_ctm);
-
- /* Construct path */
- for (i = 0; i < n; ) {
- if (p[i] == PLOTTER_PATH_MOVE) {
- cairo_move_to(glob->cr, p[i+1], p[i+2]);
- i += 3;
- } else if (p[i] == PLOTTER_PATH_CLOSE) {
- cairo_close_path(glob->cr);
- i++;
- } else if (p[i] == PLOTTER_PATH_LINE) {
- cairo_line_to(glob->cr, p[i+1], p[i+2]);
- i += 3;
- } else if (p[i] == PLOTTER_PATH_BEZIER) {
- cairo_curve_to(glob->cr, p[i+1], p[i+2],
- p[i+3], p[i+4],
- p[i+5], p[i+6]);
- i += 7;
- } else {
- LOG(("bad path command %f", p[i]));
- /* Reset matrix for safety */
- cairo_set_matrix(glob->cr, &old_ctm);
- return false;
- }
+ if (fill != NS_TRANSPARENT) {
+ ami_plot_setapen(fill);
+ if (c != NS_TRANSPARENT)
+ ami_plot_setopen(c);
+ } else {
+ if (c != NS_TRANSPARENT) {
+ ami_plot_setapen(c);
+ } else {
+ return true; /* wholly transparent */
}
+ }
- /* Restore original CTM */
- cairo_set_matrix(glob->cr, &old_ctm);
-
- /* Now draw path */
- if (fill != NS_TRANSPARENT) {
- ami_cairo_set_colour(glob->cr,fill);
-
- if (c != NS_TRANSPARENT) {
- /* Fill & Stroke */
- cairo_fill_preserve(glob->cr);
- ami_cairo_set_colour(glob->cr,c);
- cairo_stroke(glob->cr);
+ /* Construct path */
+ for (i = 0; i < n; ) {
+ if (p[i] == PLOTTER_PATH_MOVE) {
+ if (fill != NS_TRANSPARENT) {
+ if(AreaMove(glob->rp, p[i+1], p[i+2]) == -1)
+ LOG(("AreaMove: vector list full"));
} else {
- /* Fill only */
- cairo_fill(glob->cr);
+ Move(glob->rp, p[i+1], p[i+2]);
}
- } else if (c != NS_TRANSPARENT) {
- /* Stroke only */
- ami_cairo_set_colour(glob->cr,c);
- cairo_stroke(glob->cr);
- }
-#endif
- } else {
- if (fill != NS_TRANSPARENT) {
- ami_plot_setapen(fill);
- if (c != NS_TRANSPARENT)
- ami_plot_setopen(c);
- } else {
- if (c != NS_TRANSPARENT) {
- ami_plot_setapen(c);
+ /* Keep track for future Bezier curves/closes etc */
+ start_p.x = p[i+1];
+ start_p.y = p[i+2];
+ cur_p.x = start_p.x;
+ cur_p.y = start_p.y;
+ i += 3;
+ } else if (p[i] == PLOTTER_PATH_CLOSE) {
+ if (fill != NS_TRANSPARENT) {
+ if(AreaEnd(glob->rp) == -1)
+ LOG(("AreaEnd: error"));
} else {
- return true; /* wholly transparent */
+ Draw(glob->rp, start_p.x, start_p.y);
}
- }
-
- /* Construct path */
- for (i = 0; i < n; ) {
- if (p[i] == PLOTTER_PATH_MOVE) {
- if (fill != NS_TRANSPARENT) {
- if(AreaMove(glob->rp, p[i+1], p[i+2]) == -1)
- LOG(("AreaMove: vector list full"));
- } else {
- Move(glob->rp, p[i+1], p[i+2]);
- }
- /* Keep track for future Bezier curves/closes etc */
- start_p.x = p[i+1];
- start_p.y = p[i+2];
- cur_p.x = start_p.x;
- cur_p.y = start_p.y;
- i += 3;
- } else if (p[i] == PLOTTER_PATH_CLOSE) {
- if (fill != NS_TRANSPARENT) {
- if(AreaEnd(glob->rp) == -1)
- LOG(("AreaEnd: error"));
- } else {
- Draw(glob->rp, start_p.x, start_p.y);
- }
- i++;
- } else if (p[i] == PLOTTER_PATH_LINE) {
+ i++;
+ } else if (p[i] == PLOTTER_PATH_LINE) {
+ if (fill != NS_TRANSPARENT) {
+ if(AreaDraw(glob->rp, p[i+1], p[i+2]) == -1)
+ LOG(("AreaDraw: vector list full"));
+ } else {
+ Draw(glob->rp, p[i+1], p[i+2]);
+ }
+ cur_p.x = p[i+1];
+ cur_p.y = p[i+2];
+ i += 3;
+ } else if (p[i] == PLOTTER_PATH_BEZIER) {
+ p_a.x = p[i+1];
+ p_a.y = p[i+2];
+ p_b.x = p[i+3];
+ p_b.y = p[i+4];
+ p_c.x = p[i+5];
+ p_c.y = p[i+6];
+
+ for(double t = 0.0; t <= 1.0; t += 0.1) {
+ ami_bezier(&cur_p, &p_a, &p_b, &p_c, t, &p_r);
if (fill != NS_TRANSPARENT) {
- if(AreaDraw(glob->rp, p[i+1], p[i+2]) == -1)
+ if(AreaDraw(glob->rp, p_r.x, p_r.y) == -1)
LOG(("AreaDraw: vector list full"));
} else {
- Draw(glob->rp, p[i+1], p[i+2]);
- }
- cur_p.x = p[i+1];
- cur_p.y = p[i+2];
- i += 3;
- } else if (p[i] == PLOTTER_PATH_BEZIER) {
- p_a.x = p[i+1];
- p_a.y = p[i+2];
- p_b.x = p[i+3];
- p_b.y = p[i+4];
- p_c.x = p[i+5];
- p_c.y = p[i+6];
-
- for(double t = 0.0; t <= 1.0; t += 0.1) {
- ami_bezier(&cur_p, &p_a, &p_b, &p_c, t, &p_r);
- if (fill != NS_TRANSPARENT) {
- if(AreaDraw(glob->rp, p_r.x, p_r.y) == -1)
- LOG(("AreaDraw: vector list full"));
- } else {
- Draw(glob->rp, p_r.x, p_r.y);
- }
- }
- cur_p.x = p_c.x;
- cur_p.y = p_c.y;
- i += 7;
- } else {
- LOG(("bad path command %f", p[i]));
- /* End path for safety if using Area commands */
- if (fill != NS_TRANSPARENT) {
- AreaEnd(glob->rp);
- BNDRYOFF(glob->rp);
+ Draw(glob->rp, p_r.x, p_r.y);
}
- return false;
}
+ cur_p.x = p_c.x;
+ cur_p.y = p_c.y;
+ i += 7;
+ } else {
+ LOG(("bad path command %f", p[i]));
+ /* End path for safety if using Area commands */
+ if (fill != NS_TRANSPARENT) {
+ AreaEnd(glob->rp);
+ BNDRYOFF(glob->rp);
+ }
+ return false;
}
- if (fill != NS_TRANSPARENT)
- BNDRYOFF(glob->rp);
}
+ if (fill != NS_TRANSPARENT)
+ BNDRYOFF(glob->rp);
return true;
}
@@ -1113,3 +838,4 @@ bool ami_plot_screen_is_palettemapped(void)
{
return palette_mapped;
}
+
diff --git a/amiga/plotters.h b/amiga/plotters.h
index db767b60a..501698a41 100755
--- a/amiga/plotters.h
+++ b/amiga/plotters.h
@@ -21,9 +21,6 @@
#include "desktop/plotters.h"
#include <proto/layers.h>
#include <proto/graphics.h>
-#ifdef NS_AMIGA_CAIRO
-#include <cairo/cairo.h>
-#endif
struct gui_globals
{
@@ -34,10 +31,6 @@ struct gui_globals
APTR tmprasbuf;
struct Rectangle rect;
struct MinList *shared_pens;
-#ifdef NS_AMIGA_CAIRO
- cairo_surface_t *surface;
- cairo_t *cr;
-#endif
};
extern const struct plotter_table amiplot;
diff --git a/amiga/plugin_hack.c b/amiga/plugin_hack.c
index f78a67e2d..9bfd7a3d3 100644
--- a/amiga/plugin_hack.c
+++ b/amiga/plugin_hack.c
@@ -132,7 +132,7 @@ void amiga_plugin_hack_destroy(struct content *c)
{
amiga_plugin_hack_content *plugin = (amiga_plugin_hack_content *) c;
- LOG(("amiga_plugin_hack_destroy"));
+ LOG(("amiga_plugin_hack_destroy %p", plugin));
return;
}
diff --git a/amiga/plugin_hack.h b/amiga/plugin_hack.h
index ae79a1f91..3d644ae8b 100644
--- a/amiga/plugin_hack.h
+++ b/amiga/plugin_hack.h
@@ -22,8 +22,6 @@
#include "utils/config.h"
#include "utils/errors.h"
-struct hlcache_handle;
-
nserror amiga_plugin_hack_init(void);
void amiga_plugin_hack_execute(struct hlcache_handle *c);
diff --git a/amiga/print.c b/amiga/print.c
index 4bfce139b..66e5a558c 100644
--- a/amiga/print.c
+++ b/amiga/print.c
@@ -375,10 +375,11 @@ BOOL ami_print_event(struct ami_print_window *pw)
void ami_print(struct hlcache_handle *c, int copies)
{
- double height, print_height;
+ double height;
float scale = nsoption_int(print_scale) / 100.0;
- if(!ami_print_info.msgport) return;
+ if(ami_print_info.msgport == NULL)
+ ami_print_init();
if(!(ami_print_info.PReq =
(struct IODRPTagsReq *)AllocSysObjectTags(ASOT_IOREQUEST,
@@ -450,7 +451,8 @@ struct MsgPort *ami_print_init(void)
void ami_print_free(void)
{
- FreeSysObject(ASOT_PORT,ami_print_info.msgport);
+ FreeSysObject(ASOT_PORT, ami_print_info.msgport);
+ ami_print_info.msgport = NULL;
}
struct MsgPort *ami_print_get_msgport(void)
@@ -491,6 +493,7 @@ void ami_print_end(void)
glob = &browserglob;
ami_print_close_device();
+ ami_print_free();
}
void ami_print_close_device(void)
diff --git a/amiga/resources/Resource.map b/amiga/resources/Resource.map
index 745df4622..dbe02a4bc 100644
--- a/amiga/resources/Resource.map
+++ b/amiga/resources/Resource.map
@@ -1,2 +1,4 @@
# Resource.map
favicon.ico:favicon.png
+default.ico:icons/search.png
+
diff --git a/amiga/resources/Themes/AISS/Resource.map b/amiga/resources/Themes/AISS/Resource.map
index 64ff81699..4fe374aa2 100644
--- a/amiga/resources/Themes/AISS/Resource.map
+++ b/amiga/resources/Themes/AISS/Resource.map
@@ -1,5 +1,6 @@
# Resource.map
favicon.ico:TBimages:list_file
+default.ico:TBimages:list_search
icons/arrow-l.png:TBimages:list_mailreplied
icons/search.png:TBimages:list_search
icons/directory.png:TBimages:list_drawer
diff --git a/amiga/schedule.c b/amiga/schedule.c
index d4b35a509..6222917cf 100755
--- a/amiga/schedule.c
+++ b/amiga/schedule.c
@@ -16,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "utils/schedule.h"
#include "amiga/os3support.h"
-#include "amiga/schedule.h"
#include <proto/exec.h>
#include <proto/timer.h>
@@ -27,6 +25,10 @@
#include <stdbool.h>
#include <pbl.h>
+#include "utils/errors.h"
+
+#include "amiga/schedule.h"
+
struct nscallback
{
struct TimeVal tv;
@@ -37,31 +39,41 @@ struct nscallback
PblHeap *schedule_list;
-void ami_remove_timer_event(struct nscallback *nscb);
-
/**
- * Schedule a callback.
+ * Remove timer event
*
- * \param t interval before the callback should be made / cs
- * \param callback callback function
- * \param p user parameter, passed to callback function
+ * \param nscb callback
*
- * The callback function will be called as soon as possible after t cs have
- * passed.
+ * The timer event for the callback is aborted
*/
-void schedule(int t, void (*callback)(void *p), void *p)
+static void ami_schedule_remove_timer_event(struct nscallback *nscb)
{
- struct nscallback *nscb;
- struct TimeVal tv;
- ULONG time_us = 0;
+ if(!nscb) return;
- if(schedule_list == NULL) return;
+ if(nscb->treq)
+ {
+ if(CheckIO((struct IORequest *)nscb->treq)==NULL)
+ AbortIO((struct IORequest *)nscb->treq);
- nscb = AllocVecTagList(sizeof(struct nscallback), NULL);
- if(!nscb) return;
+ WaitIO((struct IORequest *)nscb->treq);
+ FreeVec(nscb->treq);
+ }
+}
+
+/**
+ * Add timer event
+ *
+ * \param nscb callback
+ * \param t time in ms
+ *
+ * NetSurf will be signalled in t ms for this event.
+ */
- time_us = t*10000; /* t converted to µs */
+static nserror ami_schedule_add_timer_event(struct nscallback *nscb, int t)
+{
+ struct TimeVal tv;
+ ULONG time_us = t * 1000; /* t converted to µs */
nscb->tv.Seconds = time_us / 1000000;
nscb->tv.Microseconds = time_us % 1000000;
@@ -69,58 +81,100 @@ void schedule(int t, void (*callback)(void *p), void *p)
GetSysTime(&tv);
AddTime(&nscb->tv,&tv); // now contains time when event occurs
- if(nscb->treq = AllocVecTagList(sizeof(struct TimeRequest), NULL))
- {
+ if(nscb->treq = AllocVecTagList(sizeof(struct TimeRequest), NULL)) {
*nscb->treq = *tioreq;
- nscb->treq->Request.io_Command=TR_ADDREQUEST;
- nscb->treq->Time.Seconds=nscb->tv.Seconds; // secs
- nscb->treq->Time.Microseconds=nscb->tv.Microseconds; // micro
- SendIO((struct IORequest *)nscb->treq);
+ nscb->treq->Request.io_Command=TR_ADDREQUEST;
+ nscb->treq->Time.Seconds=nscb->tv.Seconds; // secs
+ nscb->treq->Time.Microseconds=nscb->tv.Microseconds; // micro
+ SendIO((struct IORequest *)nscb->treq);
+ } else {
+ return NSERROR_NOMEM;
}
- nscb->callback = callback;
- nscb->p = p;
-
- pblHeapInsert(schedule_list, nscb);
+ return NSERROR_OK;
}
/**
- * Unschedule a callback.
+ * Locate a scheduled callback
*
* \param callback callback function
* \param p user parameter, passed to callback function
+ * \param remove remove callback from the heap
*
- * All scheduled callbacks matching both callback and p are removed.
+ * A scheduled callback matching both callback and p is returned, or NULL if none present.
*/
-void schedule_remove(void (*callback)(void *p), void *p)
+static struct nscallback *ami_schedule_locate(void (*callback)(void *p), void *p, bool remove)
{
PblIterator *iterator;
struct nscallback *nscb;
- bool restoreheap = false;
+ bool found_cb = false;
- if(schedule_list == NULL) return;
- if(pblHeapIsEmpty(schedule_list)) return;
+ /* check there is something on the list */
+ if (schedule_list == NULL) return NULL;
+ if(pblHeapIsEmpty(schedule_list)) return NULL;
iterator = pblHeapIterator(schedule_list);
- while ((nscb = pblIteratorNext(iterator)) != -1)
- {
- if((nscb->callback == callback) && (nscb->p == p))
- {
- ami_remove_timer_event(nscb);
- pblIteratorRemove(iterator);
- FreeVec(nscb);
- restoreheap = true;
+ while ((nscb = pblIteratorNext(iterator)) != -1) {
+ if ((nscb->callback == callback) && (nscb->p == p)) {
+ if (remove == true) pblIteratorRemove(iterator);
+ found_cb = true;
+ break;
}
};
pblIteratorFree(iterator);
- if(restoreheap) pblHeapConstruct(schedule_list);
+ if (found_cb == true) return nscb;
+ else return NULL;
+}
+
+/**
+ * Reschedule a callback.
+ *
+ * \param nscb callback
+ * \param t time in ms
+ *
+ * The nscallback will be rescheduled for t ms.
+ */
+
+static nserror ami_schedule_reschedule(struct nscallback *nscb, int t)
+{
+ ami_schedule_remove_timer_event(nscb);
+ if (ami_schedule_add_timer_event(nscb, t) != NSERROR_OK)
+ return NSERROR_NOMEM;
+
+ pblHeapConstruct(schedule_list);
+ return NSERROR_OK;
}
-void schedule_remove_all(void)
+/**
+ * Unschedule a callback.
+ *
+ * \param callback callback function
+ * \param p user parameter, passed to callback function
+ *
+ * All scheduled callbacks matching both callback and p are removed.
+ */
+
+static nserror schedule_remove(void (*callback)(void *p), void *p)
+{
+ PblIterator *iterator;
+ struct nscallback *nscb;
+
+ nscb = ami_schedule_locate(callback, p, true);
+
+ if(nscb != NULL) {
+ ami_schedule_remove_timer_event(nscb);
+ FreeVec(nscb);
+ pblHeapConstruct(schedule_list);
+ }
+
+ return NSERROR_OK;
+}
+
+static void schedule_remove_all(void)
{
PblIterator *iterator;
struct nscallback *nscb;
@@ -131,7 +185,7 @@ void schedule_remove_all(void)
while ((nscb = pblIteratorNext(iterator)) != -1)
{
- ami_remove_timer_event(nscb);
+ ami_schedule_remove_timer_event(nscb);
pblIteratorRemove(iterator);
FreeVec(nscb);
};
@@ -139,13 +193,16 @@ void schedule_remove_all(void)
pblIteratorFree(iterator);
}
-/**
- * Process events up to current time.
- * This implementation only takes the top entry off the heap, it does not
- * venture to later scheduled events until the next time it is called -
- * immediately afterwards, if we're in a timer signalled loop.
- */
+static int ami_schedule_compare(const void *prev, const void *next)
+{
+ struct nscallback *nscb1 = *(struct nscallback **)prev;
+ struct nscallback *nscb2 = *(struct nscallback **)next;
+
+ return CmpTime(&nscb1->tv, &nscb2->tv);
+}
+
+/* exported function documented in amiga/schedule.h */
void schedule_run(BOOL poll)
{
struct nscallback *nscb;
@@ -170,34 +227,13 @@ void schedule_run(BOOL poll)
callback = nscb->callback;
p = nscb->p;
- ami_remove_timer_event(nscb);
+ ami_schedule_remove_timer_event(nscb);
pblHeapRemoveFirst(schedule_list);
FreeVec(nscb);
callback(p);
}
-void ami_remove_timer_event(struct nscallback *nscb)
-{
- if(!nscb) return;
-
- if(nscb->treq)
- {
- if(CheckIO((struct IORequest *)nscb->treq)==NULL)
- AbortIO((struct IORequest *)nscb->treq);
-
- WaitIO((struct IORequest *)nscb->treq);
- FreeVec(nscb->treq);
- }
-}
-
-int ami_schedule_compare(const void *prev, const void *next)
-{
- struct nscallback *nscb1 = *(struct nscallback **)prev;
- struct nscallback *nscb2 = *(struct nscallback **)next;
-
- return CmpTime(&nscb1->tv, &nscb2->tv);
-}
-
+/* exported function documented in amiga/schedule.h */
BOOL ami_schedule_create(void)
{
schedule_list = pblHeapNew();
@@ -206,6 +242,7 @@ BOOL ami_schedule_create(void)
pblHeapSetCompareFunction(schedule_list, ami_schedule_compare);
}
+/* exported function documented in amiga/schedule.h */
void ami_schedule_free(void)
{
schedule_remove_all();
@@ -213,6 +250,7 @@ void ami_schedule_free(void)
schedule_list = NULL;
}
+/* exported function documented in amiga/schedule.h */
void ami_schedule_open_timer(void)
{
msgport = AllocSysObjectTags(ASOT_PORT,
@@ -231,14 +269,38 @@ void ami_schedule_open_timer(void)
ITimer = (struct TimerIFace *)GetInterface((struct Library *)TimerBase,"main",1,NULL);
}
+/* exported function documented in amiga/schedule.h */
void ami_schedule_close_timer(void)
{
- if(ITimer)
- {
- DropInterface((struct Interface *)ITimer);
- }
-
+ if(ITimer) DropInterface((struct Interface *)ITimer);
CloseDevice((struct IORequest *) tioreq);
FreeSysObject(ASOT_IOREQUEST,tioreq);
FreeSysObject(ASOT_PORT,msgport);
}
+
+/* exported function documented in amiga/schedule.h */
+nserror ami_schedule(int t, void (*callback)(void *p), void *p)
+{
+ struct nscallback *nscb;
+
+ if(schedule_list == NULL) return NSERROR_INIT_FAILED;
+ if (t < 0) return schedule_remove(callback, p);
+
+ if (nscb = ami_schedule_locate(callback, p, false)) {
+ return ami_schedule_reschedule(nscb, t);
+ }
+
+ nscb = AllocVecTagList(sizeof(struct nscallback), NULL);
+ if(!nscb) return NSERROR_NOMEM;
+
+ if (ami_schedule_add_timer_event(nscb, t) != NSERROR_OK)
+ return NSERROR_NOMEM;
+
+ nscb->callback = callback;
+ nscb->p = p;
+
+ pblHeapInsert(schedule_list, nscb);
+
+ return NSERROR_OK;
+}
+
diff --git a/amiga/schedule.h b/amiga/schedule.h
index 3eddc8913..659230627 100755
--- a/amiga/schedule.h
+++ b/amiga/schedule.h
@@ -19,7 +19,6 @@
#ifndef AMIGA_SCHEDULE_H
#define AMIGA_SCHEDULE_H
#include <proto/timer.h>
-#include "utils/schedule.h"
#include "amiga/os3support.h"
struct Device *TimerBase;
@@ -28,9 +27,42 @@ struct TimerIFace *ITimer;
struct TimeRequest *tioreq;
struct MsgPort *msgport;
-void ami_schedule_open_timer(void);
-void ami_schedule_close_timer(void);
+/**
+ * Schedule a callback.
+ *
+ * \param t interval before the callback should be made / ms
+ * \param callback callback function
+ * \param p user parameter, passed to callback function
+ * \return NSERROR_OK on sucess or appropriate error on faliure
+ *
+ * The callback function will be called as soon as possible after t ms have
+ * passed.
+ */
+nserror ami_schedule(int t, void (*callback)(void *p), void *p);
+
+/**
+ * Initialise amiga scheduler
+ *
+ * /return true if initialised ok or false on error.
+ */
BOOL ami_schedule_create(void);
+
+/**
+ * Finalise amiga scheduler
+ *
+ */
void ami_schedule_free(void);
+
+/**
+ * Process events up to current time.
+ *
+ * This implementation only takes the top entry off the heap, it does not
+ * venture to later scheduled events until the next time it is called -
+ * immediately afterwards, if we're in a timer signalled loop.
+ */
void schedule_run(BOOL poll);
+
+void ami_schedule_open_timer(void);
+void ami_schedule_close_timer(void);
+
#endif
diff --git a/amiga/search.c b/amiga/search.c
index 17a2d453c..53754145a 100755
--- a/amiga/search.c
+++ b/amiga/search.c
@@ -69,14 +69,15 @@ static void ami_search_add_recent(const char *string, void *p);
static void ami_search_set_forward_state(bool active, void *p);
static void ami_search_set_back_state(bool active, void *p);
-static struct gui_search_callbacks ami_search_callbacks = {
- ami_search_set_forward_state,
- ami_search_set_back_state,
+static struct gui_search_table search_table = {
ami_search_set_status,
ami_search_set_hourglass,
- ami_search_add_recent
+ ami_search_add_recent,
+ ami_search_set_forward_state,
+ ami_search_set_back_state,
};
+struct gui_search_table *amiga_search_table = &search_table;
/**
* Change the displayed search status.
@@ -90,8 +91,6 @@ void ami_search_open(struct gui_window *gwin)
if(fwin)
{
browser_window_search_clear(fwin->gwin->shared->bw);
- ami_search_set_forward_state(true, NULL);
- ami_search_set_back_state(true, NULL);
fwin->gwin->shared->searchwin = NULL;
fwin->gwin = gwin;
gwin->shared->searchwin = fwin;
@@ -177,8 +176,6 @@ void ami_search_open(struct gui_window *gwin)
void ami_search_close(void)
{
browser_window_search_clear(fwin->gwin->shared->bw);
- ami_search_set_forward_state(true, NULL);
- ami_search_set_back_state(true, NULL);
fwin->gwin->shared->searchwin = NULL;
DisposeObject(fwin->objects[OID_MAIN]);
DelObject(fwin->node);
@@ -201,12 +198,7 @@ BOOL ami_search_event(void)
switch(result & WMHI_GADGETMASK)
{
case GID_SEARCHSTRING:
- browser_window_search_clear(
- fwin->gwin->shared->bw);
- ami_search_set_forward_state(
- true, NULL);
- ami_search_set_back_state(
- true, NULL);
+ browser_window_search_clear(fwin->gwin->shared->bw);
RefreshSetGadgetAttrs((struct Gadget *)fwin->objects[GID_PREV],
fwin->win, NULL,
@@ -226,7 +218,7 @@ BOOL ami_search_event(void)
ami_search_flags();
browser_window_search(
fwin->gwin->shared->bw,
- &ami_search_callbacks, NULL,
+ NULL,
flags, ami_search_string());
ActivateWindow(fwin->gwin->shared->win);
break;
@@ -237,7 +229,7 @@ BOOL ami_search_event(void)
ami_search_flags();
browser_window_search(
fwin->gwin->shared->bw,
- &ami_search_callbacks, NULL,
+ NULL,
flags, ami_search_string());
ActivateWindow(fwin->gwin->shared->win);
break;
diff --git a/amiga/search.h b/amiga/search.h
index fde730280..c4f30eb01 100755
--- a/amiga/search.h
+++ b/amiga/search.h
@@ -28,10 +28,10 @@ struct find_window {
struct gui_window *gwin;
};
+struct gui_search_table *amiga_search_table;
+
void ami_search_open(struct gui_window *gwin);
BOOL ami_search_event(void);
void ami_search_close(void);
-char *search_engines_file_location;
-char *search_default_ico_location;
#endif
diff --git a/amiga/sslcert.h b/amiga/sslcert.h
index e308f6231..953142e98 100644
--- a/amiga/sslcert.h
+++ b/amiga/sslcert.h
@@ -19,5 +19,10 @@
#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/stringview/stringview.c b/amiga/stringview/stringview.c
index 5aea939d5..9aa110a55 100755
--- a/amiga/stringview/stringview.c
+++ b/amiga/stringview/stringview.c
@@ -859,7 +859,6 @@ Class *MakeStringClass( void )
void FreeStringClass(Class *cl)
{
- struct Library *libbase;
URLHistory_Free();
FreeClass(cl);
}
diff --git a/amiga/theme.c b/amiga/theme.c
index 03ce01aeb..cc8b55d7f 100644
--- a/amiga/theme.c
+++ b/amiga/theme.c
@@ -36,11 +36,12 @@
#include "amiga/bitmap.h"
#include "amiga/drag.h"
-#include "desktop/browser_private.h"
-#include "utils/nsoption.h"
+#include "amiga/schedule.h"
#include "amiga/theme.h"
+#include "desktop/browser_private.h"
#include "desktop/searchweb.h"
#include "utils/messages.h"
+#include "utils/nsoption.h"
#include "utils/utils.h"
struct BitMap *throbber = NULL;
@@ -123,7 +124,6 @@ int osmouseptr[AMI_LASTPOINTER+1] = {
void ami_theme_init(void)
{
char themefile[1024];
- char searchico[1024];
BPTR lock = 0;
strcpy(themefile,nsoption_charp(theme));
@@ -148,21 +148,17 @@ void ami_theme_init(void)
UnLock(lock);
messages_load(themefile);
}
-
- ami_get_theme_filename(searchico, "theme_search", false);
- search_default_ico_location = (char *)strdup(searchico);
}
void ami_theme_throbber_setup(void)
{
char throbberfile[1024];
- Object *dto;
struct bitmap *bm;
ami_get_theme_filename(throbberfile,"theme_throbber",false);
throbber_frames=atoi(messages_get("theme_throbber_frames"));
throbber_update_interval = atoi(messages_get("theme_throbber_delay"));
- if(throbber_update_interval == 0) throbber_update_interval = 100;
+ if(throbber_update_interval == 0) throbber_update_interval = 250;
bm = ami_bitmap_from_datatype(throbberfile);
throbber = ami_bitmap_get_native(bm, bm->width, bm->height, NULL);
@@ -275,11 +271,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;
@@ -294,7 +285,7 @@ void ami_init_mouse_pointers(void)
for(i=0;i<=AMI_LASTPOINTER;i++)
{
- BPTR ptrfile = 0;
+ BPTR ptrfile;
mouseptrbm[i] = NULL;
mouseptrobj[i] = NULL;
char ptrfname[1024];
@@ -433,16 +424,8 @@ void gui_window_start_throbber(struct gui_window *g)
}
g->throbbing = true;
-
- if((cur_tab == g->tab) || (g->shared->tabs <= 1))
- {
- GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER],
- (ULONG *)&bbox);
-
- if(g->shared->throbber_frame == 0) g->shared->throbber_frame=1;
-
- BltBitMapRastPort(throbber,throbber_width,0,g->shared->win->RPort,bbox->Left,bbox->Top,throbber_width,throbber_height,0x0C0);
- }
+ if(g->shared->throbber_frame == 0) g->shared->throbber_frame = 1;
+ ami_throbber_redraw_schedule(throbber_update_interval, g);
}
void gui_window_stop_throbber(struct gui_window *g)
@@ -462,8 +445,6 @@ void gui_window_stop_throbber(struct gui_window *g)
g->shared->win, NULL);
}
- g->throbbing = false;
-
if((cur_tab == g->tab) || (g->shared->tabs <= 1))
{
GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER],
@@ -472,58 +453,58 @@ void gui_window_stop_throbber(struct gui_window *g)
BltBitMapRastPort(throbber, 0, 0, g->shared->win->RPort, bbox->Left,
bbox->Top, throbber_width, throbber_height, 0x0C0);
}
-// g->shared->throbber_frame = 0;
+
+ g->throbbing = false;
+ ami_throbber_redraw_schedule(-1, g);
}
-void ami_update_throbber(struct gui_window_2 *g,bool redraw)
+static void ami_throbber_update(void *p)
{
+ struct gui_window *g = (struct gui_window *)p;
struct IBox *bbox;
- int frame = g->throbber_frame;
+ int frame = 0;
+ ULONG cur_tab = 0;
if(!g) return;
- if(!g->objects[GID_THROBBER]) return;
+ if(!g->shared->objects[GID_THROBBER]) return;
- if(g->bw->window->throbbing == false)
- {
- frame = 0;
- g->throbber_frame=1;
+ if(g->throbbing == true) {
+ frame = g->shared->throbber_frame;
+ g->shared->throbber_frame++;
+ if(g->shared->throbber_frame > (throbber_frames-1))
+ g->shared->throbber_frame=1;
}
- else
- {
- if(!redraw)
- {
- if(g->throbber_update_count < throbber_update_interval)
- {
- g->throbber_update_count++;
- return;
- }
- g->throbber_update_count = 0;
+ if(g->tab_node && (g->shared->tabs > 1))
+ {
+ GetAttr(CLICKTAB_Current, g->shared->objects[GID_TABS],
+ (ULONG *)&cur_tab);
+ }
- g->throbber_frame++;
- if(g->throbber_frame > (throbber_frames-1))
- g->throbber_frame=1;
+ if((cur_tab == g->tab) || (g->shared->tabs <= 1))
+ {
+ GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER],
+ (ULONG *)&bbox);
- }
+ BltBitMapTags(BLITA_SrcX, throbber_width * frame,
+ BLITA_SrcY, 0,
+ BLITA_DestX, bbox->Left,
+ BLITA_DestY, bbox->Top,
+ BLITA_Width, throbber_width,
+ BLITA_Height, throbber_height,
+ BLITA_Source, throbber,
+ BLITA_Dest, g->shared->win->RPort,
+ BLITA_SrcType, BLITT_BITMAP,
+ BLITA_DestType, BLITT_RASTPORT,
+ // BLITA_UseSrcAlpha, TRUE,
+ TAG_DONE);
}
- GetAttr(SPACE_AreaBox,(Object *)g->objects[GID_THROBBER],(ULONG *)&bbox);
+ if(frame > 0) ami_throbber_redraw_schedule(throbber_update_interval, g);
+}
-/*
- EraseRect(g->win->RPort,bbox->Left,bbox->Top,
- bbox->Left+throbber_width,bbox->Top+throbber_height);
-*/
-
- BltBitMapTags(BLITA_SrcX, throbber_width * frame,
- BLITA_SrcY,0,
- BLITA_DestX,bbox->Left,
- BLITA_DestY,bbox->Top,
- BLITA_Width,throbber_width,
- BLITA_Height,throbber_height,
- BLITA_Source,throbber,
- BLITA_Dest,g->win->RPort,
- BLITA_SrcType,BLITT_BITMAP,
- BLITA_DestType,BLITT_RASTPORT,
-// BLITA_UseSrcAlpha,TRUE,
- TAG_DONE);
+void ami_throbber_redraw_schedule(int t, struct gui_window *g)
+{
+ ami_schedule(t, ami_throbber_update, g);
}
+
diff --git a/amiga/theme.h b/amiga/theme.h
index 3c3931c12..c1aca15d7 100644
--- a/amiga/theme.h
+++ b/amiga/theme.h
@@ -41,4 +41,11 @@ 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 ami_throbber_redraw_schedule(int t, struct gui_window *g);
+
+void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape);
#endif
+
diff --git a/amiga/thumbnail.c b/amiga/thumbnail.c
index 61102feff..9c149129d 100755
--- a/amiga/thumbnail.c
+++ b/amiga/thumbnail.c
@@ -69,7 +69,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
if(GfxBase->LibNode.lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
{
float resample_scale = bitmap->width / (float)plot_width;
- uint32 flags = COMPFLAG_IgnoreDestAlpha | COMPFLAG_SrcAlphaOverride;
+ uint32 flags = COMPFLAG_IgnoreDestAlpha;
if(nsoption_bool(scale_quality)) flags |= COMPFLAG_SrcFilter;
CompositeTags(COMPOSITE_Src,browserglob.bm,bitmap->nativebm,
@@ -84,6 +84,7 @@ bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
COMPTAG_DestHeight,bitmap->height,
COMPTAG_OffsetX,0,
COMPTAG_OffsetY,0,
+ COMPTAG_FriendBitMap, scrn->RastPort.BitMap,
TAG_DONE);
}
else
diff --git a/amiga/tree.c b/amiga/tree.c
index 42eae4fa6..18b071de3 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -304,26 +304,26 @@ void ami_tree_drag_end(struct treeview_window *twin, int x, int y)
BOOL drag;
nsurl *url = NULL;
const char *title = NULL;
+ bool ok = false;
if(drag = ami_drag_in_progress()) ami_drag_icon_close(twin->win);
if(drag && (twin != ami_window_at_pointer(AMINS_TVWINDOW)))
{
if((twin->type == AMI_TREE_HOTLIST) && (hotlist_has_selection())) {
- hotlist_get_selection(&url, &title);
+ ok = hotlist_get_selection(&url, &title);
} else if((twin->type == AMI_TREE_HISTORY) && (global_history_has_selection())) {
- global_history_get_selection(&url, &title);
+ ok = global_history_get_selection(&url, &title);
}
- if((title == NULL) || (title && (url == NULL))) {
+ if((ok == false) || (url == NULL)) {
DisplayBeep(scrn);
} else if(url) {
if(gwin = ami_window_at_pointer(AMINS_WINDOW)) {
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -332,9 +332,11 @@ void ami_tree_drag_end(struct treeview_window *twin, int x, int y)
hotlist_add_entry(url, title, true, y);
}
}
+ tree_mouse_action(twin->tree, twin->mouse_state | twin->key_state,
+ twin->drag_x, twin->drag_y); /* Keep the tree happy */
tree_drag_end(twin->tree, twin->mouse_state,
twin->drag_x, twin->drag_y,
- twin->drag_x, twin->drag_y); /* Keep the tree happy */
+ twin->drag_x, twin->drag_y); /* Keep the tree happier */
} else {
if(tree_drag_status(twin->tree) == TREE_UNKNOWN_DRAG)
DisplayBeep(scrn);
@@ -709,7 +711,7 @@ void ami_tree_close(struct treeview_window *twin)
ami_ssl_free(twin);
}
- ami_gui_hotlist_toolbar_update_all();
+ ami_gui_hotlist_update_all();
}
void ami_tree_update_quals(struct treeview_window *twin)
@@ -1391,11 +1393,11 @@ void ami_tree_redraw_request(int x, int y, int width, int height, void *data)
atrr_data->height = height;
atrr_data->twin = (struct treeview_window *)data;
- /**TODO: Queue these requests properly like the main browser code does
+ /** /todo Queue these requests properly like the main browser code does
**/
if(nsoption_bool(direct_render) == false)
- schedule(0, ami_tree_redraw_req, atrr_data);
+ ami_schedule(0, ami_tree_redraw_req, atrr_data);
else
- schedule(0, ami_tree_redraw_req_dr, atrr_data);
+ ami_schedule(0, ami_tree_redraw_req_dr, atrr_data);
}
diff --git a/amiga/utf8.c b/amiga/utf8.c
index a620ac181..a8e415d45 100755
--- a/amiga/utf8.c
+++ b/amiga/utf8.c
@@ -18,13 +18,44 @@
#include <stdlib.h>
#include <string.h>
-
#include <sys/types.h>
+
#include "utils/utf8.h"
+#include "desktop/gui.h"
#include <proto/exec.h>
#include <proto/diskfont.h>
#include <diskfont/diskfonttag.h>
+#include "amiga/utf8.h"
+
+nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
+{
+ const char *encname = "ISO-8859-1";
+
+#ifdef __amigaos4__
+ LONG charset;
+
+ charset = GetDiskFontCtrl(DFCTRL_CHARSET);
+ encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
+#endif
+
+ return utf8_from_enc(string,encname,len,result,NULL);
+}
+
+nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
+{
+ const char *encname = "ISO-8859-1";
+
+#ifdef __amigaos4__
+ LONG charset;
+
+ charset = GetDiskFontCtrl(DFCTRL_CHARSET);
+ encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
+#endif
+
+ return utf8_to_enc(string,encname,len,result);
+}
+
void ami_utf8_free(char *ptr)
{
if(ptr) free(ptr);
@@ -34,7 +65,7 @@ char *ami_utf8_easy(const char *string)
{
char *localtext;
- if(utf8_to_local_encoding(string,strlen(string),&localtext) == UTF8_CONVERT_OK)
+ if(utf8_to_local_encoding(string,strlen(string),&localtext) == NSERROR_OK)
{
return localtext;
}
@@ -48,7 +79,7 @@ char *ami_to_utf8_easy(const char *string)
{
char *localtext;
- if(utf8_from_local_encoding(string,strlen(string),&localtext) == UTF8_CONVERT_OK)
+ if(utf8_from_local_encoding(string,strlen(string),&localtext) == NSERROR_OK)
{
return localtext;
}
@@ -58,34 +89,10 @@ char *ami_to_utf8_easy(const char *string)
}
}
-utf8_convert_ret utf8_from_local_encoding(const char *string, size_t len,
- char **result)
-{
- const char *encname = "ISO-8859-1";
-
-#ifdef __amigaos4__
- LONG charset;
-
- charset = GetDiskFontCtrl(DFCTRL_CHARSET);
- encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
-#endif
-
- return utf8_from_enc(string,encname,len,result,NULL);
-}
-
-utf8_convert_ret utf8_to_local_encoding(const char *string, size_t len,
- char **result)
-{
- const char *encname = "ISO-8859-1";
-
-#ifdef __amigaos4__
- LONG charset;
-
- charset = GetDiskFontCtrl(DFCTRL_CHARSET);
- encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
-#endif
-
- return utf8_to_enc(string,encname,len,result);
-}
+static struct gui_utf8_table utf8_table = {
+ .utf8_to_local = utf8_to_local_encoding,
+ .local_to_utf8 = utf8_from_local_encoding,
+};
+struct gui_utf8_table *amiga_utf8_table = &utf8_table;
diff --git a/amiga/utf8.h b/amiga/utf8.h
index 7956523ee..065a149f2 100755
--- a/amiga/utf8.h
+++ b/amiga/utf8.h
@@ -18,7 +18,14 @@
#ifndef AMIGA_UTF8_H
#define AMIGA_UTF8_H
+
+extern struct gui_utf8_table *ami_utf8_table;
+
char *ami_utf8_easy(const char *string);
void ami_utf8_free(char *ptr);
char *ami_to_utf8_easy(const char *string);
+
+nserror utf8_from_local_encoding(const char *string, size_t len, char **result);
+nserror utf8_to_local_encoding(const char *string, size_t len, char **result);
+
#endif
diff --git a/amiga/version.c b/amiga/version.c
index 8bc1fbc81..aa5aa5d6f 100644
--- a/amiga/version.c
+++ b/amiga/version.c
@@ -16,22 +16,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "utils/testament.h"
+#include "testament.h"
/* NB: AmigaOS revision numbers start at 1 (not 0) and are monotonically
* incremental (v1.20 is higher than v1.3 and not the same as v1.2).
* Consequently, this version pair may not match the user-facing one in
- * desktop/version.c.
+ * desktop/version.c. Release revisions are prepended with 6000 to ensure
+ * they are higher than CI builds, and make this less confusing.
*/
#define NETSURF_VERSION_MAJOR "3"
#if defined(CI_BUILD)
#define NETSURF_VERSION_MINOR CI_BUILD
#else
-#define NETSURF_VERSION_MINOR "2"
+#define NETSURF_VERSION_MINOR "6000" "3"
#endif
-
static const __attribute__((used)) char *verstag = "\0$VER: NetSurf " NETSURF_VERSION_MAJOR "." NETSURF_VERSION_MINOR " (" WT_COMPILEDATE ")\0";
const char * const verdate = WT_COMPILEDATE;
const char * const verarexx = NETSURF_VERSION_MAJOR "." NETSURF_VERSION_MINOR;
const char * const wt_revid = WT_REVID;
+