Precis:
This is Mark Benjamin's GTK work. It builds for GTK, with warnings. It does not build
for RISC OS. The Amiga frontend conflicts loads when merged to trunk, so all bets are off
there.
GTK build warnings:
COMPILE: desktop/save_complete.c
desktop/save_complete.c: In function ‘save_complete_html’:
desktop/save_complete.c:150: warning: cast from pointer to integer of different size
desktop/save_complete.c:185: warning: cast from pointer to integer of different size
desktop/save_complete.c:212: warning: cast from pointer to integer of different size
desktop/save_complete.c: In function ‘save_imported_sheets’:
desktop/save_complete.c:263: warning: cast from pointer to integer of different size
desktop/save_complete.c: In function ‘rewrite_stylesheet_urls’:
desktop/save_complete.c:417: warning: cast from pointer to integer of different size
desktop/save_complete.c: In function ‘rewrite_url’:
desktop/save_complete.c:619: warning: cast from pointer to integer of different size
desktop/save_complete.c: In function ‘save_complete_inventory’:
desktop/save_complete.c:735: warning: cast from pointer to integer of different size
COMPILE: gtk/gtk_toolbar.c
gtk/gtk_toolbar.c: In function ‘nsgtk_toolbar_customization_load’:
gtk/gtk_toolbar.c:896: warning: ‘pter’ may be used uninitialised in this function
COMPILE: render/favicon.c
render/favicon.c: In function ‘favicon_get_icon’:
render/favicon.c:284: warning: passing argument 11 of ‘fetchcache_go’ from
incompatible pointer type
RISC OS build warnings + failure:
COMPILE: content/fetchcache.c
content/fetchcache.c: In function 'fetchcache_search_redirect':
content/fetchcache.c:833: warning: passing argument 11 of 'fetchcache_go' from
incompatible pointer type
COMPILE: render/favicon.c
render/favicon.c: In function 'favicon_get_icon':
render/favicon.c:284: warning: passing argument 11 of 'fetchcache_go' from
incompatible pointer type
COMPILE: riscos/search.c
riscos/search.c:188: error: conflicting types for 'ro_gui_search_prepare'
./riscos/gui.h:202: error: previous declaration of 'ro_gui_search_prepare' was
here
Added files
Index: render/favicon.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ render/favicon.c 2009-07-10 12:49:13.000000000 +0100
@@ -0,0 +1,375 @@
+/*
+ * Copyright 2007 James Bursa <bursa(a)users.sourceforge.net>
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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 <string.h>
+#include "content/fetch.h"
+#include "content/fetchcache.h"
+#include "render/favicon.h"
+#include "render/html.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/talloc.h"
+#include "utils/url.h"
+#include "utils/utils.h"
+
+static char *favicon_get_icon_ref(struct content *c, xmlNode *html);
+static void favicon_callback(content_msg msg, struct content *icon,
+ intptr_t p1, intptr_t p2, union content_msg_data data);
+static unsigned long favicon_hash(char *str);
+
+unsigned long favicon_hash(char *str)
+{
+ if (str == NULL)
+ return 0;
+ unsigned long hash = 5381;
+ int c;
+ while ((c = (unsigned char) *str++))
+ hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
+ return hash;
+}
+
+/**
+ * retrieve 1 url reference to 1 favicon
+ * \param html xml node of html element
+ * \return pointer to url; NULL for no icon
+ */
+char *favicon_get_icon_ref(struct content *c, xmlNode *html)
+{
+ xmlNode *node;
+ char *rel, *type, *href, *url, *suf, *url2;
+ url2 = NULL;
+ url_func_result res;
+ int score, hiscore;
+ hiscore = 0;
+ /* hashed values - saves calculating them afresh every time */
+ #define HHICON 0x7c98572e
+ /* icon */
+ #define HHSHORTCUTICON 0xfcbccdca
+ /* shortcut icon */
+ #define HHAPPLETOUCHICON 0x024c6ddd
+ /* apple-touch-icon */
+ #define HHIMAGEPNG 0x7382417c
+ /* image/png */
+ #define HHIMAGEGIF 0x73821a8d
+ /* image/gif */
+ #define HHIMAGEVNDMICROSOFTICON 0xdae02bba
+ /* image.vnd.microsoft.icon */
+ #define HHIMAGEJPEG 0xe3c72f5d
+ /* image/jpeg */
+ #define HHIMAGEJPG 0x73822838
+ /* image/jpg */
+ #define HHIMAGEICO 0x73822252
+ /* image/ico */
+ #define HHIMAGEICON 0xe3c66d00
+ /* image/icon */
+ #define HHIMAGEXICON 0x0e3e78e5
+ /* image/x-icon */
+ #define HHTEXTICO 0x17e966a2
+ /* text/icon */
+ #define HHAPPLICATIONICO 0x087b6fb4
+ /*application/icon*/
+ #define HHSUFICO 0x0b887ec0
+ /* ico */
+ #define HHSUFPNG 0x0b889dea
+ /* png */
+ #define HHSUFGIF 0x0b8876fb
+ /* gif */
+ #define HHSUFJPG 0x0b888486
+ /* jpg */
+ #define HHSUFJPEG 0x7c99198b
+ /* jpeg */
+
+ union content_msg_data msg_data;
+
+ node = html;
+ while (node) {
+ score = 0;
+ suf = NULL;
+ if (node->children) { /* children */
+ node = node->children;
+ } else if (node->next) { /* siblings */
+ node = node->next;
+ } else { /* ancestor siblings */
+ while (node && !node->next)
+ node = node->parent;
+ if (!node)
+ break;
+ node = node->next;
+ }
+ assert(node);
+
+ if (node->type != XML_ELEMENT_NODE)
+ continue;
+
+ if (strcmp((const char *) node->name, "link") == 0) {
+ /* rel=<space separated list, including 'icon'> */
+ if ((rel = (char *) xmlGetProp(node,
+ (const xmlChar *) "rel")) == NULL)
+ continue;
+ if (strcasestr(rel, "icon") == 0) {
+ xmlFree(rel);
+ continue;
+ }
+ LOG(("icon node found"));
+ switch(favicon_hash(rel)) {
+ /* give points for rel attributes, kind of arbitrary
+ * in an attempt to test how closely standards are
+ * being respected; the reason apple-touch-icon scores
+ * less is that the appearance of such is really
+ * specific to the iphone style */
+ case HHICON:
+ LOG(("icon"));
+ score = 3;
+ break;
+ case HHSHORTCUTICON:
+ LOG(("shortcut icon"));
+ score = 5;
+ break;
+ case HHAPPLETOUCHICON:
+ LOG(("apple-touch-icon"));
+ score = 1;
+ break;
+ }
+ xmlFree(rel);
+ /* current implementation scores candidates according
+ * to how closely they seem to adhere to standards,
+ * scoring system may be modified in the future */
+ if ((type = (char *) xmlGetProp(node,
+ (const xmlChar *) "type")) != NULL) {
+ switch(favicon_hash(type)) {
+ /* here we score highest for "image/type"
+ * mime types, lower scores for "type/ico"
+ * mime types, no score for no type */
+ case HHIMAGEPNG:
+ score += 5;
+ break;
+ case HHIMAGEGIF:
+ score += 5;
+ break;
+ case HHIMAGEVNDMICROSOFTICON:
+ score += 5;
+ break;
+ case HHIMAGEJPEG:
+ score += 5;
+ break;
+ case HHIMAGEJPG:
+ score += 5;
+ break;
+ case HHIMAGEICO:
+ score += 5;
+ break;
+ case HHIMAGEICON:
+ score += 5;
+ break;
+ case HHIMAGEXICON:
+ score += 5;
+ break;
+ case HHTEXTICO:
+ score += 2;
+ break;
+ case HHAPPLICATIONICO:
+ score += 1;
+ break;
+ }
+ xmlFree(type);
+ }
+ if ((href = (char *) xmlGetProp(node,
+ (const xmlChar *) "href")) == NULL)
+ continue;
+ suf = strrchr(href, '.');
+ if (suf != NULL) {
+ suf ++;
+ switch(favicon_hash(suf)) {
+ /* here the largest bonus points of all
+ * attributes, notably for .ico, .png, .gif
+ * as the standards support; less for .jpg */
+ case HHSUFICO:
+ score += 10;
+ break;
+ case HHSUFPNG:
+ score += 10;
+ break;
+ case HHSUFGIF:
+ score += 10;
+ break;
+ case HHSUFJPG:
+ score += 7;
+ break;
+ case HHSUFJPEG:
+ score += 7;
+ break;
+ }
+ }
+ if (score > hiscore) {
+ res = url_join(href, c->data.html.base_url,
+ &url);
+ xmlFree(href);
+ if (res != URL_FUNC_OK)
+ continue;
+
+ LOG(("best favicon so far '%s'", url));
+ res = url_normalize(url, &url2);
+ if (res != URL_FUNC_OK) {
+ url2 = NULL;
+ if (res == URL_FUNC_NOMEM)
+ goto no_memory;
+ continue;
+ }
+ hiscore = score;
+ free(url);
+ }
+ }
+ }
+ if (url2 == NULL) {
+ struct url_components comp;
+ if (url_get_components(c->data.html.base_url, &comp) !=
+ URL_FUNC_OK)
+ return NULL;
+ if (url_normalize(comp.authority,
+ &url) != URL_FUNC_OK)
+ return NULL;
+ url_destroy_components(&comp);
+ if (url_join("/favicon.ico", url, &url2) != URL_FUNC_OK)
+ return NULL;
+ free(url);
+ }
+ LOG(("Best favicon %s", url2));
+ return url2;
+no_memory:
+ msg_data.error = messages_get("NoMemory");
+ /* content_broadcast(c, CONTENT_MSG_ERROR, msg_data); */
+ return false;
+}
+
+/**
+ * retrieve 1 favicon
+ * \param c content structure
+ * \param html xml node of html element
+ * \return true for success, false for error
+ */
+
+bool favicon_get_icon(struct content *c, xmlNode *html)
+{
+ union content_msg_data msg_data;
+ char *url = favicon_get_icon_ref(c, html);
+ struct content *favcontent = NULL;
+ if (url != NULL)
+ favcontent = fetchcache(url, favicon_callback,
+ (intptr_t) c, 0, c->width, c->height, true, 0,
+ 0, false, false);
+ free(url);
+ if (favcontent == NULL)
+ return false;
+
+ c->data.html.favicon = favcontent;
+
+ fetchcache_go(favcontent, c->url, favicon_callback,
+ (intptr_t) c, 0, c->width, c->height,
+ 0, 0, false, c->url);
+
+ if (!c->data.html.favicon) {
+ msg_data.error = "Favicon failed to load";
+ return false;
+ }
+ return true;
+}
+
+/**
+ * Callback for fetchcache() for linked favicon
+ */
+
+void favicon_callback(content_msg msg, struct content *icon,
+ intptr_t p1, intptr_t p2, union content_msg_data data)
+{
+ struct content *c = (struct content *) p1;
+ unsigned int i = p2;
+
+ switch (msg) {
+ case CONTENT_MSG_LOADING:
+ /* check that the favicon is really a correct image type */
+
+ if (!((icon->type == CONTENT_ICO) ||
+ (icon->type == CONTENT_PNG) ||
+ (icon->type == CONTENT_GIF))) {
+ c->data.html.favicon = 0;
+ LOG(("%s is not a favicon", icon->url));
+ content_add_error(c, "NotFavIco", 0);
+ html_set_status(c, messages_get("NotFavIco"));
+ content_broadcast(c, CONTENT_MSG_STATUS, data);
+ content_remove_user(icon,
+ favicon_callback,
+ (intptr_t) c, i);
+ if (!icon->user_list->next) {
+ /* we were the only user and we don't want this
+ * content, so stop it fetching and mark it as
+ * having an error so it gets removed from the
+ * cache next time content_clean() gets called
+ */
+ fetch_abort(icon->fetch);
+ icon->fetch = 0;
+ icon->status = CONTENT_STATUS_ERROR;
+ }
+ }
+ break;
+
+ case CONTENT_MSG_READY:
+ break;
+
+ case CONTENT_MSG_DONE:
+ LOG(("got favicon '%s'", icon->url));
+ break;
+
+ case CONTENT_MSG_LAUNCH:
+ /* Fall through */
+ case CONTENT_MSG_ERROR:
+ LOG(("favicon %s failed: %s", icon->url, data.error));
+ /* The favicon we were fetching may have been
+ * redirected, in that case, the object pointers
+ * will differ, so ensure that the object that's
+ * in error is still in use by us before invalidating
+ * the pointer */
+ if (c->data.html.favicon == icon) {
+ c->data.html.favicon = 0;
+ content_add_error(c, "?", 0);
+ }
+ break;
+
+ case CONTENT_MSG_STATUS:
+ html_set_status(c, icon->status_message);
+ content_broadcast(c, CONTENT_MSG_STATUS, data);
+ break;
+
+ case CONTENT_MSG_NEWPTR:
+ c->data.html.favicon = icon;
+ break;
+
+ case CONTENT_MSG_AUTH:
+ c->data.html.favicon = 0;
+ content_add_error(c, "?", 0);
+ break;
+
+ case CONTENT_MSG_SSL:
+ c->data.html.favicon = 0;
+ content_add_error(c, "?", 0);
+ break;
+
+ default:
+ assert(0);
+ }
+}
Index: render/favicon.h
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ render/favicon.h 2009-07-10 12:49:13.000000000 +0100
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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_RENDER_FAVICON_H_
+#define _NETSURF_RENDER_FAVICON_H_
+
+typedef enum {
+ HHICON = 0x7c98572e,
+ /* icon */
+ HHSHORTCUTICON = 0xfcbccdca,
+ /* shortcut icon */
+ HHAPPLETOUCHICON = 0x024c6ddd,
+ /* apple-touch-icon */
+ HHIMAGEPNG = 0x7382417c,
+ /* image/png */
+ HHIMAGEGIF = 0x73821a8d,
+ /* image/gif */
+ HHIMAGEVNDMICROSOFTICON = 0xdae02bba,
+ /* image.vnd.microsoft.icon */
+ HHIMAGEJPEG = 0xe3c72f5d,
+ /* image/jpeg */
+ HHIMAGEJPG = 0x73822838,
+ /* image/jpg */
+ HHIMAGEICO = 0x73822252,
+ /* image/ico */
+ HHIMAGEICON = 0xe3c66d00,
+ /* image/icon */
+ HHIMAGEXICON = 0x0e3e78e5,
+ /* image/x-icon */
+ HHTEXTICO = 0x17e966a2,
+ /* text/icon */
+ HHAPPLICATIONICO = 0x087b6fb4,
+ /* application/icon */
+ HHSUFICO = 0x0b887ec0,
+ /* ico */
+ HHSUFPNG = 0x0b889dea,
+ /* png */
+ HHSUFGIF = 0x0b8876fb,
+ /* gif */
+ HHSUFJPG = 0x0b888486,
+ /* jpg */
+ HHSUFJPEG = 0x7c99198b
+ /* jpeg */
+} favicon_string_hash;
+
+bool favicon_get_icon(struct content *c, xmlNode *html);
+
+#endif
Index: framebuffer/fb_search.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ framebuffer/fb_search.c 2009-07-10 12:49:34.000000000 +0100
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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 <stdbool.h>
+#include <string.h>
+
+#include "utils/log.h"
+
+/* put new search_web globals here for now */
+char *search_engines_file_location;
+char *search_default_ico_location;
+
+/**
+ * Change the displayed search status.
+ * \param found search pattern matched in text
+ */
+void gui_search_set_status(bool found)
+{
+}
+
+/**
+ * display hourglass while searching
+ * \param active start/stop indicator
+ */
+void gui_search_set_hourglass(bool active)
+{
+}
+
+/**
+ * retrieve string being searched for from gui
+ */
+char *gui_search_get_string(void)
+{
+}
+
+/**
+ * add search string to recent searches list
+ * \param string search pattern
+ */
+void gui_search_add_recent(const char *string)
+{
+}
+
+/**
+ * activate search forwards button in gui
+ * \param active activate/inactivate
+ */
+void gui_search_set_forward_state(bool inactive)
+{
+}
+
+/**
+ * activate search forwards button in gui
+ * \param active activate/inactivate
+ */
+void gui_search_set_back_state(bool inactive)
+{
+}
+
+/**
+ * retrieve state of 'case sensitive' check in gui
+ */
+bool gui_search_get_case_sens(void)
+{
+}
+
+/**
+ * retrieve state of 'show all' check in gui
+ */
+bool gui_search_get_show_all(void)
+{
+}
Index: gtk/gtk_save.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/gtk_save.c 2009-07-10 12:49:36.000000000 +0100
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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 <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <libxml/HTMLtree.h>
+#include "desktop/save_complete.h"
+#include "utils/utils.h"
+
+bool save_complete_gui_save(const char *path, const char *filename, struct content *c,
int len, char *sourcedata, int type)
+{
+ int res;
+ int namelen;
+ namelen = strlen(path) + strlen(filename) + 2;
+ char *fullpath = malloc(namelen);
+ if (!fullpath) {
+ warn_user("NoMemory", 0);
+ return false;
+ }
+ snprintf(fullpath, namelen, "%s/%s", path, filename);
+ FILE *f = fopen(fullpath, "w"); /* may need mode 'b' when c != NULL
*/
+ free(fullpath);
+ if (f == NULL)
+ return false;
+ res = fwrite(sourcedata, len, 1, f);
+ fclose(f);
+ if (res != 1)
+ return false;
+ return true;
+}
+
+int save_complete_htmlSaveFileFormat(const char *path, const char *filename,
+ xmlDocPtr cur, const char *encoding, int format)
+{
+ int ret;
+ int len = strlen(path) + strlen(filename) + 2;
+ char *finame = malloc(len);
+ if (!finame){
+ warn_user("NoMemory", 0);
+ return -1;
+ }
+ snprintf(finame, len, "%s/%s", path, filename);
+ ret = htmlSaveFileFormat(finame, cur, encoding, format);
+ free(finame);
+ return ret;
+}
+
+bool save_complete_gui_filetype(const char *path, const char *filename,
+ int type)
+{
+ return true;
+}
Index: gtk/gtk_theme.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/gtk_theme.c 2009-07-10 12:49:36.000000000 +0100
@@ -0,0 +1,591 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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 <gtk/gtk.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include "content/content.h"
+#include "content/content_type.h"
+#include "gtk/gtk_gui.h"
+#include "gtk/gtk_scaffolding.h"
+#include "gtk/gtk_menu.h"
+#include "gtk/gtk_theme.h"
+#include "gtk/gtk_window.h"
+#include "gtk/options.h"
+#include "gtk/dialogs/gtk_options.h"
+#include "utils/container.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+
+struct nsgtk_theme_cache {
+ GdkPixbuf *image[PLACEHOLDER_BUTTON];
+ GdkPixbuf *searchimage[3]; /* back, forward, close */
+ /* apng throbber image */
+};
+
+char *current_theme_name = NULL;
+static struct nsgtk_theme_cache *theme_cache_menu = NULL;
+static struct nsgtk_theme_cache *theme_cache_toolbar = NULL;
+
+static struct nsgtk_theme *nsgtk_theme_default(GtkIconSize s);
+static GtkImage *nsgtk_theme_image_default(int i, GtkIconSize s);
+static bool nsgtk_theme_verify(const char *themename);
+
+#ifdef WITH_THEME_INSTALL
+static struct content *theme_install_content = NULL;
+
+static void theme_install_callback(content_msg msg, struct content *c,
+ intptr_t p1, intptr_t p2, union content_msg_data data);
+static bool theme_install_read(char *data, unsigned long len);
+#endif
+
+void nsgtk_theme_init()
+{
+ if (option_current_theme == 0)
+ return;
+ char *themefile = g_strconcat(res_dir_location, "themelist", NULL);
+ nsgtk_scaffolding *list = scaf_list;
+ nsgtk_theme_verify(NULL);
+ FILE *fp = fopen(themefile, "r");
+ char buf[50];
+ int row_count = 0;
+ if (fp == NULL)
+ return;
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (buf[0] == '\0')
+ continue;
+
+ if (row_count++ == option_current_theme) {
+ if (current_theme_name != NULL)
+ free(current_theme_name);
+ buf[strlen(buf) - 1] = '\0';
+ current_theme_name = strdup(buf);
+ break;
+ }
+ }
+ fclose(fp);
+
+ while (list) {
+ nsgtk_theme_implement(list);
+ list = nsgtk_scaffolding_iterate(list);
+ }
+}
+
+void nsgtk_theme_add(const char *themename)
+{
+ GtkWidget *notification, *label;
+ char *labelcontent, *themefile = g_strconcat(res_dir_location,
+ "themelist", NULL);
+ /* conduct verification here; no adding duplicates to list */
+ if (nsgtk_theme_verify(themename) == false) {
+ warn_user(messages_get("gtkThemeDup"), 0);
+ g_free(themefile);
+ return;
+ }
+ FILE *fp = fopen(themefile, "a");
+ if (fp == NULL) {
+ warn_user(messages_get("gtkFileError"), themefile);
+ g_free(themefile);
+ return;
+ }
+ fprintf(fp, "%s\n", themename);
+ fclose(fp);
+ g_free(themefile);
+
+ /* notification that theme was added successfully */
+ notification = gtk_dialog_new_with_buttons(messages_get("gtkThemeAdd"),
+ NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK,
+ GTK_RESPONSE_NONE, NULL);
+ labelcontent = g_strconcat("\t\t\t", messages_get("gtkThemeAdd"),
+ "\t\t\t", NULL);
+ label = gtk_label_new(labelcontent);
+ g_signal_connect_swapped(notification, "response",
+ G_CALLBACK(gtk_widget_destroy), notification);
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(notification)->vbox), label);
+ gtk_widget_show_all(notification);
+ g_free(labelcontent);
+
+ /* update combo */
+ if (wndPreferences == NULL)
+ return;
+ nsgtk_options_combo_theme_add(themename);
+
+}
+
+bool nsgtk_theme_verify(const char *themename)
+{
+ long filelength;
+ FILE *fp;
+ size_t val;
+ char buf[50];
+ char *themefile = g_strconcat(res_dir_location, "themelist", NULL);
+ if (themename == NULL) {
+ char *filecontent, *testfile;
+ struct stat sta;
+ fp = fopen(themefile, "r+");
+ if (fp == NULL) {
+ warn_user(messages_get("gtkFileError"), themefile);
+ g_free(themefile);
+ return true;
+ }
+ fseek(fp, 0L, SEEK_END);
+ filelength = ftell(fp);
+ filecontent = malloc(filelength + 2);
+ strcpy(filecontent, "gtk default theme\n");
+ if (filecontent == NULL) {
+ warn_user(messages_get("NoMemory"), 0);
+ g_free(themefile);
+ return true;
+ }
+ fseek(fp, 0L, SEEK_SET);
+ while (fgets(buf, sizeof(buf), fp)) {
+ /* iterate list */
+ buf[strlen(buf) - 1] = '\0';
+ testfile = g_strconcat(res_dir_location, "themes/",
+ buf, NULL);
+ /* check every directory */
+ if (access(testfile, R_OK) == 0) {
+ stat(testfile, &sta);
+ if (S_ISDIR(sta.st_mode)) {
+ free(testfile);
+ buf[strlen(buf)] = '\n';
+ strcat(filecontent, buf);
+ }
+ }
+ }
+ fclose(fp);
+ fp = fopen(themefile, "w");
+ if (fp == NULL) {
+ warn_user(messages_get("gtkFileError"), themefile);
+ free(filecontent);
+ g_free(themefile);
+ return true;
+ }
+ val = fwrite(filecontent, strlen(filecontent), 1, fp);
+ if (val == 0)
+ LOG(("empty write themelist"));
+ fclose(fp);
+ free(filecontent);
+ g_free(themefile);
+ return true;
+ } else {
+ fp = fopen(themefile, "r");
+ if (fp == NULL) {
+ warn_user(messages_get("gtkFileError"), themefile);
+ g_free(themefile);
+ return false;
+ }
+ while (fgets(buf, sizeof(buf), fp)) {
+ buf[strlen(buf) - 1] = '\0';
+ if (strcmp(buf, themename) == 0) {
+ g_free(themefile);
+ return false;
+ }
+ }
+ fclose(fp);
+ g_free(themefile);
+ return true;
+ }
+
+}
+
+void nsgtk_theme_implement(struct gtk_scaffolding *g)
+{
+ struct nsgtk_theme *theme[4];
+ int i;
+ for (i = 0; i < 3; i++)
+ theme[i] = nsgtk_theme_load(GTK_ICON_SIZE_MENU);
+ theme[3] = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ if ((i == URL_BAR_ITEM) || (i == THROBBER_ITEM) ||
+ (i == WEBSEARCH_ITEM))
+ continue;
+ if (nsgtk_scaffolding_button(g, i)->main != NULL) {
+ gtk_image_menu_item_set_image(nsgtk_scaffolding_button(
+ g, i)->main,
+ GTK_WIDGET(theme[0]->image[i]));
+ gtk_widget_show_all(GTK_WIDGET(
+ nsgtk_scaffolding_button(g, i)->main));
+ }
+ if (nsgtk_scaffolding_button(g, i)->rclick != NULL) {
+ gtk_image_menu_item_set_image(nsgtk_scaffolding_button(
+ g, i)->rclick,
+ GTK_WIDGET(theme[1]->image[i]));
+ gtk_widget_show_all(GTK_WIDGET(
+ nsgtk_scaffolding_button(
+ g, i)->rclick));
+ }
+ if (nsgtk_scaffolding_button(g, i)->popup != NULL) {
+ gtk_image_menu_item_set_image(nsgtk_scaffolding_button(
+ g, i)->popup,
+ GTK_WIDGET(theme[2]->image[i]));
+ gtk_widget_show_all(GTK_WIDGET(
+ nsgtk_scaffolding_button(g, i)->
+ popup));
+ }
+ if ((nsgtk_scaffolding_button(g, i)->location != -1) &&
+ (nsgtk_scaffolding_button(g, i)->button
+ != NULL)) {
+ gtk_tool_button_set_icon_widget(
+ GTK_TOOL_BUTTON(
+ nsgtk_scaffolding_button(
+ g, i)->button),
+ GTK_WIDGET(theme[3]->image[i]));
+ gtk_widget_show_all(GTK_WIDGET(
+ nsgtk_scaffolding_button(g, i)->
+ button));
+ }
+ }
+
+ /* set search bar images */
+ gtk_tool_button_set_icon_widget(
+ nsgtk_scaffolding_search(g)->buttons[0],
+ GTK_WIDGET(theme[0]->searchimage[0]));
+ gtk_widget_show_all(GTK_WIDGET(
+ nsgtk_scaffolding_search(g)->buttons[0]));
+ gtk_tool_button_set_icon_widget(
+ nsgtk_scaffolding_search(g)->buttons[1],
+ GTK_WIDGET(theme[0]->searchimage[1]));
+ gtk_widget_show_all(GTK_WIDGET(
+ nsgtk_scaffolding_search(g)->buttons[1]));
+ gtk_tool_button_set_icon_widget(
+ nsgtk_scaffolding_search(g)->buttons[2],
+ GTK_WIDGET(theme[0]->searchimage[2]));
+ gtk_widget_show_all(GTK_WIDGET(
+ nsgtk_scaffolding_search(g)->buttons[2]));
+
+ for (i = 0; i < 4; i++)
+ free(theme[i]);
+}
+
+struct nsgtk_theme *nsgtk_theme_load(GtkIconSize s)
+{
+ if (current_theme_name == NULL)
+ return nsgtk_theme_default(s);
+ struct nsgtk_theme *theme = malloc(sizeof(struct nsgtk_theme));
+ if ((theme_cache_menu == NULL) || (theme_cache_toolbar == NULL))
+ nsgtk_theme_prepare();
+ /* load theme from cache */
+ struct nsgtk_theme_cache *cachetheme = (s == GTK_ICON_SIZE_MENU) ?
+ theme_cache_menu : theme_cache_toolbar;
+#define SET_BUTTON_IMAGE(q)\
+ if (cachetheme->image[q##_BUTTON] != NULL)\
+ theme->image[q##_BUTTON] = GTK_IMAGE(gtk_image_new_from_pixbuf(\
+ cachetheme->image[q##_BUTTON]));\
+ else\
+ theme->image[q##_BUTTON] = nsgtk_theme_image_default(\
+ q##_BUTTON, s);
+ SET_BUTTON_IMAGE(BACK)
+ SET_BUTTON_IMAGE(HISTORY)
+ SET_BUTTON_IMAGE(FORWARD)
+ SET_BUTTON_IMAGE(STOP)
+ SET_BUTTON_IMAGE(RELOAD)
+ SET_BUTTON_IMAGE(HOME)
+ SET_BUTTON_IMAGE(NEWWINDOW)
+ SET_BUTTON_IMAGE(NEWTAB)
+ SET_BUTTON_IMAGE(OPENFILE)
+ SET_BUTTON_IMAGE(CLOSETAB)
+ SET_BUTTON_IMAGE(CLOSEWINDOW)
+ SET_BUTTON_IMAGE(SAVEPAGE)
+ SET_BUTTON_IMAGE(PRINTPREVIEW)
+ SET_BUTTON_IMAGE(PRINT)
+ SET_BUTTON_IMAGE(QUIT)
+ SET_BUTTON_IMAGE(CUT)
+ SET_BUTTON_IMAGE(COPY)
+ SET_BUTTON_IMAGE(PASTE)
+ SET_BUTTON_IMAGE(DELETE)
+ SET_BUTTON_IMAGE(SELECTALL)
+ SET_BUTTON_IMAGE(PREFERENCES)
+ SET_BUTTON_IMAGE(ZOOMPLUS)
+ SET_BUTTON_IMAGE(ZOOMMINUS)
+ SET_BUTTON_IMAGE(ZOOMNORMAL)
+ SET_BUTTON_IMAGE(FULLSCREEN)
+ SET_BUTTON_IMAGE(VIEWSOURCE)
+ SET_BUTTON_IMAGE(CONTENTS)
+ SET_BUTTON_IMAGE(ABOUT)
+ SET_BUTTON_IMAGE(PDF)
+ SET_BUTTON_IMAGE(PLAINTEXT)
+ SET_BUTTON_IMAGE(DRAWFILE)
+ SET_BUTTON_IMAGE(POSTSCRIPT)
+ SET_BUTTON_IMAGE(FIND)
+ SET_BUTTON_IMAGE(DOWNLOADS)
+ SET_BUTTON_IMAGE(SAVEWINDOWSIZE)
+ SET_BUTTON_IMAGE(TOGGLEDEBUGGING)
+ SET_BUTTON_IMAGE(SAVEBOXTREE)
+ SET_BUTTON_IMAGE(SAVEDOMTREE)
+ SET_BUTTON_IMAGE(LOCALHISTORY)
+ SET_BUTTON_IMAGE(GLOBALHISTORY)
+ SET_BUTTON_IMAGE(ADDBOOKMARKS)
+ SET_BUTTON_IMAGE(SHOWBOOKMARKS)
+ SET_BUTTON_IMAGE(OPENLOCATION)
+ SET_BUTTON_IMAGE(NEXTTAB)
+ SET_BUTTON_IMAGE(PREVTAB)
+ SET_BUTTON_IMAGE(GUIDE)
+ SET_BUTTON_IMAGE(INFO)
+#undef SET_BUTTON_IMAGE
+#define SET_BUTTON_IMAGE(p, q)\
+ if (cachetheme->searchimage[p] != NULL)\
+ theme->searchimage[p] = GTK_IMAGE(gtk_image_new_from_pixbuf(\
+ cachetheme->searchimage[p]));\
+ else if (cachetheme->image[q##_BUTTON] != NULL)\
+ theme->searchimage[p] = GTK_IMAGE(gtk_image_new_from_pixbuf(\
+ cachetheme->image[q##_BUTTON]));\
+ else\
+ theme->searchimage[p] = nsgtk_theme_image_default(\
+ PLACEHOLDER_BUTTON + p, s);
+ SET_BUTTON_IMAGE(0, BACK)
+ SET_BUTTON_IMAGE(1, FORWARD)
+ SET_BUTTON_IMAGE(2, CLOSEWINDOW)
+#undef SET_BUTTON_IMAGE
+ return theme;
+}
+
+void nsgtk_theme_prepare(void)
+{
+ if (current_theme_name == NULL)
+ return;
+ if (theme_cache_menu == NULL)
+ theme_cache_menu = malloc(sizeof(struct nsgtk_theme_cache));
+ if (theme_cache_toolbar == NULL)
+ theme_cache_toolbar = malloc(sizeof(struct nsgtk_theme_cache));
+ char *path = g_strconcat(res_dir_location, "themes/",
+ current_theme_name, "/", NULL);
+ char *filename;
+#define CACHE_IMAGE(p, q)\
+ filename = g_strconcat(path, #q, ".png", NULL);\
+ theme_cache_toolbar->image[p##_BUTTON] =\
+ gdk_pixbuf_new_from_file_at_size(filename, 24, 24,\
+ NULL);\
+ theme_cache_menu->image[p##_BUTTON] =\
+ gdk_pixbuf_new_from_file_at_size(filename, 16, 16,\
+ NULL);\
+ g_free(filename)
+ CACHE_IMAGE(BACK, back);
+ CACHE_IMAGE(HISTORY, history);
+ CACHE_IMAGE(FORWARD, forward);
+ CACHE_IMAGE(STOP, stop);
+ CACHE_IMAGE(RELOAD, reload);
+ CACHE_IMAGE(HOME, home);
+ CACHE_IMAGE(NEWWINDOW, newwindow);
+ CACHE_IMAGE(NEWTAB, newtab);
+ CACHE_IMAGE(OPENFILE, openfile);
+ CACHE_IMAGE(CLOSETAB, closetab);
+ CACHE_IMAGE(CLOSEWINDOW, closewindow);
+ CACHE_IMAGE(SAVEPAGE, savepage);
+ CACHE_IMAGE(PRINTPREVIEW, printpreview);
+ CACHE_IMAGE(PRINT, print);
+ CACHE_IMAGE(QUIT, quit);
+ CACHE_IMAGE(CUT, cut);
+ CACHE_IMAGE(COPY, copy);
+ CACHE_IMAGE(PASTE, paste);
+ CACHE_IMAGE(DELETE, delete);
+ CACHE_IMAGE(SELECTALL, selectall);
+ CACHE_IMAGE(PREFERENCES, preferences);
+ CACHE_IMAGE(ZOOMPLUS, zoomplus);
+ CACHE_IMAGE(ZOOMMINUS, zoomminus);
+ CACHE_IMAGE(ZOOMNORMAL, zoomnormal);
+ CACHE_IMAGE(FULLSCREEN, fullscreen);
+ CACHE_IMAGE(VIEWSOURCE, viewsource);
+ CACHE_IMAGE(CONTENTS, helpcontents);
+ CACHE_IMAGE(ABOUT, helpabout);
+ CACHE_IMAGE(PDF, pdf);
+ CACHE_IMAGE(PLAINTEXT, plaintext);
+ CACHE_IMAGE(DRAWFILE, drawfile);
+ CACHE_IMAGE(POSTSCRIPT, postscript);
+ CACHE_IMAGE(FIND, find);
+ CACHE_IMAGE(DOWNLOADS, downloads);
+ CACHE_IMAGE(SAVEWINDOWSIZE, savewindowsize);
+ CACHE_IMAGE(TOGGLEDEBUGGING, toggledebugging);
+ CACHE_IMAGE(SAVEBOXTREE, boxtree);
+ CACHE_IMAGE(SAVEDOMTREE, domtree);
+ CACHE_IMAGE(LOCALHISTORY, localhistory);
+ CACHE_IMAGE(GLOBALHISTORY, globalhistory);
+ CACHE_IMAGE(ADDBOOKMARKS, addbookmarks);
+ CACHE_IMAGE(SHOWBOOKMARKS, showbookmarks);
+ CACHE_IMAGE(OPENLOCATION, openlocation);
+ CACHE_IMAGE(NEXTTAB, nexttab);
+ CACHE_IMAGE(PREVTAB, prevtab);
+ CACHE_IMAGE(GUIDE, helpguide);
+ CACHE_IMAGE(INFO, helpinfo);
+#undef CACHE_IMAGE
+#define CACHE_IMAGE(p, q)\
+ filename = g_strconcat(path, #q, ".png", NULL);\
+ theme_cache_toolbar->searchimage[p] =\
+ gdk_pixbuf_new_from_file_at_size(filename, 24, 24,\
+ NULL);\
+ theme_cache_menu->searchimage[p] =\
+ gdk_pixbuf_new_from_file_at_size(filename, 16, 16,\
+ NULL);\
+ g_free(filename)
+ CACHE_IMAGE(0, searchback);
+ CACHE_IMAGE(1, searchforward);
+ CACHE_IMAGE(2, searchclose);
+#undef CACHE_IMAGE
+ g_free(path);
+}
+
+GtkImage *nsgtk_theme_image_default(int i, GtkIconSize s)
+{
+ char *imagefile;
+ GtkImage *image;
+ switch(i) {
+#define BUTTON_IMAGE(p, q)\
+ case p##_BUTTON:\
+ return GTK_IMAGE(gtk_image_new_from_stock(#q, s))
+ BUTTON_IMAGE(BACK, gtk-go-back);
+ case HISTORY_BUTTON:
+ imagefile = g_strconcat(res_dir_location,
+ "arrow_down_8x32.png", NULL);
+ image = GTK_IMAGE(gtk_image_new_from_file(imagefile));
+ g_free(imagefile);
+ return image;
+ BUTTON_IMAGE(FORWARD, gtk-go-forward);
+ BUTTON_IMAGE(STOP, gtk-stop);
+ BUTTON_IMAGE(RELOAD, gtk-refresh);
+ BUTTON_IMAGE(HOME, gtk-home);
+ BUTTON_IMAGE(NEWWINDOW, gtk-new);
+ BUTTON_IMAGE(NEWTAB, gtk-new);
+ BUTTON_IMAGE(OPENFILE, gtk-open);
+ BUTTON_IMAGE(CLOSETAB, gtk-close);
+ BUTTON_IMAGE(CLOSEWINDOW, gtk-close);
+ BUTTON_IMAGE(SAVEPAGE, gtk-save-as);
+ BUTTON_IMAGE(PRINTPREVIEW, gtk-print-preview);
+ BUTTON_IMAGE(PRINT, gtk-print);
+ BUTTON_IMAGE(QUIT, gtk-quit);
+ BUTTON_IMAGE(CUT, gtk-cut);
+ BUTTON_IMAGE(COPY, gtk-copy);
+ BUTTON_IMAGE(PASTE, gtk-paste);
+ BUTTON_IMAGE(DELETE, gtk-delete);
+ BUTTON_IMAGE(SELECTALL, gtk-select-all);
+ BUTTON_IMAGE(FIND, gtk-find);
+ BUTTON_IMAGE(PREFERENCES, gtk-preferences);
+ BUTTON_IMAGE(ZOOMPLUS, gtk-zoom-in);
+ BUTTON_IMAGE(ZOOMMINUS, gtk-zoom-out);
+ BUTTON_IMAGE(ZOOMNORMAL, gtk-zoom-100);
+ BUTTON_IMAGE(FULLSCREEN, gtk-fullscreen);
+ BUTTON_IMAGE(VIEWSOURCE, gtk-index);
+ BUTTON_IMAGE(CONTENTS, gtk-help);
+ BUTTON_IMAGE(ABOUT, gtk-about);
+#undef BUTTON_IMAGE
+ case (PLACEHOLDER_BUTTON):
+ return GTK_IMAGE(gtk_image_new_from_stock("gtk-go-back", s));
+ case (PLACEHOLDER_BUTTON + 1):
+ return GTK_IMAGE(gtk_image_new_from_stock("gtk-go-forward",
+ s));
+ case (PLACEHOLDER_BUTTON + 2):
+ return GTK_IMAGE(gtk_image_new_from_stock("gtk-close", s));
+ default:
+ imagefile = g_strconcat(res_dir_location, "themes/Alpha.png",
+ NULL);
+ image = GTK_IMAGE(gtk_image_new_from_file(imagefile));
+ g_free(imagefile);
+ return image;
+ }
+}
+
+
+#ifdef WITH_THEME_INSTALL
+/**
+ * Handle CONTENT_THEME
+ */
+void theme_install_start(struct content *c)
+{
+ assert(c);
+ assert(c->type == CONTENT_THEME);
+
+ /* stop theme sitting in memory cache */
+ c->fresh = false;
+ if (!content_add_user(c, theme_install_callback, 0, 0)) {
+ warn_user("NoMemory", 0);
+ return;
+ }
+}
+
+
+/**
+ * Callback for fetchcache() for theme install fetches.
+ */
+void theme_install_callback(content_msg msg, struct content *c,
+ intptr_t p1, intptr_t p2, union content_msg_data data)
+{
+ switch (msg) {
+ case CONTENT_MSG_READY:
+ break;
+
+ case CONTENT_MSG_DONE:
+ theme_install_content = c;
+ if (!theme_install_read(c->source_data, c->source_size))
+ warn_user("ThemeInvalid", 0);
+ break;
+
+ case CONTENT_MSG_ERROR:
+ warn_user(data.error, 0);
+ break;
+
+ case CONTENT_MSG_STATUS:
+ break;
+
+ case CONTENT_MSG_LOADING:
+ case CONTENT_MSG_REFORMAT:
+ case CONTENT_MSG_REDRAW:
+ case CONTENT_MSG_NEWPTR:
+ case CONTENT_MSG_LAUNCH:
+ case CONTENT_MSG_AUTH:
+ default:
+ assert(0);
+ break;
+ }
+}
+
+/**
+ * handler saves theme data as a local theme
+ */
+bool theme_install_read(char *data, unsigned long len)
+{
+ char *filename;
+ int handle = g_file_open_tmp("nsgtkthemeXXXXXX", &filename, NULL);
+ ssize_t written = write(handle, data, len);
+ close(handle);
+ if ((unsigned)written != len)
+ return false;
+
+ /* get name of theme; set as dirname */
+ char *dirname = g_strconcat(res_dir_location, "themes/", NULL);
+ if (dirname == NULL)
+ return false;
+
+ /* save individual files in theme */
+ filename = container_extract_theme(filename, dirname);
+ g_free(dirname);
+ if (filename == NULL)
+ return false;
+ nsgtk_theme_add(filename);
+
+ return true;
+}
+#endif
+
+struct nsgtk_theme *nsgtk_theme_default(GtkIconSize s)
+{
+ struct nsgtk_theme *theme = malloc(sizeof(struct nsgtk_theme));
+ for (int i = BACK_BUTTON; i <= PLACEHOLDER_BUTTON + 2; i++)
+ theme->image[i] = nsgtk_theme_image_default(i, s);
+ return theme;
+}
+
Index: gtk/gtk_toolbar.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/gtk_toolbar.c 2009-07-10 12:49:36.000000000 +0100
@@ -0,0 +1,957 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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 <gtk/gtk.h>
+#include "gtk/gtk_toolbar.h"
+#include "gtk/gtk_gui.h"
+#include "gtk/gtk_scaffolding.h"
+#include "gtk/gtk_search.h"
+#include "gtk/gtk_theme.h"
+#include "gtk/gtk_throbber.h"
+#include "gtk/gtk_window.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+
+static GtkTargetEntry entry = {(char *)"nsgtk_button_data",
+ GTK_TARGET_SAME_APP, 0};
+
+static bool edit_mode = false;
+
+struct nsgtk_toolbar_custom_store {
+ GtkWidget *window;
+/* currently includes all menu items that have stock images that could be
+ * added to buttons; once theming is added, could allow all menu items;
+ * until then, need to consider adding images to important menu items such
+ * as savetext, savepdf, find, downloads, debugrendering, localhistory,
+ * globalhistory, addbookmarks, editbookmarks */
+ GtkWidget *store_buttons[PLACEHOLDER_BUTTON];
+ GtkWidget *widgetvbox;
+ GtkWidget *currentbar;
+ char numberh;
+ GladeXML *glade;
+ int buttonlocations[PLACEHOLDER_BUTTON];
+ int currentbutton;
+ bool fromstore;
+};
+
+static struct nsgtk_toolbar_custom_store store;
+static struct nsgtk_toolbar_custom_store *window = &store;
+
+static void nsgtk_toolbar_close(struct gtk_scaffolding *g);
+static void nsgtk_toolbar_window_open(struct gtk_scaffolding *g);
+static void nsgtk_toolbar_customization_save(struct gtk_scaffolding *g);
+static void nsgtk_toolbar_add_item_to_toolbar(struct gtk_scaffolding *g, int i,
+ struct nsgtk_theme *theme);
+static bool nsgtk_toolbar_add_store_widget(GtkWidget *widget);
+static gboolean nsgtk_toolbar_data(GtkWidget *widget, GdkDragContext *context,
+ gint x, gint y, guint time, gpointer data);
+static gboolean nsgtk_toolbar_store_return(GtkWidget *widget, GdkDragContext *gdc,
gint x, gint y, guint time, gpointer data);
+static gboolean nsgtk_toolbar_action(GtkWidget *widget, GdkDragContext
+ *drag_context, gint x, gint y, guint time, gpointer data);
+gboolean nsgtk_toolbar_store_action(GtkWidget *widget, GdkDragContext *gdc,
+ gint x, gint y, guint time, gpointer data);
+static gboolean nsgtk_toolbar_move_complete(GtkWidget *widget, GdkDragContext
+ *gdc, gint x, gint y, GtkSelectionData *selection, guint info,
+ guint time, gpointer data);
+static void nsgtk_toolbar_clear(GtkWidget *widget, GdkDragContext *gdc, guint
+ time, gpointer data);
+static gboolean nsgtk_toolbar_delete(GtkWidget *widget, GdkEvent *event,
+ gpointer data);
+static gboolean nsgtk_toolbar_cancel_clicked(GtkWidget *widget, gpointer data);
+static gboolean nsgtk_toolbar_reset(GtkWidget *widget, gpointer data);
+static gboolean nsgtk_toolbar_persist(GtkWidget *widget, gpointer data);
+static void nsgtk_toolbar_cast(struct gtk_scaffolding *g);
+static GtkWidget *nsgtk_toolbar_make_widget(struct gtk_scaffolding *g, int i,
+ struct nsgtk_theme *theme);
+static void nsgtk_toolbar_set_handler(struct gtk_scaffolding *g, int i);
+static void nsgtk_toolbar_temp_connect(struct gtk_scaffolding *g, int i);
+static void nsgtk_toolbar_clear_toolbar(GtkWidget *widget, gpointer data);
+static int nsgtk_toolbar_get_id_at_location(struct gtk_scaffolding *g, int i);
+
+/**
+ * change behaviour of scaffoldings while editing toolbar
+ */
+void nsgtk_toolbar_customization_init(struct gtk_scaffolding *g)
+{
+ int i;
+ nsgtk_scaffolding *list = scaf_list;;
+ edit_mode = true;
+
+ while (list) {
+ g_signal_handler_block(GTK_WIDGET(
+ nsgtk_window_get_drawing_area(
+ nsgtk_scaffolding_top_level(list))),
+ nsgtk_window_get_signalhandler(
+ nsgtk_scaffolding_top_level(list), 0));
+ g_signal_handler_block(GTK_WIDGET(
+ nsgtk_window_get_drawing_area(
+ nsgtk_scaffolding_top_level(list))),
+ nsgtk_window_get_signalhandler(
+ nsgtk_scaffolding_top_level(list), 1));
+ gtk_widget_modify_bg(GTK_WIDGET(nsgtk_window_get_drawing_area(
+ nsgtk_scaffolding_top_level(list))),
+ GTK_STATE_NORMAL, &((GdkColor)
+ {0, 0xEEEE, 0xEEEE, 0xEEEE}));
+
+ if (list == g) {
+ list = nsgtk_scaffolding_iterate(list);
+ continue;
+ }
+ /* set sensitive for all gui_windows save g */
+ gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_window(
+ list)), FALSE);
+ list = nsgtk_scaffolding_iterate(list);
+ }
+ /* set sensitive for all of g save toolbar */
+ gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_menu_bar(g)),
+ FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_notebook(g)),
+ FALSE);
+
+ /* set editable aspect for toolbar */
+ gtk_container_foreach(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)),
+ nsgtk_toolbar_clear_toolbar, g);
+ nsgtk_toolbar_set_physical(g);
+ /* memorize button locations, set editable */
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ window->buttonlocations[i] = nsgtk_scaffolding_button(g, i)
+ ->location;
+ if ((window->buttonlocations[i] == -1) || (i == URL_BAR_ITEM))
+ continue;
+ gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM(
+ nsgtk_scaffolding_button(g, i)->button), TRUE);
+ gtk_drag_source_set(GTK_WIDGET(nsgtk_scaffolding_button(
+ g, i)->button), GDK_BUTTON1_MASK, &entry, 1,
+ GDK_ACTION_COPY);
+ nsgtk_toolbar_temp_connect(g, i);
+ }
+
+ /* add move button listeners */
+ g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
+ "drag-drop", G_CALLBACK(nsgtk_toolbar_data), g);
+ g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
+ "drag-data-received", G_CALLBACK(
+ nsgtk_toolbar_move_complete), g);
+ g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
+ "drag-motion", G_CALLBACK(nsgtk_toolbar_action), g);
+ g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
+ "drag-leave", G_CALLBACK(
+ nsgtk_toolbar_clear), g);
+
+ /* set data types */
+ gtk_drag_dest_set(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
+ GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
+ &entry, 1, GDK_ACTION_COPY);
+
+ /* open toolbar window */
+ nsgtk_toolbar_window_open(g);
+}
+
+/**
+ * create store window
+ */
+void nsgtk_toolbar_window_open(struct gtk_scaffolding *g)
+{
+ int x,y;
+ struct nsgtk_theme *theme =
+ nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
+ window->glade = glade_xml_new(glade_toolbar_file_location,
+ "toolbarwindow", NULL);
+ glade_xml_signal_autoconnect(window->glade);
+
+#define GET_TOOLWIDGET(p, q) window->p = glade_xml_get_widget(window->glade,\
+ #q)
+ GET_TOOLWIDGET(window, toolbarwindow);
+ GET_TOOLWIDGET(widgetvbox, widgetvbox);
+#undef GET_TOOLWIDGET
+
+ window->numberh = 6;
+ window->currentbutton = -1;
+ /* load toolbuttons */
+ /* add toolbuttons to window */
+ /* set event handlers */
+ for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ if (i == URL_BAR_ITEM)
+ continue;
+ window->store_buttons[i] =
+ nsgtk_toolbar_make_widget(g, i, theme);
+ nsgtk_toolbar_add_store_widget(window->store_buttons[i]);
+ g_signal_connect(window->store_buttons[i], "drag-data-get",
+ G_CALLBACK(
+ nsgtk_scaffolding_button(g, i)->dataplus), g);
+ }
+ free(theme);
+ gtk_window_set_transient_for(GTK_WINDOW(window->window),
+ nsgtk_scaffolding_window(g));
+ gtk_window_set_title(GTK_WINDOW(window->window), messages_get(
+ "gtkToolBarTitle"));
+ gtk_window_set_accept_focus(GTK_WINDOW(window->window), FALSE);
+ gtk_drag_dest_set(GTK_WIDGET(window->window), GTK_DEST_DEFAULT_MOTION |
+ GTK_DEST_DEFAULT_DROP, &entry, 1, GDK_ACTION_COPY);
+ gtk_widget_show_all(window->window);
+ gtk_window_set_position(GTK_WINDOW(window->window),
+ GTK_WIN_POS_CENTER_ON_PARENT);
+ gtk_window_get_position(nsgtk_scaffolding_window(g), &x, &y);
+ gtk_window_move(GTK_WINDOW(window->window), x, y + 100);
+ g_signal_connect(glade_xml_get_widget(window->glade, "cancelbutton"),
+ "clicked", G_CALLBACK(
+ nsgtk_toolbar_cancel_clicked), g);
+ g_signal_connect(glade_xml_get_widget(window->glade, "okbutton"),
+ "clicked", G_CALLBACK(nsgtk_toolbar_persist), g);
+ g_signal_connect(glade_xml_get_widget(window->glade, "resetbutton"),
+ "clicked", G_CALLBACK(nsgtk_toolbar_reset), g);
+ g_signal_connect(window->window, "delete-event",
+ G_CALLBACK(nsgtk_toolbar_delete), g);
+ g_signal_connect(window->window, "drag-drop",
+ G_CALLBACK(nsgtk_toolbar_store_return), g);
+ g_signal_connect(window->window, "drag-motion",
+ G_CALLBACK(nsgtk_toolbar_store_action), g);
+}
+
+/**
+ * when titlebar / alt-F4 window close event happens
+ */
+gboolean nsgtk_toolbar_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ edit_mode = false;
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ /* reset g->buttons->location */
+ for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ nsgtk_scaffolding_button(g, i)->location =
+ window->buttonlocations[i];
+ }
+ nsgtk_toolbar_set_physical(g);
+ nsgtk_toolbar_connect_all(g);
+ nsgtk_toolbar_close(g);
+ nsgtk_scaffolding_set_sensitivity(g);
+ gtk_widget_destroy(window->window);
+ return TRUE;
+}
+
+/**
+ * when cancel button is clicked
+ */
+gboolean nsgtk_toolbar_cancel_clicked(GtkWidget *widget, gpointer data)
+{
+ edit_mode = false;
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ /* reset g->buttons->location */
+ for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ nsgtk_scaffolding_button(g, i)->location =
+ window->buttonlocations[i];
+ }
+ nsgtk_toolbar_set_physical(g);
+ nsgtk_toolbar_connect_all(g);
+ nsgtk_toolbar_close(g);
+ nsgtk_scaffolding_set_sensitivity(g);
+ gtk_widget_destroy(window->window);
+ return TRUE;
+}
+
+/**
+ * when 'save settings' button is clicked
+ */
+gboolean nsgtk_toolbar_persist(GtkWidget *widget, gpointer data)
+{
+ edit_mode = false;
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ /* save state to file, update toolbars for all windows */
+ nsgtk_toolbar_customization_save(g);
+ nsgtk_toolbar_cast(g);
+ nsgtk_toolbar_set_physical(g);
+ nsgtk_toolbar_close(g);
+ gtk_widget_destroy(window->window);
+ return TRUE;
+}
+
+/**
+ * when 'reload defaults' button is clicked
+ */
+gboolean nsgtk_toolbar_reset(GtkWidget *widget, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ int i;
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++)
+ nsgtk_scaffolding_button(g, i)->location =
+ (i <= WEBSEARCH_ITEM) ? i : -1;
+ nsgtk_toolbar_set_physical(g);
+ for (i = BACK_BUTTON; i <= WEBSEARCH_ITEM; i++) {
+ if (i == URL_BAR_ITEM)
+ continue;
+ gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM(
+ nsgtk_scaffolding_button(g, i)->button), TRUE);
+ gtk_drag_source_set(GTK_WIDGET(
+ nsgtk_scaffolding_button(g, i)->button),
+ GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_COPY);
+ nsgtk_toolbar_temp_connect(g, i);
+ }
+ return TRUE;
+}
+
+/**
+ * set toolbar logical -> physical
+ */
+void nsgtk_toolbar_set_physical(struct gtk_scaffolding *g)
+{
+ int i;
+ struct nsgtk_theme *theme =
+ nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
+ /* simplest is to clear the toolbar then reload it from memory */
+ gtk_container_foreach(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)),
+ nsgtk_toolbar_clear_toolbar, g);
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++)
+ nsgtk_toolbar_add_item_to_toolbar(g, i, theme);
+ gtk_widget_show_all(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)));
+ free(theme);
+}
+
+/**
+ * physical update of all toolbars; resensitize
+ * \param g the 'front' scaffolding that called customize
+ */
+void nsgtk_toolbar_close(struct gtk_scaffolding *g)
+{
+ int i;
+ nsgtk_scaffolding *list = scaf_list;
+ while (list) {
+ struct nsgtk_theme *theme =
+ nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
+ /* clear toolbar */
+ gtk_container_foreach(GTK_CONTAINER(nsgtk_scaffolding_toolbar(
+ list)), nsgtk_toolbar_clear_toolbar, list);
+ /* then add items */
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ nsgtk_toolbar_add_item_to_toolbar(list, i, theme);
+ }
+ nsgtk_toolbar_connect_all(list);
+ gtk_widget_show_all(GTK_WIDGET(nsgtk_scaffolding_toolbar(
+ list)));
+ nsgtk_scaffolding_set_sensitivity(list);
+ gtk_widget_modify_bg(GTK_WIDGET(nsgtk_window_get_drawing_area(
+ nsgtk_scaffolding_top_level(list))),
+ GTK_STATE_NORMAL, &((GdkColor)
+ {0, 0xFFFF, 0xFFFF, 0xFFFF}));
+ g_signal_handler_unblock(GTK_WIDGET(
+ nsgtk_window_get_drawing_area(
+ nsgtk_scaffolding_top_level(list))),
+ nsgtk_window_get_signalhandler(
+ nsgtk_scaffolding_top_level(list), 0));
+ g_signal_handler_unblock(GTK_WIDGET(
+ nsgtk_window_get_drawing_area(
+ nsgtk_scaffolding_top_level(list))),
+ nsgtk_window_get_signalhandler(
+ nsgtk_scaffolding_top_level(list), 1));
+ if ((gui_window_get_browser_window(nsgtk_scaffolding_top_level(
+ list))->current_content != NULL) &&
+ (gui_window_get_browser_window(
+ nsgtk_scaffolding_top_level(list))->
+ current_content->url != NULL))
+ browser_window_refresh_url_bar(
+ gui_window_get_browser_window(
+ nsgtk_scaffolding_top_level(list)),
+ gui_window_get_browser_window(
+ nsgtk_scaffolding_top_level(list))->
+ current_content->url,
+ gui_window_get_browser_window(
+ nsgtk_scaffolding_top_level(list))->
+ frag_id);
+
+ if (list != g)
+ gtk_widget_set_sensitive(GTK_WIDGET(
+ nsgtk_scaffolding_window(list)), TRUE);
+ free(theme);
+ list = nsgtk_scaffolding_iterate(list);
+ }
+ gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_notebook(g)),
+ TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_menu_bar(g)),
+ TRUE);
+ gui_window_set_search_ico();
+}
+
+/**
+ * callback function to iterate toolbar's widgets
+ */
+void nsgtk_toolbar_clear_toolbar(GtkWidget *widget, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ gtk_container_remove(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)), widget);
+}
+
+/**
+ * add item to toolbar
+ * \param g the scaffolding whose toolbar an item is added to
+ * \param i the location in the toolbar
+ * the function should be called, when multiple items are being added,
+ * in ascending order
+ */
+void nsgtk_toolbar_add_item_to_toolbar(struct gtk_scaffolding *g, int i,
+ struct nsgtk_theme *theme)
+{
+ int q;
+ for (q = BACK_BUTTON; q < PLACEHOLDER_BUTTON; q++)
+ if (nsgtk_scaffolding_button(g, q)->location == i) {
+ nsgtk_scaffolding_button(g, q)->button = GTK_TOOL_ITEM(
+ nsgtk_toolbar_make_widget(g, q,
+ theme));
+ gtk_toolbar_insert(nsgtk_scaffolding_toolbar(g),
+ nsgtk_scaffolding_button(g, q)->button,
+ i);
+ break;
+ }
+}
+
+/**
+ * physically add widgets to store window
+ */
+bool nsgtk_toolbar_add_store_widget(GtkWidget *widget)
+{
+ if (window->numberh >= 6) {
+ window->currentbar = gtk_toolbar_new();
+ gtk_toolbar_set_style(GTK_TOOLBAR(window->currentbar),
+ GTK_TOOLBAR_BOTH);
+ gtk_toolbar_set_icon_size(GTK_TOOLBAR(window->currentbar),
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
+ gtk_box_pack_start(GTK_BOX(window->widgetvbox),
+ window->currentbar, FALSE, FALSE, 0);
+ window->numberh = 0;
+ }
+ gtk_widget_set_size_request(widget, 111, 70);
+ gtk_toolbar_insert(GTK_TOOLBAR(window->currentbar), GTK_TOOL_ITEM(
+ widget), window->numberh++);
+ gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM(widget), TRUE);
+ gtk_drag_source_set(widget, GDK_BUTTON1_MASK, &entry, 1,
+ GDK_ACTION_COPY);
+ gtk_widget_show_all(window->window);
+ return true;
+}
+
+/**
+ * called when a widget is dropped onto the toolbar
+ */
+gboolean nsgtk_toolbar_data(GtkWidget *widget, GdkDragContext *gdc, gint x,
+ gint y, guint time, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ int ind = gtk_toolbar_get_drop_index(nsgtk_scaffolding_toolbar(g),
+ x, y);
+ int q, i;
+ if (window->currentbutton == -1)
+ return TRUE;
+ struct nsgtk_theme *theme =
+ nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR);
+ if (nsgtk_scaffolding_button(g, window->currentbutton)->location
+ != -1) {
+ if (nsgtk_scaffolding_button(g, window->currentbutton)->
+ location < ind)
+ ind--;
+ gtk_container_remove(GTK_CONTAINER(
+ nsgtk_scaffolding_toolbar(g)), GTK_WIDGET(
+ nsgtk_scaffolding_button(g,
+ window->currentbutton)->button));
+ for (i = nsgtk_scaffolding_button(g, window->currentbutton)->
+ location + 1; i < PLACEHOLDER_BUTTON; i++) {
+ q = nsgtk_toolbar_get_id_at_location(g, i);
+ if (q == -1)
+ continue;
+ nsgtk_scaffolding_button(g, q)->location--;
+ }
+ nsgtk_scaffolding_button(g, window->currentbutton)->
+ location = -1;
+ }
+ nsgtk_scaffolding_button(g, window->currentbutton)->button =
+ GTK_TOOL_ITEM(nsgtk_toolbar_make_widget(g,
+ window->currentbutton, theme));
+ free(theme);
+ /* update logical schema */
+ nsgtk_scaffolding_reset_offset(g);
+ for (i = PLACEHOLDER_BUTTON - 1; i >= ind; i--) {
+ q = nsgtk_toolbar_get_id_at_location(g, i);
+ if (q == -1)
+ continue;
+ nsgtk_scaffolding_button(g, q)->location++;
+ }
+ nsgtk_scaffolding_button(g, window->currentbutton)->location = ind;
+
+ /* complete action */
+ gtk_toolbar_insert(nsgtk_scaffolding_toolbar(g),
+ nsgtk_scaffolding_button(g,
+ window->currentbutton)->button, ind);
+ gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM(
+ nsgtk_scaffolding_button(g,
+ window->currentbutton)->button), TRUE);
+ gtk_drag_source_set(GTK_WIDGET(
+ nsgtk_scaffolding_button(g,
+ window->currentbutton)->button),
+ GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_COPY);
+ nsgtk_toolbar_temp_connect(g, window->currentbutton);
+ gtk_widget_show_all(GTK_WIDGET(
+ nsgtk_scaffolding_button(g,
+ window->currentbutton)->button));
+ window->currentbutton = -1;
+ return TRUE;
+}
+
+gboolean nsgtk_toolbar_move_complete(GtkWidget *widget, GdkDragContext *gdc,
+ gint x, gint y, GtkSelectionData *selection, guint info, guint
+ time, gpointer data)
+{
+ return FALSE;
+}
+/**
+ * called when a widget is dropped onto the store window
+ */
+gboolean nsgtk_toolbar_store_return(GtkWidget *widget, GdkDragContext *gdc,
+ gint x, gint y, guint time, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ int q, i;
+
+ if ((window->fromstore) || (window->currentbutton == -1)) {
+ window->currentbutton = -1;
+ return FALSE;
+ }
+ if (nsgtk_scaffolding_button(g, window->currentbutton)->location
+ != -1) {
+ for (i = nsgtk_scaffolding_button(g, window->currentbutton)->
+ location + 1; i < PLACEHOLDER_BUTTON; i++) {
+ q = nsgtk_toolbar_get_id_at_location(g, i);
+ if (q == -1)
+ continue;
+ nsgtk_scaffolding_button(g, q)->location--;
+ }
+ gtk_container_remove(GTK_CONTAINER(
+ nsgtk_scaffolding_toolbar(g)), GTK_WIDGET(
+ nsgtk_scaffolding_button(g,
+ window->currentbutton)->button));
+ nsgtk_scaffolding_button(g, window->currentbutton)->location
+ = -1;
+ }
+ window->currentbutton = -1;
+ gtk_drag_finish(gdc, TRUE, TRUE, time);
+ return FALSE;
+}
+/**
+ * called when hovering an item above the toolbar
+ */
+gboolean nsgtk_toolbar_action(GtkWidget *widget, GdkDragContext *gdc, gint x,
+ gint y, guint time, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ GtkToolItem *item = gtk_tool_button_new(NULL, NULL);
+ gtk_toolbar_set_drop_highlight_item(nsgtk_scaffolding_toolbar(g),
+ GTK_TOOL_ITEM(item), gtk_toolbar_get_drop_index(
+ nsgtk_scaffolding_toolbar(g), x, y));
+ return FALSE;
+}
+
+/**
+ * called when hovering above the store
+ */
+gboolean nsgtk_toolbar_store_action(GtkWidget *widget, GdkDragContext *gdc,
+ gint x, gint y, guint time, gpointer data)
+{
+ return FALSE;
+}
+/**
+ * called when hovering stops
+ */
+void nsgtk_toolbar_clear(GtkWidget *widget, GdkDragContext *gdc, guint time,
+ gpointer data)
+{
+ gtk_toolbar_set_drop_highlight_item(GTK_TOOLBAR(widget), NULL, 0);
+}
+
+/**
+ * widget factory for creation of toolbar item widgets
+ * \param g the reference scaffolding
+ * \param i the id of the widget
+ * \param theme the theme to make the widgets from
+ */
+GtkWidget *nsgtk_toolbar_make_widget(struct gtk_scaffolding *g, int i,
+ struct nsgtk_theme *theme)
+{
+ GtkWidget *w = NULL, *image = NULL, *hbox = NULL, *entry = NULL;
+ char *label;
+ GtkStockItem item;
+ switch(i){
+#define MAKE_STOCKBUTTON(p, q) case p##_BUTTON:\
+ gtk_stock_lookup(#q, &item);\
+ label = remove_underscores(item.label, false);\
+ w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(\
+ theme->image[p##_BUTTON]),label));\
+ free(label);\
+ break
+ MAKE_STOCKBUTTON(HOME, gtk-home);
+ MAKE_STOCKBUTTON(BACK, gtk-go-back);
+ MAKE_STOCKBUTTON(FORWARD, gtk-go-forward);
+ MAKE_STOCKBUTTON(STOP, gtk-stop);
+ MAKE_STOCKBUTTON(RELOAD, gtk-refresh);
+#undef MAKE_STOCKBUTTON
+ case HISTORY_BUTTON:
+ w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
+ theme->image[HISTORY_BUTTON]), NULL));
+ break;
+ case URL_BAR_ITEM:
+ label = g_strconcat(res_dir_location, "netsurf-16x16.xpm", NULL);
+ hbox = gtk_hbox_new(FALSE, 0);
+ image = GTK_WIDGET(gtk_image_new_from_file(label));
+ g_free(label);
+ entry = GTK_WIDGET(gtk_entry_new());
+ gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+ w = GTK_WIDGET(gtk_tool_item_new());
+ gtk_container_add(GTK_CONTAINER(w), hbox);
+ gtk_tool_item_set_expand(GTK_TOOL_ITEM(w), TRUE);
+ break;
+ case THROBBER_ITEM:
+ if (edit_mode)
+ return GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
+ gtk_image_new_from_pixbuf(
+ nsgtk_throbber->framedata[0])),
+ "[throbber]"));
+ image = GTK_WIDGET(gtk_image_new_from_pixbuf(
+ nsgtk_throbber->framedata[0]));
+ w = GTK_WIDGET(gtk_tool_item_new());
+ gtk_container_add(GTK_CONTAINER(w), image);
+ break;
+ case WEBSEARCH_ITEM:
+ if (edit_mode)
+ return GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
+ gtk_image_new_from_stock("gtk-find",
+ GTK_ICON_SIZE_LARGE_TOOLBAR)),
+ "[websearch]"));
+ hbox = gtk_hbox_new(FALSE, 0);
+ image = GTK_WIDGET(gtk_image_new_from_stock("gtk-info",
+ GTK_ICON_SIZE_LARGE_TOOLBAR));
+ entry = GTK_WIDGET(gtk_entry_new());
+ gtk_widget_set_size_request(entry, 77, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+ w = GTK_WIDGET(gtk_tool_item_new());
+ gtk_container_add(GTK_CONTAINER(w), hbox);
+ break;
+#define MAKE_MENUBUTTON(p, q) case p##_BUTTON:\
+ label = remove_underscores(messages_get(#q), false);\
+ w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(\
+ theme->image[p##_BUTTON]), label));\
+ free(label);\
+ break
+ MAKE_MENUBUTTON(NEWWINDOW, gtkNewWindow);
+ MAKE_MENUBUTTON(NEWTAB, gtkNewTab);
+ MAKE_MENUBUTTON(OPENFILE, gtkOpenFile);
+ MAKE_MENUBUTTON(CLOSETAB, gtkCloseTab);
+ MAKE_MENUBUTTON(CLOSEWINDOW, gtkCloseWindow);
+ MAKE_MENUBUTTON(SAVEPAGE, gtkSavePage);
+ MAKE_MENUBUTTON(PRINTPREVIEW, gtkPrintPreview);
+ MAKE_MENUBUTTON(PRINT, gtkPrint);
+ MAKE_MENUBUTTON(QUIT, gtkQuit);
+ MAKE_MENUBUTTON(CUT, gtkCut);
+ MAKE_MENUBUTTON(COPY, gtkCopy);
+ MAKE_MENUBUTTON(PASTE, gtkPaste);
+ MAKE_MENUBUTTON(DELETE, gtkDelete);
+ MAKE_MENUBUTTON(SELECTALL, gtkSelectAll);
+ MAKE_MENUBUTTON(PREFERENCES, gtkPreferences);
+ MAKE_MENUBUTTON(ZOOMPLUS, gtkZoomPlus);
+ MAKE_MENUBUTTON(ZOOMMINUS, gtkZoomMinus);
+ MAKE_MENUBUTTON(ZOOMNORMAL, gtkZoomNormal);
+ MAKE_MENUBUTTON(FULLSCREEN, gtkFullScreen);
+ MAKE_MENUBUTTON(VIEWSOURCE, gtkViewSource);
+ MAKE_MENUBUTTON(CONTENTS, gtkContents);
+ MAKE_MENUBUTTON(ABOUT, gtkAbout);
+ MAKE_MENUBUTTON(PDF, gtkPDF);
+ MAKE_MENUBUTTON(PLAINTEXT, gtkPlainText);
+ MAKE_MENUBUTTON(DRAWFILE, gtkDrawFile);
+ MAKE_MENUBUTTON(POSTSCRIPT, gtkPostScript);
+ MAKE_MENUBUTTON(FIND, gtkFind);
+ MAKE_MENUBUTTON(DOWNLOADS, gtkDownloads);
+ MAKE_MENUBUTTON(SAVEWINDOWSIZE, gtkSaveWindowSize);
+ MAKE_MENUBUTTON(TOGGLEDEBUGGING, gtkToggleDebugging);
+ MAKE_MENUBUTTON(SAVEBOXTREE, gtkSaveBoxTree);
+ MAKE_MENUBUTTON(SAVEDOMTREE, gtkSaveDomTree);
+ MAKE_MENUBUTTON(LOCALHISTORY, gtkLocalHistory);
+ MAKE_MENUBUTTON(GLOBALHISTORY, gtkGlobalHistory);
+ MAKE_MENUBUTTON(ADDBOOKMARKS, gtkAddBookMarks);
+ MAKE_MENUBUTTON(SHOWBOOKMARKS, gtkShowBookMarks);
+ MAKE_MENUBUTTON(OPENLOCATION, gtkOpenLocation);
+ MAKE_MENUBUTTON(NEXTTAB, gtkNextTab);
+ MAKE_MENUBUTTON(PREVTAB, gtkPrevTab);
+ MAKE_MENUBUTTON(GUIDE, gtkGuide);
+ MAKE_MENUBUTTON(INFO, gtkUserInformation);
+ default:
+ break;
+#undef MAKE_MENUBUTTON
+ }
+ return w;
+}
+
+/**
+ * \return toolbar item id when a widget is an element of the scaffolding
+ * else -1
+ */
+int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct gtk_scaffolding
+ *g)
+{
+ int i;
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ if ((nsgtk_scaffolding_button(g, i)->location != -1)
+ && (widget == GTK_WIDGET(
+ nsgtk_scaffolding_button(g, i)->button))) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+/**
+ * \return toolbar item id from location when there is an item at that logical
+ * location; else -1
+ */
+int nsgtk_toolbar_get_id_at_location(struct gtk_scaffolding *g, int i)
+{
+ int q;
+ for (q = BACK_BUTTON; q < PLACEHOLDER_BUTTON; q++)
+ if (nsgtk_scaffolding_button(g, q)->location == i)
+ return q;
+ return -1;
+}
+
+void nsgtk_toolbar_connect_all(struct gtk_scaffolding *g)
+{
+ int q, i;
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ q = nsgtk_toolbar_get_id_at_location(g, i);
+ if (q == -1)
+ continue;
+ g_signal_connect(nsgtk_scaffolding_button(g, q)->button,
+ "size-allocate", G_CALLBACK(
+ nsgtk_scaffolding_toolbar_size_allocate), g);
+ nsgtk_toolbar_set_handler(g, q);
+ }
+}
+
+/**
+ * add handlers to factory widgets
+ * \param g the scaffolding to attach handlers to
+ * \param i the toolbar item id
+ */
+void nsgtk_toolbar_set_handler(struct gtk_scaffolding *g, int i)
+{
+ switch(i){
+ case URL_BAR_ITEM:
+ nsgtk_scaffolding_update_url_bar_ref(g);
+ g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_urlbar(g)),
+ "activate", G_CALLBACK(
+ nsgtk_window_url_activate_event), g);
+ g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_urlbar(g)),
+ "changed", G_CALLBACK(
+ nsgtk_window_url_changed), g);
+ break;
+ case THROBBER_ITEM:
+ nsgtk_scaffolding_update_throbber_ref(g);
+ break;
+ case WEBSEARCH_ITEM:
+ nsgtk_scaffolding_update_websearch_ref(g);
+ g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_websearch(g)),
+ "activate", G_CALLBACK(
+ nsgtk_websearch_activate), g);
+ g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_websearch(g)),
+ "focus-in-event", G_CALLBACK(
+ nsgtk_websearch_clear), g);
+ break;
+ default:
+ if (nsgtk_scaffolding_button(g, i)->bhandler != NULL)
+ g_signal_connect(nsgtk_scaffolding_button(g, i)->
+ button, "clicked",
+ G_CALLBACK(nsgtk_scaffolding_button(g,
+ i)->bhandler), g);
+ break;
+ }
+}
+
+#define DATAHANDLER(p, q)\
+gboolean nsgtk_toolbar_##p##_button_data(GtkWidget *widget, GdkDragContext\
+ *cont, GtkSelectionData *selection, guint info, guint time,\
+ gpointer data)\
+{\
+ window->currentbutton = q##_BUTTON;\
+ window->fromstore = true;\
+ return TRUE;\
+}\
+gboolean nsgtk_toolbar_##p##_toolbar_button_data(GtkWidget *widget,\
+ GdkDragContext *cont, GtkSelectionData *selection, guint info,\
+ guint time, gpointer data)\
+{\
+ window->currentbutton = q##_BUTTON;\
+ window->fromstore = false;\
+ return TRUE;\
+}
+
+DATAHANDLER(home, HOME)
+DATAHANDLER(forward, FORWARD)
+DATAHANDLER(back, BACK)
+DATAHANDLER(stop, STOP)
+DATAHANDLER(reload, RELOAD)
+DATAHANDLER(history, HISTORY)
+DATAHANDLER(newwindow, NEWWINDOW);
+DATAHANDLER(newtab, NEWTAB);
+DATAHANDLER(openfile, OPENFILE);
+DATAHANDLER(closetab, CLOSETAB);
+DATAHANDLER(closewindow, CLOSEWINDOW);
+DATAHANDLER(savepage, SAVEPAGE);
+DATAHANDLER(printpreview, PRINTPREVIEW);
+DATAHANDLER(print, PRINT);
+DATAHANDLER(quit, QUIT);
+DATAHANDLER(cut, CUT);
+DATAHANDLER(copy, COPY);
+DATAHANDLER(paste, PASTE);
+DATAHANDLER(delete, DELETE);
+DATAHANDLER(selectall, SELECTALL);
+DATAHANDLER(preferences, PREFERENCES);
+DATAHANDLER(zoomplus, ZOOMPLUS);
+DATAHANDLER(zoomminus, ZOOMMINUS);
+DATAHANDLER(zoomnormal, ZOOMNORMAL);
+DATAHANDLER(fullscreen, FULLSCREEN);
+DATAHANDLER(viewsource, VIEWSOURCE);
+DATAHANDLER(contents, CONTENTS);
+DATAHANDLER(about, ABOUT);
+DATAHANDLER(pdf, PDF);
+DATAHANDLER(plaintext, PLAINTEXT);
+DATAHANDLER(drawfile, DRAWFILE);
+DATAHANDLER(postscript, POSTSCRIPT);
+DATAHANDLER(find, FIND);
+DATAHANDLER(downloads, DOWNLOADS);
+DATAHANDLER(savewindowsize, SAVEWINDOWSIZE);
+DATAHANDLER(toggledebugging, TOGGLEDEBUGGING);
+DATAHANDLER(saveboxtree, SAVEBOXTREE);
+DATAHANDLER(savedomtree, SAVEDOMTREE);
+DATAHANDLER(localhistory, LOCALHISTORY);
+DATAHANDLER(globalhistory, GLOBALHISTORY);
+DATAHANDLER(addbookmarks, ADDBOOKMARKS);
+DATAHANDLER(showbookmarks, SHOWBOOKMARKS);
+DATAHANDLER(openlocation, OPENLOCATION);
+DATAHANDLER(nexttab, NEXTTAB);
+DATAHANDLER(prevtab, PREVTAB);
+DATAHANDLER(guide, GUIDE);
+DATAHANDLER(info, INFO);
+#undef DATAHANDLER
+#define DATAHANDLER(p, q)\
+gboolean nsgtk_toolbar_##p##_button_data(GtkWidget *widget, GdkDragContext\
+ *cont, GtkSelectionData *selection, guint info, guint time,\
+ gpointer data)\
+{\
+ window->currentbutton = q##_ITEM;\
+ window->fromstore = true;\
+ return TRUE;\
+}\
+gboolean nsgtk_toolbar_##p##_toolbar_button_data(GtkWidget *widget,\
+ GdkDragContext *cont, GtkSelectionData *selection, guint info,\
+ guint time, gpointer data)\
+{\
+ window->currentbutton = q##_ITEM;\
+ window->fromstore = false;\
+ return TRUE;\
+}
+DATAHANDLER(throbber, THROBBER);
+DATAHANDLER(websearch, WEBSEARCH);
+#undef DATAHANDLER
+
+/**
+ * connect temporary handler for toolbar edit events
+ */
+void nsgtk_toolbar_temp_connect(struct gtk_scaffolding *g, int i)
+{
+ if (i == URL_BAR_ITEM)
+ return;
+ g_signal_connect(nsgtk_scaffolding_button(g, i)->button,
+ "drag-data-get", G_CALLBACK(nsgtk_scaffolding_button(
+ g, i)->dataminus), g);
+}
+
+/**
+ * load toolbar settings from file
+ */
+void nsgtk_toolbar_customization_load(struct gtk_scaffolding *g)
+{
+ int i, ii;
+ char *val;
+ char buffer[SLEN("11;|") * 2 * PLACEHOLDER_BUTTON]; /* numbers 0-99 */
+ buffer[0] = '\0';
+ char *buffer1, *subbuffer, *ptr, *pter;
+ FILE *f = fopen(toolbar_indices_file_location, "r");
+ val = fgets(buffer, sizeof buffer, f);
+ if (val == NULL)
+ LOG(("empty read toolbar settings"));
+ fclose(f);
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++)
+ nsgtk_scaffolding_button(g, i)->location =
+ (i <= WEBSEARCH_ITEM) ? i : -1;
+ i = BACK_BUTTON;
+ ii = BACK_BUTTON;
+ buffer1 = strtok_r(buffer, "|", &ptr);
+ while (buffer1 != NULL) {
+ subbuffer = strtok_r(buffer1, ";", &pter);
+ i = atoi(subbuffer);
+ subbuffer = strtok_r(NULL, ";", &pter);
+ ii = atoi(subbuffer);
+ if ((i >= BACK_BUTTON) && (i < PLACEHOLDER_BUTTON) &&
+ (ii >= -1) && (ii < PLACEHOLDER_BUTTON)) {
+ nsgtk_scaffolding_button(g, i)->location = ii;
+ }
+ buffer1 = strtok_r(NULL, "|", &ptr);
+ }
+}
+
+/**
+ * cast toolbar settings to all scaffoldings referenced from the global linked
+ * list of gui_windows
+ */
+void nsgtk_toolbar_cast(struct gtk_scaffolding *g)
+{
+ int i;
+ nsgtk_scaffolding *list = scaf_list;
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++)
+ window->buttonlocations[i] = nsgtk_scaffolding_button(g, i)->
+ location;
+ while (list) {
+ if (list != g)
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++)
+ nsgtk_scaffolding_button(list, i)->location =
+ window->buttonlocations[i];
+ list = nsgtk_scaffolding_iterate(list);
+ }
+}
+
+/**
+ * save toolbar settings to file
+ */
+void nsgtk_toolbar_customization_save(struct gtk_scaffolding *g)
+{
+ int i;
+ FILE *f = fopen(toolbar_indices_file_location, "w");
+ if (f == NULL){
+ warn_user("gtkFileError", toolbar_indices_file_location);
+ return;
+ }
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ fprintf(f, "%d;%d|", i, nsgtk_scaffolding_button(g, i)->location);
+ }
+ fclose(f);
+}
+
Index: gtk/gtk_menu.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/gtk_menu.c 2009-07-10 12:49:36.000000000 +0100
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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 <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+#include <stdlib.h>
+#include "gtk/gtk_menu.h"
+#include "utils/messages.h"
+
+static struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *);
+static struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu(
+ GtkAccelGroup *);
+static struct nsgtk_images_submenu *nsgtk_menu_images_submenu(GtkAccelGroup *);
+static struct nsgtk_toolbars_submenu *nsgtk_menu_toolbars_submenu(
+ GtkAccelGroup *);
+static struct nsgtk_debugging_submenu *nsgtk_menu_debugging_submenu(
+ GtkAccelGroup *);
+
+static unsigned int key;
+static GdkModifierType mod;
+
+#define IMAGE_ITEM(p, q, r)\
+ ret->q##_menuitem = GTK_IMAGE_MENU_ITEM(\
+ gtk_image_menu_item_new_with_mnemonic(\
+ messages_get(#r)));\
+ gtk_accelerator_parse(messages_get(#r "Accel"), &key, &mod);\
+ if (key > 0)\
+ gtk_widget_add_accelerator(GTK_WIDGET(ret->q##_menuitem),\
+ "activate", group, key, mod, GTK_ACCEL_VISIBLE);\
+ gtk_menu_shell_append(GTK_MENU_SHELL(ret->p##_menu),\
+ GTK_WIDGET(ret->q##_menuitem));\
+ gtk_widget_show(GTK_WIDGET(ret->q##_menuitem))
+#define CHECK_ITEM(p, q, r)\
+ ret->q##_menuitem = GTK_CHECK_MENU_ITEM(\
+ gtk_check_menu_item_new_with_mnemonic(\
+ messages_get(#r)));\
+ gtk_menu_shell_append(GTK_MENU_SHELL(ret->p##_menu),\
+ GTK_WIDGET(ret->q##_menuitem));\
+ gtk_widget_show(GTK_WIDGET(ret->q##_menuitem))
+
+#define SET_SUBMENU(q)\
+ ret->q##_submenu = nsgtk_menu_##q##_submenu(group);\
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(ret->q##_menuitem),\
+ GTK_WIDGET(ret->q##_submenu->q##_menu))
+#define ADD_SEP(q)\
+ w = gtk_separator_menu_item_new();\
+ gtk_menu_shell_append(GTK_MENU_SHELL(ret->q##_menu), w);\
+ gtk_widget_show(w)
+struct nsgtk_file_menu *nsgtk_menu_file_menu(GtkAccelGroup *group)
+{
+ GtkWidget *w;
+ struct nsgtk_file_menu *ret = malloc(sizeof(struct nsgtk_file_menu));
+ ret->file_menu = GTK_MENU(gtk_menu_new());
+ IMAGE_ITEM(file, newwindow, gtkNewWindow);
+ IMAGE_ITEM(file, newtab, gtkNewTab);
+ IMAGE_ITEM(file, openfile, gtkOpenFile);
+ IMAGE_ITEM(file, closewindow, gtkCloseWindow);
+ ADD_SEP(file);
+ IMAGE_ITEM(file, savepage, gtkSavePage);
+ IMAGE_ITEM(file, export, gtkExport);
+ ADD_SEP(file);
+ IMAGE_ITEM(file, printpreview, gtkPrintPreview);
+ IMAGE_ITEM(file, print, gtkPrint);
+ ADD_SEP(file);
+ IMAGE_ITEM(file, quit, gtkQuit);
+ SET_SUBMENU(export);
+ return ret;
+}
+
+struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group)
+{
+ GtkWidget *w;
+ struct nsgtk_edit_menu *ret = malloc(sizeof(struct nsgtk_edit_menu));
+ ret->edit_menu = GTK_MENU(gtk_menu_new());
+ IMAGE_ITEM(edit, cut, gtkCut);
+ IMAGE_ITEM(edit, copy, gtkCopy);
+ IMAGE_ITEM(edit, paste, gtkPaste);
+ IMAGE_ITEM(edit, delete, gtkDelete);
+ ADD_SEP(edit);
+ IMAGE_ITEM(edit, selectall, gtkSelectAll);
+ ADD_SEP(edit);
+ IMAGE_ITEM(edit, find, gtkFind);
+ ADD_SEP(edit);
+ IMAGE_ITEM(edit, preferences, gtkPreferences);
+ return ret;
+}
+
+struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group)
+{
+ GtkWidget *w;
+ struct nsgtk_view_menu *ret = malloc(sizeof(struct nsgtk_view_menu));
+ ret->view_menu = GTK_MENU(gtk_menu_new());
+ IMAGE_ITEM(view, stop, gtkStop);
+ IMAGE_ITEM(view, reload, gtkReload);
+ ADD_SEP(view);
+ IMAGE_ITEM(view, scaleview, gtkScaleView);
+ IMAGE_ITEM(view, fullscreen, gtkFullScreen);
+ IMAGE_ITEM(view, viewsource, gtkViewSource);
+ ADD_SEP(view);
+ IMAGE_ITEM(view, images, gtkImages);
+ IMAGE_ITEM(view, toolbars, gtkToolbars);
+ ADD_SEP(view);
+ IMAGE_ITEM(view, downloads, gtkDownloads);
+ IMAGE_ITEM(view, savewindowsize, gtkSaveWindowSize);
+ IMAGE_ITEM(view, debugging, gtkDebugging);
+ SET_SUBMENU(scaleview);
+ SET_SUBMENU(images);
+ SET_SUBMENU(toolbars);
+ SET_SUBMENU(debugging);
+ return ret;
+}
+
+struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group)
+{
+ GtkWidget *w;
+ struct nsgtk_nav_menu *ret = malloc(sizeof(struct nsgtk_nav_menu));
+ ret->nav_menu = GTK_MENU(gtk_menu_new());
+ IMAGE_ITEM(nav, back, gtkBack);
+ IMAGE_ITEM(nav, forward, gtkForward);
+ IMAGE_ITEM(nav, home, gtkHome);
+ ADD_SEP(nav);
+ IMAGE_ITEM(nav, localhistory, gtkLocalHistory);
+ IMAGE_ITEM(nav, globalhistory, gtkGlobalHistory);
+ ADD_SEP(nav);
+ IMAGE_ITEM(nav, addbookmarks, gtkAddBookMarks);
+ IMAGE_ITEM(nav, showbookmarks, gtkShowBookMarks);
+ ADD_SEP(nav);
+ IMAGE_ITEM(nav, openlocation, gtkOpenLocation);
+ return ret;
+}
+
+struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group)
+{
+ struct nsgtk_tabs_menu *ret = malloc(sizeof(struct nsgtk_tabs_menu));
+ ret->tabs_menu = GTK_MENU(gtk_menu_new());
+ IMAGE_ITEM(tabs, nexttab, gtkNextTab);
+ IMAGE_ITEM(tabs, prevtab, gtkPrevTab);
+ IMAGE_ITEM(tabs, closetab, gtkCloseTab);
+ return ret;
+}
+
+struct nsgtk_help_menu *nsgtk_menu_help_menu(GtkAccelGroup *group)
+{
+ GtkWidget *w;
+ struct nsgtk_help_menu *ret = malloc(sizeof(struct nsgtk_help_menu));
+ ret->help_menu = GTK_MENU(gtk_menu_new());
+ IMAGE_ITEM(help, contents, gtkContents);
+ IMAGE_ITEM(help, guide, gtkGuide);
+ IMAGE_ITEM(help, info, gtkUserInformation);
+ ADD_SEP(help);
+ IMAGE_ITEM(help, about, gtkAbout);
+ return ret;
+}
+
+struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *group)
+{
+ struct nsgtk_export_submenu *ret = malloc(sizeof(struct
+ nsgtk_export_submenu));
+ ret->export_menu = GTK_MENU(gtk_menu_new());
+ IMAGE_ITEM(export, plaintext, gtkPlainText);
+ IMAGE_ITEM(export, drawfile, gtkDrawFile);
+ IMAGE_ITEM(export, postscript, gtkPostScript);
+ IMAGE_ITEM(export, pdf, gtkPDF);
+ return ret;
+}
+
+struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu(GtkAccelGroup
+ *group)
+{
+ struct nsgtk_scaleview_submenu *ret = malloc(sizeof(struct
+ nsgtk_scaleview_submenu));
+ ret->scaleview_menu = GTK_MENU(gtk_menu_new());
+ IMAGE_ITEM(scaleview, zoomplus, gtkZoomPlus);
+ IMAGE_ITEM(scaleview, zoomnormal, gtkZoomNormal);
+ IMAGE_ITEM(scaleview, zoomminus, gtkZoomMinus);
+ return ret;
+}
+struct nsgtk_images_submenu *nsgtk_menu_images_submenu(GtkAccelGroup *group)
+{
+ struct nsgtk_images_submenu *ret = malloc(sizeof(struct
+ nsgtk_images_submenu));
+ ret->images_menu = GTK_MENU(gtk_menu_new());
+ CHECK_ITEM(images, foregroundimages, gtkForegroundImages);
+ CHECK_ITEM(images, backgroundimages, gtkBackgroundImages);
+ return ret;
+}
+struct nsgtk_toolbars_submenu *nsgtk_menu_toolbars_submenu(GtkAccelGroup *group)
+{
+ struct nsgtk_toolbars_submenu *ret = malloc(sizeof(struct
+ nsgtk_toolbars_submenu));
+ ret->toolbars_menu = GTK_MENU(gtk_menu_new());
+ CHECK_ITEM(toolbars, menubar, gtkMenuBar);
+ gtk_check_menu_item_set_active(ret->menubar_menuitem, TRUE);
+ CHECK_ITEM(toolbars, toolbar, gtkToolBar);
+ gtk_check_menu_item_set_active(ret->toolbar_menuitem, TRUE);
+ CHECK_ITEM(toolbars, statusbar, gtkStatusBar);
+ gtk_check_menu_item_set_active(ret->statusbar_menuitem, TRUE);
+ return ret;
+}
+struct nsgtk_debugging_submenu *nsgtk_menu_debugging_submenu(GtkAccelGroup
+ *group)
+{
+ struct nsgtk_debugging_submenu *ret = malloc(sizeof(struct
+ nsgtk_debugging_submenu));
+ ret->debugging_menu = GTK_MENU(gtk_menu_new());
+ IMAGE_ITEM(debugging, toggledebugging, gtkToggleDebugging);
+ IMAGE_ITEM(debugging, saveboxtree, gtkSaveBoxTree);
+ IMAGE_ITEM(debugging, savedomtree, gtkSaveDomTree);
+ return ret;
+}
+
+#undef CHECK_ITEM
+#undef IMAGE_ITEM
+#undef SET_SUBMENU
+#undef ADD_SEP
+
Index: gtk/gtk_search.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/gtk_search.c 2009-07-10 12:49:36.000000000 +0100
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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
+ * Free text search (implementation)
+ */
+#include <ctype.h>
+#include <string.h>
+#include <gdk/gdkkeysyms.h>
+#include "gtk/gtk_search.h"
+#include "gtk/gtk_scaffolding.h"
+#include "gtk/gtk_window.h"
+#include "utils/config.h"
+#include "content/content.h"
+#include "desktop/browser.h"
+#include "desktop/gui.h"
+#include "desktop/search.h"
+#include "desktop/searchweb.h"
+#include "desktop/selection.h"
+#include "render/box.h"
+#include "render/html.h"
+#include "utils/config.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+
+void nsgtk_search_init(struct gtk_scaffolding *g);
+
+gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ nsgtk_search_init(g);
+ start_search(true);
+ return TRUE;
+}
+
+gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ nsgtk_search_init(g);
+ start_search(false);
+ return TRUE;
+}
+
+void nsgtk_search_init(struct gtk_scaffolding *g)
+{
+ struct content *c;
+
+ assert(gui_window_get_browser_window(nsgtk_scaffolding_top_level(g))
+ != NULL);
+
+ c = gui_window_get_browser_window(nsgtk_scaffolding_top_level(g))->
+ current_content;
+
+ if ((!c) || (c->type != CONTENT_HTML && c->type != CONTENT_TEXTPLAIN))
+ return;
+
+ search_current_window = gui_window_get_browser_window(
+ nsgtk_scaffolding_top_level(g));
+ search_insert = true;
+}
+
+gboolean nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ nsgtk_scaffolding_toggle_search_bar_visibility(g);
+ return TRUE;
+}
+
+gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
+{
+ gui_search_set_forward_state(false);
+ gui_search_set_back_state(false);
+ return TRUE;
+}
+
+gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ nsgtk_search_init(g);
+ start_search(true);
+ return FALSE;
+}
+
+gboolean nsgtk_search_entry_key(GtkWidget *widget, GdkEventKey *event,
+ gpointer data)
+{
+ if (event->keyval == GDK_Escape) {
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ nsgtk_scaffolding_toggle_search_bar_visibility(g);
+ }
+ return FALSE;
+}
+
+gboolean nsgtk_websearch_activate(GtkWidget *widget, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ temp_open_background = 0;
+ search_web_new_window(gui_window_get_browser_window(
+ nsgtk_scaffolding_top_level(g)),
+ (char *)gtk_entry_get_text(nsgtk_scaffolding_search(
+ g)->entry));
+ temp_open_background = -1;
+ return TRUE;
+}
+
+gboolean nsgtk_websearch_clear(GtkWidget *widget, GdkEventFocus *f,
+ gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ gtk_entry_set_text(nsgtk_scaffolding_search(g)->entry, "");
+ return FALSE;
+}
+
+void gui_search_set_status(bool found)
+{
+}
+
+void gui_search_set_hourglass(bool active)
+{
+}
+
+char *gui_search_get_string(void)
+{
+ struct gtk_scaffolding *g = nsgtk_get_scaffold(search_current_window->
+ window);
+ return (char *)gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry);
+}
+
+void gui_search_add_recent(const char *string)
+{
+ recent_search[0] = strdup(string);
+}
+
+void gui_search_set_forward_state(bool inactive)
+{
+ if (search_current_window) {
+ struct gtk_scaffolding *g = nsgtk_get_scaffold(
+ search_current_window->window);
+ gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_search(
+ g)->buttons[1]), inactive ? FALSE : TRUE);
+ }
+}
+
+void gui_search_set_back_state(bool inactive)
+{
+ if (search_current_window) {
+ struct gtk_scaffolding *g = nsgtk_get_scaffold(
+ search_current_window->window);
+ gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_search(
+ g)->buttons[0]), inactive ? FALSE : TRUE);
+ }
+}
+
+bool gui_search_get_case_sens(void)
+{
+ struct gtk_scaffolding *g = nsgtk_get_scaffold(search_current_window->
+ window);
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+ nsgtk_scaffolding_search(g)->caseSens)) ? true : false;
+}
+
+bool gui_search_get_show_all(void)
+{
+ struct gtk_scaffolding *g = nsgtk_get_scaffold(search_current_window->
+ window);
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+ nsgtk_scaffolding_search(g)->checkAll)) ? true : false;
+}
Index: gtk/gtk_theme.h
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/gtk_theme.h 2009-07-10 12:49:37.000000000 +0100
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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_THEME_H_
+#define _NETSURF_GTK_THEME_H_
+
+#include <gtk/gtk.h>
+#include "gtk/gtk_scaffolding.h"
+
+extern char *current_theme_name;
+
+struct nsgtk_theme {
+ GtkImage *image[PLACEHOLDER_BUTTON];
+ GtkImage *searchimage[3]; /* back, forward, close */
+ /* apng throbber element */
+};
+
+struct nsgtk_theme *nsgtk_theme_load(GtkIconSize s);
+void nsgtk_theme_add(const char *themename);
+void nsgtk_theme_init(void);
+void nsgtk_theme_prepare(void);
+void nsgtk_theme_implement(struct gtk_scaffolding *g);
+
+#endif
Index: gtk/gtk_toolbar.h
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/gtk_toolbar.h 2009-07-10 12:49:37.000000000 +0100
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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_TOOLBAR_H_
+#define _NETSURF_GTK_TOOLBAR_H_
+
+#include <gtk/gtk.h>
+#include "gtk/gtk_scaffolding.h"
+
+void nsgtk_toolbar_customization_init(nsgtk_scaffolding *g);
+void nsgtk_toolbar_init(nsgtk_scaffolding *g);
+void nsgtk_toolbar_customization_load(nsgtk_scaffolding *g);
+void nsgtk_toolbar_set_physical(nsgtk_scaffolding *g);
+void nsgtk_toolbar_connect_all(nsgtk_scaffolding *g);
+int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, nsgtk_scaffolding
+ *g);
+
+#define TOOLPROTO(q) gboolean nsgtk_toolbar_##q##_button_data(\
+ GtkWidget *widget, GdkDragContext *cont, GtkSelectionData\
+ *selection, guint info, guint time, gpointer data);\
+gboolean nsgtk_toolbar_##q##_toolbar_button_data(GtkWidget *widget,\
+ GdkDragContext *cont, GtkSelectionData *selection, guint info,\
+ guint time, gpointer data)
+TOOLPROTO(home);
+TOOLPROTO(back);
+TOOLPROTO(forward);
+TOOLPROTO(reload);
+TOOLPROTO(stop);
+TOOLPROTO(throbber);
+TOOLPROTO(websearch);
+TOOLPROTO(history);
+TOOLPROTO(newwindow);
+TOOLPROTO(newtab);
+TOOLPROTO(openfile);
+TOOLPROTO(closetab);
+TOOLPROTO(closewindow);
+TOOLPROTO(savepage);
+TOOLPROTO(pdf);
+TOOLPROTO(plaintext);
+TOOLPROTO(drawfile);
+TOOLPROTO(postscript);
+TOOLPROTO(printpreview);
+TOOLPROTO(print);
+TOOLPROTO(quit);
+TOOLPROTO(cut);
+TOOLPROTO(copy);
+TOOLPROTO(paste);
+TOOLPROTO(delete);
+TOOLPROTO(selectall);
+TOOLPROTO(find);
+TOOLPROTO(preferences);
+TOOLPROTO(zoomplus);
+TOOLPROTO(zoomminus);
+TOOLPROTO(zoomnormal);
+TOOLPROTO(fullscreen);
+TOOLPROTO(viewsource);
+TOOLPROTO(downloads);
+TOOLPROTO(localhistory);
+TOOLPROTO(globalhistory);
+TOOLPROTO(addbookmarks);
+TOOLPROTO(showbookmarks);
+TOOLPROTO(openlocation);
+TOOLPROTO(nexttab);
+TOOLPROTO(prevtab);
+TOOLPROTO(savewindowsize);
+TOOLPROTO(toggledebugging);
+TOOLPROTO(saveboxtree);
+TOOLPROTO(savedomtree);
+TOOLPROTO(contents);
+TOOLPROTO(guide);
+TOOLPROTO(info);
+TOOLPROTO(about);
+#undef TOOLPROTO
+
+#endif
Index: gtk/gtk_menu.h
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/gtk_menu.h 2009-07-10 12:49:38.000000000 +0100
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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_MENU_H_
+#define _NETSURF_GTK_MENU_H_
+
+#include <gtk/gtk.h>
+
+struct nsgtk_file_menu {
+ GtkMenu *file_menu;
+ GtkImageMenuItem *newwindow_menuitem;
+ GtkImageMenuItem *newtab_menuitem;
+ GtkImageMenuItem *openfile_menuitem;
+ GtkImageMenuItem *closewindow_menuitem;
+ GtkImageMenuItem *savepage_menuitem;
+ GtkImageMenuItem *export_menuitem;
+ struct nsgtk_export_submenu *export_submenu;
+ GtkImageMenuItem *printpreview_menuitem;
+ GtkImageMenuItem *print_menuitem;
+ GtkImageMenuItem *quit_menuitem;
+};
+
+struct nsgtk_edit_menu {
+ GtkMenu *edit_menu;
+ GtkImageMenuItem *cut_menuitem;
+ GtkImageMenuItem *copy_menuitem;
+ GtkImageMenuItem *paste_menuitem;
+ GtkImageMenuItem *delete_menuitem;
+ GtkImageMenuItem *selectall_menuitem;
+ GtkImageMenuItem *find_menuitem;
+ GtkImageMenuItem *preferences_menuitem;
+};
+
+struct nsgtk_view_menu {
+ GtkMenu *view_menu;
+ GtkImageMenuItem *stop_menuitem;
+ GtkImageMenuItem *reload_menuitem;
+ GtkImageMenuItem *scaleview_menuitem;
+ struct nsgtk_scaleview_submenu *scaleview_submenu;
+ GtkImageMenuItem *fullscreen_menuitem;
+ GtkImageMenuItem *viewsource_menuitem;
+ GtkImageMenuItem *images_menuitem;
+ struct nsgtk_images_submenu *images_submenu;
+ GtkImageMenuItem *toolbars_menuitem;
+ struct nsgtk_toolbars_submenu *toolbars_submenu;
+ GtkImageMenuItem *downloads_menuitem;
+ GtkImageMenuItem *savewindowsize_menuitem;
+ GtkImageMenuItem *debugging_menuitem;
+ struct nsgtk_debugging_submenu *debugging_submenu;
+};
+
+struct nsgtk_nav_menu {
+ GtkMenu *nav_menu;
+ GtkImageMenuItem *back_menuitem;
+ GtkImageMenuItem *forward_menuitem;
+ GtkImageMenuItem *home_menuitem;
+ GtkImageMenuItem *localhistory_menuitem;
+ GtkImageMenuItem *globalhistory_menuitem;
+ GtkImageMenuItem *addbookmarks_menuitem;
+ GtkImageMenuItem *showbookmarks_menuitem;
+ GtkImageMenuItem *openlocation_menuitem;
+};
+
+struct nsgtk_tabs_menu {
+ GtkMenu *tabs_menu;
+ GtkImageMenuItem *nexttab_menuitem;
+ GtkImageMenuItem *prevtab_menuitem;
+ GtkImageMenuItem *closetab_menuitem;
+};
+
+struct nsgtk_help_menu {
+ GtkMenu *help_menu;
+ GtkImageMenuItem *contents_menuitem;
+ GtkImageMenuItem *guide_menuitem;
+ GtkImageMenuItem *info_menuitem;
+ GtkImageMenuItem *about_menuitem;
+};
+
+struct nsgtk_export_submenu {
+ GtkMenu *export_menu;
+ GtkImageMenuItem *plaintext_menuitem;
+ GtkImageMenuItem *drawfile_menuitem;
+ GtkImageMenuItem *postscript_menuitem;
+ GtkImageMenuItem *pdf_menuitem;
+};
+
+struct nsgtk_scaleview_submenu {
+ GtkMenu *scaleview_menu;
+ GtkImageMenuItem *zoomplus_menuitem;
+ GtkImageMenuItem *zoomminus_menuitem;
+ GtkImageMenuItem *zoomnormal_menuitem;
+};
+
+struct nsgtk_images_submenu {
+ GtkMenu *images_menu;
+ GtkCheckMenuItem *foregroundimages_menuitem;
+ GtkCheckMenuItem *backgroundimages_menuitem;
+};
+
+struct nsgtk_toolbars_submenu {
+ GtkMenu *toolbars_menu;
+ GtkCheckMenuItem *menubar_menuitem;
+ GtkCheckMenuItem *toolbar_menuitem;
+ GtkCheckMenuItem *statusbar_menuitem;
+};
+
+struct nsgtk_debugging_submenu {
+ GtkMenu *debugging_menu;
+ GtkImageMenuItem *toggledebugging_menuitem;
+ GtkImageMenuItem *saveboxtree_menuitem;
+ GtkImageMenuItem *savedomtree_menuitem;
+};
+
+struct nsgtk_file_menu *nsgtk_menu_file_menu(GtkAccelGroup *group);
+struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group);
+struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group);
+struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group);
+struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group);
+struct nsgtk_help_menu *nsgtk_menu_help_menu(GtkAccelGroup *group);
+
+#endif
Index: gtk/gtk_search.h
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/gtk_search.h 2009-07-10 12:49:38.000000000 +0100
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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_SEARCH_H_
+#define _NETSURF_GTK_SEARCH_H_
+
+#include <gtk/gtk.h>
+#include "gtk/gtk_scaffolding.h"
+
+void nsgtk_search_bar_toggle_visibility(struct gtk_scaffolding * g);
+gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data);
+gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data);
+gboolean nsgtk_search_entry_key(GtkWidget *widget, GdkEventKey *event,
+ gpointer data);
+gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data);
+gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data);
+gboolean nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data);
+gboolean nsgtk_websearch_activate(GtkWidget *widget, gpointer data);
+gboolean nsgtk_websearch_clear(GtkWidget *widget, GdkEventFocus *f,
+ gpointer data);
+
+#endif
Index: gtk/res/warning.glade
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/res/warning.glade 2009-07-10 12:49:47.000000000 +0100
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+ <widget class="GtkWindow" id="wndWarning">
+ <property name="title" translatable="yes">Warning from
NetSurf</property>
+ <property name="window_position">GTK_WIN_POS_CENTER</property>
+ <property name="icon_name">gtk-dialog-warning</property>
+ <property
name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="urgency_hint">True</property>
+ <child>
+ <widget class="GtkVBox" id="vbox32">
+ <property name="visible">True</property>
+ <property name="border_width">2</property>
+ <child>
+ <widget class="GtkHBox" id="hbox30">
+ <property name="visible">True</property>
+ <property name="border_width">3</property>
+ <child>
+ <widget class="GtkImage" id="image519">
+ <property name="visible">True</property>
+ <property name="xpad">12</property>
+ <property name="icon_size">6</property>
+ <property
name="icon_name">gtk-dialog-warning</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="labelWarning">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Help
help help! I'm being held prisoner by a bunch of RISC OS zealots!</property>
+ <property name="wrap">True</property>
+ </widget>
+ <packing>
+ <property name="padding">1</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkHSeparator" id="hseparator2">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">3</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox2">
+ <property name="visible">True</property>
+ <property
name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton" id="button14">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="gtk_widget_hide"
object="wndWarning"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Index: gtk/res/login.glade
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/res/login.glade 2009-07-10 12:49:47.000000000 +0100
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+ <widget class="GtkDialog" id="wndLogin">
+ <property name="title" translatable="yes">Site
Authentication</property>
+ <property
name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property>
+ <property
name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox12">
+ <property name="visible">True</property>
+ <property name="border_width">3</property>
+ <child>
+ <widget class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property
name="yalign">0.10000000149011612</property>
+ <property name="xpad">12</property>
+ <property name="icon_size">6</property>
+ <property
name="icon_name">gtk-dialog-authentication</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTable" id="table5">
+ <property name="visible">True</property>
+ <property name="border_width">1</property>
+ <property name="n_rows">4</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">11</property>
+ <property name="row_spacing">10</property>
+ <child>
+ <widget class="GtkLabel"
id="labelLoginHost">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label"
translatable="yes">moo.yoo.com</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label57">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label"
translatable="yes">Password</property>
+ </widget>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label56">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label"
translatable="yes">Username</property>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label54">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label"
translatable="yes">Host</property>
+ </widget>
+ <packing>
+ <property name="x_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label55">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label"
translatable="yes">Realm</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="labelLoginRealm">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label"
translatable="yes">my sekr3t area</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry"
id="entryLoginPass">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="visibility">False</property>
+ <property
name="activates_default">True</property>
+ <property name="text"
translatable="yes">opensesame</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry"
id="entryLoginUser">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="text"
translatable="yes">sesame</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">1</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox"
id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property
name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton" id="buttonLoginCan">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="buttonLoginOK">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="response_id">-5</property>
+ <child>
+ <widget class="GtkAlignment"
id="alignment14">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <widget class="GtkHBox" id="hbox11">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkImage"
id="image2">
+ <property
name="visible">True</property>
+ <property
name="stock">gtk-ok</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label49">
+ <property
name="visible">True</property>
+ <property name="label"
translatable="yes">Login</property>
+ <property
name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Index: gtk/res/themes
===================================================================
Index: gtk/res/themes/gtk+
===================================================================
Index: gtk/res/themes/gtk+/print.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/print.png differ
Index: gtk/res/themes/gtk+/closetab.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/closetab.png differ
Index: gtk/res/themes/gtk+/zoomnormal.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/zoomnormal.png differ
Index: gtk/res/themes/gtk+/closewindow.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/closewindow.png differ
Index: gtk/res/themes/gtk+/printpreview.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/printpreview.png differ
Index: gtk/res/themes/gtk+/zoomminus.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/zoomminus.png differ
Index: gtk/res/themes/gtk+/back.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/back.png differ
Index: gtk/res/themes/gtk+/preferences.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/preferences.png differ
Index: gtk/res/themes/gtk+/history.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/history.png differ
Index: gtk/res/themes/gtk+/openfile.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/openfile.png differ
Index: gtk/res/themes/gtk+/delete.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/delete.png differ
Index: gtk/res/themes/gtk+/fullscreen.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/fullscreen.png differ
Index: gtk/res/themes/gtk+/forward.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/forward.png differ
Index: gtk/res/themes/gtk+/reload.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/reload.png differ
Index: gtk/res/themes/gtk+/helpcontents.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/helpcontents.png differ
Index: gtk/res/themes/gtk+/info
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/res/themes/gtk+/info 2009-07-10 12:49:47.000000000 +0100
@@ -0,0 +1,81 @@
+This file is part of NetSurf,
http://www.netsurf-browser.org/
+
+The images in this theme folder 'gtk+' are from the gtk stock image set
+http://library.gnome.org/devel/gtk/unstable/gtk-Stock-Items.html
+
+the image history.png is [for what it's worth!] Copyright 2009 Mark Benjamin
+<netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+
+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/>.
+
+*** Instructions for theming ***
+
+to create a theme, make a folder, whose name is the name of the theme;
+put in the folder, a set of png images for the toolbuttons;
+the names of the images should be a subset of the list
+
+ back.png,
+ history.png,
+ forward.png,
+ stop.png,
+ reload.png,
+ home.png,
+ newwindow.png,
+ newtab.png,
+ openfile.png,
+ closetab.png,
+ closewindow.png,
+ savepage.png,
+ pdf.png,
+ plaintext.png,
+ drawfile.png,
+ postscript.png,
+ printpreview.png,
+ print.png,
+ quit.png,
+ cut.png,
+ copy.png,
+ paste.png,
+ delete.png,
+ selectall.png,
+ find.png,
+ preferences.png,
+ zoomplus.png,
+ zoomminus.png,
+ zoomnormal.png,
+ fullscreen.png,
+ viewsource.png,
+ downloads.png,
+ savewindowsize.png,
+ toggledebugging.png,
+ saveboxtree.png,
+ savedomtree.png,
+ localhistory.png,
+ globalhistory.png,
+ addbookmarks.png,
+ showbookmarks.png,
+ openlocation.png,
+ nexttab.png,
+ prevtab.png,
+ contents.png,
+ guide.png,
+ info.png,
+ about.png,
+ searchback.png,
+ searchforward.png,
+ searchclose.png
+
+for local theming, the folder may be placed directly [as a subfolder] into the
netsurf/gtk/res/themes folder; then 'add theme' from the preferences->advanced
tab;
+
+for downloadable themes, compile netsurf/utils/container.c according to the instructions
in the header of that file; make a netsurf container of the folder, serve it as
content-type "application/x-netsurf-theme"; browse to it in NetSurf, then
NetSurf should automatically install it
+
Index: gtk/res/themes/gtk+/selectall.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/selectall.png differ
Index: gtk/res/themes/gtk+/copy.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/copy.png differ
Index: gtk/res/themes/gtk+/paste.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/paste.png differ
Index: gtk/res/themes/gtk+/newtab.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/newtab.png differ
Index: gtk/res/themes/gtk+/newwindow.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/newwindow.png differ
Index: gtk/res/themes/gtk+/quit.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/quit.png differ
Index: gtk/res/themes/gtk+/helpabout.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/helpabout.png differ
Index: gtk/res/themes/gtk+/stop.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/stop.png differ
Index: gtk/res/themes/gtk+/home.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/home.png differ
Index: gtk/res/themes/gtk+/zoomplus.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/zoomplus.png differ
Index: gtk/res/themes/gtk+/cut.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/cut.png differ
Index: gtk/res/themes/gtk+/savepage.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/savepage.png differ
Index: gtk/res/themes/gtk+/viewsource.png
===================================================================
Binary files /dev/null and gtk/res/themes/gtk+/viewsource.png differ
Index: gtk/res/themes/Alpha.png
===================================================================
Binary files /dev/null and gtk/res/themes/Alpha.png differ
Index: gtk/res/default.ico
===================================================================
Binary files /dev/null and gtk/res/default.ico differ
Index: gtk/res/themelist
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/res/themelist 2009-07-10 12:49:47.000000000 +0100
@@ -0,0 +1,2 @@
+gtk default theme
+gtk+
Index: gtk/res/toolbarIndices
===================================================================
Index: gtk/res/ssl.glade
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/res/ssl.glade 2009-07-10 12:49:52.000000000 +0100
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+ <widget class="GtkDialog" id="wndSSLProblem">
+ <property name="border_width">1</property>
+ <property name="title" translatable="yes">SSL certificate
problem</property>
+ <property name="modal">True</property>
+ <property
name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox3">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox15">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkImage" id="image6">
+ <property name="visible">True</property>
+ <property name="yalign">0</property>
+ <property name="icon_size">6</property>
+ <property
name="icon_name">gtk-dialog-warning</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox13">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkLabel" id="label62">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">NetSurf failed to verify the authenticity of an SSL
certificate. Please verify the details presented below.</property>
+ <property
name="justify">GTK_JUSTIFY_CENTER</property>
+ <property name="wrap">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkFrame" id="frame13">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="label_xalign">0</property>
+ <child>
+ <widget class="GtkAlignment"
id="alignment17">
+ <property name="visible">True</property>
+ <property
name="left_padding">12</property>
+ <child>
+ <widget class="GtkScrolledWindow"
id="scrolledwindow1">
+ <property
name="visible">True</property>
+ <property
name="can_focus">True</property>
+ <property
name="shadow_type">GTK_SHADOW_IN</property>
+ <child>
+ <widget class="GtkTextView"
id="textview1">
+ <property
name="height_request">200</property>
+ <property
name="visible">True</property>
+ <property
name="can_focus">True</property>
+ <property
name="editable">False</property>
+ <property name="text"
translatable="yes">(not implemented)</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label63">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes"><b>Certificate
chain</b></property>
+ <property
name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property
name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox"
id="dialog-action_area3">
+ <property name="visible">True</property>
+ <property
name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton" id="sslreject">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="response_id">-6</property>
+ <child>
+ <widget class="GtkAlignment"
id="alignment16">
+ <property name="visible">True</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <widget class="GtkHBox" id="hbox14">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkImage"
id="image5">
+ <property
name="visible">True</property>
+ <property
name="stock">gtk-cancel</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label61">
+ <property
name="visible">True</property>
+ <property name="label"
translatable="yes">Reject</property>
+ <property
name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="sslaccept">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="response_id">-5</property>
+ <child>
+ <widget class="GtkAlignment"
id="alignment15">
+ <property name="visible">True</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <widget class="GtkHBox" id="hbox13">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkImage"
id="image4">
+ <property
name="visible">True</property>
+ <property
name="stock">gtk-apply</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label60">
+ <property
name="visible">True</property>
+ <property name="label"
translatable="yes">Accept</property>
+ <property
name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Index: gtk/res/password.glade
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/res/password.glade 2009-07-10 12:49:52.000000000 +0100
@@ -0,0 +1,274 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+ <widget class="GtkWindow" id="wndPDFPassword">
+ <property name="title" translatable="yes">PDF
Password</property>
+ <property name="modal">True</property>
+ <property name="window_position">GTK_WIN_POS_CENTER</property>
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="yalign">0.10000000149011612</property>
+ <property name="xpad">12</property>
+ <property name="icon_size">6</property>
+ <property
name="icon_name">gtk-dialog-authentication</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <child>
+ <widget class="GtkLabel" id="labelInfo">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Write
and confirm passwords:</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <child>
+ <widget class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Owner password:</property>
+ <property name="width_chars">15</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry"
id="entryPDFOwnerPassword">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">20</property>
+ <property name="visibility">False</property>
+ <property name="width_chars">20</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Repeat password:</property>
+ <property name="width_chars">15</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry"
id="entryPDFOwnerPassword1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">20</property>
+ <property name="visibility">False</property>
+ <property name="width_chars">20</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox4">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">User password:</property>
+ <property name="width_chars">15</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry"
id="entryPDFUserPassword">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">20</property>
+ <property name="visibility">False</property>
+ <property name="width_chars">20</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox5">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <child>
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Repeat password:</property>
+ <property name="width_chars">15</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry"
id="entryPDFUserPassword1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">20</property>
+ <property name="visibility">False</property>
+ <property name="width_chars">20</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="spacing">10</property>
+ <property
name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton"
id="buttonPDFSetPassword">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkHBox" id="hbox7">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkImage"
id="image7">
+ <property
name="visible">True</property>
+ <property
name="stock">gtk-ok</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label8">
+ <property
name="visible">True</property>
+ <property name="label"
translatable="yes">Set password</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton"
id="buttonPDFNoPassword">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkAlignment"
id="alignment1">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox6">
+ <property
name="visible">True</property>
+ <child>
+ <widget class="GtkImage"
id="image8">
+ <property
name="visible">True</property>
+ <property
name="stock">gtk-cancel</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label9">
+ <property
name="visible">True</property>
+ <property name="label"
translatable="yes">No password</property>
+ </widget>
+ <packing>
+ <property
name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Index: gtk/res/toolbar.glade
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/res/toolbar.glade 2009-07-10 12:49:52.000000000 +0100
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--Generated with glade3 3.4.5 on Tue Jun 9 08:21:40 2009 -->
+<glade-interface>
+ <widget class="GtkWindow" id="toolbarwindow">
+ <property name="width_request">700</property>
+ <property name="height_request">450</property>
+ <child>
+ <widget class="GtkVBox" id="windowvbox">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkLabel" id="toolbarlabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">move
items from store to toolbar rearrange items in toolbar move items from toolbar
to store</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkScrolledWindow"
id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property
name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property
name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <child>
+ <widget class="GtkViewport" id="viewport1">
+ <property name="visible">True</property>
+ <property
name="resize_mode">GTK_RESIZE_QUEUE</property>
+ <child>
+ <widget class="GtkVBox" id="widgetvbox">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="buttonhbox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <widget class="GtkButton" id="resetbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkHBox" id="button1hbox">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property
name="stock">gtk-refresh</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="refreshbuttonlabel">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">reset default</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">10</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <widget class="GtkButton" id="okbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label"
translatable="yes">gtk-apply</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">10</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="cancelbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label"
translatable="yes">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Index: gtk/res/SearchEngines
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ gtk/res/SearchEngines 2009-07-10 12:49:52.000000000 +0100
@@ -0,0 +1,20 @@
+Google|www.google.com|http://www.google.com/search?q=%s|http://www.google.com/favicon.ico|
+Yahoo|search.yahoo.com|http://search.yahoo.com/search?p=%s|http://www.yahoo.com/favicon.ico|
+Bing|www.bing.com|http://www.bing.com/search?q=%s|http://www.bing.com/favicon.ico|
+Business.com|www.business.com|http://www.business.com/search/rslt_default.asp?query=%s|http://www.business.com/favicon.ico|
+Omgili|www.omgili.com|http://www.omgili.com/AAAAA/%s.html|http://www.omgili.com/favicon.ico|
+BBC
News|search.bbc.co.uk|http://search.bbc.co.uk/search?q=%s&tab=ns|http://news.bbc.co.uk/favicon.ico|
+Ubuntu
Packages|packages.ubuntu.com|http://packages.ubuntu.com/search?keywords=%...
+Creative
Commons|creativecommons.org|http://creativecommons.org/?s=%s|http://creat...
+Ask.com|www.ask.com|http://www.ask.com/web?q=%s|http://www.ask.com/favicon.ico|
+Answers.com|www.answers.com|http://www.answers.com/%s|http://www.answers.com/favicon.ico|
+Dictionary.com|dictionary.reference.com|http://dictionary.reference.com/browse/%s?jss=0|http://dictionary.reference.com/favicon.ico|
+Youtube|www.youtube.com|http://www.youtube.com/results?search_query=%s|http://www.youtube.com/favicon.ico|
+AeroMp3|www.aeromp3.com|http://www.aeromp3.com/search?q=%s|http://www.aeromp3.com/favicon.ico|
+AOL|search.aol.com|http://search.aol.com/aol/search?query=%s|http://www.aol.com/favicon.ico|
+Baidu|www.baidu.com|http://www.baidu.com/s?wd=%s|http://www.baidu.com/favicon.ico|
+Amazon|www.amazon.com|http://www.amazon.com/s/ref=nb_ss_gw?field-keywords=%s|http://www.amazon.com/favicon.ico|
+Ebay|shop.ebay.com|http://shop.ebay.com/items/%s|http://www.ebay.com/favicon.ico|
+IMDB|www.imdb.com|http://www.imdb.com/find?q=%s|http://www.imdb.com/favicon.ico|
+ESPN|search.espn.go.com|http://search.espn.go.com/%s/|http://www.espn.go.com/favicon.ico|
+Wikipedia|en.wikipedia.org|http://en.wikipedia.org/w/index.php?title=Special%%3ASearch&search=%s|http://en.wikipedia.org/favicon.ico|
Index: !NetSurf/Resources/default.ico
===================================================================
Binary files /dev/null and !NetSurf/Resources/default.ico differ
Index: !NetSurf/Resources/SearchEngines
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ !NetSurf/Resources/SearchEngines 2009-07-10 12:49:58.000000000 +0100
@@ -0,0 +1,20 @@
+Google|www.google.com|http://www.google.com/search?q=%s|http://www.google.com/favicon.ico|
+Yahoo|search.yahoo.com|http://search.yahoo.com/search?p=%s|http://www.yahoo.com/favicon.ico|
+Bing|www.bing.com|http://www.bing.com/search?q=%s|http://www.bing.com/favicon.ico|
+Business.com|www.business.com|http://www.business.com/search/rslt_default.asp?query=%s|http://www.business.com/favicon.ico|
+Omgili|www.omgili.com|http://www.omgili.com/AAAAA/%s.html|http://www.omgili.com/favicon.ico|
+BBC
News|search.bbc.co.uk|http://search.bbc.co.uk/search?q=%s&tab=ns|http://news.bbc.co.uk/favicon.ico|
+Ubuntu
Packages|packages.ubuntu.com|http://packages.ubuntu.com/search?keywords=%...
+Creative
Commons|creativecommons.org|http://creativecommons.org/?s=%s|http://creat...
+Ask.com|www.ask.com|http://www.ask.com/web?q=%s|http://www.ask.com/favicon.ico|
+Answers.com|www.answers.com|http://www.answers.com/%s|http://www.answers.com/favicon.ico|
+Dictionary.com|dictionary.reference.com|http://dictionary.reference.com/browse/%s?jss=0|http://dictionary.reference.com/favicon.ico|
+Youtube|www.youtube.com|http://www.youtube.com/results?search_query=%s|http://www.youtube.com/favicon.ico|
+AeroMp3|www.aeromp3.com|http://www.aeromp3.com/search?q=%s|http://www.aeromp3.com/favicon.ico|
+AOL|search.aol.com|http://search.aol.com/aol/search?query=%s|http://www.aol.com/favicon.ico|
+Baidu|www.baidu.com|http://www.baidu.com/s?wd=%s|http://www.baidu.com/favicon.ico|
+Amazon|www.amazon.com|http://www.amazon.com/s/ref=nb_ss_gw?field-keywords=%s|http://www.amazon.com/favicon.ico|
+Ebay|shop.ebay.com|http://shop.ebay.com/items/%s|http://www.ebay.com/favicon.ico|
+IMDB|www.imdb.com|http://www.imdb.com/find?q=%s|http://www.imdb.com/favicon.ico|
+ESPN|search.espn.go.com|http://search.espn.go.com/%s/|http://www.espn.go.com/favicon.ico|
+Wikipedia|en.wikipedia.org|http://en.wikipedia.org/w/index.php?title=Special%%3ASearch&search=%s|http://en.wikipedia.org/favicon.ico|
Index: Docs/BUILDING-AmigaCross
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ Docs/BUILDING-AmigaCross 2009-07-10 12:49:59.000000000 +0100
@@ -0,0 +1,11 @@
+to install an Amiga cross-compiler in a Linux distribution, there are instructions at
+
+http://utilitybase.com/article/show/2007/06/23/231/Installing+an+AmigaOS+4+cross+compiler
+
+a more Mac-oriented article is at
+http://utilitybase.com/article/show/2006/05/21/188/Building+Amiga+OS+4+GCC+Cross+Compiler+for+UNIX%252FMAC
+
+more background at
+http://cross.zerohero.se/os4.html
+
+then install linked libs in the correct place
Index: beos/beos_search.cpp
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ beos/beos_search.cpp 2009-07-10 12:50:00.000000000 +0100
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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 <stdbool.h>
+#include <string.h>
+
+extern "C" {
+#include "utils/log.h"
+}
+
+/* put new search_web globals here for now */
+char *search_engines_file_location;
+char *search_default_ico_location;
+
+/**
+ * Change the displayed search status.
+ * \param found search pattern matched in text
+ */
+void gui_search_set_status(bool found)
+{
+}
+
+/**
+ * display hourglass while searching
+ * \param active start/stop indicator
+ */
+void gui_search_set_hourglass(bool active)
+{
+}
+
+/**
+ * retrieve string being searched for from gui
+ */
+char *gui_search_get_string(void)
+{
+}
+
+/**
+ * add search string to recent searches list
+ * \param string search pattern
+ */
+void gui_search_add_recent(const char *string)
+{
+}
+
+/**
+ * activate search forwards button in gui
+ * \param active activate/inactivate
+ */
+void gui_search_set_forward_state(bool inactive)
+{
+}
+
+/**
+ * activate search forwards button in gui
+ * \param active activate/inactivate
+ */
+void gui_search_set_back_state(bool inactive)
+{
+}
+
+/**
+ * retrieve state of 'case sensitive' check in gui
+ */
+bool gui_search_get_case_sens(void)
+{
+}
+
+/**
+ * retrieve state of 'show all' check in gui
+ */
+bool gui_search_get_show_all(void)
+{
+}
Index: riscos/searchweb.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ riscos/searchweb.c 2009-07-10 12:50:10.000000000 +0100
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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 <string.h>
+#include "content/content.h"
+#include "desktop/searchweb.h"
+
+char *search_engines_file_location;
+char *search_default_ico_location;
+struct content *search_ico;
Index: desktop/searchweb.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ desktop/searchweb.c 2009-07-10 12:50:16.000000000 +0100
@@ -0,0 +1,228 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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
+ * Free text search (core)
+ */
+#include "utils/config.h"
+
+#include <ctype.h>
+#include <string.h>
+#include "content/content.h"
+#include "content/fetchcache.h"
+#include "content/fetch.h"
+#include "desktop/browser.h"
+#include "desktop/gui.h"
+#include "desktop/options.h"
+#include "desktop/searchweb.h"
+#include "utils/config.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
+#include "utils/utils.h"
+
+static struct search_provider {
+ char *name;
+ char *hostname;
+ char *searchstring;
+ char *ico;
+} current_search_provider;
+
+struct content *search_ico = 0;
+
+bool search_web_new_window(struct browser_window *bw, const char *searchterm)
+{
+ char *encsearchterm;
+ char *url;
+ if (url_escape(searchterm,0, true, NULL, &encsearchterm) !=
+ URL_FUNC_OK)
+ return false;
+ url = search_web_get_url(encsearchterm);
+ browser_window_create(url, bw, NULL,
+ false, true);
+ free(url);
+ return true;
+}
+
+bool search_is_url(const char *url)
+{
+ char *url2, *host;
+
+ if (url_normalize(url, &url2) != URL_FUNC_OK)
+ return false;
+
+ if (url_host(url2, &host) != URL_FUNC_OK)
+ return false;
+
+ return true;
+}
+/**
+ * caches the details of the current web search provider
+ * \param reference the enum value of the provider
+ * browser init code [as well as changing preferences code] should call
+ * search_web_provider_details(option_search_provider)
+ */
+
+void search_web_provider_details(int reference)
+{
+ char buf[300];
+ char delim[2];
+ int ref = 0;
+ if (search_engines_file_location == NULL)
+ return;
+ FILE *f = fopen(search_engines_file_location, "r");
+ if (f == NULL)
+ return;
+ while (fgets(buf, sizeof(buf), f)) {
+ if (buf[0] == '\0')
+ continue;
+ buf[strlen(buf)-1] = '\0';
+ if (ref++ == reference)
+ break;
+ }
+ strcpy(delim, "|");
+ if (current_search_provider.name)
+ free(current_search_provider.name);
+ current_search_provider.name = strdup(strtok(buf, delim));
+ if (current_search_provider.hostname)
+ free(current_search_provider.hostname);
+ current_search_provider.hostname = strdup(strtok(NULL, delim));
+ if (current_search_provider.searchstring)
+ free(current_search_provider.searchstring);
+ current_search_provider.searchstring = strdup(strtok(NULL, delim));
+ if (current_search_provider.ico)
+ free(current_search_provider.ico);
+ current_search_provider.ico = strdup(strtok(NULL, delim));
+ return;
+}
+
+char *search_web_from_term(const char *searchterm)
+{
+ char *encsearchterm;
+ if (url_escape(searchterm, 0, true, NULL, &encsearchterm)
+ != URL_FUNC_OK)
+ return strdup(searchterm);
+ return search_web_get_url(encsearchterm);
+}
+
+char *search_web_provider_name()
+{
+ if (current_search_provider.name)
+ return strdup(current_search_provider.name);
+ return strdup("google");
+}
+
+char *search_web_provider_host()
+{
+ if (current_search_provider.hostname)
+ return strdup(current_search_provider.hostname);
+ return strdup("www.google.com");
+}
+
+char *search_web_ico_name()
+{
+ if (current_search_provider.ico)
+ return strdup(current_search_provider.ico);
+ return
strdup("http://www.google.com/favicon.ico");
+}
+
+char *search_web_get_url(const char *encsearchterm)
+{
+ char *pref, *ret;
+ int len;
+ if (current_search_provider.searchstring)
+ pref = strdup(current_search_provider.searchstring);
+ else
+ pref =
strdup("http://www.google.com/search?q=%s");
+ len = strlen(encsearchterm) + strlen(pref);
+ ret = malloc(len -1);
+ snprintf(ret, len-1, pref, encsearchterm);
+ free(pref);
+ return ret;
+}
+
+struct content *search_web_retrieve_ico(bool localdefault)
+{
+ char *url;
+ if (localdefault) {
+ if (search_default_ico_location == NULL)
+ return NULL;
+ url = malloc(SLEN("file://") + strlen(
+ search_default_ico_location) + 1);
+ strcpy(url, "file://");
+ strcat(url, search_default_ico_location);
+ } else {
+ url = search_web_ico_name();
+ }
+
+ struct content *icocontent = NULL;
+ if (url != NULL)
+ icocontent = fetchcache(url, search_web_ico_callback,
+ 0, 0, 20, 20, true, 0,
+ 0, false, false);
+ free(url);
+ if (icocontent == NULL)
+ return NULL;
+
+ fetchcache_go(icocontent, 0, search_web_ico_callback,
+ 0, 0, 20, 20,
+ 0, 0, false, 0);
+
+ if (icocontent == NULL) {
+ LOG(("web search ico loading delayed"));
+ return NULL;
+ }
+ return icocontent;
+}
+
+void search_web_ico_callback(content_msg msg, struct content *ico,
+ intptr_t p1, intptr_t p2, union content_msg_data data)
+{
+
+ switch (msg) {
+ case CONTENT_MSG_LOADING:
+ case CONTENT_MSG_READY:
+ break;
+
+ case CONTENT_MSG_DONE:
+ LOG(("got favicon '%s'", ico->url));
+ if (ico->type == CONTENT_ICO) {
+ search_ico = ico; /* cache */
+ gui_window_set_search_ico();
+ } else {
+ search_web_retrieve_ico(true);
+ }
+ break;
+
+ case CONTENT_MSG_LAUNCH:
+ case CONTENT_MSG_ERROR:
+ LOG(("favicon %s error: %s", ico->url, data.error));
+ ico = 0;
+ search_web_retrieve_ico(true);
+ break;
+
+ case CONTENT_MSG_STATUS:
+ case CONTENT_MSG_NEWPTR:
+ case CONTENT_MSG_AUTH:
+ case CONTENT_MSG_SSL:
+ break;
+
+ default:
+ assert(0);
+ }
+}
Index: desktop/searchweb.h
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ desktop/searchweb.h 2009-07-10 12:50:17.000000000 +0100
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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_DESKTOP_SEARCH_WEB_H_
+#define _NETSURF_DESKTOP_SEARCH_WEB_H_
+
+#include <ctype.h>
+#include <string.h>
+#include "content/content.h"
+#include "desktop/browser.h"
+
+extern char *search_engines_file_location;
+extern char *search_default_ico_location;
+extern struct content *search_ico;
+
+typedef enum {
+ OSP_GOOGLE,
+ OSP_YAHOO,
+ OSP_MICROSOFT,
+ OSP_BUSINESS,
+ OSP_OMGILI,
+ OSP_BBC,
+ OSP_UBUNTU,
+ OSP_COMMONS,
+ OSP_ASK,
+ OSP_ANSWERS,
+ OSP_DICTIONARYCOM,
+ OSP_YOUTUBE,
+ OSP_AEROMP3,
+ OSP_AOL,
+ OSP_BAIDU,
+ OSP_AMAZON,
+ OSP_EBAY,
+ OSP_IMDB,
+ OSP_ESPN,
+ OSP_WIKIPEDIA
+} default_search_provider;
+
+/**
+ * open new tab/window for web search term
+ */
+bool search_web_new_window(struct browser_window *bw, const char *searchterm);
+
+/**
+ * retrieve full search url from unencoded search term
+ */
+char *search_web_from_term(const char *searchterm);
+
+/**
+ * retrieve full search url from encoded web search term
+ */
+char *search_web_get_url(const char *encsearchterm);
+
+/**
+ * cache details of web search provider from file
+ */
+void search_web_provider_details(int reference);
+
+/**
+ * retrieve name of web search provider
+ */
+char *search_web_provider_name(void);
+
+/**
+ * retrieve hostname of web search provider
+ */
+char *search_web_provider_host(void);
+
+/**
+ * retrieve name of .ico for search bar
+ */
+char *search_web_ico_name(void);
+
+/**
+ * check whether an URL is in fact a search term
+ * \param url the url being checked
+ * \return true for url, false for search
+ */
+bool search_is_url(const char *url);
+
+struct content *search_web_retrieve_ico(bool localdefault);
+
+void search_web_ico_callback(content_msg msg, struct content *ico,
+ intptr_t p1, intptr_t p2, union content_msg_data data);
+
+#endif
Index: desktop/search.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ desktop/search.c 2009-07-10 12:50:19.000000000 +0100
@@ -0,0 +1,630 @@
+/*
+ * Copyright 2004 John M Bell <jmb202(a)ecs.soton.ac.uk>
+ * Copyright 2005 Adrian Lees <adrianl(a)users.sourceforge.net>
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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
+ * Free text search (core)
+ */
+#include "utils/config.h"
+
+#include <ctype.h>
+#include <string.h>
+#include "content/content.h"
+#include "desktop/browser.h"
+#include "desktop/gui.h"
+#include "desktop/options.h"
+#include "desktop/search.h"
+#include "desktop/selection.h"
+#include "render/box.h"
+#include "render/html.h"
+#include "utils/config.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
+#include "utils/utils.h"
+
+
+#ifndef NOF_ELEMENTS
+#define NOF_ELEMENTS(array) (sizeof(array)/sizeof(*(array)))
+#endif
+
+
+struct list_entry {
+ unsigned start_idx; /* start position of match */
+ unsigned end_idx; /* end of match */
+
+ struct box *start_box; /* used only for html contents */
+ struct box *end_box;
+
+ struct selection *sel;
+
+ struct list_entry *prev;
+ struct list_entry *next;
+};
+
+struct browser_window *search_current_window = NULL;
+static char *search_string = NULL;
+static struct list_entry search_head = { 0, 0, NULL, NULL, NULL, NULL, NULL };
+static struct list_entry *search_found = &search_head;
+static struct list_entry *search_current = NULL;
+static struct content *search_content = NULL;
+static bool search_prev_case_sens = false;
+
+bool search_insert;
+char *recent_search[RECENT_SEARCHES];
+
+static void do_search(const char *string, int string_len, bool case_sens,
+ bool forwards);
+static const char *find_pattern(const char *string, int s_len,
+ const char *pattern, int p_len, bool case_sens,
+ unsigned int *m_len);
+static bool find_occurrences_html(const char *pattern, int p_len,
+ struct box *cur, bool case_sens);
+static bool find_occurrences_text(const char *pattern, int p_len,
+ struct content *c, bool case_sens);
+static struct list_entry *add_entry(unsigned start_idx, unsigned end_idx);
+static void free_matches(void);
+
+/**
+ * Begins/continues the search process
+ * Note that this may be called many times for a single search.
+ *
+ * \param forwards search forwards from start/current position
+ */
+
+void start_search(bool forwards)
+{
+ int string_len;
+ const char *string;
+ int i = 0;
+
+ string = gui_search_get_string();
+ assert(string);
+
+ gui_search_add_recent(string);
+
+ string_len = strlen(string);
+ for(i = 0; i < string_len; i++)
+ if (string[i] != '#' && string[i] != '*') break;
+ if (i >= string_len) {
+ free_matches();
+ gui_search_set_status(true);
+ gui_search_set_back_state(true);
+ gui_search_set_forward_state(true);
+ gui_window_set_scroll(search_current_window->window, 0, 0);
+ return;
+ }
+
+ do_search(string, string_len, gui_search_get_case_sens(), forwards);
+}
+
+/**
+ * Release the memory used by the list of matches,
+ * deleting selection objects too
+ */
+
+void free_matches(void)
+{
+ struct list_entry *a = search_found->next;
+ struct list_entry *b;
+
+ /* empty the list before clearing and deleting the
+ selections because the the clearing updates the
+ screen immediately, causing nested accesses to the list */
+
+ search_found->prev = 0;
+ search_found->next = 0;
+
+ for (; a; a = b) {
+ b = a->next;
+ if (a->sel) {
+ selection_clear(a->sel, true);
+ selection_destroy(a->sel);
+ }
+ free(a);
+ }
+}
+
+/**
+ * Search for a string in the box tree
+ *
+ * \param string the string to search for
+ * \param string_len length of search string
+ * \param case_sens whether to perform a case sensitive search
+ * \param forwards direction to search in
+ */
+void do_search(const char *string, int string_len, bool case_sens,
+ bool forwards)
+{
+ struct rect bounds;
+ struct content *c;
+ struct box *box;
+ bool new = false;
+
+ if (!search_current_window)
+ return;
+ c = search_current_window->current_content;
+
+ /* only handle html contents */
+ if ((!c) || (c->type != CONTENT_HTML &&
+ c->type != CONTENT_TEXTPLAIN))
+ return;
+
+ box = c->data.html.layout;
+
+ if (!box)
+ return;
+
+ /* LOG(("do_search '%s' - '%s' (%p, %p) %p (%d, %d) %d",
+ search_string, string, search_content, c, search_found->next,
+ search_prev_case_sens, case_sens, forwards)); */
+
+ /* check if we need to start a new search or continue an old one */
+ if (!search_string || c != search_content || !search_found->next ||
+ search_prev_case_sens != case_sens ||
+ (case_sens && strcmp(string, search_string) != 0) ||
+ (!case_sens && strcasecmp(string, search_string) != 0)) {
+ bool res;
+
+ if (search_string)
+ free(search_string);
+ search_current = 0;
+ free_matches();
+
+ search_string = malloc(string_len + 1);
+ if (search_string) {
+ memcpy(search_string, string, string_len);
+ search_string[string_len] = '\0';
+ }
+
+ gui_search_set_hourglass(true);
+
+ if (c->type == CONTENT_HTML)
+ res = find_occurrences_html(string, string_len,
+ box, case_sens);
+ else {
+ assert(c->type == CONTENT_TEXTPLAIN);
+ res = find_occurrences_text(string, string_len,
+ c, case_sens);
+ }
+
+ if (!res) {
+ free_matches();
+ gui_search_set_hourglass(false);
+ return;
+ }
+ gui_search_set_hourglass(false);
+
+ new = true;
+ search_content = c;
+ search_prev_case_sens = case_sens;
+ }
+
+ /* LOG(("%d %p %p (%p, %p)", new, search_found->next, search_current,
+ search_current->prev, search_current->next)); */
+
+ if (new) {
+ /* new search, beginning at the top of the page */
+ search_current = search_found->next;
+ }
+ else if (search_current) {
+ /* continued search in the direction specified */
+ if (forwards) {
+ if (search_current->next)
+ search_current = search_current->next;
+ }
+ else {
+ if (search_current->prev)
+ search_current = search_current->prev;
+ }
+ }
+
+ gui_search_set_status(search_current != NULL);
+ search_show_all(gui_search_get_show_all());
+
+ gui_search_set_back_state(!search_current || !search_current->prev);
+ gui_search_set_forward_state(!search_current || !search_current->next);
+
+ if (!search_current)
+ return;
+
+ switch (c->type) {
+ case CONTENT_HTML:
+ /* get box position and jump to it */
+ box_coords(search_current->start_box,
+ &bounds.x0, &bounds.y0);
+ /* \todo: move x0 in by correct idx */
+ box_coords(search_current->end_box,
+ &bounds.x1, &bounds.y1);
+ /* \todo: move x1 in by correct idx */
+ bounds.x1 += search_current->end_box->width;
+ bounds.y1 += search_current->end_box->height;
+ break;
+
+ default:
+ assert(c->type == CONTENT_TEXTPLAIN);
+ textplain_coords_from_range(c,
+ search_current->start_idx,
+ search_current->end_idx, &bounds);
+ break;
+ }
+
+ gui_window_scroll_visible(search_current_window->window,
+ bounds.x0, bounds.y0, bounds.x1, bounds.y1);
+}
+
+/**
+ * Find the first occurrence of 'match' in 'string' and return its index
+ *
+ * /param string the string to be searched (unterminated)
+ * /param s_len length of the string to be searched
+ * /param pattern the pattern for which we are searching (unterminated)
+ * /param p_len length of pattern
+ * /param case_sens true iff case sensitive match required
+ * /param m_len accepts length of match in bytes
+ * /return pointer to first match, NULL if none
+ */
+
+const char *find_pattern(const char *string, int s_len, const char *pattern,
+ int p_len, bool case_sens, unsigned int *m_len)
+{
+ struct { const char *ss, *s, *p; bool first; } context[16];
+ const char *ep = pattern + p_len;
+ const char *es = string + s_len;
+ const char *p = pattern - 1; /* a virtual '*' before the pattern */
+ const char *ss = string;
+ const char *s = string;
+ bool first = true;
+ int top = 0;
+
+ while (p < ep) {
+ bool matches;
+ if (p < pattern || *p == '*') {
+ char ch;
+
+ /* skip any further asterisks; one is the same as many
+ */
+ do p++; while (p < ep && *p == '*');
+
+ /* if we're at the end of the pattern, yes, it matches
+ */
+ if (p >= ep) break;
+
+ /* anything matches a # so continue matching from
+ here, and stack a context that will try to match
+ the wildcard against the next character */
+
+ ch = *p;
+ if (ch != '#') {
+ /* scan forwards until we find a match for
+ this char */
+ if (!case_sens) ch = toupper(ch);
+ while (s < es) {
+ if (case_sens) {
+ if (*s == ch) break;
+ } else if (toupper(*s) == ch)
+ break;
+ s++;
+ }
+ }
+
+ if (s < es) {
+ /* remember where we are in case the match
+ fails; we may then resume */
+ if (top < (int)NOF_ELEMENTS(context)) {
+ context[top].ss = ss;
+ context[top].s = s + 1;
+ context[top].p = p - 1;
+ /* ptr to last asterisk */
+ context[top].first = first;
+ top++;
+ }
+
+ if (first) {
+ ss = s;
+ /* remember first non-'*' char */
+ first = false;
+ }
+
+ matches = true;
+ }
+ else
+ matches = false;
+ }
+ else if (s < es) {
+ char ch = *p;
+ if (ch == '#')
+ matches = true;
+ else {
+ if (case_sens)
+ matches = (*s == ch);
+ else
+ matches = (toupper(*s) == toupper(ch));
+ }
+ if (matches && first) {
+ ss = s; /* remember first non-'*' char */
+ first = false;
+ }
+ }
+ else
+ matches = false;
+
+ if (matches) {
+ p++; s++;
+ }
+ else {
+ /* doesn't match, resume with stacked context if we have one */
+ if (--top < 0) return NULL; /* no match, give up */
+
+ ss = context[top].ss;
+ s = context[top].s;
+ p = context[top].p;
+ first = context[top].first;
+ }
+ }
+
+ /* end of pattern reached */
+ *m_len = max(s - ss, 1);
+ return ss;
+}
+
+/**
+ * Finds all occurrences of a given string in the html box tree
+ *
+ * \param pattern the string pattern to search for
+ * \param p_len pattern length
+ * \param cur pointer to the current box
+ * \param case_sens whether to perform a case sensitive search
+ * \return true on success, false on memory allocation failure
+ */
+bool find_occurrences_html(const char *pattern, int p_len, struct box *cur,
+ bool case_sens)
+{
+ struct box *a;
+
+ /* ignore this box, if there's no visible text */
+ if (!cur->object && cur->text) {
+ const char *text = cur->text;
+ unsigned length = cur->length;
+
+ while (length > 0) {
+ struct list_entry *entry;
+ unsigned match_length;
+ unsigned match_offset;
+ const char *new_text;
+ const char *pos = find_pattern(text, length,
+ pattern, p_len, case_sens,
+ &match_length);
+ if (!pos) break;
+
+ /* found string in box => add to list */
+ match_offset = pos - cur->text;
+
+ entry = add_entry(cur->byte_offset + match_offset,
+ cur->byte_offset +
+ match_offset +
+ match_length);
+ if (!entry)
+ return false;
+
+ entry->start_box = cur;
+ entry->end_box = cur;
+
+ new_text = pos + match_length;
+ length -= (new_text - text);
+ text = new_text;
+ }
+ }
+
+ /* and recurse */
+ for (a = cur->children; a; a = a->next) {
+ if (!find_occurrences_html(pattern, p_len, a, case_sens))
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Finds all occurrences of a given string in a textplain content
+ *
+ * \param pattern the string pattern to search for
+ * \param p_len pattern length
+ * \param c the content to be searched
+ * \param case_sens wheteher to perform a case sensitive search
+ * \return true on success, false on memory allocation failure
+ */
+
+bool find_occurrences_text(const char *pattern, int p_len,
+ struct content *c, bool case_sens)
+{
+ int nlines = textplain_line_count(c);
+ int line;
+
+ for(line = 0; line < nlines; line++) {
+ size_t offset, length;
+ const char *text = textplain_get_line(c, line,
+ &offset, &length);
+ if (text) {
+ while (length > 0) {
+ struct list_entry *entry;
+ unsigned match_length;
+ size_t start_idx;
+ const char *new_text;
+ const char *pos = find_pattern(text, length,
+ pattern, p_len, case_sens,
+ &match_length);
+ if (!pos) break;
+
+ /* found string in line => add to list */
+ start_idx = offset + (pos - text);
+ entry = add_entry(start_idx, start_idx +
+ match_length);
+ if (!entry)
+ return false;
+
+ new_text = pos + match_length;
+ offset += (new_text - text);
+ length -= (new_text - text);
+ text = new_text;
+ }
+ }
+ }
+
+ return true;
+}
+
+/**
+ * Determines whether any portion of the given text box should be
+ * selected because it matches the current search string.
+ *
+ * \param g gui window
+ * \param start_offset byte offset within text of string to be checked
+ * \param end_offset byte offset within text
+ * \param start_idx byte offset within string of highlight start
+ * \param end_idx byte offset of highlight end
+ * \return true iff part of the box should be highlighted
+ */
+
+bool gui_search_term_highlighted(struct gui_window *g,
+ unsigned start_offset, unsigned end_offset,
+ unsigned *start_idx, unsigned *end_idx)
+{
+ if (g == search_current_window->window) {
+ struct list_entry *a;
+ for(a = search_found->next; a; a = a->next)
+ if (a->sel && selection_defined(a->sel) &&
+ selection_highlighted(a->sel,
+ start_offset, end_offset,
+ start_idx, end_idx))
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Specifies whether all matches or just the current match should
+ * be highlighted in the search text.
+ */
+
+void search_show_all(bool all)
+{
+ struct list_entry *a;
+
+ for (a = search_found->next; a; a = a->next) {
+ bool add = true;
+ if (!all && a != search_current) {
+ add = false;
+ if (a->sel) {
+ selection_clear(a->sel, true);
+ selection_destroy(a->sel);
+ a->sel = NULL;
+ }
+ }
+ if (add && !a->sel) {
+ a->sel = selection_create(search_current_window);
+ if (a->sel) {
+ struct content *c = search_current_window->
+ current_content;
+ switch (c->type) {
+ case CONTENT_HTML:
+ selection_init(a->sel,
+ c->data.html.layout);
+ break;
+ default:
+ assert(c->type ==
+ CONTENT_TEXTPLAIN);
+ selection_init(a->sel, NULL);
+ break;
+ }
+ selection_set_start(a->sel, a->start_idx);
+ selection_set_end(a->sel, a->end_idx);
+ }
+ }
+ }
+}
+
+/**
+ * Add a new entry to the list of matches
+ *
+ * \param start_idx offset of match start within textual representation
+ * \param end_idx offset of match end
+ * \return pointer to added entry, NULL iff failed
+ */
+
+struct list_entry *add_entry(unsigned start_idx, unsigned end_idx)
+{
+ struct list_entry *entry;
+
+ /* found string in box => add to list */
+ entry = calloc(1, sizeof(*entry));
+ if (!entry) {
+ warn_user("NoMemory", 0);
+ return NULL;
+ }
+
+ entry->start_idx = start_idx;
+ entry->end_idx = end_idx;
+ entry->sel = NULL;
+
+ entry->next = 0;
+ entry->prev = search_found->prev;
+ if (!search_found->prev)
+ search_found->next = entry;
+ else
+ search_found->prev->next = entry;
+ search_found->prev = entry;
+
+ return entry;
+}
+
+/**
+ * clears the state of the search, including resetting buttons
+ * to their active state
+ */
+void search_reset()
+{
+ gui_search_set_forward_state(false);
+ gui_search_set_back_state(false);
+ search_end();
+}
+
+/**
+ * Ends the search process, invalidating all global state
+ * freeing the list of found boxes
+ */
+void search_end()
+{
+ search_current_window = 0;
+
+ if (search_string) {
+ gui_search_add_recent(search_string);
+ free(search_string);
+ }
+ search_string = 0;
+
+ free_matches();
+
+ search_current = 0;
+
+ search_content = 0;
+
+ search_prev_case_sens = false;
+}
Index: desktop/search.h
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ desktop/search.h 2009-07-10 12:50:19.000000000 +0100
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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_DESKTOP_SEARCH_H_
+#define _NETSURF_DESKTOP_SEARCH_H_
+
+#include <ctype.h>
+#include <string.h>
+
+#define RECENT_SEARCHES 8
+
+extern char *recent_search[RECENT_SEARCHES];
+extern bool search_insert;
+
+void start_search(bool forwards);
+
+/**
+ * Change the displayed search status.
+ * \param found search pattern matched in text
+ */
+void gui_search_set_status(bool found);
+
+/**
+ * display hourglass while searching
+ * \param active start/stop indicator
+ */
+void gui_search_set_hourglass(bool active);
+
+/**
+ * retrieve string being searched for from gui
+ */
+char *gui_search_get_string(void);
+
+/**
+ * add search string to recent searches list
+ * \param string search pattern
+ */
+void gui_search_add_recent(const char *string);
+
+/**
+ * activate search forwards button in gui
+ * \param active activate/inactivate
+ */
+void gui_search_set_forward_state(bool inactive);
+
+/**
+ * activate search forwards button in gui
+ * \param active activate/inactivate
+ */
+void gui_search_set_back_state(bool inactive);
+
+/**
+ * retrieve state of 'case sensitive' check in gui
+ */
+bool gui_search_get_case_sens(void);
+
+/**
+ * retrieve state of 'show all' check in gui
+ */
+bool gui_search_get_show_all(void);
+
+void search_show_all(bool all);
+
+void search_reset(void);
+void search_end(void);
+
+#endif
Index: desktop/save_complete.c
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ desktop/save_complete.c 2009-07-10 12:50:20.000000000 +0100
@@ -0,0 +1,742 @@
+/*
+ * Copyright 2004 John M Bell <jmb202(a)ecs.soton.ac.uk>
+ * Copyright 2004-2007 James Bursa <bursa(a)users.sourceforge.net>
+ *
+ * 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
+ * Save HTML document with dependencies (implementation).
+ */
+
+#include "utils/config.h"
+
+#define _GNU_SOURCE /* for strndup */
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <regex.h>
+#include <libxml/HTMLtree.h>
+#include <libxml/parserInternals.h>
+#include "utils/config.h"
+#include "content/content.h"
+#include "css/css.h"
+#include "render/box.h"
+#include "desktop/save_complete.h"
+#include "utils/log.h"
+#include "utils/url.h"
+#include "utils/utils.h"
+
+regex_t save_complete_import_re;
+
+/** An entry in save_complete_list. */
+struct save_complete_entry {
+ struct content *content;
+ struct save_complete_entry *next; /**< Next entry in list */
+};
+
+#ifdef RISCOS
+ static char pathsep = '.';
+#else
+ static char pathsep = '/';
+#endif
+
+/** List of urls seen and saved so far. */
+static struct save_complete_entry *save_complete_list = 0;
+
+static bool save_complete_html(struct content *c, const char *path,
+ bool index);
+static bool save_imported_sheets(struct content *c, const char *path);
+static char * rewrite_stylesheet_urls(const char *source, unsigned int size,
+ int *osize, const char *base);
+static bool rewrite_document_urls(xmlDoc *doc, const char *base);
+static bool rewrite_urls(xmlNode *n, const char *base);
+static bool rewrite_url(xmlNode *n, const char *attr, const char *base);
+static bool save_complete_list_add(struct content *content);
+static struct content * save_complete_list_find(const char *url);
+static bool save_complete_list_check(struct content *content);
+/* static void save_complete_list_dump(void); */
+static bool save_complete_inventory(const char *path);
+
+/**
+ * Save an HTML page with all dependencies.
+ *
+ * \param c CONTENT_HTML to save
+ * \param path directory to save to (must exist)
+ * \return true on success, false on error and error reported
+ */
+
+bool save_complete(struct content *c, const char *path)
+{
+ bool result;
+
+ result = save_complete_html(c, path, true);
+
+ if (result)
+ result = save_complete_inventory(path);
+
+ /* free save_complete_list */
+ while (save_complete_list) {
+ struct save_complete_entry *next = save_complete_list->next;
+ free(save_complete_list);
+ save_complete_list = next;
+ }
+
+ return result;
+}
+
+
+/**
+ * Save an HTML page with all dependencies, recursing through imported pages.
+ *
+ * \param c CONTENT_HTML to save
+ * \param path directory to save to (must exist)
+ * \param index true to save as "index"
+ * \return true on success, false on error and error reported
+ */
+
+bool save_complete_html(struct content *c, const char *path, bool index)
+{
+ char filename[256];
+ unsigned int i;
+ xmlDocPtr doc;
+ bool res;
+
+ if (c->type != CONTENT_HTML)
+ return false;
+
+ if (save_complete_list_check(c))
+ return true;
+
+ /* save stylesheets, ignoring the base and adblocking sheets */
+ for (i = STYLESHEET_STYLE; i != c->data.html.stylesheet_count; i++) {
+ struct content *css = c->data.html.stylesheet_content[i];
+ char *source;
+ int source_len;
+
+ if (!css)
+ continue;
+ if (save_complete_list_check(css))
+ continue;
+
+ if (i != STYLESHEET_STYLE) {
+ if (!save_complete_list_add(css)) {
+ warn_user("NoMemory", 0);
+ return false;
+ }
+ }
+
+ if (!save_imported_sheets(css, path))
+ return false;
+
+ if (i == STYLESHEET_STYLE)
+ continue; /* don't save <style> elements */
+
+ snprintf(filename, sizeof filename, "%x", (unsigned int) css);
+ source = rewrite_stylesheet_urls(css->source_data,
+ css->source_size, &source_len, css->url);
+ if (!source) {
+ warn_user("NoMemory", 0);
+ return false;
+ }
+ res = save_complete_gui_save(path, filename, NULL, source_len,
+ source, 0xf79);
+ free(source);
+ if (res == false)
+ return false;
+ }
+
+ /* save objects */
+ for (i = 0; i != c->data.html.object_count; i++) {
+ struct content *obj = c->data.html.object[i].content;
+
+ /* skip difficult content types */
+ if (!obj || obj->type >= CONTENT_OTHER || !obj->source_data)
+ continue;
+ if (save_complete_list_check(obj))
+ continue;
+
+ if (!save_complete_list_add(obj)) {
+ warn_user("NoMemory", 0);
+ return false;
+ }
+
+ if (obj->type == CONTENT_HTML) {
+ if (!save_complete_html(obj, path, false))
+ return false;
+ continue;
+ }
+
+ snprintf(filename, sizeof filename, "%x", (unsigned int) obj);
+ res = save_complete_gui_save(path, filename, obj,
+ obj->source_size, obj->source_data, 0);
+ if(res == false)
+ return false;
+ }
+
+ /*save_complete_list_dump();*/
+
+ /* copy document */
+ doc = xmlCopyDoc(c->data.html.document, 1);
+ if (doc == NULL) {
+ warn_user("NoMemory", 0);
+ return false;
+ }
+
+ /* rewrite all urls we know about */
+ if (!rewrite_document_urls(doc, c->data.html.base_url)) {
+ xmlFreeDoc(doc);
+ warn_user("NoMemory", 0);
+ return false;
+ }
+
+ /* save the html file out last of all */
+ if (index)
+ snprintf(filename, sizeof filename, "index");
+ else
+ snprintf(filename, sizeof filename, "%x", (unsigned int)c);
+
+ errno = 0;
+ if (save_complete_htmlSaveFileFormat(path, filename, doc, 0, 0) == -1) {
+ if (errno)
+ warn_user("SaveError", strerror(errno));
+ else
+ warn_user("SaveError", "htmlSaveFileFormat failed");
+
+ xmlFreeDoc(doc);
+ return false;
+ }
+
+ xmlFreeDoc(doc);
+
+ return save_complete_gui_filetype(path, filename, 0xfaf);
+}
+
+
+/**
+ * Save stylesheets imported by a CONTENT_CSS.
+ *
+ * \param c a CONTENT_CSS
+ * \param path path to save to
+ * \return true on success, false on error and error reported
+ */
+
+bool save_imported_sheets(struct content *c, const char *path)
+{
+ char filename[256];
+ unsigned int j;
+ char *source;
+ int source_len;
+ bool res;
+
+ for (j = 0; j != c->data.css.import_count; j++) {
+ struct content *css = c->data.css.import_content[j];
+
+ if (!css)
+ continue;
+ if (save_complete_list_check(css))
+ continue;
+
+ if (!save_complete_list_add(css)) {
+ warn_user("NoMemory", 0);
+ return false;
+ }
+
+ if (!save_imported_sheets(css, path))
+ return false;
+
+ snprintf(filename, sizeof filename, "%x", (unsigned int) css);
+ source = rewrite_stylesheet_urls(css->source_data,
+ css->source_size, &source_len, css->url);
+ if (!source) {
+ warn_user("NoMemory", 0);
+ return false;
+ }
+
+ res = save_complete_gui_save(path, filename, NULL, source_len,
+ source, 0xf79);
+ free(source);
+ if (res == false)
+ return false;
+ }
+
+ return true;
+}
+
+
+/**
+ * Initialise the save_complete module.
+ */
+
+void save_complete_init(void)
+{
+ /* Match an @import rule - see CSS 2.1 G.1. */
+ regcomp_wrapper(&save_complete_import_re,
+ "@import" /* IMPORT_SYM */
+ "[ \t\r\n\f]*" /* S* */
+ /* 1 */
+ "(" /* [ */
+ /* 2 3 */
+ "\"(([^\"]|[\\]\")*)\"" /* STRING (approximated) */
+ "|"
+ /* 4 5 */
+ "'(([^']|[\\]')*)'"
+ "|" /* | */
+ "url\\([ \t\r\n\f]*" /* URI (approximated) */
+ /* 6 7 */
+ "\"(([^\"]|[\\]\")*)\""
+ "[ \t\r\n\f]*\\)"
+ "|"
+ "url\\([ \t\r\n\f]*"
+ /* 8 9 */
+ "'(([^']|[\\]')*)'"
+ "[ \t\r\n\f]*\\)"
+ "|"
+ "url\\([ \t\r\n\f]*"
+ /* 10 */
+ "([^) \t\r\n\f]*)"
+ "[ \t\r\n\f]*\\)"
+ ")", /* ] */
+ REG_EXTENDED | REG_ICASE);
+}
+
+
+/**
+ * Rewrite stylesheet \@import rules for save complete.
+ *
+ * @param source stylesheet source
+ * @param size size of source
+ * @param osize updated with the size of the result
+ * @param base url of stylesheet
+ * @return converted source, or 0 on out of memory
+ */
+
+char * rewrite_stylesheet_urls(const char *source, unsigned int size,
+ int *osize, const char *base)
+{
+ char *res;
+ const char *url;
+ char *url2;
+ char buf[20];
+ unsigned int offset = 0;
+ int url_len = 0;
+ struct content *content;
+ int m;
+ unsigned int i;
+ unsigned int imports = 0;
+ regmatch_t match[11];
+ url_func_result result;
+
+ /* count number occurences of @import to (over)estimate result size */
+ /* can't use strstr because source is not 0-terminated string */
+ for (i = 0; 7 < size && i != size - 7; i++) {
+ if (source[i] == '@' &&
+ tolower(source[i + 1]) == 'i' &&
+ tolower(source[i + 2]) == 'm' &&
+ tolower(source[i + 3]) == 'p' &&
+ tolower(source[i + 4]) == 'o' &&
+ tolower(source[i + 5]) == 'r' &&
+ tolower(source[i + 6]) == 't')
+ imports++;
+ }
+
+ res = malloc(size + imports * 20);
+ if (!res)
+ return 0;
+ *osize = 0;
+
+ while (offset < size) {
+ m = regexec(&save_complete_import_re, source + offset,
+ 11, match, 0);
+ if (m)
+ break;
+
+ /*for (unsigned int i = 0; i != 11; i++) {
+ if (match[i].rm_so == -1)
+ continue;
+ fprintf(stderr, "%i: '%.*s'\n", i,
+ match[i].rm_eo - match[i].rm_so,
+ source + offset + match[i].rm_so);
+ }*/
+
+ url = 0;
+ if (match[2].rm_so != -1) {
+ url = source + offset + match[2].rm_so;
+ url_len = match[2].rm_eo - match[2].rm_so;
+ } else if (match[4].rm_so != -1) {
+ url = source + offset + match[4].rm_so;
+ url_len = match[4].rm_eo - match[4].rm_so;
+ } else if (match[6].rm_so != -1) {
+ url = source + offset + match[6].rm_so;
+ url_len = match[6].rm_eo - match[6].rm_so;
+ } else if (match[8].rm_so != -1) {
+ url = source + offset + match[8].rm_so;
+ url_len = match[8].rm_eo - match[8].rm_so;
+ } else if (match[10].rm_so != -1) {
+ url = source + offset + match[10].rm_so;
+ url_len = match[10].rm_eo - match[10].rm_so;
+ }
+ assert(url);
+
+ url2 = strndup(url, url_len);
+ if (!url2) {
+ free(res);
+ return 0;
+ }
+ result = url_join(url2, base, (char**)&url);
+ free(url2);
+ if (result == URL_FUNC_NOMEM) {
+ free(res);
+ return 0;
+ }
+
+ /* copy data before match */
+ memcpy(res + *osize, source + offset, match[0].rm_so);
+ *osize += match[0].rm_so;
+
+ if (result == URL_FUNC_OK) {
+ content = save_complete_list_find(url);
+ if (content) {
+ /* replace import */
+ snprintf(buf, sizeof buf, "@import '%x'",
+ (unsigned int) content);
+ memcpy(res + *osize, buf, strlen(buf));
+ *osize += strlen(buf);
+ } else {
+ /* copy import */
+ memcpy(res + *osize, source + offset + match[0].rm_so,
+ match[0].rm_eo - match[0].rm_so);
+ *osize += match[0].rm_eo - match[0].rm_so;
+ }
+ }
+ else {
+ /* copy import */
+ memcpy(res + *osize, source + offset + match[0].rm_so,
+ match[0].rm_eo - match[0].rm_so);
+ *osize += match[0].rm_eo - match[0].rm_so;
+ }
+
+ assert(0 < match[0].rm_eo);
+ offset += match[0].rm_eo;
+ }
+
+ /* copy rest of source */
+ if (offset < size) {
+ memcpy(res + *osize, source + offset, size - offset);
+ *osize += size - offset;
+ }
+
+ return res;
+}
+
+
+/**
+ * Rewrite URLs in a HTML document to be relative.
+ *
+ * \param doc root of the document tree
+ * \param base base url of document
+ * \return true on success, false on out of memory
+ */
+
+bool rewrite_document_urls(xmlDoc *doc, const char *base)
+{
+ xmlNode *node;
+
+ for (node = doc->children; node; node = node->next)
+ if (node->type == XML_ELEMENT_NODE)
+ if (!rewrite_urls(node, base))
+ return false;
+
+ return true;
+}
+
+
+/**
+ * Traverse tree, rewriting URLs as we go.
+ *
+ * \param n xmlNode of type XML_ELEMENT_NODE to rewrite
+ * \param base base url of document
+ * \return true on success, false on out of memory
+ *
+ * URLs in the tree rooted at element n are rewritten.
+ */
+
+bool rewrite_urls(xmlNode *n, const char *base)
+{
+ xmlNode *child;
+
+ assert(n->type == XML_ELEMENT_NODE);
+
+ /**
+ * We only need to consider the following cases:
+ *
+ * Attribute: Elements:
+ *
+ * 1) data <object>
+ * 2) href <a> <area> <link>
+ * 3) src <script> <input> <frame> <iframe>
<img>
+ * 4) n/a <style>
+ * 5) n/a any <base> tag
+ * 6) background any (except those above)
+ */
+ if (!n->name) {
+ /* ignore */
+ }
+ /* 1 */
+ else if (strcmp((const char *) n->name, "object") == 0) {
+ if (!rewrite_url(n, "data", base))
+ return false;
+ }
+ /* 2 */
+ else if (strcmp((const char *) n->name, "a") == 0 ||
+ strcmp((const char *) n->name, "area") == 0 ||
+ strcmp((const char *) n->name, "link") == 0) {
+ if (!rewrite_url(n, "href", base))
+ return false;
+ }
+ /* 3 */
+ else if (strcmp((const char *) n->name, "frame") == 0 ||
+ strcmp((const char *) n->name, "iframe") == 0 ||
+ strcmp((const char *) n->name, "input") == 0 ||
+ strcmp((const char *) n->name, "img") == 0 ||
+ strcmp((const char *) n->name, "script") == 0) {
+ if (!rewrite_url(n, "src", base))
+ return false;
+ }
+ /* 4 */
+ else if (strcmp((const char *) n->name, "style") == 0) {
+ unsigned int len;
+ xmlChar *content;
+
+ for (child = n->children; child != 0; child = child->next) {
+ /* Get current content */
+ content = xmlNodeGetContent(child);
+ if (!content)
+ /* unfortunately we don't know if this is
+ * due to memory exhaustion, or because
+ * there is no content for this node */
+ continue;
+
+ /* Rewrite @import rules */
+ char *rewritten = rewrite_stylesheet_urls(
+ (const char *) content,
+ strlen((const char *) content),
+ (int *) &len, base);
+ xmlFree(content);
+ if (!rewritten)
+ return false;
+
+ /* set new content */
+ xmlNodeSetContentLen(child,
+ (const xmlChar*)rewritten,
+ len);
+ }
+
+ return true;
+ }
+ /* 5 */
+ else if (strcmp((const char *) n->name, "base") == 0) {
+ /* simply remove any <base> tags from the document */
+ xmlUnlinkNode(n);
+ xmlFreeNode(n);
+ /* base tags have no content, so there's no point recursing
+ * additionally, we've just destroyed this node, so trying
+ * to recurse would result in bad things happening */
+ return true;
+ }
+ /* 6 */
+ else {
+ if (!rewrite_url(n, "background", base))
+ return false;
+ }
+
+ /* now recurse */
+ for (child = n->children; child;) {
+ /* we must extract the next child now, as if the current
+ * child is a <base> element, it will be removed from the
+ * tree (see 5, above), thus preventing extraction of the
+ * next child */
+ xmlNode *next = child->next;
+ if (child->type == XML_ELEMENT_NODE) {
+ if (!rewrite_urls(child, base))
+ return false;
+ }
+ child = next;
+ }
+
+ return true;
+}
+
+
+/**
+ * Rewrite an URL in a HTML document.
+ *
+ * \param n The node to modify
+ * \param attr The html attribute to modify
+ * \param base base url of document
+ * \return true on success, false on out of memory
+ */
+
+bool rewrite_url(xmlNode *n, const char *attr, const char *base)
+{
+ char *url, *data;
+ char rel[20];
+ struct content *content;
+ url_func_result res;
+
+ if (!xmlHasProp(n, (const xmlChar *) attr))
+ return true;
+
+ data = (char *) xmlGetProp(n, (const xmlChar *) attr);
+ if (!data)
+ return false;
+
+ res = url_join(data, base, &url);
+ xmlFree(data);
+ if (res == URL_FUNC_NOMEM)
+ return false;
+ else if (res == URL_FUNC_OK) {
+ content = save_complete_list_find(url);
+ if (content) {
+ /* found a match */
+ free(url);
+ snprintf(rel, sizeof rel, "%x",
+ (unsigned int) content);
+ if (!xmlSetProp(n, (const xmlChar *) attr,
+ (xmlChar *) rel))
+ return false;
+ } else {
+ /* no match found */
+ if (!xmlSetProp(n, (const xmlChar *) attr,
+ (xmlChar *) url)) {
+ free(url);
+ return false;
+ }
+ free(url);
+ }
+ }
+
+ return true;
+}
+
+
+/**
+ * Add a content to the save_complete_list.
+ *
+ * \param content content to add
+ * \return true on success, false on out of memory
+ */
+
+bool save_complete_list_add(struct content *content)
+{
+ struct save_complete_entry *entry;
+ entry = malloc(sizeof (*entry));
+ if (!entry)
+ return false;
+ entry->content = content;
+ entry->next = save_complete_list;
+ save_complete_list = entry;
+ return true;
+}
+
+
+/**
+ * Look up a url in the save_complete_list.
+ *
+ * \param url url to find
+ * \return content if found, 0 otherwise
+ */
+
+struct content * save_complete_list_find(const char *url)
+{
+ struct save_complete_entry *entry;
+ for (entry = save_complete_list; entry; entry = entry->next)
+ if (strcmp(url, entry->content->url) == 0)
+ return entry->content;
+ return 0;
+}
+
+
+/**
+ * Look up a content in the save_complete_list.
+ *
+ * \param content pointer to content
+ * \return true if the content is in the save_complete_list
+ */
+
+bool save_complete_list_check(struct content *content)
+{
+ struct save_complete_entry *entry;
+ for (entry = save_complete_list; entry; entry = entry->next)
+ if (entry->content == content)
+ return true;
+ return false;
+}
+
+
+#if 0
+/**
+ * Dump save complete list to stderr
+ */
+void save_complete_list_dump(void)
+{
+ struct save_complete_entry *entry;
+ for (entry = save_complete_list; entry; entry = entry->next)
+ fprintf(stderr, "%p : %s\n", entry->content,
+ entry->content->url);
+}
+#endif
+
+
+/**
+ * Create the inventory file listing original URLs.
+ */
+
+bool save_complete_inventory(const char *path)
+{
+ char spath[256];
+ FILE *fp;
+ char *pathstring;
+
+ pathstring = strdup("%s/Inventory");
+ if (!pathstring) {
+ warn_user("NoMemory", 0);
+ return false;
+ }
+ pathstring[2] = pathsep;
+ snprintf(spath, sizeof spath, pathstring, path);
+ free(pathstring);
+
+ fp = fopen(spath, "w");
+ if (!fp) {
+ LOG(("fopen(): errno = %i", errno));
+ warn_user("SaveError", strerror(errno));
+ return false;
+ }
+
+ struct save_complete_entry *entry;
+ for (entry = save_complete_list; entry; entry = entry->next)
+ fprintf(fp, "%x %s\n",
+ (unsigned int) entry->content,
+ entry->content->url);
+
+ fclose(fp);
+
+ return true;
+}
+
Index: desktop/save_complete.h
===================================================================
--- /dev/null 2009-04-16 19:17:07.000000000 +0100
+++ desktop/save_complete.h 2009-07-10 12:50:22.000000000 +0100
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004 John M Bell <jmb202(a)ecs.soton.ac.uk>
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ *
+ * 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
+ * Save HTML document with dependencies (interface).
+ */
+
+#ifndef _NETSURF_DESKTOP_SAVE_COMPLETE_H_
+#define _NETSURF_DESKTOP_SAVE_COMPLETE_H_
+
+#include <stdbool.h>
+#include <libxml/HTMLtree.h>
+
+struct content;
+
+void save_complete_init(void);
+bool save_complete(struct content *c, const char *path);
+
+/**
+ * conducts the filesystem save appropriate to the gui
+ * \param path save path
+ * \param filename name of file to save
+ * \param c content to save, or NULL
+ * \param len data length
+ * \param sourcedata pointer to data to save, NULL when all data in sourcedata
+ * \param type integer filetype [riscos]
+ * \return true for success
+ */
+bool save_complete_gui_save(const char *path, const char *filename, struct content *c,
int len, char *sourcedata, int type);
+
+/**
+ * wrapper for lib function htmlSaveFileFormat
+ */
+int save_complete_htmlSaveFileFormat(const char *path, const char *filename,
+ xmlDocPtr cur, const char *encoding, int format);
+
+/**
+ * mainly implemented as a wrapper for riscos
+ */
+bool save_complete_gui_filetype(const char *path, const char *filename,
+ int type);
+
+#endif
Changed files
!NetSurf/Resources/de/Messages | 113 ++
!NetSurf/Resources/en/Messages | 111 ++
!NetSurf/Resources/fr/Messages | 115 ++
!NetSurf/Resources/it/Messages | 146 ++-
!NetSurf/Resources/nl/Messages | 113 ++
Docs/Doxyfile | 2
Makefile | 8
Makefile.sources | 25
amiga/download.c | 2
amiga/gui.c | 6
amiga/menu.c | 2
amiga/save_complete.c | 827 +----------------
amiga/search.c | 668 +-------------
beos/beos_scaffolding.cpp | 4
content/content.c | 3
content/fetchcache.c | 97 +-
desktop/browser.c | 34
desktop/browser.h | 1
desktop/gui.h | 5
desktop/options.c | 8
desktop/options.h | 2
gtk/dialogs/gtk_options.c | 198 +++-
gtk/dialogs/gtk_options.h | 2
gtk/dialogs/gtk_source.c | 222 ++--
gtk/gtk_download.c | 4
gtk/gtk_gui.c | 114 +-
gtk/gtk_gui.h | 14
gtk/gtk_login.c | 2
gtk/gtk_scaffolding.c | 1952 +++++++++++++++++++++++++++--------------
gtk/gtk_scaffolding.h | 233 ++++
gtk/gtk_selection.c | 5
gtk/gtk_tabs.c | 34
gtk/gtk_window.c | 115 +-
gtk/gtk_window.h | 40
gtk/options.h | 10
gtk/res/netsurf.glade | 1661 ++--------------------------------
gtk/res/options.glade | 772 ++++++++++------
image/ico.c | 9
image/ico.h | 1
render/html.c | 8
render/html.h | 3
render/html_redraw.c | 2
render/textplain.c | 2
riscos/save.c | 64 +
riscos/search.c | 618 ------------
riscos/window.c | 13
utils/config.h | 5
utils/container.c | 170 ++-
utils/container.h | 3
utils/utils.c | 17
utils/utils.h | 1
51 files changed, 3855 insertions(+), 4731 deletions(-)
Index: render/html.c
===================================================================
--- render/html.c (revision 8438)
+++ render/html.c (working copy)
@@ -37,6 +37,7 @@
#include "desktop/options.h"
#include "image/bitmap.h"
#include "render/box.h"
+#include "render/favicon.h"
#include "render/font.h"
#include "render/form.h"
#include "render/html.h"
@@ -73,7 +74,6 @@
static void html_object_refresh(void *p);
static void html_destroy_frameset(struct content_html_frames *frameset);
static void html_destroy_iframe(struct content_html_iframe *iframe);
-static void html_set_status(struct content *c, const char *extra);
#if ALWAYS_DUMP_FRAMESET
static void html_dump_frameset(struct content_html_frames *frame,
unsigned int depth);
@@ -283,6 +283,7 @@
*
* - parsing to an XML tree is completed
* - stylesheets are fetched
+ * - favicon is retrieved
* - the XML tree is converted to a box tree and object fetches are started
* - the box tree is laid out
*
@@ -399,6 +400,9 @@
if (!html_find_stylesheets(c, html))
return false;
+ /* get icon */
+ favicon_get_icon(c, html);
+
/* Retrieve forms from parser */
c->data.html.forms = binding_get_forms(c->data.html.parser_binding);
for (f = c->data.html.forms; f != NULL; f = f->prev) {
@@ -765,7 +769,7 @@
* Uses STYLE and LINK elements inside and outside HEAD
*
* \param c content structure
- * \param head xml node of html element
+ * \param html xml node of html element
* \return true on success, false if an error occurred
*/
Index: render/html_redraw.c
===================================================================
--- render/html_redraw.c (revision 8438)
+++ render/html_redraw.c (working copy)
@@ -795,7 +795,7 @@
/* what about the current search operation, if any? */
if (!highlighted && search_current_window ==
- current_redraw_browser->window &&
+ current_redraw_browser &&
gui_search_term_highlighted(
current_redraw_browser->window,
offset, offset + len,
Index: render/textplain.c
===================================================================
--- render/textplain.c (revision 8438)
+++ render/textplain.c (working copy)
@@ -427,7 +427,7 @@
highlighted = true;
}
- if (!highlighted && search_current_window == bw->window) {
+ if (!highlighted && search_current_window == bw) {
unsigned start_idx, end_idx;
if (gui_search_term_highlighted(bw->window,
tab_ofst, tab_ofst + 1,
Index: render/html.h
===================================================================
--- render/html.h (revision 8438)
+++ render/html.h (working copy)
@@ -128,6 +128,8 @@
colour background_colour; /**< Document background colour. */
const struct font_functions *font_func;
+ struct content *favicon;
+
/** Number of entries in stylesheet_content. */
unsigned int stylesheet_count;
/** Stylesheets. Each may be 0. */
@@ -184,6 +186,7 @@
struct content *page, unsigned int index, struct box *box,
struct object_params *params);
void html_close(struct content *c);
+void html_set_status(struct content *c, const char *extra);
/* in render/html_redraw.c */
bool html_redraw(struct content *c, int x, int y,
Index: image/ico.c
===================================================================
--- image/ico.c (revision 8438)
+++ image/ico.c (working copy)
@@ -114,6 +114,15 @@
background_colour, BITMAPF_NONE);
}
+bool nsico_set_bitmap_from_size(struct content *c, int width, int height)
+{
+ struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
+ if (!bmp->decoded)
+ if (bmp_decode(bmp) != BMP_OK)
+ return false;
+ c->bitmap = bmp->bitmap;
+ return true;
+}
bool nsico_redraw_tiled(struct content *c, int x, int y,
int width, int height,
Index: image/ico.h
===================================================================
--- image/ico.h (revision 8438)
+++ image/ico.h (working copy)
@@ -47,6 +47,7 @@
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale, colour background_colour,
bool repeat_x, bool repeat_y);
+bool nsico_set_bitmap_from_size(struct content *c, int width, int height);
#endif /* WITH_BMP */
Index: gtk/gtk_gui.h
===================================================================
--- gtk/gtk_gui.h (revision 8438)
+++ gtk/gtk_gui.h (working copy)
@@ -25,8 +25,18 @@
#include <glade/glade.h>
extern bool gui_in_multitask;
-extern GladeXML *gladeWindows;
-extern char *glade_file_location;
+extern GladeXML *gladeNetsurf;
+extern GladeXML *gladePassword;
+extern GladeXML *gladeWarning;
+extern GladeXML *gladeLogin;
+extern GladeXML *gladeSsl;
+extern char *glade_netsurf_file_location;
+extern char *glade_password_file_location;
+extern char *glade_warning_file_location;
+extern char *glade_login_file_location;
+extern char *glade_ssl_file_location;
+extern char *glade_toolbar_file_location;
+extern char *toolbar_indices_file_location;
extern char *options_file_location;
extern char *res_dir_location;
extern char *print_options_file_location;
Index: gtk/options.h
===================================================================
--- gtk/options.h (revision 8438)
+++ gtk/options.h (working copy)
@@ -34,6 +34,8 @@
extern bool option_hover_urls;
extern bool option_focus_new;
extern bool option_new_blank;
+extern bool option_source_tab;
+extern int option_current_theme;
#define EXTRA_OPTION_DEFINE \
bool option_render_resample = false; \
@@ -48,7 +50,9 @@
int option_history_age = 0; \
bool option_hover_urls = false; \
bool option_focus_new = false; \
-bool option_new_blank = false;
+bool option_new_blank = false; \
+bool option_source_tab = false;\
+int option_current_theme = 0;
#define EXTRA_OPTION_TABLE \
{ "render_resample", OPTION_BOOL, &option_render_resample }, \
@@ -63,6 +67,8 @@
{ "history_age", OPTION_INTEGER, &option_history_age}, \
{ "hover_urls", OPTION_BOOL, &option_hover_urls}, \
{ "focus_new", OPTION_BOOL, &option_focus_new}, \
-{ "new_blank", OPTION_BOOL, &option_new_blank}
+{ "new_blank", OPTION_BOOL, &option_new_blank}, \
+{ "source_tab", OPTION_BOOL, &option_source_tab},\
+{ "current_theme", OPTION_INTEGER, &option_current_theme}
#endif
Index: gtk/gtk_download.c
===================================================================
--- gtk/gtk_download.c (revision 8438)
+++ gtk/gtk_download.c (working copy)
@@ -33,6 +33,7 @@
#include "gtk/gtk_scaffolding.h"
#include "gtk/options.h"
#include "gtk/gtk_download.h"
+#include "gtk/gtk_window.h"
#define UPDATE_RATE 500 /* In milliseconds */
#define GLADE_NAME "downloads.glade"
@@ -206,7 +207,8 @@
messages_get("gtkUnknownSize") :
human_friendly_bytesize(total_size));
- nsgtk_download_parent = nsgtk_scaffolding_get_window(gui);
+ nsgtk_download_parent = nsgtk_scaffolding_window(nsgtk_get_scaffold(
+ gui));
struct gui_download_window *download = malloc(sizeof *download);
if (url_nice(url, &filename, false) != URL_FUNC_OK)
Index: gtk/gtk_window.c
===================================================================
--- gtk/gtk_window.c (revision 8438)
+++ gtk/gtk_window.c (working copy)
@@ -22,6 +22,7 @@
#include "gtk/gtk_window.h"
#include "desktop/browser.h"
#include "desktop/options.h"
+#include "desktop/searchweb.h"
#include "desktop/textinput.h"
#include "desktop/selection.h"
#include "gtk/gtk_gui.h"
@@ -35,6 +36,37 @@
#include <gdk/gdkkeysyms.h>
#include <assert.h>
+struct gui_window {
+ /* All gui_window objects have an ultimate scaffold */
+ nsgtk_scaffolding *scaffold;
+ /* A gui_window is the rendering of a browser_window */
+ struct browser_window *bw;
+ struct browser_mouse *mouse;
+
+ /* These are the storage for the rendering */
+ int caretx, carety, careth;
+ gui_pointer_shape current_pointer;
+ int last_x, last_y;
+
+ /* Within GTK, a gui_window is a scrolled window
+ * with a viewport inside
+ * with a gtkfixed in that
+ * with a drawing area in that
+ * The scrolled window is optional and only chosen
+ * for frames which need it. Otherwise we just use
+ * a viewport.
+ */
+ GtkWidget *tab;
+ GtkScrolledWindow *scrolledwindow;
+ GtkViewport *viewport;
+ GtkFixed *fixed;
+ GtkDrawingArea *drawing_area;
+ gulong signalhandler[2];
+
+ /* Keep gui_windows in a list for cleanup later */
+ struct gui_window *next, *prev;
+};
+
struct gui_window *window_list = 0; /**< first entry in win list*/
int temp_open_background = -1;
@@ -60,21 +92,47 @@
static GdkCursor *nsgtk_create_menu_cursor(void);
-struct browser_window *nsgtk_get_browser_window(struct gui_window *g)
+nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g)
{
+ return g->scaffold;
+}
+
+struct browser_window *gui_window_get_browser_window(struct gui_window *g)
+{
return g->bw;
}
-nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g)
+unsigned long nsgtk_window_get_signalhandler(struct gui_window *g, int i)
{
- return g->scaffold;
+ return g->signalhandler[i];
}
-struct browser_window *nsgtk_get_browser_for_gui(struct gui_window *g)
+GtkDrawingArea *nsgtk_window_get_drawing_area(struct gui_window *g)
{
- return g->bw;
+ return g->drawing_area;
}
+GtkScrolledWindow *nsgtk_window_get_scrolledwindow(struct gui_window *g)
+{
+ return g->scrolledwindow;
+}
+
+GtkWidget *nsgtk_window_get_tab(struct gui_window *g)
+{
+ return g->tab;
+}
+
+void nsgtk_window_set_tab(struct gui_window *g, GtkWidget *w)
+{
+ g->tab = w;
+}
+
+
+struct gui_window *nsgtk_window_iterate(struct gui_window *g)
+{
+ return g->next;
+}
+
float nsgtk_get_scale_for_gui(struct gui_window *g)
{
return g->bw->scale;
@@ -111,13 +169,6 @@
g->careth = 0;
- /* Attach ourselves to the list (push_top) */
- if (window_list)
- window_list->prev = g;
- g->next = window_list;
- g->prev = NULL;
- window_list = g;
-
if (bw->parent != NULL)
/* Find our parent's scaffolding */
g->scaffold = bw->parent->window->scaffold;
@@ -127,9 +178,20 @@
else
/* Now construct and attach a scaffold */
g->scaffold = nsgtk_new_scaffolding(g);
+ if (g->scaffold == NULL) {
+ free(g);
+ return NULL;
+ }
- /* Construct our primary elements */
- g->fixed = GTK_FIXED(gtk_fixed_new());
+ /* Attach ourselves to the list (push_top) */
+ if (window_list)
+ window_list->prev = g;
+ g->next = window_list;
+ g->prev = NULL;
+ window_list = g;
+
+ /* Construct our primary elements */
+ g->fixed = GTK_FIXED(gtk_fixed_new());
g->drawing_area = GTK_DRAWING_AREA(gtk_drawing_area_new());
gtk_fixed_put(g->fixed, GTK_WIDGET(g->drawing_area), 0, 0);
gtk_container_set_border_width(GTK_CONTAINER(g->fixed), 0);
@@ -229,17 +291,18 @@
#define CONNECT(obj, sig, callback, ptr) \
g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
- CONNECT(g->drawing_area, "expose_event", nsgtk_window_expose_event, g);
+ g->signalhandler[0] = CONNECT(g->drawing_area, "expose_event",
+ nsgtk_window_expose_event, g);
CONNECT(g->drawing_area, "motion_notify_event",
- nsgtk_window_motion_notify_event, g);
- CONNECT(g->drawing_area, "button_press_event",
- nsgtk_window_button_press_event, g);
+ nsgtk_window_motion_notify_event, g);
+ g->signalhandler[1] = CONNECT(g->drawing_area, "button_press_event",
+ nsgtk_window_button_press_event, g);
CONNECT(g->drawing_area, "button_release_event",
- nsgtk_window_button_release_event, g);
+ nsgtk_window_button_release_event, g);
CONNECT(g->drawing_area, "key_press_event",
- nsgtk_window_keypress_event, g);
+ nsgtk_window_keypress_event, g);
CONNECT(g->viewport, "size_allocate",
- nsgtk_window_size_allocate_event, g);
+ nsgtk_window_size_allocate_event, g);
return g;
}
@@ -382,6 +445,8 @@
struct gui_window *g = data;
gtk_widget_grab_focus(GTK_WIDGET(g->drawing_area));
+ gtk_widget_hide(GTK_WIDGET(nsgtk_scaffolding_history_window(
+ g->scaffold)->window));
g->mouse->pressed_x = event->x / g->bw->scale;
g->mouse->pressed_y = event->y / g->bw->scale;
@@ -562,7 +627,7 @@
{
for (struct gui_window *g = window_list; g; g = g->next) {
nsgtk_tab_options_changed(GTK_WIDGET(
- nsgtk_scaffolding_get_notebook(g)));
+ nsgtk_scaffolding_notebook(g->scaffold)));
g->bw->reformat_pending = true;
}
@@ -697,7 +762,13 @@
gtk_adjustment_set_value(hadj, x);
}
+void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
+ int x1, int y1)
+{
+ gui_window_set_scroll(g,x0,y0);
+}
+
/**
* Set the scale setting of a window
*
Index: gtk/gtk_window.h
===================================================================
--- gtk/gtk_window.h (revision 8438)
+++ gtk/gtk_window.h (working copy)
@@ -23,36 +23,6 @@
#include "desktop/browser.h"
#include "gtk/gtk_scaffolding.h"
-struct gui_window {
- /* All gui_window objects have an ultimate scaffold */
- nsgtk_scaffolding *scaffold;
- /* A gui_window is the rendering of a browser_window */
- struct browser_window *bw;
- struct browser_mouse *mouse;
-
- /* These are the storage for the rendering */
- int caretx, carety, careth;
- gui_pointer_shape current_pointer;
- int last_x, last_y;
-
- /* Within GTK, a gui_window is a scrolled window
- * with a viewport inside
- * with a gtkfixed in that
- * with a drawing area in that
- * The scrolled window is optional and only chosen
- * for frames which need it. Otherwise we just use
- * a viewport.
- */
- GtkWidget *tab;
- GtkScrolledWindow *scrolledwindow;
- GtkViewport *viewport;
- GtkFixed *fixed;
- GtkDrawingArea *drawing_area;
-
- /* Keep gui_windows in a list for cleanup later */
- struct gui_window *next, *prev;
-};
-
struct browser_mouse {
struct gui_window *gui;
struct box *box;
@@ -63,19 +33,23 @@
browser_mouse_state state;
};
-extern struct gui_window * window_list;
+extern struct gui_window *window_list;
extern int temp_open_background;
void nsgtk_reflow_all_windows(void);
void nsgtk_window_process_reformats(void);
nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g);
-struct browser_window *nsgtk_get_browser_for_gui(struct gui_window *g);
float nsgtk_get_scale_for_gui(struct gui_window *g);
int nsgtk_gui_window_update_targets(struct gui_window *g);
void nsgtk_window_destroy_browser(struct gui_window *g);
+unsigned long nsgtk_window_get_signalhandler(struct gui_window *g, int i);
+GtkDrawingArea *nsgtk_window_get_drawing_area(struct gui_window *g);
+struct gui_window *nsgtk_window_iterate(struct gui_window *g);
+GtkScrolledWindow *nsgtk_window_get_scrolledwindow(struct gui_window *g);
+GtkWidget *nsgtk_window_get_tab(struct gui_window *g);
+void nsgtk_window_set_tab(struct gui_window *g, GtkWidget *w);
-struct browser_window *nsgtk_get_browser_window(struct gui_window *g);
#endif /* NETSURF_GTK_WINDOW_H */
Index: gtk/gtk_scaffolding.c
===================================================================
--- gtk/gtk_scaffolding.c (revision 8438)
+++ gtk/gtk_scaffolding.c (working copy)
@@ -1,5 +1,6 @@
/*
* Copyright 2006 Rob Kendrick <rjek(a)rjek.com>
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
*
* This file is part of NetSurf,
http://www.netsurf-browser.org/
*
@@ -17,12 +18,16 @@
*/
#include <assert.h>
+#include <dirent.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <gtk/gtk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libxml/debugXML.h>
+#include "gtk/gtk_scaffolding.h"
#include "content/content.h"
#include "desktop/browser.h"
#include "desktop/history_core.h"
@@ -31,27 +36,36 @@
#include "desktop/options.h"
#include "desktop/plotters.h"
#include "desktop/print.h"
+#include "desktop/save_complete.h"
#ifdef WITH_PDF_EXPORT
#include "desktop/save_pdf/font_haru.h"
#include "desktop/save_pdf/pdf_plotters.h"
#endif
+#include "desktop/save_text.h"
+#include "desktop/search.h"
+#include "desktop/searchweb.h"
#include "desktop/selection.h"
#include "desktop/textinput.h"
#include "gtk/gtk_completion.h"
#include "gtk/dialogs/gtk_options.h"
#include "gtk/dialogs/gtk_about.h"
#include "gtk/dialogs/gtk_source.h"
+#include "gtk/gtk_bitmap.h"
#include "gtk/gtk_download.h"
#include "gtk/gtk_gui.h"
#include "gtk/gtk_history.h"
+#include "gtk/gtk_menu.h"
#include "gtk/gtk_plotters.h"
#include "gtk/gtk_print.h"
-#include "gtk/gtk_scaffolding.h"
#include "gtk/gtk_schedule.h"
+#include "gtk/gtk_search.h"
#include "gtk/gtk_tabs.h"
+#include "gtk/gtk_theme.h"
#include "gtk/gtk_throbber.h"
+#include "gtk/gtk_toolbar.h"
#include "gtk/gtk_window.h"
#include "gtk/options.h"
+#include "image/ico.h"
#include "render/box.h"
#include "render/font.h"
#include "render/form.h"
@@ -62,50 +76,85 @@
#include "utils/log.h"
-struct gtk_history_window;
+struct gtk_scaffolding {
+ GtkWindow *window;
+ GtkNotebook *notebook;
+ GtkEntry *url_bar;
+ GtkEntryCompletion *url_bar_completion;
+ GtkStatusbar *status_bar;
+ struct nsgtk_file_menu *file_menu;
+ struct nsgtk_file_menu *rclick_file_menu;
+ struct nsgtk_edit_menu *edit_menu;
+ struct nsgtk_edit_menu *rclick_edit_menu;
+ struct nsgtk_view_menu *view_menu;
+ struct nsgtk_view_menu *rclick_view_menu;
+ struct nsgtk_nav_menu *nav_menu;
+ struct nsgtk_nav_menu *rclick_nav_menu;
+ struct nsgtk_tabs_menu *tabs_menu;
+ struct nsgtk_tabs_menu *rclick_tabs_menu;
+ struct nsgtk_help_menu *help_menu;
+ struct nsgtk_help_menu *rclick_help_menu;
+ GtkMenuItem *edit_menu_item;
+ GtkMenuItem *tabs_menu_item;
+ GtkToolbar *tool_bar;
+ struct nsgtk_button_connect *buttons[PLACEHOLDER_BUTTON];
+ GtkMenuBar *menu_bar;
+ GtkImage *throbber;
+ GtkImage *icoFav;
+ struct gtk_search *search;
+ GtkImage *webSearchIco;
+ GtkEntry *webSearchEntry;
+ GtkPaned *status_pane;
+
+ int offset;
+ int toolbarmem;
+ int toolbarbase;
+ int historybase;
+
+ GladeXML *xml;
-struct gtk_history_window {
- struct gtk_scaffolding *g;
- GtkWindow *window;
- GtkScrolledWindow *scrolled;
- GtkDrawingArea *drawing_area;
-};
+ GladeXML *popup_xml;
+ GtkMenu *popup_menu;
-struct menu_events {
- const char *widget;
- GCallback handler;
+ struct gtk_history_window *history_window;
+ GtkDialog *preferences_dialog;
+
+ int throb_frame;
+ struct gui_window *top_level;
+ int being_destroyed;
+
+ bool fullscreen;
+
+ /* keep global linked list for gui interface adjustments */
+ struct gtk_scaffolding *next, *prev;
};
static int open_windows = 0; /**< current number of open browsers */
static struct gtk_scaffolding *current_model; /**< current window for model
- dialogue use */
+ dialogue use */
+nsgtk_scaffolding *scaf_list = NULL; /**< global list for interface changes */
static struct box *current_menu_link_box; /**< pointer to the box containing a
link under the mouse, or 0 if none */
-static gboolean nsgtk_window_delete_event(GtkWidget *, gpointer);
-static void nsgtk_window_destroy_event(GtkWidget *, gpointer);
+static gboolean nsgtk_window_delete_event(GtkWidget *, GdkEvent *, gpointer);
+static void nsgtk_window_close(struct gtk_scaffolding *g);
static void nsgtk_window_update_back_forward(struct gtk_scaffolding *);
static void nsgtk_throb(void *);
+static gboolean nsgtk_filter_directory(const GtkFileFilterInfo *info,
+ gpointer data);
static gboolean nsgtk_window_edit_menu_clicked(GtkWidget *widget,
struct gtk_scaffolding *g);
static gboolean nsgtk_window_edit_menu_hidden(GtkWidget *widget,
struct gtk_scaffolding *g);
static gboolean nsgtk_window_popup_menu_hidden(GtkWidget *widget,
struct gtk_scaffolding *g);
-static gboolean nsgtk_window_back_button_clicked(GtkWidget *, gpointer);
-static gboolean nsgtk_window_history_button_clicked(GtkWidget *, gpointer);
-static gboolean nsgtk_window_forward_button_clicked(GtkWidget *, gpointer);
-static gboolean nsgtk_window_stop_button_clicked(GtkWidget *, gpointer);
-static gboolean nsgtk_window_reload_button_clicked(GtkWidget *, gpointer);
-static gboolean nsgtk_window_home_button_clicked(GtkWidget *, gpointer);
-static gboolean nsgtk_window_url_activate_event(GtkWidget *, gpointer);
-static gboolean nsgtk_window_url_changed(GtkWidget *, GdkEventKey *, gpointer);
-
+static gboolean nsgtk_window_tool_bar_clicked(GtkToolbar *toolbar, gint x,
+ gint y, gint button, gpointer data);
static guint nsgtk_scaffolding_update_link_operations_sensitivity(
struct gtk_scaffolding *g, GladeXML *xml, gdouble x, gdouble y,
gboolean hide);
static guint nsgtk_scaffolding_update_edit_actions_sensitivity(
- struct gtk_scaffolding *g, GladeXML *xml, gboolean hide);
+ struct gtk_scaffolding *g, GladeXML *xml, bool hide);
static void nsgtk_scaffolding_enable_link_operations_sensitivity(
struct gtk_scaffolding *g, GladeXML *xml);
static void nsgtk_scaffolding_enable_edit_actions_sensitivity(
@@ -116,168 +165,70 @@
static gboolean nsgtk_history_button_press_event(GtkWidget *, GdkEventButton *,
gpointer);
-static void nsgtk_attach_menu_handlers(GladeXML *, gpointer);
+static void nsgtk_attach_menu_handlers(struct gtk_scaffolding *);
static void nsgtk_window_tabs_num_changed(GtkNotebook *notebook,
GtkWidget *page, guint page_num, struct gtk_scaffolding *g);
void nsgtk_openfile_open(const char *filename);
-#define MENUEVENT(x) { #x, G_CALLBACK(nsgtk_on_##x##_activate) }
-#define MENUPROTO(x) static gboolean nsgtk_on_##x##_activate( \
- GtkMenuItem *widget, gpointer g)
-/* prototypes for menu handlers */
-/* file menu */
-MENUPROTO(new_window);
-MENUPROTO(new_tab);
-MENUPROTO(open_location);
-MENUPROTO(open_file);
-#ifdef WITH_PDF_EXPORT
-MENUPROTO(export_pdf);
-#endif
-MENUPROTO(print);
-MENUPROTO(close_window);
-MENUPROTO(quit);
-
-/* edit menu */
-MENUPROTO(cut);
-MENUPROTO(copy);
-MENUPROTO(paste);
-MENUPROTO(select_all);
-MENUPROTO(preferences);
-
-/* view menu */
-MENUPROTO(stop);
-MENUPROTO(reload);
-MENUPROTO(zoom_in);
-MENUPROTO(normal_size);
-MENUPROTO(zoom_out);
-MENUPROTO(full_screen);
-MENUPROTO(view_source);
-MENUPROTO(menu_bar);
-MENUPROTO(tool_bar);
-MENUPROTO(status_bar);
-MENUPROTO(downloads);
-MENUPROTO(save_window_size);
-MENUPROTO(toggle_debug_rendering);
-MENUPROTO(save_box_tree);
-MENUPROTO(save_dom_tree);
-
-/* navigate menu */
-MENUPROTO(back);
-MENUPROTO(forward);
-MENUPROTO(home);
-MENUPROTO(local_history);
-MENUPROTO(global_history);
-
-/* tabs menu */
-MENUPROTO(next_tab);
-MENUPROTO(prev_tab);
-MENUPROTO(close_tab);
-
-/* help menu */
-MENUPROTO(about);
-
-/* Popup context menu (also shares edit menu handlers) */
-MENUPROTO(save_link);
-MENUPROTO(open_link_in_focused_tab);
-MENUPROTO(open_link_in_background_tab);
-
-/* structure used by nsgtk_attach_menu_handlers to connect menu items to
- * their handling functions.
- */
-static struct menu_events menu_events[] = {
- /* file menu */
- MENUEVENT(new_window),
- MENUEVENT(new_tab),
- MENUEVENT(open_location),
- MENUEVENT(open_file),
-#ifdef WITH_PDF_EXPORT
- MENUEVENT(export_pdf),
-#endif
- MENUEVENT(print),
- MENUEVENT(close_window),
- MENUEVENT(quit),
-
- /* edit menu */
- MENUEVENT(cut),
- MENUEVENT(copy),
- MENUEVENT(paste),
- MENUEVENT(select_all),
- MENUEVENT(preferences),
-
- /* view menu */
- MENUEVENT(stop),
- MENUEVENT(reload),
- MENUEVENT(zoom_in),
- MENUEVENT(normal_size),
- MENUEVENT(zoom_out),
- MENUEVENT(full_screen),
- MENUEVENT(view_source),
- MENUEVENT(menu_bar),
- MENUEVENT(tool_bar),
- MENUEVENT(status_bar),
- MENUEVENT(downloads),
- MENUEVENT(save_window_size),
- MENUEVENT(toggle_debug_rendering),
- MENUEVENT(save_box_tree),
- MENUEVENT(save_dom_tree),
-
- /* navigate menu */
- MENUEVENT(back),
- MENUEVENT(forward),
- MENUEVENT(home),
- MENUEVENT(local_history),
- MENUEVENT(global_history),
-
- /* tab menu */
- MENUEVENT(next_tab),
- MENUEVENT(prev_tab),
- MENUEVENT(close_tab),
-
- /* help menu */
- MENUEVENT(about),
-
- /* sentinel */
- { NULL, NULL }
-};
-
-void nsgtk_attach_menu_handlers(GladeXML *xml, gpointer g)
+void nsgtk_attach_menu_handlers(struct gtk_scaffolding *g)
{
- struct menu_events *event = menu_events;
-
- while (event->widget != NULL)
- {
- GtkWidget *w = glade_xml_get_widget(xml, event->widget);
- g_signal_connect(G_OBJECT(w), "activate", event->handler, g);
- event++;
+ for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ if (g->buttons[i]->main != NULL) {
+ g_signal_connect(g->buttons[i]->main, "activate",
+ G_CALLBACK(g->buttons[i]->mhandler), g);
+ }
+ if (g->buttons[i]->rclick != NULL) {
+ g_signal_connect(g->buttons[i]->rclick, "activate",
+ G_CALLBACK(g->buttons[i]->mhandler), g);
+ }
+ if (g->buttons[i]->popup != NULL) {
+ g_signal_connect(g->buttons[i]->popup, "activate",
+ G_CALLBACK(g->buttons[i]->mhandler), g);
+ }
}
-}
+#define CONNECT_CHECK(q)\
+ g_signal_connect(g->view_menu->toolbars_submenu->q##_menuitem,\
+ "toggled", G_CALLBACK(nsgtk_on_##q##_activate), g);\
+ g_signal_connect(g->rclick_view_menu->toolbars_submenu->q##_menuitem,\
+ "toggled", G_CALLBACK(nsgtk_on_##q##_activate), g)
+ CONNECT_CHECK(menubar);
+ CONNECT_CHECK(toolbar);
+ CONNECT_CHECK(statusbar);
+#undef CONNECT_CHECK
-GtkWindow *nsgtk_get_window_for_scaffold(struct gtk_scaffolding *g)
-{
- return g->window;
}
/* event handlers and support functions for them */
-gboolean nsgtk_window_delete_event(GtkWidget *widget, gpointer data)
+gboolean nsgtk_window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer
+ data)
{
- struct gtk_scaffolding *g = data;
- gtk_widget_destroy(GTK_WIDGET(g->window));
- if (open_windows == 1 && nsgtk_check_for_downloads(GTK_WINDOW(widget)))
- return TRUE;
- else
- return FALSE;
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ if (open_windows != 1 || nsgtk_check_for_downloads(GTK_WINDOW(
+ widget)) == false) {
+ nsgtk_window_close(g);
+ gtk_widget_destroy(GTK_WIDGET(g->window));
+ }
+ return TRUE;
}
-void nsgtk_window_destroy_event(GtkWidget *widget, gpointer data)
+/**
+ * cleanup function
+ */
+void nsgtk_window_close(struct gtk_scaffolding *g)
{
- struct gtk_scaffolding *g = data;
+ /* close all tabs first */
+ gint numbertabs = gtk_notebook_get_n_pages(g->notebook);
+ while (numbertabs-- > 1) {
+ nsgtk_tab_close_current(g->notebook);
+ }
LOG(("Being Destroyed = %d", g->being_destroyed));
- if (g->history_window->window) {
+/* if ((g->history_window) && (g->history_window->window)) {
gtk_widget_destroy(GTK_WIDGET(g->history_window->window));
}
- gtk_widget_destroy(GTK_WIDGET(g->window));
-
+ if (g->window)
+ gtk_widget_destroy(GTK_WIDGET(g->window));
+*/
if (--open_windows == 0)
netsurf_quit = true;
@@ -285,38 +236,38 @@
g->being_destroyed = 1;
nsgtk_window_destroy_browser(g->top_level);
}
+ if (g->prev)
+ g->prev->next = g->next;
+ else
+ scaf_list = g->next;
+
+ if (g->next)
+ g->next->prev = g->prev;
+
}
-void nsgtk_scaffolding_destroy(nsgtk_scaffolding *scaffold)
+void nsgtk_scaffolding_destroy(nsgtk_scaffolding *g)
{
/* Our top_level has asked us to die */
- LOG(("Being Destroyed = %d", scaffold->being_destroyed));
- if (scaffold->being_destroyed) return;
- scaffold->being_destroyed = 1;
- nsgtk_window_destroy_event(0, scaffold);
+ LOG(("Being Destroyed = %d", g->being_destroyed));
+ if (g->being_destroyed) return;
+ g->being_destroyed = 1;
+ nsgtk_window_close(g);
}
void nsgtk_window_update_back_forward(struct gtk_scaffolding *g)
{
int width, height;
- struct browser_window *bw = nsgtk_get_browser_for_gui(g->top_level);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
- gtk_widget_set_sensitive(GTK_WIDGET(g->back_button),
- history_back_available(bw->history));
- gtk_widget_set_sensitive(GTK_WIDGET(g->forward_button),
- history_forward_available(bw->history));
+ g->buttons[BACK_BUTTON]->sensitivity =
+ history_back_available(bw->history);
+ g->buttons[FORWARD_BUTTON]->sensitivity = history_forward_available(
+ bw->history);
+
+ nsgtk_scaffolding_set_sensitivity(g);
- gtk_widget_set_sensitive(GTK_WIDGET(g->back_menu),
- history_back_available(bw->history));
- gtk_widget_set_sensitive(GTK_WIDGET(g->forward_menu),
- history_forward_available(bw->history));
- gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(g->popup_xml,
- "popupBack")), history_back_available(bw->history));
- gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(g->popup_xml,
- "popupForward")),
- history_forward_available(bw->history));
-
/* update the url bar, particularly necessary when tabbing */
if (bw->current_content != NULL && bw->current_content->url != NULL)
browser_window_refresh_url_bar(bw, bw->current_content->url,
@@ -350,7 +301,7 @@
static gboolean nsgtk_window_edit_menu_clicked(GtkWidget *widget,
struct gtk_scaffolding *g)
{
- nsgtk_scaffolding_update_edit_actions_sensitivity (g, g->xml, FALSE);
+ nsgtk_scaffolding_update_edit_actions_sensitivity(g, g->xml, false);
return TRUE;
}
@@ -370,97 +321,15 @@
return TRUE;
}
-gboolean nsgtk_window_back_button_clicked(GtkWidget *widget, gpointer data)
-{
- struct gtk_scaffolding *g = data;
- struct browser_window *bw = nsgtk_get_browser_for_gui(g->top_level);
-
- if (!history_back_available(bw->history))
- return TRUE;
-
- history_back(bw, bw->history);
- nsgtk_window_update_back_forward(g);
-
- return TRUE;
-}
-
-/* TODO: add resize handling */
-gboolean nsgtk_window_history_button_clicked(GtkWidget *widget, gpointer data)
-{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)data;
-
- /* if entries of the same url but different frag_ids have been added
- * the history needs redrawing (what is done in the throbber code in
- * other cases)
- */
- nsgtk_window_update_back_forward(gw);
-
- gtk_window_set_default_size(gw->history_window->window, 500, 150);
- gtk_window_set_position(gw->history_window->window, GTK_WIN_POS_MOUSE);
- gtk_window_set_transient_for(gw->history_window->window, gw->window);
- gtk_window_set_opacity(gw->history_window->window, 0.9);
- gtk_widget_show(GTK_WIDGET(gw->history_window->window));
- gdk_window_raise(GTK_WIDGET(gw->history_window->window)->window);
-
- return TRUE;
-}
-
-gboolean nsgtk_window_forward_button_clicked(GtkWidget *widget, gpointer data)
-{
- struct gtk_scaffolding *g = data;
- struct browser_window *bw = nsgtk_get_browser_for_gui(g->top_level);
-
- if (!history_forward_available(bw->history))
- return TRUE;
-
- history_forward(bw, bw->history);
- nsgtk_window_update_back_forward(g);
-
- return TRUE;
-}
-
-gboolean nsgtk_window_stop_button_clicked(GtkWidget *widget, gpointer data)
-{
- struct gtk_scaffolding *g = data;
- struct browser_window *bw = nsgtk_get_browser_for_gui(g->top_level);
-
- browser_window_stop(bw);
-
- return TRUE;
-}
-
-gboolean nsgtk_window_reload_button_clicked(GtkWidget *widget, gpointer data)
-{
- struct gtk_scaffolding *g = data;
- struct browser_window *bw = nsgtk_get_browser_for_gui(g->top_level);
-
- browser_window_reload(bw, true);
-
- return TRUE;
-}
-
-gboolean nsgtk_window_home_button_clicked(GtkWidget *widget, gpointer data)
-{
- struct gtk_scaffolding *g = data;
- static const char *addr = NETSURF_HOMEPAGE;
- struct browser_window *bw = nsgtk_get_browser_for_gui(g->top_level);
-
- if (option_homepage_url != NULL && option_homepage_url[0] !=
'\0')
- addr = option_homepage_url;
-
- browser_window_go(bw, addr, 0, true);
-
- return TRUE;
-}
-
gboolean nsgtk_window_url_activate_event(GtkWidget *widget, gpointer data)
{
struct gtk_scaffolding *g = data;
- struct browser_window *bw = nsgtk_get_browser_for_gui(g->top_level);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+ char *url = (char *)gtk_entry_get_text(GTK_ENTRY(g->url_bar));
+ if (!search_is_url(url))
+ url = search_web_from_term(url);
+ browser_window_go(bw, url, 0, true);
- browser_window_go(bw, gtk_entry_get_text(GTK_ENTRY(g->url_bar)),
- 0, true);
-
return TRUE;
}
@@ -476,17 +345,40 @@
return TRUE;
}
+gboolean nsgtk_window_tool_bar_clicked(GtkToolbar *toolbar, gint x, gint y,
+ gint button, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ /* set visibility for right-click menu */
+ gtk_widget_hide(glade_xml_get_widget(g->popup_xml, "sep2"));
+ gtk_widget_hide(glade_xml_get_widget(g->popup_xml, "save_link_popup"));
+ gtk_widget_hide(glade_xml_get_widget(g->popup_xml,
+ "open_link_in_focused_tab_popup"));
+ gtk_widget_hide(glade_xml_get_widget(g->popup_xml,
+ "open_link_in_background_tab_popup"));
+ gtk_widget_show(glade_xml_get_widget(g->popup_xml, "customize_popup"));
+ gtk_widget_hide(glade_xml_get_widget(g->popup_xml, "copy_popup"));
+ gtk_widget_hide(glade_xml_get_widget(g->popup_xml, "cut_popup"));
+ gtk_widget_hide(glade_xml_get_widget(g->popup_xml, "paste_popup"));
+ gtk_menu_popup(g->popup_menu, NULL, NULL, NULL, NULL, 0,
+ gtk_get_current_event_time());
+ return TRUE;
+}
void nsgtk_window_tabs_num_changed(GtkNotebook *notebook, GtkWidget *page,
guint page_num, struct gtk_scaffolding *g)
{
gboolean visible = gtk_notebook_get_show_tabs(g->notebook);
- g_object_set(g->tabs_menu, "visible", visible, NULL);
+ g_object_set(g->tabs_menu_item, "visible", visible, NULL);
+ g->buttons[NEXTTAB_BUTTON]->sensitivity = visible;
+ g->buttons[PREVTAB_BUTTON]->sensitivity = visible;
+ g->buttons[CLOSETAB_BUTTON]->sensitivity = visible;
+ nsgtk_scaffolding_set_sensitivity(g);
}
void nsgtk_openfile_open(const char *filename)
{
- struct browser_window *bw = nsgtk_get_browser_for_gui(
+ struct browser_window *bw = gui_window_get_browser_window(
current_model->top_level);
char *url = malloc(strlen(filename) + sizeof("file://"));
@@ -498,25 +390,39 @@
}
/* signal handlers for menu entries */
-#define MENUHANDLER(x) gboolean nsgtk_on_##x##_activate(GtkMenuItem *widget, \
- gpointer g)
+#define MULTIHANDLER(q)\
+gboolean nsgtk_on_##q##_activate_menu(GtkMenuItem *widget, gpointer data)\
+{\
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;\
+ return nsgtk_on_##q##_activate(g);\
+}\
+gboolean nsgtk_on_##q##_activate_button(GtkButton *widget, gpointer data)\
+{\
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;\
+ return nsgtk_on_##q##_activate(g);\
+}\
+gboolean nsgtk_on_##q##_activate(struct gtk_scaffolding *g)
-MENUHANDLER(new_window)
+#define MENUHANDLER(q)\
+gboolean nsgtk_on_##q##_activate(GtkMenuItem *widget, gpointer data)
+
+#define BUTTONHANDLER(q)\
+gboolean nsgtk_on_##q##_activate(GtkButton *widget, gpointer data)
+
+MULTIHANDLER(newwindow)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
- const char *url = gtk_entry_get_text(GTK_ENTRY(gw->url_bar));
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+ const char *url = gtk_entry_get_text(GTK_ENTRY(g->url_bar));
browser_window_create(url, bw, NULL, false, false);
return TRUE;
}
-MENUHANDLER(new_tab)
+MULTIHANDLER(newtab)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
- const char *url = gtk_entry_get_text(GTK_ENTRY(gw->url_bar));
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+ const char *url = gtk_entry_get_text(GTK_ENTRY(g->url_bar));
if (option_new_blank)
browser_window_create(0, bw, NULL, false, true);
@@ -527,18 +433,16 @@
return TRUE;
}
-MENUHANDLER(open_location)
+MULTIHANDLER(open_location)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
+ gtk_widget_grab_focus(GTK_WIDGET(g->url_bar));
- gtk_widget_grab_focus(GTK_WIDGET(gw->url_bar));
-
return TRUE;
}
-MENUHANDLER(open_file)
+MULTIHANDLER(openfile)
{
- current_model = (struct gtk_scaffolding *)g;
+ current_model = g;
GtkWidget *dlgOpen = gtk_file_chooser_dialog_new("Open File",
current_model->window, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, -6, GTK_STOCK_OPEN, -5, NULL);
@@ -557,12 +461,75 @@
return TRUE;
}
+MULTIHANDLER(savepage)
+{
+ if (gui_window_get_browser_window(g->top_level)->current_content
+ == NULL)
+ return FALSE;
+
+ GtkWidget *fc = gtk_file_chooser_dialog_new(
+ messages_get("gtkcompleteSave"), g->window,
+ GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT,
+ NULL);
+ DIR *d;
+ char *path;
+ url_func_result res;
+ GtkFileFilter *filter = gtk_file_filter_new();
+ gtk_file_filter_set_name(filter, "directory");
+ gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME,
+ nsgtk_filter_directory, NULL, NULL);
+ gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fc), filter);
+ gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fc), filter);
+
+ res = url_nice(gui_window_get_browser_window(
+ g->top_level)->current_content->url, &path, false);
+ if (res != URL_FUNC_OK) {
+ path = strdup(messages_get("SaveText"));
+ if (path == NULL) {
+ warn_user("NoMemory", 0);
+ return FALSE;
+ }
+ }
+
+ if (access(path, F_OK) != 0)
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), path);
+ free(path);
+
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(fc),
+ TRUE);
+
+ if (gtk_dialog_run(GTK_DIALOG(fc)) != GTK_RESPONSE_ACCEPT)
+ return TRUE;
+ path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
+ d = opendir(path);
+ if (d == NULL) {
+ printf("d NULL\n");
+ if (errno == ENOTDIR)
+ warn_user("NoDirError", path);
+ else
+ warn_user("gtkFileError", path);
+ return TRUE;
+ }
+ closedir(d);
+ save_complete_init();
+ save_complete(gui_window_get_browser_window(
+ g->top_level)->current_content, path);
+ g_free(path);
+
+ gtk_widget_destroy(fc);
+
+ return TRUE;
+}
+
+
+MULTIHANDLER(pdf)
+{
#ifdef WITH_PDF_EXPORT
-MENUHANDLER(export_pdf)
-{
+
GtkWidget *save_dialog;
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
struct print_settings *settings;
char filename[PATH_MAX];
char dirname[PATH_MAX];
@@ -592,7 +559,7 @@
used by the all-purpose print interface*/
haru_nsfont_set_scale((float)option_export_scale / 100);
- save_dialog = gtk_file_chooser_dialog_new("Export to PDF", gw->window,
+ save_dialog = gtk_file_chooser_dialog_new("Export to PDF", g->window,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
@@ -624,14 +591,72 @@
gtk_widget_destroy(save_dialog);
+#endif /* WITH_PDF_EXPORT */
+
return TRUE;
}
-#endif /* WITH_PDF_EXPORT */
-MENUHANDLER(print)
+MULTIHANDLER(plaintext)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
+ if (gui_window_get_browser_window(g->top_level)->current_content
+ == NULL)
+ return FALSE;
+
+ GtkWidget *fc = gtk_file_chooser_dialog_new(
+ messages_get("gtkplainSave"), g->window,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ char *filename;
+ url_func_result res;
+
+ res = url_nice(gui_window_get_browser_window(
+ g->top_level)->current_content->url, &filename, false);
+ if (res != URL_FUNC_OK) {
+ filename = strdup(messages_get("SaveText"));
+ if (filename == NULL) {
+ warn_user("NoMemory", 0);
+ return FALSE;
+ }
+ }
+
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), filename);
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(fc),
+ TRUE);
+
+ free(filename);
+
+ if (gtk_dialog_run(GTK_DIALOG(fc)) == GTK_RESPONSE_ACCEPT) {
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
+ save_as_text(gui_window_get_browser_window(
+ g->top_level)->current_content, filename);
+ g_free(filename);
+ }
+
+ gtk_widget_destroy(fc);
+ return TRUE;
+}
+
+MULTIHANDLER(drawfile)
+{
+ return TRUE;
+}
+
+MULTIHANDLER(postscript)
+{
+ return TRUE;
+}
+
+MULTIHANDLER(printpreview)
+{
+ return TRUE;
+}
+
+
+MULTIHANDLER(print)
+{
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
GtkPrintOperation *print_op;
GtkPageSetup *page_setup;
@@ -658,7 +683,7 @@
content_to_print = bw->current_content;
- page_setup = gtk_print_run_page_setup_dialog(gw->window, NULL, NULL);
+ page_setup = gtk_print_run_page_setup_dialog(g->window, NULL, NULL);
if (page_setup == NULL) {
warn_user(messages_get("NoMemory"), 0);
g_object_unref(print_op);
@@ -677,7 +702,7 @@
if (bw->current_content->type != CONTENT_TEXTPLAIN)
res = gtk_print_operation_run(print_op,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
- gw->window,
+ g->window,
NULL);
/* if the settings were used save them for future use */
@@ -697,50 +722,46 @@
return TRUE;
}
-MENUHANDLER(close_window)
+MULTIHANDLER(closewindow)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
-
/* close all tabs first */
- gint numbertabs = gtk_notebook_get_n_pages(gw->notebook);
+ gint numbertabs = gtk_notebook_get_n_pages(g->notebook);
while (numbertabs-- > 1) {
- nsgtk_tab_close_current(gw->notebook);
+ nsgtk_tab_close_current(g->notebook);
}
- gtk_widget_destroy(GTK_WIDGET(gw->window));
-
+ nsgtk_window_close(g);
+ gtk_widget_destroy(GTK_WIDGET(g->window));
return TRUE;
}
-MENUHANDLER(quit)
+MULTIHANDLER(quit)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
-
- if (nsgtk_check_for_downloads(gw->window) == false)
+ if (nsgtk_check_for_downloads(g->window) == false)
netsurf_quit = true;
return TRUE;
}
-MENUHANDLER(save_link)
+MENUHANDLER(savelink)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct gui_window *gui = gw->top_level;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gui);
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *) data;
+ struct gui_window *gui = g->top_level;
+ struct browser_window *bw = gui_window_get_browser_window(gui);
+
+ if (!current_menu_link_box)
+ return FALSE;
+
+ browser_window_download(bw, current_menu_link_box->href,
+ bw->current_content->url);
- if (!current_menu_link_box)
- return FALSE;
-
- browser_window_download(bw, current_menu_link_box->href,
- bw->current_content->url);
-
- return TRUE;
+ return TRUE;
}
-MENUHANDLER(open_link_in_focused_tab)
+MENUHANDLER(linkfocused)
{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *) data;
temp_open_background = 0;
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct gui_window *gui = gw->top_level;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gui);
+ struct gui_window *gui = g->top_level;
+ struct browser_window *bw = gui_window_get_browser_window(gui);
if (current_menu_link_box == NULL)
return FALSE;
@@ -752,11 +773,11 @@
return TRUE;
}
-MENUHANDLER(open_link_in_background_tab)
+MENUHANDLER(linkbackground)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct gui_window *gui = gw->top_level;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gui);
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *) data;
+ struct gui_window *gui = g->top_level;
+ struct browser_window *bw = gui_window_get_browser_window(gui);
temp_open_background = 1;
@@ -771,41 +792,38 @@
}
-MENUHANDLER(cut)
+MULTIHANDLER(cut)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
- GtkWidget *focused = gtk_window_get_focus(gw->window);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+ GtkWidget *focused = gtk_window_get_focus(g->window);
/* If the url bar has focus, let gtk handle it */
if (GTK_IS_EDITABLE (focused))
- gtk_editable_cut_clipboard (GTK_EDITABLE(gw->url_bar));
+ gtk_editable_cut_clipboard (GTK_EDITABLE(g->url_bar));
else
browser_window_key_press(bw, KEY_CUT_SELECTION);
return TRUE;
}
-MENUHANDLER(copy)
+MULTIHANDLER(copy)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
- GtkWidget *focused = gtk_window_get_focus(gw->window);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+ GtkWidget *focused = gtk_window_get_focus(g->window);
/* If the url bar has focus, let gtk handle it */
if (GTK_IS_EDITABLE (focused))
- gtk_editable_copy_clipboard(GTK_EDITABLE(gw->url_bar));
+ gtk_editable_copy_clipboard(GTK_EDITABLE(g->url_bar));
else
gui_copy_to_clipboard(bw->sel);
return TRUE;
}
-MENUHANDLER(paste)
+MULTIHANDLER(paste)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct gui_window *gui = gw->top_level;
- GtkWidget *focused = gtk_window_get_focus(gw->window);
+ struct gui_window *gui = g->top_level;
+ GtkWidget *focused = gtk_window_get_focus(g->window);
/* If the url bar has focus, let gtk handle it */
if (GTK_IS_EDITABLE (focused))
@@ -816,14 +834,25 @@
return TRUE;
}
-MENUHANDLER(select_all)
+MULTIHANDLER(delete)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
+ return TRUE;
+}
+
+MENUHANDLER(customize)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ nsgtk_toolbar_customization_init(g);
+ return TRUE;
+}
+
+MULTIHANDLER(selectall)
+{
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
- if (GTK_WIDGET_HAS_FOCUS(gw->url_bar)) {
+ if (GTK_WIDGET_HAS_FOCUS(g->url_bar)) {
LOG(("Selecting all URL bar text"));
- gtk_editable_select_region(GTK_EDITABLE(gw->url_bar), 0, -1);
+ gtk_editable_select_region(GTK_EDITABLE(g->url_bar), 0, -1);
} else {
LOG(("Selecting all document text"));
selection_select_all(bw->sel);
@@ -832,145 +861,211 @@
return TRUE;
}
-MENUHANDLER(preferences)
+MULTIHANDLER(find)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
- if (gw->preferences_dialog == NULL)
- gw->preferences_dialog = nsgtk_options_init(bw, gw->window);
+ nsgtk_scaffolding_toggle_search_bar_visibility(g);
+ return TRUE;
+}
+
+MULTIHANDLER(preferences)
+{
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+ if (g->preferences_dialog == NULL)
+ g->preferences_dialog = nsgtk_options_init(bw, g->window);
else
- gtk_widget_show (GTK_WIDGET(gw->preferences_dialog));
+ gtk_widget_show(GTK_WIDGET(g->preferences_dialog));
return TRUE;
}
-MENUHANDLER(zoom_in)
+MULTIHANDLER(zoomplus)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
- float old_scale = nsgtk_get_scale_for_gui(gw->top_level);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+ float old_scale = nsgtk_get_scale_for_gui(g->top_level);
browser_window_set_scale(bw, old_scale + 0.05, true);
return TRUE;
}
-MENUHANDLER(normal_size)
+MULTIHANDLER(zoomnormal)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
browser_window_set_scale(bw, 1.0, true);
return TRUE;
}
-MENUHANDLER(zoom_out)
+MULTIHANDLER(zoomminus)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- struct browser_window *bw = nsgtk_get_browser_for_gui(gw->top_level);
- float old_scale = nsgtk_get_scale_for_gui(gw->top_level);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+ float old_scale = nsgtk_get_scale_for_gui(g->top_level);
browser_window_set_scale(bw, old_scale - 0.05, true);
return TRUE;
}
-MENUHANDLER(full_screen)
+MULTIHANDLER(fullscreen)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
-
- if (gw->fullscreen) {
- gtk_window_unfullscreen(gw->window);
+ if (g->fullscreen) {
+ gtk_window_unfullscreen(g->window);
} else {
- gtk_window_fullscreen(gw->window);
+ gtk_window_fullscreen(g->window);
}
- gw->fullscreen = !gw->fullscreen;
+ g->fullscreen = !g->fullscreen;
return TRUE;
}
-MENUHANDLER(view_source)
+MULTIHANDLER(viewsource)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- nsgtk_source_dialog_init(gw->window,
- nsgtk_get_browser_for_gui(gw->top_level));
+ nsgtk_source_dialog_init(g->window,
+ gui_window_get_browser_window(g->top_level));
return TRUE;
}
-MENUHANDLER(menu_bar)
+MENUHANDLER(menubar)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
-
+ GtkWidget *w;
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
- gtk_widget_show(GTK_WIDGET(gw->menu_bar));
+ /* need to synchronise menus as gtk grumbles when one menu
+ * is attached to both headers */
+ w = GTK_WIDGET(g->rclick_view_menu->
+ toolbars_submenu->menubar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
+ == FALSE)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ TRUE);
+ w = GTK_WIDGET(g->view_menu->
+ toolbars_submenu->menubar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
+ == FALSE)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ TRUE);
- gtk_widget_show_all(GTK_WIDGET(gw->popup_menu));
-
- GList *widgets = glade_xml_get_widget_prefix(gw->popup_xml,
+ gtk_widget_show(GTK_WIDGET(g->menu_bar));
+
+ gtk_widget_show_all(GTK_WIDGET(g->popup_menu));
+
+ GList *widgets = glade_xml_get_widget_prefix(g->popup_xml,
"menupopup");
for (; widgets != NULL; widgets = widgets->next)
gtk_widget_hide(GTK_WIDGET(widgets->data));
+
} else {
- gtk_widget_hide(GTK_WIDGET(gw->menu_bar));
+ w = GTK_WIDGET(g->rclick_view_menu->
+ toolbars_submenu->menubar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ FALSE);
+ w = GTK_WIDGET(g->view_menu->
+ toolbars_submenu->menubar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ FALSE);
- gtk_widget_hide_all(GTK_WIDGET(gw->popup_menu));
- gtk_widget_show(GTK_WIDGET(gw->popup_menu));
+ gtk_widget_hide(GTK_WIDGET(g->menu_bar));
- GList *widgets = glade_xml_get_widget_prefix(gw->popup_xml,
+ GList *widgets = glade_xml_get_widget_prefix(g->popup_xml,
"menupopup");
for (; widgets != NULL; widgets = widgets->next)
gtk_widget_show_all(GTK_WIDGET(widgets->data));
+
}
-
return TRUE;
}
-MENUHANDLER(tool_bar)
+MENUHANDLER(toolbar)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
-
+ GtkWidget *w;
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
- gtk_widget_show(GTK_WIDGET(gw->tool_bar));
+ w = GTK_WIDGET(g->rclick_view_menu->
+ toolbars_submenu->toolbar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
+ == FALSE)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ TRUE);
+ w = GTK_WIDGET(g->view_menu->
+ toolbars_submenu->toolbar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
+ == FALSE)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ TRUE);
+ gtk_widget_show(GTK_WIDGET(g->tool_bar));
} else {
- gtk_widget_hide(GTK_WIDGET(gw->tool_bar));
+ w = GTK_WIDGET(g->rclick_view_menu->
+ toolbars_submenu->toolbar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ FALSE);
+ w = GTK_WIDGET(g->view_menu->
+ toolbars_submenu->toolbar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ FALSE);
+ gtk_widget_hide(GTK_WIDGET(g->tool_bar));
}
return TRUE;
}
-MENUHANDLER(status_bar)
+MENUHANDLER(statusbar)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
-
+ GtkWidget *w;
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
- gtk_widget_show(GTK_WIDGET(gw->status_bar));
+ w = GTK_WIDGET(g->rclick_view_menu->
+ toolbars_submenu->statusbar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
+ == FALSE)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ TRUE);
+ w = GTK_WIDGET(g->view_menu->
+ toolbars_submenu->statusbar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
+ == FALSE)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ TRUE);
+ gtk_widget_show(GTK_WIDGET(g->status_bar));
} else {
- gtk_widget_hide(GTK_WIDGET(gw->status_bar));
+ w = GTK_WIDGET(g->rclick_view_menu->
+ toolbars_submenu->statusbar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ FALSE);
+ w = GTK_WIDGET(g->view_menu->
+ toolbars_submenu->statusbar_menuitem);
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
+ FALSE);
+ gtk_widget_hide(GTK_WIDGET(g->status_bar));
}
return TRUE;
}
-MENUHANDLER(downloads)
+MULTIHANDLER(downloads)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- nsgtk_download_show(gw->window);
+ nsgtk_download_show(g->window);
return TRUE;
}
-MENUHANDLER(save_window_size)
+MULTIHANDLER(savewindowsize)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
-
- option_toolbar_status_width = gtk_paned_get_position(gw->status_pane);
- gtk_window_get_position(gw->window, &option_window_x,
+ option_toolbar_status_width = gtk_paned_get_position(g->status_pane);
+ gtk_window_get_position(g->window, &option_window_x,
&option_window_y);
- gtk_window_get_size(gw->window, &option_window_width,
+ gtk_window_get_size(g->window, &option_window_width,
&option_window_height);
@@ -979,19 +1074,18 @@
return TRUE;
}
-MENUHANDLER(toggle_debug_rendering)
+MULTIHANDLER(toggledebugging)
{
html_redraw_debug = !html_redraw_debug;
nsgtk_reflow_all_windows();
return TRUE;
}
-MENUHANDLER(save_box_tree)
+MULTIHANDLER(saveboxtree)
{
GtkWidget *save_dialog;
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- save_dialog = gtk_file_chooser_dialog_new("Save File", gw->window,
+ save_dialog = gtk_file_chooser_dialog_new("Save File", g->window,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
@@ -1016,7 +1110,7 @@
"Unable to open file for writing.");
} else {
struct browser_window *bw;
- bw = nsgtk_get_browser_window(gw->top_level);
+ bw = gui_window_get_browser_window(g->top_level);
if (bw->current_content &&
bw->current_content->type ==
@@ -1037,12 +1131,11 @@
return TRUE;
}
-MENUHANDLER(save_dom_tree)
+MULTIHANDLER(savedomtree)
{
GtkWidget *save_dialog;
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- save_dialog = gtk_file_chooser_dialog_new("Save File", gw->window,
+ save_dialog = gtk_file_chooser_dialog_new("Save File", g->window,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
@@ -1066,7 +1159,7 @@
"Unable to open file for writing.");
} else {
struct browser_window *bw;
- bw = nsgtk_get_browser_window(gw->top_level);
+ bw = gui_window_get_browser_window(g->top_level);
if (bw->current_content &&
bw->current_content->type ==
@@ -1088,37 +1181,94 @@
}
-MENUHANDLER(stop)
+MULTIHANDLER(stop)
{
- return nsgtk_window_stop_button_clicked(GTK_WIDGET(widget), g);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+
+ browser_window_stop(bw);
+
+ return TRUE;
}
-MENUHANDLER(reload)
+MULTIHANDLER(reload)
{
- return nsgtk_window_reload_button_clicked(GTK_WIDGET(widget), g);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+
+ /* clear potential search effects */
+ search_reset();
+
+ browser_window_reload(bw, true);
+
+ return TRUE;
}
-MENUHANDLER(back)
+MULTIHANDLER(back)
{
- return nsgtk_window_back_button_clicked(GTK_WIDGET(widget), g);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+
+ if (!history_back_available(bw->history))
+ return TRUE;
+
+ /* clear potential search effects */
+ search_reset();
+
+ history_back(bw, bw->history);
+ nsgtk_window_update_back_forward(g);
+
+ return TRUE;
}
-MENUHANDLER(forward)
+MULTIHANDLER(forward)
{
- return nsgtk_window_forward_button_clicked(GTK_WIDGET(widget), g);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+
+ if (!history_forward_available(bw->history))
+ return TRUE;
+
+ /* clear potential search effects */
+ search_reset();
+
+ history_forward(bw, bw->history);
+ nsgtk_window_update_back_forward(g);
+
+ return TRUE;
}
-MENUHANDLER(home)
+MULTIHANDLER(home)
{
- return nsgtk_window_home_button_clicked(GTK_WIDGET(widget), g);
+ static const char *addr = NETSURF_HOMEPAGE;
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
+
+ if (option_homepage_url != NULL && option_homepage_url[0] !=
'\0')
+ addr = option_homepage_url;
+
+ browser_window_go(bw, addr, 0, true);
+
+ return TRUE;
}
-MENUHANDLER(local_history)
+MULTIHANDLER(localhistory)
{
- return nsgtk_window_history_button_clicked(GTK_WIDGET(widget), g);
+/* TODO: add resize handling */
+ int x,y;
+ /* if entries of the same url but different frag_ids have been added
+ * the history needs redrawing (what throbber code normally does)
+ */
+ nsgtk_window_update_back_forward(g);
+ gtk_window_get_position(g->window, &x, &y);
+ gtk_window_set_default_size(g->history_window->window, 600, 200);
+ gtk_window_set_transient_for(g->history_window->window, g->window);
+ gtk_window_set_opacity(g->history_window->window, 0.9);
+ gtk_window_set_decorated(g->history_window->window, FALSE);
+ gtk_widget_show(GTK_WIDGET(g->history_window->window));
+ gtk_window_move(g->history_window->window, x + g->historybase, y +
+ g->toolbarbase);
+ gdk_window_raise(GTK_WIDGET(g->history_window->window)->window);
+
+ return TRUE;
}
-MENUHANDLER(global_history)
+MULTIHANDLER(globalhistory)
{
gtk_widget_show(GTK_WIDGET(wndHistory));
gdk_window_raise(GTK_WIDGET(wndHistory)->window);
@@ -1126,49 +1276,89 @@
return TRUE;
}
-MENUHANDLER(next_tab)
+MULTIHANDLER(addbookmarks)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
+ return TRUE;
+}
- gtk_notebook_next_page(gw->notebook);
-
+MULTIHANDLER(showbookmarks)
+{
return TRUE;
}
-MENUHANDLER(prev_tab)
+MULTIHANDLER(openlocation)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
+ gtk_widget_grab_focus(GTK_WIDGET(g->url_bar));
+ return TRUE;
+}
- gtk_notebook_prev_page(gw->notebook);
+MULTIHANDLER(nexttab)
+{
+ gtk_notebook_next_page(g->notebook);
return TRUE;
}
-MENUHANDLER(close_tab)
+MULTIHANDLER(prevtab)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
+ gtk_notebook_prev_page(g->notebook);
- nsgtk_tab_close_current(gw->notebook);
+ return TRUE;
+}
+MULTIHANDLER(closetab)
+{
+ nsgtk_tab_close_current(g->notebook);
+
return TRUE;
}
-MENUHANDLER(about)
+MULTIHANDLER(contents)
{
- struct gtk_scaffolding *gw = (struct gtk_scaffolding *)g;
- nsgtk_about_dialog_init(gw->window,
- nsgtk_get_browser_for_gui(gw->top_level),
+ return TRUE;
+}
+
+MULTIHANDLER(guide)
+{
+ return TRUE;
+}
+
+MULTIHANDLER(info)
+{
+ return TRUE;
+}
+
+MULTIHANDLER(about)
+{
+ nsgtk_about_dialog_init(g->window,
+ gui_window_get_browser_window(g->top_level),
netsurf_version);
return TRUE;
}
+BUTTONHANDLER(history)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ return nsgtk_on_localhistory_activate(g);
+}
+
+gboolean nsgtk_filter_directory(const GtkFileFilterInfo *info,
+ gpointer data)
+{
+ DIR *d = opendir(info->filename);
+ if (d == NULL)
+ return FALSE;
+ closedir(d);
+ return TRUE;
+}
+
/* signal handler functions for the local history window */
gboolean nsgtk_history_expose_event(GtkWidget *widget,
GdkEventExpose *event, gpointer g)
{
struct gtk_history_window *hw = (struct gtk_history_window *)g;
struct browser_window *bw =
- nsgtk_get_browser_for_gui(hw->g->top_level);
+ gui_window_get_browser_window(hw->g->top_level);
current_widget = widget;
current_drawable = widget->window;
@@ -1188,12 +1378,16 @@
return FALSE;
}
+#undef MULTIHANDLER
+#undef CHECKHANDLER
+#undef BUTTONHANDLER
+
gboolean nsgtk_history_button_press_event(GtkWidget *widget,
GdkEventButton *event, gpointer g)
{
struct gtk_history_window *hw = (struct gtk_history_window *)g;
struct browser_window *bw =
- nsgtk_get_browser_for_gui(hw->g->top_level);
+ gui_window_get_browser_window(hw->g->top_level);
LOG(("X=%g, Y=%g", event->x, event->y));
@@ -1207,7 +1401,9 @@
nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
{
- struct gtk_scaffolding *g = malloc(sizeof(*g));
+ struct gtk_scaffolding *g = malloc(sizeof(*g));
+ char *searchname;
+ int i;
LOG(("Constructing a scaffold of %p for gui_window %p", g, toplevel));
@@ -1218,29 +1414,78 @@
/* load the window template from the glade xml file, and extract
* widget references from it for later use.
*/
- g->xml = glade_xml_new(glade_file_location, "wndBrowser", NULL);
+ g->xml = glade_xml_new(glade_netsurf_file_location,
+ "wndBrowser", NULL);
glade_xml_signal_autoconnect(g->xml);
g->window = GTK_WINDOW(GET_WIDGET("wndBrowser"));
g->notebook = GTK_NOTEBOOK(GET_WIDGET("notebook"));
- g->url_bar = GTK_ENTRY(GET_WIDGET("URLBar"));
g->menu_bar = GTK_MENU_BAR(GET_WIDGET("menubar"));
g->status_bar = GTK_STATUSBAR(GET_WIDGET("statusbar"));
- g->edit_menu = GTK_MENU_ITEM(GET_WIDGET("menuitem_edit"));
- g->tabs_menu = GTK_MENU_ITEM(GET_WIDGET("menuitem_tabs"));
g->tool_bar = GTK_TOOLBAR(GET_WIDGET("toolbar"));
- g->back_button = GTK_TOOL_BUTTON(GET_WIDGET("toolBack"));
- g->forward_button = GTK_TOOL_BUTTON(GET_WIDGET("toolForward"));
- g->stop_button = GTK_TOOL_BUTTON(GET_WIDGET("toolStop"));
- g->reload_button = GTK_TOOL_BUTTON(GET_WIDGET("toolReload"));
- g->back_menu = GTK_MENU_ITEM(GET_WIDGET("back"));
- g->history_button = GTK_TOOL_BUTTON(GET_WIDGET("toolHistory"));
- g->forward_menu = GTK_MENU_ITEM(GET_WIDGET("forward"));
- g->stop_menu = GTK_MENU_ITEM(GET_WIDGET("stop"));
- g->reload_menu = GTK_MENU_ITEM(GET_WIDGET("reload"));
- g->throbber = GTK_IMAGE(GET_WIDGET("throbber"));
+ g->search = malloc(sizeof(struct gtk_search));
+ if (g->search == NULL) {
+ warn_user("NoMemory", 0);
+ return NULL;
+ }
+
+ g->search->bar = GTK_TOOLBAR(GET_WIDGET("searchbar"));
+ g->search->entry = GTK_ENTRY(GET_WIDGET("searchEntry"));
+
+ g->search->buttons[0] =
GTK_TOOL_BUTTON(GET_WIDGET("searchBackButton"));
+ g->search->buttons[1] = GTK_TOOL_BUTTON(GET_WIDGET(
+ "searchForwardButton"));
+ g->search->buttons[2] = GTK_TOOL_BUTTON(GET_WIDGET(
+ "closeSearchButton"));
+ g->search->checkAll = GTK_CHECK_BUTTON(GET_WIDGET("checkAllSearch"));
+ g->search->caseSens = GTK_CHECK_BUTTON(GET_WIDGET("caseSensButton"));
+
+ GtkAccelGroup *group = gtk_accel_group_new();
+ gtk_window_add_accel_group(g->window, group);
+
+
+ for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ g->buttons[i] = malloc(sizeof(struct nsgtk_button_connect));
+ if (g->buttons[i] == NULL) {
+ warn_user("NoMemory", 0);
+ return NULL;
+ }
+ g->buttons[i]->button = NULL;
+ g->buttons[i]->location = -1;
+ g->buttons[i]->sensitivity = true;
+ g->buttons[i]->main = NULL;
+ g->buttons[i]->rclick = NULL;
+ g->buttons[i]->popup = NULL;
+ g->buttons[i]->mhandler = NULL;
+ g->buttons[i]->bhandler = NULL;
+ g->buttons[i]->dataplus = NULL;
+ g->buttons[i]->dataminus = NULL;
+ }
+ /* here custom toolbutton adding code */
+ g->offset = 0;
+ g->toolbarmem = 0;
+ g->toolbarbase = 0;
+ g->historybase = 0;
+ nsgtk_toolbar_customization_load(g);
+ nsgtk_toolbar_set_physical(g);
+#define MAKE_MENUS(q)\
+ g->q##_menu = nsgtk_menu_##q##_menu(group);\
+ g->rclick_##q##_menu = nsgtk_menu_##q##_menu(group);\
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(GET_WIDGET("menuitem_" #q)),\
+ GTK_WIDGET(g->q##_menu->q##_menu));\
+ gtk_menu_set_accel_group(g->q##_menu->q##_menu, group)
+ MAKE_MENUS(file);
+ MAKE_MENUS(edit);
+ MAKE_MENUS(view);
+ MAKE_MENUS(nav);
+ MAKE_MENUS(tabs);
+ MAKE_MENUS(help);
+#undef MAKE_MENUS
+ g->edit_menu_item = GTK_MENU_ITEM(GET_WIDGET("menuitem_edit"));
+ g->tabs_menu_item = GTK_MENU_ITEM(GET_WIDGET("menuitem_tabs"));
+
g->preferences_dialog = NULL;
-
+
css_screen_dpi = gdk_screen_get_resolution(
gtk_widget_get_screen(GTK_WIDGET(g->window)));
LOG(("Set CSS DPI to %f", css_screen_dpi));
@@ -1309,26 +1554,19 @@
break;
}
+ gtk_toolbar_set_show_arrow(g->tool_bar, TRUE);
+ gtk_widget_show_all(GTK_WIDGET(g->tool_bar));
nsgtk_tab_init(GTK_WIDGET(g->notebook));
- /* set the URL entry box to expand, as we can't do this from within
- * glade because of the way it emulates toolbars.
- */
- gtk_tool_item_set_expand(GTK_TOOL_ITEM(GET_WIDGET("toolURLBar")),
- TRUE);
-
- /* disable toolbar buttons that make no sense initially. */
- gtk_widget_set_sensitive(GTK_WIDGET(g->back_button), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(g->forward_button), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(g->stop_button), FALSE);
-
+ gtk_widget_set_size_request(GTK_WIDGET(
+ g->buttons[HISTORY_BUTTON]->button), 20, -1);
+
/* create the local history window to be associated with this browser */
g->history_window = malloc(sizeof(struct gtk_history_window));
g->history_window->g = g;
g->history_window->window =
GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gtk_window_set_transient_for(g->history_window->window, g->window);
- gtk_window_set_default_size(g->history_window->window, 400, 400);
gtk_window_set_title(g->history_window->window, "NetSurf History");
gtk_window_set_type_hint(g->history_window->window,
GDK_WINDOW_TYPE_HINT_UTILITY);
@@ -1354,7 +1592,6 @@
/* set up URL bar completion */
g->url_bar_completion = gtk_entry_completion_new();
- gtk_entry_set_completion(g->url_bar, g->url_bar_completion);
gtk_entry_completion_set_match_func(g->url_bar_completion,
nsgtk_completion_match, NULL, NULL);
gtk_entry_completion_set_model(g->url_bar_completion,
@@ -1368,8 +1605,8 @@
NULL);
/* set up the throbber. */
- gtk_image_set_from_pixbuf(g->throbber, nsgtk_throbber->framedata[0]);
g->throb_frame = 0;
+
#define CONNECT(obj, sig, callback, ptr) \
g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
@@ -1377,8 +1614,8 @@
/* connect history window signals to their handlers */
CONNECT(g->history_window->drawing_area, "expose_event",
nsgtk_history_expose_event, g->history_window);
-// CONNECT(g->history_window->drawing_area, "motion_notify_event",
-// nsgtk_history_motion_notify_event, g->history_window);
+ /*CONNECT(g->history_window->drawing_area, "motion_notify_event",
+ nsgtk_history_motion_notify_event, g->history_window);*/
CONNECT(g->history_window->drawing_area, "button_press_event",
nsgtk_history_button_press_event, g->history_window);
CONNECT(g->history_window->window, "delete_event",
@@ -1391,35 +1628,61 @@
/* connect signals to handlers. */
CONNECT(g->window, "delete-event", nsgtk_window_delete_event, g);
- CONNECT(g->window, "destroy", nsgtk_window_destroy_event, g);
- /* toolbar, URL bar, and menu bar signal handlers */
- CONNECT(g->edit_menu, "show", nsgtk_window_edit_menu_clicked, g);
- CONNECT(g->edit_menu, "hide", nsgtk_window_edit_menu_hidden, g);
- CONNECT(g->back_button, "clicked", nsgtk_window_back_button_clicked,
- g);
- CONNECT(g->forward_button, "clicked",
- nsgtk_window_forward_button_clicked, g);
- CONNECT(g->history_button, "clicked",
- nsgtk_window_history_button_clicked, g);
- CONNECT(g->stop_button, "clicked", nsgtk_window_stop_button_clicked,
- g);
- CONNECT(g->reload_button, "clicked",
- nsgtk_window_reload_button_clicked, g);
- CONNECT(GET_WIDGET("toolHome"), "clicked",
- nsgtk_window_home_button_clicked, g);
- CONNECT(g->url_bar, "activate", nsgtk_window_url_activate_event, g);
- CONNECT(g->url_bar, "changed", nsgtk_window_url_changed, g);
+ /* toolbar URL bar menu bar search bar signal handlers */
+ CONNECT(g->edit_menu_item, "show", nsgtk_window_edit_menu_clicked, g);
+ CONNECT(g->edit_menu_item, "hide", nsgtk_window_edit_menu_hidden, g);
+ CONNECT(g->search->buttons[1], "clicked",
+ nsgtk_search_forward_button_clicked, g);
+ CONNECT(g->search->buttons[0], "clicked",
+ nsgtk_search_back_button_clicked, g);
+ CONNECT(g->search->entry, "changed", nsgtk_search_entry_changed, g);
+ CONNECT(g->search->entry, "activate", nsgtk_search_entry_activate, g);
+ CONNECT(g->search->entry, "key-press-event", nsgtk_search_entry_key,
g);
+ CONNECT(g->search->buttons[2], "clicked",
+ nsgtk_search_close_button_clicked, g);
+
+ CONNECT(g->tool_bar, "popup-context-menu",
+ nsgtk_window_tool_bar_clicked, g);
+ g->popup_xml = glade_xml_new(glade_netsurf_file_location, "menuPopup",
NULL);
/* set up the menu signal handlers */
- nsgtk_attach_menu_handlers(g->xml, g);
+ nsgtk_scaffolding_toolbar_init(g);
+ nsgtk_toolbar_connect_all(g);
+ nsgtk_attach_menu_handlers(g);
+
+ /* prepare to set the web search ico */
+
+ /* init web search prefs from file */
+ search_web_provider_details(option_search_provider);
+
+ /* potentially retrieve ico */
+ if (search_ico == NULL)
+ search_ico = search_web_retrieve_ico(false);
+
+ /* set entry */
+ searchname = search_web_provider_name();
+ gtk_entry_set_text(g->webSearchEntry, searchname);
+ free(searchname);
+#define POPUP_ATTACH(q) gtk_menu_item_set_submenu( \
+ GTK_MENU_ITEM(glade_xml_get_widget(g->popup_xml,\
+ "menupopup_" #q)), GTK_WIDGET(g->rclick_##q##_menu->q##_menu));\
+
+ POPUP_ATTACH(file);
+ POPUP_ATTACH(edit);
+ POPUP_ATTACH(view);
+ POPUP_ATTACH(nav);
+ POPUP_ATTACH(tabs);
+ POPUP_ATTACH(help);
+#undef POPUP_ATTACH
+ nsgtk_scaffolding_initial_sensitivity(g);
+
g->being_destroyed = 0;
g->fullscreen = false;
/* create the popup version of the menu */
- g->popup_xml = glade_xml_new(glade_file_location, "menuPopup", NULL);
g->popup_menu = GTK_MENU(glade_xml_get_widget(g->popup_xml,
"menuPopup"));
@@ -1428,54 +1691,50 @@
* gtk_menu_shell_append (GTK_MENU_SHELL(g->popup_menu),
* GTK_WIDGET(glade_xml_get_widget(g->xml, "back"))); */
CONNECT(g->popup_menu, "hide", nsgtk_window_popup_menu_hidden, g);
- CONNECT(glade_xml_get_widget(g->popup_xml, "popupBack"),
"activate",
- nsgtk_window_back_button_clicked, g);
- CONNECT(glade_xml_get_widget(g->popup_xml,
"popupForward"),"activate",
- nsgtk_window_forward_button_clicked, g);
- CONNECT(glade_xml_get_widget(g->popup_xml, "popupReload"),
"activate",
- nsgtk_window_reload_button_clicked, g);
+
CONNECT(glade_xml_get_widget(g->popup_xml, "save_link_popup"),
- "activate", nsgtk_on_save_link_activate, g);
+ "activate", nsgtk_on_savelink_activate, g);
CONNECT(glade_xml_get_widget(g->popup_xml,
- "open_link_in_focused_tab_popup"),
- "activate",
- nsgtk_on_open_link_in_focused_tab_activate, g);
+ "open_link_in_focused_tab_popup"), "activate",
+ nsgtk_on_linkfocused_activate, g);
CONNECT(glade_xml_get_widget(g->popup_xml,
- "open_link_in_background_tab_popup"),
- "activate",
- nsgtk_on_open_link_in_background_tab_activate, g);
+ "open_link_in_background_tab_popup"), "activate",
+ nsgtk_on_linkbackground_activate, g);
CONNECT(glade_xml_get_widget(g->popup_xml, "cut_popup"),
"activate",
nsgtk_on_cut_activate, g);
CONNECT(glade_xml_get_widget(g->popup_xml, "copy_popup"),
"activate",
nsgtk_on_copy_activate, g);
- CONNECT(glade_xml_get_widget(g->popup_xml,
"paste_popup"),"activate",
- nsgtk_on_paste_activate, g);
-
-#define POPUP_ATTACH(x, y) gtk_menu_item_set_submenu( \
- GTK_MENU_ITEM(glade_xml_get_widget(g->popup_xml, x)),\
- GTK_WIDGET(glade_xml_get_widget(g->xml, y)))
-
- POPUP_ATTACH("menupopup_file", "menumain_file");
- POPUP_ATTACH("menupopup_edit", "menumain_edit");
- POPUP_ATTACH("menupopup_view", "menumain_view");
- POPUP_ATTACH("menupopup_navigate", "menumain_navigate");
- POPUP_ATTACH("menupopup_help", "menumain_help");
-
-#undef POPUP_ATTACH
+ CONNECT(glade_xml_get_widget(g->popup_xml, "paste_popup"),
"activate",
+ nsgtk_on_paste_activate, g);
+ CONNECT(glade_xml_get_widget(g->popup_xml, "customize_popup"),
+ "activate", nsgtk_on_customize_activate, g);
/* hides redundant popup menu items */
GList *widgets = glade_xml_get_widget_prefix(g->popup_xml,
"menupopup");
for (; widgets != NULL; widgets = widgets->next)
gtk_widget_hide(GTK_WIDGET(widgets->data));
+ gtk_widget_hide(glade_xml_get_widget(g->popup_xml, "customize_popup"));
- /* disable PDF-requiring menu items */
-#ifndef WITH_PDF_EXPORT
- gtk_widget_set_sensitive(GET_WIDGET("export_pdf"), FALSE);
-#endif
+ /* attach to the list */
+ if (scaf_list)
+ scaf_list->prev = g;
+ g->next = scaf_list;
+ g->prev = NULL;
+ scaf_list = g;
+
+ /* call functions that need access from the list */
+ nsgtk_theme_init();
+ nsgtk_theme_implement(g);
+ /* set web search ico */
+ if (search_ico != NULL)
+ gui_window_set_search_ico();
+
/* finally, show the window. */
gtk_widget_show(GTK_WIDGET(g->window));
+ LOG(("creation complete"));
+
return g;
}
@@ -1521,10 +1780,9 @@
void gui_window_start_throbber(struct gui_window* _g)
{
struct gtk_scaffolding *g = nsgtk_get_scaffold(_g);
- gtk_widget_set_sensitive(GTK_WIDGET(g->stop_button), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(g->reload_button), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(g->stop_menu), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(g->reload_menu), FALSE);
+ g->buttons[STOP_BUTTON]->sensitivity = true;
+ g->buttons[RELOAD_BUTTON]->sensitivity = false;
+ nsgtk_scaffolding_set_sensitivity(g);
nsgtk_window_update_back_forward(g);
@@ -1534,11 +1792,8 @@
void gui_window_stop_throbber(struct gui_window* _g)
{
struct gtk_scaffolding *g = nsgtk_get_scaffold(_g);
- gtk_widget_set_sensitive(GTK_WIDGET(g->stop_button), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(g->reload_button), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(g->stop_menu), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(g->reload_menu), TRUE);
-
+ g->buttons[STOP_BUTTON]->sensitivity = false;
+ g->buttons[RELOAD_BUTTON]->sensitivity = true;
nsgtk_window_update_back_forward(g);
schedule_remove(nsgtk_throb, g);
@@ -1546,76 +1801,402 @@
gtk_image_set_from_pixbuf(g->throbber, nsgtk_throbber->framedata[0]);
}
-gboolean nsgtk_scaffolding_is_busy(struct gtk_scaffolding *scaffold)
+/**
+ * set favicon
+ */
+void gui_window_set_icon(struct gui_window *_g, struct content *icon)
{
+ struct gtk_scaffolding *g = nsgtk_get_scaffold(_g);
+ GtkImage *iconImage = NULL;
+ GtkContainer *container;
+ container = GTK_CONTAINER(gtk_bin_get_child(GTK_BIN(
+ g->buttons[URL_BAR_ITEM]->button)));
+ if (g->icoFav != NULL) {
+ g_object_ref(g->url_bar);
+ gtk_container_remove(container, GTK_WIDGET(g->icoFav));
+ gtk_container_remove(container, GTK_WIDGET(g->url_bar));
+ }
+ if ((icon != NULL) && (icon->type == CONTENT_ICO)) {
+ nsico_set_bitmap_from_size(icon, 20, 20);
+ }
+ if ((icon != NULL) && (icon->bitmap != NULL)) {
+ GdkPixbuf *pb = gtk_bitmap_get_primary(icon->bitmap);
+ if ((pb != NULL) && (gdk_pixbuf_get_width(pb) > 0) &&
+ (gdk_pixbuf_get_height(pb) > 0)) {
+ pb = gdk_pixbuf_scale_simple(pb, 20, 20,
+ GDK_INTERP_HYPER);
+ iconImage = GTK_IMAGE(
+ gtk_image_new_from_pixbuf(pb));
+ } else {
+ iconImage = NULL;
+ }
+ }
+ if (iconImage == NULL)
+ iconImage = GTK_IMAGE(gtk_image_new_from_file(g_strconcat(
+ res_dir_location, "netsurf-16x16.xpm", NULL)));
+ gtk_box_pack_start(GTK_BOX(container), GTK_WIDGET(iconImage), FALSE,
+ FALSE, 0);
+ g->icoFav = iconImage;
+ gtk_box_pack_end(GTK_BOX(container), GTK_WIDGET(g->url_bar), TRUE, TRUE,
+ 0);
+ g_object_unref(g->url_bar);
+ gtk_widget_show_all(GTK_WIDGET(g->buttons[URL_BAR_ITEM]->button));
+}
+
+void gui_window_set_search_ico()
+{
+ GdkPixbuf *pbico;
+ GtkImage *searchico = 0;
+ GtkContainer *container;
+ nsgtk_scaffolding *current;
+
+ if ((search_ico != NULL) && (search_ico->type == CONTENT_ICO)) {
+ nsico_set_bitmap_from_size(search_ico, 20, 20);
+ }
+ if ((search_ico != NULL) && (search_ico->bitmap != NULL)) {
+ pbico = gtk_bitmap_get_primary(search_ico->bitmap);
+ if ((pbico != NULL) && (gdk_pixbuf_get_width(pbico) > 0) &&
+ (gdk_pixbuf_get_height(pbico) > 0)) {
+ pbico = gdk_pixbuf_scale_simple(pbico, 20, 20,
+ GDK_INTERP_HYPER);
+ current = scaf_list;
+ while (current) {
+ container = GTK_CONTAINER(gtk_bin_get_child(
+ GTK_BIN(current->
+ buttons[WEBSEARCH_ITEM]->
+ button)));
+ gtk_container_remove(container,
+ GTK_WIDGET(
+ current->webSearchIco));
+ g_object_ref(current->webSearchEntry);
+ gtk_container_remove(container,
+ GTK_WIDGET(
+ current->webSearchEntry));
+ current = current->next;
+ }
+ searchico = GTK_IMAGE(
+ gtk_image_new_from_pixbuf(pbico));
+ } else {
+ searchico = NULL;
+ }
+ }
+ /* add ico to toolbar */
+ if (searchico != NULL) {
+ current = scaf_list;
+ while (current) {
+ container = GTK_CONTAINER(gtk_bin_get_child(
+ GTK_BIN(current->
+ buttons[WEBSEARCH_ITEM]->button)));
+ gtk_box_pack_start(GTK_BOX(container),
+ GTK_WIDGET(searchico), FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(container),
+ GTK_WIDGET(current->webSearchEntry), TRUE,
+ TRUE, 0);
+ g_object_unref(current->webSearchEntry);
+ current->webSearchIco = searchico;
+ gtk_widget_show(GTK_WIDGET(searchico));
+ searchico = GTK_IMAGE(gtk_image_new_from_pixbuf(
+ pbico));
+ current = current->next;
+ }
+ }
+
+}
+
+bool nsgtk_scaffolding_is_busy(nsgtk_scaffolding *g)
+{
/* We are considered "busy" if the stop button is sensitive */
- return GTK_WIDGET_SENSITIVE((GTK_WIDGET(scaffold->stop_button)));
+ return g->buttons[STOP_BUTTON]->sensitivity;
}
-GtkWindow* nsgtk_scaffolding_get_window (struct gui_window *g)
+GtkWindow* nsgtk_scaffolding_window(nsgtk_scaffolding *g)
{
- return g->scaffold->window;
+ return g->window;
}
-GtkNotebook* nsgtk_scaffolding_get_notebook (struct gui_window *g)
+GtkNotebook* nsgtk_scaffolding_notebook(nsgtk_scaffolding *g)
{
- return g->scaffold->notebook;
+ return g->notebook;
}
+GtkEntry *nsgtk_scaffolding_urlbar(nsgtk_scaffolding *g)
+{
+ return g->url_bar;
+}
+
+GtkEntry *nsgtk_scaffolding_websearch(nsgtk_scaffolding *g)
+{
+ return g->webSearchEntry;
+}
+
+
+GtkToolbar *nsgtk_scaffolding_toolbar(nsgtk_scaffolding *g)
+{
+ return g->tool_bar;
+}
+
+struct nsgtk_button_connect *nsgtk_scaffolding_button(nsgtk_scaffolding *g,
+ int i)
+{
+ return g->buttons[i];
+}
+
+struct gtk_search *nsgtk_scaffolding_search(nsgtk_scaffolding *g)
+{
+ return g->search;
+}
+
+GtkMenuBar *nsgtk_scaffolding_menu_bar(nsgtk_scaffolding *g)
+{
+ return g->menu_bar;
+}
+
+struct gtk_history_window *nsgtk_scaffolding_history_window(nsgtk_scaffolding
+ *g)
+{
+ return g->history_window;
+}
+
+nsgtk_scaffolding *nsgtk_scaffolding_iterate(nsgtk_scaffolding *g)
+{
+ return g->next;
+}
+
+void nsgtk_scaffolding_reset_offset(nsgtk_scaffolding *g)
+{
+ g->offset = 0;
+}
+
+void nsgtk_scaffolding_update_url_bar_ref(nsgtk_scaffolding *g)
+{
+ GList *list;
+ GtkBox *box;
+ GtkBoxChild *child;
+ box = GTK_BOX(gtk_bin_get_child(GTK_BIN(nsgtk_scaffolding_button(
+ g, URL_BAR_ITEM)->button)));
+ list = box->children;
+ while (list) {
+ child = (GtkBoxChild *)(list->data);
+ if (GTK_IS_IMAGE(child->widget))
+ g->icoFav = GTK_IMAGE(child->widget);
+ if (GTK_IS_ENTRY(child->widget))
+ g->url_bar = GTK_ENTRY(child->widget);
+ list = list->next;
+ }
+
+ gtk_entry_set_completion(g->url_bar, g->url_bar_completion);
+}
+void nsgtk_scaffolding_update_throbber_ref(nsgtk_scaffolding *g)
+{
+ g->throbber = GTK_IMAGE(gtk_bin_get_child(GTK_BIN(
+ g->buttons[THROBBER_ITEM]->button)));
+}
+
+void nsgtk_scaffolding_update_websearch_ref(nsgtk_scaffolding *g)
+{
+ GList *list;
+ GtkBox *box;
+ GtkBoxChild *child;
+ box = GTK_BOX(gtk_bin_get_child(GTK_BIN(
+ g->buttons[WEBSEARCH_ITEM]->button)));
+ list = box->children;
+ while (list) {
+ child = (GtkBoxChild *)(list->data);
+ if (GTK_IS_IMAGE(child->widget))
+ g->webSearchIco = GTK_IMAGE(child->widget);
+ if (GTK_IS_ENTRY(child->widget))
+ g->webSearchEntry = GTK_ENTRY(child->widget);
+ list = list->next;
+ }
+}
+
+void nsgtk_scaffolding_set_websearch(nsgtk_scaffolding *g, const char *content)
+{
+ gtk_entry_set_text(g->webSearchEntry, content);
+}
+
+void nsgtk_scaffolding_toggle_search_bar_visibility(nsgtk_scaffolding *g)
+{
+ gboolean vis;
+ g_object_get(G_OBJECT(g->search->bar), "visible", &vis, NULL);
+ if (vis) {
+ search_reset();
+ gtk_widget_hide(GTK_WIDGET(g->search->bar));
+ } else {
+ gtk_widget_show(GTK_WIDGET(g->search->bar));
+ gtk_widget_grab_focus(GTK_WIDGET(g->search->entry));
+ }
+}
+
+
+struct gui_window *nsgtk_scaffolding_top_level(nsgtk_scaffolding *g)
+{
+ return g->top_level;
+}
+
void nsgtk_scaffolding_set_top_level (struct gui_window *gw)
{
- gw->scaffold->top_level = gw;
+ nsgtk_get_scaffold(gw)->top_level = gw;
/* Synchronise the history (will also update the URL bar) */
- nsgtk_window_update_back_forward(gw->scaffold);
+ nsgtk_window_update_back_forward(nsgtk_get_scaffold(gw));
+ /* clear effects of potential searches */
+ search_reset();
- /* Ensure the window's title bar is updated */
- if (gw->bw != NULL && gw->bw->current_content != NULL) {
- if (gw->bw->current_content->title != NULL) {
+ /* Ensure the window's title bar as well as favicon are updated */
+ if (gui_window_get_browser_window(gw) != NULL &&
+ gui_window_get_browser_window(gw)->current_content
+ != NULL) {
+ if (gui_window_get_browser_window(gw)->current_content->title
+ != NULL) {
gui_window_set_title(gw,
- gw->bw->current_content->title);
+ gui_window_get_browser_window(gw)->
+ current_content->title);
} else {
- gui_window_set_title(gw, gw->bw->current_content->url);
+ gui_window_set_title(gw,
+ gui_window_get_browser_window(gw)->
+ current_content->url);
}
+ if (gui_window_get_browser_window(gw)->current_content->type
+ == CONTENT_HTML)
+ gui_window_set_icon(gw,
+ gui_window_get_browser_window(gw)->
+ current_content->data.html.favicon);
}
}
+void nsgtk_scaffolding_set_sensitivity(struct gtk_scaffolding *g)
+{
+#define SENSITIVITY(q)\
+ i = q##_BUTTON;\
+ if (g->buttons[i]->main != NULL)\
+ gtk_widget_set_sensitive(GTK_WIDGET(\
+ g->buttons[i]->main),\
+ g->buttons[i]->sensitivity);\
+ if (g->buttons[i]->rclick != NULL)\
+ gtk_widget_set_sensitive(GTK_WIDGET(\
+ g->buttons[i]->rclick),\
+ g->buttons[i]->sensitivity);\
+ if ((g->buttons[i]->location != -1) && \
+ (g->buttons[i]->button != NULL))\
+ gtk_widget_set_sensitive(GTK_WIDGET(\
+ g->buttons[i]->button),\
+ g->buttons[i]->sensitivity);\
+ if (g->buttons[i]->popup != NULL)\
+ gtk_widget_set_sensitive(GTK_WIDGET(\
+ g->buttons[i]->popup),\
+ g->buttons[i]->sensitivity);
+
+ int i;
+ SENSITIVITY(STOP)
+ SENSITIVITY(RELOAD)
+ SENSITIVITY(CUT)
+ SENSITIVITY(COPY)
+ SENSITIVITY(PASTE)
+ SENSITIVITY(BACK)
+ SENSITIVITY(FORWARD)
+ SENSITIVITY(NEXTTAB)
+ SENSITIVITY(PREVTAB)
+ SENSITIVITY(CLOSETAB)
+#undef SENSITIVITY
+}
+
+void nsgtk_scaffolding_initial_sensitivity(struct gtk_scaffolding *g)
+{
+ for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ if (g->buttons[i]->main != NULL)
+ gtk_widget_set_sensitive(GTK_WIDGET(
+ g->buttons[i]->main),
+ g->buttons[i]->sensitivity);
+ if (g->buttons[i]->rclick != NULL)
+ gtk_widget_set_sensitive(GTK_WIDGET(
+ g->buttons[i]->rclick),
+ g->buttons[i]->sensitivity);
+ if ((g->buttons[i]->location != -1) &&
+ (g->buttons[i]->button != NULL))
+ gtk_widget_set_sensitive(GTK_WIDGET(
+ g->buttons[i]->button),
+ g->buttons[i]->sensitivity);
+ if (g->buttons[i]->popup != NULL)
+ gtk_widget_set_sensitive(GTK_WIDGET(
+ g->buttons[i]->popup),
+ g->buttons[i]->sensitivity);
+ }
+ gtk_widget_set_sensitive(GTK_WIDGET(g->view_menu->images_menuitem),
+ FALSE);
+}
+
void nsgtk_scaffolding_popup_menu(struct gtk_scaffolding *g,
gdouble x, gdouble y)
{
guint available_menu_options = 0;
GtkWidget *widget = NULL;
+
available_menu_options |=
nsgtk_scaffolding_update_link_operations_sensitivity(g,
- g->popup_xml, x, y, TRUE);
+ g->popup_xml, x, y, true);
available_menu_options |=
nsgtk_scaffolding_update_edit_actions_sensitivity(g,
- g->popup_xml, TRUE);
+ g->popup_xml, true);
/* Hide the separator as well */
if (!available_menu_options) {
- widget = glade_xml_get_widget(g->popup_xml, "separator1");
+ widget = glade_xml_get_widget(g->popup_xml, "sep2");
gtk_widget_hide(widget);
}
+ /* hide customize */
+ gtk_widget_hide(glade_xml_get_widget(g->popup_xml, "customize_popup"));
+
gtk_menu_popup(g->popup_menu, NULL, NULL, NULL, NULL, 0,
gtk_get_current_event_time());
}
+/**
+ * reallocate width for history button, reallocate buttons right of history;
+ * memorise base of history button / toolbar
+ */
+void nsgtk_scaffolding_toolbar_size_allocate(GtkWidget *widget, GtkAllocation
+ *alloc, gpointer data)
+{
+ struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
+ if ((g->toolbarmem == alloc->x) ||
+ (g->buttons[nsgtk_toolbar_get_id_from_widget(
+ widget, g)]->location <
+ g->buttons[HISTORY_BUTTON]->location))
+ /* no reallocation after first adjustment, no reallocation for buttons
+ * left of history button */
+ return;
+ if (widget == GTK_WIDGET(g->buttons[HISTORY_BUTTON]->button)) {
+ if (alloc->width == 20)
+ return;
+ g->toolbarbase = alloc->y + alloc->height;
+ g->historybase = alloc->x;
+ if (g->offset == 0)
+ g->offset = alloc->width - 20;
+ alloc->width = 20;
+ } else {
+ alloc->x -= g->offset;
+ g->toolbarmem = alloc->x;
+ }
+ gtk_widget_size_allocate(widget, alloc);
+}
+
static guint nsgtk_scaffolding_update_link_operations_sensitivity(
struct gtk_scaffolding *g, GladeXML *xml, gdouble x, gdouble y,
gboolean hide)
{
gboolean is_sensitive;
- GtkWidget *widget1, *widget2, *widget3;
+ GtkWidget *widget[3];
+ int i;
- widget1 = glade_xml_get_widget_prefix(xml, "save_link")->data;
- widget2 = glade_xml_get_widget_prefix(xml,
+ widget[0] = glade_xml_get_widget_prefix(xml, "save_link")->data;
+ widget[1] = glade_xml_get_widget_prefix(xml,
"open_link_in_focused_tab")->data;
- widget3 = glade_xml_get_widget_prefix(xml,
+ widget[2] = glade_xml_get_widget_prefix(xml,
"open_link_in_background_tab")->data;
- struct browser_window *bw = nsgtk_get_browser_for_gui(g->top_level);
+ struct browser_window *bw = gui_window_get_browser_window(g->top_level);
current_menu_link_box = NULL;
if (bw->current_content && bw->current_content->type == CONTENT_HTML)
{
@@ -1624,107 +2205,228 @@
}
is_sensitive = (current_menu_link_box != NULL) ? TRUE : FALSE;
- gtk_widget_set_sensitive(widget1, is_sensitive);
- gtk_widget_set_sensitive(widget2, is_sensitive);
- gtk_widget_set_sensitive(widget3, is_sensitive);
+ for (i = 0; i < 3; i++) {
+ gtk_widget_set_sensitive(widget[i], is_sensitive);
- if (hide == TRUE && current_menu_link_box == NULL) {
- gtk_widget_hide(widget1);
- gtk_widget_hide(widget2);
- gtk_widget_hide(widget3);
+ if (hide == true && current_menu_link_box == NULL) {
+ gtk_widget_hide(widget[i]);
+ }
}
return is_sensitive;
}
static guint nsgtk_scaffolding_update_edit_actions_sensitivity(
- struct gtk_scaffolding *g, GladeXML *xml, gboolean hide)
+ struct gtk_scaffolding *g, GladeXML *xml, bool hide)
{
GtkWidget *widget = gtk_window_get_focus(g->window);
- gboolean can_copy, can_cut, can_paste;
gboolean has_selection;
- if (GTK_IS_EDITABLE (widget)) {
- has_selection = gtk_editable_get_selection_bounds
- (GTK_EDITABLE (widget), NULL, NULL);
+ if (GTK_IS_EDITABLE(widget)) {
+ has_selection = gtk_editable_get_selection_bounds(
+ GTK_EDITABLE (widget), NULL, NULL);
- can_copy = has_selection;
- can_cut = has_selection;
- can_paste = TRUE;
+ g->buttons[COPY_BUTTON]->sensitivity = has_selection;
+ g->buttons[CUT_BUTTON]->sensitivity = has_selection;
+ g->buttons[PASTE_BUTTON]->sensitivity = true;
} else {
struct browser_window *bw =
- nsgtk_get_browser_for_gui(g->top_level);
+ gui_window_get_browser_window(g->top_level);
has_selection = bw->sel->defined;
- can_copy = has_selection;
- can_cut = (has_selection && bw->caret_callback != 0);
- can_paste = (bw->paste_callback != 0);
+ g->buttons[COPY_BUTTON]->sensitivity = has_selection;
+ g->buttons[CUT_BUTTON]->sensitivity = (has_selection &&
+ bw->caret_callback != 0);
+ g->buttons[PASTE_BUTTON]->sensitivity =
+ (bw->paste_callback != 0);
}
widget = glade_xml_get_widget_prefix(xml, "copy")->data;
- gtk_widget_set_sensitive (widget, can_copy);
- if (hide && !can_copy)
+ if (hide && !(g->buttons[COPY_BUTTON]->sensitivity))
gtk_widget_hide(widget);
widget = glade_xml_get_widget_prefix(xml, "cut")->data;
- gtk_widget_set_sensitive (widget, can_cut);
- if (hide && !can_cut)
+ if (hide && !(g->buttons[CUT_BUTTON]->sensitivity))
gtk_widget_hide(widget);
widget = glade_xml_get_widget_prefix(xml, "paste")->data;
- gtk_widget_set_sensitive (widget, can_paste);
- if (hide && !can_paste)
+ if (hide && !(g->buttons[PASTE_BUTTON]->sensitivity))
gtk_widget_hide(widget);
-
- return (can_paste | can_cut | can_copy);
+ nsgtk_scaffolding_set_sensitivity(g);
+ return ((g->buttons[COPY_BUTTON]->sensitivity) |
+ (g->buttons[CUT_BUTTON]->sensitivity) |
+ (g->buttons[PASTE_BUTTON]->sensitivity));
}
static void nsgtk_scaffolding_enable_link_operations_sensitivity(
struct gtk_scaffolding *g, GladeXML *xml)
{
- GtkWidget *widget1;
- GtkWidget *widget2;
- GtkWidget *widget3;
+ int i;
+ GtkWidget *widget[3];
- widget1 = glade_xml_get_widget_prefix(xml, "save_link")->data;
- widget2 = glade_xml_get_widget_prefix(xml,
+ widget[0] = glade_xml_get_widget_prefix(xml, "save_link")->data;
+ widget[1] = glade_xml_get_widget_prefix(xml,
"open_link_in_focused_tab")->data;
- widget3 = glade_xml_get_widget_prefix(xml,
+ widget[2] = glade_xml_get_widget_prefix(xml,
"open_link_in_background_tab")->data;
- gtk_widget_set_sensitive(widget1, TRUE);
- gtk_widget_show(widget1);
- gtk_widget_set_sensitive(widget2, TRUE);
- gtk_widget_show(widget2);
- gtk_widget_set_sensitive(widget3, TRUE);
- gtk_widget_show(widget3);
-
-
+ for (i = 0; i < 3; i++) {
+ gtk_widget_set_sensitive(widget[i], TRUE);
+ gtk_widget_show(widget[i]);
+ }
}
static void nsgtk_scaffolding_enable_edit_actions_sensitivity(
struct gtk_scaffolding *g, GladeXML *xml)
{
- GtkWidget *widget1;
- GtkWidget *widget2;
- GtkWidget *widget3;
- GtkWidget *widget4;
- GtkWidget *widget5;
+ int i;
+ GtkWidget *widget[5];
- widget1 = glade_xml_get_widget(xml, "separator");
- widget2 = glade_xml_get_widget(xml, "separator1");
- widget3 = glade_xml_get_widget_prefix(xml, "copy")->data;
- widget4 = glade_xml_get_widget_prefix(xml, "cut")->data;
- widget5 = glade_xml_get_widget_prefix(xml, "paste")->data;
-
- gtk_widget_set_sensitive(widget3, TRUE);
- gtk_widget_set_sensitive(widget4, TRUE);
- gtk_widget_set_sensitive(widget5, TRUE);
-
- gtk_widget_show(widget1);
- gtk_widget_show(widget2);
- gtk_widget_show(widget3);
- gtk_widget_show(widget4);
- gtk_widget_show(widget5);
+ widget[0] = glade_xml_get_widget(xml, "sep");
+ widget[1] = glade_xml_get_widget(xml, "sep2");
+ widget[2] = glade_xml_get_widget_prefix(xml, "copy")->data;
+ widget[3] = glade_xml_get_widget_prefix(xml, "cut")->data;
+ widget[4] = glade_xml_get_widget_prefix(xml, "paste")->data;
+ g->buttons[PASTE_BUTTON]->sensitivity = true;
+ g->buttons[COPY_BUTTON]->sensitivity = true;
+ g->buttons[CUT_BUTTON]->sensitivity = true;
+ nsgtk_scaffolding_set_sensitivity(g);
+
+ for (i = 0; i < 5; i++)
+ gtk_widget_show(widget[i]);
+
}
+
+/**
+ * init the array g->buttons[]
+ */
+void nsgtk_scaffolding_toolbar_init(struct gtk_scaffolding *g)
+{
+#define ITEM_MAIN(p, q, r)\
+ g->buttons[p##_BUTTON]->main =\
+ g->q##_menu->r##_menuitem;\
+ g->buttons[p##_BUTTON]->rclick =\
+ g->rclick_##q##_menu->r##_menuitem;\
+ g->buttons[p##_BUTTON]->mhandler =\
+ nsgtk_on_##r##_activate_menu;\
+ g->buttons[p##_BUTTON]->bhandler =\
+ nsgtk_on_##r##_activate_button;\
+ g->buttons[p##_BUTTON]->dataplus =\
+ nsgtk_toolbar_##r##_button_data;\
+ g->buttons[p##_BUTTON]->dataminus =\
+ nsgtk_toolbar_##r##_toolbar_button_data
+#define ITEM_SUB(p, q, r, s)\
+ g->buttons[p##_BUTTON]->main =\
+ g->q##_menu->\
+ r##_submenu->s##_menuitem;\
+ g->buttons[p##_BUTTON]->rclick =\
+ g->rclick_##q##_menu->\
+ r##_submenu->s##_menuitem;\
+ g->buttons[p##_BUTTON]->mhandler =\
+ nsgtk_on_##s##_activate_menu;\
+ g->buttons[p##_BUTTON]->bhandler =\
+ nsgtk_on_##s##_activate_button;\
+ g->buttons[p##_BUTTON]->dataplus =\
+ nsgtk_toolbar_##s##_button_data;\
+ g->buttons[p##_BUTTON]->dataminus =\
+ nsgtk_toolbar_##s##_toolbar_button_data
+#define ITEM_BUTTON(p, q)\
+ g->buttons[p##_BUTTON]->bhandler =\
+ nsgtk_on_##q##_activate;\
+ g->buttons[p##_BUTTON]->dataplus =\
+ nsgtk_toolbar_##q##_button_data;\
+ g->buttons[p##_BUTTON]->dataminus =\
+ nsgtk_toolbar_##q##_toolbar_button_data
+#define ITEM_POP(p, q)\
+ g->buttons[p##_BUTTON]->popup = GTK_IMAGE_MENU_ITEM(\
+ glade_xml_get_widget(g->popup_xml, #q "_popup"))
+#define SENSITIVITY(q)\
+ g->buttons[q##_BUTTON]->sensitivity = false
+#define ITEM_ITEM(p, q)\
+ g->buttons[p##_ITEM]->dataplus =\
+ nsgtk_toolbar_##q##_button_data;\
+ g->buttons[p##_ITEM]->dataminus =\
+ nsgtk_toolbar_##q##_toolbar_button_data
+ ITEM_ITEM(WEBSEARCH, websearch);
+ ITEM_ITEM(THROBBER, throbber);
+ ITEM_MAIN(NEWWINDOW, file, newwindow);
+ ITEM_MAIN(NEWTAB, file, newtab);
+ ITEM_MAIN(OPENFILE, file, openfile);
+ ITEM_MAIN(PRINT, file, print);
+ ITEM_MAIN(CLOSEWINDOW, file, closewindow);
+ ITEM_MAIN(SAVEPAGE, file, savepage);
+ ITEM_MAIN(PRINTPREVIEW, file, printpreview);
+ ITEM_MAIN(PRINT, file, print);
+ ITEM_MAIN(QUIT, file, quit);
+ ITEM_MAIN(CUT, edit, cut);
+ ITEM_MAIN(COPY, edit, copy);
+ ITEM_MAIN(PASTE, edit, paste);
+ ITEM_MAIN(DELETE, edit, delete);
+ ITEM_MAIN(SELECTALL, edit, selectall);
+ ITEM_MAIN(FIND, edit, find);
+ ITEM_MAIN(PREFERENCES, edit, preferences);
+ ITEM_MAIN(STOP, view, stop);
+ ITEM_POP(STOP, stop);
+ ITEM_MAIN(RELOAD, view, reload);
+ ITEM_POP(RELOAD, reload);
+ ITEM_MAIN(FULLSCREEN, view, fullscreen);
+ ITEM_MAIN(VIEWSOURCE, view, viewsource);
+ ITEM_MAIN(DOWNLOADS, view, downloads);
+ ITEM_MAIN(SAVEWINDOWSIZE, view, savewindowsize);
+ ITEM_MAIN(BACK, nav, back);
+ ITEM_POP(BACK, back);
+ ITEM_MAIN(FORWARD, nav, forward);
+ ITEM_POP(FORWARD, forward);
+ ITEM_MAIN(HOME, nav, home);
+ ITEM_MAIN(LOCALHISTORY, nav, localhistory);
+ ITEM_MAIN(GLOBALHISTORY, nav, globalhistory);
+ ITEM_MAIN(ADDBOOKMARKS, nav, addbookmarks);
+ ITEM_MAIN(SHOWBOOKMARKS, nav, showbookmarks);
+ ITEM_MAIN(OPENLOCATION, nav, openlocation);
+ ITEM_MAIN(NEXTTAB, tabs, nexttab);
+ ITEM_MAIN(PREVTAB, tabs, prevtab);
+ ITEM_MAIN(CLOSETAB, tabs, closetab);
+ ITEM_MAIN(CONTENTS, help, contents);
+ ITEM_MAIN(INFO, help, info);
+ ITEM_MAIN(GUIDE, help, guide);
+ ITEM_MAIN(ABOUT, help, about);
+ ITEM_SUB(PLAINTEXT, file, export, plaintext);
+ ITEM_SUB(PDF, file, export, pdf);
+ ITEM_SUB(DRAWFILE, file, export, drawfile);
+ ITEM_SUB(POSTSCRIPT, file, export, postscript);
+ ITEM_SUB(ZOOMPLUS, view, scaleview, zoomplus);
+ ITEM_SUB(ZOOMMINUS, view, scaleview, zoomminus);
+ ITEM_SUB(ZOOMNORMAL, view, scaleview, zoomnormal);
+ ITEM_SUB(TOGGLEDEBUGGING, view, debugging, toggledebugging);
+ ITEM_SUB(SAVEBOXTREE, view, debugging, saveboxtree);
+ ITEM_SUB(SAVEDOMTREE, view, debugging, savedomtree);
+ ITEM_BUTTON(HISTORY, history);
+ /* disable items that make no sense initially, as well as
+ * as-yet-unimplemented items */
+ SENSITIVITY(BACK);
+ SENSITIVITY(FORWARD);
+ SENSITIVITY(STOP);
+ SENSITIVITY(PRINTPREVIEW);
+ SENSITIVITY(DELETE);
+ SENSITIVITY(CONTENTS);
+ SENSITIVITY(DRAWFILE);
+ SENSITIVITY(POSTSCRIPT);
+ SENSITIVITY(ADDBOOKMARKS);
+ SENSITIVITY(SHOWBOOKMARKS);
+ SENSITIVITY(NEXTTAB);
+ SENSITIVITY(PREVTAB);
+ SENSITIVITY(CLOSETAB);
+ SENSITIVITY(GUIDE);
+ SENSITIVITY(INFO);
+#ifndef WITH_PDF_EXPORT
+ SENSITIVITY(PDF);
+#endif
+
+#undef ITEM_MAIN
+#undef ITEM_SUB
+#undef ITEM_BUTTON
+#undef ITEM_POP
+#undef SENSITIVITY
+
+}
Index: gtk/gtk_scaffolding.h
===================================================================
--- gtk/gtk_scaffolding.h (revision 8438)
+++ gtk/gtk_scaffolding.h (working copy)
@@ -21,63 +21,218 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
+#include <glib.h>
#include "desktop/gui.h"
#include "desktop/plotters.h"
+#include "gtk/gtk_menu.h"
typedef struct gtk_scaffolding nsgtk_scaffolding;
-struct gtk_scaffolding {
+typedef enum {
+ BACK_BUTTON = 0,
+ HISTORY_BUTTON,
+ FORWARD_BUTTON,
+ STOP_BUTTON,
+ RELOAD_BUTTON,
+ HOME_BUTTON,
+ URL_BAR_ITEM,
+ THROBBER_ITEM,
+ WEBSEARCH_ITEM,
+ NEWWINDOW_BUTTON,
+ NEWTAB_BUTTON,
+ OPENFILE_BUTTON,
+ CLOSETAB_BUTTON,
+ CLOSEWINDOW_BUTTON,
+ SAVEPAGE_BUTTON,
+ PDF_BUTTON,
+ PLAINTEXT_BUTTON,
+ DRAWFILE_BUTTON,
+ POSTSCRIPT_BUTTON,
+ PRINTPREVIEW_BUTTON,
+ PRINT_BUTTON,
+ QUIT_BUTTON,
+ CUT_BUTTON,
+ COPY_BUTTON,
+ PASTE_BUTTON,
+ DELETE_BUTTON,
+ SELECTALL_BUTTON,
+ FIND_BUTTON,
+ PREFERENCES_BUTTON,
+ ZOOMPLUS_BUTTON,
+ ZOOMMINUS_BUTTON,
+ ZOOMNORMAL_BUTTON,
+ FULLSCREEN_BUTTON,
+ VIEWSOURCE_BUTTON,
+ DOWNLOADS_BUTTON,
+ SAVEWINDOWSIZE_BUTTON,
+ TOGGLEDEBUGGING_BUTTON,
+ SAVEBOXTREE_BUTTON,
+ SAVEDOMTREE_BUTTON,
+ LOCALHISTORY_BUTTON,
+ GLOBALHISTORY_BUTTON,
+ ADDBOOKMARKS_BUTTON,
+ SHOWBOOKMARKS_BUTTON,
+ OPENLOCATION_BUTTON,
+ NEXTTAB_BUTTON,
+ PREVTAB_BUTTON,
+ CONTENTS_BUTTON,
+ GUIDE_BUTTON,
+ INFO_BUTTON,
+ ABOUT_BUTTON,
+ PLACEHOLDER_BUTTON /* size indicator; array maximum indices */
+} nsgtk_toolbar_button; /* PLACEHOLDER_BUTTON - 1 */
+
+struct gtk_history_window {
+ struct gtk_scaffolding *g;
GtkWindow *window;
- GtkNotebook *notebook;
- GtkEntry *url_bar;
- GtkEntryCompletion *url_bar_completion;
- GtkStatusbar *status_bar;
- GtkMenuItem *edit_menu;
- GtkMenuItem *tabs_menu;
- GtkToolbar *tool_bar;
- GtkToolButton *back_button;
- GtkToolButton *history_button;
- GtkToolButton *forward_button;
- GtkToolButton *stop_button;
- GtkToolButton *reload_button;
- GtkMenuBar *menu_bar;
- GtkMenuItem *back_menu;
- GtkMenuItem *forward_menu;
- GtkMenuItem *stop_menu;
- GtkMenuItem *reload_menu;
- GtkImage *throbber;
- GtkPaned *status_pane;
+ GtkScrolledWindow *scrolled;
+ GtkDrawingArea *drawing_area;
+};
- GladeXML *xml;
+struct gtk_search {
+ GtkToolbar *bar;
+ GtkEntry *entry;
+ GtkToolButton *buttons[3]; /* back, forward, */
+ GtkCheckButton *checkAll; /* close */
+ GtkCheckButton *caseSens;
+};
- GladeXML *popup_xml;
- GtkMenu *popup_menu;
+struct nsgtk_button_connect {
+ GtkToolItem *button;
+ int location; /* in toolbar */
+ bool sensitivity;
+ GtkImageMenuItem *main;
+ GtkImageMenuItem *rclick;
+ GtkImageMenuItem *popup;
+ void *mhandler; /* menu item clicked */
+ void *bhandler; /* button clicked */
+ void *dataplus; /* customization -> toolbar */
+ void *dataminus; /* customization -> store */
+};
- struct gtk_history_window *history_window;
- GtkDialog *preferences_dialog;
+extern nsgtk_scaffolding *scaf_list;
- int throb_frame;
- struct gui_window *top_level;
- int being_destroyed;
+nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel);
- bool fullscreen;
-};
+bool nsgtk_scaffolding_is_busy(nsgtk_scaffolding *g);
-GtkWindow *nsgtk_get_window_for_scaffold(struct gtk_scaffolding *g);
+GtkWindow *nsgtk_scaffolding_window(nsgtk_scaffolding *g);
+GtkNotebook *nsgtk_scaffolding_notebook(nsgtk_scaffolding *g);
+GtkEntry *nsgtk_scaffolding_urlbar(nsgtk_scaffolding *g);
+GtkEntry *nsgtk_scaffolding_websearch(nsgtk_scaffolding *g);
+GtkToolbar *nsgtk_scaffolding_toolbar(nsgtk_scaffolding *g);
+struct nsgtk_button_connect *nsgtk_scaffolding_button(nsgtk_scaffolding *g,
+ int i);
+struct gtk_search *nsgtk_scaffolding_search(nsgtk_scaffolding *g);
+GtkMenuBar *nsgtk_scaffolding_menu_bar(nsgtk_scaffolding *g);
+struct gtk_history_window *nsgtk_scaffolding_history_window(nsgtk_scaffolding
+ *g);
+struct gui_window *nsgtk_scaffolding_top_level(nsgtk_scaffolding *g);
+void nsgtk_scaffolding_reset_offset(nsgtk_scaffolding *g);
+nsgtk_scaffolding *nsgtk_scaffolding_iterate(nsgtk_scaffolding *g);
+void nsgtk_scaffolding_toolbar_init(struct gtk_scaffolding *g);
+void nsgtk_scaffolding_update_url_bar_ref(nsgtk_scaffolding *g);
+void nsgtk_scaffolding_update_throbber_ref(nsgtk_scaffolding *g);
+void nsgtk_scaffolding_update_websearch_ref(nsgtk_scaffolding *g);
+void nsgtk_scaffolding_set_websearch(nsgtk_scaffolding *g, const char
+ *content);
+void nsgtk_scaffolding_toggle_search_bar_visibility(nsgtk_scaffolding *g);
+void nsgtk_scaffolding_set_top_level(struct gui_window *g);
-nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel);
+void nsgtk_scaffolding_destroy(nsgtk_scaffolding *g);
-gboolean nsgtk_scaffolding_is_busy(nsgtk_scaffolding *scaffold);
+void nsgtk_scaffolding_set_sensitivity(struct gtk_scaffolding *g);
+void nsgtk_scaffolding_initial_sensitivity(struct gtk_scaffolding *g);
+void nsgtk_scaffolding_popup_menu(struct gtk_scaffolding *g, gdouble x,
+ gdouble y);
+void nsgtk_scaffolding_toolbar_size_allocate(GtkWidget *widget,
+ GtkAllocation *alloc, gpointer data);
-GtkWindow* nsgtk_scaffolding_get_window (struct gui_window *g);
+gboolean nsgtk_window_url_activate_event(GtkWidget *, gpointer);
+gboolean nsgtk_window_url_changed(GtkWidget *, GdkEventKey *, gpointer);
-GtkNotebook* nsgtk_scaffolding_get_notebook (struct gui_window *g);
+#define MULTIPROTO(q)\
+gboolean nsgtk_on_##q##_activate(struct gtk_scaffolding *);\
+gboolean nsgtk_on_##q##_activate_menu(GtkMenuItem *, gpointer);\
+gboolean nsgtk_on_##q##_activate_button(GtkButton *, gpointer)
+#define MENUPROTO(q)\
+gboolean nsgtk_on_##q##_activate(GtkMenuItem *, gpointer)
+#define BUTTONPROTO(q)\
+gboolean nsgtk_on_##q##_activate(GtkButton *, gpointer)
+/* prototypes for handlers */
+/* file menu */
+MULTIPROTO(newwindow);
+MULTIPROTO(newtab);
+MULTIPROTO(open_location);
+MULTIPROTO(openfile);
+MULTIPROTO(savepage);
+MULTIPROTO(pdf);
+MULTIPROTO(plaintext);
+MULTIPROTO(drawfile);
+MULTIPROTO(postscript);
+MULTIPROTO(printpreview);
+MULTIPROTO(print);
+MULTIPROTO(closewindow);
+MULTIPROTO(quit);
-void nsgtk_scaffolding_set_top_level (struct gui_window *gw);
+/* edit menu */
+MULTIPROTO(cut);
+MULTIPROTO(copy);
+MULTIPROTO(paste);
+MULTIPROTO(delete);
+MULTIPROTO(selectall);
+MULTIPROTO(find);
+MULTIPROTO(preferences);
-void nsgtk_scaffolding_destroy(nsgtk_scaffolding *scaffold);
+/* view menu */
+MULTIPROTO(stop);
+MULTIPROTO(reload);
+MULTIPROTO(zoomplus);
+MULTIPROTO(zoomnormal);
+MULTIPROTO(zoomminus);
+MULTIPROTO(fullscreen);
+MULTIPROTO(viewsource);
+MENUPROTO(menubar);
+MENUPROTO(toolbar);
+MENUPROTO(statusbar);
+MULTIPROTO(downloads);
+MULTIPROTO(savewindowsize);
+MULTIPROTO(toggledebugging);
+MULTIPROTO(saveboxtree);
+MULTIPROTO(savedomtree);
-void nsgtk_scaffolding_popup_menu(struct gtk_scaffolding *g, gdouble x,
- gdouble y);
+/* navigate menu */
+MULTIPROTO(back);
+MULTIPROTO(forward);
+MULTIPROTO(home);
+MULTIPROTO(localhistory);
+MULTIPROTO(globalhistory);
+MULTIPROTO(addbookmarks);
+MULTIPROTO(showbookmarks);
+MULTIPROTO(openlocation);
+/* tabs menu */
+MULTIPROTO(nexttab);
+MULTIPROTO(prevtab);
+MULTIPROTO(closetab);
+
+/* help menu */
+MULTIPROTO(contents);
+MULTIPROTO(guide);
+MULTIPROTO(info);
+MULTIPROTO(about);
+
+/* popup menu */
+MENUPROTO(customize);
+MENUPROTO(savelink);
+MENUPROTO(linkfocused);
+MENUPROTO(linkbackground);
+
+/* non-menu */
+BUTTONPROTO(history);
+
+#undef MULTIPROTO
+#undef MENUPROTO
+#undef BUTTONPROTO
+
#endif /* NETSURF_GTK_SCAFFOLDING_H */
Index: gtk/gtk_tabs.c
===================================================================
--- gtk/gtk_tabs.c (revision 8438)
+++ gtk/gtk_tabs.c (working copy)
@@ -23,12 +23,13 @@
#include "desktop/browser.h"
#include "content/content.h"
#include "desktop/options.h"
+#include "desktop/search.h"
#include "utils/utils.h"
#include "gtk/options.h"
#include "gtk/gtk_tabs.h"
#define TAB_WIDTH_N_CHARS 15
-#define GET_WIDGET(x) glade_xml_get_widget(gladeWindows, (x))
+#define GET_WIDGET(x) glade_xml_get_widget(gladeNetsurf, (x))
static GtkWidget *nsgtk_tab_label_setup(struct gui_window *window);
static void nsgtk_tab_visibility_update(GtkNotebook *notebook, GtkWidget *child,
@@ -58,15 +59,19 @@
void nsgtk_tab_add(struct gui_window *window, bool background)
{
- GtkWidget *tabs = GTK_WIDGET(nsgtk_scaffolding_get_notebook(window));
+ GtkWidget *tabs = GTK_WIDGET(nsgtk_scaffolding_notebook(
+ nsgtk_get_scaffold(window)));
GtkWidget *tabBox = nsgtk_tab_label_setup(window);
gint remember = gtk_notebook_get_current_page(GTK_NOTEBOOK(tabs));
gtk_notebook_append_page(GTK_NOTEBOOK(tabs),
- GTK_WIDGET(window->scrolledwindow), tabBox);
- /*causes gtk errors can't set a parent
+ GTK_WIDGET(nsgtk_window_get_scrolledwindow(window)),
+ tabBox);
+ /*causes gtk errors can't set a parent */
gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(tabs),
- GTK_WIDGET(window->scrolledwindow), true); */
- gtk_widget_show_all(GTK_WIDGET(window->scrolledwindow));
+ GTK_WIDGET(nsgtk_window_get_scrolledwindow(window)),
+ true);
+ gtk_widget_show_all(GTK_WIDGET(nsgtk_window_get_scrolledwindow(
+ window)));
gtk_notebook_set_current_page(GTK_NOTEBOOK(tabs),
gtk_notebook_get_n_pages(GTK_NOTEBOOK(tabs)) - 1);
if (option_new_blank) {
@@ -75,13 +80,15 @@
blankpage = g_strconcat("file:///", res_dir_location,
"blankpage", NULL); */
/* segfaults
- struct browser_window *bw = nsgtk_get_browser_for_gui(window);
+ struct browser_window *bw =
+ gui_window_get_browser_window(window);
browser_window_go(bw, blankpage, 0, true); */
/* free(blankpage); */
}
if (background)
gtk_notebook_set_current_page(GTK_NOTEBOOK(tabs), remember);
- gtk_widget_grab_focus(GTK_WIDGET(window->scaffold->url_bar));
+ gtk_widget_grab_focus(GTK_WIDGET(nsgtk_scaffolding_urlbar(
+ nsgtk_get_scaffold(window))));
}
void nsgtk_tab_visibility_update(GtkNotebook *notebook, GtkWidget *child,
@@ -97,12 +104,14 @@
void nsgtk_tab_set_title(struct gui_window *g, const char *title)
{
GtkWidget *label;
- gboolean is_top_level = (g->tab != NULL);
+ GtkWidget *tab;
+ tab = nsgtk_window_get_tab(g);
+ gboolean is_top_level = (tab != NULL);
if (is_top_level) {
- label = g_object_get_data(G_OBJECT(g->tab), "label");
+ label = g_object_get_data(G_OBJECT(tab), "label");
gtk_label_set_text(GTK_LABEL(label), title);
- gtk_widget_set_tooltip_text(g->tab, title);
+ gtk_widget_set_tooltip_text(tab, title);
}
}
@@ -147,7 +156,7 @@
g_object_set_data(G_OBJECT(hbox), "label", label);
g_object_set_data(G_OBJECT(hbox), "close-button", button);
- window->tab = hbox;
+ nsgtk_window_set_tab(window, hbox);
gtk_widget_show_all(hbox);
return hbox;
@@ -183,6 +192,7 @@
GtkWidget *window = gtk_notebook_get_nth_page(notebook, page_num);
struct gui_window *gw = g_object_get_data(G_OBJECT(window),
"gui_window");
+ search_reset();
if (gw)
nsgtk_scaffolding_set_top_level(gw);
}
Index: gtk/dialogs/gtk_options.c
===================================================================
--- gtk/dialogs/gtk_options.c (revision 8438)
+++ gtk/dialogs/gtk_options.c (working copy)
@@ -2,6 +2,7 @@
* Copyright 2006 Rob Kendrick <rjek(a)rjek.com>
* Copyright 2008 Mike Lester <element3260(a)gmail.com>
* Copyright 2009 Daniel Silverstone <dsilvers(a)netsurf-browser.org>
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
*
* This file is part of NetSurf,
http://www.netsurf-browser.org/
*
@@ -27,15 +28,18 @@
#include <glade/glade.h>
#include "desktop/options.h"
#include "desktop/print.h"
+#include "desktop/searchweb.h"
#include "gtk/options.h"
#include "gtk/gtk_gui.h"
#include "gtk/gtk_scaffolding.h"
+#include "gtk/gtk_theme.h"
#include "gtk/dialogs/gtk_options.h"
#include "gtk/gtk_window.h"
#include "utils/log.h"
#include "utils/utils.h"
+#include "utils/messages.h"
-GtkDialog *wndPreferences;
+GtkDialog *wndPreferences = NULL;
static GladeXML *gladeFile;
static gchar *glade_location;
static struct browser_window *current_browser;
@@ -97,6 +101,12 @@
DECLARE(fileChooserDownloads);
DECLARE(checkFocusNew);
DECLARE(checkNewBlank);
+DECLARE(checkUrlSearch);
+DECLARE(comboSearch);
+DECLARE(combotheme);
+DECLARE(buttonaddtheme);
+DECLARE(sourceButtonTab);
+static GtkWidget *sourceButtonWindow;
DECLARE(spinMarginTop);
DECLARE(spinMarginBottom);
@@ -133,7 +143,13 @@
wndPreferences = GTK_DIALOG(glade_xml_get_widget(gladeFile,
"dlgPreferences"));
gtk_window_set_transient_for (GTK_WINDOW(wndPreferences), parent);
-
+
+ FIND_WIDGET(sourceButtonTab);
+ FIND_WIDGET(sourceButtonWindow);
+ GSList *group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(
+ sourceButtonWindow));
+ gtk_radio_button_set_group(GTK_RADIO_BUTTON(sourceButtonTab), group);
+
/* set the widgets to reflect the current options */
nsgtk_options_load();
@@ -188,7 +204,13 @@
CONNECT(checkFocusNew, "toggled");
CONNECT(checkNewBlank, "toggled");
+ CONNECT(checkUrlSearch, "toggled");
+ CONNECT(comboSearch, "changed");
+ CONNECT(combotheme, "changed");
+ CONNECT(buttonaddtheme, "clicked");
+ CONNECT(sourceButtonTab, "toggled");
+
CONNECT(spinMarginTop, "value-changed");
CONNECT(spinMarginBottom, "value-changed");
CONNECT(spinMarginLeft, "value-changed");
@@ -247,11 +269,11 @@
(value)); \
} while (0)
-#define SET_FILE_CHOOSER(widgt, value) \
+#define SET_FILE_CHOOSER(widget, value) \
do { \
- (widgt) = glade_xml_get_widget(gladeFile, #widgt); \
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER((widgt)), \
- (value)); \
+ (widget) = glade_xml_get_widget(gladeFile, #widget); \
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(\
+ (widget)), (value)); \
} while (0)
#define SET_BUTTON(widget) \
@@ -262,19 +284,18 @@
void nsgtk_options_load(void)
{
- GtkVBox *combolanguagevbox;
- gchar *languagefile;
+ GtkBox *box;
+ gchar *languagefile, *themefile;
const char *default_accept_language =
option_accept_language ? option_accept_language : "en";
int combo_row_count = 0;
int active_language = 0;
int proxytype = 0;
FILE *fp;
- char buf[20];
+ char buf[50];
/* Create combobox */
- combolanguagevbox =
- GTK_VBOX(glade_xml_get_widget(gladeFile, "combolanguagevbox"));
+ box = GTK_BOX(glade_xml_get_widget(gladeFile, "combolanguagevbox"));
comboLanguage = gtk_combo_box_new_text();
languagefile = g_strconcat(res_dir_location, "languages", NULL);
@@ -309,10 +330,35 @@
/** \todo localisation */
gtk_widget_set_tooltip_text(GTK_WIDGET(comboLanguage),
"set preferred language for web pages");
- gtk_box_pack_start(GTK_BOX(combolanguagevbox),
- comboLanguage, FALSE, FALSE, 0);
+ gtk_box_pack_start(box, comboLanguage, FALSE, FALSE, 0);
gtk_widget_show(comboLanguage);
+
+ /* populate theme combo from themelist file */
+ box = GTK_BOX(glade_xml_get_widget(gladeFile, "themehbox"));
+ combotheme = gtk_combo_box_new_text();
+ themefile = g_strconcat(res_dir_location, "themelist", NULL);
+ fp = fopen((const char *)themefile, "r");
+ g_free(themefile);
+ if (fp == NULL) {
+ LOG(("Failed opening themes file"));
+ warn_user("FileError", (const char *) themefile);
+ return;
+ }
+ while (fgets(buf, sizeof(buf), fp)) {
+ /* Ignore blank lines */
+ if (buf[0] == '\0')
+ continue;
+ /* Remove trailing \n */
+ buf[strlen(buf) - 1] = '\0';
+
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combotheme), buf);
+ }
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combotheme),
+ option_current_theme);
+ gtk_box_pack_start(box, combotheme, FALSE, TRUE, 0);
+ gtk_widget_show(combotheme);
+
SET_ENTRY(entryHomePageURL,
option_homepage_url ? option_homepage_url : "");
SET_BUTTON(setCurrentPage);
@@ -380,7 +426,12 @@
SET_CHECK(checkFocusNew, option_focus_new);
SET_CHECK(checkNewBlank, option_new_blank);
+ SET_CHECK(checkUrlSearch, option_search_url_bar);
+ SET_COMBO(comboSearch, option_search_provider);
+ SET_BUTTON(buttonaddtheme);
+ SET_CHECK(sourceButtonTab, option_source_tab);
+
SET_SPIN(spinMarginTop, option_margin_top);
SET_SPIN(spinMarginBottom, option_margin_bottom);
SET_SPIN(spinMarginLeft, option_margin_left);
@@ -417,6 +468,14 @@
}
return stay_alive;
}
+
+bool nsgtk_options_combo_theme_add(const char *themename)
+{
+ if (wndPreferences == NULL)
+ return false;
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combotheme), themename);
+ return true;
+}
/* Defines the callback functions for all widgets and specifies
@@ -643,42 +702,43 @@
END_HANDLER
COMBO_CHANGED(comboButtonType, option_button_type)
- struct gui_window *current = window_list;
+ nsgtk_scaffolding *current = scaf_list;
while (current) {
+ nsgtk_scaffolding_reset_offset(current);
switch(option_button_type) {
case 0:
gtk_toolbar_set_style(
- GTK_TOOLBAR(current->scaffold->tool_bar),
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
GTK_TOOLBAR_ICONS);
gtk_toolbar_set_icon_size(
- GTK_TOOLBAR(current->scaffold->tool_bar),
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
GTK_ICON_SIZE_SMALL_TOOLBAR);
break;
case 1:
gtk_toolbar_set_style(
- GTK_TOOLBAR(current->scaffold->tool_bar),
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
GTK_TOOLBAR_ICONS);
gtk_toolbar_set_icon_size(
- GTK_TOOLBAR(current->scaffold->tool_bar),
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
GTK_ICON_SIZE_LARGE_TOOLBAR);
break;
case 2:
gtk_toolbar_set_style(
- GTK_TOOLBAR(current->scaffold->tool_bar),
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
GTK_TOOLBAR_BOTH);
gtk_toolbar_set_icon_size(
- GTK_TOOLBAR(current->scaffold->tool_bar),
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
GTK_ICON_SIZE_LARGE_TOOLBAR);
break;
case 3:
gtk_toolbar_set_style(
- GTK_TOOLBAR(current->scaffold->tool_bar),
+ GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
GTK_TOOLBAR_TEXT);
default:
break;
}
- current = current->next;
+ current = nsgtk_scaffolding_iterate(current);
}
END_HANDLER
@@ -704,6 +764,100 @@
CHECK_CHANGED(checkNewBlank, option_new_blank)
END_HANDLER
+CHECK_CHANGED(checkUrlSearch, option_search_url_bar)
+END_HANDLER
+
+COMBO_CHANGED(comboSearch, option_search_provider)
+ nsgtk_scaffolding *current = scaf_list;
+ char *name;
+ /* refresh web search prefs from file */
+ search_web_provider_details(option_search_provider);
+ /* retrieve ico */
+ search_ico = search_web_retrieve_ico(false);
+ /* callback may handle changing gui */
+ if (search_ico != NULL)
+ gui_window_set_search_ico();
+ /* set entry */
+ name = search_web_provider_name();
+ while (current) {
+ nsgtk_scaffolding_set_websearch(current, name);
+ current = nsgtk_scaffolding_iterate(current);
+ }
+ free(name);
+END_HANDLER
+
+COMBO_CHANGED(combotheme, option_current_theme)
+ nsgtk_scaffolding *current = scaf_list;
+ if (option_current_theme != 0) {
+ if (current_theme_name != NULL)
+ free(current_theme_name);
+ current_theme_name = strdup(gtk_combo_box_get_active_text(
+ GTK_COMBO_BOX(combotheme)));
+ nsgtk_theme_prepare();
+ } else if (current_theme_name != NULL) {
+ free(current_theme_name);
+ current_theme_name = NULL;
+ }
+ while (current) {
+ nsgtk_theme_implement(current);
+ current = nsgtk_scaffolding_iterate(current);
+ }
+END_HANDLER
+
+BUTTON_CLICKED(buttonaddtheme)
+ char *themesfolder, *filename, *directory;
+ GtkWidget *fc = gtk_file_chooser_dialog_new(
+ messages_get("gtkAddThemeTitle"),
+ GTK_WINDOW(wndPreferences),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
+ themesfolder = g_strconcat(res_dir_location, "themes", NULL);
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc),
+ themesfolder);
+ gint res = gtk_dialog_run(GTK_DIALOG(fc));
+ if (res == GTK_RESPONSE_ACCEPT) {
+ filename = gtk_file_chooser_get_current_folder(
+ GTK_FILE_CHOOSER(fc));
+ if (strcmp(filename, themesfolder) != 0) {
+ directory = strrchr(filename, '/');
+ *directory = '\0';
+ if (strcmp(filename, themesfolder) != 0) {
+ warn_user(messages_get(
+ "gtkThemeFolderInstructions"),
+ 0);
+ gtk_widget_destroy(GTK_WIDGET(fc));
+ free(filename);
+ free(themesfolder);
+ return FALSE;
+ } else {
+ directory++;
+ }
+ } else {
+ free(filename);
+ filename = gtk_file_chooser_get_filename(
+ GTK_FILE_CHOOSER(fc));
+ if (strcmp(filename, themesfolder) == 0) {
+ warn_user(messages_get("gtkThemeFolderSub"),
+ 0);
+ gtk_widget_destroy(GTK_WIDGET(fc));
+ free(filename);
+ free(themesfolder);
+ return FALSE;
+ }
+ directory = strrchr(filename, '/') + 1;
+ }
+ gtk_widget_destroy(GTK_WIDGET(fc));
+ nsgtk_theme_add(directory);
+ free(filename);
+ free(themesfolder);
+ }
+
+END_HANDLER
+
+CHECK_CHANGED(sourceButtonTab, option_source_tab)
+END_HANDLER
+
SPIN_CHANGED(spinMarginTop, option_margin_top)
END_HANDLER
Index: gtk/dialogs/gtk_options.h
===================================================================
--- gtk/dialogs/gtk_options.h (revision 8438)
+++ gtk/dialogs/gtk_options.h (working copy)
@@ -1,5 +1,6 @@
/*
* Copyright 2006 Rob Kendrick <rjek(a)rjek.com>
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
*
* This file is part of NetSurf,
http://www.netsurf-browser.org/
*
@@ -26,5 +27,6 @@
GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent); /** Init
options and load window */
void nsgtk_options_load(void); /** Load current options into window */
void nsgtk_options_save(void); /** Save options from window */
+bool nsgtk_options_combo_theme_add(const char *themename); /** add new theme name to
combo */
#endif
Index: gtk/dialogs/gtk_source.c
===================================================================
--- gtk/dialogs/gtk_source.c (revision 8438)
+++ gtk/dialogs/gtk_source.c (working copy)
@@ -28,8 +28,10 @@
#include "gtk/gtk_gui.h"
#include "gtk/gtk_print.h"
#include "gtk/gtk_selection.h"
+#include "gtk/options.h"
#include "desktop/netsurf.h"
#include "desktop/print.h"
+#include "desktop/options.h"
#include "utils/messages.h"
#include "utils/url.h"
#include "utils/utils.h"
@@ -61,6 +63,7 @@
static struct nsgtk_source_window *nsgtk_source_list = 0;
static char source_zoomlevel = 10;
+void nsgtk_source_tab_init(GtkWindow *parent, struct browser_window *bw);
static void nsgtk_attach_source_menu_handlers(GladeXML *xml, gpointer g);
static gboolean nsgtk_source_delete_event(GtkWindow *window, gpointer g);
static gboolean nsgtk_source_destroy_event(GtkWindow *window, gpointer g);
@@ -103,111 +106,148 @@
void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw)
{
- if (bw->current_content->type == CONTENT_HTML) {
- glade_Location = g_strconcat(res_dir_location, "source.glade",
- NULL);
- glade_File = glade_xml_new(glade_Location, NULL, NULL);
- if (glade_File == NULL) {
- LOG(("error loading glade tree"));
- }
+ if (bw->current_content->type != CONTENT_HTML)
+ return;
+
+ if (option_source_tab) {
+ nsgtk_source_tab_init(parent, bw);
+ return;
+ }
+
+ glade_Location = g_strconcat(res_dir_location, "source.glade",
+ NULL);
+ glade_File = glade_xml_new(glade_Location, NULL, NULL);
+ if (glade_File == NULL) {
+ LOG(("error loading glade tree"));
+ }
+ g_free(glade_Location);
- char *data = NULL;
+ char *data = NULL;
- utf8_convert_ret r = utf8_from_enc(
- bw->current_content->source_data,
- bw->current_content->data.html.encoding,
- bw->current_content->source_size,
- &data);
- if (r == UTF8_CONVERT_NOMEM) {
- warn_user("NoMemory",0);
- return;
- } else if (r == UTF8_CONVERT_BADENC) {
- warn_user("EncNotRec",0);
- return;
- }
+ utf8_convert_ret r = utf8_from_enc(
+ bw->current_content->source_data,
+ bw->current_content->data.html.encoding,
+ bw->current_content->source_size,
+ &data);
+ if (r == UTF8_CONVERT_NOMEM) {
+ warn_user("NoMemory",0);
+ return;
+ } else if (r == UTF8_CONVERT_BADENC) {
+ warn_user("EncNotRec",0);
+ return;
+ }
- GtkWindow *wndSource = GTK_WINDOW(glade_xml_get_widget(
- glade_File, "wndSource"));
- GtkWidget *cutbutton = glade_xml_get_widget(
- glade_File, "source_cut");
- GtkWidget *pastebutton = glade_xml_get_widget(
- glade_File, "source_paste");
- GtkWidget *deletebutton = glade_xml_get_widget(
- glade_File, "source_delete");
- GtkWidget *printbutton = glade_xml_get_widget(
- glade_File, "source_print");
- gtk_widget_set_sensitive(cutbutton, FALSE);
- gtk_widget_set_sensitive(pastebutton, FALSE);
- gtk_widget_set_sensitive(deletebutton, FALSE);
- /* for now */
- gtk_widget_set_sensitive(printbutton, FALSE);
-
- struct nsgtk_source_window *thiswindow =
- malloc(sizeof(struct nsgtk_source_window));
- if (thiswindow == NULL) {
- free(data);
- warn_user("NoMemory", 0);
- return;
- }
+ GtkWindow *wndSource = GTK_WINDOW(glade_xml_get_widget(
+ glade_File, "wndSource"));
+ GtkWidget *cutbutton = glade_xml_get_widget(
+ glade_File, "source_cut");
+ GtkWidget *pastebutton = glade_xml_get_widget(
+ glade_File, "source_paste");
+ GtkWidget *deletebutton = glade_xml_get_widget(
+ glade_File, "source_delete");
+ GtkWidget *printbutton = glade_xml_get_widget(
+ glade_File, "source_print");
+ gtk_widget_set_sensitive(cutbutton, FALSE);
+ gtk_widget_set_sensitive(pastebutton, FALSE);
+ gtk_widget_set_sensitive(deletebutton, FALSE);
+ /* for now */
+ gtk_widget_set_sensitive(printbutton, FALSE);
+
+ struct nsgtk_source_window *thiswindow =
+ malloc(sizeof(struct nsgtk_source_window));
+ if (thiswindow == NULL) {
+ free(data);
+ warn_user("NoMemory", 0);
+ return;
+ }
- thiswindow->url = strdup(bw->current_content->url);
- if (thiswindow->url == NULL) {
- free(thiswindow);
- free(data);
- warn_user("NoMemory", 0);
- return;
- }
+ thiswindow->url = strdup(bw->current_content->url);
+ if (thiswindow->url == NULL) {
+ free(thiswindow);
+ free(data);
+ warn_user("NoMemory", 0);
+ return;
+ }
- thiswindow->data = data;
-
- thiswindow->sourcewindow = wndSource;
- thiswindow->bw = bw;
+ thiswindow->data = data;
- char *title = malloc(strlen(bw->current_content->url)
- + SLEN("Source of ") + 1);
- if (title == NULL) {
- free(thiswindow->url);
- free(thiswindow);
- free(data);
- warn_user("NoMemory", 0);
- return;
- }
- sprintf(title, "Source of %s", bw->current_content->url);
+ thiswindow->sourcewindow = wndSource;
+ thiswindow->bw = bw;
- thiswindow->next = nsgtk_source_list;
- thiswindow->prev = NULL;
- if (nsgtk_source_list != NULL)
- nsgtk_source_list->prev = thiswindow;
- nsgtk_source_list = thiswindow;
-
- nsgtk_attach_source_menu_handlers(glade_File, thiswindow);
+ char *title = malloc(strlen(bw->current_content->url)
+ + SLEN("Source of ") + 1);
+ if (title == NULL) {
+ free(thiswindow->url);
+ free(thiswindow);
+ free(data);
+ warn_user("NoMemory", 0);
+ return;
+ }
+ sprintf(title, "Source of %s", bw->current_content->url);
+
+ thiswindow->next = nsgtk_source_list;
+ thiswindow->prev = NULL;
+ if (nsgtk_source_list != NULL)
+ nsgtk_source_list->prev = thiswindow;
+ nsgtk_source_list = thiswindow;
- gtk_window_set_title(wndSource, title);
+ nsgtk_attach_source_menu_handlers(glade_File, thiswindow);
- g_signal_connect(G_OBJECT(wndSource), "destroy",
- G_CALLBACK(nsgtk_source_destroy_event),
- thiswindow);
- g_signal_connect(G_OBJECT(wndSource), "delete-event",
- G_CALLBACK(nsgtk_source_delete_event),
- thiswindow);
+ gtk_window_set_title(wndSource, title);
+
+ g_signal_connect(G_OBJECT(wndSource), "destroy",
+ G_CALLBACK(nsgtk_source_destroy_event),
+ thiswindow);
+ g_signal_connect(G_OBJECT(wndSource), "delete-event",
+ G_CALLBACK(nsgtk_source_delete_event),
+ thiswindow);
+
+ GtkTextView *sourceview = GTK_TEXT_VIEW(
+ glade_xml_get_widget(glade_File,
+ "source_view"));
+ PangoFontDescription *fontdesc =
+ pango_font_description_from_string("Monospace 8");
+
+ thiswindow->gv = sourceview;
+ gtk_widget_modify_font(GTK_WIDGET(sourceview), fontdesc);
+ GtkTextBuffer *tb = gtk_text_view_get_buffer(sourceview);
+ gtk_text_buffer_set_text(tb, thiswindow->data, -1);
- GtkTextView *sourceview = GTK_TEXT_VIEW(
- glade_xml_get_widget(glade_File,
- "source_view"));
- PangoFontDescription *fontdesc =
- pango_font_description_from_string("Monospace 8");
+ gtk_widget_show(GTK_WIDGET(wndSource));
- thiswindow->gv = sourceview;
- gtk_widget_modify_font(GTK_WIDGET(sourceview), fontdesc);
- GtkTextBuffer *tb = gtk_text_view_get_buffer(sourceview);
- gtk_text_buffer_set_text(tb, thiswindow->data, -1);
-
- gtk_widget_show(GTK_WIDGET(wndSource));
-
- free(title);
+ free(title);
+}
+void nsgtk_source_tab_init(GtkWindow *parent, struct browser_window *bw)
+{
+ char *ndata = 0;
+ utf8_convert_ret r = utf8_from_enc(
+ bw->current_content->source_data,
+ bw->current_content->data.html.encoding,
+ bw->current_content->source_size,
+ &ndata);
+ if (r == UTF8_CONVERT_NOMEM) {
+ warn_user("NoMemory",0);
+ return;
+ } else if (r == UTF8_CONVERT_BADENC) {
+ warn_user("EncNotRec",0);
+ return;
}
+ gchar *filename;
+ gint handle = g_file_open_tmp("nsgtksourceXXXXXX", &filename, NULL);
+ close (handle); /* in case it was binary mode */
+ FILE *f = fopen(filename, "w");
+ fprintf(f, "%s", ndata);
+ fclose(f);
+ filename = g_strconcat("file://", filename, NULL);
+ struct browser_window *newbw = browser_window_create(filename, bw,
+ NULL, false, true);
+ g_free(filename);
+ if (newbw->current_content)
+ newbw->current_content->title = g_strconcat("source of ",
+ bw->current_content->url , NULL);
}
+
void nsgtk_attach_source_menu_handlers(GladeXML *xml, gpointer g)
{
struct menu_events *event = source_menu_events;
Index: gtk/res/netsurf.glade
===================================================================
--- gtk/res/netsurf.glade (revision 8438)
+++ gtk/res/netsurf.glade (working copy)
@@ -12,197 +12,10 @@
<widget class="GtkMenuBar" id="menubar">
<property name="visible">True</property>
<child>
- <widget class="GtkMenuItem" id="menuitem_main">
+ <widget class="GtkMenuItem" id="menuitem_file">
<property name="visible">True</property>
<property name="label"
translatable="yes">_File</property>
<property name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="menuitem_main_menu">
- <child>
- <widget class="GtkImageMenuItem"
id="new_window">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Opens a new browser window.</property>
- <property name="label"
translatable="yes">_New Window</property>
- <property
name="use_underline">True</property>
- <accelerator key="n"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image608">
- <property
name="visible">True</property>
- <property
name="stock">gtk-new</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="new_tab">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Opens a new browser tab.</property>
- <property name="label"
translatable="yes">New _Tab</property>
- <property
name="use_underline">True</property>
- <accelerator key="t"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image609">
- <property
name="visible">True</property>
- <property
name="stock">gtk-new</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="open_file">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Open a file on your computer into this browser
window.</property>
- <property name="label"
translatable="yes">_Open File...</property>
- <property
name="use_underline">True</property>
- <accelerator key="o"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image610">
- <property
name="visible">True</property>
- <property
name="stock">gtk-open</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="close_window">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Close this browser window.</property>
- <property name="label"
translatable="yes">_Close Window</property>
- <property
name="use_underline">True</property>
- <accelerator key="w" modifiers="GDK_SHIFT_MASK
| GDK_CONTROL_MASK" signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image611">
- <property
name="visible">True</property>
- <property
name="stock">gtk-close</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separatormenuitem1">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="save_page">
- <property name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">Save this page to disc, optionally including images,
etc.</property>
- <property name="label"
translatable="yes">Save page...</property>
- <property
name="use_underline">True</property>
- <child internal-child="image">
- <widget class="GtkImage"
id="image612">
- <property
name="visible">True</property>
- <property
name="stock">gtk-save-as</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="export">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Export the page to a different format.</property>
- <property name="label"
translatable="yes">Export</property>
- <property
name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="export_menu">
- <child>
- <widget class="GtkMenuItem"
id="export_plain_text">
- <property
name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">Plain ASCII text, readable in text editors and
views.</property>
- <property name="label"
translatable="yes">Plain text...</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="export_drawfile">
- <property
name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">RISC OS Drawfile vector graphic.</property>
- <property name="label"
translatable="yes">Drawfile...</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="export_postscript">
- <property
name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">PostScript for printing and converting to
PDFs.</property>
- <property name="label"
translatable="yes">PostScript...</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="export_pdf">
- <property
name="visible">True</property>
- <property name="tooltip"
translatable="yes">Portable Document Format.</property>
- <property name="label"
translatable="yes">PDF...</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator2">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="print_preview">
- <property name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">Show how a print out might look like.</property>
- <property name="label"
translatable="yes">Print preview...</property>
- <property
name="use_underline">True</property>
- <accelerator key="P" modifiers="GDK_SHIFT_MASK
| GDK_CONTROL_MASK" signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image613">
- <property
name="visible">True</property>
- <property
name="stock">gtk-print-preview</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="print">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Produce a hardcopy on your printer.</property>
- <property name="label"
translatable="yes">Print...</property>
- <property
name="use_underline">True</property>
- <accelerator key="P"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image614">
- <property
name="visible">True</property>
- <property
name="stock">gtk-print</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator3">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="quit">
- <property name="visible">True</property>
- <property name="label">gtk-quit</property>
- <property
name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- </widget>
- </child>
</widget>
</child>
<child>
@@ -210,93 +23,6 @@
<property name="visible">True</property>
<property name="label"
translatable="yes">_Edit</property>
<property name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="menuitem_edit_menu">
- <child>
- <widget class="GtkImageMenuItem"
id="cut">
- <property name="visible">True</property>
- <property name="label">gtk-cut</property>
- <property
name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="copy">
- <property name="visible">True</property>
- <property name="label">gtk-copy</property>
- <property
name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="paste">
- <property name="visible">True</property>
- <property
name="label">gtk-paste</property>
- <property
name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="delete">
- <property name="visible">True</property>
- <property
name="sensitive">False</property>
- <property
name="label">gtk-delete</property>
- <property
name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator4">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="select_all">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Selects all text in the current browser
window.</property>
- <property
name="label">gtk-select-all</property>
- <property
name="use_underline">True</property>
- <property name="use_stock">True</property>
- <accelerator key="a"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator5">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="find">
- <property name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">Find specific text in the current browser
window.</property>
- <property name="label"
translatable="yes">_Find...</property>
- <property
name="use_underline">True</property>
- <accelerator key="F"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator6">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="preferences">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Change how NetSurf functions.</property>
- <property name="label"
translatable="yes">P_references...</property>
- <property
name="use_underline">True</property>
- <child internal-child="image">
- <widget class="GtkImage"
id="image615">
- <property
name="visible">True</property>
- <property
name="stock">gtk-preferences</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
</widget>
</child>
<child>
@@ -304,375 +30,13 @@
<property name="visible">True</property>
<property name="label"
translatable="yes">_View</property>
<property name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="menuitem_view_menu">
- <child>
- <widget class="GtkImageMenuItem"
id="stop">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">_Stop</property>
- <property
name="use_underline">True</property>
- <accelerator key="Escape" modifiers=""
signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image616">
- <property
name="visible">True</property>
- <property
name="stock">gtk-stop</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="reload">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">_Reload</property>
- <property
name="use_underline">True</property>
- <accelerator key="F5" modifiers=""
signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image617">
- <property
name="visible">True</property>
- <property
name="stock">gtk-refresh</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator10">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="scale_view">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Scale the page in the current browser window to be smaller
or larger.</property>
- <property name="label"
translatable="yes">_Scale View...</property>
- <property
name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="scale_view_menu">
- <child>
- <widget class="GtkImageMenuItem"
id="zoom_in">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">Zoom _in</property>
- <property
name="use_underline">True</property>
- <child internal-child="image">
- <widget class="GtkImage"
id="image619">
- <property
name="visible">True</property>
- <property
name="stock">gtk-zoom-in</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="normal_size">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">_Normal size</property>
- <property
name="use_underline">True</property>
- <child internal-child="image">
- <widget class="GtkImage"
id="image620">
- <property
name="visible">True</property>
- <property
name="stock">gtk-zoom-100</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="zoom_out">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">Zoom _out</property>
- <property
name="use_underline">True</property>
- <child internal-child="image">
- <widget class="GtkImage"
id="image621">
- <property
name="visible">True</property>
- <property
name="stock">gtk-zoom-out</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child internal-child="image">
- <widget class="GtkImage"
id="image618">
- <property
name="visible">True</property>
- <property
name="stock">gtk-zoom-in</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="full_screen">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">_Fullscreen</property>
- <property
name="use_underline">True</property>
- <accelerator key="F11" modifiers=""
signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image622">
- <property
name="visible">True</property>
- <property
name="stock">gtk-fullscreen</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="view_source">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">View S_ource</property>
- <property
name="use_underline">True</property>
- <child internal-child="image">
- <widget class="GtkImage"
id="menu-item-image28">
- <property
name="visible">True</property>
- <property
name="stock">gtk-index</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator12">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="images">
- <property name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="label"
translatable="yes">_Images...</property>
- <property
name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="images_menu">
- <child>
- <widget class="GtkCheckMenuItem"
id="foreground_images">
- <property
name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">Toggle the display of images in the
foreground.</property>
- <property name="label"
translatable="yes">_Foreground Images</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkCheckMenuItem"
id="background_images">
- <property
name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">Toggle the display of images in the
background.</property>
- <property name="label"
translatable="yes">_Background Images</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="toolbars">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">_Toolbars...</property>
- <property
name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="toolbars_menu">
- <child>
- <widget class="GtkCheckMenuItem"
id="menu_bar">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">_Menu Bar</property>
- <property
name="use_underline">True</property>
- <property
name="active">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkCheckMenuItem"
id="tool_bar">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">_Button Bar</property>
- <property
name="use_underline">True</property>
- <property
name="active">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkCheckMenuItem"
id="status_bar">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">_Status Bar</property>
- <property
name="use_underline">True</property>
- <property
name="active">True</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator11">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="downloads">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Shows the downloads window</property>
- <property name="label"
translatable="yes">_Downloads...</property>
- <property
name="use_underline">True</property>
- <accelerator key="d"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="save_window_size">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Save this window's size and position for use with new
windows.</property>
- <property name="label"
translatable="yes">S_ave Window Size</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="debugging">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">De_bugging</property>
- <property
name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="debugging_menu">
- <child>
- <widget class="GtkMenuItem"
id="toggle_debug_rendering">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">T_oggle debug rendering</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="save_box_tree">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">_Save box tree</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="save_dom_tree">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">Save DOM tree</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
</widget>
</child>
<child>
- <widget class="GtkMenuItem"
id="menuitem_navigate">
+ <widget class="GtkMenuItem" id="menuitem_nav">
<property name="visible">True</property>
<property name="label"
translatable="yes">_Navigate</property>
<property name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="menuitem_navigate_menu">
- <child>
- <widget class="GtkImageMenuItem"
id="back">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">_Back</property>
- <property
name="use_underline">True</property>
- <accelerator key="Left"
modifiers="GDK_MOD1_MASK" signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image623">
- <property
name="visible">True</property>
- <property
name="stock">gtk-go-back</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="forward">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">_Forward</property>
- <property
name="use_underline">True</property>
- <accelerator key="Right"
modifiers="GDK_MOD1_MASK" signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image624">
- <property
name="visible">True</property>
- <property
name="stock">gtk-go-forward</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="home">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">_Home</property>
- <property
name="use_underline">True</property>
- <accelerator key="Down"
modifiers="GDK_MOD1_MASK" signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image625">
- <property
name="visible">True</property>
- <property
name="stock">gtk-home</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator7">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="local_history">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Show the history tree for this browser
window.</property>
- <property name="label"
translatable="yes">_Local history...</property>
- <property
name="use_underline">True</property>
- <accelerator key="H"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="global_history">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Show the history tree for all windows.</property>
- <property name="label"
translatable="yes">_Global history...</property>
- <property
name="use_underline">True</property>
- <accelerator key="h" modifiers="GDK_SHIFT_MASK
| GDK_CONTROL_MASK" signal="activate"/>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator8">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="nsgtk_add_to_bookmarks">
- <property name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">Add the current page to your bookmarks.</property>
- <property name="label"
translatable="yes">_Add to Bookmarks</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="show_bookmarks">
- <property name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">Open a window showing all your
bookmarks.</property>
- <property name="label"
translatable="yes">_Show Bookmarks...</property>
- <property
name="use_underline">True</property>
- <accelerator key="F6" modifiers=""
signal="activate"/>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator13">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="open_location">
- <property name="visible">True</property>
- <property name="tooltip"
translatable="yes">Open an address into this browser
window.</property>
- <property name="label"
translatable="yes">_Open location...</property>
- <property
name="use_underline">True</property>
- <accelerator key="L"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- </widget>
- </child>
- </widget>
- </child>
</widget>
</child>
<child>
@@ -680,41 +44,6 @@
<property name="visible">True</property>
<property name="label"
translatable="yes">_Tabs</property>
<property name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="menuitem_tabs_menu">
- <child>
- <widget class="GtkMenuItem"
id="next_tab">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">_Next Tab</property>
- <property
name="use_underline">True</property>
- <accelerator key="Right"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="prev_tab">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">_Previous Tab</property>
- <property
name="use_underline">True</property>
- <accelerator key="Left"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="close_tab">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">_Close tab</property>
- <property
name="use_underline">True</property>
- <accelerator key="W"
modifiers="GDK_CONTROL_MASK" signal="activate"/>
- <child internal-child="image">
- <widget class="GtkImage"
id="image626">
- <property
name="visible">True</property>
- <property
name="stock">gtk-close</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
</widget>
</child>
<child>
@@ -722,56 +51,6 @@
<property name="visible">True</property>
<property name="label"
translatable="yes">_Help</property>
<property name="use_underline">True</property>
- <child>
- <widget class="GtkMenu"
id="menuitem_help_menu">
- <child>
- <widget class="GtkImageMenuItem"
id="contents">
- <property name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">Shows the contents of the NetSurf
manual.</property>
- <property name="label"
translatable="yes">_Contents...</property>
- <property
name="use_underline">True</property>
- <child internal-child="image">
- <widget class="GtkImage"
id="image627">
- <property
name="visible">True</property>
- <property
name="stock">gtk-help</property>
- <property
name="icon_size">1</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="guide">
- <property name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="tooltip"
translatable="yes">Shows a guide and tutorial.</property>
- <property name="label"
translatable="yes">User _guide...</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem"
id="user_information">
- <property name="visible">True</property>
- <property
name="sensitive">False</property>
- <property name="label"
translatable="yes">User _information...</property>
- <property
name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem"
id="separator9">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem"
id="about">
- <property name="visible">True</property>
- <property
name="label">gtk-about</property>
- <property
name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- </widget>
- </child>
</widget>
</child>
</widget>
@@ -784,92 +63,123 @@
<widget class="GtkToolbar" id="toolbar">
<property name="visible">True</property>
<property
name="toolbar_style">GTK_TOOLBAR_BOTH_HORIZ</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkToolbar" id="searchbar">
<child>
- <widget class="GtkToolButton" id="toolBack">
+ <widget class="GtkToolButton"
id="closeSearchButton">
<property name="visible">True</property>
- <property name="stock_id">gtk-go-back</property>
+ <property name="stock_id">gtk-close</property>
</widget>
<packing>
- <property name="homogeneous">True</property>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
</packing>
</child>
<child>
- <widget class="GtkToolButton" id="toolHistory">
+ <widget class="GtkToolItem"
id="searchLabelItem">
<property name="visible">True</property>
- <property
name="visible_horizontal">False</property>
- <property name="visible_vertical">False</property>
- <property name="is_important">True</property>
- <property
name="icon">arrow_down_8x32.png</property>
+ <child>
+ <widget class="GtkLabel" id="searchlabel">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Match</property>
+ </widget>
+ </child>
</widget>
<packing>
- <property name="homogeneous">True</property>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
</packing>
</child>
<child>
- <widget class="GtkToolButton" id="toolForward">
+ <widget class="GtkToolItem" id="toolSearch">
<property name="visible">True</property>
- <property
name="stock_id">gtk-go-forward</property>
+ <child>
+ <widget class="GtkEntry" id="searchEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ </child>
</widget>
<packing>
- <property name="homogeneous">True</property>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
</packing>
</child>
<child>
- <widget class="GtkToolButton" id="toolStop">
+ <widget class="GtkToolButton"
id="searchBackButton">
<property name="visible">True</property>
- <property name="stock_id">gtk-stop</property>
+ <property name="label"
translatable="yes">search _Back</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-go-back</property>
</widget>
<packing>
- <property name="homogeneous">True</property>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
</packing>
</child>
<child>
- <widget class="GtkToolButton" id="toolReload">
+ <widget class="GtkToolButton"
id="searchForwardButton">
<property name="visible">True</property>
- <property name="stock_id">gtk-refresh</property>
+ <property name="label"
translatable="yes">search _Forward</property>
+ <property name="use_underline">True</property>
+ <property
name="stock_id">gtk-go-forward</property>
</widget>
<packing>
- <property name="homogeneous">True</property>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
</packing>
</child>
<child>
- <widget class="GtkToolButton" id="toolHome">
+ <widget class="GtkToolItem"
id="checkAllSearchItem">
<property name="visible">True</property>
- <property name="stock_id">gtk-home</property>
- </widget>
- <packing>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <widget class="GtkToolItem" id="toolURLBar">
- <property name="visible">True</property>
<child>
- <widget class="GtkEntry" id="URLBar">
+ <widget class="GtkCheckButton"
id="checkAllSearch">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="has_focus">True</property>
+ <property name="tooltip"
translatable="yes">show all matches</property>
+ <property name="label"
translatable="yes">all </property>
+ <property name="response_id">0</property>
+ <property
name="draw_indicator">True</property>
</widget>
</child>
</widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
+ </packing>
</child>
<child>
- <widget class="GtkToolItem" id="toolthrobber">
+ <widget class="GtkToolItem" id="caseSensItem">
<property name="visible">True</property>
<child>
- <widget class="GtkImage" id="throbber">
+ <widget class="GtkCheckButton"
id="caseSensButton">
<property name="visible">True</property>
- <property name="xpad">2</property>
- <property name="icon_name">gtk-yes</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip"
translatable="yes">Match case when searching</property>
+ <property name="label"
translatable="yes">case</property>
+ <property
name="relief">GTK_RELIEF_NONE</property>
+ <property name="response_id">0</property>
+ <property
name="draw_indicator">True</property>
</widget>
</child>
</widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
+ </packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -907,7 +217,7 @@
</child>
</widget>
<packing>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -917,497 +227,61 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
</widget>
</child>
</widget>
- <widget class="GtkDialog" id="wndLogin">
- <property name="title" translatable="yes">Site
Authentication</property>
- <property
name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property>
- <property
name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox2">
+ <widget class="GtkMenu" id="menuPopup">
+ <child>
+ <widget class="GtkMenuItem" id="menupopup_file">
<property name="visible">True</property>
- <child>
- <widget class="GtkHBox" id="hbox12">
- <property name="visible">True</property>
- <property name="border_width">3</property>
- <child>
- <widget class="GtkImage" id="image3">
- <property name="visible">True</property>
- <property
name="yalign">0.10000000149011612</property>
- <property name="xpad">12</property>
- <property name="icon_size">6</property>
- <property
name="icon_name">gtk-dialog-authentication</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkTable" id="table5">
- <property name="visible">True</property>
- <property name="border_width">1</property>
- <property name="n_rows">4</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">11</property>
- <property name="row_spacing">10</property>
- <child>
- <widget class="GtkLabel"
id="labelLoginHost">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label"
translatable="yes">moo.yoo.com</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label57">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label"
translatable="yes">Password</property>
- </widget>
- <packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label56">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label"
translatable="yes">Username</property>
- </widget>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label54">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label"
translatable="yes">Host</property>
- </widget>
- <packing>
- <property name="x_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label55">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label"
translatable="yes">Realm</property>
- </widget>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="labelLoginRealm">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label"
translatable="yes">my sekr3t area</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkEntry"
id="entryLoginPass">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="visibility">False</property>
- <property
name="activates_default">True</property>
- <property name="text"
translatable="yes">opensesame</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkEntry"
id="entryLoginUser">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_focus">True</property>
- <property name="text"
translatable="yes">sesame</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="y_options"></property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">1</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <widget class="GtkHButtonBox"
id="dialog-action_area2">
- <property name="visible">True</property>
- <property
name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <widget class="GtkButton" id="buttonLoginCan">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
- <child>
- <widget class="GtkButton" id="buttonLoginOK">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="response_id">-5</property>
- <child>
- <widget class="GtkAlignment"
id="alignment14">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <widget class="GtkHBox" id="hbox11">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <widget class="GtkImage"
id="image2">
- <property
name="visible">True</property>
- <property
name="stock">gtk-ok</property>
- </widget>
- <packing>
- <property
name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label49">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">Login</property>
- <property
name="use_underline">True</property>
- </widget>
- <packing>
- <property
name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
+ <property name="label"
translatable="yes">File</property>
+ <property name="use_underline">True</property>
</widget>
</child>
- </widget>
- <widget class="GtkDialog" id="wndSSLProblem">
- <property name="border_width">1</property>
- <property name="title" translatable="yes">SSL certificate
problem</property>
- <property name="modal">True</property>
- <property
name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox3">
+ <child>
+ <widget class="GtkMenuItem" id="menupopup_edit">
<property name="visible">True</property>
- <child>
- <widget class="GtkHBox" id="hbox15">
- <property name="visible">True</property>
- <child>
- <widget class="GtkImage" id="image6">
- <property name="visible">True</property>
- <property name="yalign">0</property>
- <property name="icon_size">6</property>
- <property
name="icon_name">gtk-dialog-warning</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkVBox" id="vbox13">
- <property name="visible">True</property>
- <child>
- <widget class="GtkLabel" id="label62">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">NetSurf failed to verify the authenticity of an SSL
certificate. Please verify the details presented below.</property>
- <property
name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkFrame" id="frame13">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <property name="label_xalign">0</property>
- <child>
- <widget class="GtkAlignment"
id="alignment17">
- <property name="visible">True</property>
- <property
name="left_padding">12</property>
- <child>
- <widget class="GtkScrolledWindow"
id="scrolledwindow1">
- <property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property
name="shadow_type">GTK_SHADOW_IN</property>
- <child>
- <widget class="GtkTextView"
id="textview1">
- <property
name="height_request">200</property>
- <property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property
name="editable">False</property>
- <property name="text"
translatable="yes">(not implemented)</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkLabel" id="label63">
- <property name="visible">True</property>
- <property name="label"
translatable="yes"><b>Certificate
chain</b></property>
- <property
name="use_markup">True</property>
- </widget>
- <packing>
- <property
name="type">label_item</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <widget class="GtkHButtonBox"
id="dialog-action_area3">
- <property name="visible">True</property>
- <property
name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <widget class="GtkButton" id="sslreject">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="response_id">-6</property>
- <child>
- <widget class="GtkAlignment"
id="alignment16">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <widget class="GtkHBox" id="hbox14">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <widget class="GtkImage"
id="image5">
- <property
name="visible">True</property>
- <property
name="stock">gtk-cancel</property>
- </widget>
- <packing>
- <property
name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label61">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">Reject</property>
- <property
name="use_underline">True</property>
- </widget>
- <packing>
- <property
name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkButton" id="sslaccept">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="response_id">-5</property>
- <child>
- <widget class="GtkAlignment"
id="alignment15">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <widget class="GtkHBox" id="hbox13">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <widget class="GtkImage"
id="image4">
- <property
name="visible">True</property>
- <property
name="stock">gtk-apply</property>
- </widget>
- <packing>
- <property
name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label60">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">Accept</property>
- <property
name="use_underline">True</property>
- </widget>
- <packing>
- <property
name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
+ <property name="label"
translatable="yes">Edit</property>
+ <property name="use_underline">True</property>
</widget>
</child>
- </widget>
- <widget class="GtkWindow" id="wndWarning">
- <property name="title" translatable="yes">Warning from
NetSurf</property>
- <property name="window_position">GTK_WIN_POS_CENTER</property>
- <property name="icon_name">gtk-dialog-warning</property>
- <property
name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="urgency_hint">True</property>
<child>
- <widget class="GtkVBox" id="vbox32">
+ <widget class="GtkMenuItem" id="menupopup_view">
<property name="visible">True</property>
- <property name="border_width">2</property>
- <child>
- <widget class="GtkHBox" id="hbox30">
- <property name="visible">True</property>
- <property name="border_width">3</property>
- <child>
- <widget class="GtkImage" id="image519">
- <property name="visible">True</property>
- <property name="xpad">12</property>
- <property name="icon_size">6</property>
- <property
name="icon_name">gtk-dialog-warning</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="labelWarning">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Help
help help! I'm being held prisoner by a bunch of RISC OS zealots!</property>
- <property name="wrap">True</property>
- </widget>
- <packing>
- <property name="padding">1</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkHSeparator" id="hseparator2">
- <property name="visible">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="padding">3</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHButtonBox" id="hbuttonbox2">
- <property name="visible">True</property>
- <property
name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <widget class="GtkButton" id="button14">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="response_id">0</property>
- <signal name="clicked" handler="gtk_widget_hide"
object="wndWarning"/>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
+ <property name="label"
translatable="yes">View</property>
+ <property name="use_underline">True</property>
</widget>
</child>
- </widget>
- <widget class="GtkMenu" id="menuPopup">
<child>
+ <widget class="GtkMenuItem" id="menupopup_nav">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Navigate</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkMenuItem" id="menupopup_tabs">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Tabs</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkMenuItem" id="menupopup_help">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Help</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkSeparatorMenuItem" id="menupopup_sep">
+ <property name="visible">True</property>
+ </widget>
+ </child>
+ <child>
<widget class="GtkMenuItem"
id="open_link_in_focused_tab_popup">
<property name="visible">True</property>
<property name="label" translatable="yes">Open Link in
_New Tab</property>
@@ -1422,12 +296,12 @@
</widget>
</child>
<child>
- <widget class="GtkSeparatorMenuItem" id="separator1">
+ <widget class="GtkSeparatorMenuItem" id="sep2">
<property name="visible">True</property>
</widget>
</child>
<child>
- <widget class="GtkImageMenuItem" id="popupBack">
+ <widget class="GtkImageMenuItem" id="back_popup">
<property name="visible">True</property>
<property name="label"
translatable="yes">_Back</property>
<property name="use_underline">True</property>
@@ -1441,7 +315,7 @@
</widget>
</child>
<child>
- <widget class="GtkImageMenuItem" id="popupForward">
+ <widget class="GtkImageMenuItem" id="forward_popup">
<property name="visible">True</property>
<property name="label"
translatable="yes">_Forward</property>
<property name="use_underline">True</property>
@@ -1455,12 +329,12 @@
</widget>
</child>
<child>
- <widget class="GtkSeparatorMenuItem" id="separator">
+ <widget class="GtkSeparatorMenuItem" id="sep">
<property name="visible">True</property>
</widget>
</child>
<child>
- <widget class="GtkImageMenuItem" id="popupReload">
+ <widget class="GtkImageMenuItem" id="reload_popup">
<property name="visible">True</property>
<property name="label"
translatable="yes">_Reload</property>
<property name="use_underline">True</property>
@@ -1530,316 +404,11 @@
</widget>
</child>
<child>
- <widget class="GtkMenuItem" id="menupopup_file">
+ <widget class="GtkMenuItem" id="customize_popup">
<property name="visible">True</property>
- <property name="label"
translatable="yes">File</property>
+ <property name="label"
translatable="yes">Customize..</property>
<property name="use_underline">True</property>
</widget>
</child>
- <child>
- <widget class="GtkMenuItem" id="menupopup_edit">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">Edit</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="menupopup_view">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">View</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="menupopup_navigate">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">Navigate</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="menupopup_object">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="label"
translatable="yes">Object</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="menupopup_help">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">Help</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
</widget>
- <widget class="GtkWindow" id="wndPDFPassword">
- <property name="title" translatable="yes">PDF
Password</property>
- <property name="modal">True</property>
- <property name="window_position">GTK_WIN_POS_CENTER</property>
- <child>
- <widget class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <child>
- <widget class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="yalign">0.10000000149011612</property>
- <property name="xpad">12</property>
- <property name="icon_size">6</property>
- <property
name="icon_name">gtk-dialog-authentication</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkVBox" id="vbox1">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <child>
- <widget class="GtkLabel" id="labelInfo">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Write
and confirm passwords:</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <child>
- <widget class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">Owner password:</property>
- <property name="width_chars">15</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkEntry"
id="entryPDFOwnerPassword">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">20</property>
- <property name="visibility">False</property>
- <property name="width_chars">20</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox3">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <child>
- <widget class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">Repeat password:</property>
- <property name="width_chars">15</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkEntry"
id="entryPDFOwnerPassword1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">20</property>
- <property name="visibility">False</property>
- <property name="width_chars">20</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox4">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <child>
- <widget class="GtkLabel" id="label6">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">User password:</property>
- <property name="width_chars">15</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkEntry"
id="entryPDFUserPassword">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">20</property>
- <property name="visibility">False</property>
- <property name="width_chars">20</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox5">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <child>
- <widget class="GtkLabel" id="label7">
- <property name="visible">True</property>
- <property name="label"
translatable="yes">Repeat password:</property>
- <property name="width_chars">15</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkEntry"
id="entryPDFUserPassword1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">20</property>
- <property name="visibility">False</property>
- <property name="width_chars">20</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHButtonBox" id="hbuttonbox1">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <property name="spacing">10</property>
- <property
name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <widget class="GtkButton"
id="buttonPDFSetPassword">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="response_id">0</property>
- <child>
- <widget class="GtkHBox" id="hbox7">
- <property name="visible">True</property>
- <child>
- <widget class="GtkImage"
id="image7">
- <property
name="visible">True</property>
- <property
name="stock">gtk-ok</property>
- </widget>
- <packing>
- <property
name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label8">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">Set password</property>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkButton"
id="buttonPDFNoPassword">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="response_id">0</property>
- <child>
- <widget class="GtkAlignment"
id="alignment1">
- <property name="visible">True</property>
- <child>
- <widget class="GtkHBox" id="hbox6">
- <property
name="visible">True</property>
- <child>
- <widget class="GtkImage"
id="image8">
- <property
name="visible">True</property>
- <property
name="stock">gtk-cancel</property>
- </widget>
- <packing>
- <property
name="expand">False</property>
- <property
name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label9">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">No password</property>
- </widget>
- <packing>
- <property
name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">5</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
</glade-interface>
Index: gtk/res/options.glade
===================================================================
--- gtk/res/options.glade (revision 8438)
+++ gtk/res/options.glade (working copy)
@@ -298,7 +298,7 @@
<property
name="visible">True</property>
<property
name="can_focus">True</property>
<property name="tooltip"
translatable="yes">Visited pages are kept in memory for this many
days</property>
- <property name="adjustment">14 0 100
1 10 10</property>
+ <property name="adjustment">14 0 100
1 10 0</property>
<property
name="climb_rate">1</property>
</widget>
<packing>
@@ -471,67 +471,30 @@
<property
name="column_spacing">3</property>
<property
name="row_spacing">3</property>
<child>
- <widget class="GtkEntry"
id="entryProxyPassword">
+ <widget class="GtkEntry"
id="entryProxyUser">
<property
name="visible">True</property>
<property
name="can_focus">True</property>
- <property name="tooltip"
translatable="yes">If your proxy server requires authentication, enter your
password here.</property>
- <property
name="visibility">False</property>
+ <property name="tooltip"
translatable="yes">If your proxy server requires authentication, enter your
username here.</property>
</widget>
<packing>
<property
name="left_attach">1</property>
<property
name="right_attach">2</property>
- <property
name="top_attach">3</property>
- <property
name="bottom_attach">4</property>
- <property
name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label76">
- <property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Proxy type</property>
- </widget>
- <packing>
- <property
name="x_options"></property>
- <property
name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label75">
- <property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Host</property>
- </widget>
- <packing>
- <property
name="top_attach">1</property>
- <property
name="bottom_attach">2</property>
- <property
name="x_options"></property>
- <property
name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label74">
- <property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Username</property>
- </widget>
- <packing>
<property
name="top_attach">2</property>
<property
name="bottom_attach">3</property>
- <property
name="x_options"></property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label73">
+ <widget class="GtkComboBox"
id="comboProxyType">
<property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Password</property>
+ <property name="items"
translatable="yes">No proxy
+Simple proxy
+Basic authentication
+NTLM authentication</property>
</widget>
<packing>
- <property
name="top_attach">3</property>
- <property
name="bottom_attach">4</property>
- <property
name="x_options"></property>
+ <property
name="left_attach">1</property>
+ <property
name="right_attach">2</property>
<property
name="y_options"></property>
</packing>
</child>
@@ -578,30 +541,67 @@
</packing>
</child>
<child>
- <widget class="GtkComboBox"
id="comboProxyType">
+ <widget class="GtkLabel"
id="label73">
<property
name="visible">True</property>
- <property name="items"
translatable="yes">No proxy
-Simple proxy
-Basic authentication
-NTLM authentication</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Password</property>
</widget>
<packing>
- <property
name="left_attach">1</property>
- <property
name="right_attach">2</property>
+ <property
name="top_attach">3</property>
+ <property
name="bottom_attach">4</property>
+ <property
name="x_options"></property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkEntry"
id="entryProxyUser">
+ <widget class="GtkLabel"
id="label74">
<property
name="visible">True</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Username</property>
+ </widget>
+ <packing>
+ <property
name="top_attach">2</property>
+ <property
name="bottom_attach">3</property>
+ <property
name="x_options"></property>
+ <property
name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label75">
+ <property
name="visible">True</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Host</property>
+ </widget>
+ <packing>
+ <property
name="top_attach">1</property>
+ <property
name="bottom_attach">2</property>
+ <property
name="x_options"></property>
+ <property
name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label76">
+ <property
name="visible">True</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Proxy type</property>
+ </widget>
+ <packing>
+ <property
name="x_options"></property>
+ <property
name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry"
id="entryProxyPassword">
+ <property
name="visible">True</property>
<property
name="can_focus">True</property>
- <property name="tooltip"
translatable="yes">If your proxy server requires authentication, enter your
username here.</property>
+ <property name="tooltip"
translatable="yes">If your proxy server requires authentication, enter your
password here.</property>
+ <property
name="visibility">False</property>
</widget>
<packing>
<property
name="left_attach">1</property>
<property
name="right_attach">2</property>
- <property
name="top_attach">2</property>
- <property
name="bottom_attach">3</property>
+ <property
name="top_attach">3</property>
+ <property
name="bottom_attach">4</property>
<property
name="y_options"></property>
</packing>
</child>
@@ -643,82 +643,82 @@
<property
name="column_spacing">3</property>
<property
name="row_spacing">3</property>
<child>
- <widget class="GtkSpinButton"
id="spinMaxFetchers">
+ <widget class="GtkLabel"
id="label78">
<property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property name="tooltip"
translatable="yes">Maximum number of concurrent items to fetch at
once.</property>
- <property name="adjustment">1 0 100 1 10
10</property>
- <property
name="climb_rate">1</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Maximum fetchers</property>
</widget>
<packing>
- <property
name="left_attach">1</property>
- <property
name="right_attach">2</property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkSpinButton"
id="spinFetchesPerHost">
+ <widget class="GtkLabel"
id="label79">
<property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property name="tooltip"
translatable="yes">Maximum number of item fetches per web
server.</property>
- <property name="adjustment">1 0 100 1 10
10</property>
- <property
name="climb_rate">1</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Fetches per host</property>
</widget>
<packing>
- <property
name="left_attach">1</property>
- <property
name="right_attach">2</property>
<property
name="top_attach">1</property>
<property
name="bottom_attach">2</property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkSpinButton"
id="spinCachedConnections">
+ <widget class="GtkLabel"
id="label80">
<property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property name="tooltip"
translatable="yes">Number of connections to keep incase they are needed
again.</property>
- <property name="adjustment">1 0 100 1 10
10</property>
- <property
name="climb_rate">1</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Cached connections</property>
</widget>
<packing>
- <property
name="left_attach">1</property>
- <property
name="right_attach">2</property>
<property
name="top_attach">2</property>
<property
name="bottom_attach">3</property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label80">
+ <widget class="GtkSpinButton"
id="spinCachedConnections">
<property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Cached connections</property>
+ <property
name="can_focus">True</property>
+ <property name="tooltip"
translatable="yes">Number of connections to keep incase they are needed
again.</property>
+ <property name="adjustment">1 0 100 1 10
0</property>
+ <property
name="climb_rate">1</property>
</widget>
<packing>
+ <property
name="left_attach">1</property>
+ <property
name="right_attach">2</property>
<property
name="top_attach">2</property>
<property
name="bottom_attach">3</property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label79">
+ <widget class="GtkSpinButton"
id="spinFetchesPerHost">
<property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Fetches per host</property>
+ <property
name="can_focus">True</property>
+ <property name="tooltip"
translatable="yes">Maximum number of item fetches per web
server.</property>
+ <property name="adjustment">1 0 100 1 10
0</property>
+ <property
name="climb_rate">1</property>
</widget>
<packing>
+ <property
name="left_attach">1</property>
+ <property
name="right_attach">2</property>
<property
name="top_attach">1</property>
<property
name="bottom_attach">2</property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label78">
+ <widget class="GtkSpinButton"
id="spinMaxFetchers">
<property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Maximum fetchers</property>
+ <property
name="can_focus">True</property>
+ <property name="tooltip"
translatable="yes">Maximum number of concurrent items to fetch at
once.</property>
+ <property name="adjustment">1 0 100 1 10
0</property>
+ <property
name="climb_rate">1</property>
</widget>
<packing>
+ <property
name="left_attach">1</property>
+ <property
name="right_attach">2</property>
<property
name="y_options"></property>
</packing>
</child>
@@ -837,7 +837,7 @@
<property
name="visible">True</property>
<property
name="can_focus">True</property>
<property name="tooltip"
translatable="yes">Do not update animations any more often than
this.</property>
- <property name="adjustment">0 0 100
0.10000000149 1 1</property>
+ <property name="adjustment">0 0 100
0.10000000149 1 0</property>
<property
name="climb_rate">1</property>
<property
name="digits">1</property>
<property
name="numeric">True</property>
@@ -934,57 +934,84 @@
<property
name="column_spacing">3</property>
<property
name="row_spacing">3</property>
<child>
- <widget class="GtkFontButton"
id="fontSansSerif">
+ <widget class="GtkLabel"
id="label88">
<property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property
name="response_id">0</property>
- <property
name="show_style">False</property>
- <property
name="show_size">False</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Sans-serif</property>
</widget>
<packing>
- <property
name="left_attach">1</property>
- <property
name="right_attach">2</property>
+ <property
name="x_options"></property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkComboBox"
id="comboDefault">
+ <widget class="GtkLabel"
id="label89">
<property
name="visible">True</property>
- <property name="items"
translatable="yes">Sans-serif
-Serif
-Monospace
-Cursive
-Fantasy</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Serif</property>
</widget>
<packing>
- <property
name="left_attach">1</property>
- <property
name="right_attach">2</property>
- <property
name="top_attach">5</property>
- <property
name="bottom_attach">6</property>
- <property
name="x_options">GTK_FILL</property>
+ <property
name="top_attach">1</property>
+ <property
name="bottom_attach">2</property>
+ <property
name="x_options"></property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkFontButton"
id="fontFantasy">
+ <widget class="GtkLabel"
id="label90">
<property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property
name="response_id">0</property>
- <property
name="show_style">False</property>
- <property
name="show_size">False</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Monospace</property>
</widget>
<packing>
- <property
name="left_attach">1</property>
- <property
name="right_attach">2</property>
+ <property
name="top_attach">2</property>
+ <property
name="bottom_attach">3</property>
+ <property
name="x_options"></property>
+ <property
name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label91">
+ <property
name="visible">True</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Cursive</property>
+ </widget>
+ <packing>
+ <property
name="top_attach">3</property>
+ <property
name="bottom_attach">4</property>
+ <property
name="x_options"></property>
+ <property
name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label92">
+ <property
name="visible">True</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Fantasy</property>
+ </widget>
+ <packing>
<property
name="top_attach">4</property>
<property
name="bottom_attach">5</property>
- <property
name="x_options">GTK_FILL</property>
+ <property
name="x_options"></property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkFontButton"
id="fontCursive">
+ <widget class="GtkLabel"
id="label93">
<property
name="visible">True</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Default</property>
+ </widget>
+ <packing>
+ <property
name="top_attach">5</property>
+ <property
name="bottom_attach">6</property>
+ <property
name="x_options"></property>
+ <property
name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkFontButton"
id="fontSerif">
+ <property
name="visible">True</property>
<property
name="can_focus">True</property>
<property
name="response_id">0</property>
<property
name="show_style">False</property>
@@ -993,8 +1020,8 @@
<packing>
<property
name="left_attach">1</property>
<property
name="right_attach">2</property>
- <property
name="top_attach">3</property>
- <property
name="bottom_attach">4</property>
+ <property
name="top_attach">1</property>
+ <property
name="bottom_attach">2</property>
<property
name="x_options">GTK_FILL</property>
<property
name="y_options"></property>
</packing>
@@ -1017,7 +1044,7 @@
</packing>
</child>
<child>
- <widget class="GtkFontButton"
id="fontSerif">
+ <widget class="GtkFontButton"
id="fontCursive">
<property
name="visible">True</property>
<property
name="can_focus">True</property>
<property
name="response_id">0</property>
@@ -1027,88 +1054,61 @@
<packing>
<property
name="left_attach">1</property>
<property
name="right_attach">2</property>
- <property
name="top_attach">1</property>
- <property
name="bottom_attach">2</property>
+ <property
name="top_attach">3</property>
+ <property
name="bottom_attach">4</property>
<property
name="x_options">GTK_FILL</property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label93">
+ <widget class="GtkFontButton"
id="fontFantasy">
<property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Default</property>
+ <property
name="can_focus">True</property>
+ <property
name="response_id">0</property>
+ <property
name="show_style">False</property>
+ <property
name="show_size">False</property>
</widget>
<packing>
- <property
name="top_attach">5</property>
- <property
name="bottom_attach">6</property>
- <property
name="x_options"></property>
- <property
name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label92">
- <property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Fantasy</property>
- </widget>
- <packing>
+ <property
name="left_attach">1</property>
+ <property
name="right_attach">2</property>
<property
name="top_attach">4</property>
<property
name="bottom_attach">5</property>
- <property
name="x_options"></property>
+ <property
name="x_options">GTK_FILL</property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label91">
+ <widget class="GtkComboBox"
id="comboDefault">
<property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Cursive</property>
+ <property name="items"
translatable="yes">Sans-serif
+Serif
+Monospace
+Cursive
+Fantasy</property>
</widget>
<packing>
- <property
name="top_attach">3</property>
- <property
name="bottom_attach">4</property>
- <property
name="x_options"></property>
+ <property
name="left_attach">1</property>
+ <property
name="right_attach">2</property>
+ <property
name="top_attach">5</property>
+ <property
name="bottom_attach">6</property>
+ <property
name="x_options">GTK_FILL</property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label90">
+ <widget class="GtkFontButton"
id="fontSansSerif">
<property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Monospace</property>
+ <property
name="can_focus">True</property>
+ <property
name="response_id">0</property>
+ <property
name="show_style">False</property>
+ <property
name="show_size">False</property>
</widget>
<packing>
- <property
name="top_attach">2</property>
- <property
name="bottom_attach">3</property>
- <property
name="x_options"></property>
+ <property
name="left_attach">1</property>
+ <property
name="right_attach">2</property>
<property
name="y_options"></property>
</packing>
</child>
- <child>
- <widget class="GtkLabel"
id="label89">
- <property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Serif</property>
- </widget>
- <packing>
- <property
name="top_attach">1</property>
- <property
name="bottom_attach">2</property>
- <property
name="x_options"></property>
- <property
name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label88">
- <property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Sans-serif</property>
- </widget>
- <packing>
- <property
name="x_options"></property>
- <property
name="y_options"></property>
- </packing>
- </child>
</widget>
</child>
</widget>
@@ -1146,42 +1146,61 @@
<property
name="column_spacing">3</property>
<property
name="row_spacing">3</property>
<child>
- <widget class="GtkLabel"
id="label98">
+ <widget class="GtkButton"
id="fontPreview">
<property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">pt</property>
+ <property
name="can_focus">True</property>
+ <property name="tooltip"
translatable="yes">View the changes in the browser window
immediately.</property>
+ <property
name="response_id">0</property>
+ <child>
+ <widget class="GtkHBox"
id="hbox3">
+ <property
name="visible">True</property>
+ <property
name="border_width">2</property>
+ <child>
+ <widget class="GtkImage"
id="image1">
+ <property
name="visible">True</property>
+ <property
name="stock">gtk-apply</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label1">
+ <property
name="visible">True</property>
+ <property name="label"
translatable="yes">_Preview</property>
+ <property
name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property
name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
</widget>
<packing>
- <property
name="left_attach">2</property>
- <property
name="right_attach">3</property>
- <property
name="top_attach">1</property>
+ <property
name="left_attach">3</property>
+ <property
name="right_attach">4</property>
<property
name="bottom_attach">2</property>
+ <property
name="x_options"></property>
<property
name="y_options"></property>
+ <property
name="x_padding">2</property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label97">
+ <widget class="GtkLabel"
id="label95">
<property
name="visible">True</property>
<property
name="xalign">0</property>
- <property name="label"
translatable="yes">pt</property>
+ <property name="label"
translatable="yes">Default</property>
</widget>
<packing>
- <property
name="left_attach">2</property>
- <property
name="right_attach">3</property>
+ <property
name="x_options"></property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkSpinButton"
id="spinMinimumSize">
+ <widget class="GtkLabel"
id="label96">
<property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property name="tooltip"
translatable="yes">Do not allow text to be displayed any smaller than
this.</property>
- <property name="adjustment">1 0 100 1 10
10</property>
- <property
name="climb_rate">1</property>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">Minimum</property>
</widget>
<packing>
- <property
name="left_attach">1</property>
- <property
name="right_attach">2</property>
<property
name="top_attach">1</property>
<property
name="bottom_attach">2</property>
<property
name="x_options"></property>
@@ -1193,7 +1212,7 @@
<property
name="visible">True</property>
<property
name="can_focus">True</property>
<property name="tooltip"
translatable="yes">The base-line font size to use.</property>
- <property name="adjustment">1 0 100 1 10
10</property>
+ <property name="adjustment">1 0 100 1 10
0</property>
<property
name="climb_rate">1</property>
</widget>
<packing>
@@ -1204,12 +1223,16 @@
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label96">
+ <widget class="GtkSpinButton"
id="spinMinimumSize">
<property
name="visible">True</property>
- <property
name="xalign">0</property>
- <property name="label"
translatable="yes">Minimum</property>
+ <property
name="can_focus">True</property>
+ <property name="tooltip"
translatable="yes">Do not allow text to be displayed any smaller than
this.</property>
+ <property name="adjustment">1 0 100 1 10
0</property>
+ <property
name="climb_rate">1</property>
</widget>
<packing>
+ <property
name="left_attach">1</property>
+ <property
name="right_attach">2</property>
<property
name="top_attach">1</property>
<property
name="bottom_attach">2</property>
<property
name="x_options"></property>
@@ -1217,52 +1240,29 @@
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label95">
+ <widget class="GtkLabel"
id="label97">
<property
name="visible">True</property>
<property
name="xalign">0</property>
- <property name="label"
translatable="yes">Default</property>
+ <property name="label"
translatable="yes">pt</property>
</widget>
<packing>
- <property
name="x_options"></property>
+ <property
name="left_attach">2</property>
+ <property
name="right_attach">3</property>
<property
name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkButton"
id="fontPreview">
+ <widget class="GtkLabel"
id="label98">
<property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property name="tooltip"
translatable="yes">View the changes in the browser window
immediately.</property>
- <property
name="response_id">0</property>
- <child>
- <widget class="GtkHBox"
id="hbox3">
- <property
name="visible">True</property>
- <property
name="border_width">2</property>
- <child>
- <widget class="GtkImage"
id="image1">
- <property
name="visible">True</property>
- <property
name="stock">gtk-apply</property>
- </widget>
- </child>
- <child>
- <widget class="GtkLabel"
id="label1">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">_Preview</property>
- <property
name="use_underline">True</property>
- </widget>
- <packing>
- <property
name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
+ <property
name="xalign">0</property>
+ <property name="label"
translatable="yes">pt</property>
</widget>
<packing>
- <property
name="left_attach">3</property>
- <property
name="right_attach">4</property>
+ <property
name="left_attach">2</property>
+ <property
name="right_attach">3</property>
+ <property
name="top_attach">1</property>
<property
name="bottom_attach">2</property>
- <property
name="x_options"></property>
<property
name="y_options"></property>
- <property
name="x_padding">2</property>
</packing>
</child>
</widget>
@@ -1301,16 +1301,6 @@
<property
name="column_spacing">10</property>
<property
name="row_spacing">3</property>
<child>
- <widget class="GtkLabel"
id="label19">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">Toolbar buttons</property>
- <property
name="justify">GTK_JUSTIFY_RIGHT</property>
- </widget>
- <packing>
- <property
name="x_options"></property>
- </packing>
- </child>
- <child>
<widget class="GtkComboBox"
id="comboButtonType">
<property
name="visible">True</property>
<property name="items"
translatable="yes">Small icons
@@ -1325,6 +1315,16 @@
<property
name="y_options"></property>
</packing>
</child>
+ <child>
+ <widget class="GtkLabel"
id="label19">
+ <property
name="visible">True</property>
+ <property name="label"
translatable="yes">Toolbar buttons</property>
+ <property
name="justify">GTK_JUSTIFY_RIGHT</property>
+ </widget>
+ <packing>
+ <property
name="x_options"></property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
@@ -1394,7 +1394,7 @@
<property
name="visible">True</property>
<property
name="can_focus">True</property>
<property name="tooltip"
translatable="yes">How much memory to use for caching recently viewed objects
in memory.</property>
- <property name="adjustment">1 0 100 1 10
10</property>
+ <property name="adjustment">1 0 100 1 10
0</property>
<property
name="climb_rate">1</property>
</widget>
<packing>
@@ -1467,7 +1467,7 @@
<property
name="visible">True</property>
<property
name="can_focus">True</property>
<property name="tooltip"
translatable="yes">How long to keep cached items around on
disc.</property>
- <property name="adjustment">1 0 100 1
10 10</property>
+ <property name="adjustment">1 0 100 1
10 0</property>
<property
name="climb_rate">1</property>
</widget>
<packing>
@@ -1742,8 +1742,200 @@
</packing>
</child>
<child>
- <placeholder/>
+ <widget class="GtkFrame" id="frame10">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property
name="shadow_type">GTK_SHADOW_NONE</property>
+ <child>
+ <widget class="GtkAlignment"
id="alignment10">
+ <property name="visible">True</property>
+ <property
name="left_padding">12</property>
+ <child>
+ <widget class="GtkHBox" id="hbox11">
+ <property
name="visible">True</property>
+ <child>
+ <widget class="GtkRadioButton"
id="sourceButtonWindow">
+ <property
name="visible">True</property>
+ <property
name="can_focus">True</property>
+ <property name="label"
translatable="yes">in own window </property>
+ <property
name="response_id">0</property>
+ <property
name="active">True</property>
+ <property
name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton"
id="sourceButtonTab">
+ <property
name="visible">True</property>
+ <property
name="can_focus">True</property>
+ <property name="label"
translatable="yes">in new tab</property>
+ <property
name="response_id">0</property>
+ <property
name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">False</property>
+ <property
name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label24">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes"><b>View
Source</b></property>
+ <property
name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property
name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
</child>
+ <child>
+ <widget class="GtkFrame" id="frame9">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property
name="shadow_type">GTK_SHADOW_NONE</property>
+ <child>
+ <widget class="GtkAlignment"
id="alignment9">
+ <property name="visible">True</property>
+ <property
name="left_padding">12</property>
+ <child>
+ <widget class="GtkHBox" id="hbox9">
+ <property
name="visible">True</property>
+ <child>
+ <widget class="GtkCheckButton"
id="checkUrlSearch">
+ <property
name="visible">True</property>
+ <property
name="can_focus">True</property>
+ <property name="label"
translatable="yes">search from url bar </property>
+ <property
name="response_id">0</property>
+ <property
name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel"
id="label23">
+ <property
name="visible">True</property>
+ <property name="label"
translatable="yes"> default provider</property>
+ <property
name="justify">GTK_JUSTIFY_RIGHT</property>
+ </widget>
+ <packing>
+ <property
name="fill">False</property>
+ <property
name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox"
id="comboSearch">
+ <property
name="visible">True</property>
+ <property name="items"
translatable="yes">Google
+Yahoo!
+Microsoft live
+Business.com
+Omgili
+BBC News
+Ubuntu packages
+Creative commons
+Ask
+Answers
+Dictionary.com
+Youtube
+AeroMp3
+AOL
+Baidu
+Amazon
+Ebay
+IMDB
+Espn
+Wikipedia</property>
+ </widget>
+ <packing>
+ <property
name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label22">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes"><b>Search</b></property>
+ <property
name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property
name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkFrame" id="frame11">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property
name="shadow_type">GTK_SHADOW_NONE</property>
+ <child>
+ <widget class="GtkAlignment"
id="alignment11">
+ <property name="visible">True</property>
+ <property
name="left_padding">12</property>
+ <child>
+ <widget class="GtkHBox"
id="themehbox">
+ <property
name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <widget class="GtkButton"
id="buttonaddtheme">
+ <property
name="visible">True</property>
+ <property
name="can_focus">True</property>
+ <property
name="receives_default">True</property>
+ <property name="label"
translatable="yes">add theme..</property>
+ <property
name="response_id">0</property>
+ </widget>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">False</property>
+ <property
name="pack_type">GTK_PACK_END</property>
+ <property
name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label25">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes"><b>Select
themes</b></property>
+ <property
name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property
name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="position">5</property>
@@ -1785,32 +1977,25 @@
<property
name="column_spacing">4</property>
<property
name="row_spacing">5</property>
<child>
- <widget class="GtkLabel"
id="label5">
+ <widget class="GtkLabel"
id="label10">
<property
name="visible">True</property>
- <property name="label"
translatable="yes">Top:</property>
+ <property name="label"
translatable="yes">mm</property>
</widget>
- </child>
- <child>
- <widget class="GtkLabel"
id="label6">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">Bottom:</property>
- </widget>
<packing>
+ <property
name="left_attach">2</property>
+ <property
name="right_attach">3</property>
<property
name="top_attach">1</property>
<property
name="bottom_attach">2</property>
</packing>
</child>
<child>
- <widget class="GtkSpinButton"
id="spinMarginTop">
+ <widget class="GtkLabel"
id="label9">
<property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property name="tooltip"
translatable="yes">Set the top margin</property>
- <property name="adjustment">0 0 100 1
10 10</property>
- <property
name="climb_rate">1</property>
+ <property name="label"
translatable="yes">mm</property>
</widget>
<packing>
- <property
name="left_attach">1</property>
- <property
name="right_attach">2</property>
+ <property
name="left_attach">2</property>
+ <property
name="right_attach">3</property>
</packing>
</child>
<child>
@@ -1818,7 +2003,7 @@
<property
name="visible">True</property>
<property
name="can_focus">True</property>
<property name="tooltip"
translatable="yes">Set the bottom margin</property>
- <property name="adjustment">0 0 100 1
10 10</property>
+ <property name="adjustment">0 0 100 1
10 0</property>
<property
name="climb_rate">1</property>
</widget>
<packing>
@@ -1829,27 +2014,34 @@
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label9">
+ <widget class="GtkSpinButton"
id="spinMarginTop">
<property
name="visible">True</property>
- <property name="label"
translatable="yes">mm</property>
+ <property
name="can_focus">True</property>
+ <property name="tooltip"
translatable="yes">Set the top margin</property>
+ <property name="adjustment">0 0 100 1
10 0</property>
+ <property
name="climb_rate">1</property>
</widget>
<packing>
- <property
name="left_attach">2</property>
- <property
name="right_attach">3</property>
+ <property
name="left_attach">1</property>
+ <property
name="right_attach">2</property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label10">
+ <widget class="GtkLabel"
id="label6">
<property
name="visible">True</property>
- <property name="label"
translatable="yes">mm</property>
+ <property name="label"
translatable="yes">Bottom:</property>
</widget>
<packing>
- <property
name="left_attach">2</property>
- <property
name="right_attach">3</property>
<property
name="top_attach">1</property>
<property
name="bottom_attach">2</property>
</packing>
</child>
+ <child>
+ <widget class="GtkLabel"
id="label5">
+ <property
name="visible">True</property>
+ <property name="label"
translatable="yes">Top:</property>
+ </widget>
+ </child>
</widget>
<packing>
<property
name="expand">False</property>
@@ -1864,32 +2056,25 @@
<property
name="column_spacing">4</property>
<property
name="row_spacing">5</property>
<child>
- <widget class="GtkLabel"
id="label7">
+ <widget class="GtkLabel"
id="label12">
<property
name="visible">True</property>
- <property name="label"
translatable="yes">Left:</property>
+ <property name="label"
translatable="yes">mm</property>
</widget>
- </child>
- <child>
- <widget class="GtkLabel"
id="label8">
- <property
name="visible">True</property>
- <property name="label"
translatable="yes">Right:</property>
- </widget>
<packing>
+ <property
name="left_attach">2</property>
+ <property
name="right_attach">3</property>
<property
name="top_attach">1</property>
<property
name="bottom_attach">2</property>
</packing>
</child>
<child>
- <widget class="GtkSpinButton"
id="spinMarginLeft">
+ <widget class="GtkLabel"
id="label11">
<property
name="visible">True</property>
- <property
name="can_focus">True</property>
- <property name="tooltip"
translatable="yes">Set the left margin</property>
- <property name="adjustment">0 0 100 1
10 10</property>
- <property
name="climb_rate">1</property>
+ <property name="label"
translatable="yes">mm</property>
</widget>
<packing>
- <property
name="left_attach">1</property>
- <property
name="right_attach">2</property>
+ <property
name="left_attach">2</property>
+ <property
name="right_attach">3</property>
</packing>
</child>
<child>
@@ -1897,7 +2082,7 @@
<property
name="visible">True</property>
<property
name="can_focus">True</property>
<property name="tooltip"
translatable="yes">Set the right margin</property>
- <property name="adjustment">0 0 100 1
10 10</property>
+ <property name="adjustment">0 0 100 1
10 0</property>
<property
name="climb_rate">1</property>
</widget>
<packing>
@@ -1908,27 +2093,34 @@
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label11">
+ <widget class="GtkSpinButton"
id="spinMarginLeft">
<property
name="visible">True</property>
- <property name="label"
translatable="yes">mm</property>
+ <property
name="can_focus">True</property>
+ <property name="tooltip"
translatable="yes">Set the left margin</property>
+ <property name="adjustment">0 0 100 1
10 0</property>
+ <property
name="climb_rate">1</property>
</widget>
<packing>
- <property
name="left_attach">2</property>
- <property
name="right_attach">3</property>
+ <property
name="left_attach">1</property>
+ <property
name="right_attach">2</property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label12">
+ <widget class="GtkLabel"
id="label8">
<property
name="visible">True</property>
- <property name="label"
translatable="yes">mm</property>
+ <property name="label"
translatable="yes">Right:</property>
</widget>
<packing>
- <property
name="left_attach">2</property>
- <property
name="right_attach">3</property>
<property
name="top_attach">1</property>
<property
name="bottom_attach">2</property>
</packing>
</child>
+ <child>
+ <widget class="GtkLabel"
id="label7">
+ <property
name="visible">True</property>
+ <property name="label"
translatable="yes">Left:</property>
+ </widget>
+ </child>
</widget>
<packing>
<property
name="expand">False</property>
@@ -1983,7 +2175,7 @@
<property
name="visible">True</property>
<property
name="can_focus">True</property>
<property name="tooltip"
translatable="yes">Set the scaling for the document - this way more content
can fit in a page</property>
- <property name="adjustment">0 0 1000 1 10
10</property>
+ <property name="adjustment">0 0 1000 1 10
0</property>
<property
name="climb_rate">1</property>
</widget>
<packing>
Index: gtk/gtk_login.c
===================================================================
--- gtk/gtk_login.c (revision 8438)
+++ gtk/gtk_login.c (working copy)
@@ -74,7 +74,7 @@
* the widgets we're interested in.
*/
- GladeXML *x = glade_xml_new(glade_file_location, NULL, NULL);
+ GladeXML *x = glade_xml_new(glade_login_file_location, NULL, NULL);
GtkWindow *wnd = GTK_WINDOW(glade_xml_get_widget(x, "wndLogin"));
GtkLabel *lhost, *lrealm;
GtkEntry *euser, *epass;
Index: gtk/gtk_gui.c
===================================================================
--- gtk/gtk_gui.c (revision 8438)
+++ gtk/gtk_gui.c (working copy)
@@ -67,15 +67,27 @@
char *default_stylesheet_url;
char *adblock_stylesheet_url;
char *options_file_location;
-char *glade_file_location;
+char *glade_netsurf_file_location;
+char *glade_password_file_location;
+char *glade_warning_file_location;
+char *glade_login_file_location;
+char *glade_ssl_file_location;
+char *glade_toolbar_file_location;
+char *toolbar_indices_file_location;
char *res_dir_location;
char *print_options_file_location;
+char *search_engines_file_location;
+char *search_default_ico_location;
-struct gui_window *search_current_window = 0;
+/* struct gui_window *search_current_window = 0; */
GtkWindow *wndAbout;
GtkWindow *wndWarning;
-GladeXML *gladeWindows;
+GladeXML *gladeNetsurf;
+GladeXML *gladePassword;
+GladeXML *gladeWarning;
+GladeXML *gladeLogin;
+GladeXML *gladeSsl;
GtkWindow *wndTooltip;
GtkLabel *labelTooltip;
@@ -194,12 +206,28 @@
check_homedir();
find_resource(buf, "netsurf.glade", "./gtk/res/netsurf.glade");
- LOG(("Using '%s' as Glade template file", buf));
- glade_file_location = strdup(buf);
+ LOG(("Using '%s' as Netsurf glade template file", buf));
+ glade_netsurf_file_location = strdup(buf);
buf[strlen(buf)- 13] = 0;
LOG(("Using '%s' as Resources directory", buf));
res_dir_location = strdup(buf);
+
+ find_resource(buf, "password.glade", "./gtk/res/password.glade");
+ LOG(("Using '%s' as password glade template file", buf));
+ glade_password_file_location = strdup(buf);
+
+ find_resource(buf, "warning.glade", "./gtk/res/warning.glade");
+ LOG(("Using '%s' as warning glade template file", buf));
+ glade_warning_file_location = strdup(buf);
+
+ find_resource(buf, "login.glade", "./gtk/res/login.glade");
+ LOG(("Using '%s' as login glade template file", buf));
+ glade_login_file_location = strdup(buf);
+
+ find_resource(buf, "ssl.glade", "./gtk/res/ssl.glade");
+ LOG(("Using '%s' as ssl glade template file", buf));
+ glade_ssl_file_location = strdup(buf);
find_resource(buf, "Aliases", "./gtk/res/Aliases");
LOG(("Using '%s' as Aliases file", buf));
@@ -207,17 +235,42 @@
die("Unable to initialise HTML parsing library.\n");
glade_init();
- gladeWindows = glade_xml_new(glade_file_location, NULL, NULL);
- if (gladeWindows == NULL)
- die("Unable to load Glade window definitions.\n");
- glade_xml_signal_autoconnect(gladeWindows);
+ gladeWarning = glade_xml_new(glade_warning_file_location, NULL, NULL);
+ if (gladeWarning == NULL)
+ die("Unable to load glade warning window definitions.\n");
+ glade_xml_signal_autoconnect(gladeWarning);
+
+ gladeNetsurf = glade_xml_new(glade_netsurf_file_location, NULL, NULL);
+ if (gladeNetsurf == NULL)
+ die("Unable to load glade Netsurf window definitions.\n");
+ glade_xml_signal_autoconnect(gladeNetsurf);
+ gladePassword = glade_xml_new(glade_password_file_location, NULL, NULL);
+ if (gladePassword == NULL)
+ die("Unable to load glade password window definitions.\n");
+ glade_xml_signal_autoconnect(gladePassword);
+
+ gladeLogin = glade_xml_new(glade_login_file_location, NULL, NULL);
+ if (gladeLogin == NULL)
+ die("Unable to load glade login window definitions.\n");
+ glade_xml_signal_autoconnect(gladeLogin);
+
+ gladeSsl = glade_xml_new(glade_ssl_file_location, NULL, NULL);
+ if (gladeSsl == NULL)
+ die("Unable to load glade ssl window definitions.\n");
+ glade_xml_signal_autoconnect(gladeSsl);
+
+ find_resource(buf, "toolbar.glade", "./gtk/res/toolbar.glade");
+ LOG(("Using '%s' as glade toolbar file", buf));
+ glade_toolbar_file_location = strdup(buf);
+
find_resource(buf, "netsurf.xpm", "./gtk/res/netsurf.xpm");
gtk_window_set_default_icon_from_file(buf, NULL);
- wndTooltip = GTK_WINDOW(glade_xml_get_widget(gladeWindows, "wndTooltip"));
- labelTooltip = GTK_LABEL(glade_xml_get_widget(gladeWindows, "tooltip"));
-
+ /* superfluous ? */
+ wndTooltip = GTK_WINDOW(glade_xml_get_widget(gladeNetsurf, "wndTooltip"));
+ labelTooltip = GTK_LABEL(glade_xml_get_widget(gladeNetsurf, "tooltip"));
+
nsgtk_completion_init();
/* This is an ugly hack to just get the new-style throbber going.
@@ -315,13 +368,26 @@
LOG(("Using '%s' as Print Settings file", buf));
print_options_file_location = strdup(buf);
+ find_resource(buf, "SearchEngines", "./gtk/res/SearchEngines");
+ LOG(("Using '%s' as Search Engines file", buf));
+ search_engines_file_location = strdup(buf);
+
+ find_resource(buf, "default.ico", "./gtk/res/default.ico");
+ LOG(("Using '%s' as default search ico", buf));
+ search_default_ico_location = strdup(buf);
+
+ find_resource(buf, "toolbarIndices", "./gtk/res/toolbarIndices");
+ LOG(("Using '%s' as custom toolbar settings file", buf));
+ toolbar_indices_file_location = strdup(buf);
+
urldb_load(option_url_file);
urldb_load_cookies(option_cookie_file);
+
+ /* superfluous ? */
+ wndAbout = GTK_WINDOW(glade_xml_get_widget(gladeNetsurf, "wndAbout"));
- wndAbout = GTK_WINDOW(glade_xml_get_widget(gladeWindows, "wndAbout"));
+ wndWarning = GTK_WINDOW(glade_xml_get_widget(gladeWarning, "wndWarning"));
- wndWarning = GTK_WINDOW(glade_xml_get_widget(gladeWindows, "wndWarning"));
-
nsgtk_history_init();
nsgtk_download_init();
}
@@ -421,6 +487,9 @@
free(option_cookie_file);
free(option_cookie_jar);
free(print_options_file_location);
+ free(search_engines_file_location);
+ free(search_default_ico_location);
+ free(toolbar_indices_file_location);
gtk_fetch_filetype_fin();
/* We don't care if this fails as we're about to die, anyway */
hubbub_finalise(myrealloc, NULL);
@@ -483,15 +552,6 @@
{
}
-
-bool gui_search_term_highlighted(struct gui_window *g,
- unsigned start_offset, unsigned end_offset,
- unsigned *start_idx, unsigned *end_idx)
-{
- return false;
-}
-
-
void warn_user(const char *warning, const char *detail)
{
char buf[300]; /* 300 is the size the RISC OS GUI uses */
@@ -503,7 +563,7 @@
detail ? detail : "");
buf[sizeof(buf) - 1] = 0;
- gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(gladeWindows,
"labelWarning")), buf);
+ gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(gladeWarning,
"labelWarning")), buf);
gtk_widget_show_all(GTK_WIDGET(wndWarning));
}
@@ -529,7 +589,7 @@
struct content *c, const struct ssl_cert_info *certs,
unsigned long num)
{
- GladeXML *x = glade_xml_new(glade_file_location, NULL, NULL);
+ GladeXML *x = glade_xml_new(glade_ssl_file_location, NULL, NULL);
GtkWindow *wnd = GTK_WINDOW(glade_xml_get_widget(x, "wndSSLProblem"));
GtkButton *accept, *reject;
void **session = calloc(sizeof(void *), 4);
@@ -633,7 +693,7 @@
void PDF_Password(char **owner_pass, char **user_pass, char *path)
{
- GladeXML *x = glade_xml_new(glade_file_location, NULL, NULL);
+ GladeXML *x = glade_xml_new(glade_password_file_location, NULL, NULL);
GtkWindow *wnd = GTK_WINDOW(glade_xml_get_widget(x, "wndPDFPassword"));
GtkButton *ok, *no;
void **data = malloc(5 * sizeof(void *));
Index: gtk/gtk_selection.c
===================================================================
--- gtk/gtk_selection.c (revision 8438)
+++ gtk/gtk_selection.c (working copy)
@@ -79,7 +79,7 @@
else
g_string_set_size(current_selection, 0);
- gtk_widget_grab_focus(GTK_WIDGET(g->drawing_area));
+ gtk_widget_grab_focus(GTK_WIDGET(nsgtk_window_get_drawing_area(g)));
}
void gui_paste_from_clipboard(struct gui_window *g, int x, int y)
@@ -89,7 +89,8 @@
text = gtk_clipboard_wait_for_text (clipboard);
/* clipboard_wait... converts the string to utf8 for us */
if (text != NULL)
- browser_window_paste_text(g->bw, text, strlen(text), true);
+ browser_window_paste_text(gui_window_get_browser_window(g),
+ text, strlen(text), true);
g_free(text);
}
Index: !NetSurf/Resources/de/Messages
===================================================================
--- !NetSurf/Resources/de/Messages (revision 8438)
+++ !NetSurf/Resources/de/Messages (working copy)
@@ -427,10 +427,118 @@
gtkFileError:File error: %s
gtkInfo:%s from %s is %s in size
gtkSave:Save file as...
+gtkSourceSave:Save Source
+gtkPlainSave:Save as text
+gtkFullSave:Save webpage complete - select an empty directory
gtkUnknownHost:an unknown host
gtkUnknownFile:
gtkUnknownSize:unknown
+# gtk Menu / Button labels
+#
+
+gtkNewTab:New _Tab
+gtkNewTabAccel:<ctrl>t
+gtkNewWindow:_New Window
+gtkNewWindowAccel:<ctrl>n
+gtkOpenFile:_Open File
+gtkOpenFileAccel:<ctrl>o
+gtkCloseWindow:_Close Window
+gtkCloseWindowAccel:<ctrl><shift>w
+gtkSavePage:Save Page..
+gtkSavePageAccel:<ctrl>s
+gtkExport:Export
+gtkPlainText:Plain Text..
+gtkDrawFile:Drawfile..
+gtkPostScript:PostScript..
+gtkPDF:PDF..
+gtkPrintPreview:Print Preview..
+gtkPrintPreviewAccel:<ctrl><shift>p
+gtkPrint:Print..
+gtkPrintAccel:<ctrl>p
+gtkQuit:_Quit
+gtkQuitAccel:<ctrl>q
+
+gtkCut:Cu_t
+gtkCutAccel:<ctrl>x
+gtkCopy:_Copy
+gtkCopyAccel:<ctrl>c
+gtkPaste:_Paste
+gtkPasteAccel:<ctrl>v
+gtkDelete:_Delete
+gtkSelectAll:Select _All
+gtkSelectAllAccel:<ctrl>a
+gtkFind:_Find..
+gtkFindAccel:<ctrl>f
+gtkPreferences:P_references
+
+gtkStop:_Stop
+gtkStopAccel:Escape
+gtkReload:_Reload
+gtkReloadAccel:F5
+gtkScaleView:_Scale View
+gtkZoomPlus:Zoom _in
+gtkZoomPlusAccel:<ctrl>plus
+gtkZoomMinus:Zoom _out
+gtkZoomMinusAccel:<ctrl>minus
+gtkZoomNormal:_Normal size
+gtkZoomNormalAccel:<ctrl>0
+gtkFullScreen:_Fullscreen
+gtkFullScreenAccel:F11
+gtkViewSource:View S_ource
+gtkViewSourceAccel:F8
+gtkImages:_Images
+gtkForegroundImages:_Foreground Images
+gtkBackgroundImages:_Background Images
+gtkToolbars:_Toolbars
+gtkMenuBar:_Menu Bar
+gtkToolBar:_Button Bar
+gtkStatusBar:_Status Bar
+gtkDownloads:_Downloads
+gtkDownloadsAccel:<ctrl>d
+gtkSaveWindowSize:S_ave Window Size
+gtkDebugging:De_bugging
+gtkToggleDebugging:T_oggle debug rendering
+gtkSaveBoxTree:_Save box tree
+gtkSaveDomTree:Save DOM tree
+
+gtkBack:_Back
+gtkBackAccel:<alt>Left
+gtkForward:_Forward
+gtkForwardAccel:<alt>Right
+gtkHome:_Home
+gtkHomeAccel:<alt>Down
+gtkLocalHistory:_Local History
+gtkLocalHistoryAccel:<ctrl>h
+gtkGlobalHistory:_Global History
+gtkGlobalHistoryAccel:<ctrl><shift>h
+gtkAddBookMarks:_Add to Bookmarks..
+gtkShowBookMarks:_Show Bookmarks..
+gtkShowBookMarksAccel:F6
+gtkOpenLocation:_Open Location..
+gtkOpenLocationAccel:<ctrl>l
+
+gtkNextTab:_Next tab
+gtkNextTabAccel:<ctrl>Right
+gtkPrevTab:_Previous tab
+gtkPrevTabAccel:<ctrl>Left
+gtkCloseTab:_Close tab
+gtkCloseTabAccel:<ctrl>w
+
+gtkContents:_Contents
+gtkGuide:User _guide
+gtkUserInformation:User _information
+gtkAbout:_About
+
+
+gtkToolBarTitle:Toolbar custom button store
+gtkAddThemeTitle:Select folder containing theme images
+
+gtkThemeFolderInstructions:To Install a theme, create a directory full of
appropriately-named images as a subdirectory of gtk/res/themes/
+gtkThemeFolderSub:Select a subdirectory of the themes folder
+gtkThemeDup:Theme is already included
+gtkThemeAdd:Theme added successfully
+
# Printing user interface tokens
# ==============================
#
@@ -570,6 +678,9 @@
FileError:Datei existiert nicht:
PrintError:Ein Fehler trat wÀhrend des Druckens auf:
AWNotSeen:Das Programm AWViewer wurde nicht gefunden.
+EncNotRec:Encoding type not recognised.
+FileOpenError:could not open file '%s'
+DirectoryError:directory '%s' already exists
# Specific errors - displayed in a dialog box
#
@@ -581,6 +692,7 @@
Template:Ein Template fÃŒr ein Fenster fehlt in der Datei Templates. Bitte NetSurf neu
installieren.
HotlistSaveError:Hotlist konnte nicht korrekt gespeichert werden.
HotlistLoadError:Hotlist konnte nicht korrekt geladen werden.
+NoDirError:%s is not a directory
NoPathError:Symbol in ein Verzeichnisfenster ziehen um zu Speichern.
NoNameError:Bitte einen Namen eingeben.
NoURLError:Bitte eine URL Adresse eingeben.
@@ -628,6 +740,7 @@
BadRedirect:Falsche URL fÃŒr Redirect
FetchFailed:Kann Dokument nicht fetchen
NotCSS:Warnung: Stylesheet ist kein CSS
+NotFavIco:Favicon not supported
BadObject:Warnung: falscher Objekttyp
ObjError:Fehler beim Laden des Objektes: %s
ParsingFail:Dokumentparsing ist fehlgeschlagen.
Index: !NetSurf/Resources/en/Messages
===================================================================
--- !NetSurf/Resources/en/Messages (revision 8438)
+++ !NetSurf/Resources/en/Messages (working copy)
@@ -429,12 +429,119 @@
gtkInfo:%s from %s is %s in size
gtkSave:Save file as...
gtkSourceSave:Save source
+gtkplainSave:Save plain text
+gtkcompleteSave:Save webpage complete - select an empty directory
gtkSaveConfirm:File saved
gtkSaveCancelled:File not saved
gtkUnknownHost:an unknown host
gtkUnknownFile:
gtkUnknownSize:unknown
+# gtk Menu / Button labels
+#
+
+gtkNewTab:New _Tab
+gtkNewTabAccel:<ctrl>t
+gtkNewWindow:_New Window
+gtkNewWindowAccel:<ctrl>n
+gtkOpenFile:_Open File
+gtkOpenFileAccel:<ctrl>o
+gtkCloseWindow:_Close Window
+gtkCloseWindowAccel:<ctrl><shift>w
+gtkSavePage:Save Page..
+gtkSavePageAccel:<ctrl>s
+gtkExport:Export
+gtkPlainText:Plain Text..
+gtkDrawFile:Drawfile..
+gtkPostScript:PostScript..
+gtkPDF:PDF..
+gtkPrintPreview:Print Preview..
+gtkPrintPreviewAccel:<ctrl><shift>p
+gtkPrint:Print..
+gtkPrintAccel:<ctrl>p
+gtkQuit:_Quit
+gtkQuitAccel:<ctrl>q
+
+gtkCut:Cu_t
+gtkCutAccel:<ctrl>x
+gtkCopy:_Copy
+gtkCopyAccel:<ctrl>c
+gtkPaste:_Paste
+gtkPasteAccel:<ctrl>v
+gtkDelete:_Delete
+gtkSelectAll:Select _All
+gtkSelectAllAccel:<ctrl>a
+gtkFind:_Find..
+gtkFindAccel:<ctrl>f
+gtkPreferences:P_references
+
+gtkStop:_Stop
+gtkStopAccel:Escape
+gtkReload:_Reload
+gtkReloadAccel:F5
+gtkScaleView:_Scale View
+gtkZoomPlus:Zoom _in
+gtkZoomPlusAccel:<ctrl>plus
+gtkZoomMinus:Zoom _out
+gtkZoomMinusAccel:<ctrl>minus
+gtkZoomNormal:_Normal size
+gtkZoomNormalAccel:<ctrl>0
+gtkFullScreen:_Fullscreen
+gtkFullScreenAccel:F11
+gtkViewSource:View S_ource
+gtkViewSourceAccel:F8
+gtkImages:_Images
+gtkForegroundImages:_Foreground Images
+gtkBackgroundImages:_Background Images
+gtkToolbars:_Toolbars
+gtkMenuBar:_Menu Bar
+gtkToolBar:_Button Bar
+gtkStatusBar:_Status Bar
+gtkDownloads:_Downloads
+gtkDownloadsAccel:<ctrl>d
+gtkSaveWindowSize:S_ave Window Size
+gtkDebugging:De_bugging
+gtkToggleDebugging:T_oggle debug rendering
+gtkSaveBoxTree:_Save box tree
+gtkSaveDomTree:Save DOM tree
+
+gtkBack:_Back
+gtkBackAccel:<alt>Left
+gtkForward:_Forward
+gtkForwardAccel:<alt>Right
+gtkHome:_Home
+gtkHomeAccel:<alt>Down
+gtkLocalHistory:_Local History
+gtkLocalHistoryAccel:<ctrl>h
+gtkGlobalHistory:_Global History
+gtkGlobalHistoryAccel:<ctrl><shift>h
+gtkAddBookMarks:_Add to Bookmarks..
+gtkShowBookMarks:_Show Bookmarks..
+gtkShowBookMarksAccel:F6
+gtkOpenLocation:_Open Location..
+gtkOpenLocationAccel:<ctrl>l
+
+gtkNextTab:_Next tab
+gtkNextTabAccel:<ctrl>Right
+gtkPrevTab:_Previous tab
+gtkPrevTabAccel:<ctrl>Left
+gtkCloseTab:_Close tab
+gtkCloseTabAccel:<ctrl>w
+
+gtkContents:_Contents
+gtkGuide:User _guide
+gtkUserInformation:User _information
+gtkAbout:_About
+
+
+gtkToolBarTitle:Toolbar custom button store
+gtkAddThemeTitle:Select folder containing theme images
+
+gtkThemeFolderInstructions:To Install a theme, create a directory full of
appropriately-named images as a subdirectory of gtk/res/themes/
+gtkThemeFolderSub:Select a subdirectory of the themes folder
+gtkThemeDup:Theme is already included
+gtkThemeAdd:Theme added successfully
+
# Printing user interface tokens
# ==============================
#
@@ -585,6 +692,7 @@
Template:A window template is missing from the Templates file. Please reinstall NetSurf.
HotlistSaveError:The hotlist was unable to be correctly saved.
HotlistLoadError:The hotlist was unable to be correctly loaded.
+NoDirError:%s is not a directory
NoPathError:To save, drag the icon to a directory display
NoNameError:Please enter a name
NoURLError:Please enter a URL
@@ -593,6 +701,8 @@
PrintErrorRO2:It appears that the printer is busy.
AWNotSeen:Please locate the AWViewer application and try again.
EncNotRec:Encoding type not recognised.
+FileOpenError:could not open file '%s'
+DirectoryError:directory '%s' already exists
# Error messages for Amiga version only
NoMode:No matching mode in screens database
@@ -633,6 +743,7 @@
BadRedirect:Bad redirect URL
FetchFailed:Unable to fetch document
NotCSS:Warning: stylesheet is not CSS
+NotFavIco:Favicon not supported
BadObject:Warning: bad object type
ObjError:Error loading object: %s
ParsingFail:Parsing the document failed.
Index: !NetSurf/Resources/fr/Messages
===================================================================
--- !NetSurf/Resources/fr/Messages (revision 8438)
+++ !NetSurf/Resources/fr/Messages (working copy)
@@ -427,10 +427,118 @@
gtkFileError:File error: %s
gtkInfo:%s from %s is %s in size
gtkSave:Save file as...
+gtkSourceSave:Save Source
+gtkPlainSave:Save as text
+gtkFullSave:Save webpage complete - select an empty directory
gtkUnknownHost:an unknown host
gtkUnknownFile:
gtkUnknownSize:unknown
+# gtk Menu / Button labels
+#
+
+gtkNewTab:New _Tab
+gtkNewTabAccel:<ctrl>t
+gtkNewWindow:_New Window
+gtkNewWindowAccel:<ctrl>n
+gtkOpenFile:_Open File
+gtkOpenFileAccel:<ctrl>o
+gtkCloseWindow:_Close Window
+gtkCloseWindowAccel:<ctrl><shift>w
+gtkSavePage:Save Page..
+gtkSavePageAccel:<ctrl>s
+gtkExport:Export
+gtkPlainText:Plain Text..
+gtkDrawFile:Drawfile..
+gtkPostScript:PostScript..
+gtkPDF:PDF..
+gtkPrintPreview:Print Preview..
+gtkPrintPreviewAccel:<ctrl><shift>p
+gtkPrint:Print..
+gtkPrintAccel:<ctrl>p
+gtkQuit:_Quit
+gtkQuitAccel:<ctrl>q
+
+gtkCut:Cu_t
+gtkCutAccel:<ctrl>x
+gtkCopy:_Copy
+gtkCopyAccel:<ctrl>c
+gtkPaste:_Paste
+gtkPasteAccel:<ctrl>v
+gtkDelete:_Delete
+gtkSelectAll:Select _All
+gtkSelectAllAccel:<ctrl>a
+gtkFind:_Find..
+gtkFindAccel:<ctrl>f
+gtkPreferences:P_references
+
+gtkStop:_Stop
+gtkStopAccel:Escape
+gtkReload:_Reload
+gtkReloadAccel:F5
+gtkScaleView:_Scale View
+gtkZoomPlus:Zoom _in
+gtkZoomPlusAccel:<ctrl>plus
+gtkZoomMinus:Zoom _out
+gtkZoomMinusAccel:<ctrl>minus
+gtkZoomNormal:_Normal size
+gtkZoomNormalAccel:<ctrl>0
+gtkFullScreen:_Fullscreen
+gtkFullScreenAccel:F11
+gtkViewSource:View S_ource
+gtkViewSourceAccel:F8
+gtkImages:_Images
+gtkForegroundImages:_Foreground Images
+gtkBackgroundImages:_Background Images
+gtkToolbars:_Toolbars
+gtkMenuBar:_Menu Bar
+gtkToolBar:_Button Bar
+gtkStatusBar:_Status Bar
+gtkDownloads:_Downloads
+gtkDownloadsAccel:<ctrl>d
+gtkSaveWindowSize:S_ave Window Size
+gtkDebugging:De_bugging
+gtkToggleDebugging:T_oggle debug rendering
+gtkSaveBoxTree:_Save box tree
+gtkSaveDomTree:Save DOM tree
+
+gtkBack:_Back
+gtkBackAccel:<alt>Left
+gtkForward:_Forward
+gtkForwardAccel:<alt>Right
+gtkHome:_Home
+gtkHomeAccel:<alt>Down
+gtkLocalHistory:_Local History
+gtkLocalHistoryAccel:<ctrl>h
+gtkGlobalHistory:_Global History
+gtkGlobalHistoryAccel:<ctrl><shift>h
+gtkAddBookMarks:_Add to Bookmarks..
+gtkShowBookMarks:_Show Bookmarks..
+gtkShowBookMarksAccel:F6
+gtkOpenLocation:_Open Location..
+gtkOpenLocationAccel:<ctrl>l
+
+gtkNextTab:_Next tab
+gtkNextTabAccel:<ctrl>Right
+gtkPrevTab:_Previous tab
+gtkPrevTabAccel:<ctrl>Left
+gtkCloseTab:_Close tab
+gtkCloseTabAccel:<ctrl>w
+
+gtkContents:_Contents
+gtkGuide:User _guide
+gtkUserInformation:User _information
+gtkAbout:_About
+
+
+gtkToolBarTitle:Toolbar custom button store
+gtkAddThemeTitle:Select folder containing theme images
+
+gtkThemeFolderInstructions:To Install a theme, create a directory full of
appropriately-named images as a subdirectory of gtk/res/themes/
+gtkThemeFolderSub:Select a subdirectory of the themes folder
+gtkThemeDup:Theme is already included
+gtkThemeAdd:Theme added successfully
+
# Printing user interface tokens
# ==============================
#
@@ -570,6 +678,9 @@
FileError:Le fichier n'existe pas:
PrintError:Une erreur s'est produite lors de l'impression:
AWNotSeen:Localisez l'application AMViewer SVP puis réessayez.
+EncNotRec:Encoding type not recognised.
+FileOpenError:could not open file '%s'
+DirectoryError:directory '%s' already exists
# Specific errors - displayed in a dialog box
#
@@ -581,6 +692,7 @@
Template:Un modÚle de fenêtre est absent du fichier Templates. Réinstallez NetSurf
SVP.
HotlistSaveError:Les favoris n'ont pas pu être sauvés correctement.
HotlistLoadError:Les favoris n'ont pas pu être chargés correctement.
+NoDirError:%s n'est pas un répertoire
NoPathError:Pour sauver, lâcher cette icÎne dans une fenêtre de Filer
NoNameError:Entrez un nom SVP
NoURLError:Entrez une URL SVP
@@ -628,6 +740,7 @@
BadRedirect:Mauvais URL de redirection
FetchFailed:Récupération du fichier impossible
NotCSS:Attention: feuille de style non CSS
+NotFavIco:Favicon non-soutenu
BadObject:Attention: mauvais type d'objet
ObjError:Erreur lors du chargement de: %s
ParsingFail:L'analyse syntaxique du document a échoué.
@@ -761,7 +874,7 @@
HelpToolbar4:\Tle bouton Accueil.|M\Saller àvotre page d'accueil.
HelpToolbar5:\Tle bouton d'historique.|M\Souvrir la \w d'historique
locale.|M\Aopen the global history \w.
HelpToolbar6:\Tle bouton de sauvegarde.|M\Ssauver le document en cours.
-HelpToolbar7:\Tle bouton d'impression.|M\Simprimer cette page.|MOuvre une boîte de
dialogue pour l'impression.
+HelpToolbar7:\Tle bouton d'impression.|M\Simprimer cette page.|MOuvre une boᅵte de
dialogue pour l'impression.
HelpToolbar8:\Tle bouton de favoris.|M\Souvrir la \w de gestion des favoris.|M\Aajouter
cette adresse aux favoris.
HelpToolbar9:\Tle bouton de changement d'échelle.|M\Sredimensionner la page, texte
et images comprises.
HelpToolbar10:\Tle bouton de recherche.|M\Strouver des occurences de fragment de texte
dans une page.
Index: !NetSurf/Resources/nl/Messages
===================================================================
--- !NetSurf/Resources/nl/Messages (revision 8438)
+++ !NetSurf/Resources/nl/Messages (working copy)
@@ -427,10 +427,118 @@
gtkFileError:File error: %s
gtkInfo:%s from %s is %s in size
gtkSave:Save file as...
+gtkSourceSave:Save Source
+gtkPlainSave:Save as text
+gtkFullSave:Save webpage complete - select an empty directory
gtkUnknownHost:an unknown host
gtkUnknownFile:
gtkUnknownSize:unknown
+# gtk Menu / Button labels
+#
+
+gtkNewTab:New _Tab
+gtkNewTabAccel:<ctrl>t
+gtkNewWindow:_New Window
+gtkNewWindowAccel:<ctrl>n
+gtkOpenFile:_Open File
+gtkOpenFileAccel:<ctrl>o
+gtkCloseWindow:_Close Window
+gtkCloseWindowAccel:<ctrl><shift>w
+gtkSavePage:Save Page..
+gtkSavePageAccel:<ctrl>s
+gtkExport:Export
+gtkPlainText:Plain Text..
+gtkDrawFile:Drawfile..
+gtkPostScript:PostScript..
+gtkPDF:PDF..
+gtkPrintPreview:Print Preview..
+gtkPrintPreviewAccel:<ctrl><shift>p
+gtkPrint:Print..
+gtkPrintAccel:<ctrl>p
+gtkQuit:_Quit
+gtkQuitAccel:<ctrl>q
+
+gtkCut:Cu_t
+gtkCutAccel:<ctrl>x
+gtkCopy:_Copy
+gtkCopyAccel:<ctrl>c
+gtkPaste:_Paste
+gtkPasteAccel:<ctrl>v
+gtkDelete:_Delete
+gtkSelectAll:Select _All
+gtkSelectAllAccel:<ctrl>a
+gtkFind:_Find..
+gtkFindAccel:<ctrl>f
+gtkPreferences:P_references
+
+gtkStop:_Stop
+gtkStopAccel:Escape
+gtkReload:_Reload
+gtkReloadAccel:F5
+gtkScaleView:_Scale View
+gtkZoomPlus:Zoom _in
+gtkZoomPlusAccel:<ctrl>plus
+gtkZoomMinus:Zoom _out
+gtkZoomMinusAccel:<ctrl>minus
+gtkZoomNormal:_Normal size
+gtkZoomNormalAccel:<ctrl>0
+gtkFullScreen:_Fullscreen
+gtkFullScreenAccel:F11
+gtkViewSource:View S_ource
+gtkViewSourceAccel:F8
+gtkImages:_Images
+gtkForegroundImages:_Foreground Images
+gtkBackgroundImages:_Background Images
+gtkToolbars:_Toolbars
+gtkMenuBar:_Menu Bar
+gtkToolBar:_Button Bar
+gtkStatusBar:_Status Bar
+gtkDownloads:_Downloads
+gtkDownloadsAccel:<ctrl>d
+gtkSaveWindowSize:S_ave Window Size
+gtkDebugging:De_bugging
+gtkToggleDebugging:T_oggle debug rendering
+gtkSaveBoxTree:_Save box tree
+gtkSaveDomTree:Save DOM tree
+
+gtkBack:_Back
+gtkBackAccel:<alt>Left
+gtkForward:_Forward
+gtkForwardAccel:<alt>Right
+gtkHome:_Home
+gtkHomeAccel:<alt>Down
+gtkLocalHistory:_Local History
+gtkLocalHistoryAccel:<ctrl>h
+gtkGlobalHistory:_Global History
+gtkGlobalHistoryAccel:<ctrl><shift>h
+gtkAddBookMarks:_Add to Bookmarks..
+gtkShowBookMarks:_Show Bookmarks..
+gtkShowBookMarksAccel:F6
+gtkOpenLocation:_Open Location..
+gtkOpenLocationAccel:<ctrl>l
+
+gtkNextTab:_Next tab
+gtkNextTabAccel:<ctrl>Right
+gtkPrevTab:_Previous tab
+gtkPrevTabAccel:<ctrl>Left
+gtkCloseTab:_Close tab
+gtkCloseTabAccel:<ctrl>w
+
+gtkContents:_Contents
+gtkGuide:User _guide
+gtkUserInformation:User _information
+gtkAbout:_About
+
+
+gtkToolBarTitle:Toolbar custom button store
+gtkAddThemeTitle:Select folder containing theme images
+
+gtkThemeFolderInstructions:To Install a theme, create a directory full of
appropriately-named images as a subdirectory of gtk/res/themes/
+gtkThemeFolderSub:Select a subdirectory of the themes folder
+gtkThemeDup:Theme is already included
+gtkThemeAdd:Theme added successfully
+
# Printing user interface tokens
# ==============================
#
@@ -570,6 +678,9 @@
FileError:Bestand bestaat niet:
PrintError:Fout tijdens printen:
AWNotSeen:Zoek eerst de AWViewer applicatie en probeer het dan nog eens.
+EncNotRec:Encoding type not recognised.
+FileOpenError:could not open file '%s'
+DirectoryError:directory '%s' already exists
# Specific errors - displayed in a dialog box
#
@@ -581,6 +692,7 @@
Template:Er ontbreekt een venster sjabloon in het Templates bestand. Installeer NetSurf
opnieuw.
HotlistSaveError:The hotlist was unable to be correctly saved.
HotlistLoadError:The hotlist was unable to be correctly loaded.
+NoDirError:%s is not a directory
NoPathError:Sleep het icoon naar een bestandsvenster om het op te slaan.
NoNameError:Geef een naam op
NoURLError:Geef een URL op
@@ -628,6 +740,7 @@
BadRedirect:foutief doorverwijzen naar URL
FetchFailed:kan dit document niet ophalen
NotCSS:melding: stylesheet is geen CSS
+NotFavIco:Favicon not supported
BadObject:melding: fout object type
ObjError:fout bij laden object: %s
ParsingFail:fout bij ontleden van dit document.
Index: !NetSurf/Resources/it/Messages
===================================================================
--- !NetSurf/Resources/it/Messages (revision 8438)
+++ !NetSurf/Resources/it/Messages (working copy)
@@ -214,7 +214,7 @@
Languages:Lingua
#
# Network pane
-ProxyType:Tipo di proxy
+ProxyType:Tipo di Proxy
ProxyNone:Nessun proxy
ProxyNoAuth:Proxy semplice
ProxyBasic:Autentificazione di Base
@@ -288,9 +288,9 @@
LinkNewTab:Apri in una nuova scheda
LinkNewWin:Apri in una nuova finestra
CopyURL:Copia URL nella clipboard
-CopyClip:Copia nella clipboard
-SaveAs:Salva come...
-SaveIFF:Salva come IFF...
+CopyClip:Copy to clipboard
+SaveAs:Save as...
+SaveIFF:Save as IFF...
ObjShow:Mostra oggetto
SelectFile:Seleziona file...
@@ -432,12 +432,119 @@
gtkInfo:%s da %s Ú %s come dimensione
gtkSave:Salva file come...
gtkSourceSave:Salva sorgente
+gtkPlainSave:Save as text
+gtkFullSave:Save webpage complete - select an empty directory
gtkSaveConfirm:File salvato
gtkSaveCancelled:File non salvato
gtkUnknownHost:un Host sconosciuto
gtkUnknownFile:
gtkUnknownSize:sconosciuto
+# gtk Menu / Button labels
+#
+
+gtkNewTab:New _Tab
+gtkNewTabAccel:<ctrl>t
+gtkNewWindow:_New Window
+gtkNewWindowAccel:<ctrl>n
+gtkOpenFile:_Open File
+gtkOpenFileAccel:<ctrl>o
+gtkCloseWindow:_Close Window
+gtkCloseWindowAccel:<ctrl><shift>w
+gtkSavePage:Save Page..
+gtkSavePageAccel:<ctrl>s
+gtkExport:Export
+gtkPlainText:Plain Text..
+gtkDrawFile:Drawfile..
+gtkPostScript:PostScript..
+gtkPDF:PDF..
+gtkPrintPreview:Print Preview..
+gtkPrintPreviewAccel:<ctrl><shift>p
+gtkPrint:Print..
+gtkPrintAccel:<ctrl>p
+gtkQuit:_Quit
+gtkQuitAccel:<ctrl>q
+
+gtkCut:Cu_t
+gtkCutAccel:<ctrl>x
+gtkCopy:_Copy
+gtkCopyAccel:<ctrl>c
+gtkPaste:_Paste
+gtkPasteAccel:<ctrl>v
+gtkDelete:_Delete
+gtkSelectAll:Select _All
+gtkSelectAllAccel:<ctrl>a
+gtkFind:_Find..
+gtkFindAccel:<ctrl>f
+gtkPreferences:P_references
+
+gtkStop:_Stop
+gtkStopAccel:Escape
+gtkReload:_Reload
+gtkReloadAccel:F5
+gtkScaleView:_Scale View
+gtkZoomPlus:Zoom _in
+gtkZoomPlusAccel:<ctrl>plus
+gtkZoomMinus:Zoom _out
+gtkZoomMinusAccel:<ctrl>minus
+gtkZoomNormal:_Normal size
+gtkZoomNormalAccel:<ctrl>0
+gtkFullScreen:_Fullscreen
+gtkFullScreenAccel:F11
+gtkViewSource:View S_ource
+gtkViewSourceAccel:F8
+gtkImages:_Images
+gtkForegroundImages:_Foreground Images
+gtkBackgroundImages:_Background Images
+gtkToolbars:_Toolbars
+gtkMenuBar:_Menu Bar
+gtkToolBar:_Button Bar
+gtkStatusBar:_Status Bar
+gtkDownloads:_Downloads
+gtkDownloadsAccel:<ctrl>d
+gtkSaveWindowSize:S_ave Window Size
+gtkDebugging:De_bugging
+gtkToggleDebugging:T_oggle debug rendering
+gtkSaveBoxTree:_Save box tree
+gtkSaveDomTree:Save DOM tree
+
+gtkBack:_Back
+gtkBackAccel:<alt>Left
+gtkForward:_Forward
+gtkForwardAccel:<alt>Right
+gtkHome:_Home
+gtkHomeAccel:<alt>Down
+gtkLocalHistory:_Local History
+gtkLocalHistoryAccel:<ctrl>h
+gtkGlobalHistory:_Global History
+gtkGlobalHistoryAccel:<ctrl><shift>h
+gtkAddBookMarks:_Add to Bookmarks..
+gtkShowBookMarks:_Show Bookmarks..
+gtkShowBookMarksAccel:F6
+gtkOpenLocation:_Open Location..
+gtkOpenLocationAccel:<ctrl>l
+
+gtkNextTab:_Next tab
+gtkNextTabAccel:<ctrl>Right
+gtkPrevTab:_Previous tab
+gtkPrevTabAccel:<ctrl>Left
+gtkCloseTab:_Close tab
+gtkCloseTabAccel:<ctrl>w
+
+gtkContents:_Contents
+gtkGuide:User _guide
+gtkUserInformation:User _information
+gtkAbout:_About
+
+
+gtkToolBarTitle:Toolbar custom button store
+gtkAddThemeTitle:Select folder containing theme images
+
+gtkThemeFolderInstructions:To Install a theme, create a directory full of
appropriately-named images as a subdirectory of gtk/res/themes/
+gtkThemeFolderSub:Select a subdirectory of the themes folder
+gtkThemeDup:Theme is already included
+gtkThemeAdd:Theme added successfully
+
# Printing user interface tokens
# ==============================
#
@@ -479,17 +586,17 @@
# This section contains tokens which are used in the
# SSL certificate verification dialog box.
#
-SSLCerts:Certificati SSL
-SSLError:NetSurf non Ú stato in grado di verificare l'autenticitàdel certificato
SSL. Per favore verifica i dettagli qui sotto elencati.
-Subject:Oggetto
-Issuer:Depositario
-Version:Versione
-ValidFrom:Valido da
-ValidTo:Valido fino
-Type:Tipo
-Serial:Seriale
-Accept:Accetta
-Reject:Rifiuta
+SSLCerts:SSL certificates
+SSLError:NetSurf failed to verify the authenticity of an SSL certificate. Please verify
the details presented below.
+Subject:Subject
+Issuer:Issuer
+Version:Version
+ValidFrom:Valid from
+ValidTo:Valid until
+Type:Type
+Serial:Serial
+Accept:Accept
+Reject:Reject
# Content
@@ -576,6 +683,9 @@
FileError:Il file Ú inesistente:
PrintError:Si Ú verificato un errore durante la stampa:
AWNotSeen:Per favore imposta l'applicazione AWViewer e riprova ancora.
+EncNotRec:Encoding type not recognised.
+FileOpenError:could not open file '%s'
+DirectoryError:directory '%s' already exists
# Specific errors - displayed in a dialog box
#
@@ -587,6 +697,7 @@
Template:Una finestra di template risulta mancante. Per favore reinstalla NetSurf.
HotlistSaveError:Non Ú stato possibile salvare correttamente l'Hotlist.
HotlistLoadError:Non Ú stato possibile caricare correttamente l'Hotlist.
+NoDirError:%s is not a directory
NoPathError:Per salvare, trascinare l'icona in una directory di visualizzazione.
NoNameError:Inserisci un nome
NoURLError:Inserisci un URL
@@ -634,7 +745,8 @@
#
BadRedirect:Errata redirezione dell'URL
FetchFailed:Impossibile ottenere il documento
-NotCSS:Attenzione: la dicitura "Foglio di stile" non ha nulla a che vedere con
i CSS
+NotCSS:Attenzione: "Foglio di stile" non ha nulla a che spartire con i CSS
+NotFavIco:Favicon not supported
BadObject:Attenzione: errato tipo di oggetto
ObjError:Errore di caricamento dell'oggetto: %s
ParsingFail:Analisi del documento fallita.
@@ -670,7 +782,7 @@
HTTP405:Metodo non permesso
HTTP406:Non accettabile
HTTP407:Autentificazione Proxy necessaria
-HTTP408:Messaggio di TimeOut
+HTTP408:Richiesta TimeOut
HTTP409:Conflitto
HTTP410:Irraggiungibile
HTTP411:Lunghezza richiesta
Index: Docs/Doxyfile
===================================================================
--- Docs/Doxyfile (revision 8438)
+++ Docs/Doxyfile (working copy)
@@ -896,6 +896,8 @@
PREDEFINED = riscos CSS_INTERNALS WITH_ARTWORKS WITH_BMP WITH_DRAW
WITH_DRAW_EXPORT WITH_GIF WITH_JPEG WITH_MMAP WITH_MNG WITH_NSSPRITE WITH_NS_SVG
WITH_PLUGIN WITH_RSVG WITH_SAVE_COMPLETE WITH_SPRITE WITH_THEME_INSTALL WITH_PDF_EXPORT
+PREDEFINED = gtk WITH_THEME_INSTALL
+
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
Index: beos/beos_scaffolding.cpp
===================================================================
--- beos/beos_scaffolding.cpp (revision 8438)
+++ beos/beos_scaffolding.cpp (working copy)
@@ -2311,6 +2311,10 @@
g->top_view->UnlockLooper();
}
+void gui_window_set_icon(struct gui_window *g, struct content *icon)
+{
+}
+
#warning XXX
#if 0 /* GTK */
gboolean nsbeos_scaffolding_is_busy(nsbeos_scaffolding *scaffold)
Index: Makefile.sources
===================================================================
--- Makefile.sources (revision 8438)
+++ Makefile.sources (working copy)
@@ -8,12 +8,13 @@
S_CONTENT := content.c fetch.c fetchcache.c urldb.c \
fetchers/fetch_curl.c fetchers/fetch_data.c
S_CSS := css.c css_enum.c parser.c ruleset.c scanner.c
-S_RENDER := box.c box_construct.c box_normalise.c directory.c \
+S_RENDER := box.c box_construct.c box_normalise.c directory.c favicon.c \
form.c html.c html_redraw.c hubbub_binding.c imagemap.c \
layout.c list.c loosen.c table.c textplain.c
-S_UTILS := base64.c filename.c hashtable.c locale.c messages.c talloc.c \
- url.c utf8.c utils.c useragent.c
-S_DESKTOP := knockout.c options.c print.c tree.c version.c textarea.c
+S_UTILS := base64.c container.c filename.c hashtable.c locale.c \
+ messages.c talloc.c url.c utf8.c utils.c useragent.c
+S_DESKTOP := knockout.c options.c print.c search.c searchweb.c textarea.c \
+ tree.c version.c
# S_COMMON are sources common to all builds
S_COMMON := $(addprefix content/,$(S_CONTENT)) \
@@ -32,8 +33,8 @@
# S_BROWSER are sources related to full browsers but are common
# between RISC OS, GTK, BeOS and AmigaOS builds
-S_BROWSER := browser.c frames.c history_core.c netsurf.c save_text.c \
- selection.c textinput.c
+S_BROWSER := browser.c frames.c history_core.c netsurf.c save_complete.c \
+ save_text.c selection.c textinput.c
S_BROWSER := $(addprefix desktop/,$(S_BROWSER))
# S_RISCOS are sources purely for the RISC OS build
@@ -42,8 +43,8 @@
filetype.c font.c global_history.c gui.c help.c history.c \
hotlist.c image.c menus.c message.c palettes.c plotters.c \
plugin.c print.c query.c save.c save_complete.c save_draw.c \
- save_pdf.c schedule.c search.c sprite.c sslcert.c textarea.c \
- textselection.c theme.c theme_install.c thumbnail.c \
+ save_pdf.c schedule.c search.c searchweb.c sprite.c sslcert.c \
+ textarea.c textselection.c theme.c theme_install.c thumbnail.c \
treeview.c ucstables.c uri.c url_complete.c url_protocol.c \
wimp.c wimp_event.c window.c gui/progress_bar.c \
gui/status_bar.c \
@@ -59,7 +60,8 @@
gtk_thumbnail.c gtk_plotters.c gtk_treeview.c gtk_scaffolding.c \
gtk_completion.c gtk_login.c gtk_throbber.c gtk_selection.c \
gtk_history.c gtk_window.c gtk_filetype.c gtk_download.c \
- gtk_print.c gtk_tabs.c \
+ gtk_menu.c gtk_print.c gtk_save.c gtk_search.c gtk_tabs.c \
+ gtk_theme.c gtk_toolbar.c \
$(addprefix dialogs/,gtk_options.c gtk_about.c gtk_source.c)
S_GTK := $(addprefix gtk/,$(S_GTK))
@@ -67,8 +69,9 @@
S_BEOS := beos_about.cpp beos_bitmap.cpp beos_fetch_rsrc.cpp \
beos_filetype.cpp beos_font.cpp beos_gui.cpp beos_history.cpp \
beos_login.cpp beos_options.cpp beos_plotters.cpp \
- beos_scaffolding.cpp beos_schedule.cpp beos_thumbnail.cpp \
- beos_treeview.cpp beos_throbber.cpp beos_window.cpp
+ beos_scaffolding.cpp beos_search.cpp beos_schedule.cpp \
+ beos_thumbnail.cpp beos_treeview.cpp beos_throbber.cpp \
+ beos_window.cpp
S_BEOS := $(addprefix beos/,$(S_BEOS))
RDEF_BEOS := beos_res.rdef
RDEF_BEOS := $(addprefix beos/,$(RDEF_BEOS))
Index: utils/utils.c
===================================================================
--- utils/utils.c (revision 8438)
+++ utils/utils.c (working copy)
@@ -61,6 +61,23 @@
return 1;
}
+char *remove_underscores(const char *s, bool replacespace)
+{
+ size_t i, len, offset = 0;
+ char *ret;
+ len = strlen(s);
+ ret = malloc(len + 1);
+ for (i = 0; i < len; i++)
+ if (s[i] != '_')
+ ret[i - offset] = s[i];
+ else if (replacespace)
+ ret[i - offset] = ' ';
+ else
+ offset++;
+ ret[i - offset] = '\0';
+ return ret;
+}
+
/**
* Replace consecutive whitespace with a single space.
*
Index: utils/utils.h
===================================================================
--- utils/utils.h (revision 8438)
+++ utils/utils.h (working copy)
@@ -76,6 +76,7 @@
char * strip(char * const s);
int whitespace(const char * str);
char * squash_whitespace(const char * s);
+char *remove_underscores(const char *s, bool replacespace);
char *cnv_space2nbsp(const char *s);
bool is_dir(const char *path);
void regcomp_wrapper(regex_t *preg, const char *regex, int cflags);
Index: utils/config.h
===================================================================
--- utils/config.h (revision 8438)
+++ utils/config.h (working copy)
@@ -55,6 +55,11 @@
#define WITH_MMAP
#endif
+#if defined(gtk)
+ #define WITH_THEME_INSTALL
+#endif
+
+
/* Configuration sanity checks: */
#if defined(WITH_NS_SVG) && defined(WITH_RSVG)
#error Cannot build WITH_NS_SVG and WITH_RSVG both enabled
Index: utils/container.c
===================================================================
--- utils/container.c (revision 8438)
+++ utils/container.c (working copy)
@@ -19,26 +19,33 @@
/* To build a stand-alone command-line utility to create and dismantal
* these theme files, build this thusly:
*
- * gcc -I../../ -DNSTHEME -o themetool container.c
+ * gcc -I../ -DNSTHEME -o themetool container.c
*
+ * then for instance to create a theme file called mythemefilename
+ * ./themetool --verbose --create -n"My theme name" mythemefilename\
+ * --author "Myname" /path/to/directory/containing/theme/files/
*/
/** \file
* Container format handling for themes etc. */
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
+#include <sys/stat.h>
#include <arpa/inet.h>
+#include "utils/config.h"
#include "utils/container.h"
-#include "utils/config.h"
+#include "utils/log.h"
+#include "utils/utils.h"
#ifdef WITH_MMAP
#include <sys/mman.h>
#endif
struct container_dirent {
- unsigned char filename[16];
+ unsigned char filename[64];
u_int32_t startoffset;
u_int32_t len;
u_int32_t flags1;
@@ -85,7 +92,7 @@
sizeof(struct container_dirent));
strncpy((char *)ctx->directory[ctx->entries - 1].filename,
- (char *)entryname, 16);
+ (char *)entryname, 64);
ctx->directory[ctx->entries - 1].startoffset = offset;
ctx->directory[ctx->entries - 1].len = length;
ctx->directory[ctx->entries - 1].flags1 = 0;
@@ -94,13 +101,14 @@
struct container_ctx *container_open(const char *filename)
{
+ size_t val;
struct container_ctx *ctx = calloc(sizeof(struct container_ctx), 1);
ctx->fh = fopen(filename, "rb");
if (ctx->fh == NULL) {
free(ctx);
- return NULL;
+ return NULL;
}
/* we don't actually load any of the data (including directory)
@@ -109,16 +117,26 @@
*/
ctx->processed = false;
- fread(&ctx->header.magic, 4, 1, ctx->fh);
+ val = fread(&ctx->header.magic, 4, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty read magic"));
ctx->header.magic = ntohl(ctx->header.magic);
- fread(&ctx->header.parser, 4, 1, ctx->fh);
+ val = fread(&ctx->header.parser, 4, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty read parser"));
ctx->header.parser = ntohl(ctx->header.parser);
- fread(ctx->header.name, 32, 1, ctx->fh);
- fread(ctx->header.author, 64, 1, ctx->fh);
+ val = fread(ctx->header.name, 32, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty read name"));
+ val = fread(ctx->header.author, 64, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty read author"));
- fread(&ctx->header.diroffset, 4, 1, ctx->fh);
+ val = fread(&ctx->header.diroffset, 4, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty read diroffset"));
ctx->header.diroffset = ntohl(ctx->header.diroffset);
if (ctx->header.magic != 0x4e53544d || ctx->header.parser != 3) {
@@ -132,7 +150,8 @@
static void container_process(struct container_ctx *ctx)
{
- unsigned char filename[16];
+ size_t val;
+ unsigned char filename[64];
u_int32_t start, len, flags1, flags2;
#ifdef WITH_MMAP
@@ -141,14 +160,19 @@
#else
ctx->data = malloc(ctx->header.diroffset);
fseek(ctx->fh, 0, SEEK_SET);
- fread(ctx->data, ctx->header.diroffset, 1, ctx->fh);
+ val = fread(ctx->data, ctx->header.diroffset, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty read diroffset"));
#endif
fseek(ctx->fh, ctx->header.diroffset, SEEK_SET);
/* now work through the directory structure taking it apart into
* our structure */
-#define BEREAD(x) do { fread(&(x), 4, 1, ctx->fh);(x) = ntohl((x)); } while (0)
+#define BEREAD(x) do { val = fread(&(x), 4, 1, ctx->fh); if (val == 0)\
+ LOG(("empty read"));(x) = ntohl((x)); } while (0)
do {
- fread(filename, 16, 1, ctx->fh);
+ val = fread(filename, 64, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty read filename"));
BEREAD(start);
BEREAD(len);
BEREAD(flags1);
@@ -164,7 +188,7 @@
struct container_ctx *ctx,
const unsigned char *entryname)
{
- int i;
+ unsigned int i;
for (i = 1; i <= ctx->entries; i++) {
struct container_dirent *e = ctx->directory + i - 1;
@@ -227,12 +251,16 @@
static void container_write_dir(struct container_ctx *ctx)
{
- int i;
+ size_t val;
+ unsigned int i;
u_int32_t tmp;
-#define BEWRITE(x) do {tmp = htonl((x)); fwrite(&tmp, 4, 1, ctx->fh);} while(0)
+#define BEWRITE(x) do {tmp = htonl((x)); val = fwrite(&tmp, 4, 1, ctx->fh);\
+ if (val == 0) LOG(("empty write")); } while(0)
for (i = 1; i <= ctx->entries; i++) {
struct container_dirent *e = ctx->directory + i - 1;
- fwrite(e->filename, 16, 1, ctx->fh);
+ val = fwrite(e->filename, 64, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty write filename"));
BEWRITE(e->startoffset);
BEWRITE(e->len);
BEWRITE(e->flags1);
@@ -241,13 +269,16 @@
#undef BEWRITE
/* empty entry signifies end of directory */
tmp = 0;
- fwrite(&tmp, 4, 8, ctx->fh);
+ val = fwrite(&tmp, 4, 8, ctx->fh);
+ if (val == 0)
+ LOG(("empty write end"));
}
struct container_ctx *container_create(const char *filename,
const unsigned char *name,
const unsigned char *author)
{
+ size_t val;
struct container_ctx *ctx = calloc(sizeof(struct container_ctx), 1);
ctx->fh = fopen(filename, "wb");
@@ -264,10 +295,18 @@
strncpy((char *)ctx->header.name, (char *)name, 32);
strncpy((char *)ctx->header.author, (char *)author, 64);
- fwrite("NSTM", 4, 1, ctx->fh);
- fwrite(&ctx->header.parser, 4, 1, ctx->fh);
- fwrite(ctx->header.name, 32, 1, ctx->fh);
- fwrite(ctx->header.author, 64, 1, ctx->fh);
+ val = fwrite("NSTM", 4, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty write NSTM"));
+ val = fwrite(&ctx->header.parser, 4, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty write parser"));
+ val = fwrite(ctx->header.name, 32, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty write name"));
+ val = fwrite(ctx->header.author, 64, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty write author"));
ctx->header.diroffset = 108;
@@ -284,14 +323,17 @@
const unsigned char *data,
const u_int32_t datalen)
{
+ size_t val;
container_add_to_dir(ctx, entryname, ftell(ctx->fh), datalen);
- fwrite(data, datalen, 1, ctx->fh);
+ val = fwrite(data, datalen, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty write add file"));
}
void container_close(struct container_ctx *ctx)
{
if (ctx->creating == true) {
- size_t flen, nflen;
+ size_t flen, nflen, val;
/* discover where the directory's going to go. */
flen = container_filelen(ctx->fh);
@@ -300,7 +342,9 @@
/* write this location to the header */
fseek(ctx->fh, 104, SEEK_SET);
nflen = htonl(flen);
- fwrite(&nflen, 4, 1, ctx->fh);
+ val = fwrite(&nflen, 4, 1, ctx->fh);
+ if (val == 0)
+ LOG(("empty write directory location"));
/* seek to where the directory will be, and write it */
fseek(ctx->fh, flen, SEEK_SET);
@@ -318,6 +362,72 @@
free(ctx);
}
+#ifdef WITH_THEME_INSTALL
+
+/**
+ * install theme from container
+ * \param themefile a file containing the containerized theme
+ * \param dirbasename a directory basename including trailing path sep; the
+ * full path of the theme is then a subdirectory of that
+ */
+
+char *container_extract_theme(const char *themefile, const char *dirbasename)
+{
+ struct stat statbuf;
+ struct container_ctx *cctx;
+ FILE *fh;
+ size_t val;
+ const unsigned char *e, *d;
+ char *themename, *dirname;
+ char path[PATH_MAX];
+ int state = 0;
+ unsigned int i;
+ u_int32_t flen;
+
+ cctx = container_open(themefile);
+ if (cctx == NULL) {
+ warn_user("FileOpenError", themefile);
+ return NULL;
+ }
+ themename = (char *)container_get_name(cctx);
+ LOG(("theme name: %s", themename));
+ LOG(("theme author: %s", container_get_author(cctx)));
+
+ dirname = malloc(strlen(dirbasename) + strlen(themename) + 2);
+ strcpy(dirname, dirbasename);
+ strcat(dirname, themename);
+ if (stat(dirname, &statbuf) != -1) {
+ warn_user("DirectoryError", dirname);
+ container_close(cctx);
+ free(dirname);
+ return NULL;
+ }
+ mkdir(dirname, 00777);
+
+ for (e = container_iterate(cctx, &state), i = 0; i < cctx->entries;
+ e = container_iterate(cctx, &state), i++) {
+ LOG(("extracting %s", e));
+ snprintf(path, PATH_MAX, "%s/%s", dirname, e);
+ fh = fopen(path, "wb");
+ if (fh == NULL) {
+ warn_user("FileOpenError", (char *)e);
+ } else {
+ d = container_get(cctx, e, &flen);
+ val = fwrite(d, flen, 1, fh);
+ if (val == 0)
+ LOG(("empty write"));
+ fclose(fh);
+ }
+ }
+ LOG(("theme container unpacked"));
+ container_close(cctx);
+ free(dirname);
+ return themename;
+
+}
+
+#endif
+
#ifdef TEST_RIG
int main(int argc, char *argv[])
{
@@ -355,7 +465,6 @@
#include <getopt.h>
#include <dirent.h>
#include <errno.h>
-#include <sys/stat.h>
#include <unistd.h>
static bool verbose = false;
@@ -403,7 +512,8 @@
printf("theme author: %s\n", container_get_author(cctx));
}
- while ( (e = container_iterate(cctx, &state)) ) {
+ for (e = container_iterate(cctx, &state), i = 0; i < cctx->entries;
+ e = container_iterate(cctx, &state), i++) {
if (verbose == true)
printf("extracting %s\n", e);
snprintf(path, PATH_MAX, "%s/%s", dirname, e);
@@ -450,9 +560,9 @@
/* not the metadirs, so we want to process this. */
if (verbose == true)
printf("adding %s\n", e->d_name);
- if (strlen(e->d_name) > 15) {
+ if (strlen(e->d_name) > 63) {
fprintf(stderr,
- "warning: name truncated to 15 characters.\n");
+ "warning: name truncated to length 63.\n");
}
snprintf(path, PATH_MAX, "%s/%s", dirname, e->d_name);
Index: utils/container.h
===================================================================
--- utils/container.h (revision 8438)
+++ utils/container.h (working copy)
@@ -47,4 +47,7 @@
/* common interface */
void container_close(struct container_ctx *ctx);
+#ifdef WITH_THEME_INSTALL
+char *container_extract_theme(const char *themefile, const char *dirbasename);
+#endif
#endif /* __CONTAINER_H__ */
Index: riscos/save.c
===================================================================
--- riscos/save.c (revision 8438)
+++ riscos/save.c (working copy)
@@ -36,6 +36,7 @@
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
#include "desktop/netsurf.h"
+#include "desktop/save_complete.h"
#include "desktop/save_text.h"
#include "desktop/selection.h"
#include "image/bitmap.h"
@@ -48,7 +49,6 @@
#include "riscos/options.h"
#include "riscos/query.h"
#include "riscos/save.h"
-#include "riscos/save_complete.h"
#include "riscos/save_draw.h"
#include "riscos/save_pdf.h"
#include "riscos/textselection.h"
@@ -986,7 +986,69 @@
gui_save_content = 0;
}
+bool save_complete_gui_save(const char *path, const char *filename, struct
+ content *c, int len, char *sourcedata, int type)
+{
+ char *finame;
+ int namelen = strlen(path) + strlen(filename) + 2;
+ finame = malloc(namelen);
+ if (!finame) {
+ warn_user("NoMemory", 0);
+ return false;
+ }
+ snprintf(finame, namelen, "%s.%s", path, filename);
+ os_error *error;
+ if (c != NULL)
+ type = ro_content_filetype(c);
+ error = xosfile_save_stamped(finame, type, (byte *) sourcedata,
+ (byte *) sourcedata + len);
+ free(finame);
+ if (error) {
+ LOG(("xosfile_save_stamped: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("SaveError", error->errmess);
+ return false;
+ }
+ return true;
+}
+int save_complete_htmlSaveFileFormat(const char *path, const char *filename,
+ xmlDocPtr cur, const char *encoding, int format)
+{
+ int ret;
+ int len = strlen(path) + strlen(filename) + 2;
+ char *finame = malloc(len);
+ if (!finame){
+ warn_user("NoMemory", 0);
+ return -1;
+ }
+ snprintf(finame, len, "%s.%s", path, filename);
+ ret = htmlSaveFileFormat(finame, cur, encoding, format);
+ free(finame);
+ return ret;
+}
+
+bool save_complete_gui_filetype(const char *path, const char *filename, int type)
+{
+ os_error *error;
+ int len = strlen(path) + strlen(filename) + 2;
+ char *finame = malloc(len);
+ if (!finame){
+ warn_user("NoMemory", 0);
+ return -1;
+ }
+ snprintf(finame, len, "%s.%s", path, filename);
+ error = xosfile_set_type(finame, type);
+ free(finame);
+ if (error) {
+ LOG(("xosfile_set_type: 0x%x: %s",
+ error->errnum, error->errmess));
+ warn_user("SaveError", error->errmess);
+ return false;
+ }
+ return true;
+}
+
/**
* Prepare an application directory and save_complete() to it.
*
Index: riscos/search.c
===================================================================
--- riscos/search.c (revision 8438)
+++ riscos/search.c (working copy)
@@ -31,6 +31,7 @@
#include "content/content.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
+#include "desktop/search.h"
#include "desktop/selection.h"
#include "render/box.h"
#include "render/html.h"
@@ -42,35 +43,6 @@
#include "utils/messages.h"
#include "utils/utils.h"
-#ifndef NOF_ELEMENTS
-#define NOF_ELEMENTS(array) (sizeof(array)/sizeof(*(array)))
-#endif
-
-struct list_entry {
- unsigned start_idx; /* start position of match */
- unsigned end_idx; /* end of match */
-
- struct box *start_box; /* used only for html contents */
- struct box *end_box;
-
- struct selection *sel;
-
- struct list_entry *prev;
- struct list_entry *next;
-};
-
-struct gui_window *search_current_window = NULL;
-
-static char *search_string = NULL;
-static struct list_entry search_head = { 0, 0, NULL, NULL, NULL, NULL, NULL };
-static struct list_entry *search_found = &search_head;
-static struct list_entry *search_current = NULL;
-static struct content *search_content = NULL;
-static bool search_prev_case_sens = false;
-
-#define RECENT_SEARCHES 8
-bool search_insert;
-static char *recent_search[RECENT_SEARCHES];
static wimp_MENU(RECENT_SEARCHES) menu_recent;
wimp_menu *recent_search_menu = (wimp_menu *)&menu_recent;
#define DEFAULT_FLAGS (wimp_ICON_TEXT | wimp_ICON_FILLED | \
@@ -78,26 +50,10 @@
(wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT))
-static void start_search(bool forwards);
-static void do_search(const char *string, int string_len, bool case_sens,
- bool forwards);
-static const char *find_pattern(const char *string, int s_len,
- const char *pattern, int p_len, bool case_sens,
- unsigned int *m_len);
-static bool find_occurrences_html(const char *pattern, int p_len,
- struct box *cur, bool case_sens);
-static bool find_occurrences_text(const char *pattern, int p_len,
- struct content *c, bool case_sens);
-static struct list_entry *add_entry(unsigned start_idx, unsigned end_idx);
-static void free_matches(void);
-static void show_all(bool all);
-static void show_status(bool found);
-
static void ro_gui_search_end(wimp_w w);
static bool ro_gui_search_next(wimp_w w);
static bool ro_gui_search_click(wimp_pointer *pointer);
static bool ro_gui_search_keypress(wimp_key *key);
-static void ro_gui_search_add_recent(const char *search);
void ro_gui_search_init(void)
{
@@ -148,14 +104,14 @@
start_search(true);
return true;
case ICON_SEARCH_SHOW_ALL:
- show_all(ro_gui_get_icon_selected_state(pointer->w,
+ search_show_all(ro_gui_get_icon_selected_state(pointer->w,
pointer->i));
return true;
}
return false;
}
-void ro_gui_search_add_recent(const char *search)
+void gui_search_add_recent(const char *search)
{
char *tmp;
int i;
@@ -226,15 +182,15 @@
/**
* Open the search dialog
*
- * \param g the gui window to search
+ * \param bw the browser window to search
*/
-void ro_gui_search_prepare(struct gui_window *g)
+void ro_gui_search_prepare(struct browser_window *bw)
{
struct content *c;
- assert(g != NULL);
+ assert(bw != NULL);
- c = g->bw->current_content;
+ c = bw->current_content;
/* only handle html/textplain contents */
if ((!c) || (c->type != CONTENT_HTML &&
@@ -243,9 +199,9 @@
/* if the search dialogue is reopened over a new window, we still
need to cancel the previous search */
- ro_gui_search_end(dialog_search);
+ search_end();
- search_current_window = g;
+ search_current_window = bw;
ro_gui_set_icon_string(dialog_search, ICON_SEARCH_TEXT, "", true);
ro_gui_set_icon_selected_state(dialog_search,
@@ -253,7 +209,7 @@
ro_gui_set_icon_selected_state(dialog_search,
ICON_SEARCH_SHOW_ALL, false);
- show_status(true);
+ gui_search_set_status(true);
ro_gui_set_icon_shaded_state(dialog_search,
ICON_SEARCH_FIND_PREV, true);
ro_gui_set_icon_shaded_state(dialog_search,
@@ -279,7 +235,7 @@
ICON_SEARCH_SHOW_ALL);
ro_gui_set_icon_selected_state(key->w,
ICON_SEARCH_SHOW_ALL, sel);
- show_all(sel);
+ search_show_all(sel);
}
break;
case 9: /* ctrl i */
@@ -317,564 +273,56 @@
}
/**
- * Begins/continues the search process
- * Note that this may be called many times for a single search.
- *
- * \param forwards search forwards from start/current position
- */
-
-void start_search(bool forwards)
-{
- int string_len;
- const char *string;
- int i = 0;
-
- string = ro_gui_get_icon_string(dialog_search, ICON_SEARCH_TEXT);
- assert(string);
-
- ro_gui_search_add_recent(string);
-
- string_len = strlen(string);
- for(i = 0; i < string_len; i++)
- if (string[i] != '#' && string[i] != '*') break;
- if (i >= string_len) {
- free_matches();
- show_status(true);
- ro_gui_set_icon_shaded_state(dialog_search,
- ICON_SEARCH_FIND_PREV, true);
- ro_gui_set_icon_shaded_state(dialog_search,
- ICON_SEARCH_FIND_NEXT, true);
- gui_window_set_scroll(search_current_window, 0, 0);
- return;
- }
-
- do_search(string, string_len,
- ro_gui_get_icon_selected_state(dialog_search,
- ICON_SEARCH_CASE_SENSITIVE),
- forwards);
-}
-
-/**
- * Ends the search process, invalidating all global state and
- * freeing the list of found boxes
- *
+ * Ends the search
* \param w the search window handle (not used)
*/
void ro_gui_search_end(wimp_w w)
{
- search_current_window = 0;
-
- if (search_string) {
- ro_gui_search_add_recent(search_string);
- free(search_string);
- }
- search_string = 0;
-
- free_matches();
-
- search_current = 0;
-
- search_content = 0;
-
- search_prev_case_sens = false;
+ search_end();
}
-/**
- * Release the memory used by the list of matches,
- * deleting selection objects too
- */
-
-void free_matches(void)
+void gui_search_set_status(bool found)
{
- struct list_entry *a = search_found->next;
- struct list_entry *b;
-
- /* empty the list before clearing and deleting the
- selections because the the clearing updates the
- screen immediately, causing nested accesses to the list */
-
- search_found->prev = 0;
- search_found->next = 0;
-
- for (; a; a = b) {
- b = a->next;
- if (a->sel) {
- selection_clear(a->sel, true);
- selection_destroy(a->sel);
- }
- free(a);
- }
+ ro_gui_set_icon_string(dialog_search, ICON_SEARCH_STATUS, found ? "" :
+ messages_get("NotFound"), true);
}
-/**
- * Search for a string in the box tree
- *
- * \param string the string to search for
- * \param string_len length of search string
- * \param case_sens whether to perform a case sensitive search
- * \param forwards direction to search in
- */
-void do_search(const char *string, int string_len, bool case_sens,
- bool forwards)
+void gui_search_set_hourglass(bool active)
{
- struct rect bounds;
- struct content *c;
- struct box *box;
- bool new = false;
-
- if (!search_current_window)
- return;
-
- c = search_current_window->bw->current_content;
-
- /* only handle html contents */
- if ((!c) || (c->type != CONTENT_HTML &&
- c->type != CONTENT_TEXTPLAIN))
- return;
-
- box = c->data.html.layout;
-
- if (!box)
- return;
-
-// LOG(("do_search '%s' - '%s' (%p, %p) %p (%d, %d) %d",
-// search_string, string, search_content, c, search_found->next,
-// search_prev_case_sens, case_sens, forwards));
-
- /* check if we need to start a new search or continue an old one */
- if (!search_string || c != search_content || !search_found->next ||
- search_prev_case_sens != case_sens ||
- (case_sens && strcmp(string, search_string) != 0) ||
- (!case_sens && strcasecmp(string, search_string) != 0)) {
- bool res;
-
- if (search_string)
- free(search_string);
- search_current = 0;
- free_matches();
-
- search_string = malloc(string_len + 1);
- if (search_string) {
- memcpy(search_string, string, string_len);
- search_string[string_len] = '\0';
- }
-
+ if (active)
xhourglass_on();
- if (c->type == CONTENT_HTML)
- res = find_occurrences_html(string, string_len,
- box, case_sens);
- else {
- assert(c->type == CONTENT_TEXTPLAIN);
- res = find_occurrences_text(string, string_len,
- c, case_sens);
- }
-
- if (!res) {
- free_matches();
- xhourglass_off();
- return;
- }
+ else
xhourglass_off();
-
- new = true;
- search_content = c;
- search_prev_case_sens = case_sens;
- }
-
-// LOG(("%d %p %p (%p, %p)", new, search_found->next, search_current,
search_current->prev, search_current->next));
-
- if (new) {
- /* new search, beginning at the top of the page */
- search_current = search_found->next;
- }
- else if (search_current) {
- /* continued search in the direction specified */
- if (forwards) {
- if (search_current->next)
- search_current = search_current->next;
- }
- else {
- if (search_current->prev)
- search_current = search_current->prev;
- }
- }
-
- show_status(search_current != NULL);
- show_all(ro_gui_get_icon_selected_state(dialog_search,
- ICON_SEARCH_SHOW_ALL));
-
- ro_gui_set_icon_shaded_state(dialog_search, ICON_SEARCH_FIND_PREV,
- !search_current || !search_current->prev);
- ro_gui_set_icon_shaded_state(dialog_search, ICON_SEARCH_FIND_NEXT,
- !search_current || !search_current->next);
-
- if (!search_current)
- return;
-
- switch (c->type) {
- case CONTENT_HTML:
- /* get box position and jump to it */
- box_coords(search_current->start_box,
- &bounds.x0, &bounds.y0);
- /* \todo: move x0 in by correct idx */
- box_coords(search_current->end_box,
- &bounds.x1, &bounds.y1);
- /* \todo: move x1 in by correct idx */
- bounds.x1 += search_current->end_box->width;
- bounds.y1 += search_current->end_box->height;
- break;
-
- default:
- assert(c->type == CONTENT_TEXTPLAIN);
- textplain_coords_from_range(c,
- search_current->start_idx,
- search_current->end_idx, &bounds);
- break;
- }
-
- gui_window_scroll_visible(search_current_window,
- bounds.x0, bounds.y0, bounds.x1, bounds.y1);
}
-
-/**
- * Find the first occurrence of 'match' in 'string' and return its index
- *
- * /param string the string to be searched (unterminated)
- * /param s_len length of the string to be searched
- * /param pattern the pattern for which we are searching (unterminated)
- * /param p_len length of pattern
- * /param case_sens true iff case sensitive match required
- * /param m_len accepts length of match in bytes
- * /return pointer to first match, NULL if none
- */
-
-const char *find_pattern(const char *string, int s_len, const char *pattern,
- int p_len, bool case_sens, unsigned int *m_len)
+char *gui_search_get_string()
{
- struct { const char *ss, *s, *p; bool first; } context[16];
- const char *ep = pattern + p_len;
- const char *es = string + s_len;
- const char *p = pattern - 1; /* a virtual '*' before the pattern */
- const char *ss = string;
- const char *s = string;
- bool first = true;
- int top = 0;
-
- while (p < ep) {
- bool matches;
- if (p < pattern || *p == '*') {
- char ch;
-
- /* skip any further asterisks; one is the same as many */
- do p++; while (p < ep && *p == '*');
-
- /* if we're at the end of the pattern, yes, it matches */
- if (p >= ep) break;
-
- /* anything matches a # so continue matching from
- here, and stack a context that will try to match
- the wildcard against the next character */
-
- ch = *p;
- if (ch != '#') {
- /* scan forwards until we find a match for this char */
- if (!case_sens) ch = toupper(ch);
- while (s < es) {
- if (case_sens) {
- if (*s == ch) break;
- } else if (toupper(*s) == ch)
- break;
- s++;
- }
- }
-
- if (s < es) {
- /* remember where we are in case the match fails;
- we can then resume */
- if (top < (int)NOF_ELEMENTS(context)) {
- context[top].ss = ss;
- context[top].s = s + 1;
- context[top].p = p - 1; /* ptr to last asterisk */
- context[top].first = first;
- top++;
- }
-
- if (first) {
- ss = s; /* remember first non-'*' char */
- first = false;
- }
-
- matches = true;
- }
- else
- matches = false;
- }
- else if (s < es) {
- char ch = *p;
- if (ch == '#')
- matches = true;
- else {
- if (case_sens)
- matches = (*s == ch);
- else
- matches = (toupper(*s) == toupper(ch));
- }
- if (matches && first) {
- ss = s; /* remember first non-'*' char */
- first = false;
- }
- }
- else
- matches = false;
-
- if (matches) {
- p++; s++;
- }
- else {
- /* doesn't match, resume with stacked context if we have one */
- if (--top < 0) return NULL; /* no match, give up */
-
- ss = context[top].ss;
- s = context[top].s;
- p = context[top].p;
- first = context[top].first;
- }
- }
-
- /* end of pattern reached */
- *m_len = max(s - ss, 1);
- return ss;
+ return strdup(ro_gui_get_icon_string(dialog_search, ICON_SEARCH_TEXT));
}
-
-/**
- * Finds all occurrences of a given string in the html box tree
- *
- * \param pattern the string pattern to search for
- * \param p_len pattern length
- * \param cur pointer to the current box
- * \param case_sens whether to perform a case sensitive search
- * \return true on success, false on memory allocation failure
- */
-bool find_occurrences_html(const char *pattern, int p_len, struct box *cur,
- bool case_sens)
+void gui_search_set_forward_state(bool inactive)
{
- struct box *a;
-
- /* ignore this box, if there's no visible text */
- if (!cur->object && cur->text) {
- const char *text = cur->text;
- unsigned length = cur->length;
-
- while (length > 0) {
- struct list_entry *entry;
- unsigned match_length;
- unsigned match_offset;
- const char *new_text;
- const char *pos = find_pattern(text, length,
- pattern, p_len, case_sens,
- &match_length);
- if (!pos) break;
-
- /* found string in box => add to list */
- match_offset = pos - cur->text;
-
- entry = add_entry(cur->byte_offset + match_offset,
- cur->byte_offset +
- match_offset +
- match_length);
- if (!entry)
- return false;
-
- entry->start_box = cur;
- entry->end_box = cur;
-
- new_text = pos + match_length;
- length -= (new_text - text);
- text = new_text;
- }
- }
-
- /* and recurse */
- for (a = cur->children; a; a = a->next) {
- if (!find_occurrences_html(pattern, p_len, a, case_sens))
- return false;
- }
-
- return true;
+ ro_gui_set_icon_shaded_state(dialog_search, ICON_SEARCH_FIND_PREV,
+ inactive);
}
-
-/**
- * Finds all occurrences of a given string in a textplain content
- *
- * \param pattern the string pattern to search for
- * \param p_len pattern length
- * \param c the content to be searched
- * \param case_sens wheteher to perform a case sensitive search
- * \return true on success, false on memory allocation failure
- */
-
-bool find_occurrences_text(const char *pattern, int p_len,
- struct content *c, bool case_sens)
+void gui_search_set_back_state(bool inactive)
{
- int nlines = textplain_line_count(c);
- int line;
-
- for(line = 0; line < nlines; line++) {
- size_t offset, length;
- const char *text = textplain_get_line(c, line,
- &offset, &length);
- if (text) {
- while (length > 0) {
- struct list_entry *entry;
- unsigned match_length;
- size_t start_idx;
- const char *new_text;
- const char *pos = find_pattern(text, length,
- pattern, p_len, case_sens,
- &match_length);
- if (!pos) break;
-
- /* found string in line => add to list */
- start_idx = offset + (pos - text);
- entry = add_entry(start_idx, start_idx +
- match_length);
- if (!entry)
- return false;
-
- new_text = pos + match_length;
- offset += (new_text - text);
- length -= (new_text - text);
- text = new_text;
- }
- }
- }
-
- return true;
+ ro_gui_set_icon_shaded_state(dialog_search, ICON_SEARCH_FIND_NEXT,
+ inactive);
}
-
-/**
- * Add a new entry to the list of matches
- *
- * \param start_idx offset of match start within textual representation
- * \param end_idx offset of match end
- * \return pointer to added entry, NULL iff failed
- */
-
-struct list_entry *add_entry(unsigned start_idx, unsigned end_idx)
+bool gui_search_get_case_sens()
{
- struct list_entry *entry;
-
- /* found string in box => add to list */
- entry = calloc(1, sizeof(*entry));
- if (!entry) {
- warn_user("NoMemory", 0);
- return NULL;
- }
-
- entry->start_idx = start_idx;
- entry->end_idx = end_idx;
- entry->sel = NULL;
-
- entry->next = 0;
- entry->prev = search_found->prev;
- if (!search_found->prev)
- search_found->next = entry;
- else
- search_found->prev->next = entry;
- search_found->prev = entry;
-
- return entry;
+ return ro_gui_get_icon_selected_state(dialog_search,
+ ICON_SEARCH_CASE_SENSITIVE);
}
-
-/**
- * Determines whether any portion of the given text box should be
- * selected because it matches the current search string.
- *
- * \param g gui window
-Â * \param start_offset byte offset within text of string to be checked
- * \param end_offset byte offset within text
- * \param start_idx byte offset within string of highlight start
- * \param end_idx byte offset of highlight end
- * \return true iff part of the box should be highlighted
- */
-
-bool gui_search_term_highlighted(struct gui_window *g,
- unsigned start_offset, unsigned end_offset,
- unsigned *start_idx, unsigned *end_idx)
+bool gui_search_get_show_all()
{
- if (g == search_current_window) {
- struct list_entry *a;
- for(a = search_found->next; a; a = a->next)
- if (a->sel && selection_defined(a->sel) &&
- selection_highlighted(a->sel,
- start_offset, end_offset,
- start_idx, end_idx))
- return true;
- }
-
- return false;
+ return ro_gui_get_icon_selected_state(dialog_search,
+ ICON_SEARCH_SHOW_ALL);
}
-
-
-/**
- * Specifies whether all matches or just the current match should
- * be highlighted in the search text.
- */
-
-void show_all(bool all)
-{
- struct list_entry *a;
-
- for (a = search_found->next; a; a = a->next) {
- bool add = true;
- if (!all && a != search_current) {
- add = false;
- if (a->sel) {
- selection_clear(a->sel, true);
- selection_destroy(a->sel);
- a->sel = NULL;
- }
- }
- if (add && !a->sel) {
- a->sel = selection_create(search_current_window->bw);
- if (a->sel) {
- struct content *c = search_current_window->bw->current_content;
- switch (c->type) {
- case CONTENT_HTML:
- selection_init(a->sel,
- c->data.html.layout);
- break;
- default:
- assert(c->type ==
- CONTENT_TEXTPLAIN);
- selection_init(a->sel, NULL);
- break;
- }
- selection_set_start(a->sel, a->start_idx);
- selection_set_end(a->sel, a->end_idx);
- }
- }
- }
-}
-
-
-/**
- * Change the displayed search status.
- *
- * \param found search pattern matched in text
- */
-
-void show_status(bool found)
-{
- ro_gui_set_icon_string(dialog_search, ICON_SEARCH_STATUS,
- found ? "" : messages_get("NotFound"), true);
-}
-
Index: riscos/window.c
===================================================================
--- riscos/window.c (revision 8438)
+++ riscos/window.c (working copy)
@@ -1104,8 +1104,21 @@
}
}
+/**
+ * set favicon
+ */
+void gui_window_set_icon(struct gui_window *g, struct content *icon)
+{
+}
/**
+ * set the search provider icon from global cache struct content *search_ico
+ */
+void gui_window_set_search_ico()
+{
+}
+
+/**
* Place the caret in a browser window.
*
* \param g window with caret
Index: desktop/options.h
===================================================================
--- desktop/options.h (revision 8438)
+++ desktop/options.h (working copy)
@@ -70,6 +70,8 @@
extern char *option_cookie_file;
extern char *option_cookie_jar;
extern char *option_homepage_url;
+extern bool option_search_url_bar;
+extern int option_search_provider;
extern bool option_target_blank;
extern bool option_button_2_tab;
extern bool option_url_suggestion;
Index: desktop/browser.c
===================================================================
--- desktop/browser.c (revision 8438)
+++ desktop/browser.c (working copy)
@@ -85,6 +85,7 @@
static void browser_window_convert_to_download(struct browser_window *bw);
static void browser_window_start_throbber(struct browser_window *bw);
static void browser_window_stop_throbber(struct browser_window *bw);
+static void browser_window_set_icon(struct browser_window *bw);
static void browser_window_set_status(struct browser_window *bw,
const char *text);
static void browser_window_set_pointer(struct gui_window *g,
@@ -167,6 +168,23 @@
if (url)
browser_window_go(bw, url, referer, history_add);
+ else {
+ LOG(("creating blank content"));
+ struct content *c = content_create(" ");
+ const char *params[] = { 0 };
+ int length;
+ const char *blankcontent = "<html><head><title>blank page \
+ </title></head><body></body></html>";
+ length = strlen(blankcontent);
+ if (content_set_type(c, CONTENT_HTML, "text/html", params)
+ && content_process_data(c, blankcontent,
+ length)) {
+ /* here need to retrieve width, height from browser */
+ content_convert(c, c->width, c->height);
+ c->fresh = false;
+ }
+ }
+
return bw;
}
@@ -491,6 +509,7 @@
browser_window_update(bw, false);
browser_window_set_status(bw, c->status_message);
browser_window_stop_throbber(bw);
+ browser_window_set_icon(bw);
history_update(bw->history, c);
hotlist_visited(c);
free(bw->referer);
@@ -764,6 +783,21 @@
return false;
}
+/**
+ * when ready, set icon at top level
+ * \param bw browser_window
+ * current implementation ignores lower-levels' link rels completely
+ */
+void browser_window_set_icon(struct browser_window *bw)
+{
+ while (bw->parent)
+ bw = bw->parent;
+ if ((bw->current_content != NULL) && (bw->current_content->type ==
CONTENT_HTML))
+ gui_window_set_icon(bw->window,
+ bw->current_content->data.html.favicon);
+ else
+ gui_window_set_icon(bw->window, NULL);
+}
/**
* Redraw browser window, set extent to content, and update title.
Index: desktop/browser.h
===================================================================
--- desktop/browser.h (revision 8438)
+++ desktop/browser.h (working copy)
@@ -213,6 +213,7 @@
extern struct browser_window *current_redraw_browser;
+extern struct browser_window *search_current_window;
extern bool browser_reformat_pending;
struct browser_window * browser_window_create(const char *url,
Index: desktop/gui.h
===================================================================
--- desktop/gui.h (revision 8438)
+++ desktop/gui.h (working copy)
@@ -57,8 +57,6 @@
#include "content/content.h"
#include "desktop/browser.h"
-extern struct gui_window *search_current_window;
-
void gui_init(int argc, char** argv);
void gui_init2(int argc, char** argv);
void gui_multitask(void);
@@ -67,6 +65,7 @@
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone, bool new_tab);
+struct browser_window *gui_window_get_browser_window(struct gui_window *g);
void gui_window_destroy(struct gui_window *g);
void gui_window_set_title(struct gui_window *g, const char *title);
void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1);
@@ -88,6 +87,8 @@
void gui_window_set_url(struct gui_window *g, const char *url);
void gui_window_start_throbber(struct gui_window *g);
void gui_window_stop_throbber(struct gui_window *g);
+void gui_window_set_icon(struct gui_window *g, struct content *icon);
+void gui_window_set_search_ico(void);
void gui_window_place_caret(struct gui_window *g, int x, int y, int height);
void gui_window_remove_caret(struct gui_window *g);
void gui_window_new_content(struct gui_window *g);
Index: desktop/options.c
===================================================================
--- desktop/options.c (revision 8438)
+++ desktop/options.c (working copy)
@@ -110,12 +110,16 @@
char *option_ca_path = 0;
/** Cookie file location */
char *option_cookie_file = 0;
-/** Cookie jar loaction */
+/** Cookie jar location */
char *option_cookie_jar = 0;
/** Home page location */
char *option_homepage_url = 0;
+/** search web from url bar */
+bool option_search_url_bar = false;
/** URL completion in url bar */
bool option_url_suggestion = true;
+/** default web search provider */
+int option_search_provider = 0;
/** default x position of new windows */
int option_window_x = 0;
/** default y position of new windows */
@@ -229,6 +233,8 @@
{ "cookie_file", OPTION_STRING, &option_cookie_file },
{ "cookie_jar", OPTION_STRING, &option_cookie_jar },
{ "homepage_url", OPTION_STRING, &option_homepage_url },
+ { "search_url_bar", OPTION_BOOL, &option_search_url_bar},
+ { "search_provider", OPTION_INTEGER, &option_search_provider},
{ "url_suggestion", OPTION_BOOL, &option_url_suggestion },
{ "window_x", OPTION_INTEGER, &option_window_x },
{ "window_y", OPTION_INTEGER, &option_window_y },
Index: content/content.c
===================================================================
--- content/content.c (revision 8438)
+++ content/content.c (working copy)
@@ -155,6 +155,9 @@
{"image/svg", CONTENT_SVG},
{"image/svg+xml", CONTENT_SVG},
#endif
+#ifdef WITH_BMP
+ {"image/vnd.microsoft.icon", CONTENT_ICO},
+#endif
#ifdef WITH_ARTWORKS
{"image/x-artworks", CONTENT_ARTWORKS},
#endif
Index: content/fetchcache.c
===================================================================
--- content/fetchcache.c (revision 8438)
+++ content/fetchcache.c (working copy)
@@ -37,6 +37,8 @@
#include "content/content.h"
#include "content/fetchcache.h"
#include "content/fetch.h"
+#include "desktop/options.h"
+#include "desktop/searchweb.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/talloc.h"
@@ -52,6 +54,7 @@
static void fetchcache_parse_header(struct content *c, const char *data,
size_t size);
static void fetchcache_error_page(struct content *c, const char *error);
+static void fetchcache_search_redirect(struct content *c, const char *error);
static void fetchcache_cache_update(struct content *c);
static void fetchcache_cache_clone(struct content *c,
const struct cache_data *data);
@@ -720,17 +723,31 @@
/**
- * Generate an error page.
- *
+ * Generate an error page. Optionally redirect to web search provider
* \param c empty content to generate the page in
* \param error message to display
*/
-void fetchcache_error_page(struct content *c, const char *error)
+void fetchcache_error_page(struct content *c, const char
+ *error)
{
const char *params[] = { 0 };
int length;
+ char *host;
+ char checkmessage[24];
+ if (option_search_url_bar)
+ /* get the start of the error message for comparison
+ * the potential error message we're identifying is derived
+ * directly from libcurl, so hopefully no need for I18n */
+ snprintf(checkmessage, 24, "%s", error);
+ if (((url_host(c->url, &host) != URL_FUNC_OK) || (strcasecmp(host,
+ search_web_provider_host())!= 0)) &&
+ (strcasecmp(checkmessage, "couldn't resolve host '")
+ == 0)) {
+ fetchcache_search_redirect(c, error);
+ return;
+ }
if ((length = snprintf(error_page, sizeof(error_page),
messages_get("ErrorPage"), error)) < 0)
length = 0;
@@ -745,7 +762,81 @@
c->fresh = false;
}
+void fetchcache_search_redirect(struct content *c, const char *error)
+{
+ char *redirurl, *temp;
+ bool can_fetch;
+ union content_msg_data msg_data;
+ /* clear http:// plus trailing / from url, it is already escaped */
+ temp = strdup(c->url + SLEN("http://"));
+ temp[strlen(temp)-1] = '\0';
+ redirurl = search_web_get_url(temp);
+
+ /* logic borrowed from fetchcache_redirect() */
+ /* check there's a fetch handler */
+ can_fetch = fetch_can_fetch(redirurl);
+
+ /* Process users of this content */
+ while (c->user_list->next) {
+ intptr_t p1, p2;
+ void (*callback)(content_msg msg,
+ struct content *c, intptr_t p1,
+ intptr_t p2,
+ union content_msg_data data);
+ struct content *replacement;
+
+ p1 = c->user_list->next->p1;
+ p2 = c->user_list->next->p2;
+ callback = c->user_list->next->callback;
+
+ /* If we can't fetch the url, attempt to launch it */
+ if (!can_fetch) {
+ msg_data.launch_url = redirurl;
+ callback(CONTENT_MSG_LAUNCH, c, p1, p2,
+ msg_data);
+ }
+
+ /* Remove user */
+ content_remove_user(c, callback, p1, p2);
+
+ if (can_fetch) {
+ replacement = fetchcache(redirurl, callback,
+ p1, p2,
+ c->width, c->height,
+ c->no_error_pages,
+ NULL, NULL, false,
+ c->download);
+ if (!replacement) {
+ msg_data.error = messages_get(
+ "BadRedirect");
+ content_broadcast(c, CONTENT_MSG_ERROR,
+ msg_data);
+
+ free(redirurl);
+ return;
+ }
+
+ /* Set replacement's redirect count to 1
+ * greater than ours */
+ replacement->redirect_count = c->redirect_count
+ + 1;
+
+ /* Notify user that content has changed */
+ msg_data.new_url = redirurl;
+ callback(CONTENT_MSG_NEWPTR, replacement,
+ p1, p2, msg_data);
+
+ /* Start fetching the replacement content */
+ fetchcache_go(replacement, NULL, callback, p1,
+ p2, c->width, c->height, NULL,
+ NULL, false, redirurl);
+ }
+ }
+ free(redirurl);
+ return;
+}
+
/**
* Update a content's cache state
*
Index: Makefile
===================================================================
--- Makefile (revision 8438)
+++ Makefile (working copy)
@@ -109,6 +109,11 @@
# Override this only if the host compiler is called something different
HOST_CC := gcc
+ifeq ($(TARGET),amiga)
+ ifneq ($(HOST),amiga)
+ CC := ppc-amigaos-gcc
+ endif
+endif
ifeq ($(TARGET),riscos)
ifeq ($(HOST),riscos)
@@ -748,10 +753,13 @@
@cp -vRL gtk/res/Aliases $(DESTDIR)$(NETSURF_GTK_RESOURCES)
@cp -vrL gtk/res/docs $(DESTDIR)/$(NETSURF_GTK_RESOURCES)
gzip -9v < gtk/res/messages > $(DESTDIR)$(NETSURF_GTK_RESOURCES)messages
+ gzip -9v < gtk/res/SearchEngines >
$(DESTDIR)$(NETSURF_GTK_RESOURCES)SearchEngines
gzip -9v < gtk/res/downloads.glade >
$(DESTDIR)$(NETSURF_GTK_RESOURCES)downloads.glade
gzip -9v < gtk/res/netsurf.glade >
$(DESTDIR)$(NETSURF_GTK_RESOURCES)netsurf.glade
gzip -9v < gtk/res/options.glade >
$(DESTDIR)$(NETSURF_GTK_RESOURCES)options.glade
gzip -9v < gtk/res/history.glade >
$(DESTDIR)$(NETSURF_GTK_RESOURCES)history.glade
+ gzip -9v < gtk/res/toolbar.glade >
+ $(DESTDIR)$(NETSURF_GTK_RESOURCES)toolbar.glade
gzip -9v < gtk/res/source.glade > $(DESTDIR)$(NETSURF_GTK_RESOURCES)source.glade
install-beos: NetSurf
Index: amiga/menu.c
===================================================================
--- amiga/menu.c (revision 8438)
+++ amiga/menu.c (working copy)
@@ -30,13 +30,13 @@
#include "amiga/save_pdf.h"
#include "desktop/save_text.h"
#include "desktop/save_pdf/pdf_plotters.h"
+#include "desktop/save_complete.h"
#include <string.h>
#include "amiga/tree.h"
#include "amiga/history.h"
#include "amiga/cookies.h"
#include <proto/exec.h>
#include "amiga/arexx.h"
-#include "amiga/save_complete.h"
#include "utils/url.h"
#include <dos/anchorpath.h>
#include "desktop/textinput.h"
Index: amiga/search.c
===================================================================
--- amiga/search.c (revision 8438)
+++ amiga/search.c (working copy)
@@ -28,6 +28,7 @@
#include "content/content.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
+#include "desktop/search.h"
#include "desktop/selection.h"
#include "render/box.h"
#include "render/html.h"
@@ -44,10 +45,12 @@
#include <proto/string.h>
#include <proto/button.h>
#include <proto/label.h>
+#include <proto/checkbox.h>
#include <classes/window.h>
#include <gadgets/layout.h>
#include <gadgets/string.h>
#include <gadgets/button.h>
+#include <gadgets/checkbox.h>
#include <images/label.h>
#include <reaction/reaction_macros.h>
@@ -68,595 +71,18 @@
struct list_entry *next;
};
-struct gui_window *search_current_window = NULL;
+/* put new search_web globals here for now */
+char *search_engines_file_location;
+char *search_default_ico_location;
-static char *search_string = NULL;
-static struct list_entry search_head = { 0, 0, NULL, NULL, NULL, NULL, NULL };
-static struct list_entry *search_found = &search_head;
-static struct list_entry *search_current = NULL;
-static struct content *search_content = NULL;
-static bool search_prev_case_sens = false;
static struct find_window *fwin = NULL;
-#define RECENT_SEARCHES 8
-bool search_insert;
-static char *recent_search[RECENT_SEARCHES];
-static void start_search(bool forwards,char *search_string);
-static void do_search(char *string, int string_len, bool case_sens,
- bool forwards);
-static const char *find_pattern(const char *string, int s_len,
- const char *pattern, int p_len, bool case_sens, int *m_len);
-static bool find_occurrences_html(const char *pattern, int p_len,
- struct box *cur, bool case_sens);
-static bool find_occurrences_text(const char *pattern, int p_len,
- struct content *c, bool case_sens);
-static struct list_entry *add_entry(unsigned start_idx, unsigned end_idx);
-static void free_matches(void);
-static void show_all(bool all);
-static void show_status(bool found);
-
/**
- * Begins/continues the search process
- * Note that this may be called many times for a single search.
- *
- * \param forwards search forwards from start/current position
- */
-
-void start_search(bool forwards,char *string)
-{
- int string_len;
- int i = 0;
-
- string_len = strlen(string);
- for(i = 0; i < string_len; i++)
- if (string[i] != '#' && string[i] != '*') break;
- if (i >= string_len) {
- free_matches();
- show_status(true);
-
- RefreshSetGadgetAttrs(fwin->gadgets[GID_PREV],fwin->win,NULL,
- GA_Disabled,TRUE,
- TAG_DONE);
-
- RefreshSetGadgetAttrs(fwin->gadgets[GID_NEXT],fwin->win,NULL,
- GA_Disabled,TRUE,
- TAG_DONE);
-
- gui_window_set_scroll(search_current_window, 0, 0);
- return;
- }
-
- do_search(string, string_len,
- false, // case sensitivity
- forwards);
-}
-
-/**
- * Ends the search process, invalidating all global state and
- * freeing the list of found boxes
- *
- * \param w the search window handle (not used)
- */
-void ami_gui_search_end(void)
-{
- search_current_window = 0;
-
- if (search_string) {
- //ro_gui_search_add_recent(search_string);
- free(search_string);
- }
- search_string = 0;
-
- free_matches();
-
- search_current = 0;
-
- search_content = 0;
-
- search_prev_case_sens = false;
-}
-
-
-/**
- * Release the memory used by the list of matches,
- * deleting selection objects too
- */
-
-void free_matches(void)
-{
- struct list_entry *a = search_found->next;
- struct list_entry *b;
-
- /* empty the list before clearing and deleting the
- selections because the the clearing updates the
- screen immediately, causing nested accesses to the list */
-
- search_found->prev = 0;
- search_found->next = 0;
-
- for (; a; a = b) {
- b = a->next;
- if (a->sel) {
- selection_clear(a->sel, true);
- selection_destroy(a->sel);
- }
- free(a);
- }
-}
-
-
-/**
- * Search for a string in the box tree
- *
- * \param string the string to search for
- * \param string_len length of search string
- * \param case_sens whether to perform a case sensitive search
- * \param forwards direction to search in
- */
-void do_search(char *string, int string_len, bool case_sens, bool forwards)
-{
- struct rect bounds;
- struct content *c;
- struct box *box;
- bool new = false;
-
- if (!search_current_window)
- return;
-
- c = search_current_window->shared->bw->current_content;
-
- /* only handle html contents */
- if ((!c) || (c->type != CONTENT_HTML &&
- c->type != CONTENT_TEXTPLAIN))
- return;
-
- box = c->data.html.layout;
-
- if (!box)
- return;
-
-// LOG(("do_search '%s' - '%s' (%p, %p) %p (%d, %d) %d",
-// search_string, string, search_content, c, search_found->next,
-// search_prev_case_sens, case_sens, forwards));
-
- /* check if we need to start a new search or continue an old one */
- if (!search_string || c != search_content || !search_found->next ||
- search_prev_case_sens != case_sens ||
- (case_sens && strcmp(string, search_string) != 0) ||
- (!case_sens && strcasecmp(string, search_string) != 0)) {
- bool res;
-
- if (search_string)
- free(search_string);
- search_current = 0;
- free_matches();
-
- search_string = malloc(string_len + 1);
- if (search_string) {
- memcpy(search_string, string, string_len);
- search_string[string_len] = '\0';
- }
-
-// xhourglass_on();
-
- if (c->type == CONTENT_HTML)
- res = find_occurrences_html(string, string_len,
- box, case_sens);
- else {
- assert(c->type == CONTENT_TEXTPLAIN);
- res = find_occurrences_text(string, string_len,
- c, case_sens);
- }
-
- if (!res) {
- free_matches();
- //xhourglass_off();
- return;
- }
- //xhourglass_off();
-
- new = true;
- search_content = c;
- search_prev_case_sens = case_sens;
- }
-
-// LOG(("%d %p %p (%p, %p)", new, search_found->next, search_current,
search_current->prev, search_current->next));
-
- if (new) {
- /* new search, beginning at the top of the page */
- search_current = search_found->next;
- }
- else if (search_current) {
- /* continued search in the direction specified */
- if (forwards) {
- if (search_current->next)
- search_current = search_current->next;
- }
- else {
- if (search_current->prev)
- search_current = search_current->prev;
- }
- }
-
- show_status(search_current != NULL);
- show_all(false);
-
- RefreshSetGadgetAttrs(fwin->gadgets[GID_PREV],fwin->win,NULL,
- GA_Disabled,(!search_current || !search_current->prev),
- TAG_DONE);
-
- RefreshSetGadgetAttrs(fwin->gadgets[GID_NEXT],fwin->win,NULL,
- GA_Disabled,(!search_current || !search_current->next),
- TAG_DONE);
-
- if (!search_current)
- return;
-
- switch (c->type) {
- case CONTENT_HTML:
- /* get box position and jump to it */
- box_coords(search_current->start_box,
- &bounds.x0, &bounds.y0);
- /* \todo: move x0 in by correct idx */
- box_coords(search_current->end_box,
- &bounds.x1, &bounds.y1);
- /* \todo: move x1 in by correct idx */
- bounds.x1 += search_current->end_box->width;
- bounds.y1 += search_current->end_box->height;
- break;
-
- default:
- assert(c->type == CONTENT_TEXTPLAIN);
- textplain_coords_from_range(c,
- search_current->start_idx,
- search_current->end_idx, &bounds);
- break;
- }
-
- gui_window_scroll_visible(search_current_window,
- bounds.x0, bounds.y0, bounds.x1, bounds.y1);
-}
-
-
-/**
- * Find the first occurrence of 'match' in 'string' and return its index
- *
- * /param string the string to be searched (unterminated)
- * /param s_len length of the string to be searched
- * /param pattern the pattern for which we are searching (unterminated)
- * /param p_len length of pattern
- * /param case_sens true iff case sensitive match required
- * /param m_len accepts length of match in bytes
- * /return pointer to first match, NULL if none
- */
-
-const char *find_pattern(const char *string, int s_len, const char *pattern,
- int p_len, bool case_sens, int *m_len)
-{
- struct { const char *ss, *s, *p; bool first; } context[16];
- const char *ep = pattern + p_len;
- const char *es = string + s_len;
- const char *p = pattern - 1; /* a virtual '*' before the pattern */
- const char *ss = string;
- const char *s = string;
- bool first = true;
- int top = 0;
-
- while (p < ep) {
- bool matches;
- if (p < pattern || *p == '*') {
- char ch;
-
- /* skip any further asterisks; one is the same as many */
- do p++; while (p < ep && *p == '*');
-
- /* if we're at the end of the pattern, yes, it matches */
- if (p >= ep) break;
-
- /* anything matches a # so continue matching from
- here, and stack a context that will try to match
- the wildcard against the next character */
-
- ch = *p;
- if (ch != '#') {
- /* scan forwards until we find a match for this char */
- if (!case_sens) ch = toupper(ch);
- while (s < es) {
- if (case_sens) {
- if (*s == ch) break;
- } else if (toupper(*s) == ch)
- break;
- s++;
- }
- }
-
- if (s < es) {
- /* remember where we are in case the match fails;
- we can then resume */
- if (top < (int)NOF_ELEMENTS(context)) {
- context[top].ss = ss;
- context[top].s = s + 1;
- context[top].p = p - 1; /* ptr to last asterisk */
- context[top].first = first;
- top++;
- }
-
- if (first) {
- ss = s; /* remember first non-'*' char */
- first = false;
- }
-
- matches = true;
- }
- else
- matches = false;
- }
- else if (s < es) {
- char ch = *p;
- if (ch == '#')
- matches = true;
- else {
- if (case_sens)
- matches = (*s == ch);
- else
- matches = (toupper(*s) == toupper(ch));
- }
- if (matches && first) {
- ss = s; /* remember first non-'*' char */
- first = false;
- }
- }
- else
- matches = false;
-
- if (matches) {
- p++; s++;
- }
- else {
- /* doesn't match, resume with stacked context if we have one */
- if (--top < 0) return NULL; /* no match, give up */
-
- ss = context[top].ss;
- s = context[top].s;
- p = context[top].p;
- first = context[top].first;
- }
- }
-
- /* end of pattern reached */
- *m_len = max(s - ss, 1);
- return ss;
-}
-
-
-/**
- * Finds all occurrences of a given string in the html box tree
- *
- * \param pattern the string pattern to search for
- * \param p_len pattern length
- * \param cur pointer to the current box
- * \param case_sens whether to perform a case sensitive search
- * \return true on success, false on memory allocation failure
- */
-bool find_occurrences_html(const char *pattern, int p_len, struct box *cur,
- bool case_sens)
-{
- struct box *a;
-
- /* ignore this box, if there's no visible text */
- if (!cur->object && cur->text) {
- const char *text = cur->text;
- unsigned length = cur->length;
-
- while (length > 0) {
- struct list_entry *entry;
- unsigned match_length;
- unsigned match_offset;
- const char *new_text;
- const char *pos = find_pattern(text, length,
- pattern, p_len, case_sens,
- &match_length);
- if (!pos) break;
-
- /* found string in box => add to list */
- match_offset = pos - cur->text;
-
- entry = add_entry(cur->byte_offset + match_offset,
- cur->byte_offset +
- match_offset +
- match_length);
- if (!entry)
- return false;
-
- entry->start_box = cur;
- entry->end_box = cur;
-
- new_text = pos + match_length;
- length -= (new_text - text);
- text = new_text;
- }
- }
-
- /* and recurse */
- for (a = cur->children; a; a = a->next) {
- if (!find_occurrences_html(pattern, p_len, a, case_sens))
- return false;
- }
-
- return true;
-}
-
-
-/**
- * Finds all occurrences of a given string in a textplain content
- *
- * \param pattern the string pattern to search for
- * \param p_len pattern length
- * \param c the content to be searched
- * \param case_sens wheteher to perform a case sensitive search
- * \return true on success, false on memory allocation failure
- */
-
-bool find_occurrences_text(const char *pattern, int p_len,
- struct content *c, bool case_sens)
-{
- int nlines = textplain_line_count(c);
- int line;
-
- for(line = 0; line < nlines; line++) {
- size_t offset, length;
- const char *text = textplain_get_line(c, line,
- &offset, &length);
- if (text) {
- while (length > 0) {
- struct list_entry *entry;
- unsigned match_length;
- size_t start_idx;
- const char *new_text;
- const char *pos = find_pattern(text, length,
- pattern, p_len, case_sens,
- &match_length);
- if (!pos) break;
-
- /* found string in line => add to list */
- start_idx = offset + (pos - text);
- entry = add_entry(start_idx, start_idx +
- match_length);
- if (!entry)
- return false;
-
- new_text = pos + match_length;
- offset += (new_text - text);
- length -= (new_text - text);
- text = new_text;
- }
- }
- }
-
- return true;
-}
-
-
-/**
- * Add a new entry to the list of matches
- *
- * \param start_idx offset of match start within textual representation
- * \param end_idx offset of match end
- * \return pointer to added entry, NULL iff failed
- */
-
-struct list_entry *add_entry(unsigned start_idx, unsigned end_idx)
-{
- struct list_entry *entry;
-
- /* found string in box => add to list */
- entry = calloc(1, sizeof(*entry));
- if (!entry) {
- warn_user("NoMemory", 0);
- return NULL;
- }
-
- entry->start_idx = start_idx;
- entry->end_idx = end_idx;
- entry->sel = NULL;
-
- entry->next = 0;
- entry->prev = search_found->prev;
- if (!search_found->prev)
- search_found->next = entry;
- else
- search_found->prev->next = entry;
- search_found->prev = entry;
-
- return entry;
-}
-
-
-/**
- * Determines whether any portion of the given text box should be
- * selected because it matches the current search string.
- *
- * \param g gui window
-Â * \param start_offset byte offset within text of string to be checked
- * \param end_offset byte offset within text
- * \param start_idx byte offset within string of highlight start
- * \param end_idx byte offset of highlight end
- * \return true iff part of the box should be highlighted
- */
-
-bool gui_search_term_highlighted(struct gui_window *g,
- unsigned start_offset, unsigned end_offset,
- unsigned *start_idx, unsigned *end_idx)
-{
- if (g == search_current_window) {
- struct list_entry *a;
- for(a = search_found->next; a; a = a->next)
- if (a->sel && selection_defined(a->sel) &&
- selection_highlighted(a->sel,
- start_offset, end_offset,
- start_idx, end_idx))
- return true;
- }
-
- return false;
-}
-
-
-/**
- * Specifies whether all matches or just the current match should
- * be highlighted in the search text.
- */
-
-void show_all(bool all)
-{
- struct list_entry *a;
-
- for (a = search_found->next; a; a = a->next) {
- bool add = true;
- if (!all && a != search_current) {
- add = false;
- if (a->sel) {
- selection_clear(a->sel, true);
- selection_destroy(a->sel);
- a->sel = NULL;
- }
- }
- if (add && !a->sel) {
- a->sel = selection_create(search_current_window->shared->bw);
- if (a->sel) {
- struct content *c = search_current_window->shared->bw->current_content;
- switch (c->type) {
- case CONTENT_HTML:
- selection_init(a->sel,
- c->data.html.layout);
- break;
- default:
- assert(c->type ==
- CONTENT_TEXTPLAIN);
- selection_init(a->sel, NULL);
- break;
- }
- selection_set_start(a->sel, a->start_idx);
- selection_set_end(a->sel, a->end_idx);
- }
- }
- }
-}
-
-
-/**
* Change the displayed search status.
*
* \param found search pattern matched in text
*/
-void show_status(bool found)
-{
-/*
- ro_gui_set_icon_string(dialog_search, ICON_SEARCH_STATUS,
- found ? "" : messages_get("NotFound"), true);
-*/
-}
void ami_search_open(struct gui_window *gwin)
{
@@ -667,12 +93,12 @@
c->type != CONTENT_TEXTPLAIN))
return;
- search_current_window = gwin;
+ search_current_window = gwin->shared->bw;
search_insert = true;
if(fwin)
{
- ami_gui_search_end();
+ search_end();
fwin->gwin->shared->searchwin = NULL;
fwin->gwin = gwin;
gwin->shared->searchwin = fwin;
@@ -709,6 +135,21 @@
LabelEnd,
*/
CHILD_WeightedHeight,0,
+ LAYOUT_AddChild, fwin->gadgets[GID_CASE] = CheckBoxObject,
+ GA_ID,GID_CASE,
+ GA_Text,messages_get("CaseSensitive"),
+ GA_Selected,FALSE,
+ GA_TabCycle,TRUE,
+ GA_RelVerify,TRUE,
+ CheckBoxEnd,
+ LAYOUT_AddChild, fwin->gadgets[GID_SHOWALL] = CheckBoxObject,
+ GA_ID,GID_SHOWALL,
+ GA_Text,messages_get("ShowAll"),
+ GA_Selected,FALSE,
+ GA_TabCycle,TRUE,
+ GA_RelVerify,TRUE,
+ CheckBoxEnd,
+
LAYOUT_AddChild, HGroupObject,
LAYOUT_AddChild, fwin->gadgets[GID_PREV] = ButtonObject,
GA_ID,GID_PREV,
@@ -739,7 +180,7 @@
void ami_search_close(void)
{
- ami_gui_search_end();
+ search_end();
fwin->gwin->shared->searchwin = NULL;
DisposeObject(fwin->objects[OID_MAIN]);
DelObject(fwin->node);
@@ -752,7 +193,6 @@
ULONG class,result,relevent = 0;
ULONG column;
uint16 code;
- char *text;
while((result = RA_HandleInput(fwin->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
{
@@ -763,14 +203,12 @@
{
case GID_NEXT:
search_insert = true;
- GetAttr(STRINGA_TextVal,fwin->gadgets[GID_SEARCHSTRING],(ULONG *)&text);
- start_search(true,text);
+ start_search(true);
break;
case GID_PREV:
search_insert = true;
- GetAttr(STRINGA_TextVal,fwin->gadgets[GID_SEARCHSTRING],(ULONG *)&text);
- start_search(false,text);
+ start_search(false);
break;
case GID_SEARCHSTRING:
@@ -793,3 +231,57 @@
}
return FALSE;
}
+void gui_search_set_status(bool found)
+{
+}
+
+void gui_search_set_hourglass(bool active)
+{
+ SetWindowPointer(fwin->win,
+ WA_BusyPointer,active,
+ WA_PointerDelay,active,
+ TAG_DONE);
+}
+
+char *gui_search_get_string()
+{
+ char *text;
+ GetAttr(STRINGA_TextVal,fwin->gadgets[GID_SEARCHSTRING],(ULONG *)&text);
+ return text;
+
+}
+
+void gui_search_add_recent(const char *string)
+{
+}
+
+void gui_search_set_forward_state(bool inactive)
+{
+ RefreshSetGadgetAttrs(fwin->gadgets[GID_NEXT],fwin->win,NULL,
+ GA_Disabled, inactive ? TRUE : FALSE, TAG_DONE);
+
+}
+
+void gui_search_set_back_state(bool inactive)
+{
+ RefreshSetGadgetAttrs(fwin->gadgets[GID_PREV],fwin->win,NULL,
+ GA_Disabled,inactive ? TRUE : FALSE, TAG_DONE);
+}
+
+bool gui_search_get_case_sens()
+{
+ ULONG res;
+ GetAttr(GA_Selected,fwin->gadgets[GID_CASE],(ULONG *)&res);
+
+ if(res) return true;
+ else return false;
+}
+
+bool gui_search_get_show_all()
+{
+ ULONG res;
+ GetAttr(GA_Selected,fwin->gadgets[GID_SHOWALL],(ULONG *)&res);
+
+ if(res) return true;
+ else return false;
+}
Index: amiga/download.c
===================================================================
--- amiga/download.c (revision 8438)
+++ amiga/download.c (working copy)
@@ -29,13 +29,13 @@
#include "amiga/download.h"
#include "amiga/object.h"
#include "amiga/options.h"
-#include "amiga/save_complete.h"
#include "amiga/bitmap.h"
#include "amiga/iff_dr2d.h"
#include "content/fetch.h"
#include "desktop/selection.h"
+#include "desktop/save_complete.h"
#include "utils/messages.h"
#include "utils/utils.h"
Index: amiga/gui.c
===================================================================
--- amiga/gui.c (revision 8438)
+++ amiga/gui.c (working copy)
@@ -46,6 +46,7 @@
#include "amiga/menu.h"
#include "amiga/options.h"
#include <libraries/keymap.h>
+#include "desktop/save_complete.h"
#include "desktop/textinput.h"
#include <intuition/pointerclass.h>
#include <math.h>
@@ -65,7 +66,6 @@
#include "amiga/cookies.h"
#include "amiga/clipboard.h"
#include <proto/keymap.h>
-#include "amiga/save_complete.h"
#include "amiga/fetch_file.h"
#include "amiga/fetch_mailto.h"
#include "amiga/search.h"
@@ -2787,6 +2787,10 @@
g->shared->throbber_frame = 0;
}
+void gui_window_set_icon(struct gui_window *g, struct content *icon)
+{
+}
+
void ami_update_throbber(struct gui_window_2 *g,bool redraw)
{
struct IBox *bbox;
Index: amiga/save_complete.c
===================================================================
--- amiga/save_complete.c (revision 8438)
+++ amiga/save_complete.c (working copy)
@@ -2,6 +2,7 @@
* Copyright 2004 John M Bell <jmb202(a)ecs.soton.ac.uk>
* Copyright 2004-2007 James Bursa <bursa(a)users.sourceforge.net>
* Copyright 2008 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
*
* This file is part of NetSurf,
http://www.netsurf-browser.org/
*
@@ -18,804 +19,90 @@
* along with this program. If not, see <
http://www.gnu.org/licenses/>.
*/
-/** \file
- * Save HTML document with dependencies (implementation).
- */
-
-#include "utils/config.h"
-//#define _GNU_SOURCE /* for strndup */
-#include <assert.h>
#include <ctype.h>
-#include <errno.h>
#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
-#include <regex.h>
#include <libxml/HTMLtree.h>
-#include <libxml/parserInternals.h>
-#include "utils/config.h"
-#include "css/css.h"
-#include "render/box.h"
-#include "amiga/save_complete.h"
-#include "utils/log.h"
-#include "utils/url.h"
+#include "desktop/save_complete.h"
#include "utils/utils.h"
-#include <proto/dos.h>
#include <proto/icon.h>
#include <workbench/icon.h>
-regex_t save_complete_import_re;
-
-/** An entry in save_complete_list. */
-struct save_complete_entry {
- struct content *content;
- struct save_complete_entry *next; /**< Next entry in list */
-};
-
-/** List of urls seen and saved so far. */
-static struct save_complete_entry *save_complete_list = 0;
-
-static bool save_complete_html(struct content *c, const char *path,
- bool index);
-static bool save_imported_sheets(struct content *c, const char *path);
-static char * rewrite_stylesheet_urls(const char *source, unsigned int size,
- int *osize, const char *base);
-static bool rewrite_document_urls(xmlDoc *doc, const char *base);
-static bool rewrite_urls(xmlNode *n, const char *base);
-static bool rewrite_url(xmlNode *n, const char *attr, const char *base);
-static bool save_complete_list_add(struct content *content);
-static struct content * save_complete_list_find(const char *url);
-static bool save_complete_list_check(struct content *content);
-/* static void save_complete_list_dump(void); */
-static bool save_complete_inventory(const char *path);
-
-/**
- * Save an HTML page with all dependencies.
- *
- * \param c CONTENT_HTML to save
- * \param path directory to save to (must exist)
- * \return true on success, false on error and error reported
- */
-
-bool save_complete(struct content *c, const char *path)
+bool save_complete_gui_save(const char *path, const char *filename, struct content *c,
int len, char *sourcedata, int type)
{
- bool result;
-
- result = save_complete_html(c, path, true);
-
- if (result)
- result = save_complete_inventory(path);
-
- /* free save_complete_list */
- while (save_complete_list) {
- struct save_complete_entry *next = save_complete_list->next;
- free(save_complete_list);
- save_complete_list = next;
- }
-
- return result;
-}
-
-
-/**
- * Save an HTML page with all dependencies, recursing through imported pages.
- *
- * \param c CONTENT_HTML to save
- * \param path directory to save to (must exist)
- * \param index true to save as "index"
- * \return true on success, false on error and error reported
- */
-
-bool save_complete_html(struct content *c, const char *path, bool index)
-{
- char spath[256];
- unsigned int i;
- htmlParserCtxtPtr parser;
- BPTR fh = 0;
-
- if (c->type != CONTENT_HTML)
- return false;
-
- if (save_complete_list_check(c))
- return true;
-
- /* save stylesheets, ignoring the base and adblocking sheets */
- for (i = STYLESHEET_STYLE; i != c->data.html.stylesheet_count; i++) {
- struct content *css = c->data.html.stylesheet_content[i];
- char *source;
- int source_len;
-
- if (!css)
- continue;
- if (save_complete_list_check(css))
- continue;
-
- if (i != STYLESHEET_STYLE) {
- if (!save_complete_list_add(css)) {
- warn_user("NoMemory", 0);
- return false;
- }
- }
-
- if (!save_imported_sheets(css, path))
- return false;
-
- if (i == STYLESHEET_STYLE)
- continue; /* don't save <style> elements */
-
- snprintf(spath, sizeof spath, "%s/%x", path,
- (unsigned int) css);
- source = rewrite_stylesheet_urls(css->source_data,
- css->source_size, &source_len, css->url);
- if (!source) {
- warn_user("NoMemory", 0);
- return false;
- }
-
-/*
- error = xosfile_save_stamped(spath, 0xf79, source,
- source + source_len);
-*/
-
- if(fh = FOpen(spath,MODE_NEWFILE,0))
- {
- FWrite(fh,source,1,source_len);
- FClose(fh);
- SetComment(spath,c->url);
- }
-
- free(source);
-/*
- if (error) {
- LOG(("xosfile_save_stamped: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("SaveError", error->errmess);
- return false;
- }
-*/
- }
-
- /* save objects */
- for (i = 0; i != c->data.html.object_count; i++) {
- struct content *obj = c->data.html.object[i].content;
-
- /* skip difficult content types */
- if (!obj || obj->type >= CONTENT_OTHER || !obj->source_data)
- continue;
- if (save_complete_list_check(obj))
- continue;
-
- if (!save_complete_list_add(obj)) {
- warn_user("NoMemory", 0);
- return false;
- }
-
- if (obj->type == CONTENT_HTML) {
- if (!save_complete_html(obj, path, false))
- return false;
- continue;
- }
-
- snprintf(spath, sizeof spath, "%s/%x", path,
- (unsigned int) obj);
-/*
- error = xosfile_save_stamped(spath,
- ro_content_filetype(obj),
- obj->source_data,
- obj->source_data + obj->source_size);
- if (error) {
- LOG(("xosfile_save_stamped: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("SaveError", error->errmess);
- return false;
- }
-*/
- if(fh = FOpen(spath,MODE_NEWFILE,0))
- {
- FWrite(fh,obj->source_data,1,obj->source_size);
- FClose(fh);
- SetComment(spath,obj->url);
- }
-
- }
-
- /*save_complete_list_dump();*/
-
- /* make a copy of the document tree */
- parser = htmlCreateMemoryParserCtxt(c->source_data, c->source_size);
- if (!parser) {
+ int res;
+ int namelen;
+ namelen = strlen(path) + strlen(filename) + 2;
+ char *fullpath = malloc(namelen);
+ if (!fullpath) {
warn_user("NoMemory", 0);
return false;
}
- /* set parser charset */
- if (c->data.html.encoding) {
- xmlCharEncodingHandler *enc_handler;
- enc_handler =
- xmlFindCharEncodingHandler(c->data.html.encoding);
- if (enc_handler) {
- xmlCtxtResetLastError(parser);
- if (xmlSwitchToEncoding(parser, enc_handler)) {
- xmlFreeDoc(parser->myDoc);
- htmlFreeParserCtxt(parser);
- warn_user("MiscError",
- "Encoding switch failed");
- return false;
- }
- }
- }
-
- htmlParseDocument(parser);
-
- /* rewrite all urls we know about */
- if (!rewrite_document_urls(parser->myDoc, c->data.html.base_url)) {
- xmlFreeDoc(parser->myDoc);
- htmlFreeParserCtxt(parser);
- warn_user("NoMemory", 0);
+ snprintf(fullpath, namelen, "%s/%s", path, filename);
+ FILE *f = fopen(fullpath, "w"); /* may need mode 'b' when c != NULL
*/
+ free(fullpath);
+ if (f == NULL)
return false;
- }
-
- /* save the html file out last of all */
- if (index)
- {
- struct DiskObject *dobj = NULL;
-
- snprintf(spath, sizeof spath, "%s/index", path);
-
- dobj = GetIconTags(NULL,ICONGETA_GetDefaultName,"html",
- ICONGETA_GetDefaultType,WBPROJECT,
- TAG_DONE);
-
- PutIconTags(spath,dobj,
- ICONPUTA_NotifyWorkbench,TRUE,
- TAG_DONE);
- }
- else
- {
- snprintf(spath, sizeof spath, "%s/%x", path, (unsigned int)c);
- }
-
- errno = 0;
- if (htmlSaveFileFormat(spath, parser->myDoc, 0, 0) == -1) {
- if (errno)
- warn_user("SaveError", strerror(errno));
- else
- warn_user("SaveError", "htmlSaveFileFormat failed");
+ res = fwrite(sourcedata, len, 1, f);
+ fclose(f);
+ save_complete_gui_filetype(path, filename, type);
+ if (res != 1)
return false;
- }
-
-/*
- error = xosfile_set_type(spath, 0xfaf);
- if (error) {
- LOG(("xosfile_set_type: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("SaveError", error->errmess);
- return false;
- }
-*/
-
- xmlFreeDoc(parser->myDoc);
- htmlFreeParserCtxt(parser);
-
return true;
}
-
-/**
- * Save stylesheets imported by a CONTENT_CSS.
- *
- * \param c a CONTENT_CSS
- * \param path path to save to
- * \return true on success, false on error and error reported
- */
-
-bool save_imported_sheets(struct content *c, const char *path)
+int save_complete_htmlSaveFileFormat(const char *path, const char *filename,
+ xmlDocPtr cur, const char *encoding, int format)
{
- char spath[256];
- unsigned int j;
- char *source;
- int source_len;
- BPTR fh = 0;
-
- for (j = 0; j != c->data.css.import_count; j++) {
- struct content *css = c->data.css.import_content[j];
-
- if (!css)
- continue;
- if (save_complete_list_check(css))
- continue;
-
- if (!save_complete_list_add(css)) {
- warn_user("NoMemory", 0);
- return false;
- }
-
- if (!save_imported_sheets(css, path))
- return false;
-
- snprintf(spath, sizeof spath, "%s/%x", path,
- (unsigned int) css);
- source = rewrite_stylesheet_urls(css->source_data,
- css->source_size, &source_len, css->url);
- if (!source) {
- warn_user("NoMemory", 0);
- return false;
- }
-
- if(fh = FOpen(spath,MODE_NEWFILE,0))
- {
- FWrite(fh,source,1,source_len);
- FClose(fh);
- SetComment(spath,c->url);
- }
-/*
- error = xosfile_save_stamped(spath, 0xf79, source,
- source + source_len);
-*/
- free(source);
-/*
- if (error) {
- LOG(("xosfile_save_stamped: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("SaveError", error->errmess);
- return false;
- }
-*/
+ int ret;
+ int len = strlen(path) + strlen(filename) + 2;
+ char *finame = malloc(len);
+ if (!finame){
+ warn_user("NoMemory", 0);
+ return -1;
}
-
- return true;
+ snprintf(finame, len, "%s/%s", path, filename);
+ ret = htmlSaveFileFormat(finame, cur, encoding, format);
+ free(finame);
+ return ret;
}
-
-/**
- * Initialise the save_complete module.
- */
-
-void save_complete_init(void)
+bool save_complete_gui_filetype(const char *path, const char *filename,
+ int type)
{
- /* Match an @import rule - see CSS 2.1 G.1. */
- regcomp_wrapper(&save_complete_import_re,
- "@import" /* IMPORT_SYM */
- "[ \t\r\n\f]*" /* S* */
- /* 1 */
- "(" /* [ */
- /* 2 3 */
- "\"(([^\"]|[\\]\")*)\"" /* STRING (approximated) */
- "|"
- /* 4 5 */
- "'(([^']|[\\]')*)'"
- "|" /* | */
- "url\\([ \t\r\n\f]*" /* URI (approximated) */
- /* 6 7 */
- "\"(([^\"]|[\\]\")*)\""
- "[ \t\r\n\f]*\\)"
- "|"
- "url\\([ \t\r\n\f]*"
- /* 8 9 */
- "'(([^']|[\\]')*)'"
- "[ \t\r\n\f]*\\)"
- "|"
- "url\\([ \t\r\n\f]*"
- /* 10 */
- "([^) \t\r\n\f]*)"
- "[ \t\r\n\f]*\\)"
- ")", /* ] */
- REG_EXTENDED | REG_ICASE);
-}
-
-
-/**
- * Rewrite stylesheet \@import rules for save complete.
- *
- * @param source stylesheet source
- * @param size size of source
- * @param osize updated with the size of the result
- * @param base url of stylesheet
- * @return converted source, or 0 on out of memory
- */
-
-char * rewrite_stylesheet_urls(const char *source, unsigned int size,
- int *osize, const char *base)
-{
- char *res;
- const char *url;
- char *url2;
- char buf[20];
- unsigned int offset = 0;
- int url_len = 0;
- struct content *content;
- int m;
- unsigned int i;
- unsigned int imports = 0;
- regmatch_t match[11];
- url_func_result result;
-
- /* count number occurences of @import to (over)estimate result size */
- /* can't use strstr because source is not 0-terminated string */
- for (i = 0; 7 < size && i != size - 7; i++) {
- if (source[i] == '@' &&
- tolower(source[i + 1]) == 'i' &&
- tolower(source[i + 2]) == 'm' &&
- tolower(source[i + 3]) == 'p' &&
- tolower(source[i + 4]) == 'o' &&
- tolower(source[i + 5]) == 'r' &&
- tolower(source[i + 6]) == 't')
- imports++;
+ int ret;
+ char deftype[5];
+ struct DiskObject *dobj = NULL;
+ int len = strlen(path) + strlen(filename) + 2;
+ char *finame = malloc(len);
+ if (!finame){
+ warn_user("NoMemory", 0);
+ return -1;
}
+ snprintf(finame, len, "%s/%s", path, filename);
- res = malloc(size + imports * 20);
- if (!res)
- return 0;
- *osize = 0;
-
- while (offset < size) {
- m = regexec(&save_complete_import_re, source + offset,
- 11, match, 0);
- if (m)
- break;
-
- /*for (unsigned int i = 0; i != 11; i++) {
- if (match[i].rm_so == -1)
- continue;
- fprintf(stderr, "%i: '%.*s'\n", i,
- match[i].rm_eo - match[i].rm_so,
- source + offset + match[i].rm_so);
- }*/
-
- url = 0;
- if (match[2].rm_so != -1) {
- url = source + offset + match[2].rm_so;
- url_len = match[2].rm_eo - match[2].rm_so;
- } else if (match[4].rm_so != -1) {
- url = source + offset + match[4].rm_so;
- url_len = match[4].rm_eo - match[4].rm_so;
- } else if (match[6].rm_so != -1) {
- url = source + offset + match[6].rm_so;
- url_len = match[6].rm_eo - match[6].rm_so;
- } else if (match[8].rm_so != -1) {
- url = source + offset + match[8].rm_so;
- url_len = match[8].rm_eo - match[8].rm_so;
- } else if (match[10].rm_so != -1) {
- url = source + offset + match[10].rm_so;
- url_len = match[10].rm_eo - match[10].rm_so;
- }
- assert(url);
-
- url2 = strndup(url, url_len);
- if (!url2) {
- free(res);
- return 0;
- }
- result = url_join(url2, base, (char**)&url);
- free(url2);
- if (result == URL_FUNC_NOMEM) {
- free(res);
- return 0;
- }
-
- /* copy data before match */
- memcpy(res + *osize, source + offset, match[0].rm_so);
- *osize += match[0].rm_so;
-
- if (result == URL_FUNC_OK) {
- content = save_complete_list_find(url);
- if (content) {
- /* replace import */
- snprintf(buf, sizeof buf, "@import '%x'",
- (unsigned int) content);
- memcpy(res + *osize, buf, strlen(buf));
- *osize += strlen(buf);
- } else {
- /* copy import */
- memcpy(res + *osize, source + offset + match[0].rm_so,
- match[0].rm_eo - match[0].rm_so);
- *osize += match[0].rm_eo - match[0].rm_so;
- }
- }
- else {
- /* copy import */
- memcpy(res + *osize, source + offset + match[0].rm_so,
- match[0].rm_eo - match[0].rm_so);
- *osize += match[0].rm_eo - match[0].rm_so;
- }
-
- assert(0 < match[0].rm_eo);
- offset += match[0].rm_eo;
- }
-
- /* copy rest of source */
- if (offset < size) {
- memcpy(res + *osize, source + offset, size - offset);
- *osize += size - offset;
- }
-
- return res;
-}
-
-
-/**
- * Rewrite URLs in a HTML document to be relative.
- *
- * \param doc root of the document tree
- * \param base base url of document
- * \return true on success, false on out of memory
- */
-
-bool rewrite_document_urls(xmlDoc *doc, const char *base)
-{
- xmlNode *node;
-
- for (node = doc->children; node; node = node->next)
- if (node->type == XML_ELEMENT_NODE)
- if (!rewrite_urls(node, base))
- return false;
-
- return true;
-}
-
-
-/**
- * Traverse tree, rewriting URLs as we go.
- *
- * \param n xmlNode of type XML_ELEMENT_NODE to rewrite
- * \param base base url of document
- * \return true on success, false on out of memory
- *
- * URLs in the tree rooted at element n are rewritten.
- */
-
-bool rewrite_urls(xmlNode *n, const char *base)
-{
- xmlNode *child;
-
- assert(n->type == XML_ELEMENT_NODE);
-
- /**
- * We only need to consider the following cases:
- *
- * Attribute: Elements:
- *
- * 1) data <object>
- * 2) href <a> <area> <link>
- * 3) src <script> <input> <frame> <iframe>
<img>
- * 4) n/a <style>
- * 5) n/a any <base> tag
- * 6) background any (except those above)
- */
- if (!n->name) {
- /* ignore */
- }
- /* 1 */
- else if (strcmp(n->name, "object") == 0) {
- if (!rewrite_url(n, "data", base))
+ switch(type)
+ {
+ case 0xfaf:
+ strcpy(deftype,"html");
+ break;
+ case 0xf79:
+ strcpy(deftype,"css");
+ break;
+ default:
+ free(finame);
return false;
+ break;
}
- /* 2 */
- else if (strcmp(n->name, "a") == 0 ||
- strcmp(n->name, "area") == 0 ||
- strcmp(n->name, "link") == 0) {
- if (!rewrite_url(n, "href", base))
- return false;
- }
- /* 3 */
- else if (strcmp(n->name, "frame") == 0 ||
- strcmp(n->name, "iframe") == 0 ||
- strcmp(n->name, "input") == 0 ||
- strcmp(n->name, "img") == 0 ||
- strcmp(n->name, "script") == 0) {
- if (!rewrite_url(n, "src", base))
- return false;
- }
- /* 4 */
- else if (strcmp(n->name, "style") == 0) {
- unsigned int len;
- xmlChar *content;
- for (child = n->children; child != 0; child = child->next) {
- /* Get current content */
- content = xmlNodeGetContent(child);
- if (!content)
- /* unfortunately we don't know if this is
- * due to memory exhaustion, or because
- * there is no content for this node */
- continue;
+ dobj = GetIconTags(NULL,ICONGETA_GetDefaultName,deftype,
+ ICONGETA_GetDefaultType,WBPROJECT,
+ TAG_DONE);
- /* Rewrite @import rules */
- char *rewritten = rewrite_stylesheet_urls(
- content,
- strlen((char*)content),
- &len, base);
- xmlFree(content);
- if (!rewritten)
- return false;
+ PutIconTags(finame,dobj,
+ ICONPUTA_NotifyWorkbench,TRUE,
+ TAG_DONE);
- /* set new content */
- xmlNodeSetContentLen(child,
- (const xmlChar*)rewritten,
- len);
- }
-
- return true;
- }
- /* 5 */
- else if (strcmp(n->name, "base") == 0) {
- /* simply remove any <base> tags from the document */
- xmlUnlinkNode(n);
- xmlFreeNode(n);
- /* base tags have no content, so there's no point recursing
- * additionally, we've just destroyed this node, so trying
- * to recurse would result in bad things happening */
- return true;
- }
- /* 6 */
- else {
- if (!rewrite_url(n, "background", base))
- return false;
- }
-
- /* now recurse */
- for (child = n->children; child;) {
- /* we must extract the next child now, as if the current
- * child is a <base> element, it will be removed from the
- * tree (see 5, above), thus preventing extraction of the
- * next child */
- xmlNode *next = child->next;
- if (child->type == XML_ELEMENT_NODE) {
- if (!rewrite_urls(child, base))
- return false;
- }
- child = next;
- }
-
+ free(finame);
return true;
}
-
-
-/**
- * Rewrite an URL in a HTML document.
- *
- * \param n The node to modify
- * \param attr The html attribute to modify
- * \param base base url of document
- * \return true on success, false on out of memory
- */
-
-bool rewrite_url(xmlNode *n, const char *attr, const char *base)
-{
- char *url, *data;
- char rel[20];
- struct content *content;
- url_func_result res;
-
- if (!xmlHasProp(n, (const xmlChar *) attr))
- return true;
-
- data = xmlGetProp(n, (const xmlChar *) attr);
- if (!data)
- return false;
-
- res = url_join(data, base, &url);
- xmlFree(data);
- if (res == URL_FUNC_NOMEM)
- return false;
- else if (res == URL_FUNC_OK) {
- content = save_complete_list_find(url);
- if (content) {
- /* found a match */
- free(url);
- snprintf(rel, sizeof rel, "%x",
- (unsigned int) content);
- if (!xmlSetProp(n, (const xmlChar *) attr,
- (xmlChar *) rel))
- return false;
- } else {
- /* no match found */
- if (!xmlSetProp(n, (const xmlChar *) attr,
- (xmlChar *) url)) {
- free(url);
- return false;
- }
- free(url);
- }
- }
-
- return true;
-}
-
-
-/**
- * Add a content to the save_complete_list.
- *
- * \param content content to add
- * \return true on success, false on out of memory
- */
-
-bool save_complete_list_add(struct content *content)
-{
- struct save_complete_entry *entry;
- entry = malloc(sizeof (*entry));
- if (!entry)
- return false;
- entry->content = content;
- entry->next = save_complete_list;
- save_complete_list = entry;
- return true;
-}
-
-
-/**
- * Look up a url in the save_complete_list.
- *
- * \param url url to find
- * \return content if found, 0 otherwise
- */
-
-struct content * save_complete_list_find(const char *url)
-{
- struct save_complete_entry *entry;
- for (entry = save_complete_list; entry; entry = entry->next)
- if (strcmp(url, entry->content->url) == 0)
- return entry->content;
- return 0;
-}
-
-
-/**
- * Look up a content in the save_complete_list.
- *
- * \param content pointer to content
- * \return true if the content is in the save_complete_list
- */
-
-bool save_complete_list_check(struct content *content)
-{
- struct save_complete_entry *entry;
- for (entry = save_complete_list; entry; entry = entry->next)
- if (entry->content == content)
- return true;
- return false;
-}
-
-
-#if 0
-/**
- * Dump save complete list to stderr
- */
-void save_complete_list_dump(void)
-{
- struct save_complete_entry *entry;
- for (entry = save_complete_list; entry; entry = entry->next)
- fprintf(stderr, "%p : %s\n", entry->content,
- entry->content->url);
-}
-#endif
-
-
-/**
- * Create the inventory file listing original URLs.
- */
-
-bool save_complete_inventory(const char *path)
-{
- char spath[256];
- FILE *fp;
-
- snprintf(spath, sizeof spath, "%s/Inventory", path);
-
- fp = fopen(spath, "w");
- if (!fp) {
- LOG(("fopen(): errno = %i", errno));
- warn_user("SaveError", strerror(errno));
- return false;
- }
-
- struct save_complete_entry *entry;
- for (entry = save_complete_list; entry; entry = entry->next)
- fprintf(fp, "%x %s\n",
- (unsigned int) entry->content,
- entry->content->url);
-
- fclose(fp);
-
- return true;
-}
-
Conflicted files
Removed files