From 484fa8b110fb10b19808e73c49b345be638cb1db Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 20 Dec 2012 15:27:07 +0000 Subject: move common include path setup to core Makefile --- Makefile | 7 +++- Makefile.defaults | 2 +- Makefile.sources.javascript | 2 +- amiga/Makefile.target | 2 +- atari/Makefile.target | 2 +- beos/Makefile.target | 93 ++++++++++++++++++++++----------------------- cocoa/Makefile.target | 6 +-- framebuffer/Makefile.target | 2 +- gtk/Makefile.target | 2 +- monkey/Makefile.target | 2 +- riscos/Makefile.target | 8 ++-- windows/Makefile.target | 77 +++++++++++++++++++------------------ 12 files changed, 104 insertions(+), 101 deletions(-) diff --git a/Makefile b/Makefile index baf835421..7a09e6c45 100644 --- a/Makefile +++ b/Makefile @@ -426,9 +426,14 @@ $(eval $(call feature_enabled,LIBICONV_PLUG,-DLIBICONV_PLUG,,glibc internal icon # common libraries without pkg-config support LDFLAGS += -lz +# add top level and build directory to include search path +CFLAGS += -I. -I$(OBJROOT) + +# export the user agent format CFLAGS += -DNETSURF_UA_FORMAT_STRING=\"$(NETSURF_UA_FORMAT_STRING)\" -CFLAGS += -DNETSURF_HOMEPAGE=\"$(NETSURF_HOMEPAGE)\" +# set the default homepage to use +CFLAGS += -DNETSURF_HOMEPAGE=\"$(NETSURF_HOMEPAGE)\" # ---------------------------------------------------------------------------- # General make rules diff --git a/Makefile.defaults b/Makefile.defaults index 812a5a950..7650b381f 100644 --- a/Makefile.defaults +++ b/Makefile.defaults @@ -93,7 +93,7 @@ NETSURF_HOMEPAGE := "about:welcome" NETSURF_USE_LIBICONV_PLUG := YES # Initial CFLAGS. Optimisation level etc. tend to be target specific. -CFLAGS := +CFLAGS := # Default installation/execution prefix PREFIX ?= /usr/local diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript index 76a6ff145..3092d1b2f 100644 --- a/Makefile.sources.javascript +++ b/Makefile.sources.javascript @@ -33,7 +33,7 @@ D_JSAPI_BINDING += $(patsubst %.c,%.d,$(2)) $(2): $(1) $(OBJROOT)/created $$(VQ)echo " GENBIND: $(1)" - $(Q)nsgenbind -I javascript/WebIDL -d $(patsubst %.c,%.d,$(2)) -o $(2) $(1) + $(Q)nsgenbind -I javascript/WebIDL -d $(patsubst %.c,%.d,$(2)) -h $(patsubst %.c,%.h,$(2)) -o $(2) $(1) endef diff --git a/amiga/Makefile.target b/amiga/Makefile.target index ec43fdd30..f2c429998 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -2,7 +2,7 @@ # Amiga target setup # ---------------------------------------------------------------------------- -CFLAGS += -std=c99 -I . -Dnsamiga +CFLAGS += -std=c99 -Dnsamiga ifneq ($(SUBTARGET),os3) CFLAGS += -U__STRICT_ANSI__ -D__USE_INLINE__ -D__USE_BASETYPE__ diff --git a/atari/Makefile.target b/atari/Makefile.target index 7f0573407..8e87a741d 100644 --- a/atari/Makefile.target +++ b/atari/Makefile.target @@ -58,7 +58,7 @@ endif $(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP)) $(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF)) -CFLAGS += -U__STRICT_ANSI__ -std=c99 -I. -Dsmall $(WARNFLAGS) -Dnsatari \ +CFLAGS += -U__STRICT_ANSI__ -std=c99 -Dsmall $(WARNFLAGS) -Dnsatari \ -D_BSD_SOURCE \ -D_XOPEN_SOURCE=600 \ -D_POSIX_C_SOURCE=200112L \ diff --git a/beos/Makefile.target b/beos/Makefile.target index 4edde01a1..7b473dd2f 100644 --- a/beos/Makefile.target +++ b/beos/Makefile.target @@ -3,35 +3,34 @@ # ---------------------------------------------------------------------------- - $(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng) )) - - LDFLAGS += -L/boot/home/config/lib - # for Haiku - LDFLAGS += -L/boot/common/lib - # some people do *not* have libm... - LDFLAGS += -lssl -lcrypto -lcss - $(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny))) - LDFLAGS += -ldom -lparserutils -lhubbub -lwapcaplet - LDFLAGS += -lexpat -lcurl -liconv - - CFLAGS += -I. -O $(WARNFLAGS) -Dnsbeos \ - -D_BSD_SOURCE -D_POSIX_C_SOURCE \ - -Drestrict="" -Wno-multichar - # DEBUG - CFLAGS += -g -O0 - # -DDEBUG=1 - - BEOS_BERES := beres - BEOS_RC := rc - BEOS_XRES := xres - BEOS_SETVER := setversion - BEOS_MIMESET := mimeset - VERSION_FULL := $(shell sed -n '/"/{s/.*"\(.*\)".*/\1/;p;}' desktop/version.c) - VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c) - VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c) - RSRC_BEOS = $(addprefix $(OBJROOT)/,$(subst /,_,$(patsubst %.rdef,%.rsrc,$(RDEF_BEOS)))) - RESOURCES = $(RSRC_BEOS) - ifeq ($(HOST),beos) +$(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng) )) + +LDFLAGS += -L/boot/home/config/lib +# for Haiku +LDFLAGS += -L/boot/common/lib +# some people do *not* have libm... +LDFLAGS += -lssl -lcrypto -lcss +$(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny))) +LDFLAGS += -ldom -lparserutils -lhubbub -lwapcaplet +LDFLAGS += -lexpat -lcurl -liconv + +CFLAGS += -O $(WARNFLAGS) -Dnsbeos -D_BSD_SOURCE -D_POSIX_C_SOURCE \ + -Drestrict="" -Wno-multichar +# DEBUG +CFLAGS += -g -O0 +# -DDEBUG=1 + +BEOS_BERES := beres +BEOS_RC := rc +BEOS_XRES := xres +BEOS_SETVER := setversion +BEOS_MIMESET := mimeset +VERSION_FULL := $(shell sed -n '/"/{s/.*"\(.*\)".*/\1/;p;}' desktop/version.c) +VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c) +VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c) +RSRC_BEOS = $(addprefix $(OBJROOT)/,$(subst /,_,$(patsubst %.rdef,%.rsrc,$(RDEF_BEOS)))) +RESOURCES = $(RSRC_BEOS) +ifeq ($(HOST),beos) CFLAGS += -I/boot/home/config/include \ -I/boot/home/config/include/libmng \ -I/boot/home/config/include/hubbub \ @@ -66,22 +65,22 @@ LDFLAGS += -lstdc++.r4 else LDFLAGS += -lstdc++ -lsupc++ - endif +endif - ifeq ($(HOST),beos) - CFLAGS += -I$(PREFIX)/include - LDFLAGS += -L$(PREFIX)/lib - $(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp,BMP (libnsbmp))) - $(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif,GIF (libnsgif))) - $(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng) )) - else - NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP - NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF - NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG - $(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 )) - endif +ifeq ($(HOST),beos) + CFLAGS += -I$(PREFIX)/include + LDFLAGS += -L$(PREFIX)/lib + $(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp,BMP (libnsbmp))) + $(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif,GIF (libnsgif))) + $(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng) )) +else + NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP + NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF + NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG + $(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 )) +endif # ---------------------------------------------------------------------------- # Source file setup @@ -89,9 +88,9 @@ # S_BEOS are sources purely for the BeOS build S_BEOS := about.cpp bitmap.cpp download.cpp fetch_rsrc.cpp filetype.cpp \ - font.cpp gui.cpp login.cpp gui_options.cpp plotters.cpp scaffolding.cpp \ - search.cpp schedule.cpp thumbnail.cpp treeview.cpp throbber.cpp \ - window.cpp system_colour.cpp + font.cpp gui.cpp login.cpp gui_options.cpp plotters.cpp \ + scaffolding.cpp search.cpp schedule.cpp thumbnail.cpp treeview.cpp \ + throbber.cpp window.cpp system_colour.cpp S_BEOS := $(addprefix beos/,$(S_BEOS)) RDEF_BEOS := res.rdef diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target index d975a0c8f..2da4c5bb4 100644 --- a/cocoa/Makefile.target +++ b/cocoa/Makefile.target @@ -10,11 +10,9 @@ LDFLAGS += -lm -lcurl -liconv LDFLAGS += -lssl -lcrypto - CFLAGS += -I. -O $(WARNFLAGS) -Dnscocoa \ + CFLAGS += -O $(WARNFLAGS) -Dnscocoa \ -D_BSD_SOURCE -D_POSIX_C_SOURCE \ - -std=c99 - - CFLAGS += -g -Os -Wno-uninitialized + -std=c99 -g -Os CFLAGS += $(shell $(PKG_CONFIG) --cflags libhubbub libcss libdom) diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target index f3d91de0d..8ab8804b9 100644 --- a/framebuffer/Makefile.target +++ b/framebuffer/Makefile.target @@ -44,7 +44,7 @@ $(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF)) $(eval $(call pkg_config_find_and_add_enabled,MOZJS,mozjs185,JavaScript)) $(eval $(call pkg_config_find_and_add_enabled,JS,mozilla-js,JavaScript)) -CFLAGS += -std=c99 -g -I. -Dsmall $(WARNFLAGS) \ +CFLAGS += -std=c99 -g -Dsmall $(WARNFLAGS) \ -D_BSD_SOURCE \ -D_XOPEN_SOURCE=600 \ -D_POSIX_C_SOURCE=200112L \ diff --git a/gtk/Makefile.target b/gtk/Makefile.target index f9b5436af..2d1eebf50 100644 --- a/gtk/Makefile.target +++ b/gtk/Makefile.target @@ -51,7 +51,7 @@ GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk \ -D_POSIX_C_SOURCE=200112L \ -D_NETBSD_SOURCE \ -DGTK_RESPATH=\"$(NETSURF_GTK_RESOURCES)\" \ - $(WARNFLAGS) -I. -g + $(WARNFLAGS) -g # non optional pkg-configed libs $(eval $(call pkg_config_find_and_add,libcss,CSS)) diff --git a/monkey/Makefile.target b/monkey/Makefile.target index fa15a50f2..05a32d005 100644 --- a/monkey/Makefile.target +++ b/monkey/Makefile.target @@ -41,7 +41,7 @@ MONKEYCFLAGS := -std=c99 -Dmonkey -Dnsmonkey \ -D_POSIX_C_SOURCE=200112L \ -D_NETBSD_SOURCE \ -DMONKEY_RESPATH=\"$(NETSURF_MONKEY_RESOURCES)\" \ - $(WARNFLAGS) -I. -g \ + $(WARNFLAGS) -g \ $(shell $(PKG_CONFIG) --cflags glib-2.0) \ $(shell $(PKG_CONFIG) --cflags libdom libcurl) \ $(shell $(PKG_CONFIG) --cflags openssl) \ diff --git a/riscos/Makefile.target b/riscos/Makefile.target index e7370e7ee..faefa417f 100644 --- a/riscos/Makefile.target +++ b/riscos/Makefile.target @@ -42,12 +42,10 @@ TPD_RISCOS = $(foreach TPL,$(notdir $(TPL_RISCOS)), \ RESOURCES = $(TPD_RISCOS) split-messages -CFLAGS += -I. $(WARNFLAGS) -Driscos \ - -std=c99 -D_BSD_SOURCE -D_POSIX_C_SOURCE \ - -mpoke-function-name -fno-strict-aliasing +CFLAGS += $(WARNFLAGS) -Driscos -std=c99 -D_BSD_SOURCE -D_POSIX_C_SOURCE \ + -mpoke-function-name -fno-strict-aliasing -CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include \ - -I$(GCCSDK_INSTALL_ENV)/include/libmng +CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include -I$(GCCSDK_INSTALL_ENV)/include/libmng ifeq ($(HOST),riscos) CFLAGS += -I -mthrowback endif diff --git a/windows/Makefile.target b/windows/Makefile.target index 90f97fbea..c373ff593 100644 --- a/windows/Makefile.target +++ b/windows/Makefile.target @@ -3,48 +3,51 @@ # # This file is part of NetSurf - LDFLAGS += -L${GCCSDK_INSTALL_ENV}/lib - CFLAGS += -I${GCCSDK_INSTALL_ENV}/include/ - - NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG - NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE - NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP - NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF - NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG - $(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp,BMP (libnsbmp))) - $(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))) - - ifneq ($(PKG_CONFIG),) - CFLAGS += $(shell $(PKG_CONFIG) --cflags zlib libcares libcurl libhubbub \ - libparserutils libdom libwapcaplet) - LDFLAGS += $(shell $(PKG_CONFIG) --libs zlib libcurl libcares \ - libhubbub libparserutils libcss libdom libwapcaplet) - else - LDFLAGS += -lhubbub -lcss -lparserutils -lwapcaplet -lcurl -lz - endif - - LDFLAGS += -lssl -lcrypto -lregex -liconv \ +LDFLAGS += -L${GCCSDK_INSTALL_ENV}/lib +CFLAGS += -I${GCCSDK_INSTALL_ENV}/include/ + +NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG +NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE +NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP +NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF +NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG + +$(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp,BMP (libnsbmp))) +$(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))) + +ifneq ($(PKG_CONFIG),) + $(eval $(call pkg_config_find_and_add,zlib,ZLib)) + $(eval $(call pkg_config_find_and_add,libcares,Cares)) + $(eval $(call pkg_config_find_and_add,libwapcaplet,Wapcaplet)) + $(eval $(call pkg_config_find_and_add,libparserutils,Parserutils)) + $(eval $(call pkg_config_find_and_add,libhubbub,Hubbub)) + $(eval $(call pkg_config_find_and_add,libdom,DOM)) + $(eval $(call pkg_config_find_and_add,libcss,CSS)) + $(eval $(call pkg_config_find_and_add,libcurl,Curl)) +else + LDFLAGS += -lhubbub -lcss -lparserutils -lwapcaplet -lcurl -lz +endif + +LDFLAGS += -lssl -lcrypto -lregex -liconv \ -lgdi32 -lcomctl32 -lws2_32 -lmsimg32 -mwindows - CFLAGS += -U__STRICT_ANSI__ -mwin32 - # only windows versions after XP are supported - CFLAGS += '-DWINVER=0x0501' - CFLAGS += '-D_WIN32_WINNT=0x0501' - CFLAGS += '-D_WIN32_WINDOWS=0x0501' - CFLAGS += '-D_WIN32_IE=0x0501' +CFLAGS += -U__STRICT_ANSI__ -mwin32 +# only windows versions after XP are supported +CFLAGS += '-DWINVER=0x0501' +CFLAGS += '-D_WIN32_WINNT=0x0501' +CFLAGS += '-D_WIN32_WINDOWS=0x0501' +CFLAGS += '-D_WIN32_IE=0x0501' - #installed resource path - CFLAGS += '-DNETSURF_WINDOWS_RESPATH="$(NETSURF_WINDOWS_RESPATH)"' +#installed resource path +CFLAGS += '-DNETSURF_WINDOWS_RESPATH="$(NETSURF_WINDOWS_RESPATH)"' +WSCFLAGS := -std=c99 $(WARNFLAGS) -DCURL_STATICLIB -DCARES_STATICLIB -g - WSCFLAGS := -std=c99 \ - $(WARNFLAGS) -I. \ - -DCURL_STATICLIB -DCARES_STATICLIB -g - CFLAGS += $(WSCFLAGS) - LDFLAGS += $(WSCFLAGS) +CFLAGS += $(WSCFLAGS) +LDFLAGS += $(WSCFLAGS) # ---------------------------------------------------------------------------- # built-in resource setup -- cgit v1.2.3 From c0f9ae95b9f5ac169f225d2b52d57d05599b6772 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 20 Dec 2012 17:00:06 +0000 Subject: change the javascript bindings to use generated headers --- Makefile.sources.javascript | 13 +-- javascript/jsapi.c | 6 +- javascript/jsapi/binding.h | 159 ------------------------------------ javascript/jsapi/console.bnd | 4 +- javascript/jsapi/event.bnd | 4 +- javascript/jsapi/htmlcollection.bnd | 6 +- javascript/jsapi/htmldocument.bnd | 10 ++- javascript/jsapi/htmlelement.bnd | 7 +- javascript/jsapi/location.bnd | 5 +- javascript/jsapi/navigator.bnd | 5 +- javascript/jsapi/node.bnd | 3 +- javascript/jsapi/nodelist.bnd | 6 +- javascript/jsapi/text.bnd | 6 +- javascript/jsapi/window.bnd | 14 +++- 14 files changed, 59 insertions(+), 189 deletions(-) delete mode 100644 javascript/jsapi/binding.h diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript index 3092d1b2f..4633e9d0d 100644 --- a/Makefile.sources.javascript +++ b/Makefile.sources.javascript @@ -23,9 +23,10 @@ JSAPI_BINDING_text := javascript/jsapi/text.bnd JSAPI_BINDING_node := javascript/jsapi/node.bnd JSAPI_BINDING_event := javascript/jsapi/event.bnd -# 1: input file -# 2: output file -# 3: binding name +# 1: input binding file +# 2: source output file +# 3: header output file +# 4: binding name define convert_jsapi_binding S_JSAPI_BINDING += $(2) @@ -33,7 +34,9 @@ D_JSAPI_BINDING += $(patsubst %.c,%.d,$(2)) $(2): $(1) $(OBJROOT)/created $$(VQ)echo " GENBIND: $(1)" - $(Q)nsgenbind -I javascript/WebIDL -d $(patsubst %.c,%.d,$(2)) -h $(patsubst %.c,%.h,$(2)) -o $(2) $(1) + $(Q)nsgenbind -I javascript/WebIDL -d $(patsubst %.c,%.d,$(2)) -h $(3) -o $(2) $(1) + +$(3): $(2) endef @@ -52,7 +55,7 @@ S_JSAPI := S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI)) -$(eval $(foreach V,$(filter JSAPI_BINDING_%,$(.VARIABLES)),$(call convert_jsapi_binding,$($(V)),$(OBJROOT)/$(patsubst JSAPI_BINDING_%,%,$(V)).c,$(patsubst JSAPI_BINDING_%,%,$(V))_jsapi))) +$(eval $(foreach V,$(filter JSAPI_BINDING_%,$(.VARIABLES)),$(call convert_jsapi_binding,$($(V)),$(OBJROOT)/$(patsubst JSAPI_BINDING_%,%,$(V)).c,$(OBJROOT)/$(patsubst JSAPI_BINDING_%,%,$(V)).h,$(patsubst JSAPI_BINDING_%,%,$(V))_jsapi))) else S_JAVASCRIPT += none.c diff --git a/javascript/jsapi.c b/javascript/jsapi.c index ef34371d1..7b68fe975 100644 --- a/javascript/jsapi.c +++ b/javascript/jsapi.c @@ -17,14 +17,16 @@ */ #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" - +#include "render/html_internal.h" #include "content/content.h" #include "javascript/content.h" #include "javascript/js.h" #include "utils/log.h" +#include "window.h" +#include "event.h" + static JSRuntime *rt; /* global runtime */ void js_initialise(void) diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h deleted file mode 100644 index 7b0f61428..000000000 --- a/javascript/jsapi/binding.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2012 Vincent Sanders - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** \file - * spidermonkey jsapi class bindings - */ - -#ifndef _NETSURF_JAVASCRIPT_JSAPI_BINDING_H_ -#define _NETSURF_JAVASCRIPT_JSAPI_BINDING_H_ - - -#include "render/html_internal.h" - -JSObject *jsapi_InitClass_Window(JSContext *cx, JSObject *parent); - -/** Create a new javascript window object - * - * @param cx The javascript context. - * @param parent The parent object or NULL for new global - * @param win_priv The private context to set on the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_Window(JSContext *cx, - JSObject *window, - JSObject *parent, - struct browser_window *bw, - html_content *htmlc); - -JSObject *jsapi_InitClass_Location(JSContext *cx, JSObject *parent); -JSObject *jsapi_new_Location(JSContext *cx, - JSObject *window, - JSObject *parent, - nsurl *url, - html_content *htmlc); - - -JSObject *jsapi_InitClass_Document(JSContext *cx, JSObject *parent); - -/** Create a new javascript document object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @param doc_priv The private context to set on the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_Document(JSContext *cx, - JSObject *proto, - JSObject *parent, - dom_document *node, - struct html_content *htmlc); - -JSObject *jsapi_InitClass_Console(JSContext *cx, JSObject *parent); -/** Create a new javascript console object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_Console(JSContext *cx, JSObject *prototype, JSObject *parent); - - -JSObject *jsapi_InitClass_Navigator(JSContext *cx, JSObject *parent); -/** Create a new javascript navigator object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_Navigator(JSContext *cx, JSObject *proto, JSObject *parent); - -extern JSClass JSClass_HTMLElement; - -JSObject *jsapi_InitClass_HTMLElement(JSContext *cx, JSObject *parent); -/** Create a new javascript element object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @param doc_priv The private context to set on the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_HTMLElement(JSContext *cx, - JSObject *prototype, - JSObject *parent, - dom_element *node, - struct html_content *htmlc); - -JSObject *jsapi_InitClass_HTMLCollection(JSContext *cx, JSObject *parent); -/** Create a new javascript element object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @param doc_priv The private context to set on the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_HTMLCollection(JSContext *cx, - JSObject *prototype, - JSObject *parent, - dom_html_collection *collection, - struct html_content *htmlc); - -JSObject *jsapi_InitClass_NodeList(JSContext *cx, JSObject *parent); -/** Create a new javascript element object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @param doc_priv The private context to set on the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_NodeList(JSContext *cx, - JSObject *prototype, - JSObject *parent, - dom_nodelist *nodelist, - struct html_content *htmlc); - - -extern JSClass JSClass_Text; - -JSObject *jsapi_InitClass_Text(JSContext *cx, JSObject *parent); -/** Create a new javascript text object - * - * @param cx The javascript context. - * @param parent The parent object, usually a global window object - * @param node The dom node to use in the object - * @return new javascript object or NULL on error - */ -JSObject *jsapi_new_Text(JSContext *cx, - JSObject *prototype, - JSObject *parent, - dom_text *node, - struct html_content *htmlc); - -JSObject *jsapi_InitClass_Node(JSContext *cx, JSObject *parent); -JSObject *jsapi_new_Node(JSContext *cx, - JSObject *prototype, - JSObject *parent); - -extern JSClass JSClass_Event; -JSObject *jsapi_InitClass_Event(JSContext *cx, JSObject *parent); -JSObject *jsapi_new_Event(JSContext *cx, - JSObject *prototype, - JSObject *parent, - dom_event *event); - -#endif diff --git a/javascript/jsapi/console.bnd b/javascript/jsapi/console.bnd index 7c3484529..9b3d21f95 100644 --- a/javascript/jsapi/console.bnd +++ b/javascript/jsapi/console.bnd @@ -19,9 +19,9 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" + +#include "console.h" %} diff --git a/javascript/jsapi/event.bnd b/javascript/jsapi/event.bnd index cc03c920a..b0880d91e 100644 --- a/javascript/jsapi/event.bnd +++ b/javascript/jsapi/event.bnd @@ -21,9 +21,9 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" + +#include "event.h" %} diff --git a/javascript/jsapi/htmlcollection.bnd b/javascript/jsapi/htmlcollection.bnd index 5e99e48b8..38e14ed1d 100644 --- a/javascript/jsapi/htmlcollection.bnd +++ b/javascript/jsapi/htmlcollection.bnd @@ -23,9 +23,11 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "render/html_internal.h" + +#include "htmlelement.h" +#include "htmlcollection.h" %} diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd index c29e470c2..ddf408a9f 100644 --- a/javascript/jsapi/htmldocument.bnd +++ b/javascript/jsapi/htmldocument.bnd @@ -25,12 +25,16 @@ preamble %{ #include "utils/log.h" #include "utils/corestrings.h" #include "utils/libdom.h" - #include "content/urldb.h" - #include "javascript/js.h" #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "render/html_internal.h" + +#include "htmldocument.h" +#include "htmlelement.h" +#include "text.h" +#include "nodelist.h" +#include "location.h" %} diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd index 3ede93bbf..48ebbdb64 100644 --- a/javascript/jsapi/htmlelement.bnd +++ b/javascript/jsapi/htmlelement.bnd @@ -24,10 +24,13 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" #include "utils/corestrings.h" - #include "javascript/js.h" #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "render/html_internal.h" + +#include "htmlelement.h" +#include "text.h" +#include "location.h" %} diff --git a/javascript/jsapi/location.bnd b/javascript/jsapi/location.bnd index 32677d1b5..85117a2ce 100644 --- a/javascript/jsapi/location.bnd +++ b/javascript/jsapi/location.bnd @@ -21,9 +21,10 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "render/html_internal.h" + +#include "location.h" %} diff --git a/javascript/jsapi/navigator.bnd b/javascript/jsapi/navigator.bnd index e63e9a9fd..d040edec2 100644 --- a/javascript/jsapi/navigator.bnd +++ b/javascript/jsapi/navigator.bnd @@ -24,14 +24,13 @@ preamble %{ #include "desktop/netsurf.h" #include "desktop/options.h" - #include "utils/config.h" #include "utils/useragent.h" #include "utils/log.h" #include "utils/utsname.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" + +#include "navigator.h" /* * navigator properties for netsurf diff --git a/javascript/jsapi/node.bnd b/javascript/jsapi/node.bnd index bcf0ef7b3..49fd06bc5 100644 --- a/javascript/jsapi/node.bnd +++ b/javascript/jsapi/node.bnd @@ -23,7 +23,8 @@ preamble %{ #include "utils/log.h" #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" + +#include "node.h" %} diff --git a/javascript/jsapi/nodelist.bnd b/javascript/jsapi/nodelist.bnd index b57dc6e05..4aa8c47f5 100644 --- a/javascript/jsapi/nodelist.bnd +++ b/javascript/jsapi/nodelist.bnd @@ -20,9 +20,11 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "render/html_internal.h" + +#include "nodelist.h" +#include "htmlelement.h" %} diff --git a/javascript/jsapi/text.bnd b/javascript/jsapi/text.bnd index 42791d081..6b4352116 100644 --- a/javascript/jsapi/text.bnd +++ b/javascript/jsapi/text.bnd @@ -23,9 +23,11 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" - +#include "render/html_internal.h" #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" + +#include "text.h" +#include "htmlelement.h" %} diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd index 6153e90aa..288b5b3d8 100644 --- a/javascript/jsapi/window.bnd +++ b/javascript/jsapi/window.bnd @@ -24,10 +24,20 @@ preamble %{ #include "utils/config.h" #include "utils/log.h" #include "utils/corestrings.h" - +#include "render/html_internal.h" #include "javascript/jsapi.h" -#include "javascript/jsapi/binding.h" +#include "console.h" +#include "navigator.h" +#include "event.h" +#include "node.h" +#include "htmlcollection.h" +#include "nodelist.h" +#include "htmldocument.h" +#include "text.h" +#include "htmlelement.h" +#include "window.h" +#include "location.h" %} -- cgit v1.2.3 From 27873fa9fee23c6cd0f498420c5130aec7379aa0 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 20 Dec 2012 17:17:42 +0000 Subject: add explicit stdlib include for definition of free() --- javascript/jsapi/event.bnd | 1 + 1 file changed, 1 insertion(+) diff --git a/javascript/jsapi/event.bnd b/javascript/jsapi/event.bnd index b0880d91e..b8b0aff47 100644 --- a/javascript/jsapi/event.bnd +++ b/javascript/jsapi/event.bnd @@ -16,6 +16,7 @@ hdrcomment "Released under the terms of the MIT License,"; hdrcomment " http://www.opensource.org/licenses/mit-license"; preamble %{ +#include #include -- cgit v1.2.3 From 68565113f382cc742dd6cb4f685f68996ed32779 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 20 Dec 2012 17:34:17 +0000 Subject: link order matters --- windows/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/Makefile.target b/windows/Makefile.target index c373ff593..33a9492af 100644 --- a/windows/Makefile.target +++ b/windows/Makefile.target @@ -20,13 +20,13 @@ $(eval $(call feature_enabled,MNG,,-llcms -ljpeg,PNG/JNG/MNG (libmng))) ifneq ($(PKG_CONFIG),) $(eval $(call pkg_config_find_and_add,zlib,ZLib)) + $(eval $(call pkg_config_find_and_add,libcurl,Curl)) $(eval $(call pkg_config_find_and_add,libcares,Cares)) $(eval $(call pkg_config_find_and_add,libwapcaplet,Wapcaplet)) $(eval $(call pkg_config_find_and_add,libparserutils,Parserutils)) $(eval $(call pkg_config_find_and_add,libhubbub,Hubbub)) $(eval $(call pkg_config_find_and_add,libdom,DOM)) $(eval $(call pkg_config_find_and_add,libcss,CSS)) - $(eval $(call pkg_config_find_and_add,libcurl,Curl)) else LDFLAGS += -lhubbub -lcss -lparserutils -lwapcaplet -lcurl -lz endif -- cgit v1.2.3 From 0402b5ca91a9c05e325d7ad94fb7fcfbe9633165 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 26 Dec 2012 17:47:41 +0000 Subject: fixup combo boxes to have content, missed in conversion from glade --- gtk/res/options.gtk2.ui | 181 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 165 insertions(+), 16 deletions(-) diff --git a/gtk/res/options.gtk2.ui b/gtk/res/options.gtk2.ui index 0f50ecce6..1a17cc104 100644 --- a/gtk/res/options.gtk2.ui +++ b/gtk/res/options.gtk2.ui @@ -297,7 +297,6 @@ True True - 1 @@ -467,6 +466,13 @@ True + liststore_proxytype + + + + 0 + + 1 @@ -623,7 +629,6 @@ True True - 1 @@ -636,7 +641,6 @@ True True - 1 @@ -651,7 +655,6 @@ True True - 1 @@ -815,7 +818,6 @@ True True - 1 1 True @@ -1072,6 +1074,13 @@ True + liststore_defaultfont + + + + 0 + + 1 @@ -1160,8 +1169,8 @@ True True - 1 + True 1 @@ -1174,7 +1183,6 @@ True True - 1 @@ -1356,7 +1364,6 @@ True True - 1 @@ -1428,7 +1435,6 @@ True True - 1 @@ -1618,9 +1624,9 @@ True - select-folder True - 25 + select-folder + 23 1 @@ -1722,6 +1728,13 @@ True + liststore_tabpositions + + + + 0 + + 1 @@ -1850,6 +1863,13 @@ True + liststore_searchproviders + + + + 0 + + 2 @@ -1986,7 +2006,6 @@ True True - 1 @@ -2000,7 +2019,6 @@ True True - 1 @@ -2066,7 +2084,6 @@ True True - 1 @@ -2080,7 +2097,6 @@ True True - 1 @@ -2158,7 +2174,6 @@ True True - 1 @@ -2414,4 +2429,138 @@ close + + + + + + + + Top + + + Left + + + Right + + + Bottom + + + + + + + + + + + Google + + + Yahoo! + + + Microsoft Live + + + Buisness.com + + + Omgili + + + BBC News + + + Ubuntu Packages + + + Creative Commons + + + Ask + + + Answers + + + Dictionary.com + + + Youtube + + + AeroMp3 + + + AOL + + + Baidu + + + Amazon + + + Ebay + + + IMDB + + + ESPN + + + Wikipedia + + + DuckDuckGo + + + + + + + + + + + Sans-serif + + + Serif + + + Monospace + + + Cursive + + + Fantasy + + + + + + + + + + + No proxy + + + Simple proxy + + + Basic authentication + + + NTLM authentication + + + -- cgit v1.2.3 From f12be4ed854d9dd44fa6e3117fe8bd9525deae51 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 28 Dec 2012 01:08:23 +0000 Subject: restructure GTK frontend options dialog to be compiant with the gnome HIG and actually work --- gtk/dialogs/options.c | 362 +++--- gtk/res/options.gtk2.ui | 2911 +++++++++++++++++++++++------------------------ gtk/res/options.gtk3.ui | 2 +- 3 files changed, 1687 insertions(+), 1588 deletions(-) diff --git a/gtk/dialogs/options.c b/gtk/dialogs/options.c index a449e6fb9..8bd5665a3 100644 --- a/gtk/dialogs/options.c +++ b/gtk/dialogs/options.c @@ -46,8 +46,6 @@ static GtkBuilder *gladeFile; static struct browser_window *current_browser; -static int proxy_type; - static void dialog_response_handler (GtkDialog *dlg, gint res_id); static gboolean on_dialog_close (GtkDialog *dlg, gboolean stay_alive); static void nsgtk_options_theme_combo(void); @@ -66,30 +64,35 @@ DECLARE(checkDisablePlugins); DECLARE(spinHistoryAge); DECLARE(checkHoverURLs); DECLARE(checkDisplayRecentURLs); -DECLARE(comboLanguage); +//DECLARE(comboboxLanguage); +static GtkWidget *comboboxLanguage; +static gboolean on_comboboxLanguage_changed(GtkComboBox *combo, gpointer data); DECLARE(checkSendReferer); +DECLARE(checkSendDNT); DECLARE(comboProxyType); DECLARE(entryProxyHost); -DECLARE(entryProxyPort); +DECLARE(spinProxyPort); DECLARE(entryProxyUser); DECLARE(entryProxyPassword); DECLARE(spinMaxFetchers); DECLARE(spinFetchesPerHost); DECLARE(spinCachedConnections); +DECLARE(checkEnableJavascript); + DECLARE(checkResampleImages); DECLARE(spinAnimationSpeed); -DECLARE(checkDisableAnimations); +DECLARE(checkEnableAnimations); -DECLARE(fontSansSerif); -DECLARE(fontSerif); -DECLARE(fontMonospace); -DECLARE(fontCursive); -DECLARE(fontFantasy); +//DECLARE(fontSansSerif); +//DECLARE(fontSerif); +//DECLARE(fontMonospace); +//DECLARE(fontCursive); +//DECLARE(fontFantasy); DECLARE(comboDefault); DECLARE(spinDefaultSize); -DECLARE(spinMinimumSize); +//DECLARE(spinMinimumSize); DECLARE(fontPreview); DECLARE(comboButtonType); @@ -123,7 +126,7 @@ DECLARE(checkRemoveBackgrounds); DECLARE(checkFitPage); DECLARE(checkCompressPDF); DECLARE(checkPasswordPDF); -DECLARE(setDefaultExportOptions); +//DECLARE(setDefaultExportOptions); /* Used when the feature is not implemented yet */ #define FIND_WIDGET(wname) \ @@ -135,12 +138,22 @@ DECLARE(setDefaultExportOptions); /* Assigns widget and connects it to its callback function */ #define CONNECT(wname, event) \ + do { \ + if ((wname) == NULL) \ + LOG(("Unable to find widget '%s'!", #wname)); \ + else \ g_signal_connect(G_OBJECT(wname), event, \ - G_CALLBACK(on_##wname##_changed), NULL) + G_CALLBACK(on_##wname##_changed), NULL); \ + } while (0) -GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent) +/* exported interface documented in gtk/dialogs/options.h */ +GtkDialog* +nsgtk_options_init(struct browser_window *bw, GtkWindow *parent) { - GError* error = NULL; + GError *error = NULL; + GObject *dlgobject; + //GSList *group; + gladeFile = gtk_builder_new(); if (!gtk_builder_add_from_file(gladeFile, glade_file_location->options, &error)) { g_warning("Couldn't load builder file: %s", error->message); @@ -148,18 +161,25 @@ GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent) return NULL; } + + dlgobject = gtk_builder_get_object(gladeFile, "dialogPreferences"); + if (dlgobject == NULL) { + LOG(("Unable to get object for preferences dialog")); + return NULL; + } + current_browser = bw; - wndPreferences = GTK_DIALOG(gtk_builder_get_object(gladeFile, "dlgPreferences")); + wndPreferences = GTK_DIALOG(dlgobject); gtk_window_set_transient_for(GTK_WINDOW(wndPreferences), parent); + + /* set the widgets to reflect the current options */ + nsgtk_options_load(); FIND_WIDGET(sourceButtonTab); FIND_WIDGET(sourceButtonWindow); - GSList *group = gtk_radio_button_get_group(GTK_RADIO_BUTTON( - sourceButtonWindow)); - gtk_radio_button_set_group(GTK_RADIO_BUTTON(sourceButtonTab), group); + //group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(sourceButtonWindow)); + //gtk_radio_button_set_group(GTK_RADIO_BUTTON(sourceButtonTab), group); - /* set the widgets to reflect the current options */ - nsgtk_options_load(); /* Connect all widgets to their appropriate callbacks */ CONNECT(entryHomePageURL, "focus-out-event"); @@ -172,33 +192,37 @@ GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent) CONNECT(spinHistoryAge, "focus-out-event"); CONNECT(checkHoverURLs, "toggled"); - CONNECT(comboLanguage, "changed"); + CONNECT(comboboxLanguage, "changed"); CONNECT(checkDisplayRecentURLs, "toggled"); CONNECT(checkSendReferer, "toggled"); + CONNECT(checkSendDNT, "toggled"); CONNECT(checkShowSingleTab, "toggled"); CONNECT(comboProxyType, "changed"); CONNECT(entryProxyHost, "focus-out-event"); - CONNECT(entryProxyPort, "focus-out-event"); + CONNECT(spinProxyPort, "focus-out-event"); CONNECT(entryProxyUser, "focus-out-event"); CONNECT(entryProxyPassword, "focus-out-event"); CONNECT(spinMaxFetchers, "value-changed"); CONNECT(spinFetchesPerHost, "value-changed"); CONNECT(spinCachedConnections, "value-changed"); + CONNECT(checkEnableJavascript, "toggled"); + CONNECT(checkResampleImages, "toggled"); CONNECT(spinAnimationSpeed, "value-changed"); - CONNECT(checkDisableAnimations, "toggled"); + CONNECT(checkEnableAnimations, "toggled"); - CONNECT(fontSansSerif, "font-set"); +/* CONNECT(fontSansSerif, "font-set"); CONNECT(fontSerif, "font-set"); CONNECT(fontMonospace, "font-set"); CONNECT(fontCursive, "font-set"); CONNECT(fontFantasy, "font-set"); + CONNECT(spinMinimumSize, "value-changed"); +*/ CONNECT(comboDefault, "changed"); CONNECT(spinDefaultSize, "value-changed"); - CONNECT(spinMinimumSize, "value-changed"); CONNECT(fontPreview, "clicked"); CONNECT(comboButtonType, "changed"); @@ -231,7 +255,7 @@ GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent) CONNECT(checkFitPage, "toggled"); CONNECT(checkCompressPDF, "toggled"); CONNECT(checkPasswordPDF, "toggled"); - CONNECT(setDefaultExportOptions, "clicked"); +// CONNECT(setDefaultExportOptions, "clicked"); g_signal_connect(G_OBJECT(wndPreferences), "response", G_CALLBACK (dialog_response_handler), NULL); @@ -291,53 +315,122 @@ GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent) (widget) = GTK_WIDGET(gtk_builder_get_object(gladeFile, #widget)); \ } while (0) +static void set_proxy_widgets_sensitivity(int proxyval) +{ + switch (proxyval) { + case 0: /* no proxy */ + gtk_widget_set_sensitive(entryProxyHost, FALSE); + gtk_widget_set_sensitive(spinProxyPort, FALSE); + gtk_widget_set_sensitive(entryProxyUser, FALSE); + gtk_widget_set_sensitive(entryProxyPassword, FALSE); + break; + + case 1: /* proxy with no auth */ + gtk_widget_set_sensitive(entryProxyHost, TRUE); + gtk_widget_set_sensitive(spinProxyPort, TRUE); + gtk_widget_set_sensitive(entryProxyUser, FALSE); + gtk_widget_set_sensitive(entryProxyPassword, FALSE); + break; + + case 2: /* proxy with basic auth */ + gtk_widget_set_sensitive(entryProxyHost, TRUE); + gtk_widget_set_sensitive(spinProxyPort, TRUE); + gtk_widget_set_sensitive(entryProxyUser, TRUE); + gtk_widget_set_sensitive(entryProxyPassword, TRUE); + break; + + case 3: /* proxy with ntlm auth */ + gtk_widget_set_sensitive(entryProxyHost, TRUE); + gtk_widget_set_sensitive(spinProxyPort, TRUE); + gtk_widget_set_sensitive(entryProxyUser, TRUE); + gtk_widget_set_sensitive(entryProxyPassword, TRUE); + break; + + case 4: /* system proxy */ + gtk_widget_set_sensitive(entryProxyHost, FALSE); + gtk_widget_set_sensitive(spinProxyPort, FALSE); + gtk_widget_set_sensitive(entryProxyUser, FALSE); + gtk_widget_set_sensitive(entryProxyPassword, FALSE); + break; + + } +} void nsgtk_options_load(void) { - GtkBox *box; const char *default_accept_language = "en"; const char *default_homepage_url = ""; - const char *default_http_proxy_host = ""; - const char *default_http_proxy_auth_user = ""; - const char *default_http_proxy_auth_pass = ""; - int combo_row_count = 0; + const char *default_http_proxy_host; + const char *default_http_proxy_auth_user; + const char *default_http_proxy_auth_pass; + int active_language = 0; + GtkListStore *liststore; + GtkTreeIter iter; + int proxytype = 0; FILE *fp; char buf[50]; - /* get widget text */ - if (nsoption_charp(accept_language) != NULL) { - default_accept_language = nsoption_charp(accept_language); - } + /* Network - HTTP Proxy */ + default_http_proxy_host = nsoption_charp(http_proxy_host); + default_http_proxy_auth_user = nsoption_charp(http_proxy_auth_user); + default_http_proxy_auth_pass = nsoption_charp(http_proxy_auth_pass); - if (nsoption_charp(homepage_url) != NULL) { - default_homepage_url = nsoption_charp(homepage_url); + if (nsoption_bool(http_proxy) == true) { + /* proxy type combo box starts with disabled, to allow + * for this the http_proxy option needs combining with + * the http_proxy_auth option + */ + proxytype = nsoption_int(http_proxy_auth) + 1; + if (default_http_proxy_host == NULL) { + /* set to use a proxy without a host, turn proxy off */ + proxytype = 0; + } else if (((proxytype == 2) || + (proxytype == 3)) && + ((default_http_proxy_auth_user == NULL) || + (default_http_proxy_auth_pass == NULL))) { + /* authentication selected with empty credentials, turn proxy off */ + proxytype = 0; + } } - if (nsoption_charp(http_proxy_host) != NULL) { - default_http_proxy_host = nsoption_charp(http_proxy_host); + if (default_http_proxy_host == NULL) { + default_http_proxy_host = ""; } - if (nsoption_charp(http_proxy_auth_user) != NULL) { - default_http_proxy_auth_user = nsoption_charp(http_proxy_auth_user); + if (default_http_proxy_auth_user == NULL) { + default_http_proxy_auth_user = ""; } - if (nsoption_charp(http_proxy_auth_pass) != NULL) { - default_http_proxy_auth_pass = nsoption_charp(http_proxy_auth_pass); + if (default_http_proxy_auth_pass == NULL) { + default_http_proxy_auth_pass = ""; } - if (nsoption_bool(http_proxy) == true) { - proxytype = nsoption_int(http_proxy_auth) + 1; - } + SET_COMBO(comboProxyType, proxytype); + SET_ENTRY(entryProxyHost, default_http_proxy_host); + SET_SPIN(spinProxyPort, nsoption_int(http_proxy_port)); + SET_ENTRY(entryProxyUser, default_http_proxy_auth_user); + SET_ENTRY(entryProxyPassword, default_http_proxy_auth_pass); - /* Create combobox */ - box = GTK_BOX(gtk_builder_get_object(gladeFile, "combolanguagevbox")); - comboLanguage = nsgtk_combo_box_text_new(); + set_proxy_widgets_sensitivity(proxytype); - /* Populate combobox from languages file */ - if ((languages_file_location != NULL) && + + /* accept language selection */ + if (nsoption_charp(accept_language) != NULL) { + default_accept_language = nsoption_charp(accept_language); + } + + /* Fill content language list store */ + liststore = GTK_LIST_STORE(gtk_builder_get_object(gladeFile, "liststore_content_language")); + if ((liststore != NULL) && + (languages_file_location != NULL) && ((fp = fopen(languages_file_location, "r")) != NULL)) { + int combo_row_count = 0; + + gtk_list_store_clear(liststore); + active_language = -1; + LOG(("Used %s for languages", languages_file_location)); while (fgets(buf, sizeof(buf), fp)) { /* Ignore blank lines */ @@ -347,34 +440,44 @@ void nsgtk_options_load(void) /* Remove trailing \n */ buf[strlen(buf) - 1] = '\0'; - nsgtk_combo_box_text_append_text(comboLanguage, buf); + gtk_list_store_append(liststore, &iter); + gtk_list_store_set(liststore, &iter, 0, buf, -1 ); - if (strcmp(buf, default_accept_language) == 0) + if (strcmp(buf, default_accept_language) == 0) { active_language = combo_row_count; + } combo_row_count++; } - fclose(fp); + if (active_language == -1) { + /* configured language was not in list, add it */ + gtk_list_store_append(liststore, &iter); + gtk_list_store_set(liststore, &iter, 0, default_accept_language, -1 ); + active_language = combo_row_count; + + } + + fclose(fp); } else { LOG(("Failed opening languages file")); - warn_user("FileError", languages_file_location); - nsgtk_combo_box_text_append_text(comboLanguage, "en"); } + SET_COMBO(comboboxLanguage, active_language); - gtk_combo_box_set_active(GTK_COMBO_BOX(comboLanguage), active_language); - /** \todo localisation */ - gtk_widget_set_tooltip_text(GTK_WIDGET(comboLanguage), - "set preferred language for web pages"); - gtk_box_pack_start(box, comboLanguage, FALSE, FALSE, 0); - gtk_widget_show(comboLanguage); - - nsgtk_options_theme_combo(); + + /* Startup */ + if (nsoption_charp(homepage_url) != NULL) { + default_homepage_url = nsoption_charp(homepage_url); + } SET_ENTRY(entryHomePageURL, default_homepage_url); SET_BUTTON(setCurrentPage); SET_BUTTON(setDefaultPage); + + /* Theme */ + nsgtk_options_theme_combo(); + SET_CHECK(checkHideAdverts, nsoption_bool(block_ads)); SET_CHECK(checkDisablePopups, nsoption_bool(disable_popups)); @@ -384,42 +487,28 @@ void nsgtk_options_load(void) SET_CHECK(checkDisplayRecentURLs, nsoption_bool(url_suggestion)); SET_CHECK(checkSendReferer, nsoption_bool(send_referer)); + SET_CHECK(checkSendDNT, nsoption_bool(do_not_track)); SET_CHECK(checkShowSingleTab, nsoption_bool(show_single_tab)); - SET_COMBO(comboProxyType, proxytype); - SET_ENTRY(entryProxyHost, default_http_proxy_host); - - gtk_widget_set_sensitive(entryProxyHost, proxytype != 0); - - snprintf(buf, sizeof(buf), "%d", nsoption_int(http_proxy_port)); - - SET_ENTRY(entryProxyPort, buf); - gtk_widget_set_sensitive(entryProxyPort, proxytype != 0); - - SET_ENTRY(entryProxyUser, default_http_proxy_auth_user); - - gtk_widget_set_sensitive(entryProxyUser, proxytype != 0); - - SET_ENTRY(entryProxyPassword, default_http_proxy_auth_pass); - - gtk_widget_set_sensitive(entryProxyPassword, proxytype != 0); - SET_SPIN(spinMaxFetchers, nsoption_int(max_fetchers)); SET_SPIN(spinFetchesPerHost, nsoption_int(max_fetchers_per_host)); SET_SPIN(spinCachedConnections, nsoption_int(max_cached_fetch_handles)); + SET_CHECK(checkEnableJavascript, nsoption_bool(enable_javascript)); + SET_CHECK(checkResampleImages, nsoption_bool(render_resample)); SET_SPIN(spinAnimationSpeed, nsoption_int(minimum_gif_delay) / 100.0); - SET_CHECK(checkDisableAnimations, !nsoption_bool(animate_images)); + SET_CHECK(checkEnableAnimations, nsoption_bool(animate_images)); - SET_FONT(fontSansSerif, nsoption_charp(font_sans)); +/* SET_FONT(fontSansSerif, nsoption_charp(font_sans)); SET_FONT(fontSerif, nsoption_charp(font_serif)); SET_FONT(fontMonospace, nsoption_charp(font_mono)); SET_FONT(fontCursive, nsoption_charp(font_cursive)); SET_FONT(fontFantasy, nsoption_charp(font_fantasy)); + SET_SPIN(spinMinimumSize, nsoption_bool(font_min_size) / 10); +*/ SET_COMBO(comboDefault, nsoption_int(font_default)); SET_SPIN(spinDefaultSize, nsoption_int(font_size) / 10); - SET_SPIN(spinMinimumSize, nsoption_bool(font_min_size) / 10); SET_BUTTON(fontPreview); SET_COMBO(comboButtonType, nsoption_int(button_type) -1); @@ -451,16 +540,12 @@ void nsgtk_options_load(void) SET_CHECK(checkFitPage, nsoption_bool(enable_loosening)); SET_CHECK(checkCompressPDF, nsoption_bool(enable_PDF_compression)); SET_CHECK(checkPasswordPDF, nsoption_bool(enable_PDF_password)); - SET_BUTTON(setDefaultExportOptions); +// SET_BUTTON(setDefaultExportOptions); } -static void dialog_response_handler (GtkDialog *dlg, gint res_id) +static void dialog_response_handler(GtkDialog *dlg, gint res_id) { switch (res_id) { - case GTK_RESPONSE_HELP: - /* Ready to implement Help */ - break; - case GTK_RESPONSE_CLOSE: on_dialog_close(dlg, TRUE); } @@ -572,18 +657,28 @@ static gboolean on_##widget##_changed(GtkWidget *widget, gpointer data) \ return FALSE; \ } -static gboolean on_comboLanguage_changed(GtkWidget *widget, gpointer data) +static gboolean on_comboboxLanguage_changed(GtkComboBox *combo, gpointer data) { - gchar *lang; - - lang = nsgtk_combo_box_text_get_active_text(comboLanguage); - if (lang == NULL) - return FALSE; + gchar *lang = NULL; + GtkTreeIter iter; + GtkTreeModel *model; + + /* Obtain currently selected item from combo box. + * If nothing is selected, do nothing. + */ + if (gtk_combo_box_get_active_iter(combo, &iter)) { + /* Obtain data model from combo box. */ + model = gtk_combo_box_get_model(combo); + + /* Obtain string from model. */ + gtk_tree_model_get(model, &iter, 0, &lang, -1); + } - nsoption_set_charp(accept_language, strdup(lang)); + if (lang != NULL) { + nsoption_set_charp(accept_language, strdup(lang)); + g_free(lang); + } - g_free(lang); - return FALSE; } @@ -621,6 +716,11 @@ CHECK_CHANGED(checkSendReferer, send_referer) { } END_HANDLER + +CHECK_CHANGED(checkSendDNT, do_not_track) +{ +} +END_HANDLER CHECK_CHANGED(checkShowSingleTab, show_single_tab) { @@ -628,54 +728,48 @@ CHECK_CHANGED(checkShowSingleTab, show_single_tab) } END_HANDLER + COMBO_CHANGED(comboProxyType, http_proxy_auth) { LOG(("proxy auth: %d", nsoption_int(http_proxy_auth))); + + set_proxy_widgets_sensitivity(nsoption_int(http_proxy_auth)); switch (nsoption_int(http_proxy_auth)) { - case 0: + case 0: /* no proxy */ nsoption_set_bool(http_proxy, false); nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); break; - case 1: + + case 1: /* proxy with no auth */ nsoption_set_bool(http_proxy, true); nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); break; - case 2: + + case 2: /* proxy with basic auth */ nsoption_set_bool(http_proxy, true); nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC); break; - case 3: + + case 3: /* proxy with ntlm auth */ nsoption_set_bool(http_proxy, true); nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NTLM); break; + + case 4: /* system proxy */ + nsoption_set_bool(http_proxy, true); + nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE); + break; + } - gboolean sensitive = (!proxy_type == 0); - gtk_widget_set_sensitive(entryProxyHost, sensitive); - gtk_widget_set_sensitive(entryProxyPort, sensitive); - gtk_widget_set_sensitive(entryProxyUser, sensitive); - gtk_widget_set_sensitive(entryProxyPassword, sensitive); } END_HANDLER ENTRY_CHANGED(entryProxyHost, http_proxy_host) -gboolean on_entryProxyPort_changed(GtkWidget *widget, gpointer data) +SPIN_CHANGED(spinProxyPort, http_proxy_port) { - long port; - - errno = 0; - port = strtol((char *)gtk_entry_get_text(GTK_ENTRY(entryProxyPort)), - NULL, 10) & 0xffff; - if ((port != 0) && (errno == 0)) { - nsoption_set_int(http_proxy_port, port); - } else { - char buf[32]; - snprintf(buf, sizeof(buf), "%d", nsoption_int(http_proxy_port)); - SET_ENTRY(entryProxyPort, buf); - } - - return FALSE; } +END_HANDLER ENTRY_CHANGED(entryProxyUser, http_proxy_auth_user) @@ -709,9 +803,13 @@ static gboolean on_spinAnimationSpeed_changed(GtkWidget *widget, gpointer data) return FALSE; } -CHECK_CHANGED(checkDisableAnimations, animate_images) +CHECK_CHANGED(checkEnableAnimations, animate_images) +{ +} +END_HANDLER + +CHECK_CHANGED(checkEnableJavascript, enable_javascript) { - nsoption_set_bool(animate_images, !nsoption_bool(animate_images)); } END_HANDLER @@ -734,7 +832,7 @@ CHECK_CHANGED(checkHoverURLs, hover_urls) { } END_HANDLER - +/* FONT_CHANGED(fontSansSerif, font_sans) { } @@ -759,7 +857,7 @@ FONT_CHANGED(fontFantasy, font_fantasy) { } END_HANDLER - +*/ COMBO_CHANGED(comboDefault, font_default) { } @@ -771,12 +869,12 @@ SPIN_CHANGED(spinDefaultSize, font_size) } END_HANDLER -SPIN_CHANGED(spinMinimumSize, font_min_size) +/*SPIN_CHANGED(spinMinimumSize, font_min_size) { nsoption_set_int(font_min_size, nsoption_int(font_min_size) * 10); } END_HANDLER - +*/ BUTTON_CLICKED(fontPreview) { nsgtk_reflow_all_windows(); @@ -1057,6 +1155,7 @@ CHECK_CHANGED(checkPasswordPDF, enable_PDF_password) } END_HANDLER +/* BUTTON_CLICKED(setDefaultExportOptions) { nsoption_set_int(margin_top, DEFAULT_MARGIN_TOP_MM); @@ -1082,3 +1181,4 @@ BUTTON_CLICKED(setDefaultExportOptions) SET_CHECK(checkFitPage, nsoption_bool(enable_loosening)); } END_HANDLER +*/ diff --git a/gtk/res/options.gtk2.ui b/gtk/res/options.gtk2.ui index 1a17cc104..5dd793062 100644 --- a/gtk/res/options.gtk2.ui +++ b/gtk/res/options.gtk2.ui @@ -1,8 +1,8 @@ - - + + 5 Netsurf Preferences center-on-parent @@ -10,42 +10,43 @@ dialog False - + True vertical 2 - + True True - 4 - + True vertical + 6 - + True - 5 0 none - + True + 6 12 + 12 - + True vertical + 6 - + True - 5 - 5 + 12 - + True - URL + Page: False @@ -60,6 +61,7 @@ + end 1 @@ -69,38 +71,42 @@ - + True - 5 + 6 + + + - Current Page + Use Current Page True True - False - True + True - 5 - 0 + False + False + 1 - Default Page + Use Default Page True True - False - True + True - 5 - end - 1 + False + False + 2 + False + end 1 @@ -109,44 +115,55 @@ - + True - <b>Home page</b> + <b>Startup</b> True False + 6 0 - + True + 0 + none - + True - 5 - 0 - none + 6 + 12 + 12 - + True - 12 + vertical + 6 + + + Search from URL bar + True + True + False + True + + + 0 + + - + True - vertical - True + 12 - - Hide advertisements + True - True - False - True - True + Provider: False @@ -155,185 +172,112 @@ - - Disable pop-up windows + True - True - False - True - True + liststore_search_provider + + + + 0 + + - False - False 1 - - - Disable plug-ins - True - False - True - True - - - False - False - 2 - - + + 1 + - - - True - <b>Content blocking</b> - True - - - - False - 0 - - - + + True - 0 - none - - - True - 12 - - - True - vertical - - - - - - True - vertical - - - - - - - - - - - - False - False - 1 - - - - - - - - - - - - True - <b>Content Language</b> - True - - + <b>Search</b> + True - - 1 - False + 6 1 - + True - 5 0 none - + True + 6 12 + 12 - + True - 1 vertical - 2 + 6 - + + Remove download from list when complete + True + True + False + True + + + False + 0 + + + + + Confirm before overwriting files + True + True + False + True + + + False + 1 + + + + True - 4 - 4 + 12 - + True - Keep history for + Location: False - False 0 - + True - True - 1 + select-folder - False - False 1 - - - True - days - - - False - False - 2 - - - - - 0 - - - - - Hover URLs by pointer in local history - True - True - False - True - True False - False - 1 + 2 @@ -341,62 +285,63 @@ - + True - <b>History</b> + <b>Downloads</b> True False - False + 6 2 + + + + + True + Main + + + False + + + + + True + vertical + 6 - + True - 5 0 none - + True + 6 12 + 12 - + True - vertical - True + 12 - - Display recently visited URLs as you type - True - True - False - True - True - - - False - False - 0 - + - - Send site referral information + + Add Theme... True True - False - True - True - True + True False - False + end 1 @@ -405,189 +350,104 @@ - + True - <b>Misc</b> + <b>Themes</b> True False - 3 + 6 + 0 - - - - - True - General - - - False - - - - - True - vertical - + True - 5 0 none - + True + 6 12 + 12 - + True - 4 - 2 - 3 - 3 + vertical + 6 - + + Always show tab bar True True - + False + True - 1 - 2 - 2 - 3 - + 0 - + + Switch to newly opened tabs immediately True - liststore_proxytype - - - - 0 - - + True + False + True - 1 - 2 - + 1 - + + Newly opened tabs are blank True + True + False + True + + + 2 + + + + + True + 12 - - True - True - - - - 0 - - - - + True - : + Position: False False - 1 + 0 - - 64 + True - True - + liststore_tab_position + + + + 0 + + - False - 2 + 1 - 1 - 2 - 1 - 2 - - - - - - True - True - False - - - - 1 - 2 - 3 - 4 - - - - - - True - 0.89999997615814209 - Host - - - 1 - 2 - GTK_FILL - - - - - - True - 0.89999997615814209 - Proxy type - - - GTK_FILL - - - - - - True - 0.89999997615814209 - Username - - - 2 - 3 - GTK_FILL - - - - - - True - 0.89999997615814209 - Password - - - 3 - 4 - GTK_FILL - + 3 @@ -595,176 +455,121 @@ - + True - <b>HTTP Proxy</b> + <b>Tabs</b> True False - 0 + 6 + 1 - + True - 5 0 none - + True + 6 12 + 12 - + True - 3 - 3 - 3 - 3 - 3 - - - True - True - 1 - - - 1 - 2 - - - - - - True - True - 1 - - - 1 - 2 - 1 - 2 - - - - - - True - True - 1 - - - 1 - 2 - 2 - 3 - - - - - - True - 0.89999997615814209 - Maximum fetchers - - - - - + vertical + 6 - + True - 0.89999997615814209 - Fetches per host + 0 + Open source view in new: - 1 - 2 - + 0 - + True - 0.89999997615814209 - Cached connections + + + window + True + True + False + 0.54000002145767212 + True + True + sourceButtonTab + + + 0 + + + + + tab + True + True + False + True + True + + + 1 + + - 2 - 3 - + 1 - - - - - - - - - - + True - <b>Fetching</b> + <b>Source</b> True False - 1 + 6 + 2 - - - 1 - - - - - True - Network - - - 1 - False - - - - - True - vertical - + True - 5 0 none - + True + 6 12 + 12 - + True + vertical + 6 - - Resample images when not at natural size + + Display recently visited URLs as you type True True False - True - True True @@ -776,319 +581,223 @@ - + True - <b>Quality</b> + <b>URLbar</b> True False - 0 + 7 + 3 - + True - 5 0 none - + True + 6 12 + 12 - + True + vertical + 6 - + True + 6 - + True - 0.89999997615814209 - Limit speed to + Buttons: + False 0 - + True - True - 1 - 1 - True - if-valid + liststore_toolbar_buttontype + + + + 0 + + - False 1 - - - True - 0 - seconds between frames - - - 2 - - 0 - - - Disable animations - True - True - False - True - True - - - False - False - 1 - - - + True - <b>Animations</b> + <b>Toolbar</b> True False - False - 1 + 6 + 4 - 2 + 1 - + True - Rendering + Appearance - 2 + 1 False - + True vertical + 6 - + True - 5 0 none - + True + 6 12 + 12 - + True - 2 - 6 - 2 - 3 - 3 + vertical + 6 - + + Prevent pop-up windows True True False - False - False - - - 1 - 2 - - - - - - True - 0.89999997615814209 - Sans-serif - - - GTK_FILL - - - - - - True - 0.89999997615814209 - Serif - - - 1 - 2 - GTK_FILL - - - - - - True - 0.89999997615814209 - Monospace - - - 2 - 3 - GTK_FILL - - - - - - True - 0.89999997615814209 - Cursive - - - 3 - 4 - GTK_FILL - - - - - - True - 0.89999997615814209 - Fantasy - - - 4 - 5 - GTK_FILL - - - - - - True - 0.89999997615814209 - Default + True - 5 - 6 - GTK_FILL - + False + False + 0 - + + Hide Adverts True True False - False - False + True - 1 - 2 - 1 - 2 - GTK_FILL - + False + False + 1 - + + Enable JavaScript True True False - False - False + True - 1 - 2 - 2 - 3 - GTK_FILL - + False + False + 2 - + + Disable plug-ins True True False - False - False + True - 1 - 2 - 3 - 4 - GTK_FILL - + False + False + 3 - + + High quality image scaling True True False - False - False + True - 1 - 2 - 4 - 5 - GTK_FILL - + 4 - + True - liststore_defaultfont + 6 - - - 0 - + + True + Load and display + + + False + 0 + + + + + True + liststore_image_loading + + + + 0 + + + + + 1 + - 1 - 2 - 5 - 6 - GTK_FILL - + 5 @@ -1096,152 +805,82 @@ - + True - <b>Font faces</b> + <b>Control</b> True False + 6 0 - + True - 5 0 none - + True + 6 12 + 12 - + True - 2 - 4 - 3 - 3 + vertical + 6 - + + Enable True True False - - - True - 2 - - - True - gtk-apply - - - 0 - - - - - True - _Preview - True - - - 1 - - - - - - - 3 - 4 - 2 - - - 2 - - - - - True - True - 1 - True - - - 1 - 2 - - - - - - - True - True - 1 - - - 1 - 2 - 1 - 2 - - - - - - - True - 0 - pt - - - 2 - 3 - - - - - - True - 0 - pt - - - 2 - 3 - 1 - 2 - - - - - - True - 0.89999997615814209 - Minimum + True - 1 - 2 - GTK_FILL - + 0 - + True - 0.89999997615814209 - Default + 12 + + + True + Minimum time between frames: + + + False + 0 + + + + + True + True + True + Do not update animations any more often than this. + + adjustment_animation_time + 1 + 1 + True + if-valid + + + False + 1 + + - GTK_FILL - + 1 @@ -1249,137 +888,117 @@ - + True - <b>Font size</b> + <b>Animation</b> True False + 6 1 - + True 0 none - + True + 6 12 + 12 - + True - 2 - 10 - 3 + 12 - + True + 6 + + + True + Default + + + False + 0 + + + + + True + liststore_defaultfont + + + + 0 + + + + + 1 + + - 1 - 2 - - + 0 - + True - Toolbar buttons - right - - - - GTK_FILL - - - - - - - - - True - 5 - <b>Icons</b> - True - - - - - 2 - - - - - 3 - - - - - True - Style - - - 3 - False - - - - - True - vertical - - - True - 5 - 0 - none - - - True - 12 - - - True - 2 - 6 - - - True - Size - - - False - False - 0 - - - - - True - True - 1 + 6 + + + True + Size + + + False + 0 + + + + + True + True + True + The base-line font size to use. + 3 + + 3 + adjustment_font_default_size + 1 + True + + + False + 1 + + False - False 1 - + + _Preview True - MB + True + True + image1 + True False - False 2 @@ -1388,142 +1007,78 @@ - + True - <b>Memory cache</b> + <b>Fonts</b> True False - False - 0 + 2 - + True - 5 0 none - + True + 6 12 + 12 - + True vertical - 5 + 6 - + True - 3 + 12 - + True - Duration + Preferred language: False - False 0 - - True - True - 1 - - - False - False - 1 - - - - - True - days - - - False - False - 2 - - - - - 0 - - - - - True - 4 - 4 - - - - - + True - True - False + True + set preferred language for web pages + liststore_content_language - - True - 0 - 0 - - - True - 2 - - - True - gtk-delete - - - False - False - 0 - - - - - True - False - Perform maintainance - True - - - False - False - 1 - - - - + + 0 + + + 1 + + + + + 1 + + 0 + - False - False 1 - - - - False - False - 1 + 0 @@ -1531,59 +1086,60 @@ - + True - <b>Disc cache</b> + <b>Language</b> True False - 1 + 3 - 4 + 2 - + True - Cache + Content - 4 + 2 False - + True vertical + 6 - + True - 5 0 none - + True + 6 12 + 12 - + True vertical + 6 - - Automatically clear downloads when completed + + Local history shows URL in tooltip True True False - True - True True @@ -1591,50 +1147,48 @@ - - Request confirmation before overwriting files - True - True - False - True - True - - - False - False - 1 - - - - + True + 6 - + True - 2 - Download directory + Remember browsing history for up to False - False - 2 0 - + True - True - select-folder - 23 + True + 4 + + 4 + adjustment_history_age + 1 + True + False 1 + + + True + days + + + False + 2 + + - 2 + 1 @@ -1642,166 +1196,251 @@ - + True - <b>Downloads</b> + <b>History</b> True False + 6 0 - + True 0 none - + True + 6 12 + 12 - + True vertical + 6 - - Show tab bar with only one tab - True - True - False - True - True - - - False - False - 0 - - - - - Shift focus to new tab - True - True - False - True - True - - - 1 - - - - - Open blank window - True - True - False - True - True - - - 2 - - - - + True + 3 + 3 + 6 + 6 - + True - 0.4699999988079071 - 2 - Tabs position + 0 + Memory cache size - False - False - 2 - 0 + GTK_FILL - + True - liststore_tabpositions - - - - 0 - - + 0 + Disc cache size - 1 + 1 + 2 + GTK_FILL - - - 3 - - - - - - - - - True - <b>Tabs</b> - True - - - - + + + True + 0 + Expire cache entries after + + + 2 + 3 + GTK_FILL + + + + + True + True + + 5 + adjustment_cache_memory_size + 1 + True + + + 1 + 2 + GTK_FILL + + + + + True + True + + 5 + adjustment_cache_disc_size + 1 + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + True + + 3 + adjustment_disc_cache_age + 1 + True + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + True + 0 + MB + + + 2 + 3 + GTK_FILL + + + + + True + 0 + MB + + + 2 + 3 + 1 + 2 + GTK_FILL + + + + + True + 0 + days + + + 2 + 3 + 2 + 3 + GTK_FILL + + + + + 0 + + + + + True + + + + + + Maintinance + True + True + True + + + False + 1 + + + + + 1 + + + + + + + + + True + <b>Cache</b> + True + + + + False + 6 1 - + True 0 none - + True + 6 12 + 12 - + True + vertical + 6 - - in own window + + Enable referral submission True True False - True - True True - False - False 0 - - in new tab + + Enable sending "Do Not Track" request True True False - True True - False - False 1 @@ -1810,117 +1449,329 @@ - + True - <b>View Source</b> + <b>General</b> True False - False 2 + + + 3 + + + + + True + Privacy + + + 3 + False + + + + + True + vertical + 6 - + True 0 none - + True + 6 12 + 12 - + True + 4 + 2 + 6 + 6 - - Search from URL bar + + True + 0 + Proxy type + + + GTK_FILL + + + + + True + 0 + Host + + + 1 + 2 + GTK_FILL + + + + + True + 0 + Username + + + 2 + 3 + GTK_FILL + + + + + True + 0 + Password + + + 3 + 4 + GTK_FILL + + + + + True + True + The type of HTTP proxy server. + liststore_proxy_type + + + + 0 + + + + + 1 + 2 + + + + + True + 6 + + + True + True + True + Host name of your proxy server. + + + + 0 + + + + + True + : + + + False + 1 + + + + + True + True + True + Port number to connect to on proxy server. + 5 + + 5 + adjustment_proxy_port + 1 + True + if-valid + + + False + 2 + + + + + 1 + 2 + 1 + 2 + + + + True True - False - True - True + True + Username to access the proxy + - False - 0 + 1 + 2 + 2 + 3 - + True - Default provider - right + True + True + Password to access the proxy + - False - 1 + 1 + 2 + 3 + 4 + + + + + + + + + True + <b>HTTP Proxy</b> + True + + + + + False + 6 + 0 + + + + + True + 0 + none + + + True + 6 + 12 + 12 + + + True + 3 + 2 + 6 + 6 + + + True + 0 + Maximum fetchers + + + GTK_FILL + + + + + True + 0 + Fetches per host + + + 1 + 2 + GTK_FILL + + + + + True + 0 + Cached connections + + + 2 + 3 + GTK_FILL - + + True + True + True + Maximum number of concurrent items to fetch at once. + + 3 + adjustment_fetching_max + 1 + True + + + 1 + 2 + GTK_FILL + + + + True - liststore_searchproviders - - - - 0 - - + True + True + Maximum number of item fetches per web server. + + 3 + adjustment_fetching_perhost + 1 + True - 2 + 1 + 2 + 1 + 2 + GTK_FILL - - - - - - - True - <b>Search</b> - True - - - - - False - False - 3 - - - - - True - 0 - none - - - True - 12 - - - True - - - - - Add theme… + True True - False - True + True + Number of connections to keep in case they are needed again. + + 3 + adjustment_fetching_cached + 1 + True - False - False - end - 1 + 1 + 2 + 2 + 3 + GTK_FILL @@ -1928,204 +1779,371 @@ - + True - <b>Select themes</b> + <b>Fetching</b> True False - 4 + 6 + 1 - 5 + 4 - + True - Advanced + Network - 5 + 4 False - + True vertical + 6 - + True - 5 0 none - + True + 6 12 + 12 - + True - True + vertical + 6 - + + No images in output True - 2 - 3 - 4 - 5 - - - True - mm - - - 2 - 3 - 1 - 2 - - + True + False + True + + + 0 + + + + + No background images in output + True + True + False + True + + + 1 + + + + + Scale output to fit page + True + True + False + True + + + 2 + + + + + True + 6 - + True - mm + Scale output - 2 - 3 + False + 0 - + True True + 4 + + 4 + 1 + adjustment_pdf_scale 1 + True - 1 - 2 - 1 - 2 + False + 1 - + True - True - 1 + % - 1 - 2 + False + 2 + + + 3 + + + + + + + + + True + <b>Appearance</b> + True + + + + + False + 6 + 0 + + + + + True + 0 + none + + + True + 6 + 12 + 12 + + + True + vertical + 6 + + + True - + True - 0.89999997615814209 - Bottom + measurements in mm - 1 - 2 + False + 0 - - True - 0.89999997615814209 - Top - + - False - False 0 - + True - 2 + 3 3 - 4 - 5 - + + True + 6 + + + True + Top + + + False + 0 + + + + + True + True + 4 + + 5 + 1 + 1 + 1 + True + + + False + 1 + + + + + 1 + 2 + GTK_EXPAND + + + + True - mm + 6 + + + True + Left + + + False + 0 + + + + + True + True + 4 + + 5 + 1 + adjustment_pdf_lmargin + 1 + 1 + True + + + False + 1 + + - 2 - 3 1 2 + GTK_EXPAND - + True - mm + 6 + + + True + Bottom + + + False + 0 + + + + + True + True + 4 + + 5 + 1 + 1 + 1 + True + + + False + 1 + + - 2 - 3 + 1 + 2 + 2 + 3 + GTK_EXPAND - + True - True - 1 + 6 + + + True + Right + + + False + 0 + + + + + True + True + 4 + + 5 + 1 + 1 + 1 + True + + + False + 1 + + - 1 - 2 + 2 + 3 1 2 + GTK_EXPAND - - True - True - 1 - - - 1 - 2 - + - - True - 0.89999997615814209 - Right - - - 1 - 2 - + - - True - 0.89999997615814209 - Left - + + + + + + + - False - False 1 @@ -2134,7 +2152,7 @@ - + True <b>Margins</b> True @@ -2143,164 +2161,32 @@ False - 0 - - - - - True - 5 - 0 - none - - - True - 12 - - - True - 4 - - - True - Scale - - - False - 0 - - - - - True - True - 1 - - - False - False - 1 - - - - - True - % - - - False - 2 - - - - - - - - - True - <b>Scaling</b> - True - - - - - False - False + 6 1 - - True - 5 - 0 - none - - - True - 12 - - - True - vertical - - - Suppress images - True - True - False - True - True - - - 0 - - - - - Remove backgrounds - True - True - False - True - True - - - 1 - - - - - Fit page - True - True - False - True - True - - - 2 - - - - - - - - - True - <b>Appearance</b> - True - - - - - False - 2 - - - - + True - 5 0 none - + True + 6 12 + 12 - + True vertical + 7 - Compress PDF + Output is compressed True True False - True True @@ -2309,11 +2195,10 @@ - Set a password for PDF + Output has a password True True False - True True @@ -2325,55 +2210,31 @@ - + True - <b>Advanced</b> + <b>Generation</b> True False - False - 3 - - - - - True - 10 - - - Default - True - True - False - True - - - False - False - 0 - - - - - False - 4 + 6 + 2 - 6 + 5 - + True - Export + PDF - 6 + 5 False @@ -2383,14 +2244,13 @@ - + True edge gtk-help True - False True False True @@ -2429,29 +2289,9 @@ close - - - - - - - - Top - - - Left - - - Right - - - Bottom - - - - + - + @@ -2465,7 +2305,7 @@ Microsoft Live - Buisness.com + Buisiness.com Omgili @@ -2489,10 +2329,10 @@ Dictionary.com - Youtube + YouTube - AeroMp3 + AeroMP3 AOL @@ -2507,7 +2347,7 @@ Ebay - IMDB + IMBD ESPN @@ -2520,6 +2360,66 @@ + + + + + + + + Top + + + Left + + + Right + + + Bottom + + + + + + + + + + + Small Icons + + + Large Icons + + + Large Icons and Text + + + Text only + + + + + + + + + + + foreground and background images + + + foreground images + + + background images + + + no images + + + @@ -2543,23 +2443,122 @@ - + + True + 3 + gtk-apply + + - No proxy + Direct connection + + + Manual with no authentication + + + Manual with basic authentication - Simple proxy + Manual with NTLM authentication - Basic authentication + System settings + + + + 0.10000000000000001 + 0.10000000000000001 + 10 + 0.10000000000000001 + 1 + + + 16 + 1 + 100 + 1 + 10 + + + 28 + 999 + 1 + 28 + + + 16 + 2048 + 4 + 16 + + + 16 + 2048 + 4 + 16 + + + 28 + 999 + 1 + 10 + + + 3128 + 1 + 65535 + 1 + 10 + + + 10 + 1 + 100 + 1 + 10 + + + 1 + 1 + 100 + 1 + 10 + + + 1 + 100 + 1 + 10 + + + 100 + 1 + 1000 + 1 + 10 + + + 999 + 1 + 10 + + + + + + + + + - NTLM authentication + en + English diff --git a/gtk/res/options.gtk3.ui b/gtk/res/options.gtk3.ui index b6254a34d..7fb513ef5 100644 --- a/gtk/res/options.gtk3.ui +++ b/gtk/res/options.gtk3.ui @@ -263,7 +263,7 @@ - + 5 Netsurf Preferences center-on-parent -- cgit v1.2.3 From ea3f09a72433be165cc4ec09052b3d636e64ac0c Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Sun, 30 Dec 2012 23:33:27 +0000 Subject: Correctly emit entities when serialising to HTML. --- desktop/save_complete.c | 115 +++++++++++++++++++++++++++++++++++---- desktop/tree_url_node.c | 8 +-- utils/corestrings.c | 3 ++ utils/corestrings.h | 1 + utils/utf8.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++- utils/utf8.h | 3 ++ 6 files changed, 253 insertions(+), 16 deletions(-) diff --git a/desktop/save_complete.c b/desktop/save_complete.c index 7137f0ba9..d9bd507b8 100644 --- a/desktop/save_complete.c +++ b/desktop/save_complete.c @@ -39,8 +39,10 @@ #include "desktop/save_complete.h" #include "render/box.h" #include "render/html.h" +#include "utils/corestrings.h" #include "utils/log.h" #include "utils/nsurl.h" +#include "utils/utf8.h" #include "utils/utils.h" regex_t save_complete_import_re; @@ -551,7 +553,9 @@ static bool save_complete_rewrite_url_value(save_complete_ctx *ctx, { nsurl *url; hlcache_handle *content; + char *escaped; nserror error; + utf8_convert_ret ret; error = nsurl_join(ctx->base, value, &url); if (error == NSERROR_NOMEM) @@ -566,11 +570,25 @@ static bool save_complete_rewrite_url_value(save_complete_ctx *ctx, fprintf(ctx->fp, "\"%p\"", content); } else { /* no match found */ - fprintf(ctx->fp, "\"%s\"", nsurl_access(url)); + ret = utf8_to_html(nsurl_access(url), "UTF-8", + nsurl_length(url), &escaped); nsurl_unref(url); + + if (ret != UTF8_CONVERT_OK) + return false; + + fprintf(ctx->fp, "\"%s\"", escaped); + + free(escaped); } } else { - fprintf(ctx->fp, "\"%.*s\"", (int) value_len, value); + ret = utf8_to_html(value, "UTF-8", value_len, &escaped); + if (ret != UTF8_CONVERT_OK) + return false; + + fprintf(ctx->fp, "\"%s\"", escaped); + + free(escaped); } return true; @@ -579,7 +597,16 @@ static bool save_complete_rewrite_url_value(save_complete_ctx *ctx, static bool save_complete_write_value(save_complete_ctx *ctx, const char *value, size_t value_len) { - fprintf(ctx->fp, "\"%.*s\"", (int) value_len, value); + char *escaped; + utf8_convert_ret ret; + + ret = utf8_to_html(value, "UTF-8", value_len, &escaped); + if (ret != UTF8_CONVERT_OK) + return false; + + fprintf(ctx->fp, "\"%s\"", escaped); + + free(escaped); return true; } @@ -728,7 +755,7 @@ static bool save_complete_handle_attrs(save_complete_ctx *ctx, for (i = 0; i < length; i++) { dom_attr *attr; - error = dom_namednodemap_item(attrs, i, &attr); + error = dom_namednodemap_item(attrs, i, (void *) &attr); if (error != DOM_NO_ERR) return false; @@ -753,6 +780,7 @@ static bool save_complete_handle_element(save_complete_ctx *ctx, dom_namednodemap *attrs; const char *name_data; size_t name_len; + bool process = true; dom_exception error; ctx->iter_state = STATE_NORMAL; @@ -767,9 +795,56 @@ static bool save_complete_handle_element(save_complete_ctx *ctx, name_data = dom_string_data(name); name_len = dom_string_byte_length(name); - /* Elide BASE elements from the output */ if (name_len == SLEN("base") && strncasecmp(name_data, "base", name_len) == 0) { + /* Elide BASE elements from the output */ + process = false; + } else if (name_len == SLEN("meta") && + strncasecmp(name_data, "meta", name_len) == 0) { + /* Don't emit close tags for META elements */ + if (event_type == EVENT_LEAVE) { + process = false; + } else { + /* Elide meta charsets */ + dom_string *value; + error = dom_element_get_attribute(node, + corestring_dom_http_equiv, &value); + if (error != DOM_NO_ERR) { + dom_string_unref(name); + return false; + } + + if (value != NULL) { + if (dom_string_length(value) == + SLEN("Content-Type") && + strncasecmp(dom_string_data(value), + "Content-Type", + SLEN("Content-Type")) == 0) + process = false; + + dom_string_unref(value); + } else { + bool yes; + + error = dom_element_has_attribute(node, + corestring_dom_charset, &yes); + if (error != DOM_NO_ERR) { + dom_string_unref(name); + return false; + } + + if (yes) + process = false; + } + } + } else if (event_type == EVENT_LEAVE && + ((name_len == SLEN("link") && + strncasecmp(name_data, "link", name_len) == 0))) { + /* Don't emit close tags for void elements */ + process = false; + } + + if (process == false) { dom_string_unref(name); return true; } @@ -833,6 +908,12 @@ static bool save_complete_handle_element(save_complete_ctx *ctx, } ctx->iter_state = STATE_IN_STYLE; + } else if (event_type == EVENT_ENTER && name_len == SLEN("head") && + strncasecmp(name_data, "head", name_len) == 0) { + /* If this is a HEAD element, insert a meta charset */ + fputs("", + ctx->fp); } dom_string_unref(name); @@ -846,6 +927,7 @@ static bool save_complete_node_handler(dom_node *node, save_complete_ctx *ctx = ctxin; dom_node_type type; dom_exception error; + utf8_convert_ret ret; error = dom_node_get_node_type(node, &type); if (error != DOM_NO_ERR) @@ -872,11 +954,20 @@ static bool save_complete_node_handler(dom_node *node, fwrite("