netsurf: branch master updated. release/3.2-77-g49fd5ea
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/49fd5ea238891a7efcd9c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/49fd5ea238891a7efcd9c32...
...tree http://git.netsurf-browser.org/netsurf.git/tree/49fd5ea238891a7efcd9c32fe...
The branch, master has been updated
via 49fd5ea238891a7efcd9c32fe2c9e6bc9c2ed180 (commit)
from f58a2580e0ea35d4b38f771f152215713fbd72b0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=49fd5ea238891a7efcd...
commit 49fd5ea238891a7efcd9c32fe2c9e6bc9c2ed180
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Correct Lock() parameter
diff --git a/amiga/misc.c b/amiga/misc.c
index 7d126c9..7b42dc9 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -195,7 +195,7 @@ static nserror amiga_path_to_nsurl(const char *path, struct nsurl **url_out)
BPTR lock = 0;
nserror ret;
- if(lock = Lock(path, MODE_OLDFILE))
+ if(lock = Lock(path, SHARED_LOCK))
{
DevNameFromLock(lock, newpath, sizeof newpath, DN_FULLPATH);
UnLock(lock);
-----------------------------------------------------------------------
Summary of changes:
amiga/misc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/amiga/misc.c b/amiga/misc.c
index 7d126c9..7b42dc9 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -195,7 +195,7 @@ static nserror amiga_path_to_nsurl(const char *path, struct nsurl **url_out)
BPTR lock = 0;
nserror ret;
- if(lock = Lock(path, MODE_OLDFILE))
+ if(lock = Lock(path, SHARED_LOCK))
{
DevNameFromLock(lock, newpath, sizeof newpath, DN_FULLPATH);
UnLock(lock);
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.2-76-gf58a258
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/f58a2580e0ea35d4b38f7...
...commit http://git.netsurf-browser.org/netsurf.git/commit/f58a2580e0ea35d4b38f771...
...tree http://git.netsurf-browser.org/netsurf.git/tree/f58a2580e0ea35d4b38f771f1...
The branch, master has been updated
via f58a2580e0ea35d4b38f771f152215713fbd72b0 (commit)
from c3d6099250475d40a8b5c9c548ac8858e9d7b5ac (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f58a2580e0ea35d4b38...
commit f58a2580e0ea35d4b38f771f152215713fbd72b0
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix textarea wrap bug.
Was comparing against the current start line length, to decide if it
needed redrawing, without taking into account that old start line
might have been longer.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 82f0989..d29e5f2 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -915,6 +915,7 @@ static bool textarea_reflow_multiline(struct textarea *ta,
unsigned int len;
unsigned int start;
size_t b_off;
+ size_t b_start_line_end;
int x;
char *space, *para_end;
unsigned int line; /* line count */
@@ -954,6 +955,9 @@ static bool textarea_reflow_multiline(struct textarea *ta,
if (start != 0)
start--;
+ /* Record original end pos of start line */
+ b_start_line_end = ta->lines[start].b_start + ta->lines[start].b_length;
+
/* During layout we may decide we need to restart again from the
* textarea's first line. */
do {
@@ -1156,9 +1160,15 @@ static bool textarea_reflow_multiline(struct textarea *ta,
ta->v_extent = v_extent;
ta->line_count = line;
+ /* Update start line end byte pos, if it's increased */
+ if (ta->lines[start].b_start + ta->lines[start].b_length >
+ b_start_line_end) {
+ b_start_line_end = ta->lines[start].b_start +
+ ta->lines[start].b_length;
+ }
+
/* Don't need to redraw above changes, so update redraw request rect */
- if (ta->lines[start].b_start + ta->lines[start].b_length < b_start &&
- restart == false) {
+ if (b_start_line_end < b_start && restart == false) {
/* Start line is unchanged */
start++;
skip_line = true;
-----------------------------------------------------------------------
Summary of changes:
desktop/textarea.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 82f0989..d29e5f2 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -915,6 +915,7 @@ static bool textarea_reflow_multiline(struct textarea *ta,
unsigned int len;
unsigned int start;
size_t b_off;
+ size_t b_start_line_end;
int x;
char *space, *para_end;
unsigned int line; /* line count */
@@ -954,6 +955,9 @@ static bool textarea_reflow_multiline(struct textarea *ta,
if (start != 0)
start--;
+ /* Record original end pos of start line */
+ b_start_line_end = ta->lines[start].b_start + ta->lines[start].b_length;
+
/* During layout we may decide we need to restart again from the
* textarea's first line. */
do {
@@ -1156,9 +1160,15 @@ static bool textarea_reflow_multiline(struct textarea *ta,
ta->v_extent = v_extent;
ta->line_count = line;
+ /* Update start line end byte pos, if it's increased */
+ if (ta->lines[start].b_start + ta->lines[start].b_length >
+ b_start_line_end) {
+ b_start_line_end = ta->lines[start].b_start +
+ ta->lines[start].b_length;
+ }
+
/* Don't need to redraw above changes, so update redraw request rect */
- if (ta->lines[start].b_start + ta->lines[start].b_length < b_start &&
- restart == false) {
+ if (b_start_line_end < b_start && restart == false) {
/* Start line is unchanged */
start++;
skip_line = true;
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.2-75-gc3d6099
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c3d6099250475d40a8b5c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c3d6099250475d40a8b5c9c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c3d6099250475d40a8b5c9c54...
The branch, master has been updated
via c3d6099250475d40a8b5c9c548ac8858e9d7b5ac (commit)
from c9bf72a4a30da996fc84ee6df8416a3e929ad28f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c3d6099250475d40a8b...
commit c3d6099250475d40a8b5c9c548ac8858e9d7b5ac
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Redraws during layout are prohibited, and redundant.
diff --git a/render/box_textarea.c b/render/box_textarea.c
index fe5a7ba..a1bbb53 100644
--- a/render/box_textarea.c
+++ b/render/box_textarea.c
@@ -155,6 +155,13 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg)
{
/* Request redraw of the required textarea rectangle */
int x, y;
+
+ if (html->reflowing == true) {
+ /* Can't redraw during layout, and it will
+ * be redrawn after layout anyway. */
+ break;
+ }
+
box_coords(box, &x, &y);
content__request_redraw((struct content *)html,
diff --git a/render/html.c b/render/html.c
index 12c173f..36f6e80 100644
--- a/render/html.c
+++ b/render/html.c
@@ -738,6 +738,7 @@ html_create_html_data(html_content *c, const http_parameter *params)
c->base_target = NULL;
c->aborted = false;
c->refresh = false;
+ c->reflowing = false;
c->title = NULL;
c->bctx = NULL;
c->layout = NULL;
@@ -1263,6 +1264,8 @@ static void html_reformat(struct content *c, int width, int height)
time_before = wallclock();
+ htmlc->reflowing = true;
+
layout_document(htmlc, width, height);
layout = htmlc->layout;
@@ -1282,6 +1285,8 @@ static void html_reformat(struct content *c, int width, int height)
selection_reinit(&htmlc->sel, htmlc->layout);
+ htmlc->reflowing = false;
+
time_taken = wallclock() - time_before;
c->reformat_time = wallclock() +
((time_taken * 3 < nsoption_uint(min_reflow_period) ?
diff --git a/render/html_interaction.c b/render/html_interaction.c
index e030e57..279eb40 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -1154,6 +1154,13 @@ void html_overflow_scroll_callback(void *client_data,
switch(scrollbar_data->msg) {
case SCROLLBAR_MSG_MOVED:
+
+ if (html->reflowing == true) {
+ /* Can't redraw during layout, and it will
+ * be redrawn after layout anyway. */
+ break;
+ }
+
html__redraw_a_box(html, box);
break;
case SCROLLBAR_MSG_SCROLL_START:
diff --git a/render/html_internal.h b/render/html_internal.h
index 05a085e..28522dc 100644
--- a/render/html_internal.h
+++ b/render/html_internal.h
@@ -94,6 +94,9 @@ typedef struct html_content {
/** Whether a meta refresh has been handled */
bool refresh;
+ /** Whether a layout (reflow) is in progress */
+ bool reflowing;
+
/* Title element node */
dom_node *title;
-----------------------------------------------------------------------
Summary of changes:
render/box_textarea.c | 7 +++++++
render/html.c | 5 +++++
render/html_interaction.c | 7 +++++++
render/html_internal.h | 3 +++
4 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/render/box_textarea.c b/render/box_textarea.c
index fe5a7ba..a1bbb53 100644
--- a/render/box_textarea.c
+++ b/render/box_textarea.c
@@ -155,6 +155,13 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg)
{
/* Request redraw of the required textarea rectangle */
int x, y;
+
+ if (html->reflowing == true) {
+ /* Can't redraw during layout, and it will
+ * be redrawn after layout anyway. */
+ break;
+ }
+
box_coords(box, &x, &y);
content__request_redraw((struct content *)html,
diff --git a/render/html.c b/render/html.c
index 12c173f..36f6e80 100644
--- a/render/html.c
+++ b/render/html.c
@@ -738,6 +738,7 @@ html_create_html_data(html_content *c, const http_parameter *params)
c->base_target = NULL;
c->aborted = false;
c->refresh = false;
+ c->reflowing = false;
c->title = NULL;
c->bctx = NULL;
c->layout = NULL;
@@ -1263,6 +1264,8 @@ static void html_reformat(struct content *c, int width, int height)
time_before = wallclock();
+ htmlc->reflowing = true;
+
layout_document(htmlc, width, height);
layout = htmlc->layout;
@@ -1282,6 +1285,8 @@ static void html_reformat(struct content *c, int width, int height)
selection_reinit(&htmlc->sel, htmlc->layout);
+ htmlc->reflowing = false;
+
time_taken = wallclock() - time_before;
c->reformat_time = wallclock() +
((time_taken * 3 < nsoption_uint(min_reflow_period) ?
diff --git a/render/html_interaction.c b/render/html_interaction.c
index e030e57..279eb40 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -1154,6 +1154,13 @@ void html_overflow_scroll_callback(void *client_data,
switch(scrollbar_data->msg) {
case SCROLLBAR_MSG_MOVED:
+
+ if (html->reflowing == true) {
+ /* Can't redraw during layout, and it will
+ * be redrawn after layout anyway. */
+ break;
+ }
+
html__redraw_a_box(html, box);
break;
case SCROLLBAR_MSG_SCROLL_START:
diff --git a/render/html_internal.h b/render/html_internal.h
index 05a085e..28522dc 100644
--- a/render/html_internal.h
+++ b/render/html_internal.h
@@ -94,6 +94,9 @@ typedef struct html_content {
/** Whether a meta refresh has been handled */
bool refresh;
+ /** Whether a layout (reflow) is in progress */
+ bool reflowing;
+
/* Title element node */
dom_node *title;
--
NetSurf Browser
9 years, 2 months
libcss: branch master updated. release/0.4.0-2-g034f23e
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/034f23e8305835dcda7503...
...commit http://git.netsurf-browser.org/libcss.git/commit/034f23e8305835dcda7503b0...
...tree http://git.netsurf-browser.org/libcss.git/tree/034f23e8305835dcda7503b0cd...
The branch, master has been updated
via 034f23e8305835dcda7503b0cd281c66fed7442d (commit)
from 56f392ec58d87e9c477c81f0690627ed778324d9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=034f23e8305835dcda75...
commit 034f23e8305835dcda7503b0cd281c66fed7442d
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
No need for extern "C" stuff now that bloom.h is internal.
diff --git a/src/select/bloom.h b/src/select/bloom.h
index 8c1da3f..85094cd 100644
--- a/src/select/bloom.h
+++ b/src/select/bloom.h
@@ -24,11 +24,6 @@
#ifndef libcss_bloom_h_
#define libcss_bloom_h_
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
#include <stdint.h>
/* Size of bloom filter as multiple of 32 bits.
@@ -197,9 +192,5 @@ static inline void css_bloom_init(css_bloom bloom[CSS_BLOOM_SIZE])
#endif
}
-#ifdef __cplusplus
-}
-#endif
-
#endif
-----------------------------------------------------------------------
Summary of changes:
src/select/bloom.h | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
diff --git a/src/select/bloom.h b/src/select/bloom.h
index 8c1da3f..85094cd 100644
--- a/src/select/bloom.h
+++ b/src/select/bloom.h
@@ -24,11 +24,6 @@
#ifndef libcss_bloom_h_
#define libcss_bloom_h_
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
#include <stdint.h>
/* Size of bloom filter as multiple of 32 bits.
@@ -197,9 +192,5 @@ static inline void css_bloom_init(css_bloom bloom[CSS_BLOOM_SIZE])
#endif
}
-#ifdef __cplusplus
-}
-#endif
-
#endif
--
Cascading Style Sheets library
9 years, 2 months
netsurf: branch master updated. release/3.2-74-gc9bf72a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c9bf72a4a30da996fc84e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c9bf72a4a30da996fc84ee6...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c9bf72a4a30da996fc84ee6df...
The branch, master has been updated
via c9bf72a4a30da996fc84ee6df8416a3e929ad28f (commit)
from e825f384370ec0c939f5b2c8d741b796b3eb98e9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c9bf72a4a30da996fc8...
commit c9bf72a4a30da996fc84ee6df8416a3e929ad28f
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Stop invalid background image URL from preventing page load.
Stops url(http://) from causing page load to fail with warning
message of "boxconvert".
diff --git a/render/box_construct.c b/render/box_construct.c
index 17cb330..9759d74 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -930,7 +930,7 @@ bool box_construct_element(struct box_construct_ctx *ctx,
/* Kick off fetch for any background image */
if (css_computed_background_image(box->style, &bgimage_uri) ==
CSS_BACKGROUND_IMAGE_IMAGE && bgimage_uri != NULL &&
- nsoption_bool(background_images) == true) {
+ nsoption_bool(background_images) == true) {
nsurl *url;
nserror error;
@@ -939,16 +939,17 @@ bool box_construct_element(struct box_construct_ctx *ctx,
* nsurl_joined it. Can this be improved?
* For now, just making another nsurl. */
error = nsurl_create(lwc_string_data(bgimage_uri), &url);
- if (error != NSERROR_OK)
- return false;
-
- if (html_fetch_object(ctx->content, url, box, image_types,
- ctx->content->base.available_width, 1000,
- true) == false) {
+ if (error == NSERROR_OK) {
+ /* Fetch image if we got a valid URL */
+ if (html_fetch_object(ctx->content, url, box,
+ image_types,
+ ctx->content->base.available_width,
+ 1000, true) == false) {
+ nsurl_unref(url);
+ return false;
+ }
nsurl_unref(url);
- return false;
}
- nsurl_unref(url);
}
if (*convert_children)
-----------------------------------------------------------------------
Summary of changes:
render/box_construct.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/render/box_construct.c b/render/box_construct.c
index 17cb330..9759d74 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -930,7 +930,7 @@ bool box_construct_element(struct box_construct_ctx *ctx,
/* Kick off fetch for any background image */
if (css_computed_background_image(box->style, &bgimage_uri) ==
CSS_BACKGROUND_IMAGE_IMAGE && bgimage_uri != NULL &&
- nsoption_bool(background_images) == true) {
+ nsoption_bool(background_images) == true) {
nsurl *url;
nserror error;
@@ -939,16 +939,17 @@ bool box_construct_element(struct box_construct_ctx *ctx,
* nsurl_joined it. Can this be improved?
* For now, just making another nsurl. */
error = nsurl_create(lwc_string_data(bgimage_uri), &url);
- if (error != NSERROR_OK)
- return false;
-
- if (html_fetch_object(ctx->content, url, box, image_types,
- ctx->content->base.available_width, 1000,
- true) == false) {
+ if (error == NSERROR_OK) {
+ /* Fetch image if we got a valid URL */
+ if (html_fetch_object(ctx->content, url, box,
+ image_types,
+ ctx->content->base.available_width,
+ 1000, true) == false) {
+ nsurl_unref(url);
+ return false;
+ }
nsurl_unref(url);
- return false;
}
- nsurl_unref(url);
}
if (*convert_children)
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.2-73-ge825f38
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e825f384370ec0c939f5b...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e825f384370ec0c939f5b2c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e825f384370ec0c939f5b2c8d...
The branch, master has been updated
via e825f384370ec0c939f5b2c8d741b796b3eb98e9 (commit)
via 9487076f2ad1298b1122155170949cb59156d9b9 (commit)
from dfb774c2458f749ebafba77ef30f2d16e80032e7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e825f384370ec0c939f...
commit e825f384370ec0c939f5b2c8d741b796b3eb98e9
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
move about and preferences window handling to more sensible position
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index 05865ff..8fed107 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -109,7 +109,7 @@ S_GTK := font_pango.c bitmap.c gui.c schedule.c thumbnail.c plotters.c \
selection.c history.c window.c fetch.c download.c menu.c \
print.c search.c tabs.c theme.c toolbar.c gettext.c \
compat.c cookies.c hotlist.c viewdata.c viewsource.c \
- $(addprefix dialogs/,preferences.c about.c)
+ preferences.c about.c
S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c)
# code in utils/container.ch is non-universal it seems
diff --git a/gtk/about.c b/gtk/about.c
new file mode 100644
index 0000000..84fb067
--- /dev/null
+++ b/gtk/about.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2014 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file gtk/about.c
+ *
+ * Implementation of gtk about dialog.
+ */
+
+#include <stdint.h>
+
+#include "utils/utils.h"
+#include "utils/messages.h"
+#include "utils/nsoption.h"
+#include "desktop/browser.h"
+#include "desktop/netsurf.h"
+
+#include "gtk/compat.h"
+#include "gtk/gui.h"
+#include "gtk/about.h"
+
+/**
+ * About dialog information button click.
+ *
+ * \param button The button widget that was clicked
+ * \param data The text of the url to open
+ */
+static void
+nsgtk_about_dialog_info(GtkWidget *button, gpointer data)
+{
+ nsurl *url;
+ nserror ret;
+ const char *url_text = data;
+ enum browser_window_create_flags flags = BW_CREATE_HISTORY;
+
+ if (nsoption_bool(show_single_tab) == true) {
+ flags |= BW_CREATE_TAB;
+ }
+
+ ret = nsurl_create(url_text, &url);
+ if (ret == NSERROR_OK) {
+ ret = browser_window_create(flags, url, NULL, NULL, NULL);
+ nsurl_unref(url);
+ }
+
+ if (ret != NSERROR_OK) {
+ warn_user(messages_get_errorcode(ret), 0);
+ }
+
+ /* close about dialog */
+ gtk_widget_destroy(gtk_widget_get_toplevel(button));
+}
+
+void nsgtk_about_dialog_init(GtkWindow *parent)
+{
+ GtkWidget *dialog, *vbox, *button, *image, *label;
+ gchar *name_string;
+ GList *pixbufs = gtk_window_get_default_icon_list();
+
+ name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">NetSurf %s</span>", netsurf_version);
+
+
+ /* Create the widgets */
+ dialog = gtk_dialog_new_with_buttons("About NetSurf",
+ parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ NULL);
+
+ vbox = nsgtk_vbox_new(FALSE, 8);
+
+ gtk_box_pack_start(GTK_BOX(nsgtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox, TRUE, TRUE, 0);
+
+ if (pixbufs != NULL) {
+ GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf(GDK_PIXBUF(g_list_nth_data(pixbufs, 0)));
+
+ image = gtk_image_new();
+
+ gtk_image_set_from_icon_set (GTK_IMAGE (image),
+ icon_set, GTK_ICON_SIZE_DIALOG);
+
+ gtk_icon_set_unref (icon_set);
+ g_list_free (pixbufs);
+
+ gtk_box_pack_start(GTK_BOX (vbox), image, FALSE, FALSE, 0);
+ }
+
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), name_string);
+ g_free (name_string);
+ gtk_label_set_selectable (GTK_LABEL (label), TRUE);
+ gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ label = gtk_label_new("NetSurf is a small fast web browser");
+ gtk_label_set_selectable(GTK_LABEL (label), TRUE);
+ gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ label = gtk_label_new("Copyright © 2003 - 2011 The NetSurf Developers");
+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
+ gtk_box_pack_start(GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+
+ nsgtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+
+ /* Add the OK button */
+ gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
+
+ /* Add the credits button */
+ button = gtk_button_new_from_stock ("Credits");
+ gtk_box_pack_end(GTK_BOX(nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))),
+ button, FALSE, TRUE, 0);
+ gtk_button_box_set_child_secondary (GTK_BUTTON_BOX(nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))), button, TRUE);
+ g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_info), (gpointer)"about:credits");
+
+ /* Add the Licence button */
+ button = gtk_button_new_from_stock ("Licence");
+ gtk_box_pack_end(GTK_BOX (nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))),
+ button, FALSE, TRUE, 0);
+ gtk_button_box_set_child_secondary (GTK_BUTTON_BOX(nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))), button, TRUE);
+ g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_info), (gpointer)"about:licence");
+
+
+ /* Ensure that the dialog box is destroyed when the user responds. */
+ g_signal_connect_swapped(dialog,
+ "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
+
+ /* Add the label, and show everything we've added to the dialog. */
+ gtk_widget_show_all(dialog);
+}
diff --git a/gtk/about.h b/gtk/about.h
new file mode 100644
index 0000000..bf3c9f5
--- /dev/null
+++ b/gtk/about.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2008 Rob Kendrick <rjek(a)rjek.com>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NETSURF_GTK_ABOUT_H
+#define NETSURF_GTK_ABOUT_H
+
+void nsgtk_about_dialog_init(GtkWindow *parent);
+
+#endif
diff --git a/gtk/dialogs/about.c b/gtk/dialogs/about.c
deleted file mode 100644
index 99df137..0000000
--- a/gtk/dialogs/about.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2014 Vincent Sanders <vince(a)netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * \file gtk/dialogs/about.c
- *
- * Implementation of gtk about dialog.
- */
-
-#include <stdint.h>
-
-#include "utils/utils.h"
-#include "utils/messages.h"
-#include "utils/nsoption.h"
-#include "desktop/browser.h"
-#include "desktop/netsurf.h"
-
-#include "gtk/compat.h"
-#include "gtk/gui.h"
-#include "gtk/dialogs/about.h"
-
-/**
- * About dialog information button click.
- *
- * \param button The button widget that was clicked
- * \param data The text of the url to open
- */
-static void
-nsgtk_about_dialog_info(GtkWidget *button, gpointer data)
-{
- nsurl *url;
- nserror ret;
- const char *url_text = data;
- enum browser_window_create_flags flags = BW_CREATE_HISTORY;
-
- if (nsoption_bool(show_single_tab) == true) {
- flags |= BW_CREATE_TAB;
- }
-
- ret = nsurl_create(url_text, &url);
- if (ret == NSERROR_OK) {
- ret = browser_window_create(flags, url, NULL, NULL, NULL);
- nsurl_unref(url);
- }
-
- if (ret != NSERROR_OK) {
- warn_user(messages_get_errorcode(ret), 0);
- }
-
- /* close about dialog */
- gtk_widget_destroy(gtk_widget_get_toplevel(button));
-}
-
-void nsgtk_about_dialog_init(GtkWindow *parent)
-{
- GtkWidget *dialog, *vbox, *button, *image, *label;
- gchar *name_string;
- GList *pixbufs = gtk_window_get_default_icon_list();
-
- name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">NetSurf %s</span>", netsurf_version);
-
-
- /* Create the widgets */
- dialog = gtk_dialog_new_with_buttons("About NetSurf",
- parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- NULL);
-
- vbox = nsgtk_vbox_new(FALSE, 8);
-
- gtk_box_pack_start(GTK_BOX(nsgtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox, TRUE, TRUE, 0);
-
- if (pixbufs != NULL) {
- GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf(GDK_PIXBUF(g_list_nth_data(pixbufs, 0)));
-
- image = gtk_image_new();
-
- gtk_image_set_from_icon_set (GTK_IMAGE (image),
- icon_set, GTK_ICON_SIZE_DIALOG);
-
- gtk_icon_set_unref (icon_set);
- g_list_free (pixbufs);
-
- gtk_box_pack_start(GTK_BOX (vbox), image, FALSE, FALSE, 0);
- }
-
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), name_string);
- g_free (name_string);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- label = gtk_label_new("NetSurf is a small fast web browser");
- gtk_label_set_selectable(GTK_LABEL (label), TRUE);
- gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- label = gtk_label_new("Copyright © 2003 - 2011 The NetSurf Developers");
- gtk_label_set_selectable(GTK_LABEL(label), TRUE);
- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
- gtk_box_pack_start(GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
-
- nsgtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
-
- /* Add the OK button */
- gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
-
- /* Add the credits button */
- button = gtk_button_new_from_stock ("Credits");
- gtk_box_pack_end(GTK_BOX(nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))),
- button, FALSE, TRUE, 0);
- gtk_button_box_set_child_secondary (GTK_BUTTON_BOX(nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))), button, TRUE);
- g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_info), (gpointer)"about:credits");
-
- /* Add the Licence button */
- button = gtk_button_new_from_stock ("Licence");
- gtk_box_pack_end(GTK_BOX (nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))),
- button, FALSE, TRUE, 0);
- gtk_button_box_set_child_secondary (GTK_BUTTON_BOX(nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))), button, TRUE);
- g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_info), (gpointer)"about:licence");
-
-
- /* Ensure that the dialog box is destroyed when the user responds. */
- g_signal_connect_swapped(dialog,
- "response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
-
- /* Add the label, and show everything we've added to the dialog. */
- gtk_widget_show_all(dialog);
-}
diff --git a/gtk/dialogs/about.h b/gtk/dialogs/about.h
deleted file mode 100644
index bf3c9f5..0000000
--- a/gtk/dialogs/about.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2008 Rob Kendrick <rjek(a)rjek.com>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NETSURF_GTK_ABOUT_H
-#define NETSURF_GTK_ABOUT_H
-
-void nsgtk_about_dialog_init(GtkWindow *parent);
-
-#endif
diff --git a/gtk/dialogs/preferences.c b/gtk/dialogs/preferences.c
deleted file mode 100644
index f38c7e9..0000000
--- a/gtk/dialogs/preferences.c
+++ /dev/null
@@ -1,1138 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdint.h>
-#include <math.h>
-#include <string.h>
-
-#include "utils/utils.h"
-#include "utils/messages.h"
-#include "utils/nsoption.h"
-#include "utils/file.h"
-#include "utils/log.h"
-#include "desktop/browser.h"
-#include "desktop/searchweb.h"
-
-#include "gtk/compat.h"
-#include "gtk/window.h"
-#include "gtk/gui.h"
-#include "gtk/scaffolding.h"
-#include "gtk/theme.h"
-#include "gtk/dialogs/preferences.h"
-
-/* private prefs */
-struct ppref {
- /** dialog handle created when window first accessed */
- GObject *dialog;
-
- struct browser_window *bw;
-
- /* widgets which are accessed from outside their own signal handlers */
- GtkEntry *entryHomePageURL;
- GtkEntry *entryProxyHost;
- GtkEntry *entryProxyUser;
- GtkEntry *entryProxyPassword;
- GtkEntry *entryProxyNoproxy;
- GtkSpinButton *spinProxyPort;
-
- /* dynamic list stores */
- GtkListStore *themes;
- GtkListStore *content_language;
- GtkListStore *search_providers;
-};
-
-static struct ppref ppref;
-
-
-/* Set netsurf option based on toggle button state
- *
- * This works for any widget which subclasses togglebutton (checkbox,
- * radiobutton etc.)
- */
-#define TOGGLEBUTTON_SIGNALS(WIDGET, OPTION) \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_toggled(GtkToggleButton *togglebutton, \
- struct ppref *priv); \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_toggled(GtkToggleButton *togglebutton, \
- struct ppref *priv) \
-{ \
- nsoption_set_bool(OPTION, \
- gtk_toggle_button_get_active(togglebutton)); \
-} \
- \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, \
- struct ppref *priv); \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, \
- struct ppref *priv) \
-{ \
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), \
- nsoption_bool(OPTION)); \
-}
-
-#define SPINBUTTON_SIGNALS(WIDGET, OPTION, MULTIPLIER) \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
- struct ppref *priv); \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
- struct ppref *priv) \
-{ \
- nsoption_set_int(OPTION, \
- round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \
-} \
- \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
-{ \
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \
- ((gdouble)nsoption_int(OPTION)) / MULTIPLIER); \
-}
-
-#define SPINBUTTON_UINT_SIGNALS(WIDGET, OPTION, MULTIPLIER) \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
- struct ppref *priv); \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
- struct ppref *priv) \
-{ \
- nsoption_set_uint(OPTION, \
- round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \
-} \
- \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
-{ \
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \
- ((gdouble)nsoption_uint(OPTION)) / MULTIPLIER); \
-}
-
-#define ENTRY_SIGNALS(WIDGET, OPTION) \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv); \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv)\
-{ \
- nsoption_set_charp(OPTION, \
- strdup(gtk_entry_get_text(GTK_ENTRY(editable)))); \
-} \
- \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
-G_MODULE_EXPORT void \
-nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
-{ \
- const char *OPTION; \
- OPTION = nsoption_charp(OPTION); \
- if (OPTION != NULL) { \
- gtk_entry_set_text(GTK_ENTRY(widget), OPTION); \
- } \
-}
-
-/* GTK module requires these to be exported symbols so these all need
- * forward declaring to avoid warnings
- */
-G_MODULE_EXPORT void nsgtk_preferences_comboProxyType_changed(GtkComboBox *combo, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboProxyType_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboboxLoadImages_changed(GtkComboBox *combo, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboboxLoadImages_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboDefault_changed(GtkComboBox *combo, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboDefault_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_fontPreview_clicked(GtkButton *button, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboboxLanguage_changed(GtkComboBox *combo, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboboxLanguage_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboTheme_changed(GtkComboBox *combo, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboTheme_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_buttonAddTheme_clicked(GtkButton *button, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_checkShowSingleTab_toggled(GtkToggleButton *togglebutton, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_checkShowSingleTab_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboTabPosition_changed(GtkComboBox *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboTabPosition_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboDeveloperView_changed(GtkComboBox *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboDeveloperView_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboButtonType_changed(GtkComboBox *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboButtonType_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_setCurrentPage_clicked(GtkButton *button, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_setDefaultPage_clicked(GtkButton *button, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboSearch_changed(GtkComboBox *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_comboSearch_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_fileChooserDownloads_selectionchanged(GtkFileChooser *chooser, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_fileChooserDownloads_realize(GtkWidget *widget, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_dialogPreferences_response(GtkDialog *dlg, gint resid);
-G_MODULE_EXPORT gboolean nsgtk_preferences_dialogPreferences_deleteevent(GtkDialog *dlg, struct ppref *priv);
-G_MODULE_EXPORT void nsgtk_preferences_dialogPreferences_destroy(GtkDialog *dlg, struct ppref *priv);
-
-
-/********* PDF **********/
-
-/* Appearance */
-
-/* no images in output */
-TOGGLEBUTTON_SIGNALS(checkSuppressImages, suppress_images)
-
-/* no background images */
-TOGGLEBUTTON_SIGNALS(checkRemoveBackgrounds, remove_backgrounds)
-
-/* scale to fit page */
-TOGGLEBUTTON_SIGNALS(checkFitPage, enable_loosening)
-
-/* port */
-SPINBUTTON_SIGNALS(spinExportScale, export_scale, 1.0)
-
-/* Margins */
-SPINBUTTON_SIGNALS(spinMarginTop, margin_top, 1.0)
-SPINBUTTON_SIGNALS(spinMarginBottom, margin_bottom, 1.0)
-SPINBUTTON_SIGNALS(spinMarginLeft, margin_left, 1.0)
-SPINBUTTON_SIGNALS(spinMarginRight, margin_right, 1.0)
-
-
-/* Generation */
-
-/* output is compressed */
-TOGGLEBUTTON_SIGNALS(checkCompressPDF, enable_PDF_compression)
-
-/* output has a password */
-TOGGLEBUTTON_SIGNALS(checkPasswordPDF, enable_PDF_password)
-
-/********* Network **********/
-
-/* HTTP proxy */
-static void set_proxy_widgets_sensitivity(int proxyval, struct ppref *priv)
-{
- gboolean host;
- gboolean port;
- gboolean user;
- gboolean pass;
- gboolean noproxy;
-
- switch (proxyval) {
- case 0: /* no proxy */
- host = FALSE;
- port = FALSE;
- user = FALSE;
- pass = FALSE;
- noproxy = FALSE;
- break;
-
- case 1: /* proxy with no auth */
- host = TRUE;
- port = TRUE;
- user = FALSE;
- pass = FALSE;
- noproxy = TRUE;
- break;
-
- case 2: /* proxy with basic auth */
- host = TRUE;
- port = TRUE;
- user = TRUE;
- pass = TRUE;
- noproxy = TRUE;
- break;
-
- case 3: /* proxy with ntlm auth */
- host = TRUE;
- port = TRUE;
- user = TRUE;
- pass = TRUE;
- noproxy = TRUE;
- break;
-
- case 4: /* system proxy */
- host = FALSE;
- port = FALSE;
- user = FALSE;
- pass = FALSE;
- noproxy = FALSE;
- break;
-
- default:
- return;
- }
-
- gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyHost), host);
- gtk_widget_set_sensitive(GTK_WIDGET(priv->spinProxyPort), port);
- gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyUser), user);
- gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyPassword), pass);
- gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyNoproxy), noproxy);
-
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_comboProxyType_changed(GtkComboBox *combo, struct ppref *priv)
-{
- int proxy_sel;
- proxy_sel = gtk_combo_box_get_active(combo);
-
- switch (proxy_sel) {
- case 0: /* no proxy */
- nsoption_set_bool(http_proxy, false);
- break;
-
- 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: /* proxy with basic auth */
- nsoption_set_bool(http_proxy, true);
- nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC);
- break;
-
- 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;
- }
-
- set_proxy_widgets_sensitivity(proxy_sel, priv);
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_comboProxyType_realize(GtkWidget *widget, struct ppref *priv)
-{
- int proxytype = 0; /* no proxy by default */
-
- 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 (nsoption_charp(http_proxy_host) == NULL) {
- /* set to use a proxy without a host, turn proxy off */
- proxytype = 0;
- } else if (((proxytype == 2) ||
- (proxytype == 3)) &&
- ((nsoption_charp(http_proxy_auth_user) == NULL) ||
- (nsoption_charp(http_proxy_auth_pass) == NULL))) {
- /* authentication selected with empty credentials, turn proxy off */
- proxytype = 0;
- }
- }
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), proxytype);
-
- set_proxy_widgets_sensitivity(proxytype, priv);
-}
-
-/* host */
-ENTRY_SIGNALS(entryProxyHost, http_proxy_host)
-
-/* port */
-SPINBUTTON_SIGNALS(spinProxyPort, http_proxy_port, 1.0)
-
-/* user */
-ENTRY_SIGNALS(entryProxyUser, http_proxy_auth_user)
-
-/* password */
-ENTRY_SIGNALS(entryProxyPassword, http_proxy_auth_pass)
-
-/* no proxy */
-ENTRY_SIGNALS(entryProxyNoproxy, http_proxy_noproxy)
-
-/* Fetching */
-
-/* maximum fetchers */
-SPINBUTTON_SIGNALS(spinMaxFetchers, max_fetchers, 1.0)
-
-/* fetches per host */
-SPINBUTTON_SIGNALS(spinFetchesPerHost, max_fetchers_per_host, 1.0)
-
-/* cached connections */
-SPINBUTTON_SIGNALS(spinCachedConnections, max_cached_fetch_handles, 1.0)
-
-
-/********* Privacy **********/
-
-/* General */
-
-/* enable referral submission */
-TOGGLEBUTTON_SIGNALS(checkSendReferer, send_referer)
-
-/* send do not track */
-TOGGLEBUTTON_SIGNALS(checkSendDNT, do_not_track)
-
-/* History */
-
-/* local history shows url tooltips */
-TOGGLEBUTTON_SIGNALS(checkHoverURLs, hover_urls)
-
-/* remember browsing history */
-SPINBUTTON_SIGNALS(spinHistoryAge, history_age, 1.0)
-
-/* Cache */
-
-/* memory cache size */
-SPINBUTTON_SIGNALS(spinMemoryCacheSize, memory_cache_size, (1024*1024))
-
-/* disc cache size */
-SPINBUTTON_UINT_SIGNALS(spinDiscCacheSize, disc_cache_size, (1024*1024))
-
-
-/* disc cache age */
-SPINBUTTON_SIGNALS(spinDiscCacheAge, disc_cache_age, 1.0)
-
-
-/********* Content **********/
-
-/* Control */
-
-
-/* prevent popups */
-TOGGLEBUTTON_SIGNALS(checkDisablePopups, disable_popups)
-
-/* hide adverts */
-TOGGLEBUTTON_SIGNALS(checkHideAdverts, block_advertisements)
-
-/* enable javascript */
-TOGGLEBUTTON_SIGNALS(checkEnableJavascript, enable_javascript)
-
-/* disable plugins */
-TOGGLEBUTTON_SIGNALS(checkDisablePlugins, disable_plugins)
-
-/* high quality image scaling */
-TOGGLEBUTTON_SIGNALS(checkResampleImages, render_resample)
-
-/* load and display of images */
-G_MODULE_EXPORT void
-nsgtk_preferences_comboboxLoadImages_changed(GtkComboBox *combo,
- struct ppref *priv)
-{
- int img_sel;
- /* get the row number for the selection */
- img_sel = gtk_combo_box_get_active(combo);
- switch (img_sel) {
- case 0:
- /* background and foreground */
- nsoption_set_bool(foreground_images, true);
- nsoption_set_bool(background_images, true);
- break;
-
- case 1:
- /* foreground only */
- nsoption_set_bool(foreground_images, true);
- nsoption_set_bool(background_images, false);
- break;
-
- case 2:
- /* background only */
- nsoption_set_bool(foreground_images, false);
- nsoption_set_bool(background_images, true);
- break;
-
- case 3:
- /* no images */
- nsoption_set_bool(foreground_images, false);
- nsoption_set_bool(background_images, false);
- break;
- }
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_comboboxLoadImages_realize(GtkWidget *widget,
- struct ppref *priv)
-{
- if (nsoption_bool(foreground_images)) {
- if (nsoption_bool(background_images)) {
- /* background and foreground */
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
- } else {
- /* foreground only */
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 1);
- }
- } else {
- if (nsoption_bool(background_images)) {
- /* background only */
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 2);
- } else {
- /* no images */
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 3);
- }
- }
-}
-
-/* Animation */
-
-/* enable animation */
-TOGGLEBUTTON_SIGNALS(checkEnableAnimations, animate_images)
-
-/* frame time */
-SPINBUTTON_SIGNALS(spinAnimationSpeed, minimum_gif_delay, 100.0)
-
-/* Fonts */
-
-/* default font */
-G_MODULE_EXPORT void
-nsgtk_preferences_comboDefault_changed(GtkComboBox *combo, struct ppref *priv)
-{
- int font_sel;
- /* get the row number for the selection */
- font_sel = gtk_combo_box_get_active(combo);
- if ((font_sel >= 0) && (font_sel <= 4)) {
- nsoption_set_int(font_default, font_sel);
- }
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_comboDefault_realize(GtkWidget *widget, struct ppref *priv)
-{
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
- nsoption_int(font_default));
-}
-
-/* default font size */
-SPINBUTTON_SIGNALS(spinDefaultSize, font_size, 10.0)
-
-/* preview - actually reflow all views */
-G_MODULE_EXPORT void
-nsgtk_preferences_fontPreview_clicked(GtkButton *button, struct ppref *priv)
-{
- nsgtk_reflow_all_windows();
-}
-
-
-/* Language */
-
-/* accept language */
-G_MODULE_EXPORT void
-nsgtk_preferences_comboboxLanguage_changed(GtkComboBox *combo,
- struct ppref *priv)
-{
- 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);
- }
-
- if (lang != NULL) {
- nsoption_set_charp(accept_language, strdup(lang));
- g_free(lang);
- }
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_comboboxLanguage_realize(GtkWidget *widget,
- struct ppref *priv)
-{
- /* Fill content language list store */
- int active_language = 0;
- GtkTreeIter iter;
- FILE *fp;
- char buf[50];
- const char *default_accept_language = "en";
-
- if ((priv->content_language != NULL) &&
- (languages_file_location != NULL) &&
- ((fp = fopen(languages_file_location, "r")) != NULL)) {
- int combo_row_count = 0;
-
- gtk_list_store_clear(priv->content_language);
- active_language = -1;
-
- LOG(("Used %s for languages", languages_file_location));
- while (fgets(buf, sizeof(buf), fp)) {
- /* Ignore blank lines */
- if (buf[0] == '\0')
- continue;
-
- /* Remove trailing \n */
- buf[strlen(buf) - 1] = '\0';
-
- gtk_list_store_append(priv->content_language, &iter);
- gtk_list_store_set(priv->content_language,
- &iter, 0, buf, -1 );
-
- if (strcmp(buf, default_accept_language) == 0) {
- active_language = combo_row_count;
- }
-
- combo_row_count++;
- }
-
- if (active_language == -1) {
- /* configured language was not in list, add it */
- gtk_list_store_append(priv->content_language, &iter);
- gtk_list_store_set(priv->content_language,
- &iter,
- 0, default_accept_language, -1 );
- active_language = combo_row_count;
- }
-
- fclose(fp);
- } else {
- LOG(("Failed opening languages file"));
- }
-
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), active_language);
-}
-
-
-/********* Apperance **********/
-
-/* Themes */
-
-/* select theme */
-G_MODULE_EXPORT void
-nsgtk_preferences_comboTheme_changed(GtkComboBox *combo, struct ppref *priv)
-{
- struct nsgtk_scaffolding *current;
- int theme = 0;
- gchar *name;
- 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)) {
- /* get the row number for the config */
- theme = gtk_combo_box_get_active(combo);
-
- nsoption_set_int(current_theme, theme);
-
- /* retrive the theme name if it is not the default */
- if (theme != 0) {
- /* Obtain data model from combo box. */
- model = gtk_combo_box_get_model(combo);
-
- /* Obtain string from model. */
- gtk_tree_model_get(model, &iter, 0, &name, -1);
- } else {
- name = NULL;
- }
-
- nsgtk_theme_set_name(name);
-
- if (name != NULL) {
- g_free(name);
- }
-
- current = nsgtk_scaffolding_iterate(NULL);
- while (current != NULL) {
- nsgtk_theme_implement(current);
- current = nsgtk_scaffolding_iterate(current);
- }
- }
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_comboTheme_realize(GtkWidget *widget, struct ppref *priv)
-{
- /* Fill theme list store */
- FILE *fp;
- GtkTreeIter iter;
- char buf[50];
- int combo_row_count = 0;
- int selected_theme = 0;
-
- if ((priv->themes != NULL) &&
- (themelist_file_location != NULL) &&
- ((fp = fopen(themelist_file_location, "r")) != NULL)) {
- gtk_list_store_clear(priv->themes);
-
- LOG(("Used %s for themelist", themelist_file_location));
-
- while (fgets(buf, sizeof(buf), fp)) {
- /* Ignore blank lines */
- if (buf[0] == '\0')
- continue;
-
- /* Remove trailing \n */
- buf[strlen(buf) - 1] = '\0';
-
- gtk_list_store_append(priv->themes, &iter);
- gtk_list_store_set(priv->themes, &iter, 0, buf, -1);
-
- combo_row_count++;
- }
-
- fclose(fp);
- } else {
- LOG(("Failed opening themes file"));
- }
-
- /* get configured theme and sanity check value */
- selected_theme = nsoption_int(current_theme);
- if (selected_theme > combo_row_count) {
- selected_theme = combo_row_count;
- }
- if (selected_theme < 0) {
- selected_theme = 0;
- }
-
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), selected_theme);
-}
-
-/* add theme */
-G_MODULE_EXPORT void
-nsgtk_preferences_buttonAddTheme_clicked(GtkButton *button, struct ppref *priv)
-{
- char *filename, *directory;
- size_t len;
- GtkWidget *fc;
- char *themesfolder;
- gint res;
-
- fc = gtk_file_chooser_dialog_new(messages_get("gtkAddThemeTitle"),
- GTK_WINDOW(priv->dialog),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- NULL);
- len = SLEN("themes") + strlen(res_dir_location) + 1;
-
- themesfolder = malloc(len);
-
- snprintf(themesfolder, len, "%sthemes", res_dir_location);
-
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc), themesfolder);
-
- res = gtk_dialog_run(GTK_DIALOG(fc));
- if (res == GTK_RESPONSE_ACCEPT) {
- filename = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(fc));
- if (filename != NULL) {
- if (strcmp(filename, themesfolder) != 0) {
- directory = strrchr(filename, '/');
- *directory = '\0';
- if (strcmp(filename, themesfolder) != 0) {
- warn_user(messages_get(
- "gtkThemeFolderInstructions"),
- 0);
-
- if (filename != NULL)
- g_free(filename);
-
- } else {
- directory++;
- nsgtk_theme_add(directory);
- }
- } else {
- g_free(filename);
-
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
-
- if (strcmp(filename, themesfolder) == 0) {
- warn_user(messages_get("gtkThemeFolderSub"),
- 0);
- } else {
- directory = strrchr(filename, '/') + 1;
- nsgtk_theme_add(directory);
- }
- }
-
- g_free(filename);
- }
- }
-
- free(themesfolder);
-
- gtk_widget_destroy(fc);
-}
-
-/* Tabs */
-
-/* always show tab bar */
-G_MODULE_EXPORT void
-nsgtk_preferences_checkShowSingleTab_toggled(GtkToggleButton *togglebutton,
- struct ppref *priv)
-{
- nsoption_set_bool(show_single_tab,
- gtk_toggle_button_get_active(togglebutton));
- nsgtk_reflow_all_windows();
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_checkShowSingleTab_realize(GtkWidget *widget,
- struct ppref *priv)
-{
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
- nsoption_bool(show_single_tab));
-}
-
-/* switch to newly opened tabs immediately */
-TOGGLEBUTTON_SIGNALS(checkFocusNew, focus_new)
-
-/* newly opened tabs are blank */
-TOGGLEBUTTON_SIGNALS(checkNewBlank, new_blank)
-
-/* tab position */
-G_MODULE_EXPORT void
-nsgtk_preferences_comboTabPosition_changed(GtkComboBox *widget,
- struct ppref *priv)
-{
- struct nsgtk_scaffolding *current;
-
- /* set the option */
- nsoption_set_int(position_tab, gtk_combo_box_get_active(widget));
-
- /* update all notebooks in all scaffolds */
- current = nsgtk_scaffolding_iterate(NULL);
- while (current) {
- nsgtk_scaffolding_reset_offset(current);
-
- nsgtk_reflow_all_windows();
-
- current = nsgtk_scaffolding_iterate(current);
- }
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_comboTabPosition_realize(GtkWidget *widget,
- struct ppref *priv)
-{
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
- nsoption_int(position_tab));
-}
-
-/* Tools */
-
-/* developer view opening */
-G_MODULE_EXPORT void
-nsgtk_preferences_comboDeveloperView_changed(GtkComboBox *widget,
- struct ppref *priv)
-{
- /* set the option */
- nsoption_set_int(developer_view, gtk_combo_box_get_active(widget));
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_comboDeveloperView_realize(GtkWidget *widget,
- struct ppref *priv)
-{
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
- nsoption_int(developer_view));
-}
-
-
-/* URLbar */
-
-/* show recently visited urls as you type */
-TOGGLEBUTTON_SIGNALS(checkDisplayRecentURLs, url_suggestion)
-
-/* Toolbar */
-
-/* button position */
-G_MODULE_EXPORT void
-nsgtk_preferences_comboButtonType_changed(GtkComboBox *widget,
- struct ppref *priv)
-{
- struct nsgtk_scaffolding *current;
-
- nsoption_set_int(button_type, gtk_combo_box_get_active(widget) + 1);
-
- current = nsgtk_scaffolding_iterate(NULL);
- while (current != NULL) {
- nsgtk_scaffolding_reset_offset(current);
- switch(nsoption_int(button_type)) {
- /* value of 0 is reserved for 'unset' */
- case 1:
- gtk_toolbar_set_style(
- GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
- GTK_TOOLBAR_ICONS);
- gtk_toolbar_set_icon_size(
- GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- break;
- case 2:
- gtk_toolbar_set_style(
- GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
- GTK_TOOLBAR_ICONS);
- gtk_toolbar_set_icon_size(
- GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
- GTK_ICON_SIZE_LARGE_TOOLBAR);
- break;
- case 3:
- gtk_toolbar_set_style(
- GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
- GTK_TOOLBAR_BOTH);
- gtk_toolbar_set_icon_size(
- GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
- GTK_ICON_SIZE_LARGE_TOOLBAR);
- break;
- case 4:
- gtk_toolbar_set_style(
- GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
- GTK_TOOLBAR_TEXT);
- default:
- break;
- }
- current = nsgtk_scaffolding_iterate(current);
- }
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_comboButtonType_realize(GtkWidget *widget,
- struct ppref *priv)
-{
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
- nsoption_int(button_type) - 1);
-}
-
-
-
-/************ Main ************/
-
-/* Startup */
-
-/* entry HomePageURL widget */
-ENTRY_SIGNALS(entryHomePageURL, homepage_url)
-
-/* put current page into homepage url */
-G_MODULE_EXPORT void
-nsgtk_preferences_setCurrentPage_clicked(GtkButton *button, struct ppref *priv)
-{
- const gchar *url = nsurl_access(browser_window_get_url(priv->bw));
-
- if (priv->entryHomePageURL != NULL) {
- gtk_entry_set_text(GTK_ENTRY(priv->entryHomePageURL), url);
- nsoption_set_charp(homepage_url, strdup(url));
- }
-}
-
-/* put default page into homepage */
-G_MODULE_EXPORT void
-nsgtk_preferences_setDefaultPage_clicked(GtkButton *button, struct ppref *priv)
-{
- const gchar *url = NETSURF_HOMEPAGE;
-
- if (priv->entryHomePageURL != NULL) {
- gtk_entry_set_text(GTK_ENTRY(priv->entryHomePageURL), url);
- nsoption_set_charp(homepage_url, strdup(url));
- }
-}
-
-/* Search */
-
-/* Url Search widget */
-TOGGLEBUTTON_SIGNALS(checkUrlSearch, search_url_bar)
-
-/* provider combo */
-G_MODULE_EXPORT void
-nsgtk_preferences_comboSearch_changed(GtkComboBox *widget, struct ppref *priv)
-{
- int provider;
-
- provider = gtk_combo_box_get_active(widget);
-
- /* set the option */
- nsoption_set_int(search_provider, provider);
-
- /* set search provider */
- search_web_select_provider(provider);
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_comboSearch_realize(GtkWidget *widget, struct ppref *priv)
-{
- int iter;
- const char *name;
- int provider = nsoption_int(search_provider);
-
- if (priv->search_providers != NULL) {
- gtk_list_store_clear(priv->search_providers);
- for (iter = search_web_iterate_providers(0, &name);
- iter != -1;
- iter = search_web_iterate_providers(iter, &name)) {
- gtk_list_store_insert_with_values(priv->search_providers,
- NULL, -1,
- 0, name, -1);
- }
- }
-
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), provider);
-}
-
-
-/* Downloads */
-
-/* clear downloads */
-TOGGLEBUTTON_SIGNALS(checkClearDownloads, downloads_clear)
-
-/* request overwite */
-TOGGLEBUTTON_SIGNALS(checkRequestOverwrite, request_overwrite)
-
-/* download location
- *
- * note selection-changed is used instead of file-set as the returned
- * filename when that signal are used is incorrect. Though this signal
- * does update frequently often with the same data.
- */
-G_MODULE_EXPORT void
-nsgtk_preferences_fileChooserDownloads_selectionchanged(GtkFileChooser *chooser,
- struct ppref *priv)
-{
- gchar *dir;
- dir = gtk_file_chooser_get_filename(chooser);
- nsoption_set_charp(downloads_directory, strdup(dir));
- g_free(dir);
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_fileChooserDownloads_realize(GtkWidget *widget,
- struct ppref *priv)
-{
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(widget),
- nsoption_charp(downloads_directory));
-}
-
-
-/************* Dialog window ***********/
-
-/* dialog close and destroy events */
-G_MODULE_EXPORT void
-nsgtk_preferences_dialogPreferences_response(GtkDialog *dlg, gint resid)
-{
- char *choices = NULL;
-
- if (resid == GTK_RESPONSE_CLOSE) {
- netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
- if (choices != NULL) {
- nsoption_write(choices, NULL, NULL);
- free(choices);
- }
- gtk_widget_hide(GTK_WIDGET(dlg));
- }
-}
-
-G_MODULE_EXPORT gboolean
-nsgtk_preferences_dialogPreferences_deleteevent(GtkDialog *dlg,
- struct ppref *priv)
-{
- char *choices = NULL;
-
- netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
- if (choices != NULL) {
- nsoption_write(choices, NULL, NULL);
- free(choices);
- }
-
- gtk_widget_hide(GTK_WIDGET(dlg));
-
- /* Delt with it by hiding window, no need to destory widget by
- * default.
- */
- return TRUE;
-}
-
-G_MODULE_EXPORT void
-nsgtk_preferences_dialogPreferences_destroy(GtkDialog *dlg, struct ppref *priv)
-{
- char *choices = NULL;
-
- netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
- if (choices != NULL) {
- nsoption_write(choices, NULL, NULL);
- free(choices);
- }
-}
-
-
-/* exported interface documented in gtk/dialogs/preferences.h */
-GtkWidget* nsgtk_preferences(struct browser_window *bw, GtkWindow *parent)
-{
- GError *error = NULL;
- GtkBuilder *preferences_builder;
- struct ppref *priv = &ppref;
-
- priv->bw = bw; /* for setting "current" page */
-
- /* memoised dialog creation */
- if (priv->dialog != NULL) {
- gtk_window_set_transient_for(GTK_WINDOW(priv->dialog), parent);
- return GTK_WIDGET(priv->dialog);
- }
-
- /* populate builder object */
- preferences_builder = gtk_builder_new();
- if (!gtk_builder_add_from_file(preferences_builder,
- glade_file_location->options,
- &error)) {
- g_warning("Couldn't load builder file: %s", error->message);
- g_error_free(error);
- return NULL;
- }
-
-
- priv->dialog = gtk_builder_get_object(preferences_builder,
- "dialogPreferences");
- if (priv->dialog == NULL) {
- LOG(("Unable to get object for preferences dialog"));
- /* release builder as were done with it */
- g_object_unref(G_OBJECT(preferences_builder));
- return NULL;
- }
-
- /* need to explicitly obtain handles for some widgets enabling
- * updates by other widget events
- */
-#define GB(TYPE, NAME) GTK_##TYPE(gtk_builder_get_object(preferences_builder, #NAME))
- priv->entryHomePageURL = GB(ENTRY, entryHomePageURL);
- priv->themes = GB(LIST_STORE, liststore_themes);
- priv->content_language = GB(LIST_STORE, liststore_content_language);
- priv->search_providers = GB(LIST_STORE, liststore_search_provider);
- priv->entryProxyHost = GB(ENTRY, entryProxyHost);
- priv->spinProxyPort = GB(SPIN_BUTTON, spinProxyPort);
- priv->entryProxyUser = GB(ENTRY, entryProxyUser);
- priv->entryProxyPassword = GB(ENTRY, entryProxyPassword);
- priv->entryProxyNoproxy = GB(ENTRY, entryProxyNoproxy);
-#undef GB
-
- /* connect all signals ready to use */
- gtk_builder_connect_signals(preferences_builder, priv);
-
- /* release builder as were done with it */
- g_object_unref(G_OBJECT(preferences_builder));
-
- /* mark dialog as transient on parent */
- gtk_window_set_transient_for(GTK_WINDOW(priv->dialog), parent);
-
- return GTK_WIDGET(priv->dialog);
-}
-
-/* exported interface documented in gtk/dialogs/preferences.h */
-void nsgtk_preferences_theme_add(const char *themename)
-{
- struct ppref *priv = &ppref;
- GtkTreeIter iter;
-
- gtk_list_store_append(priv->themes, &iter);
- gtk_list_store_set(priv->themes, &iter, 0, themename, -1 );
-}
diff --git a/gtk/dialogs/preferences.h b/gtk/dialogs/preferences.h
deleted file mode 100644
index 3ef33ca..0000000
--- a/gtk/dialogs/preferences.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NETSURF_GTK_PREFERENCES_H
-#define NETSURF_GTK_PREFERENCES_H
-
-#include <gtk/gtk.h>
-
-/** Initialise prefernces window
- */
-GtkWidget* nsgtk_preferences(struct browser_window *bw, GtkWindow *parent);
-
-/** Theme added
- */
-void nsgtk_preferences_theme_add(const char *themename);
-
-#endif
diff --git a/gtk/preferences.c b/gtk/preferences.c
new file mode 100644
index 0000000..0255b4b
--- /dev/null
+++ b/gtk/preferences.c
@@ -0,0 +1,1138 @@
+/*
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdint.h>
+#include <math.h>
+#include <string.h>
+
+#include "utils/utils.h"
+#include "utils/messages.h"
+#include "utils/nsoption.h"
+#include "utils/file.h"
+#include "utils/log.h"
+#include "desktop/browser.h"
+#include "desktop/searchweb.h"
+
+#include "gtk/compat.h"
+#include "gtk/window.h"
+#include "gtk/gui.h"
+#include "gtk/scaffolding.h"
+#include "gtk/theme.h"
+#include "gtk/preferences.h"
+
+/* private prefs */
+struct ppref {
+ /** dialog handle created when window first accessed */
+ GObject *dialog;
+
+ struct browser_window *bw;
+
+ /* widgets which are accessed from outside their own signal handlers */
+ GtkEntry *entryHomePageURL;
+ GtkEntry *entryProxyHost;
+ GtkEntry *entryProxyUser;
+ GtkEntry *entryProxyPassword;
+ GtkEntry *entryProxyNoproxy;
+ GtkSpinButton *spinProxyPort;
+
+ /* dynamic list stores */
+ GtkListStore *themes;
+ GtkListStore *content_language;
+ GtkListStore *search_providers;
+};
+
+static struct ppref ppref;
+
+
+/* Set netsurf option based on toggle button state
+ *
+ * This works for any widget which subclasses togglebutton (checkbox,
+ * radiobutton etc.)
+ */
+#define TOGGLEBUTTON_SIGNALS(WIDGET, OPTION) \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_toggled(GtkToggleButton *togglebutton, \
+ struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_toggled(GtkToggleButton *togglebutton, \
+ struct ppref *priv) \
+{ \
+ nsoption_set_bool(OPTION, \
+ gtk_toggle_button_get_active(togglebutton)); \
+} \
+ \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, \
+ struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, \
+ struct ppref *priv) \
+{ \
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), \
+ nsoption_bool(OPTION)); \
+}
+
+#define SPINBUTTON_SIGNALS(WIDGET, OPTION, MULTIPLIER) \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
+ struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
+ struct ppref *priv) \
+{ \
+ nsoption_set_int(OPTION, \
+ round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \
+} \
+ \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
+{ \
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \
+ ((gdouble)nsoption_int(OPTION)) / MULTIPLIER); \
+}
+
+#define SPINBUTTON_UINT_SIGNALS(WIDGET, OPTION, MULTIPLIER) \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
+ struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
+ struct ppref *priv) \
+{ \
+ nsoption_set_uint(OPTION, \
+ round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \
+} \
+ \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
+{ \
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \
+ ((gdouble)nsoption_uint(OPTION)) / MULTIPLIER); \
+}
+
+#define ENTRY_SIGNALS(WIDGET, OPTION) \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv)\
+{ \
+ nsoption_set_charp(OPTION, \
+ strdup(gtk_entry_get_text(GTK_ENTRY(editable)))); \
+} \
+ \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
+G_MODULE_EXPORT void \
+nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
+{ \
+ const char *OPTION; \
+ OPTION = nsoption_charp(OPTION); \
+ if (OPTION != NULL) { \
+ gtk_entry_set_text(GTK_ENTRY(widget), OPTION); \
+ } \
+}
+
+/* GTK module requires these to be exported symbols so these all need
+ * forward declaring to avoid warnings
+ */
+G_MODULE_EXPORT void nsgtk_preferences_comboProxyType_changed(GtkComboBox *combo, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboProxyType_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboboxLoadImages_changed(GtkComboBox *combo, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboboxLoadImages_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboDefault_changed(GtkComboBox *combo, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboDefault_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_fontPreview_clicked(GtkButton *button, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboboxLanguage_changed(GtkComboBox *combo, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboboxLanguage_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboTheme_changed(GtkComboBox *combo, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboTheme_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_buttonAddTheme_clicked(GtkButton *button, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_checkShowSingleTab_toggled(GtkToggleButton *togglebutton, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_checkShowSingleTab_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboTabPosition_changed(GtkComboBox *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboTabPosition_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboDeveloperView_changed(GtkComboBox *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboDeveloperView_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboButtonType_changed(GtkComboBox *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboButtonType_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_setCurrentPage_clicked(GtkButton *button, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_setDefaultPage_clicked(GtkButton *button, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboSearch_changed(GtkComboBox *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_comboSearch_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_fileChooserDownloads_selectionchanged(GtkFileChooser *chooser, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_fileChooserDownloads_realize(GtkWidget *widget, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_dialogPreferences_response(GtkDialog *dlg, gint resid);
+G_MODULE_EXPORT gboolean nsgtk_preferences_dialogPreferences_deleteevent(GtkDialog *dlg, struct ppref *priv);
+G_MODULE_EXPORT void nsgtk_preferences_dialogPreferences_destroy(GtkDialog *dlg, struct ppref *priv);
+
+
+/********* PDF **********/
+
+/* Appearance */
+
+/* no images in output */
+TOGGLEBUTTON_SIGNALS(checkSuppressImages, suppress_images)
+
+/* no background images */
+TOGGLEBUTTON_SIGNALS(checkRemoveBackgrounds, remove_backgrounds)
+
+/* scale to fit page */
+TOGGLEBUTTON_SIGNALS(checkFitPage, enable_loosening)
+
+/* port */
+SPINBUTTON_SIGNALS(spinExportScale, export_scale, 1.0)
+
+/* Margins */
+SPINBUTTON_SIGNALS(spinMarginTop, margin_top, 1.0)
+SPINBUTTON_SIGNALS(spinMarginBottom, margin_bottom, 1.0)
+SPINBUTTON_SIGNALS(spinMarginLeft, margin_left, 1.0)
+SPINBUTTON_SIGNALS(spinMarginRight, margin_right, 1.0)
+
+
+/* Generation */
+
+/* output is compressed */
+TOGGLEBUTTON_SIGNALS(checkCompressPDF, enable_PDF_compression)
+
+/* output has a password */
+TOGGLEBUTTON_SIGNALS(checkPasswordPDF, enable_PDF_password)
+
+/********* Network **********/
+
+/* HTTP proxy */
+static void set_proxy_widgets_sensitivity(int proxyval, struct ppref *priv)
+{
+ gboolean host;
+ gboolean port;
+ gboolean user;
+ gboolean pass;
+ gboolean noproxy;
+
+ switch (proxyval) {
+ case 0: /* no proxy */
+ host = FALSE;
+ port = FALSE;
+ user = FALSE;
+ pass = FALSE;
+ noproxy = FALSE;
+ break;
+
+ case 1: /* proxy with no auth */
+ host = TRUE;
+ port = TRUE;
+ user = FALSE;
+ pass = FALSE;
+ noproxy = TRUE;
+ break;
+
+ case 2: /* proxy with basic auth */
+ host = TRUE;
+ port = TRUE;
+ user = TRUE;
+ pass = TRUE;
+ noproxy = TRUE;
+ break;
+
+ case 3: /* proxy with ntlm auth */
+ host = TRUE;
+ port = TRUE;
+ user = TRUE;
+ pass = TRUE;
+ noproxy = TRUE;
+ break;
+
+ case 4: /* system proxy */
+ host = FALSE;
+ port = FALSE;
+ user = FALSE;
+ pass = FALSE;
+ noproxy = FALSE;
+ break;
+
+ default:
+ return;
+ }
+
+ gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyHost), host);
+ gtk_widget_set_sensitive(GTK_WIDGET(priv->spinProxyPort), port);
+ gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyUser), user);
+ gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyPassword), pass);
+ gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyNoproxy), noproxy);
+
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_comboProxyType_changed(GtkComboBox *combo, struct ppref *priv)
+{
+ int proxy_sel;
+ proxy_sel = gtk_combo_box_get_active(combo);
+
+ switch (proxy_sel) {
+ case 0: /* no proxy */
+ nsoption_set_bool(http_proxy, false);
+ break;
+
+ 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: /* proxy with basic auth */
+ nsoption_set_bool(http_proxy, true);
+ nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC);
+ break;
+
+ 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;
+ }
+
+ set_proxy_widgets_sensitivity(proxy_sel, priv);
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_comboProxyType_realize(GtkWidget *widget, struct ppref *priv)
+{
+ int proxytype = 0; /* no proxy by default */
+
+ 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 (nsoption_charp(http_proxy_host) == NULL) {
+ /* set to use a proxy without a host, turn proxy off */
+ proxytype = 0;
+ } else if (((proxytype == 2) ||
+ (proxytype == 3)) &&
+ ((nsoption_charp(http_proxy_auth_user) == NULL) ||
+ (nsoption_charp(http_proxy_auth_pass) == NULL))) {
+ /* authentication selected with empty credentials, turn proxy off */
+ proxytype = 0;
+ }
+ }
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), proxytype);
+
+ set_proxy_widgets_sensitivity(proxytype, priv);
+}
+
+/* host */
+ENTRY_SIGNALS(entryProxyHost, http_proxy_host)
+
+/* port */
+SPINBUTTON_SIGNALS(spinProxyPort, http_proxy_port, 1.0)
+
+/* user */
+ENTRY_SIGNALS(entryProxyUser, http_proxy_auth_user)
+
+/* password */
+ENTRY_SIGNALS(entryProxyPassword, http_proxy_auth_pass)
+
+/* no proxy */
+ENTRY_SIGNALS(entryProxyNoproxy, http_proxy_noproxy)
+
+/* Fetching */
+
+/* maximum fetchers */
+SPINBUTTON_SIGNALS(spinMaxFetchers, max_fetchers, 1.0)
+
+/* fetches per host */
+SPINBUTTON_SIGNALS(spinFetchesPerHost, max_fetchers_per_host, 1.0)
+
+/* cached connections */
+SPINBUTTON_SIGNALS(spinCachedConnections, max_cached_fetch_handles, 1.0)
+
+
+/********* Privacy **********/
+
+/* General */
+
+/* enable referral submission */
+TOGGLEBUTTON_SIGNALS(checkSendReferer, send_referer)
+
+/* send do not track */
+TOGGLEBUTTON_SIGNALS(checkSendDNT, do_not_track)
+
+/* History */
+
+/* local history shows url tooltips */
+TOGGLEBUTTON_SIGNALS(checkHoverURLs, hover_urls)
+
+/* remember browsing history */
+SPINBUTTON_SIGNALS(spinHistoryAge, history_age, 1.0)
+
+/* Cache */
+
+/* memory cache size */
+SPINBUTTON_SIGNALS(spinMemoryCacheSize, memory_cache_size, (1024*1024))
+
+/* disc cache size */
+SPINBUTTON_UINT_SIGNALS(spinDiscCacheSize, disc_cache_size, (1024*1024))
+
+
+/* disc cache age */
+SPINBUTTON_SIGNALS(spinDiscCacheAge, disc_cache_age, 1.0)
+
+
+/********* Content **********/
+
+/* Control */
+
+
+/* prevent popups */
+TOGGLEBUTTON_SIGNALS(checkDisablePopups, disable_popups)
+
+/* hide adverts */
+TOGGLEBUTTON_SIGNALS(checkHideAdverts, block_advertisements)
+
+/* enable javascript */
+TOGGLEBUTTON_SIGNALS(checkEnableJavascript, enable_javascript)
+
+/* disable plugins */
+TOGGLEBUTTON_SIGNALS(checkDisablePlugins, disable_plugins)
+
+/* high quality image scaling */
+TOGGLEBUTTON_SIGNALS(checkResampleImages, render_resample)
+
+/* load and display of images */
+G_MODULE_EXPORT void
+nsgtk_preferences_comboboxLoadImages_changed(GtkComboBox *combo,
+ struct ppref *priv)
+{
+ int img_sel;
+ /* get the row number for the selection */
+ img_sel = gtk_combo_box_get_active(combo);
+ switch (img_sel) {
+ case 0:
+ /* background and foreground */
+ nsoption_set_bool(foreground_images, true);
+ nsoption_set_bool(background_images, true);
+ break;
+
+ case 1:
+ /* foreground only */
+ nsoption_set_bool(foreground_images, true);
+ nsoption_set_bool(background_images, false);
+ break;
+
+ case 2:
+ /* background only */
+ nsoption_set_bool(foreground_images, false);
+ nsoption_set_bool(background_images, true);
+ break;
+
+ case 3:
+ /* no images */
+ nsoption_set_bool(foreground_images, false);
+ nsoption_set_bool(background_images, false);
+ break;
+ }
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_comboboxLoadImages_realize(GtkWidget *widget,
+ struct ppref *priv)
+{
+ if (nsoption_bool(foreground_images)) {
+ if (nsoption_bool(background_images)) {
+ /* background and foreground */
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
+ } else {
+ /* foreground only */
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 1);
+ }
+ } else {
+ if (nsoption_bool(background_images)) {
+ /* background only */
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 2);
+ } else {
+ /* no images */
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 3);
+ }
+ }
+}
+
+/* Animation */
+
+/* enable animation */
+TOGGLEBUTTON_SIGNALS(checkEnableAnimations, animate_images)
+
+/* frame time */
+SPINBUTTON_SIGNALS(spinAnimationSpeed, minimum_gif_delay, 100.0)
+
+/* Fonts */
+
+/* default font */
+G_MODULE_EXPORT void
+nsgtk_preferences_comboDefault_changed(GtkComboBox *combo, struct ppref *priv)
+{
+ int font_sel;
+ /* get the row number for the selection */
+ font_sel = gtk_combo_box_get_active(combo);
+ if ((font_sel >= 0) && (font_sel <= 4)) {
+ nsoption_set_int(font_default, font_sel);
+ }
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_comboDefault_realize(GtkWidget *widget, struct ppref *priv)
+{
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
+ nsoption_int(font_default));
+}
+
+/* default font size */
+SPINBUTTON_SIGNALS(spinDefaultSize, font_size, 10.0)
+
+/* preview - actually reflow all views */
+G_MODULE_EXPORT void
+nsgtk_preferences_fontPreview_clicked(GtkButton *button, struct ppref *priv)
+{
+ nsgtk_reflow_all_windows();
+}
+
+
+/* Language */
+
+/* accept language */
+G_MODULE_EXPORT void
+nsgtk_preferences_comboboxLanguage_changed(GtkComboBox *combo,
+ struct ppref *priv)
+{
+ 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);
+ }
+
+ if (lang != NULL) {
+ nsoption_set_charp(accept_language, strdup(lang));
+ g_free(lang);
+ }
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_comboboxLanguage_realize(GtkWidget *widget,
+ struct ppref *priv)
+{
+ /* Fill content language list store */
+ int active_language = 0;
+ GtkTreeIter iter;
+ FILE *fp;
+ char buf[50];
+ const char *default_accept_language = "en";
+
+ if ((priv->content_language != NULL) &&
+ (languages_file_location != NULL) &&
+ ((fp = fopen(languages_file_location, "r")) != NULL)) {
+ int combo_row_count = 0;
+
+ gtk_list_store_clear(priv->content_language);
+ active_language = -1;
+
+ LOG(("Used %s for languages", languages_file_location));
+ while (fgets(buf, sizeof(buf), fp)) {
+ /* Ignore blank lines */
+ if (buf[0] == '\0')
+ continue;
+
+ /* Remove trailing \n */
+ buf[strlen(buf) - 1] = '\0';
+
+ gtk_list_store_append(priv->content_language, &iter);
+ gtk_list_store_set(priv->content_language,
+ &iter, 0, buf, -1 );
+
+ if (strcmp(buf, default_accept_language) == 0) {
+ active_language = combo_row_count;
+ }
+
+ combo_row_count++;
+ }
+
+ if (active_language == -1) {
+ /* configured language was not in list, add it */
+ gtk_list_store_append(priv->content_language, &iter);
+ gtk_list_store_set(priv->content_language,
+ &iter,
+ 0, default_accept_language, -1 );
+ active_language = combo_row_count;
+ }
+
+ fclose(fp);
+ } else {
+ LOG(("Failed opening languages file"));
+ }
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), active_language);
+}
+
+
+/********* Apperance **********/
+
+/* Themes */
+
+/* select theme */
+G_MODULE_EXPORT void
+nsgtk_preferences_comboTheme_changed(GtkComboBox *combo, struct ppref *priv)
+{
+ struct nsgtk_scaffolding *current;
+ int theme = 0;
+ gchar *name;
+ 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)) {
+ /* get the row number for the config */
+ theme = gtk_combo_box_get_active(combo);
+
+ nsoption_set_int(current_theme, theme);
+
+ /* retrive the theme name if it is not the default */
+ if (theme != 0) {
+ /* Obtain data model from combo box. */
+ model = gtk_combo_box_get_model(combo);
+
+ /* Obtain string from model. */
+ gtk_tree_model_get(model, &iter, 0, &name, -1);
+ } else {
+ name = NULL;
+ }
+
+ nsgtk_theme_set_name(name);
+
+ if (name != NULL) {
+ g_free(name);
+ }
+
+ current = nsgtk_scaffolding_iterate(NULL);
+ while (current != NULL) {
+ nsgtk_theme_implement(current);
+ current = nsgtk_scaffolding_iterate(current);
+ }
+ }
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_comboTheme_realize(GtkWidget *widget, struct ppref *priv)
+{
+ /* Fill theme list store */
+ FILE *fp;
+ GtkTreeIter iter;
+ char buf[50];
+ int combo_row_count = 0;
+ int selected_theme = 0;
+
+ if ((priv->themes != NULL) &&
+ (themelist_file_location != NULL) &&
+ ((fp = fopen(themelist_file_location, "r")) != NULL)) {
+ gtk_list_store_clear(priv->themes);
+
+ LOG(("Used %s for themelist", themelist_file_location));
+
+ while (fgets(buf, sizeof(buf), fp)) {
+ /* Ignore blank lines */
+ if (buf[0] == '\0')
+ continue;
+
+ /* Remove trailing \n */
+ buf[strlen(buf) - 1] = '\0';
+
+ gtk_list_store_append(priv->themes, &iter);
+ gtk_list_store_set(priv->themes, &iter, 0, buf, -1);
+
+ combo_row_count++;
+ }
+
+ fclose(fp);
+ } else {
+ LOG(("Failed opening themes file"));
+ }
+
+ /* get configured theme and sanity check value */
+ selected_theme = nsoption_int(current_theme);
+ if (selected_theme > combo_row_count) {
+ selected_theme = combo_row_count;
+ }
+ if (selected_theme < 0) {
+ selected_theme = 0;
+ }
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), selected_theme);
+}
+
+/* add theme */
+G_MODULE_EXPORT void
+nsgtk_preferences_buttonAddTheme_clicked(GtkButton *button, struct ppref *priv)
+{
+ char *filename, *directory;
+ size_t len;
+ GtkWidget *fc;
+ char *themesfolder;
+ gint res;
+
+ fc = gtk_file_chooser_dialog_new(messages_get("gtkAddThemeTitle"),
+ GTK_WINDOW(priv->dialog),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_OK,
+ GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ NULL);
+ len = SLEN("themes") + strlen(res_dir_location) + 1;
+
+ themesfolder = malloc(len);
+
+ snprintf(themesfolder, len, "%sthemes", res_dir_location);
+
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc), themesfolder);
+
+ res = gtk_dialog_run(GTK_DIALOG(fc));
+ if (res == GTK_RESPONSE_ACCEPT) {
+ filename = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(fc));
+ if (filename != NULL) {
+ if (strcmp(filename, themesfolder) != 0) {
+ directory = strrchr(filename, '/');
+ *directory = '\0';
+ if (strcmp(filename, themesfolder) != 0) {
+ warn_user(messages_get(
+ "gtkThemeFolderInstructions"),
+ 0);
+
+ if (filename != NULL)
+ g_free(filename);
+
+ } else {
+ directory++;
+ nsgtk_theme_add(directory);
+ }
+ } else {
+ g_free(filename);
+
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
+
+ if (strcmp(filename, themesfolder) == 0) {
+ warn_user(messages_get("gtkThemeFolderSub"),
+ 0);
+ } else {
+ directory = strrchr(filename, '/') + 1;
+ nsgtk_theme_add(directory);
+ }
+ }
+
+ g_free(filename);
+ }
+ }
+
+ free(themesfolder);
+
+ gtk_widget_destroy(fc);
+}
+
+/* Tabs */
+
+/* always show tab bar */
+G_MODULE_EXPORT void
+nsgtk_preferences_checkShowSingleTab_toggled(GtkToggleButton *togglebutton,
+ struct ppref *priv)
+{
+ nsoption_set_bool(show_single_tab,
+ gtk_toggle_button_get_active(togglebutton));
+ nsgtk_reflow_all_windows();
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_checkShowSingleTab_realize(GtkWidget *widget,
+ struct ppref *priv)
+{
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
+ nsoption_bool(show_single_tab));
+}
+
+/* switch to newly opened tabs immediately */
+TOGGLEBUTTON_SIGNALS(checkFocusNew, focus_new)
+
+/* newly opened tabs are blank */
+TOGGLEBUTTON_SIGNALS(checkNewBlank, new_blank)
+
+/* tab position */
+G_MODULE_EXPORT void
+nsgtk_preferences_comboTabPosition_changed(GtkComboBox *widget,
+ struct ppref *priv)
+{
+ struct nsgtk_scaffolding *current;
+
+ /* set the option */
+ nsoption_set_int(position_tab, gtk_combo_box_get_active(widget));
+
+ /* update all notebooks in all scaffolds */
+ current = nsgtk_scaffolding_iterate(NULL);
+ while (current) {
+ nsgtk_scaffolding_reset_offset(current);
+
+ nsgtk_reflow_all_windows();
+
+ current = nsgtk_scaffolding_iterate(current);
+ }
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_comboTabPosition_realize(GtkWidget *widget,
+ struct ppref *priv)
+{
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
+ nsoption_int(position_tab));
+}
+
+/* Tools */
+
+/* developer view opening */
+G_MODULE_EXPORT void
+nsgtk_preferences_comboDeveloperView_changed(GtkComboBox *widget,
+ struct ppref *priv)
+{
+ /* set the option */
+ nsoption_set_int(developer_view, gtk_combo_box_get_active(widget));
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_comboDeveloperView_realize(GtkWidget *widget,
+ struct ppref *priv)
+{
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
+ nsoption_int(developer_view));
+}
+
+
+/* URLbar */
+
+/* show recently visited urls as you type */
+TOGGLEBUTTON_SIGNALS(checkDisplayRecentURLs, url_suggestion)
+
+/* Toolbar */
+
+/* button position */
+G_MODULE_EXPORT void
+nsgtk_preferences_comboButtonType_changed(GtkComboBox *widget,
+ struct ppref *priv)
+{
+ struct nsgtk_scaffolding *current;
+
+ nsoption_set_int(button_type, gtk_combo_box_get_active(widget) + 1);
+
+ current = nsgtk_scaffolding_iterate(NULL);
+ while (current != NULL) {
+ nsgtk_scaffolding_reset_offset(current);
+ switch(nsoption_int(button_type)) {
+ /* value of 0 is reserved for 'unset' */
+ case 1:
+ gtk_toolbar_set_style(
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
+ GTK_TOOLBAR_ICONS);
+ gtk_toolbar_set_icon_size(
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ break;
+ case 2:
+ gtk_toolbar_set_style(
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
+ GTK_TOOLBAR_ICONS);
+ gtk_toolbar_set_icon_size(
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
+ break;
+ case 3:
+ gtk_toolbar_set_style(
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
+ GTK_TOOLBAR_BOTH);
+ gtk_toolbar_set_icon_size(
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
+ break;
+ case 4:
+ gtk_toolbar_set_style(
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
+ GTK_TOOLBAR_TEXT);
+ default:
+ break;
+ }
+ current = nsgtk_scaffolding_iterate(current);
+ }
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_comboButtonType_realize(GtkWidget *widget,
+ struct ppref *priv)
+{
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
+ nsoption_int(button_type) - 1);
+}
+
+
+
+/************ Main ************/
+
+/* Startup */
+
+/* entry HomePageURL widget */
+ENTRY_SIGNALS(entryHomePageURL, homepage_url)
+
+/* put current page into homepage url */
+G_MODULE_EXPORT void
+nsgtk_preferences_setCurrentPage_clicked(GtkButton *button, struct ppref *priv)
+{
+ const gchar *url = nsurl_access(browser_window_get_url(priv->bw));
+
+ if (priv->entryHomePageURL != NULL) {
+ gtk_entry_set_text(GTK_ENTRY(priv->entryHomePageURL), url);
+ nsoption_set_charp(homepage_url, strdup(url));
+ }
+}
+
+/* put default page into homepage */
+G_MODULE_EXPORT void
+nsgtk_preferences_setDefaultPage_clicked(GtkButton *button, struct ppref *priv)
+{
+ const gchar *url = NETSURF_HOMEPAGE;
+
+ if (priv->entryHomePageURL != NULL) {
+ gtk_entry_set_text(GTK_ENTRY(priv->entryHomePageURL), url);
+ nsoption_set_charp(homepage_url, strdup(url));
+ }
+}
+
+/* Search */
+
+/* Url Search widget */
+TOGGLEBUTTON_SIGNALS(checkUrlSearch, search_url_bar)
+
+/* provider combo */
+G_MODULE_EXPORT void
+nsgtk_preferences_comboSearch_changed(GtkComboBox *widget, struct ppref *priv)
+{
+ int provider;
+
+ provider = gtk_combo_box_get_active(widget);
+
+ /* set the option */
+ nsoption_set_int(search_provider, provider);
+
+ /* set search provider */
+ search_web_select_provider(provider);
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_comboSearch_realize(GtkWidget *widget, struct ppref *priv)
+{
+ int iter;
+ const char *name;
+ int provider = nsoption_int(search_provider);
+
+ if (priv->search_providers != NULL) {
+ gtk_list_store_clear(priv->search_providers);
+ for (iter = search_web_iterate_providers(0, &name);
+ iter != -1;
+ iter = search_web_iterate_providers(iter, &name)) {
+ gtk_list_store_insert_with_values(priv->search_providers,
+ NULL, -1,
+ 0, name, -1);
+ }
+ }
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), provider);
+}
+
+
+/* Downloads */
+
+/* clear downloads */
+TOGGLEBUTTON_SIGNALS(checkClearDownloads, downloads_clear)
+
+/* request overwite */
+TOGGLEBUTTON_SIGNALS(checkRequestOverwrite, request_overwrite)
+
+/* download location
+ *
+ * note selection-changed is used instead of file-set as the returned
+ * filename when that signal are used is incorrect. Though this signal
+ * does update frequently often with the same data.
+ */
+G_MODULE_EXPORT void
+nsgtk_preferences_fileChooserDownloads_selectionchanged(GtkFileChooser *chooser,
+ struct ppref *priv)
+{
+ gchar *dir;
+ dir = gtk_file_chooser_get_filename(chooser);
+ nsoption_set_charp(downloads_directory, strdup(dir));
+ g_free(dir);
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_fileChooserDownloads_realize(GtkWidget *widget,
+ struct ppref *priv)
+{
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(widget),
+ nsoption_charp(downloads_directory));
+}
+
+
+/************* Dialog window ***********/
+
+/* dialog close and destroy events */
+G_MODULE_EXPORT void
+nsgtk_preferences_dialogPreferences_response(GtkDialog *dlg, gint resid)
+{
+ char *choices = NULL;
+
+ if (resid == GTK_RESPONSE_CLOSE) {
+ netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
+ if (choices != NULL) {
+ nsoption_write(choices, NULL, NULL);
+ free(choices);
+ }
+ gtk_widget_hide(GTK_WIDGET(dlg));
+ }
+}
+
+G_MODULE_EXPORT gboolean
+nsgtk_preferences_dialogPreferences_deleteevent(GtkDialog *dlg,
+ struct ppref *priv)
+{
+ char *choices = NULL;
+
+ netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
+ if (choices != NULL) {
+ nsoption_write(choices, NULL, NULL);
+ free(choices);
+ }
+
+ gtk_widget_hide(GTK_WIDGET(dlg));
+
+ /* Delt with it by hiding window, no need to destory widget by
+ * default.
+ */
+ return TRUE;
+}
+
+G_MODULE_EXPORT void
+nsgtk_preferences_dialogPreferences_destroy(GtkDialog *dlg, struct ppref *priv)
+{
+ char *choices = NULL;
+
+ netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
+ if (choices != NULL) {
+ nsoption_write(choices, NULL, NULL);
+ free(choices);
+ }
+}
+
+
+/* exported interface documented in gtk/preferences.h */
+GtkWidget* nsgtk_preferences(struct browser_window *bw, GtkWindow *parent)
+{
+ GError *error = NULL;
+ GtkBuilder *preferences_builder;
+ struct ppref *priv = &ppref;
+
+ priv->bw = bw; /* for setting "current" page */
+
+ /* memoised dialog creation */
+ if (priv->dialog != NULL) {
+ gtk_window_set_transient_for(GTK_WINDOW(priv->dialog), parent);
+ return GTK_WIDGET(priv->dialog);
+ }
+
+ /* populate builder object */
+ preferences_builder = gtk_builder_new();
+ if (!gtk_builder_add_from_file(preferences_builder,
+ glade_file_location->options,
+ &error)) {
+ g_warning("Couldn't load builder file: %s", error->message);
+ g_error_free(error);
+ return NULL;
+ }
+
+
+ priv->dialog = gtk_builder_get_object(preferences_builder,
+ "dialogPreferences");
+ if (priv->dialog == NULL) {
+ LOG(("Unable to get object for preferences dialog"));
+ /* release builder as were done with it */
+ g_object_unref(G_OBJECT(preferences_builder));
+ return NULL;
+ }
+
+ /* need to explicitly obtain handles for some widgets enabling
+ * updates by other widget events
+ */
+#define GB(TYPE, NAME) GTK_##TYPE(gtk_builder_get_object(preferences_builder, #NAME))
+ priv->entryHomePageURL = GB(ENTRY, entryHomePageURL);
+ priv->themes = GB(LIST_STORE, liststore_themes);
+ priv->content_language = GB(LIST_STORE, liststore_content_language);
+ priv->search_providers = GB(LIST_STORE, liststore_search_provider);
+ priv->entryProxyHost = GB(ENTRY, entryProxyHost);
+ priv->spinProxyPort = GB(SPIN_BUTTON, spinProxyPort);
+ priv->entryProxyUser = GB(ENTRY, entryProxyUser);
+ priv->entryProxyPassword = GB(ENTRY, entryProxyPassword);
+ priv->entryProxyNoproxy = GB(ENTRY, entryProxyNoproxy);
+#undef GB
+
+ /* connect all signals ready to use */
+ gtk_builder_connect_signals(preferences_builder, priv);
+
+ /* release builder as were done with it */
+ g_object_unref(G_OBJECT(preferences_builder));
+
+ /* mark dialog as transient on parent */
+ gtk_window_set_transient_for(GTK_WINDOW(priv->dialog), parent);
+
+ return GTK_WIDGET(priv->dialog);
+}
+
+/* exported interface documented in gtk/preferences.h */
+void nsgtk_preferences_theme_add(const char *themename)
+{
+ struct ppref *priv = &ppref;
+ GtkTreeIter iter;
+
+ gtk_list_store_append(priv->themes, &iter);
+ gtk_list_store_set(priv->themes, &iter, 0, themename, -1 );
+}
diff --git a/gtk/preferences.h b/gtk/preferences.h
new file mode 100644
index 0000000..3ef33ca
--- /dev/null
+++ b/gtk/preferences.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NETSURF_GTK_PREFERENCES_H
+#define NETSURF_GTK_PREFERENCES_H
+
+#include <gtk/gtk.h>
+
+/** Initialise prefernces window
+ */
+GtkWidget* nsgtk_preferences(struct browser_window *bw, GtkWindow *parent);
+
+/** Theme added
+ */
+void nsgtk_preferences_theme_add(const char *themename);
+
+#endif
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 7f40d62..4706c6f 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -51,8 +51,8 @@
#include "gtk/compat.h"
#include "gtk/cookies.h"
#include "gtk/completion.h"
-#include "gtk/dialogs/preferences.h"
-#include "gtk/dialogs/about.h"
+#include "gtk/preferences.h"
+#include "gtk/about.h"
#include "gtk/viewsource.h"
#include "gtk/bitmap.h"
#include "gtk/gui.h"
diff --git a/gtk/theme.c b/gtk/theme.c
index dd034ac..8612c39 100644
--- a/gtk/theme.c
+++ b/gtk/theme.c
@@ -39,7 +39,7 @@
#include "gtk/menu.h"
#include "gtk/theme.h"
#include "gtk/window.h"
-#include "gtk/dialogs/preferences.h"
+#include "gtk/preferences.h"
enum image_sets {
IMAGE_SET_MAIN_MENU = 0,
diff --git a/gtk/viewdata.c b/gtk/viewdata.c
index 47af0fa..1d419a3 100644
--- a/gtk/viewdata.c
+++ b/gtk/viewdata.c
@@ -43,7 +43,7 @@
#include "content/hlcache.h"
#include "content/content.h"
-#include "gtk/dialogs/about.h"
+#include "gtk/about.h"
#include "gtk/fetch.h"
#include "gtk/compat.h"
#include "gtk/gui.h"
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9487076f2ad1298b112...
commit 9487076f2ad1298b1122155170949cb59156d9b9
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
remove old notes that are no longer relevant
diff --git a/gtk/notes b/gtk/notes
deleted file mode 100644
index 0944db9..0000000
--- a/gtk/notes
+++ /dev/null
@@ -1,36 +0,0 @@
-Currently a gui_window is a top level browser object.
-
-This has to be corrected. Instead a gui_window must simply be a render
-target inside a non-user-sizable container which is capable of
-scrolling around. I.E. a GtkViewport.
-
-Thusly all routines which are callbacks for the viewport can remain
-attached to a gui_window, all others must be migrated to a
-gtk_scaffold concept which embodies the toolbar, statusbar,
-blahblahblah.
-
-If a gui_window wants to be able to scroll itself, it automatically
-embeds itself in a GtkScrolledWindow which will provide scrollbars for
-it. Otherwise it makes a call to its scaffold to ask it to attach its
-scrollbars to the viewport.
-
-The gui_window objects therefore are a GtkDrawingArea inside a
-GtkFixed inside a GtkViewport (optionally inside a GtkScrolledWindow)
-The GtkFixed's job (among other things) is to sit on its size_allocate
-event and ensure that the GtkDrawingArea fills 100% of itself. (and is
-on the bottom of the widget stack -- this happens automatically if the
-drawing area is the first widget to be added to the GtkFixed and it is
-never removed.)
-
-The gtk_scaffold object must expose a call to show/hide (link/delink?)
-its scrollbars so that if the contained gui_window becomes a frameset
-then it can hide the scrollbars belonging to the top level window.
-
-It must be possible to add gui_window objects to other gui_window
-objects rather than to a gtk_scaffold so that frames can be embedded
-appropriately.
-
-The size-allocate event for the drawing area must pass through to the
-underlying browser_window as currently it does.
-
-
-----------------------------------------------------------------------
Summary of changes:
gtk/Makefile.target | 2 +-
gtk/{dialogs => }/about.c | 4 ++--
gtk/{dialogs => }/about.h | 0
gtk/notes | 36 ------------------------------------
gtk/{dialogs => }/preferences.c | 6 +++---
gtk/{dialogs => }/preferences.h | 0
gtk/scaffolding.c | 4 ++--
gtk/theme.c | 2 +-
gtk/viewdata.c | 2 +-
9 files changed, 10 insertions(+), 46 deletions(-)
rename gtk/{dialogs => }/about.c (98%)
rename gtk/{dialogs => }/about.h (100%)
delete mode 100644 gtk/notes
rename gtk/{dialogs => }/preferences.c (99%)
rename gtk/{dialogs => }/preferences.h (100%)
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index 05865ff..8fed107 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -109,7 +109,7 @@ S_GTK := font_pango.c bitmap.c gui.c schedule.c thumbnail.c plotters.c \
selection.c history.c window.c fetch.c download.c menu.c \
print.c search.c tabs.c theme.c toolbar.c gettext.c \
compat.c cookies.c hotlist.c viewdata.c viewsource.c \
- $(addprefix dialogs/,preferences.c about.c)
+ preferences.c about.c
S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c)
# code in utils/container.ch is non-universal it seems
diff --git a/gtk/dialogs/about.c b/gtk/about.c
similarity index 98%
rename from gtk/dialogs/about.c
rename to gtk/about.c
index 99df137..84fb067 100644
--- a/gtk/dialogs/about.c
+++ b/gtk/about.c
@@ -17,7 +17,7 @@
*/
/**
- * \file gtk/dialogs/about.c
+ * \file gtk/about.c
*
* Implementation of gtk about dialog.
*/
@@ -32,7 +32,7 @@
#include "gtk/compat.h"
#include "gtk/gui.h"
-#include "gtk/dialogs/about.h"
+#include "gtk/about.h"
/**
* About dialog information button click.
diff --git a/gtk/dialogs/about.h b/gtk/about.h
similarity index 100%
rename from gtk/dialogs/about.h
rename to gtk/about.h
diff --git a/gtk/notes b/gtk/notes
deleted file mode 100644
index 0944db9..0000000
--- a/gtk/notes
+++ /dev/null
@@ -1,36 +0,0 @@
-Currently a gui_window is a top level browser object.
-
-This has to be corrected. Instead a gui_window must simply be a render
-target inside a non-user-sizable container which is capable of
-scrolling around. I.E. a GtkViewport.
-
-Thusly all routines which are callbacks for the viewport can remain
-attached to a gui_window, all others must be migrated to a
-gtk_scaffold concept which embodies the toolbar, statusbar,
-blahblahblah.
-
-If a gui_window wants to be able to scroll itself, it automatically
-embeds itself in a GtkScrolledWindow which will provide scrollbars for
-it. Otherwise it makes a call to its scaffold to ask it to attach its
-scrollbars to the viewport.
-
-The gui_window objects therefore are a GtkDrawingArea inside a
-GtkFixed inside a GtkViewport (optionally inside a GtkScrolledWindow)
-The GtkFixed's job (among other things) is to sit on its size_allocate
-event and ensure that the GtkDrawingArea fills 100% of itself. (and is
-on the bottom of the widget stack -- this happens automatically if the
-drawing area is the first widget to be added to the GtkFixed and it is
-never removed.)
-
-The gtk_scaffold object must expose a call to show/hide (link/delink?)
-its scrollbars so that if the contained gui_window becomes a frameset
-then it can hide the scrollbars belonging to the top level window.
-
-It must be possible to add gui_window objects to other gui_window
-objects rather than to a gtk_scaffold so that frames can be embedded
-appropriately.
-
-The size-allocate event for the drawing area must pass through to the
-underlying browser_window as currently it does.
-
-
diff --git a/gtk/dialogs/preferences.c b/gtk/preferences.c
similarity index 99%
rename from gtk/dialogs/preferences.c
rename to gtk/preferences.c
index f38c7e9..0255b4b 100644
--- a/gtk/dialogs/preferences.c
+++ b/gtk/preferences.c
@@ -33,7 +33,7 @@
#include "gtk/gui.h"
#include "gtk/scaffolding.h"
#include "gtk/theme.h"
-#include "gtk/dialogs/preferences.h"
+#include "gtk/preferences.h"
/* private prefs */
struct ppref {
@@ -1065,7 +1065,7 @@ nsgtk_preferences_dialogPreferences_destroy(GtkDialog *dlg, struct ppref *priv)
}
-/* exported interface documented in gtk/dialogs/preferences.h */
+/* exported interface documented in gtk/preferences.h */
GtkWidget* nsgtk_preferences(struct browser_window *bw, GtkWindow *parent)
{
GError *error = NULL;
@@ -1127,7 +1127,7 @@ GtkWidget* nsgtk_preferences(struct browser_window *bw, GtkWindow *parent)
return GTK_WIDGET(priv->dialog);
}
-/* exported interface documented in gtk/dialogs/preferences.h */
+/* exported interface documented in gtk/preferences.h */
void nsgtk_preferences_theme_add(const char *themename)
{
struct ppref *priv = &ppref;
diff --git a/gtk/dialogs/preferences.h b/gtk/preferences.h
similarity index 100%
rename from gtk/dialogs/preferences.h
rename to gtk/preferences.h
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 7f40d62..4706c6f 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -51,8 +51,8 @@
#include "gtk/compat.h"
#include "gtk/cookies.h"
#include "gtk/completion.h"
-#include "gtk/dialogs/preferences.h"
-#include "gtk/dialogs/about.h"
+#include "gtk/preferences.h"
+#include "gtk/about.h"
#include "gtk/viewsource.h"
#include "gtk/bitmap.h"
#include "gtk/gui.h"
diff --git a/gtk/theme.c b/gtk/theme.c
index dd034ac..8612c39 100644
--- a/gtk/theme.c
+++ b/gtk/theme.c
@@ -39,7 +39,7 @@
#include "gtk/menu.h"
#include "gtk/theme.h"
#include "gtk/window.h"
-#include "gtk/dialogs/preferences.h"
+#include "gtk/preferences.h"
enum image_sets {
IMAGE_SET_MAIN_MENU = 0,
diff --git a/gtk/viewdata.c b/gtk/viewdata.c
index 47af0fa..1d419a3 100644
--- a/gtk/viewdata.c
+++ b/gtk/viewdata.c
@@ -43,7 +43,7 @@
#include "content/hlcache.h"
#include "content/content.h"
-#include "gtk/dialogs/about.h"
+#include "gtk/about.h"
#include "gtk/fetch.h"
#include "gtk/compat.h"
#include "gtk/gui.h"
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.2-71-gdfb774c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/dfb774c2458f749ebafba...
...commit http://git.netsurf-browser.org/netsurf.git/commit/dfb774c2458f749ebafba77...
...tree http://git.netsurf-browser.org/netsurf.git/tree/dfb774c2458f749ebafba77ef...
The branch, master has been updated
via dfb774c2458f749ebafba77ef30f2d16e80032e7 (commit)
from 79c6617cfb1b54b72f5c37631b4bb3a9c9afb16e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=dfb774c2458f749ebaf...
commit dfb774c2458f749ebafba77ef30f2d16e80032e7
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
change frmebuffer to run its own main loop
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 4069df2..f580347 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -62,6 +62,8 @@
fbtk_widget_t *fbtk;
+static bool fb_complete = false;
+
struct gui_window *input_window = NULL;
struct gui_window *search_current_window;
struct gui_window *window_list = NULL;
@@ -555,28 +557,31 @@ static bool nslog_stream_configure(FILE *fptr)
return true;
}
-
-
-static void framebuffer_poll(bool active)
+static void framebuffer_run(void)
{
nsfb_event_t event;
int timeout; /* timeout in miliseconds */
- /* run the scheduler and discover how long to wait for the next event */
- timeout = schedule_run();
-
- /* if redraws are pending do not wait for event, return immediately */
- if (fbtk_get_redraw_pending(fbtk))
- timeout = 0;
+ while (fb_complete != true) {
+ /* run the scheduler and discover how long to wait for
+ * the next event.
+ */
+ timeout = schedule_run();
+
+ /* if redraws are pending do not wait for event,
+ * return immediately
+ */
+ if (fbtk_get_redraw_pending(fbtk))
+ timeout = 0;
+
+ if (fbtk_event(fbtk, &event, timeout)) {
+ if ((event.type == NSFB_EVENT_CONTROL) &&
+ (event.value.controlcode == NSFB_CONTROL_QUIT))
+ fb_complete = true;
+ }
- if (fbtk_event(fbtk, &event, timeout)) {
- if ((event.type == NSFB_EVENT_CONTROL) &&
- (event.value.controlcode == NSFB_CONTROL_QUIT))
- netsurf_quit = true;
+ fbtk_redraw(fbtk);
}
-
- fbtk_redraw(fbtk);
-
}
static void gui_quit(void)
@@ -1052,7 +1057,8 @@ fb_close_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- netsurf_quit = true;
+ fb_complete = true;
+
return 0;
}
@@ -2035,7 +2041,6 @@ static struct gui_window_table framebuffer_window_table = {
static struct gui_browser_table framebuffer_browser_table = {
- .poll = framebuffer_poll,
.schedule = framebuffer_schedule,
.quit = gui_quit,
@@ -2131,7 +2136,7 @@ main(int argc, char** argv)
if (ret != NSERROR_OK) {
warn_user(messages_get_errorcode(ret), 0);
} else {
- netsurf_main_loop();
+ framebuffer_run();
browser_window_destroy(bw);
}
-----------------------------------------------------------------------
Summary of changes:
framebuffer/gui.c | 43 ++++++++++++++++++++++++-------------------
1 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 4069df2..f580347 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -62,6 +62,8 @@
fbtk_widget_t *fbtk;
+static bool fb_complete = false;
+
struct gui_window *input_window = NULL;
struct gui_window *search_current_window;
struct gui_window *window_list = NULL;
@@ -555,28 +557,31 @@ static bool nslog_stream_configure(FILE *fptr)
return true;
}
-
-
-static void framebuffer_poll(bool active)
+static void framebuffer_run(void)
{
nsfb_event_t event;
int timeout; /* timeout in miliseconds */
- /* run the scheduler and discover how long to wait for the next event */
- timeout = schedule_run();
-
- /* if redraws are pending do not wait for event, return immediately */
- if (fbtk_get_redraw_pending(fbtk))
- timeout = 0;
+ while (fb_complete != true) {
+ /* run the scheduler and discover how long to wait for
+ * the next event.
+ */
+ timeout = schedule_run();
+
+ /* if redraws are pending do not wait for event,
+ * return immediately
+ */
+ if (fbtk_get_redraw_pending(fbtk))
+ timeout = 0;
+
+ if (fbtk_event(fbtk, &event, timeout)) {
+ if ((event.type == NSFB_EVENT_CONTROL) &&
+ (event.value.controlcode == NSFB_CONTROL_QUIT))
+ fb_complete = true;
+ }
- if (fbtk_event(fbtk, &event, timeout)) {
- if ((event.type == NSFB_EVENT_CONTROL) &&
- (event.value.controlcode == NSFB_CONTROL_QUIT))
- netsurf_quit = true;
+ fbtk_redraw(fbtk);
}
-
- fbtk_redraw(fbtk);
-
}
static void gui_quit(void)
@@ -1052,7 +1057,8 @@ fb_close_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- netsurf_quit = true;
+ fb_complete = true;
+
return 0;
}
@@ -2035,7 +2041,6 @@ static struct gui_window_table framebuffer_window_table = {
static struct gui_browser_table framebuffer_browser_table = {
- .poll = framebuffer_poll,
.schedule = framebuffer_schedule,
.quit = gui_quit,
@@ -2131,7 +2136,7 @@ main(int argc, char** argv)
if (ret != NSERROR_OK) {
warn_user(messages_get_errorcode(ret), 0);
} else {
- netsurf_main_loop();
+ framebuffer_run();
browser_window_destroy(bw);
}
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.2-70-g79c6617
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/79c6617cfb1b54b72f5c3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/79c6617cfb1b54b72f5c376...
...tree http://git.netsurf-browser.org/netsurf.git/tree/79c6617cfb1b54b72f5c37631...
The branch, master has been updated
via 79c6617cfb1b54b72f5c37631b4bb3a9c9afb16e (commit)
via a8101a99ea48c1af23941a0322246cace3dfa69e (commit)
via 0de8cfc9d40214370ed499e465ebc56e88c4d24f (commit)
via 841bc170909704344373da73964ff492d078f08f (commit)
via 3d72c4a77281a304824f80ecbb3c47417a46d433 (commit)
from e994704d5cdbb6b9a710d20d5fbbedde9a305a77 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=79c6617cfb1b54b72f5...
commit 79c6617cfb1b54b72f5c37631b4bb3a9c9afb16e
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
move gtk to using its own main loop instead of core polling
diff --git a/gtk/gui.c b/gtk/gui.c
index 9fa152a..eefb03a 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -79,6 +79,7 @@
#include "gtk/selection.h"
#include "gtk/search.h"
+bool nsgtk_complete = false;
char *toolbar_indices_file_location;
char *res_dir_location;
@@ -484,49 +485,60 @@ static bool nslog_stream_configure(FILE *fptr)
}
-
-static void nsgtk_poll(bool active)
+/**
+ * Run the gtk event loop.
+ *
+ * The same as the standard gtk_main loop except this ensures active
+ * FD are added to the gtk poll event set.
+ */
+static void nsgtk_main(void)
{
fd_set read_fd_set, write_fd_set, exc_fd_set;
int max_fd;
GPollFD *fd_list[1000];
- unsigned int fd_count = 0;
- bool block = true;
-
- fetcher_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
- for (int i = 0; i <= max_fd; i++) {
- if (FD_ISSET(i, &read_fd_set)) {
- GPollFD *fd = malloc(sizeof *fd);
- fd->fd = i;
- fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
- g_main_context_add_poll(0, fd, 0);
- fd_list[fd_count++] = fd;
- }
- if (FD_ISSET(i, &write_fd_set)) {
- GPollFD *fd = malloc(sizeof *fd);
- fd->fd = i;
- fd->events = G_IO_OUT | G_IO_ERR;
- g_main_context_add_poll(0, fd, 0);
- fd_list[fd_count++] = fd;
- }
- if (FD_ISSET(i, &exc_fd_set)) {
- GPollFD *fd = malloc(sizeof *fd);
- fd->fd = i;
- fd->events = G_IO_ERR;
- g_main_context_add_poll(0, fd, 0);
- fd_list[fd_count++] = fd;
+ unsigned int fd_count;
+
+ while (!nsgtk_complete) {
+ max_fd = -1;
+ fd_count = 0;
+ FD_ZERO(&read_fd_set);
+ FD_ZERO(&write_fd_set);
+ FD_ZERO(&exc_fd_set);
+
+ fetcher_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
+ for (int i = 0; i <= max_fd; i++) {
+ if (FD_ISSET(i, &read_fd_set)) {
+ GPollFD *fd = malloc(sizeof *fd);
+ fd->fd = i;
+ fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
+ g_main_context_add_poll(0, fd, 0);
+ fd_list[fd_count++] = fd;
+ }
+ if (FD_ISSET(i, &write_fd_set)) {
+ GPollFD *fd = malloc(sizeof *fd);
+ fd->fd = i;
+ fd->events = G_IO_OUT | G_IO_ERR;
+ g_main_context_add_poll(0, fd, 0);
+ fd_list[fd_count++] = fd;
+ }
+ if (FD_ISSET(i, &exc_fd_set)) {
+ GPollFD *fd = malloc(sizeof *fd);
+ fd->fd = i;
+ fd->events = G_IO_ERR;
+ g_main_context_add_poll(0, fd, 0);
+ fd_list[fd_count++] = fd;
+ }
}
- }
- schedule_run();
+ schedule_run();
- gtk_main_iteration_do(block);
+ gtk_main_iteration();
- for (unsigned int i = 0; i != fd_count; i++) {
- g_main_context_remove_poll(0, fd_list[i]);
- free(fd_list[i]);
+ for (unsigned int i = 0; i != fd_count; i++) {
+ g_main_context_remove_poll(0, fd_list[i]);
+ free(fd_list[i]);
+ }
}
-
}
@@ -1229,7 +1241,6 @@ static nserror nsgtk_option_init(int *pargc, char** argv)
}
static struct gui_browser_table nsgtk_browser_table = {
- .poll = nsgtk_poll,
.schedule = nsgtk_schedule,
.quit = gui_quit,
@@ -1260,7 +1271,7 @@ int main(int argc, char** argv)
ret = netsurf_register(&nsgtk_table);
if (ret != NSERROR_OK) {
- die("NetSurf operation table failed registration");
+ die("NetSurf operation table failed registration\n");
}
/* build the common resource path list */
@@ -1322,7 +1333,7 @@ int main(int argc, char** argv)
fprintf(stderr, "NetSurf gtk specific initialise failed (%s)\n",
messages_get_errorcode(ret));
} else {
- netsurf_main_loop();
+ nsgtk_main();
}
/* common finalisation */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a8101a99ea48c1af239...
commit a8101a99ea48c1af23941a0322246cace3dfa69e
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
use gtk completion variable and remove uneeded include of netsurf.h
diff --git a/gtk/dialogs/about.c b/gtk/dialogs/about.c
index a86bfe7..99df137 100644
--- a/gtk/dialogs/about.c
+++ b/gtk/dialogs/about.c
@@ -28,6 +28,7 @@
#include "utils/messages.h"
#include "utils/nsoption.h"
#include "desktop/browser.h"
+#include "desktop/netsurf.h"
#include "gtk/compat.h"
#include "gtk/gui.h"
@@ -65,13 +66,13 @@ nsgtk_about_dialog_info(GtkWidget *button, gpointer data)
gtk_widget_destroy(gtk_widget_get_toplevel(button));
}
-void nsgtk_about_dialog_init(GtkWindow *parent, const char *version)
+void nsgtk_about_dialog_init(GtkWindow *parent)
{
GtkWidget *dialog, *vbox, *button, *image, *label;
gchar *name_string;
GList *pixbufs = gtk_window_get_default_icon_list();
- name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">NetSurf %s</span>", version);
+ name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">NetSurf %s</span>", netsurf_version);
/* Create the widgets */
diff --git a/gtk/dialogs/about.h b/gtk/dialogs/about.h
index 1ca0d86..bf3c9f5 100644
--- a/gtk/dialogs/about.h
+++ b/gtk/dialogs/about.h
@@ -19,6 +19,6 @@
#ifndef NETSURF_GTK_ABOUT_H
#define NETSURF_GTK_ABOUT_H
-void nsgtk_about_dialog_init(GtkWindow *parent, const char *version);
+void nsgtk_about_dialog_init(GtkWindow *parent);
#endif
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 93cd7f7..7f40d62 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -34,7 +34,6 @@
#include "desktop/browser_history.h"
#include "desktop/browser.h"
#include "desktop/hotlist.h"
-#include "desktop/netsurf.h"
#include "desktop/plotters.h"
#include "desktop/print.h"
#include "desktop/save_complete.h"
@@ -246,8 +245,8 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data)
LOG(("scaffold list head: %p", scaf_list));
if (scaf_list == NULL) {
- /* no more open windows */
- netsurf_quit = true;
+ /* no more open windows - stop the browser */
+ nsgtk_complete = true;
}
}
@@ -1609,7 +1608,7 @@ MULTIHANDLER(info)
MULTIHANDLER(about)
{
- nsgtk_about_dialog_init(g->window, netsurf_version);
+ nsgtk_about_dialog_init(g->window);
return TRUE;
}
diff --git a/gtk/viewdata.c b/gtk/viewdata.c
index 1b5bfb1..47af0fa 100644
--- a/gtk/viewdata.c
+++ b/gtk/viewdata.c
@@ -38,7 +38,6 @@
#include "utils/file.h"
#include "utils/filepath.h"
-#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "render/html.h"
#include "content/hlcache.h"
@@ -337,7 +336,7 @@ gboolean nsgtk_on_viewdata_about_activate(GtkMenuItem *widget, gpointer g)
{
struct nsgtk_viewdata_ctx *nsg = (struct nsgtk_viewdata_ctx *) g;
- nsgtk_about_dialog_init(nsg->window, netsurf_version);
+ nsgtk_about_dialog_init(nsg->window);
return TRUE;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=0de8cfc9d40214370ed...
commit 0de8cfc9d40214370ed499e465ebc56e88c4d24f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add flag to allow gtk loop to be signalled to exit
diff --git a/gtk/gui.h b/gtk/gui.h
index 32f864f..26f51ee 100644
--- a/gtk/gui.h
+++ b/gtk/gui.h
@@ -1,12 +1,5 @@
/*
- * Copyright 2004-2010 James Bursa <bursa(a)users.sourceforge.net>
- * Copyright 2010 Vincent Sanders <vince(a)debian.org>
- * Copyright 2004-2009 John-Mark Bell <jmb(a)netsurf-browser.org>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- * Copyright 2006-2009 Daniel Silverstone <dsilvers(a)netsurf-browser.org>
- * Copyright 2006-2008 Rob Kendrick <rjek(a)netsurf-browser.org>
- * Copyright 2008 John Tytgat <joty(a)netsurf-browser.org>
- * Copyright 2008 Adam Blokus <adamblokus(a)gmail.com>
+ * Copyright 2014 Vincent Sanders <vince(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -32,6 +25,7 @@
#include "utils/nsurl.h"
+/** glade file paths. */
struct glade_file_location_s {
char *netsurf;
char *tabcontents;
@@ -51,22 +45,34 @@ struct glade_file_location_s {
/** location of all glade files. */
extern struct glade_file_location_s *glade_file_location;
+/** language list file path. */
extern char *languages_file_location;
+
+/** toolbar arrangement file path. */
extern char *toolbar_indices_file_location;
+
+/** Resource directory path. */
extern char *res_dir_location;
+
+/** Theme location. */
extern char *themelist_file_location;
/** Directory where all configuration files are held. */
extern char *nsgtk_config_home;
-extern GdkPixbuf *favicon_pixbuf; /* favicon default pixbuf */
+/** favicon default pixbuf */
+extern GdkPixbuf *favicon_pixbuf;
-extern char **respaths; /** resource search path vector */
+/** resource search path vector */
+extern char **respaths;
-uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *);
+/** input conversion. */
+uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *eventkey);
-extern void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw);
+/** login window request. */
+extern void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw);
-#endif /* GTK_GUI_H */
+/** set when no windows remain open. */
+extern bool nsgtk_complete;
+#endif /* GTK_GUI_H */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=841bc17090970434437...
commit 841bc170909704344373da73964ff492d078f08f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
move gtk execution loop to main()
diff --git a/gtk/gui.c b/gtk/gui.c
index 6fb2a41..9fa152a 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -322,7 +322,7 @@ static nserror set_defaults(struct nsoption_s *defaults)
/**
* Initialize GTK interface.
*/
-static void gui_init(int argc, char** argv, char **respath)
+static nserror nsgtk_init(int argc, char** argv, char **respath)
{
char buf[PATH_MAX];
char *resource_filename;
@@ -467,11 +467,7 @@ static void gui_init(int argc, char** argv, char **respath)
free(addr);
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- } else {
- netsurf_main_loop();
- }
+ return error;
}
@@ -1321,7 +1317,13 @@ int main(int argc, char** argv)
}
/* run the browser */
- gui_init(argc, argv, respaths);
+ ret = nsgtk_init(argc, argv, respaths);
+ if (ret != NSERROR_OK) {
+ fprintf(stderr, "NetSurf gtk specific initialise failed (%s)\n",
+ messages_get_errorcode(ret));
+ } else {
+ netsurf_main_loop();
+ }
/* common finalisation */
netsurf_exit();
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3d72c4a77281a304824...
commit 3d72c4a77281a304824f80ecbb3c47417a46d433
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
stop poll callback entry being mandantory in preparation for its removal
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index 977805e..9ce8682 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -569,10 +569,6 @@ static nserror verify_browser_register(struct gui_browser_table *gbt)
}
/* check the mandantory fields are set */
- if (gbt->poll == NULL) {
- return NSERROR_BAD_PARAMETER;
- }
-
if (gbt->schedule == NULL) {
return NSERROR_BAD_PARAMETER;
}
-----------------------------------------------------------------------
Summary of changes:
desktop/gui_factory.c | 4 --
gtk/dialogs/about.c | 5 +-
gtk/dialogs/about.h | 2 +-
gtk/gui.c | 99 +++++++++++++++++++++++++++---------------------
gtk/gui.h | 34 ++++++++++-------
gtk/scaffolding.c | 7 +--
gtk/viewdata.c | 3 +-
7 files changed, 84 insertions(+), 70 deletions(-)
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index 977805e..9ce8682 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -569,10 +569,6 @@ static nserror verify_browser_register(struct gui_browser_table *gbt)
}
/* check the mandantory fields are set */
- if (gbt->poll == NULL) {
- return NSERROR_BAD_PARAMETER;
- }
-
if (gbt->schedule == NULL) {
return NSERROR_BAD_PARAMETER;
}
diff --git a/gtk/dialogs/about.c b/gtk/dialogs/about.c
index a86bfe7..99df137 100644
--- a/gtk/dialogs/about.c
+++ b/gtk/dialogs/about.c
@@ -28,6 +28,7 @@
#include "utils/messages.h"
#include "utils/nsoption.h"
#include "desktop/browser.h"
+#include "desktop/netsurf.h"
#include "gtk/compat.h"
#include "gtk/gui.h"
@@ -65,13 +66,13 @@ nsgtk_about_dialog_info(GtkWidget *button, gpointer data)
gtk_widget_destroy(gtk_widget_get_toplevel(button));
}
-void nsgtk_about_dialog_init(GtkWindow *parent, const char *version)
+void nsgtk_about_dialog_init(GtkWindow *parent)
{
GtkWidget *dialog, *vbox, *button, *image, *label;
gchar *name_string;
GList *pixbufs = gtk_window_get_default_icon_list();
- name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">NetSurf %s</span>", version);
+ name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">NetSurf %s</span>", netsurf_version);
/* Create the widgets */
diff --git a/gtk/dialogs/about.h b/gtk/dialogs/about.h
index 1ca0d86..bf3c9f5 100644
--- a/gtk/dialogs/about.h
+++ b/gtk/dialogs/about.h
@@ -19,6 +19,6 @@
#ifndef NETSURF_GTK_ABOUT_H
#define NETSURF_GTK_ABOUT_H
-void nsgtk_about_dialog_init(GtkWindow *parent, const char *version);
+void nsgtk_about_dialog_init(GtkWindow *parent);
#endif
diff --git a/gtk/gui.c b/gtk/gui.c
index 6fb2a41..eefb03a 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -79,6 +79,7 @@
#include "gtk/selection.h"
#include "gtk/search.h"
+bool nsgtk_complete = false;
char *toolbar_indices_file_location;
char *res_dir_location;
@@ -322,7 +323,7 @@ static nserror set_defaults(struct nsoption_s *defaults)
/**
* Initialize GTK interface.
*/
-static void gui_init(int argc, char** argv, char **respath)
+static nserror nsgtk_init(int argc, char** argv, char **respath)
{
char buf[PATH_MAX];
char *resource_filename;
@@ -467,11 +468,7 @@ static void gui_init(int argc, char** argv, char **respath)
free(addr);
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- } else {
- netsurf_main_loop();
- }
+ return error;
}
@@ -488,49 +485,60 @@ static bool nslog_stream_configure(FILE *fptr)
}
-
-static void nsgtk_poll(bool active)
+/**
+ * Run the gtk event loop.
+ *
+ * The same as the standard gtk_main loop except this ensures active
+ * FD are added to the gtk poll event set.
+ */
+static void nsgtk_main(void)
{
fd_set read_fd_set, write_fd_set, exc_fd_set;
int max_fd;
GPollFD *fd_list[1000];
- unsigned int fd_count = 0;
- bool block = true;
-
- fetcher_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
- for (int i = 0; i <= max_fd; i++) {
- if (FD_ISSET(i, &read_fd_set)) {
- GPollFD *fd = malloc(sizeof *fd);
- fd->fd = i;
- fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
- g_main_context_add_poll(0, fd, 0);
- fd_list[fd_count++] = fd;
- }
- if (FD_ISSET(i, &write_fd_set)) {
- GPollFD *fd = malloc(sizeof *fd);
- fd->fd = i;
- fd->events = G_IO_OUT | G_IO_ERR;
- g_main_context_add_poll(0, fd, 0);
- fd_list[fd_count++] = fd;
- }
- if (FD_ISSET(i, &exc_fd_set)) {
- GPollFD *fd = malloc(sizeof *fd);
- fd->fd = i;
- fd->events = G_IO_ERR;
- g_main_context_add_poll(0, fd, 0);
- fd_list[fd_count++] = fd;
+ unsigned int fd_count;
+
+ while (!nsgtk_complete) {
+ max_fd = -1;
+ fd_count = 0;
+ FD_ZERO(&read_fd_set);
+ FD_ZERO(&write_fd_set);
+ FD_ZERO(&exc_fd_set);
+
+ fetcher_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
+ for (int i = 0; i <= max_fd; i++) {
+ if (FD_ISSET(i, &read_fd_set)) {
+ GPollFD *fd = malloc(sizeof *fd);
+ fd->fd = i;
+ fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
+ g_main_context_add_poll(0, fd, 0);
+ fd_list[fd_count++] = fd;
+ }
+ if (FD_ISSET(i, &write_fd_set)) {
+ GPollFD *fd = malloc(sizeof *fd);
+ fd->fd = i;
+ fd->events = G_IO_OUT | G_IO_ERR;
+ g_main_context_add_poll(0, fd, 0);
+ fd_list[fd_count++] = fd;
+ }
+ if (FD_ISSET(i, &exc_fd_set)) {
+ GPollFD *fd = malloc(sizeof *fd);
+ fd->fd = i;
+ fd->events = G_IO_ERR;
+ g_main_context_add_poll(0, fd, 0);
+ fd_list[fd_count++] = fd;
+ }
}
- }
- schedule_run();
+ schedule_run();
- gtk_main_iteration_do(block);
+ gtk_main_iteration();
- for (unsigned int i = 0; i != fd_count; i++) {
- g_main_context_remove_poll(0, fd_list[i]);
- free(fd_list[i]);
+ for (unsigned int i = 0; i != fd_count; i++) {
+ g_main_context_remove_poll(0, fd_list[i]);
+ free(fd_list[i]);
+ }
}
-
}
@@ -1233,7 +1241,6 @@ static nserror nsgtk_option_init(int *pargc, char** argv)
}
static struct gui_browser_table nsgtk_browser_table = {
- .poll = nsgtk_poll,
.schedule = nsgtk_schedule,
.quit = gui_quit,
@@ -1264,7 +1271,7 @@ int main(int argc, char** argv)
ret = netsurf_register(&nsgtk_table);
if (ret != NSERROR_OK) {
- die("NetSurf operation table failed registration");
+ die("NetSurf operation table failed registration\n");
}
/* build the common resource path list */
@@ -1321,7 +1328,13 @@ int main(int argc, char** argv)
}
/* run the browser */
- gui_init(argc, argv, respaths);
+ ret = nsgtk_init(argc, argv, respaths);
+ if (ret != NSERROR_OK) {
+ fprintf(stderr, "NetSurf gtk specific initialise failed (%s)\n",
+ messages_get_errorcode(ret));
+ } else {
+ nsgtk_main();
+ }
/* common finalisation */
netsurf_exit();
diff --git a/gtk/gui.h b/gtk/gui.h
index 32f864f..26f51ee 100644
--- a/gtk/gui.h
+++ b/gtk/gui.h
@@ -1,12 +1,5 @@
/*
- * Copyright 2004-2010 James Bursa <bursa(a)users.sourceforge.net>
- * Copyright 2010 Vincent Sanders <vince(a)debian.org>
- * Copyright 2004-2009 John-Mark Bell <jmb(a)netsurf-browser.org>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- * Copyright 2006-2009 Daniel Silverstone <dsilvers(a)netsurf-browser.org>
- * Copyright 2006-2008 Rob Kendrick <rjek(a)netsurf-browser.org>
- * Copyright 2008 John Tytgat <joty(a)netsurf-browser.org>
- * Copyright 2008 Adam Blokus <adamblokus(a)gmail.com>
+ * Copyright 2014 Vincent Sanders <vince(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -32,6 +25,7 @@
#include "utils/nsurl.h"
+/** glade file paths. */
struct glade_file_location_s {
char *netsurf;
char *tabcontents;
@@ -51,22 +45,34 @@ struct glade_file_location_s {
/** location of all glade files. */
extern struct glade_file_location_s *glade_file_location;
+/** language list file path. */
extern char *languages_file_location;
+
+/** toolbar arrangement file path. */
extern char *toolbar_indices_file_location;
+
+/** Resource directory path. */
extern char *res_dir_location;
+
+/** Theme location. */
extern char *themelist_file_location;
/** Directory where all configuration files are held. */
extern char *nsgtk_config_home;
-extern GdkPixbuf *favicon_pixbuf; /* favicon default pixbuf */
+/** favicon default pixbuf */
+extern GdkPixbuf *favicon_pixbuf;
-extern char **respaths; /** resource search path vector */
+/** resource search path vector */
+extern char **respaths;
-uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *);
+/** input conversion. */
+uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *eventkey);
-extern void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw);
+/** login window request. */
+extern void gui_401login_open(nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw);
-#endif /* GTK_GUI_H */
+/** set when no windows remain open. */
+extern bool nsgtk_complete;
+#endif /* GTK_GUI_H */
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 93cd7f7..7f40d62 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -34,7 +34,6 @@
#include "desktop/browser_history.h"
#include "desktop/browser.h"
#include "desktop/hotlist.h"
-#include "desktop/netsurf.h"
#include "desktop/plotters.h"
#include "desktop/print.h"
#include "desktop/save_complete.h"
@@ -246,8 +245,8 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data)
LOG(("scaffold list head: %p", scaf_list));
if (scaf_list == NULL) {
- /* no more open windows */
- netsurf_quit = true;
+ /* no more open windows - stop the browser */
+ nsgtk_complete = true;
}
}
@@ -1609,7 +1608,7 @@ MULTIHANDLER(info)
MULTIHANDLER(about)
{
- nsgtk_about_dialog_init(g->window, netsurf_version);
+ nsgtk_about_dialog_init(g->window);
return TRUE;
}
diff --git a/gtk/viewdata.c b/gtk/viewdata.c
index 1b5bfb1..47af0fa 100644
--- a/gtk/viewdata.c
+++ b/gtk/viewdata.c
@@ -38,7 +38,6 @@
#include "utils/file.h"
#include "utils/filepath.h"
-#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "render/html.h"
#include "content/hlcache.h"
@@ -337,7 +336,7 @@ gboolean nsgtk_on_viewdata_about_activate(GtkMenuItem *widget, gpointer g)
{
struct nsgtk_viewdata_ctx *nsg = (struct nsgtk_viewdata_ctx *) g;
- nsgtk_about_dialog_init(nsg->window, netsurf_version);
+ nsgtk_about_dialog_init(nsg->window);
return TRUE;
}
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.2-65-ge994704
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e994704d5cdbb6b9a710d...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e994704d5cdbb6b9a710d20...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e994704d5cdbb6b9a710d20d5...
The branch, master has been updated
via e994704d5cdbb6b9a710d20d5fbbedde9a305a77 (commit)
via a90f5d1c8ba9c8d5d4542f1e176a8183130613d7 (commit)
via 1b2225ea076e32412cdde273ea59510e571d84c2 (commit)
from 2551885fd6c168b6b2738e6197325324e1d52a00 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e994704d5cdbb6b9a71...
commit e994704d5cdbb6b9a710d20d5fbbedde9a305a77
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
void function
diff --git a/amiga/gui.c b/amiga/gui.c
index 09b7310..f833081 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -192,8 +192,8 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw);
void ami_change_tab(struct gui_window_2 *gwin, int direction);
void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs);
void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys);
-ULONG ami_set_border_gadget_balance(struct gui_window_2 *gwin);
-ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2);
+static void ami_set_border_gadget_balance(struct gui_window_2 *gwin);
+static ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2);
void ami_try_quit(void);
void ami_quit_netsurf_delayed(void);
Object *ami_gui_splash_open(void);
@@ -3788,7 +3788,7 @@ gui_window_create(struct browser_window *bw,
return g;
}
-ULONG ami_set_border_gadget_balance(struct gui_window_2 *gwin)
+static void ami_set_border_gadget_balance(struct gui_window_2 *gwin)
{
/* Reset gadget widths according to new calculation */
ULONG size1, size2, sz;
@@ -3809,7 +3809,7 @@ ULONG ami_set_border_gadget_balance(struct gui_window_2 *gwin)
RefreshWindowFrame(gwin->win);
}
-ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2)
+static ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2)
{
/* Get the sizes that border gadget 1 (status) and 2 (hscroller) need to be.
** Returns the width of the vertical scroller (right-hand window border) as
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a90f5d1c8ba9c8d5d45...
commit a90f5d1c8ba9c8d5d4542f1e176a8183130613d7
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Stop the Amiga build complaining about redefined strndup
diff --git a/utils/config.h b/utils/config.h
index 21a2e4a..8f17b16 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -24,7 +24,7 @@
/* Try to detect which features the target OS supports */
-#if (defined(_GNU_SOURCE) && !defined(__APPLE__) || defined(__HAIKU__) || (defined(_POSIX_C_SOURCE) && ((_POSIX_C_SOURCE - 0) >= 200809L)))
+#if (defined(_GNU_SOURCE) && !defined(__APPLE__) || defined(__amigaos4__) || defined(__HAIKU__) || (defined(_POSIX_C_SOURCE) && ((_POSIX_C_SOURCE - 0) >= 200809L)))
#define HAVE_STRNDUP
#else
#undef HAVE_STRNDUP
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=1b2225ea076e32412cd...
commit 1b2225ea076e32412cdde273ea59510e571d84c2
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Move log init so it starts earlier
diff --git a/amiga/gui.c b/amiga/gui.c
index 7ababdf..09b7310 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -4985,6 +4985,7 @@ Object *ami_gui_splash_open(void)
LayoutEnd,
EndWindow;
+ LOG(("Attempting to open splash window..."));
win = RA_OpenWindow(win_obj);
GetAttrs(bm_obj, IA_Top, &top,
@@ -5038,13 +5039,16 @@ Object *ami_gui_splash_open(void)
void ami_gui_splash_close(Object *win_obj)
{
- if(win_obj) DisposeObject(win_obj);
+ if(win_obj == NULL) return;
+
+ LOG(("Closing splash window"));
+ 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));
+ LOG(("File open dialog request for %p/%p", g, gadget));
if(AslRequestTags(filereq,
ASLFR_Window, g->shared->win,
@@ -5126,7 +5130,7 @@ int main(int argc, char** argv)
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,
@@ -5147,6 +5151,14 @@ int main(int argc, char** argv)
die("NetSurf operation table failed registration");
}
+ /* initialise logging. Not fatal if it fails but not much we
+ * can do about it either.
+ */
+ nslog_init(NULL, &argc, argv);
+
+ /* Open splash window */
+ Object *splash_window = ami_gui_splash_open();
+
/* 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.
@@ -5183,11 +5195,6 @@ int main(int argc, char** argv)
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) {
diff --git a/amiga/plugin_hack.c b/amiga/plugin_hack.c
index 9bfd7a3..389cc11 100644
--- a/amiga/plugin_hack.c
+++ b/amiga/plugin_hack.c
@@ -77,7 +77,7 @@ nserror amiga_plugin_hack_init(void)
if(node)
{
- LOG(("plugin_hack registered %s\n",lwc_string_data(type)));
+ LOG(("plugin_hack registered %s",lwc_string_data(type)));
error = content_factory_register_handler(
lwc_string_data(type),
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 31 +++++++++++++++++++------------
amiga/plugin_hack.c | 2 +-
utils/config.h | 2 +-
3 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/amiga/gui.c b/amiga/gui.c
index 7ababdf..f833081 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -192,8 +192,8 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw);
void ami_change_tab(struct gui_window_2 *gwin, int direction);
void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs);
void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys);
-ULONG ami_set_border_gadget_balance(struct gui_window_2 *gwin);
-ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2);
+static void ami_set_border_gadget_balance(struct gui_window_2 *gwin);
+static ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2);
void ami_try_quit(void);
void ami_quit_netsurf_delayed(void);
Object *ami_gui_splash_open(void);
@@ -3788,7 +3788,7 @@ gui_window_create(struct browser_window *bw,
return g;
}
-ULONG ami_set_border_gadget_balance(struct gui_window_2 *gwin)
+static void ami_set_border_gadget_balance(struct gui_window_2 *gwin)
{
/* Reset gadget widths according to new calculation */
ULONG size1, size2, sz;
@@ -3809,7 +3809,7 @@ ULONG ami_set_border_gadget_balance(struct gui_window_2 *gwin)
RefreshWindowFrame(gwin->win);
}
-ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2)
+static ULONG ami_get_border_gadget_balance(struct gui_window_2 *gwin, ULONG *size1, ULONG *size2)
{
/* Get the sizes that border gadget 1 (status) and 2 (hscroller) need to be.
** Returns the width of the vertical scroller (right-hand window border) as
@@ -4985,6 +4985,7 @@ Object *ami_gui_splash_open(void)
LayoutEnd,
EndWindow;
+ LOG(("Attempting to open splash window..."));
win = RA_OpenWindow(win_obj);
GetAttrs(bm_obj, IA_Top, &top,
@@ -5038,13 +5039,16 @@ Object *ami_gui_splash_open(void)
void ami_gui_splash_close(Object *win_obj)
{
- if(win_obj) DisposeObject(win_obj);
+ if(win_obj == NULL) return;
+
+ LOG(("Closing splash window"));
+ 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));
+ LOG(("File open dialog request for %p/%p", g, gadget));
if(AslRequestTags(filereq,
ASLFR_Window, g->shared->win,
@@ -5126,7 +5130,7 @@ int main(int argc, char** argv)
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,
@@ -5147,6 +5151,14 @@ int main(int argc, char** argv)
die("NetSurf operation table failed registration");
}
+ /* initialise logging. Not fatal if it fails but not much we
+ * can do about it either.
+ */
+ nslog_init(NULL, &argc, argv);
+
+ /* Open splash window */
+ Object *splash_window = ami_gui_splash_open();
+
/* 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.
@@ -5183,11 +5195,6 @@ int main(int argc, char** argv)
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) {
diff --git a/amiga/plugin_hack.c b/amiga/plugin_hack.c
index 9bfd7a3..389cc11 100644
--- a/amiga/plugin_hack.c
+++ b/amiga/plugin_hack.c
@@ -77,7 +77,7 @@ nserror amiga_plugin_hack_init(void)
if(node)
{
- LOG(("plugin_hack registered %s\n",lwc_string_data(type)));
+ LOG(("plugin_hack registered %s",lwc_string_data(type)));
error = content_factory_register_handler(
lwc_string_data(type),
diff --git a/utils/config.h b/utils/config.h
index 21a2e4a..8f17b16 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -24,7 +24,7 @@
/* Try to detect which features the target OS supports */
-#if (defined(_GNU_SOURCE) && !defined(__APPLE__) || defined(__HAIKU__) || (defined(_POSIX_C_SOURCE) && ((_POSIX_C_SOURCE - 0) >= 200809L)))
+#if (defined(_GNU_SOURCE) && !defined(__APPLE__) || defined(__amigaos4__) || defined(__HAIKU__) || (defined(_POSIX_C_SOURCE) && ((_POSIX_C_SOURCE - 0) >= 200809L)))
#define HAVE_STRNDUP
#else
#undef HAVE_STRNDUP
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.2-62-g2551885
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/2551885fd6c168b6b2738...
...commit http://git.netsurf-browser.org/netsurf.git/commit/2551885fd6c168b6b2738e6...
...tree http://git.netsurf-browser.org/netsurf.git/tree/2551885fd6c168b6b2738e619...
The branch, master has been updated
via 2551885fd6c168b6b2738e6197325324e1d52a00 (commit)
via 5b96a84ef7ccc4ed426b2b130328437089bb6af0 (commit)
via 6a74106d36059d27ad7150e0ad2c56d0ead80990 (commit)
via f95b9d2eb3c9d10003f64db2af6b932c17d043e1 (commit)
from 35f7f2b9f39f000a652b0bdf423b4042338f474f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=2551885fd6c168b6b27...
commit 2551885fd6c168b6b2738e6197325324e1d52a00
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Optimise case where scrollbar_set_extents call changes nothing.
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 948009f..c4da77c 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -514,6 +514,12 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
int well_length;
struct scrollbar_msg_data msg;
+ if (length == s->length && visible_size == s->visible_size &&
+ full_size == s->full_size) {
+ /* Nothing's changed. */
+ return;
+ }
+
if (length != -1)
s->length = length;
if (visible_size != -1)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5b96a84ef7ccc4ed426...
commit 5b96a84ef7ccc4ed426b2b130328437089bb6af0
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Setting extents can move scroll pos, so send message.
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 3d21aae..948009f 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -510,8 +510,9 @@ int scrollbar_get_offset(struct scrollbar *s)
void scrollbar_set_extents(struct scrollbar *s, int length,
int visible_size, int full_size)
{
- int well_length;
int cur_excess = s->full_size - s->visible_size;
+ int well_length;
+ struct scrollbar_msg_data msg;
if (length != -1)
s->length = length;
@@ -539,6 +540,11 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
s->bar_len = (well_length * s->visible_size) / s->full_size;
s->bar_pos = (well_length * s->offset) / s->full_size;
}
+
+ msg.scrollbar = s;
+ msg.msg = SCROLLBAR_MSG_MOVED;
+ msg.scroll_offset = s->offset;
+ s->client_callback(s->client_data, &msg);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6a74106d36059d27ad7...
commit 6a74106d36059d27ad7150e0ad2c56d0ead80990
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Make code more readable.
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index dadb828..3d21aae 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -524,9 +524,11 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
s->full_size = s->visible_size;
/* Update scroll offset (scaled in proportion with change in excess) */
- s->offset = (cur_excess < 1) ? 0 :
- ((s->full_size - s->visible_size) * s->offset /
- cur_excess);
+ if (cur_excess <= 0) {
+ s->offset = 0;
+ } else {
+ s->offset = (full_size - visible_size) * s->offset / cur_excess;
+ }
well_length = s->length - 2 * SCROLLBAR_WIDTH;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f95b9d2eb3c9d10003f...
commit f95b9d2eb3c9d10003f64db2af6b932c17d043e1
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix a couple of comment typos.
diff --git a/desktop/textarea.c b/desktop/textarea.c
index e37f06e..82f0989 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1078,7 +1078,7 @@ static bool textarea_reflow_multiline(struct textarea *ta,
continue;
} else if (len - b_off > 0) {
- /* soft wraped, find last space (if any) */
+ /* soft wrapped, find last space (if any) */
for (space = text + b_off; space > text;
space--) {
if (*space == ' ')
@@ -1156,7 +1156,7 @@ static bool textarea_reflow_multiline(struct textarea *ta,
ta->v_extent = v_extent;
ta->line_count = line;
- /* Don't need to redraw above changes, so update redraw request rect*/
+ /* Don't need to redraw above changes, so update redraw request rect */
if (ta->lines[start].b_start + ta->lines[start].b_length < b_start &&
restart == false) {
/* Start line is unchanged */
-----------------------------------------------------------------------
Summary of changes:
desktop/scrollbar.c | 22 ++++++++++++++++++----
desktop/textarea.c | 4 ++--
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index dadb828..c4da77c 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -510,8 +510,15 @@ int scrollbar_get_offset(struct scrollbar *s)
void scrollbar_set_extents(struct scrollbar *s, int length,
int visible_size, int full_size)
{
- int well_length;
int cur_excess = s->full_size - s->visible_size;
+ int well_length;
+ struct scrollbar_msg_data msg;
+
+ if (length == s->length && visible_size == s->visible_size &&
+ full_size == s->full_size) {
+ /* Nothing's changed. */
+ return;
+ }
if (length != -1)
s->length = length;
@@ -524,9 +531,11 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
s->full_size = s->visible_size;
/* Update scroll offset (scaled in proportion with change in excess) */
- s->offset = (cur_excess < 1) ? 0 :
- ((s->full_size - s->visible_size) * s->offset /
- cur_excess);
+ if (cur_excess <= 0) {
+ s->offset = 0;
+ } else {
+ s->offset = (full_size - visible_size) * s->offset / cur_excess;
+ }
well_length = s->length - 2 * SCROLLBAR_WIDTH;
@@ -537,6 +546,11 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
s->bar_len = (well_length * s->visible_size) / s->full_size;
s->bar_pos = (well_length * s->offset) / s->full_size;
}
+
+ msg.scrollbar = s;
+ msg.msg = SCROLLBAR_MSG_MOVED;
+ msg.scroll_offset = s->offset;
+ s->client_callback(s->client_data, &msg);
}
diff --git a/desktop/textarea.c b/desktop/textarea.c
index e37f06e..82f0989 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1078,7 +1078,7 @@ static bool textarea_reflow_multiline(struct textarea *ta,
continue;
} else if (len - b_off > 0) {
- /* soft wraped, find last space (if any) */
+ /* soft wrapped, find last space (if any) */
for (space = text + b_off; space > text;
space--) {
if (*space == ' ')
@@ -1156,7 +1156,7 @@ static bool textarea_reflow_multiline(struct textarea *ta,
ta->v_extent = v_extent;
ta->line_count = line;
- /* Don't need to redraw above changes, so update redraw request rect*/
+ /* Don't need to redraw above changes, so update redraw request rect */
if (ta->lines[start].b_start + ta->lines[start].b_length < b_start &&
restart == false) {
/* Start line is unchanged */
--
NetSurf Browser
9 years, 2 months