diff options
Diffstat (limited to 'frontends/gtk')
61 files changed, 2288 insertions, 1449 deletions
diff --git a/frontends/gtk/Makefile b/frontends/gtk/Makefile index afbfcd791..ec60ce70c 100644 --- a/frontends/gtk/Makefile +++ b/frontends/gtk/Makefile @@ -165,11 +165,11 @@ endif # S_FRONTEND are sources purely for the GTK frontend S_FRONTEND := gui.c schedule.c layout_pango.c bitmap.c plotters.c \ - scaffolding.c gdk.c completion.c login.c throbber.c \ - selection.c global_history.c window.c fetch.c download.c menu.c \ - print.c search.c tabs.c toolbar.c gettext.c \ - compat.c cookies.c hotlist.c viewdata.c viewsource.c \ - preferences.c about.c ssl_cert.c resources.c corewindow.c + scaffolding.c gdk.c completion.c login.c throbber.c accelerator.c \ + selection.c window.c fetch.c download.c menu.c print.c \ + search.c tabs.c toolbar.c gettext.c compat.c viewdata.c \ + viewsource.c preferences.c about.c resources.c corewindow.c \ + local_history.c global_history.c cookies.c hotlist.c ssl_cert.c # This is the final source build list # Note this is deliberately *not* expanded here as common and image diff --git a/frontends/gtk/accelerator.c b/frontends/gtk/accelerator.c new file mode 100644 index 000000000..11b7fb1d0 --- /dev/null +++ b/frontends/gtk/accelerator.c @@ -0,0 +1,79 @@ +/* + * Copyright 2018 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * \file + * GTK accelerator support + * + */ + +#include <stdint.h> +#include <gtk/gtk.h> + +#include "utils/log.h" +#include "utils/errors.h" +#include "utils/hashtable.h" + +#include "gtk/resources.h" +#include "gtk/accelerator.h" + +/** acclelerators are stored in a fixed-size hash table. */ +#define HASH_SIZE 53 + +/** The hash table used to store the accelerators */ +static struct hash_table *accelerators_hash = NULL; + +nserror nsgtk_accelerator_init(char **respaths) +{ + nserror res; + const uint8_t *data; + size_t data_size; + + if (accelerators_hash == NULL) { + accelerators_hash = hash_create(HASH_SIZE); + } + if (accelerators_hash == NULL) { + NSLOG(netsurf, INFO, "Unable to create hash table"); + return NSERROR_NOMEM; + } + + res = nsgtk_data_from_resname("accelerators", &data, &data_size); + if (res == NSERROR_OK) { + res = hash_add_inline(accelerators_hash, data, data_size); + } else { + const char *accelerators_path; + /* Obtain path to accelerators */ + res = nsgtk_path_from_resname("accelerators", + &accelerators_path); + if (res == NSERROR_OK) { + res = hash_add_file(accelerators_hash, + accelerators_path); + } + } + + return res; +} + +const char *nsgtk_accelerator_get_desc(const char *key) +{ + if ((key == NULL) || + (accelerators_hash == NULL)) { + return NULL; + } + return hash_get(accelerators_hash, key); +} diff --git a/frontends/gtk/accelerator.h b/frontends/gtk/accelerator.h new file mode 100644 index 000000000..09c253eb9 --- /dev/null +++ b/frontends/gtk/accelerator.h @@ -0,0 +1,2 @@ +nserror nsgtk_accelerator_init(char **respaths); +const char *nsgtk_accelerator_get_desc(const char *key); diff --git a/frontends/gtk/bitmap.c b/frontends/gtk/bitmap.c index b42814295..36b614cf9 100644 --- a/frontends/gtk/bitmap.c +++ b/frontends/gtk/bitmap.c @@ -18,9 +18,9 @@ /** * \file - * Generic bitmap handling (GDK / GTK+ implementation). + * GTK bitmap handling. * - * This implements the interface given by desktop/bitmap.h using GdkPixbufs. + * This implements the bitmap interface using cairo image surfaces */ #include <assert.h> diff --git a/frontends/gtk/cookies.c b/frontends/gtk/cookies.c index dc77e1c4e..1f7833cca 100644 --- a/frontends/gtk/cookies.c +++ b/frontends/gtk/cookies.c @@ -164,8 +164,9 @@ static void nsgtk_cookies_init_menu(struct nsgtk_cookie_window *ncwin) w = GTK_WIDGET(gtk_builder_get_object(ncwin->builder, event->widget)); if (w == NULL) { - LOG("Unable to connect menu widget ""%s""", - event->widget); + NSLOG(netsurf, INFO, + "Unable to connect menu widget ""%s""", + event->widget); } else { g_signal_connect(G_OBJECT(w), "activate", @@ -246,14 +247,14 @@ static nserror nsgtk_cookies_init(void) return NSERROR_OK; } - ncwin = malloc(sizeof(struct nsgtk_cookie_window)); + ncwin = calloc(1, sizeof(*ncwin)); if (ncwin == NULL) { return NSERROR_NOMEM; } res = nsgtk_builder_new_from_resname("cookies", &ncwin->builder); if (res != NSERROR_OK) { - LOG("Cookie UI builder init failed"); + NSLOG(netsurf, INFO, "Cookie UI builder init failed"); free(ncwin); return res; } diff --git a/frontends/gtk/corewindow.c b/frontends/gtk/corewindow.c index 70c3ad135..6ca5d228f 100644 --- a/frontends/gtk/corewindow.c +++ b/frontends/gtk/corewindow.c @@ -145,6 +145,7 @@ nsgtk_cw_button_release_event(GtkWidget *widget, { struct nsgtk_corewindow *nsgtk_cw = (struct nsgtk_corewindow *)g; struct nsgtk_corewindow_mouse *mouse = &nsgtk_cw->mouse_state; + bool was_drag = false; /* only button 1 clicks are considered double clicks. If the * mouse state is PRESS then we are waiting for a release to @@ -168,9 +169,11 @@ nsgtk_cw_button_release_event(GtkWidget *widget, } else if (mouse->state & BROWSER_MOUSE_HOLDING_1) { mouse->state ^= (BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON); + was_drag = true; } else if (mouse->state & BROWSER_MOUSE_HOLDING_2) { mouse->state ^= (BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_ON); + was_drag = true; } /* Handle modifiers being removed */ @@ -188,9 +191,10 @@ nsgtk_cw_button_release_event(GtkWidget *widget, } /* end drag with modifiers */ - if (mouse->state & (BROWSER_MOUSE_MOD_1 | - BROWSER_MOUSE_MOD_2 | - BROWSER_MOUSE_MOD_3)) { + if (was_drag && (mouse->state & ( + BROWSER_MOUSE_MOD_1 | + BROWSER_MOUSE_MOD_2 | + BROWSER_MOUSE_MOD_3))) { mouse->state = BROWSER_MOUSE_HOVER; } @@ -413,14 +417,14 @@ nsgtk_cw_keypress_event(GtkWidget *widget, GdkEventKey *event, gpointer g) if (res == NSERROR_OK) { return TRUE; } else if (res != NSERROR_NOT_IMPLEMENTED) { - LOG("%s", messages_get_errorcode(res)); + NSLOG(netsurf, INFO, "%s", messages_get_errorcode(res)); return FALSE; } /* deal with unprocessed keypress */ res = nsgtk_cw_key(nsgtk_cw, nskey); if (res != NSERROR_OK) { - LOG("%s", messages_get_errorcode(res)); + NSLOG(netsurf, INFO, "%s", messages_get_errorcode(res)); return FALSE; } return TRUE; @@ -496,7 +500,6 @@ nsgtk_cw_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data) double y2; struct rect clip; - current_widget = widget; current_cr = cr; cairo_clip_extents(cr, &x1, &y1, &x2, &y2); @@ -508,8 +511,6 @@ nsgtk_cw_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data) nsgtk_cw->draw(nsgtk_cw, &clip); - current_widget = NULL; - return FALSE; } @@ -537,12 +538,10 @@ nsgtk_cw_draw_event(GtkWidget *widget, clip.x1 = event->area.x + event->area.width; clip.y1 = event->area.y + event->area.height; - current_widget = widget; current_cr = gdk_cairo_create(nsgtk_widget_get_window(widget)); nsgtk_cw->draw(nsgtk_cw, &clip); - current_widget = NULL; cairo_destroy(current_cr); return FALSE; @@ -552,19 +551,33 @@ nsgtk_cw_draw_event(GtkWidget *widget, /** - * redraw window core window callback + * callback from core to request an invalidation of a GTK core window area. * - * \param cw core window handle. - * \param r rectangle that needs redrawing. + * The specified area of the window should now be considered + * out of date. If the area is NULL the entire window must be + * invalidated. + * + * \param[in] cw The core window to invalidate. + * \param[in] rect area to redraw or NULL for the entire window area. + * \return NSERROR_OK on success or appropriate error code. */ -static void -nsgtk_cw_redraw_request(struct core_window *cw, const struct rect *r) +static nserror +nsgtk_cw_invalidate_area(struct core_window *cw, const struct rect *rect) { struct nsgtk_corewindow *nsgtk_cw = (struct nsgtk_corewindow *)cw; + if (rect == NULL) { + gtk_widget_queue_draw(GTK_WIDGET(nsgtk_cw->drawing_area)); + return NSERROR_OK; + } + gtk_widget_queue_draw_area(GTK_WIDGET(nsgtk_cw->drawing_area), - r->x0, r->y0, - r->x1 - r->x0, r->y1 - r->y0); + rect->x0, + rect->y0, + rect->x1 - rect->x0, + rect->y1 - rect->y0); + + return NSERROR_OK; } @@ -653,7 +666,7 @@ static void nsgtk_cw_drag_status(struct core_window *cw, core_window_drag_status ds) { struct nsgtk_corewindow *nsgtk_cw = (struct nsgtk_corewindow *)cw; - nsgtk_cw->drag_staus = ds; + nsgtk_cw->drag_status = ds; } @@ -661,17 +674,19 @@ nsgtk_cw_drag_status(struct core_window *cw, core_window_drag_status ds) * core window callback table for nsgtk */ static struct core_window_callback_table nsgtk_cw_cb_table = { - .redraw_request = nsgtk_cw_redraw_request, + .invalidate = nsgtk_cw_invalidate_area, .update_size = nsgtk_cw_update_size, .scroll_visible = nsgtk_cw_scroll_visible, .get_window_dimensions = nsgtk_cw_get_window_dimensions, .drag_status = nsgtk_cw_drag_status }; + /* exported function documented gtk/corewindow.h */ nserror nsgtk_corewindow_init(struct nsgtk_corewindow *nsgtk_cw) { nsgtk_cw->cb_table = &nsgtk_cw_cb_table; + nsgtk_cw->drag_status = CORE_WINDOW_DRAG_NONE; /* input method setup */ nsgtk_cw->input_method = gtk_im_multicontext_new(); diff --git a/frontends/gtk/corewindow.h b/frontends/gtk/corewindow.h index 90bfd6193..6100e67ae 100644 --- a/frontends/gtk/corewindow.h +++ b/frontends/gtk/corewindow.h @@ -51,7 +51,7 @@ struct nsgtk_corewindow { /** mouse state */ struct nsgtk_corewindow_mouse mouse_state; /** drag status set by core */ - core_window_drag_status drag_staus; + core_window_drag_status drag_status; /** * callback to draw on drawable area of nsgtk core window diff --git a/frontends/gtk/download.c b/frontends/gtk/download.c index 8c8161459..d11036ea8 100644 --- a/frontends/gtk/download.c +++ b/frontends/gtk/download.c @@ -331,6 +331,7 @@ static gboolean nsgtk_download_update(gboolean force_update) switch (dl->status) { case NSGTK_DOWNLOAD_WORKING: pulse_mode = TRUE; + /* Fall through */ case NSGTK_DOWNLOAD_NONE: dl->speed = dl->size_downloaded / @@ -347,6 +348,7 @@ static gboolean nsgtk_download_update(gboolean force_update) nsgtk_downloads_num_active++; update = TRUE; + /* Fall through */ case NSGTK_DOWNLOAD_COMPLETE: downloaded += dl->size_downloaded; @@ -475,7 +477,7 @@ nserror nsgtk_download_init(void) res = nsgtk_builder_new_from_resname("downloads", &builder); if (res != NSERROR_OK) { - LOG("Download UI builder init failed"); + NSLOG(netsurf, INFO, "Download UI builder init failed"); return res; } diff --git a/frontends/gtk/fetch.c b/frontends/gtk/fetch.c index 154f43708..b05c1bd95 100644 --- a/frontends/gtk/fetch.c +++ b/frontends/gtk/fetch.c @@ -30,6 +30,7 @@ * ASCII hence not using locale dependant ctype functions for parsing. */ +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> @@ -39,8 +40,8 @@ #include <strings.h> #include <gtk/gtk.h> -#include "utils/hashtable.h" #include "utils/log.h" +#include "utils/hashtable.h" #include "utils/filepath.h" #include "utils/file.h" #include "utils/nsurl.h" @@ -90,7 +91,8 @@ void gtk_fetch_filetype_init(const char *mimefile) fh = fopen(mimefile, "r"); if (fh == NULL) { - LOG("Unable to open a mime.types file, so using a minimal one for you."); + NSLOG(netsurf, INFO, + "Unable to open a mime.types file, so using a minimal one for you."); return; } diff --git a/frontends/gtk/gdk.c b/frontends/gtk/gdk.c index 9ed90bd8e..fd82af5b2 100644 --- a/frontends/gtk/gdk.c +++ b/frontends/gtk/gdk.c @@ -86,7 +86,7 @@ nsgdk_pixbuf_get_from_surface(cairo_surface_t *surface, int scwidth, int scheigh if (cairo_surface_status(scsurface) != CAIRO_STATUS_SUCCESS) { cairo_surface_destroy(scsurface); g_object_unref(pixbuf); - LOG("Surface creation failed"); + NSLOG(netsurf, INFO, "Surface creation failed"); return NULL; } diff --git a/frontends/gtk/global_history.c b/frontends/gtk/global_history.c index 7d647057b..f204168d0 100644 --- a/frontends/gtk/global_history.c +++ b/frontends/gtk/global_history.c @@ -214,8 +214,9 @@ nsgtk_global_history_init_menu(struct nsgtk_global_history_window *ghwin) w = GTK_WIDGET(gtk_builder_get_object(ghwin->builder, event->widget)); if (w == NULL) { - LOG("Unable to connect menu widget ""%s""", - event->widget); + NSLOG(netsurf, INFO, + "Unable to connect menu widget ""%s""", + event->widget); } else { g_signal_connect(G_OBJECT(w), "activate", @@ -228,7 +229,7 @@ nsgtk_global_history_init_menu(struct nsgtk_global_history_window *ghwin) /** - * callback for mouse action on cookie window + * callback for mouse action on global history window * * \param nsgtk_cw The nsgtk core window structure. * \param mouse_state netsurf mouse state on event @@ -248,7 +249,7 @@ nsgtk_global_history_mouse(struct nsgtk_corewindow *nsgtk_cw, /** - * callback for keypress on cookie window + * callback for keypress on global history window * * \param nsgtk_cw The nsgtk core window structure. * \param nskey The netsurf key code @@ -265,7 +266,7 @@ nsgtk_global_history_key(struct nsgtk_corewindow *nsgtk_cw, uint32_t nskey) /** - * callback on draw event for cookie window + * callback on draw event for global history window * * \param nsgtk_cw The nsgtk core window structure. * \param r The rectangle of the window that needs updating. @@ -299,14 +300,14 @@ static nserror nsgtk_global_history_init(void) return NSERROR_OK; } - ncwin = malloc(sizeof(struct nsgtk_global_history_window)); + ncwin = calloc(1, sizeof(*ncwin)); if (ncwin == NULL) { return NSERROR_NOMEM; } - res = nsgtk_builder_new_from_resname("history", &ncwin->builder); + res = nsgtk_builder_new_from_resname("globalhistory", &ncwin->builder); if (res != NSERROR_OK) { - LOG("History UI builder init failed"); + NSLOG(netsurf, INFO, "History UI builder init failed"); free(ncwin); return res; } diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c index 8d6b42234..3163be16d 100644 --- a/frontends/gtk/gui.c +++ b/frontends/gtk/gui.c @@ -58,6 +58,7 @@ #include "gtk/download.h" #include "gtk/fetch.h" #include "gtk/gui.h" +#include "gtk/local_history.h" #include "gtk/global_history.h" #include "gtk/hotlist.h" #include "gtk/throbber.h" @@ -71,6 +72,7 @@ #include "gtk/resources.h" #include "gtk/login.h" #include "gtk/layout_pango.h" +#include "gtk/accelerator.h" bool nsgtk_complete = false; @@ -207,7 +209,8 @@ static nserror set_defaults(struct nsoption_s *defaults) (nsoption_charp(hotlist_path) == NULL) || (nsoption_charp(downloads_directory) == NULL) || (nsoption_charp(ca_path) == NULL)) { - LOG("Failed initialising default resource paths"); + NSLOG(netsurf, INFO, + "Failed initialising default resource paths"); return NSERROR_BAD_PARAMETER; } @@ -225,7 +228,11 @@ static nserror set_defaults(struct nsoption_s *defaults) /** - * Initialize GTK interface. + * Initialize GTK specific parts of the browser. + * + * \param argc The number of arguments on the command line + * \param argv A string vector of command line arguments. + * \respath A string vector of the path elements of resources */ static nserror nsgtk_init(int argc, char** argv, char **respath) { @@ -233,21 +240,30 @@ static nserror nsgtk_init(int argc, char** argv, char **respath) char *resource_filename; char *addr = NULL; nsurl *url; - nserror error; + nserror res; - error = nsgtk_builder_new_from_resname("warning", &warning_builder); - if (error != NSERROR_OK) { - LOG("Unable to initialise warning dialog"); - return error; + /* Initialise gtk accelerator table */ + res = nsgtk_accelerator_init(respaths); + if (res != NSERROR_OK) { + NSLOG(netsurf, INFO, + "Unable to load gtk accelerator configuration"); + /* not fatal if this does not load */ + } + + /* initialise warning dialog */ + res = nsgtk_builder_new_from_resname("warning", &warning_builder); + if (res != NSERROR_OK) { + NSLOG(netsurf, INFO, "Unable to initialise warning dialog"); + return res; } gtk_builder_connect_signals(warning_builder, NULL); /* set default icon if its available */ - error = nsgdk_pixbuf_new_from_resname("netsurf.xpm", - &win_default_icon_pixbuf); - if (error == NSERROR_OK) { - LOG("Seting default window icon"); + res = nsgdk_pixbuf_new_from_resname("netsurf.xpm", + &win_default_icon_pixbuf); + if (res == NSERROR_OK) { + NSLOG(netsurf, INFO, "Seting default window icon"); gtk_window_set_default_icon(win_default_icon_pixbuf); } @@ -255,35 +271,43 @@ static nserror nsgtk_init(int argc, char** argv, char **respath) resource_filename = filepath_find(respath, "SearchEngines"); search_web_init(resource_filename); if (resource_filename != NULL) { - LOG("Using '%s' as Search Engines file", resource_filename); + NSLOG(netsurf, INFO, "Using '%s' as Search Engines file", + resource_filename); free(resource_filename); } /* Default favicon */ - error = nsgdk_pixbuf_new_from_resname("favicon.png", &favicon_pixbuf); - if (error != NSERROR_OK) { + res = nsgdk_pixbuf_new_from_resname("favicon.png", &favicon_pixbuf); + if (res != NSERROR_OK) { favicon_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 16, 16); } /* arrow down icon */ - error = nsgdk_pixbuf_new_from_resname("arrow_down_8x32.png", - &arrow_down_pixbuf); - if (error != NSERROR_OK) { + res = nsgdk_pixbuf_new_from_resname("arrow_down_8x32.png", + &arrow_down_pixbuf); + if (res != NSERROR_OK) { arrow_down_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 8, 32); } /* initialise throbber */ - error = nsgtk_throbber_init(); - if (error != NSERROR_OK) { - LOG("Unable to initialise throbber."); - return error; + res = nsgtk_throbber_init(); + if (res != NSERROR_OK) { + NSLOG(netsurf, INFO, "Unable to initialise throbber."); + return res; } /* Initialise completions - cannot fail */ nsgtk_completion_init(); + /* The tree view system needs to know the screen's DPI, so we + * find that out here, rather than when we create a first browser + * window. + */ + browser_set_dpi(gdk_screen_get_resolution(gdk_screen_get_default())); + NSLOG(netsurf, INFO, "Set CSS DPI to %d", browser_get_dpi()); + filepath_sfinddef(respath, buf, "mime.types", "/etc/"); gtk_fetch_filetype_init(buf); @@ -291,20 +315,14 @@ static nserror nsgtk_init(int argc, char** argv, char **respath) urldb_load(nsoption_charp(url_file)); urldb_load_cookies(nsoption_charp(cookie_file)); - hotlist_init(nsoption_charp(hotlist_path)); - - /* The tree view system needs to know the screen's DPI, so we - * find that out here, rather than when we create a first browser - * window. - */ - browser_set_dpi(gdk_screen_get_resolution(gdk_screen_get_default())); - LOG("Set CSS DPI to %d", browser_get_dpi()); + hotlist_init(nsoption_charp(hotlist_path), + nsoption_charp(hotlist_path)); /* Initialise top level UI elements */ - error = nsgtk_download_init(); - if (error != NSERROR_OK) { - LOG("Unable to initialise download window."); - return error; + res = nsgtk_download_init(); + if (res != NSERROR_OK) { + NSLOG(netsurf, INFO, "Unable to initialise download window."); + return res; } /* If there is a url specified on the command line use it */ @@ -334,19 +352,19 @@ static nserror nsgtk_init(int argc, char** argv, char **respath) } /* create an initial browser window */ - error = nsurl_create(addr, &url); - if (error == NSERROR_OK) { - error = browser_window_create(BW_CREATE_HISTORY, - url, - NULL, - NULL, - NULL); + res = nsurl_create(addr, &url); + if (res == NSERROR_OK) { + res = browser_window_create(BW_CREATE_HISTORY, + url, + NULL, + NULL, + NULL); nsurl_unref(url); } free(addr); - return error; + return res; } @@ -424,7 +442,7 @@ static void gui_quit(void) { nserror res; - LOG("Quitting GUI"); + NSLOG(netsurf, INFO, "Quitting GUI"); /* Ensure all scaffoldings are destroyed before we go into exit */ nsgtk_download_destroy(); @@ -433,26 +451,34 @@ static void gui_quit(void) res = nsgtk_cookies_destroy(); if (res != NSERROR_OK) { - LOG("Error finalising cookie viewer: %s", - messages_get_errorcode(res)); + NSLOG(netsurf, INFO, "Error finalising cookie viewer: %s", + messages_get_errorcode(res)); + } + + res = nsgtk_local_history_destroy(); + if (res != NSERROR_OK) { + NSLOG(netsurf, INFO, + "Error finalising local history viewer: %s", + messages_get_errorcode(res)); } res = nsgtk_global_history_destroy(); if (res != NSERROR_OK) { - LOG("Error finalising global history viewer: %s", - messages_get_errorcode(res)); + NSLOG(netsurf, INFO, + "Error finalising global history viewer: %s", + messages_get_errorcode(res)); } res = nsgtk_hotlist_destroy(); if (res != NSERROR_OK) { - LOG("Error finalising hotlist viewer: %s", - messages_get_errorcode(res)); + NSLOG(netsurf, INFO, "Error finalising hotlist viewer: %s", + messages_get_errorcode(res)); } - res = hotlist_fini(nsoption_charp(hotlist_path)); + res = hotlist_fini(); if (res != NSERROR_OK) { - LOG("Error finalising hotlist: %s", - messages_get_errorcode(res)); + NSLOG(netsurf, INFO, "Error finalising hotlist: %s", + messages_get_errorcode(res)); } free(nsgtk_config_home); @@ -484,7 +510,7 @@ nserror nsgtk_warning(const char *warning, const char *detail) static GtkWindow *nsgtk_warning_window; GtkLabel *WarningLabel; - LOG("%s %s", warning, detail ? detail : ""); + NSLOG(netsurf, INFO, "%s %s", warning, detail ? detail : ""); fflush(stdout); nsgtk_warning_window = GTK_WINDOW(gtk_builder_get_object(warning_builder, "wndWarning")); @@ -592,7 +618,7 @@ static void nsgtk_pdf_password(char **owner_pass, char **user_pass, char *path) res = nsgtk_builder_new_from_resname("password", &password_builder); if (res != NSERROR_OK) { - LOG("Password UI builder init failed"); + NSLOG(netsurf, INFO, "Password UI builder init failed"); return; } @@ -813,7 +839,7 @@ static nserror get_config_home(char **config_home_out) if (home_dir != NULL) { ret = check_dirname(home_dir, ".netsurf", &config_home); if (ret == NSERROR_OK) { - LOG("\"%s\"", config_home); + NSLOG(netsurf, INFO, "\"%s\"", config_home); *config_home_out = config_home; return ret; } @@ -853,7 +879,7 @@ static nserror get_config_home(char **config_home_out) } } - LOG("\"%s\"", config_home); + NSLOG(netsurf, INFO, "\"%s\"", config_home); *config_home_out = config_home; return NSERROR_OK; @@ -866,7 +892,7 @@ static nserror create_config_home(char **config_home_out) char *xdg_config_dir; nserror ret; - LOG("Attempting to create configuration directory"); + NSLOG(netsurf, INFO, "Attempting to create configuration directory"); /* $XDG_CONFIG_HOME defines the base directory * relative to which user specific configuration files @@ -902,7 +928,7 @@ static nserror create_config_home(char **config_home_out) /* strip the trailing separator */ config_home[strlen(config_home) - 1] = 0; - LOG("\"%s\"", config_home); + NSLOG(netsurf, INFO, "\"%s\"", config_home); *config_home_out = config_home; @@ -951,7 +977,7 @@ static nserror get_cache_home(char **cache_home_out) } } - LOG("\"%s\"", cache_home); + NSLOG(netsurf, INFO, "\"%s\"", cache_home); *cache_home_out = cache_home; return NSERROR_OK; @@ -964,7 +990,7 @@ static nserror create_cache_home(char **cache_home_out) char *xdg_cache_dir; nserror ret; - LOG("Attempting to create configuration directory"); + NSLOG(netsurf, INFO, "Attempting to create configuration directory"); /* $XDG_CACHE_HOME defines the base directory * relative to which user specific cache files @@ -1000,7 +1026,7 @@ static nserror create_cache_home(char **cache_home_out) /* strip the trailing separator */ cache_home[strlen(cache_home) - 1] = 0; - LOG("\"%s\"", cache_home); + NSLOG(netsurf, INFO, "\"%s\"", cache_home); *cache_home_out = cache_home; @@ -1107,7 +1133,8 @@ int main(int argc, char** argv) ret = create_config_home(&nsgtk_config_home); } if (ret != NSERROR_OK) { - LOG("Unable to locate a configuration directory."); + NSLOG(netsurf, INFO, + "Unable to locate a configuration directory."); nsgtk_config_home = NULL; } @@ -1147,10 +1174,10 @@ int main(int argc, char** argv) if (ret != NSERROR_OK) { fprintf(stderr, "Unable to load translated messages (%s)\n", messages_get_errorcode(ret)); - LOG("Unable to load translated messages"); + NSLOG(netsurf, INFO, "Unable to load translated messages"); /** \todo decide if message load faliure should be fatal */ } - + /* Locate the correct user cache directory path */ ret = get_cache_home(&cache_home); if (ret == NSERROR_NOT_FOUND) { @@ -1158,7 +1185,7 @@ int main(int argc, char** argv) ret = create_cache_home(&cache_home); } if (ret != NSERROR_OK) { - LOG("Unable to locate a cache directory."); + NSLOG(netsurf, INFO, "Unable to locate a cache directory."); } /* core initialisation */ @@ -1170,7 +1197,7 @@ int main(int argc, char** argv) return 1; } - /* run the browser */ + /* gtk specific initalisation and main run loop */ ret = nsgtk_init(argc, argv, respaths); if (ret != NSERROR_OK) { fprintf(stderr, "NetSurf gtk initialise failed (%s)\n", @@ -1185,5 +1212,8 @@ int main(int argc, char** argv) /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/gtk/hotlist.c b/frontends/gtk/hotlist.c index 34a13772d..843e47736 100644 --- a/frontends/gtk/hotlist.c +++ b/frontends/gtk/hotlist.c @@ -236,8 +236,9 @@ static void nsgtk_hotlist_init_menu(struct nsgtk_hotlist_window *hlwin) w = GTK_WIDGET(gtk_builder_get_object(hlwin->builder, event->widget)); if (w == NULL) { - LOG("Unable to connect menu widget ""%s""", - event->widget); + NSLOG(netsurf, INFO, + "Unable to connect menu widget ""%s""", + event->widget); } else { g_signal_connect(G_OBJECT(w), "activate", @@ -319,14 +320,14 @@ static nserror nsgtk_hotlist_init(void) return NSERROR_OK; } - ncwin = malloc(sizeof(struct nsgtk_hotlist_window)); + ncwin = calloc(1, sizeof(*ncwin)); if (ncwin == NULL) { return NSERROR_NOMEM; } res = nsgtk_builder_new_from_resname("hotlist", &ncwin->builder); if (res != NSERROR_OK) { - LOG("Hotlist UI builder init failed"); + NSLOG(netsurf, INFO, "Hotlist UI builder init failed"); free(ncwin); return res; } diff --git a/frontends/gtk/layout_pango.c b/frontends/gtk/layout_pango.c index 7c7190982..9e8e94d48 100644 --- a/frontends/gtk/layout_pango.c +++ b/frontends/gtk/layout_pango.c @@ -30,6 +30,7 @@ #include "utils/log.h" #include "utils/nsoption.h" +#include "netsurf/inttypes.h" #include "netsurf/layout.h" #include "netsurf/plot_style.h" @@ -42,12 +43,12 @@ static PangoLayout *nsfont_pango_layout = NULL; static inline void nsfont_pango_check(void) { if (nsfont_pango_context == NULL) { - LOG("Creating nsfont_pango_context."); + NSLOG(netsurf, INFO, "Creating nsfont_pango_context."); nsfont_pango_context = gdk_pango_context_get(); } if (nsfont_pango_layout == NULL) { - LOG("Creating nsfont_pango_layout."); + NSLOG(netsurf, INFO, "Creating nsfont_pango_layout."); nsfont_pango_layout = pango_layout_new(nsfont_pango_context); } } @@ -84,9 +85,10 @@ nsfont_width(const plot_font_style_t *fstyle, pango_layout_get_pixel_size(nsfont_pango_layout, width, 0); - /* LOG("fstyle: %p string:\"%.*s\", length: %u, width: %dpx", - fstyle, length, string, length, *width); - */ + NSLOG(netsurf, DEEPDEBUG, + "fstyle: %p string:\"%.*s\", length: %" PRIsizet ", width: %dpx", + fstyle, (int)length, string, length, *width); + return NSERROR_OK; } @@ -194,7 +196,7 @@ nsfont_split(const plot_font_style_t *fstyle, pango_layout_set_single_paragraph_mode(layout, TRUE); /* Obtain the second line of the layout (if there is one) */ - line = pango_layout_get_line(layout, 1); + line = pango_layout_get_line_readonly(layout, 1); if (line != NULL) { /* Pango split the text. The line's start_index indicates the * start of the character after the line break. */ @@ -222,32 +224,29 @@ nsfont_split(const plot_font_style_t *fstyle, * \param fstyle plot style for this text * \return true on success, false on error and error reported */ -bool nsfont_paint(int x, int y, const char *string, size_t length, +nserror nsfont_paint(int x, int y, const char *string, size_t length, const plot_font_style_t *fstyle) { PangoFontDescription *desc; - PangoLayout *layout; PangoLayoutLine *line; if (length == 0) - return true; + return NSERROR_OK; - layout = pango_cairo_create_layout(current_cr); + nsfont_pango_check(); desc = nsfont_style_to_description(fstyle); - pango_layout_set_font_description(layout, desc); + pango_layout_set_font_description(nsfont_pango_layout, desc); pango_font_description_free(desc); - pango_layout_set_text(layout, string, length); + pango_layout_set_text(nsfont_pango_layout, string, length); - line = pango_layout_get_line_readonly(layout, 0); + line = pango_layout_get_line_readonly(nsfont_pango_layout, 0); cairo_move_to(current_cr, x, y); nsgtk_set_colour(fstyle->foreground); pango_cairo_show_layout_line(current_cr, line); - g_object_unref(layout); - - return true; + return NSERROR_OK; } @@ -278,7 +277,7 @@ nsfont_style_to_description(const plot_font_style_t *fstyle) break; } - size = (fstyle->size * PANGO_SCALE) / FONT_SIZE_SCALE; + size = (fstyle->size * PANGO_SCALE) / PLOT_STYLE_SCALE; if (fstyle->flags & FONTF_ITALIC) style = PANGO_STYLE_ITALIC; diff --git a/frontends/gtk/layout_pango.h b/frontends/gtk/layout_pango.h index 137cebe68..7ce107a5d 100644 --- a/frontends/gtk/layout_pango.h +++ b/frontends/gtk/layout_pango.h @@ -30,7 +30,7 @@ struct plot_font_style; extern struct gui_layout_table *nsgtk_layout_table; -bool nsfont_paint(int x, int y, const char *string, size_t length, const struct plot_font_style *fstyle); +nserror nsfont_paint(int x, int y, const char *string, size_t length, const struct plot_font_style *fstyle); /** * Convert a plot style to a PangoFontDescription. diff --git a/frontends/gtk/local_history.c b/frontends/gtk/local_history.c new file mode 100644 index 000000000..35b7a4ad6 --- /dev/null +++ b/frontends/gtk/local_history.c @@ -0,0 +1,269 @@ +/* + * Copyright 2017 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * \file + * Implementation of GTK local history manager. + */ + +#include <stdint.h> +#include <stdlib.h> +#include <gtk/gtk.h> + +#include "utils/log.h" +#include "netsurf/keypress.h" +#include "netsurf/plotters.h" +#include "desktop/local_history.h" + +#include "gtk/compat.h" +#include "gtk/plotters.h" +#include "gtk/resources.h" +#include "gtk/corewindow.h" +#include "gtk/local_history.h" + +struct nsgtk_local_history_window { + struct nsgtk_corewindow core; + + GtkBuilder *builder; + + GtkWindow *wnd; + + struct local_history_session *session; +}; + +static struct nsgtk_local_history_window *local_history_window = NULL; + + + +/** + * callback for mouse action on local history window + * + * \param nsgtk_cw The nsgtk core window structure. + * \param mouse_state netsurf mouse state on event + * \param x location of event + * \param y location of event + * \return NSERROR_OK on success otherwise apropriate error code + */ +static nserror +nsgtk_local_history_mouse(struct nsgtk_corewindow *nsgtk_cw, + browser_mouse_state mouse_state, + int x, int y) +{ + struct nsgtk_local_history_window *lhw; + /* technically degenerate container of */ + lhw = (struct nsgtk_local_history_window *)nsgtk_cw; + + local_history_mouse_action(lhw->session, mouse_state, x, y); + + return NSERROR_OK; +} + + +/** + * callback for keypress on local history window + * + * \param nsgtk_cw The nsgtk core window structure. + * \param nskey The netsurf key code + * \return NSERROR_OK on success otherwise apropriate error code + */ +static nserror +nsgtk_local_history_key(struct nsgtk_corewindow *nsgtk_cw, uint32_t nskey) +{ + struct nsgtk_local_history_window *lhw; + /* technically degenerate container of */ + lhw = (struct nsgtk_local_history_window *)nsgtk_cw; + + if (local_history_keypress(lhw->session, nskey)) { + return NSERROR_OK; + } + return NSERROR_NOT_IMPLEMENTED; +} + + +/** + * callback on draw event for local history window + * + * \param nsgtk_cw The nsgtk core window structure. + * \param r The rectangle of the window that needs updating. + * \return NSERROR_OK on success otherwise apropriate error code + */ +static nserror +nsgtk_local_history_draw(struct nsgtk_corewindow *nsgtk_cw, struct rect *r) +{ + struct redraw_context ctx = { + .interactive = true, + .background_images = true, + .plot = &nsgtk_plotters + }; + struct nsgtk_local_history_window *lhw; + + /* technically degenerate container of */ + lhw = (struct nsgtk_local_history_window *)nsgtk_cw; + + ctx.plot->clip(&ctx, r); + local_history_redraw(lhw->session, 0, 0, r, &ctx); + + return NSERROR_OK; +} + +/** + * Creates the window for the local history view. + * + * \return NSERROR_OK on success else appropriate error code on faliure. + */ +static nserror +nsgtk_local_history_init(struct browser_window *bw, + struct nsgtk_local_history_window **win_out) +{ + struct nsgtk_local_history_window *ncwin; + nserror res; + + /* memoise window so it can be represented when necessary + * instead of recreating every time. + */ + if ((*win_out) != NULL) { + res = local_history_set((*win_out)->session, bw); + return res; + } + + ncwin = calloc(1, sizeof(*ncwin)); + if (ncwin == NULL) { + return NSERROR_NOMEM; + } + + res = nsgtk_builder_new_from_resname("localhistory", &ncwin->builder); + if (res != NSERROR_OK) { + NSLOG(netsurf, INFO, "Local history UI builder init failed"); + free(ncwin); + return res; + } + + gtk_builder_connect_signals(ncwin->builder, NULL); + + ncwin->wnd = GTK_WINDOW(gtk_builder_get_object(ncwin->builder, + "wndHistory")); + + ncwin->core.scrolled = GTK_SCROLLED_WINDOW( + gtk_builder_get_object(ncwin->builder, + "HistoryScrolled")); + + ncwin->core.drawing_area = GTK_DRAWING_AREA( + gtk_builder_get_object(ncwin->builder, + "HistoryDrawingArea")); + + /* make the delete event hide the window */ + g_signal_connect(G_OBJECT(ncwin->wnd), + "delete_event", + G_CALLBACK(gtk_widget_hide_on_delete), + NULL); + + ncwin->core.draw = nsgtk_local_history_draw; + ncwin->core.key = nsgtk_local_history_key; + ncwin->core.mouse = nsgtk_local_history_mouse; + + res = nsgtk_corewindow_init(&ncwin->core); + if (res != NSERROR_OK) { + free(ncwin); + return res; + } + + res = local_history_init(ncwin->core.cb_table, + (struct core_window *)ncwin, + bw, + &ncwin->session); + if (res != NSERROR_OK) { + free(ncwin); + return res; + } + + *win_out = ncwin; + + return NSERROR_OK; +} + + +/* exported function documented gtk/history.h */ +nserror nsgtk_local_history_present(GtkWindow *parent, + struct browser_window *bw) +{ + nserror res; + int prnt_width, prnt_height; + int width, height; + res = nsgtk_local_history_init(bw, &local_history_window); + if (res == NSERROR_OK) { + gtk_window_set_transient_for(local_history_window->wnd, parent); + + gtk_window_get_size(parent, &prnt_width, &prnt_height); + + /* resize history widget ensureing the drawing area is + * no larger than parent window + */ + res = local_history_get_size(local_history_window->session, + &width, + &height); + if (width > prnt_width) { + width = prnt_width; + } + if (height > prnt_height) { + height = prnt_height; + } + gtk_window_resize(local_history_window->wnd, width, height); + + gtk_window_present(local_history_window->wnd); + } + + return res; +} + + +/* exported function documented gtk/history.h */ +nserror nsgtk_local_history_hide(void) +{ + nserror res = NSERROR_OK; + + if (local_history_window != NULL) { + gtk_widget_hide(GTK_WIDGET(local_history_window->wnd)); + + res = local_history_set(local_history_window->session, NULL); + } + + return res; +} + + +/* exported function documented gtk/history.h */ +nserror nsgtk_local_history_destroy(void) +{ + nserror res; + + if (local_history_window == NULL) { + return NSERROR_OK; + } + + res = local_history_fini(local_history_window->session); + if (res == NSERROR_OK) { + res = nsgtk_corewindow_fini(&local_history_window->core); + gtk_widget_destroy(GTK_WIDGET(local_history_window->wnd)); + g_object_unref(G_OBJECT(local_history_window->builder)); + free(local_history_window); + local_history_window = NULL; + } + + return res; + +} diff --git a/frontends/gtk/local_history.h b/frontends/gtk/local_history.h new file mode 100644 index 000000000..605405ddf --- /dev/null +++ b/frontends/gtk/local_history.h @@ -0,0 +1,49 @@ +/* + * Copyright 2017 Vincent Sanders <vince@kyllikki.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * \file + * Interface to GTK local history manager + */ + +#ifndef NSGTK_LOCAL_HISTORY_H +#define NSGTK_LOCAL_HISTORY_H + +struct browser_window; + +/** + * make the local history window visible. + * + * \return NSERROR_OK on success else appropriate error code on faliure. + */ +nserror nsgtk_local_history_present(GtkWindow *parent, struct browser_window *bw); + +/** + * hide the local history window from being visible. + * + * \return NSERROR_OK on success else appropriate error code on faliure. + */ +nserror nsgtk_local_history_hide(void); + +/** + * Destroys the local history window and performs any other necessary cleanup + * actions. + */ +nserror nsgtk_local_history_destroy(void); + +#endif diff --git a/frontends/gtk/login.c b/frontends/gtk/login.c index 3e29903fe..91d8b37f0 100644 --- a/frontends/gtk/login.c +++ b/frontends/gtk/login.c @@ -222,7 +222,7 @@ void gui_401login_open(nsurl *url, res = create_login_window(url, host, realm, cb, cbpw); if (res != NSERROR_OK) { - LOG("Login init failed"); + NSLOG(netsurf, INFO, "Login init failed"); /* creating login failed so cancel navigation */ cb(false, cbpw); diff --git a/frontends/gtk/menu.c b/frontends/gtk/menu.c index a93ef9385..6a6033231 100644 --- a/frontends/gtk/menu.c +++ b/frontends/gtk/menu.c @@ -27,6 +27,7 @@ #include "gtk/compat.h" #include "gtk/menu.h" #include "gtk/warn.h" +#include "gtk/accelerator.h" /** * Adds image menu item to a menu. @@ -34,28 +35,37 @@ * \param menu the menu to add the item to * \param item_out a pointer to the item's location in the menu struct * \param message the menu item I18n lookup value - * \param messageAccel the menu item accelerator I18n lookup value * \param group the 'global' in a gtk sense accelerator group * \return true if sucessful and \a item_out updated else false. */ -static bool nsgtk_menu_add_image_item(GtkMenu *menu, - GtkWidget **item_out, const char *message, - const char *messageAccel, GtkAccelGroup *group) +static bool +nsgtk_menu_add_image_item(GtkMenu *menu, + GtkWidget **item_out, + const char *message, + GtkAccelGroup *group) { unsigned int key; GdkModifierType mod; GtkWidget *item; - + const char *accelerator_desc; /* accelerator key description */ + item = nsgtk_image_menu_item_new_with_mnemonic(messages_get(message)); if (item == NULL) { return false; } - - gtk_accelerator_parse(messages_get(messageAccel), &key, &mod); - if (key > 0) { - gtk_widget_add_accelerator(item, "activate", group, key, mod, - GTK_ACCEL_VISIBLE); + + accelerator_desc = nsgtk_accelerator_get_desc(message); + if (accelerator_desc != NULL) { + gtk_accelerator_parse(accelerator_desc, &key, &mod); + if (key > 0) { + gtk_widget_add_accelerator(item, + "activate", + group, + key, + mod, + GTK_ACCEL_VISIBLE); + } } gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); gtk_widget_show(item); @@ -73,8 +83,7 @@ static bool nsgtk_menu_add_image_item(GtkMenu *menu, n->m##_menu = GTK_MENU(gtk_menu_new()) #define IMAGE_ITEM(p, q, r, s, t)\ - nsgtk_menu_add_image_item(s->p##_menu, &(s->q##_menuitem), #r,\ - #r "Accel", t) + nsgtk_menu_add_image_item(s->p##_menu, &(s->q##_menuitem), #r, t) #define CHECK_ITEM(p, q, r, s)\ s->q##_menuitem = GTK_CHECK_MENU_ITEM(\ @@ -130,8 +139,8 @@ static bool nsgtk_menu_add_image_item(GtkMenu *menu, * creates an export submenu * \param group the 'global' in a gtk sense accelerator reference */ - -static struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *group) +static struct nsgtk_export_submenu * +nsgtk_menu_export_submenu(GtkAccelGroup *group) { struct nsgtk_export_submenu *ret = malloc(sizeof(struct nsgtk_export_submenu)); @@ -157,8 +166,8 @@ static struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *gro * \param group the 'global' in a gtk sense accelerator reference */ -static struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu( - GtkAccelGroup *group) +static struct nsgtk_scaleview_submenu * +nsgtk_menu_scaleview_submenu(GtkAccelGroup *group) { struct nsgtk_scaleview_submenu *ret = malloc(sizeof(struct nsgtk_scaleview_submenu)); @@ -185,7 +194,8 @@ static struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu( static struct nsgtk_tabs_submenu *nsgtk_menu_tabs_submenu(GtkAccelGroup *group) { - struct nsgtk_tabs_submenu *ret = malloc(sizeof(struct nsgtk_tabs_submenu)); + struct nsgtk_tabs_submenu *ret; + ret = malloc(sizeof(struct nsgtk_tabs_submenu)); if (ret == NULL) { nsgtk_warning(messages_get("NoMemory"), 0); return NULL; diff --git a/frontends/gtk/plotters.c b/frontends/gtk/plotters.c index 817b72808..4a5ef510c 100644 --- a/frontends/gtk/plotters.c +++ b/frontends/gtk/plotters.c @@ -39,14 +39,15 @@ #include "gtk/scaffolding.h" #include "gtk/bitmap.h" -GtkWidget *current_widget; cairo_t *current_cr; static GdkRectangle cliprect; -struct plotter_table plot; - -/** Set cairo context colour to nsgtk colour. */ +/** + * Set cairo context colour to nsgtk colour. + * + * \param c the netsurf colour to set in cairo + */ void nsgtk_set_colour(colour c) { cairo_set_source_rgba(current_cr, @@ -56,29 +57,61 @@ void nsgtk_set_colour(colour c) 1.0); } -/** Set cairo context to solid plot operation. */ + +/** + * Set cairo context to solid plot operation. + */ static inline void nsgtk_set_solid(void) { double dashes = 0; cairo_set_dash(current_cr, &dashes, 0, 0); } -/** Set cairo context to dotted plot operation. */ + +/** + * Set cairo context to dotted plot operation. + */ static inline void nsgtk_set_dotted(void) { double cdashes[] = { 1.0, 2.0 }; cairo_set_dash(current_cr, cdashes, 2, 0); } -/** Set cairo context to dashed plot operation. */ + +/** + * Set cairo context to dashed plot operation. + */ static inline void nsgtk_set_dashed(void) { double cdashes[] = { 8.0, 2.0 }; cairo_set_dash(current_cr, cdashes, 2, 0); } -/** Set clipping area for subsequent plot operations. */ -static bool nsgtk_plot_clip(const struct rect *clip) + +/** + * Set cairo context line width. + */ +static inline void nsgtk_set_line_width(plot_style_fixed width) +{ + if (width == 0) { + cairo_set_line_width(current_cr, 1); + } else { + cairo_set_line_width(current_cr, + plot_style_fixed_to_double(width)); + } +} + + +/** + * \brief Sets a clip rectangle for subsequent plot operations. + * + * \param ctx The current redraw context. + * \param clip The rectangle to limit all subsequent plot + * operations within. + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_plot_clip(const struct redraw_context *ctx, const struct rect *clip) { cairo_reset_clip(current_cr); cairo_rectangle(current_cr, clip->x0, clip->y0, @@ -90,11 +123,30 @@ static bool nsgtk_plot_clip(const struct rect *clip) cliprect.width = clip->x1 - clip->x0; cliprect.height = clip->y1 - clip->y0; - return true; + return NSERROR_OK; } -static bool nsgtk_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style) +/** + * Plots an arc + * + * plot an arc segment around (x,y), anticlockwise from angle1 + * to angle2. Angles are measured anticlockwise from + * horizontal, in degrees. + * + * \param ctx The current redraw context. + * \param style Style controlling the arc plot. + * \param x The x coordinate of the arc. + * \param y The y coordinate of the arc. + * \param radius The radius of the arc. + * \param angle1 The start angle of the arc. + * \param angle2 The finish angle of the arc. + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_plot_arc(const struct redraw_context *ctx, + const plot_style_t *style, + int x, int y, int radius, int angle1, int angle2) { nsgtk_set_colour(style->fill_colour); nsgtk_set_solid(); @@ -105,10 +157,26 @@ static bool nsgtk_plot_arc(int x, int y, int radius, int angle1, int angle2, con (angle2 + 90) * (M_PI / 180)); cairo_stroke(current_cr); - return true; + return NSERROR_OK; } -static bool nsgtk_plot_disc(int x, int y, int radius, const plot_style_t *style) + +/** + * Plots a circle + * + * Plot a circle centered on (x,y), which is optionally filled. + * + * \param ctx The current redraw context. + * \param style Style controlling the circle plot. + * \param x x coordinate of circle centre. + * \param y y coordinate of circle centre. + * \param radius circle radius. + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_plot_disc(const struct redraw_context *ctx, + const plot_style_t *style, + int x, int y, int radius) { if (style->fill_type != PLOT_OP_TYPE_NONE) { nsgtk_set_colour(style->fill_colour); @@ -123,49 +191,60 @@ static bool nsgtk_plot_disc(int x, int y, int radius, const plot_style_t *style) nsgtk_set_colour(style->stroke_colour); switch (style->stroke_type) { - case PLOT_OP_TYPE_SOLID: /**< Solid colour */ + case PLOT_OP_TYPE_SOLID: /* Solid colour */ default: nsgtk_set_solid(); break; - case PLOT_OP_TYPE_DOT: /**< Doted plot */ + case PLOT_OP_TYPE_DOT: /* Doted plot */ nsgtk_set_dotted(); break; - case PLOT_OP_TYPE_DASH: /**< dashed plot */ + case PLOT_OP_TYPE_DASH: /* dashed plot */ nsgtk_set_dashed(); break; } - if (style->stroke_width == 0) - cairo_set_line_width(current_cr, 1); - else - cairo_set_line_width(current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); cairo_arc(current_cr, x, y, radius, 0, M_PI * 2); cairo_stroke(current_cr); } - return true; + return NSERROR_OK; } -static bool -nsgtk_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style) + +/** + * Plots a line + * + * plot a line from (x0,y0) to (x1,y1). Coordinates are at + * centre of line width/thickness. + * + * \param ctx The current redraw context. + * \param style Style controlling the line plot. + * \param line A rectangle defining the line to be drawn + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_plot_line(const struct redraw_context *ctx, + const plot_style_t *style, + const struct rect *line) { nsgtk_set_colour(style->stroke_colour); switch (style->stroke_type) { - case PLOT_OP_TYPE_SOLID: /**< Solid colour */ + case PLOT_OP_TYPE_SOLID: /* Solid colour */ default: nsgtk_set_solid(); break; - case PLOT_OP_TYPE_DOT: /**< Doted plot */ + case PLOT_OP_TYPE_DOT: /* Doted plot */ nsgtk_set_dotted(); break; - case PLOT_OP_TYPE_DASH: /**< dashed plot */ + case PLOT_OP_TYPE_DASH: /* dashed plot */ nsgtk_set_dashed(); break; } @@ -174,23 +253,25 @@ nsgtk_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style) nsgtk_set_colour(style->stroke_colour); } - if (style->stroke_width == 0) - cairo_set_line_width(current_cr, 1); - else - cairo_set_line_width(current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); /* core expects horizontal and vertical lines to be on pixels, not - * between pixels */ - cairo_move_to(current_cr, (x0 == x1) ? x0 + 0.5 : x0, - (y0 == y1) ? y0 + 0.5 : y0); - cairo_line_to(current_cr, (x0 == x1) ? x1 + 0.5 : x1, - (y0 == y1) ? y1 + 0.5 : y1); + * between pixels + */ + cairo_move_to(current_cr, + (line->x0 == line->x1) ? line->x0 + 0.5 : line->x0, + (line->y0 == line->y1) ? line->y0 + 0.5 : line->y0); + cairo_line_to(current_cr, + (line->x0 == line->x1) ? line->x1 + 0.5 : line->x1, + (line->y0 == line->y1) ? line->y1 + 0.5 : line->y1); cairo_stroke(current_cr); - return true; + return NSERROR_OK; } -/** Plot a caret. + +/** + * Plot a caret. * * @note It is assumed that the plotters have been set up. */ @@ -207,14 +288,35 @@ void nsgtk_plot_caret(int x, int y, int h) cairo_stroke(current_cr); } -static bool nsgtk_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) + +/** + * Plots a rectangle. + * + * The rectangle can be filled an outline or both controlled + * by the plot style The line can be solid, dotted or + * dashed. Top left corner at (x0,y0) and rectangle has given + * width and height. + * + * \param ctx The current redraw context. + * \param style Style controlling the rectangle plot. + * \param rect A rectangle defining the line to be drawn + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_plot_rectangle(const struct redraw_context *ctx, + const plot_style_t *style, + const struct rect *rect) { if (style->fill_type != PLOT_OP_TYPE_NONE) { nsgtk_set_colour(style->fill_colour); nsgtk_set_solid(); cairo_set_line_width(current_cr, 0); - cairo_rectangle(current_cr, x0, y0, x1 - x0, y1 - y0); + cairo_rectangle(current_cr, + rect->x0, + rect->y0, + rect->x1 - rect->x0, + rect->y1 - rect->y0); cairo_fill(current_cr); cairo_stroke(current_cr); } @@ -223,32 +325,52 @@ static bool nsgtk_plot_rectangle(int x0, int y0, int x1, int y1, const plot_styl nsgtk_set_colour(style->stroke_colour); switch (style->stroke_type) { - case PLOT_OP_TYPE_SOLID: /**< Solid colour */ + case PLOT_OP_TYPE_SOLID: /* Solid colour */ default: nsgtk_set_solid(); break; - case PLOT_OP_TYPE_DOT: /**< Doted plot */ + case PLOT_OP_TYPE_DOT: /* Doted plot */ nsgtk_set_dotted(); break; - case PLOT_OP_TYPE_DASH: /**< dashed plot */ + case PLOT_OP_TYPE_DASH: /* dashed plot */ nsgtk_set_dashed(); break; } - if (style->stroke_width == 0) - cairo_set_line_width(current_cr, 1); - else - cairo_set_line_width(current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); - cairo_rectangle(current_cr, x0 + 0.5, y0 + 0.5, x1 - x0, y1 - y0); + cairo_rectangle(current_cr, + rect->x0 + 0.5, + rect->y0 + 0.5, + rect->x1 - rect->x0, + rect->y1 - rect->y0); cairo_stroke(current_cr); } - return true; + return NSERROR_OK; } -static bool nsgtk_plot_polygon(const int *p, unsigned int n, const plot_style_t *style) + +/** + * Plot a polygon + * + * Plots a filled polygon with straight lines between + * points. The lines around the edge of the ploygon are not + * plotted. The polygon is filled with the non-zero winding + * rule. + * + * \param ctx The current redraw context. + * \param style Style controlling the polygon plot. + * \param p verticies of polygon + * \param n number of verticies. + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_plot_polygon(const struct redraw_context *ctx, + const plot_style_t *style, + const int *p, + unsigned int n) { unsigned int i; @@ -263,201 +385,46 @@ static bool nsgtk_plot_polygon(const int *p, unsigned int n, const plot_style_t cairo_fill(current_cr); cairo_stroke(current_cr); - return true; -} - - - - -static bool nsgtk_plot_text(int x, int y, const char *text, size_t length, - const struct plot_font_style *fstyle) -{ - return nsfont_paint(x, y, text, length, fstyle); -} - - - -static bool nsgtk_plot_pixbuf(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg) -{ - int x0, y0, x1, y1; - int dsrcx, dsrcy, dwidth, dheight; - int bmwidth, bmheight; - - cairo_surface_t *bmsurface = bitmap->surface; - - /* Bail early if we can */ - if (width == 0 || height == 0) - /* Nothing to plot */ - return true; - if ((x > (cliprect.x + cliprect.width)) || - ((x + width) < cliprect.x) || - (y > (cliprect.y + cliprect.height)) || - ((y + height) < cliprect.y)) { - /* Image completely outside clip region */ - return true; - } - - /* Get clip rectangle / image rectangle edge differences */ - x0 = cliprect.x - x; - y0 = cliprect.y - y; - x1 = (x + width) - (cliprect.x + cliprect.width); - y1 = (y + height) - (cliprect.y + cliprect.height); - - /* Set initial draw geometry */ - dsrcx = x; - dsrcy = y; - dwidth = width; - dheight = height; - - /* Manually clip draw coordinates to area of image to be rendered */ - if (x0 > 0) { - /* Clip left */ - dsrcx += x0; - dwidth -= x0; - } - if (y0 > 0) { - /* Clip top */ - dsrcy += y0; - dheight -= y0; - } - if (x1 > 0) { - /* Clip right */ - dwidth -= x1; - } - if (y1 > 0) { - /* Clip bottom */ - dheight -= y1; - } - - if (dwidth == 0 || dheight == 0) - /* Nothing to plot */ - return true; - - bmwidth = cairo_image_surface_get_width(bmsurface); - bmheight = cairo_image_surface_get_height(bmsurface); - - /* Render the bitmap */ - if ((bmwidth == width) && (bmheight == height)) { - /* Bitmap is not scaled */ - /* Plot the bitmap */ - cairo_set_source_surface(current_cr, bmsurface, x, y); - cairo_rectangle(current_cr, dsrcx, dsrcy, dwidth, dheight); - cairo_fill(current_cr); - - } else { - /* Bitmap is scaled */ - if ((bitmap->scsurface != NULL) && - ((cairo_image_surface_get_width(bitmap->scsurface) != width) || - (cairo_image_surface_get_height(bitmap->scsurface) != height))){ - cairo_surface_destroy(bitmap->scsurface); - bitmap->scsurface = NULL; - } - - if (bitmap->scsurface == NULL) { - bitmap->scsurface = cairo_surface_create_similar(bmsurface,CAIRO_CONTENT_COLOR_ALPHA, width, height); - cairo_t *cr = cairo_create(bitmap->scsurface); - - /* Scale *before* setting the source surface (1) */ - cairo_scale(cr, (double)width / bmwidth, (double)height / bmheight); - cairo_set_source_surface(cr, bmsurface, 0, 0); - - /* To avoid getting the edge pixels blended with 0 - * alpha, which would occur with the default - * EXTEND_NONE. Use EXTEND_PAD for 1.2 or newer (2) - */ - cairo_pattern_set_extend(cairo_get_source(cr), - CAIRO_EXTEND_REFLECT); - - /* Replace the destination with the source instead of - * overlaying - */ - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - - /* Do the actual drawing */ - cairo_paint(cr); - - cairo_destroy(cr); - - } - /* Plot the scaled bitmap */ - cairo_set_source_surface(current_cr, bitmap->scsurface, x, y); - cairo_rectangle(current_cr, dsrcx, dsrcy, dwidth, dheight); - cairo_fill(current_cr); - - - } - - return true; + return NSERROR_OK; } -static bool nsgtk_plot_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg, - bitmap_flags_t flags) -{ - int doneheight = 0, donewidth = 0; - bool repeat_x = (flags & BITMAPF_REPEAT_X); - bool repeat_y = (flags & BITMAPF_REPEAT_Y); - - /* Bail early if we can */ - if (width == 0 || height == 0) - /* Nothing to plot */ - return true; - - if (!(repeat_x || repeat_y)) { - /* Not repeating at all, so just pass it on */ - return nsgtk_plot_pixbuf(x, y, width, height, bitmap, bg); - } - - if (y > cliprect.y) { - doneheight = (cliprect.y - height) + ((y - cliprect.y) % height); - } else { - doneheight = y; - } - - while (doneheight < (cliprect.y + cliprect.height)) { - if (x > cliprect.x) { - donewidth = (cliprect.x - width) + ((x - cliprect.x) % width); - } else { - donewidth = x; - } - - while (donewidth < (cliprect.x + cliprect.width)) { - nsgtk_plot_pixbuf(donewidth, doneheight, - width, height, bitmap, bg); - donewidth += width; - if (!repeat_x) - break; - } - doneheight += height; - - if (!repeat_y) - break; - } - - return true; -} -static bool nsgtk_plot_path(const float *p, unsigned int n, colour fill, float width, - colour c, const float transform[6]) +/** + * Plots a path. + * + * Path plot consisting of cubic Bezier curves. Line and fill colour is + * controlled by the plot style. + * + * \param ctx The current redraw context. + * \param pstyle Style controlling the path plot. + * \param p elements of path + * \param n nunber of elements on path + * \param transform A transform to apply to the path. + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_plot_path(const struct redraw_context *ctx, + const plot_style_t *pstyle, + const float *p, + unsigned int n, + const float transform[6]) { unsigned int i; cairo_matrix_t old_ctm, n_ctm; if (n == 0) - return true; + return NSERROR_OK; if (p[0] != PLOTTER_PATH_MOVE) { - LOG("Path does not start with move"); - return false; + NSLOG(netsurf, INFO, "Path does not start with move"); + return NSERROR_INVALID; } - /* Save CTM */ cairo_get_matrix(current_cr, &old_ctm); /* Set up line style and width */ - cairo_set_line_width(current_cr, 1); + nsgtk_set_line_width(pstyle->stroke_width); nsgtk_set_solid(); /* Load new CTM */ @@ -487,10 +454,10 @@ static bool nsgtk_plot_path(const float *p, unsigned int n, colour fill, float w p[i+5], p[i+6]); i += 7; } else { - LOG("bad path command %f", p[i]); + NSLOG(netsurf, INFO, "bad path command %f", p[i]); /* Reset matrix for safety */ cairo_set_matrix(current_cr, &old_ctm); - return false; + return NSERROR_INVALID; } } @@ -498,27 +465,184 @@ static bool nsgtk_plot_path(const float *p, unsigned int n, colour fill, float w cairo_set_matrix(current_cr, &old_ctm); /* Now draw path */ - if (fill != NS_TRANSPARENT) { - nsgtk_set_colour(fill); + if (pstyle->fill_colour != NS_TRANSPARENT) { + nsgtk_set_colour(pstyle->fill_colour); - if (c != NS_TRANSPARENT) { + if (pstyle->stroke_colour != NS_TRANSPARENT) { /* Fill & Stroke */ cairo_fill_preserve(current_cr); - nsgtk_set_colour(c); + nsgtk_set_colour(pstyle->stroke_colour); cairo_stroke(current_cr); } else { /* Fill only */ cairo_fill(current_cr); } - } else if (c != NS_TRANSPARENT) { + } else if (pstyle->stroke_colour != NS_TRANSPARENT) { /* Stroke only */ - nsgtk_set_colour(c); + nsgtk_set_colour(pstyle->stroke_colour); cairo_stroke(current_cr); } - return true; + return NSERROR_OK; } + +/** + * Plot a bitmap + * + * Tiled plot of a bitmap image. (x,y) gives the top left + * coordinate of an explicitly placed tile. From this tile the + * image can repeat in all four directions -- up, down, left + * and right -- to the extents given by the current clip + * rectangle. + * + * The bitmap_flags say whether to tile in the x and y + * directions. If not tiling in x or y directions, the single + * image is plotted. The width and height give the dimensions + * the image is to be scaled to. + * + * \param ctx The current redraw context. + * \param bitmap The bitmap to plot + * \param x The x coordinate to plot the bitmap + * \param y The y coordiante to plot the bitmap + * \param width The width of area to plot the bitmap into + * \param height The height of area to plot the bitmap into + * \param bg the background colour to alpha blend into + * \param flags the flags controlling the type of plot operation + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_plot_bitmap(const struct redraw_context *ctx, + struct bitmap *bitmap, + int x, int y, + int width, + int height, + colour bg, + bitmap_flags_t flags) +{ + bool repeat_x = (flags & BITMAPF_REPEAT_X); + bool repeat_y = (flags & BITMAPF_REPEAT_Y); + GdkRectangle cliprect_bitmap; + cairo_surface_t *img_surface; + int img_width, img_height; + + /* Bail early if we can */ + if (width <= 0 || height <= 0) { + /* Nothing to plot */ + return NSERROR_OK; + } + + /* Copy the clip rectangle into bitmap plot clip rectangle */ + cliprect_bitmap = cliprect; + + /* Constrain bitmap plot rectangle for any lack of tiling */ + if (!repeat_x) { + if (cliprect_bitmap.width > width) { + cliprect_bitmap.width = width; + } + if (cliprect_bitmap.x < x) { + cliprect_bitmap.x = x; + cliprect_bitmap.width -= x - cliprect_bitmap.x; + } + } + if (!repeat_y) { + if (cliprect_bitmap.height > height) { + cliprect_bitmap.height = height; + } + if (cliprect_bitmap.y < y) { + cliprect_bitmap.y = y; + cliprect_bitmap.height -= y - cliprect_bitmap.y; + } + } + + /* Bail early if we can */ + if (cliprect_bitmap.width <= 0 || cliprect_bitmap.height <= 0) { + /* Nothing to plot */ + return NSERROR_OK; + } + + /* Get the image's surface and intrinsic dimensions */ + img_surface = bitmap->surface; + img_width = cairo_image_surface_get_width(img_surface); + img_height = cairo_image_surface_get_height(img_surface); + + /* Set the source surface */ + if ((img_width == width) && (img_height == height)) { + /* Non-scaled rendering */ + cairo_set_source_surface(current_cr, img_surface, x, y); + + /* Enable tiling if we're repeating */ + if (repeat_x || repeat_y) { + cairo_pattern_set_extend( + cairo_get_source(current_cr), + CAIRO_EXTEND_REPEAT); + } + + /* Render the bitmap */ + cairo_rectangle(current_cr, + cliprect_bitmap.x, + cliprect_bitmap.y, + cliprect_bitmap.width, + cliprect_bitmap.height); + cairo_fill(current_cr); + } else { + /* Scaled rendering */ + double scale_x = (double)width / img_width; + double scale_y = (double)height / img_height; + + /* Save cairo rendering context state before scaling */ + cairo_save(current_cr); + cairo_scale(current_cr, scale_x, scale_y); + + cairo_set_source_surface(current_cr, img_surface, + x / scale_x, y / scale_y); + + /* Enable tiling if we're repeating */ + if (repeat_x || repeat_y) { + cairo_pattern_set_extend( + cairo_get_source(current_cr), + CAIRO_EXTEND_REPEAT); + } + + /* Render the bitmap */ + cairo_rectangle(current_cr, + cliprect_bitmap.x / scale_x, + cliprect_bitmap.y / scale_y, + cliprect_bitmap.width / scale_x, + cliprect_bitmap.height / scale_y); + cairo_fill(current_cr); + + /* Restore pre-scaling cairo rendering state */ + cairo_restore(current_cr); + } + + return NSERROR_OK; +} + + +/** + * Text plotting. + * + * \param ctx The current redraw context. + * \param fstyle plot style for this text + * \param x x coordinate + * \param y y coordinate + * \param text UTF-8 string to plot + * \param length length of string, in bytes + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_plot_text(const struct redraw_context *ctx, + const struct plot_font_style *fstyle, + int x, + int y, + const char *text, + size_t length) +{ + return nsfont_paint(x, y, text, length, fstyle); +} + + /** GTK plotter table */ const struct plotter_table nsgtk_plotters = { .clip = nsgtk_plot_clip, @@ -532,6 +656,3 @@ const struct plotter_table nsgtk_plotters = { .text = nsgtk_plot_text, .option_knockout = true }; - - - diff --git a/frontends/gtk/plotters.h b/frontends/gtk/plotters.h index c88a8da0c..453d5ceb5 100644 --- a/frontends/gtk/plotters.h +++ b/frontends/gtk/plotters.h @@ -16,8 +16,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/** \file - * Target independent plotting (GDK / GTK+ interface). +/** + * \file + * Target independent plotting GTK+ interface. */ #ifndef NETSURF_GTK_PLOTTERS_H @@ -30,7 +31,6 @@ struct plotter_table; extern const struct plotter_table nsgtk_plotters; /* make sure this is NULL if no redraw is in progress */ -extern GtkWidget *current_widget; extern cairo_t *current_cr; void nsgtk_set_colour(colour c); diff --git a/frontends/gtk/preferences.c b/frontends/gtk/preferences.c index e51e77014..dac4a559d 100644 --- a/frontends/gtk/preferences.c +++ b/frontends/gtk/preferences.c @@ -621,7 +621,7 @@ comboboxLanguage_add_from_file(GtkListStore *liststore, gtk_list_store_clear(liststore); - LOG("Used %s for languages", file_location); + NSLOG(netsurf, INFO, "Used %s for languages", file_location); while (fgets(buf, sizeof(buf), fp)) { /* Ignore blank lines */ if (buf[0] == '\0') @@ -668,7 +668,7 @@ nsgtk_preferences_comboboxLanguage_realize(GtkWidget *widget, const char *accept_language; if (priv->content_language == NULL) { - LOG("content language list store unavailable"); + NSLOG(netsurf, INFO, "content language list store unavailable"); return; } @@ -697,7 +697,7 @@ nsgtk_preferences_comboboxLanguage_realize(GtkWidget *widget, } } if (res != NSERROR_OK) { - LOG("error populatiung languages combo"); + NSLOG(netsurf, INFO, "error populatiung languages combo"); } } @@ -826,7 +826,7 @@ ENTRY_SIGNALS(entryHomePageURL, homepage_url) G_MODULE_EXPORT void nsgtk_preferences_setCurrentPage_clicked(GtkButton *button, struct ppref *priv) { - const gchar *url = nsurl_access(browser_window_get_url(priv->bw)); + const gchar *url = nsurl_access(browser_window_access_url(priv->bw)); if (priv->entryHomePageURL != NULL) { gtk_entry_set_text(GTK_ENTRY(priv->entryHomePageURL), url); @@ -989,14 +989,15 @@ GtkWidget* nsgtk_preferences(struct browser_window *bw, GtkWindow *parent) res = nsgtk_builder_new_from_resname("options", &preferences_builder); if (res != NSERROR_OK) { - LOG("Preferences UI builder init failed"); + NSLOG(netsurf, INFO, "Preferences UI builder init failed"); return NULL; } priv->dialog = gtk_builder_get_object(preferences_builder, "dialogPreferences"); if (priv->dialog == NULL) { - LOG("Unable to get object for preferences dialog"); + NSLOG(netsurf, INFO, + "Unable to get object for preferences dialog"); /* release builder as were done with it */ g_object_unref(G_OBJECT(preferences_builder)); return NULL; diff --git a/frontends/gtk/print.c b/frontends/gtk/print.c index 55dcf6390..c4f1b0f7a 100644 --- a/frontends/gtk/print.c +++ b/frontends/gtk/print.c @@ -17,8 +17,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - /** \file - * GTK printing (implementation). + +/** + * \file + * GTK printing implementation. * All the functions and structures necessary for printing( signal handlers, * plotters, printer) are here. * Most of the plotters have been copied from the gtk_plotters.c file. @@ -71,7 +73,7 @@ static inline void nsgtk_print_set_colour(colour c) -static bool gtk_print_font_paint(int x, int y, +static nserror gtk_print_font_paint(int x, int y, const char *string, size_t length, const plot_font_style_t *fstyle) { @@ -81,7 +83,7 @@ static bool gtk_print_font_paint(int x, int y, PangoLayoutLine *line; if (length == 0) - return true; + return NSERROR_OK; desc = nsfont_style_to_description(fstyle); size = (gint) ((double) pango_font_description_get_size(desc) * @@ -106,7 +108,7 @@ static bool gtk_print_font_paint(int x, int y, g_object_unref(layout); pango_font_description_free(desc); - return true; + return NSERROR_OK; } @@ -131,10 +133,32 @@ static inline void nsgtk_print_set_dashed(void) cairo_set_dash(gtk_print_current_cr, cdashes, 1, 0); } -/** Set clipping area for subsequent plot operations. */ -static bool nsgtk_print_plot_clip(const struct rect *clip) +/** Set cairo context line width. */ +static inline void nsgtk_set_line_width(plot_style_fixed width) { - LOG("Clipping. x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", clip->x0, clip->y0, clip->x1, clip->y1); + if (width == 0) { + cairo_set_line_width(gtk_print_current_cr, 1); + } else { + cairo_set_line_width(gtk_print_current_cr, + plot_style_fixed_to_double(width)); + } +} + + +/** + * \brief Sets a clip rectangle for subsequent plot operations. + * + * \param ctx The current redraw context. + * \param clip The rectangle to limit all subsequent plot + * operations within. + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_print_plot_clip(const struct redraw_context *ctx, const struct rect *clip) +{ + NSLOG(netsurf, INFO, + "Clipping. x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", clip->x0, + clip->y0, clip->x1, clip->y1); /* Normalize cllipping area - to prevent overflows. * See comment in pdf_plot_fill. */ @@ -153,10 +177,30 @@ static bool nsgtk_print_plot_clip(const struct rect *clip) cliprect.width = clip_x1 - clip_x0; cliprect.height = clip_y1 - clip_y0; - return true; + return NSERROR_OK; } -static bool nsgtk_print_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style) + +/** + * Plots an arc + * + * plot an arc segment around (x,y), anticlockwise from angle1 + * to angle2. Angles are measured anticlockwise from + * horizontal, in degrees. + * + * \param ctx The current redraw context. + * \param style Style controlling the arc plot. + * \param x The x coordinate of the arc. + * \param y The y coordinate of the arc. + * \param radius The radius of the arc. + * \param angle1 The start angle of the arc. + * \param angle2 The finish angle of the arc. + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_print_plot_arc(const struct redraw_context *ctx, + const plot_style_t *style, + int x, int y, int radius, int angle1, int angle2) { nsgtk_print_set_colour(style->fill_colour); nsgtk_print_set_solid(); @@ -167,10 +211,26 @@ static bool nsgtk_print_plot_arc(int x, int y, int radius, int angle1, int angle (angle2 + 90) * (M_PI / 180)); cairo_stroke(gtk_print_current_cr); - return true; + return NSERROR_OK; } -static bool nsgtk_print_plot_disc(int x, int y, int radius, const plot_style_t *style) + +/** + * Plots a circle + * + * Plot a circle centered on (x,y), which is optionally filled. + * + * \param ctx The current redraw context. + * \param style Style controlling the circle plot. + * \param x x coordinate of circle centre. + * \param y y coordinate of circle centre. + * \param radius circle radius. + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_print_plot_disc(const struct redraw_context *ctx, + const plot_style_t *style, + int x, int y, int radius) { if (style->fill_type != PLOT_OP_TYPE_NONE) { nsgtk_print_set_colour(style->fill_colour); @@ -199,19 +259,31 @@ static bool nsgtk_print_plot_disc(int x, int y, int radius, const plot_style_t * break; } - if (style->stroke_width == 0) - cairo_set_line_width(gtk_print_current_cr, 1); - else - cairo_set_line_width(gtk_print_current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); cairo_arc(gtk_print_current_cr, x, y, radius, 0, M_PI * 2); cairo_stroke(gtk_print_current_cr); } - return true; + return NSERROR_OK; } -static bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style) + +/** + * Plots a line + * + * plot a line from (x0,y0) to (x1,y1). Coordinates are at + * centre of line width/thickness. + * + * \param ctx The current redraw context. + * \param style Style controlling the line plot. + * \param line A rectangle defining the line to be drawn + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_print_plot_line(const struct redraw_context *ctx, + const plot_style_t *style, + const struct rect *line) { nsgtk_print_set_colour(style->stroke_colour); @@ -230,42 +302,61 @@ static bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, const plot_sty break; } - if (style->stroke_width == 0) - cairo_set_line_width(gtk_print_current_cr, 1); - else - cairo_set_line_width(gtk_print_current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); - cairo_move_to(gtk_print_current_cr, x0 + 0.5, y0 + 0.5); - cairo_line_to(gtk_print_current_cr, x1 + 0.5, y1 + 0.5); + cairo_move_to(gtk_print_current_cr, line->x0 + 0.5, line->y0 + 0.5); + cairo_line_to(gtk_print_current_cr, line->x1 + 0.5, line->y1 + 0.5); cairo_stroke(gtk_print_current_cr); - return true; + return NSERROR_OK; } -static bool nsgtk_print_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) + +/** + * Plots a rectangle. + * + * The rectangle can be filled an outline or both controlled + * by the plot style The line can be solid, dotted or + * dashed. Top left corner at (x0,y0) and rectangle has given + * width and height. + * + * \param ctx The current redraw context. + * \param style Style controlling the rectangle plot. + * \param rect A rectangle defining the line to be drawn + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_print_plot_rectangle(const struct redraw_context *ctx, + const plot_style_t *style, + const struct rect *rect) { - LOG("x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", x0, y0, x1, y1); + NSLOG(netsurf, INFO, "x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", + rect->x0, rect->y0, rect->x1, rect->y1); if (style->fill_type != PLOT_OP_TYPE_NONE) { + int x0,y0,x1,y1; nsgtk_print_set_colour(style->fill_colour); nsgtk_print_set_solid(); /* Normalize boundaries of the area - to prevent overflows. * See comment in pdf_plot_fill. */ - x0 = min(max(x0, 0), settings->page_width); - y0 = min(max(y0, 0), settings->page_height); - x1 = min(max(x1, 0), settings->page_width); - y1 = min(max(y1, 0), settings->page_height); + x0 = min(max(rect->x0, 0), settings->page_width); + y0 = min(max(rect->y0, 0), settings->page_height); + x1 = min(max(rect->x1, 0), settings->page_width); + y1 = min(max(rect->y1, 0), settings->page_height); cairo_set_line_width(gtk_print_current_cr, 0); - cairo_rectangle(gtk_print_current_cr, x0, y0, x1 - x0, y1 - y0); + cairo_rectangle(gtk_print_current_cr, + x0, y0, + x1 - x0, y1 - y0); cairo_fill(gtk_print_current_cr); cairo_stroke(gtk_print_current_cr); } if (style->stroke_type != PLOT_OP_TYPE_NONE) { - nsgtk_print_set_colour(style->stroke_colour); + + nsgtk_print_set_colour(style->stroke_colour); switch (style->stroke_type) { case PLOT_OP_TYPE_SOLID: /**< Solid colour */ @@ -282,23 +373,28 @@ static bool nsgtk_print_plot_rectangle(int x0, int y0, int x1, int y1, const plo break; } - if (style->stroke_width == 0) - cairo_set_line_width(gtk_print_current_cr, 1); - else - cairo_set_line_width(gtk_print_current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); + + cairo_rectangle(gtk_print_current_cr, + rect->x0, rect->y0, + rect->x1 - rect->x0, rect->y1 - rect->y0); - cairo_rectangle(gtk_print_current_cr, x0, y0, x1 - x0, y1 - y0); cairo_stroke(gtk_print_current_cr); } - return true; + return NSERROR_OK; } -static bool nsgtk_print_plot_polygon(const int *p, unsigned int n, const plot_style_t *style) + +static nserror +nsgtk_print_plot_polygon(const struct redraw_context *ctx, + const plot_style_t *style, + const int *p, + unsigned int n) { unsigned int i; - LOG("Plotting polygon."); + NSLOG(netsurf, INFO, "Plotting polygon."); nsgtk_print_set_colour(style->fill_colour); nsgtk_print_set_solid(); @@ -306,28 +402,46 @@ static bool nsgtk_print_plot_polygon(const int *p, unsigned int n, const plot_st cairo_set_line_width(gtk_print_current_cr, 0); cairo_move_to(gtk_print_current_cr, p[0], p[1]); - LOG("Starting line at: %i\t%i", p[0], p[1]); + NSLOG(netsurf, INFO, "Starting line at: %i\t%i", p[0], p[1]); for (i = 1; i != n; i++) { cairo_line_to(gtk_print_current_cr, p[i * 2], p[i * 2 + 1]); - LOG("Drawing line to: %i\t%i", p[i * 2], p[i * 2 + 1]); + NSLOG(netsurf, INFO, "Drawing line to: %i\t%i", p[i * 2], + p[i * 2 + 1]); } cairo_fill(gtk_print_current_cr); cairo_stroke(gtk_print_current_cr); - return true; + return NSERROR_OK; } -static bool nsgtk_print_plot_path(const float *p, unsigned int n, colour fill, - float width, colour c, const float transform[6]) +/** + * Plots a path. + * + * Path plot consisting of cubic Bezier curves. Line and fill colour is + * controlled by the plot style. + * + * \param ctx The current redraw context. + * \param pstyle Style controlling the path plot. + * \param p elements of path + * \param n nunber of elements on path + * \param transform A transform to apply to the path. + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_print_plot_path(const struct redraw_context *ctx, + const plot_style_t *pstyle, + const float *p, + unsigned int n, + const float transform[6]) { /* Only the internal SVG renderer uses this plot call currently, * and the GTK version uses librsvg. Thus, we ignore this complexity, * and just return true obliviously. */ - return true; + return NSERROR_OK; } @@ -445,9 +559,37 @@ static bool nsgtk_print_plot_pixbuf(int x, int y, int width, int height, } -static bool nsgtk_print_plot_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg, - bitmap_flags_t flags) +/** + * Plot a bitmap + * + * Tiled plot of a bitmap image. (x,y) gives the top left + * coordinate of an explicitly placed tile. From this tile the + * image can repeat in all four directions -- up, down, left + * and right -- to the extents given by the current clip + * rectangle. + * + * The bitmap_flags say whether to tile in the x and y + * directions. If not tiling in x or y directions, the single + * image is plotted. The width and height give the dimensions + * the image is to be scaled to. + * + * \param ctx The current redraw context. + * \param bitmap The bitmap to plot + * \param x The x coordinate to plot the bitmap + * \param y The y coordiante to plot the bitmap + * \param width The width of area to plot the bitmap into + * \param height The height of area to plot the bitmap into + * \param bg the background colour to alpha blend into + * \param flags the flags controlling the type of plot operation + * \return NSERROR_OK on success else error code. + */ +static nserror +nsgtk_print_plot_bitmap(const struct redraw_context *ctx, + struct bitmap *bitmap, + int x, int y, + int width, int height, + colour bg, + bitmap_flags_t flags) { int doneheight = 0, donewidth = 0; bool repeat_x = (flags & BITMAPF_REPEAT_X); @@ -495,12 +637,19 @@ static bool nsgtk_print_plot_bitmap(int x, int y, int width, int height, return true; } -static bool nsgtk_print_plot_text(int x, int y, const char *text, size_t length, - const plot_font_style_t *fstyle) + +static nserror +nsgtk_print_plot_text(const struct redraw_context *ctx, + const struct plot_font_style *fstyle, + int x, + int y, + const char *text, + size_t length) { return gtk_print_font_paint(x, y, text, length, fstyle); } + /** GTK print plotter table */ static const struct plotter_table nsgtk_print_plotters = { .clip = nsgtk_print_plot_clip, @@ -549,7 +698,7 @@ void gtk_print_signal_begin_print (GtkPrintOperation *operation, int page_number; double height_on_page, height_to_print; - LOG("Begin print"); + NSLOG(netsurf, INFO, "Begin print"); settings = user_data; @@ -568,7 +717,11 @@ void gtk_print_signal_begin_print (GtkPrintOperation *operation, } else { - LOG("page_width: %f ;page_height: %f; content height: %lf", settings->page_width, settings->page_height, height_to_print); + NSLOG(netsurf, INFO, + "page_width: %f ;page_height: %f; content height: %lf", + settings->page_width, + settings->page_height, + height_to_print); height_on_page = settings->page_height; height_on_page = height_on_page - @@ -592,7 +745,7 @@ void gtk_print_signal_begin_print (GtkPrintOperation *operation, void gtk_print_signal_draw_page(GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr, gpointer user_data) { - LOG("Draw Page"); + NSLOG(netsurf, INFO, "Draw Page"); gtk_print_current_cr = gtk_print_context_get_cairo_context(context); print_draw_next_page(>k_printer, settings); } @@ -604,7 +757,7 @@ void gtk_print_signal_draw_page(GtkPrintOperation *operation, void gtk_print_signal_end_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data) { - LOG("End print"); + NSLOG(netsurf, INFO, "End print"); print_cleanup(content_to_print, >k_printer, user_data); } diff --git a/frontends/gtk/res/accelerators b/frontends/gtk/res/accelerators new file mode 100644 index 000000000..2da229aff --- /dev/null +++ b/frontends/gtk/res/accelerators @@ -0,0 +1,40 @@ +# GTK accelerator keys for menu entries +# The keys must match those in the menus to be applied +# +# These are passed to gtk_accelerator_parse and must not be translated +# The key names are the same as those in the gdk/gdkkeysyms.h header file +# but without the leading “GDK_KEY_”. + +gtkNextTab:<Control>Page_Down +gtkPrevTab:<Control>Page_Up +gtkCloseTab:<Control>w +gtkNewTab:<Control>t +gtkNewWindow:<Control>n +gtkOpenFile:<Control>o +gtkCloseWindow:<Control><shift>w +gtkSavePage:<Control>s +gtkPrintPreview:<Control><shift>p +gtkPrint:<Control>p +gtkQuitMenu:<Control>q +gtkCut:<Control>x +gtkCopy:<Control>c +gtkPaste:<Control>v +gtkSelectAll:<Control>a +gtkFind:<Control>f +gtkStop:Escape +gtkReload:F5 +gtkZoomPlus:<Control>plus +gtkZoomMinus:<Control>minus +gtkZoomNormal:<Control>0 +gtkFullScreen:F11 +gtkPageSource:<Control>U +gtkDownloads:<Control>j +gtkBack:<alt>Left +gtkForward:<alt>Right +gtkHome:<alt>Down +gtkLocalHistory:<Control>h +gtkGlobalHistory:<Control><shift>h +gtkAddBookMarks:<Control>d +gtkShowBookMarks:F6 +gtkShowCookies:F9 +gtkOpenLocation:<Control>l diff --git a/frontends/gtk/res/adblock.css b/frontends/gtk/res/adblock.css index ff2485622..0d12aaa7c 120000 --- a/frontends/gtk/res/adblock.css +++ b/frontends/gtk/res/adblock.css @@ -1 +1 @@ -../../../!NetSurf/Resources/AdBlock,f79
\ No newline at end of file +../../../resources/adblock.css
\ No newline at end of file diff --git a/frontends/gtk/res/ca-bundle.txt b/frontends/gtk/res/ca-bundle.txt index 0b0e416ad..1187fa51a 120000 --- a/frontends/gtk/res/ca-bundle.txt +++ b/frontends/gtk/res/ca-bundle.txt @@ -1 +1 @@ -../../../!NetSurf/Resources/ca-bundle
\ No newline at end of file +../../../resources/ca-bundle
\ No newline at end of file diff --git a/frontends/gtk/res/de/welcome.html b/frontends/gtk/res/de/welcome.html index 98a53b215..b77e23743 120000 --- a/frontends/gtk/res/de/welcome.html +++ b/frontends/gtk/res/de/welcome.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/de/welcome.html,faf
\ No newline at end of file +../../../../resources/de/welcome.html
\ No newline at end of file diff --git a/frontends/gtk/res/default.css b/frontends/gtk/res/default.css index a8579eb7c..fa3ae6c26 120000 --- a/frontends/gtk/res/default.css +++ b/frontends/gtk/res/default.css @@ -1 +1 @@ -../../../!NetSurf/Resources/CSS,f79
\ No newline at end of file +../../../resources/default.css
\ No newline at end of file diff --git a/frontends/gtk/res/en/credits.html b/frontends/gtk/res/en/credits.html index 252516fd7..f73ecd4aa 120000 --- a/frontends/gtk/res/en/credits.html +++ b/frontends/gtk/res/en/credits.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/en/credits.html,faf
\ No newline at end of file +../../../../resources/en/credits.html
\ No newline at end of file diff --git a/frontends/gtk/res/en/licence.html b/frontends/gtk/res/en/licence.html index 79f73669b..0c3b430b7 120000 --- a/frontends/gtk/res/en/licence.html +++ b/frontends/gtk/res/en/licence.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/en/licence.html,faf
\ No newline at end of file +../../../../resources/en/licence.html
\ No newline at end of file diff --git a/frontends/gtk/res/en/maps.html b/frontends/gtk/res/en/maps.html index bb3ffcbe7..507a4b248 120000 --- a/frontends/gtk/res/en/maps.html +++ b/frontends/gtk/res/en/maps.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/en/maps.html,faf
\ No newline at end of file +../../../../resources/en/maps.html
\ No newline at end of file diff --git a/frontends/gtk/res/en/welcome.html b/frontends/gtk/res/en/welcome.html index 601099223..543f31ddd 120000 --- a/frontends/gtk/res/en/welcome.html +++ b/frontends/gtk/res/en/welcome.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/en/welcome.html,faf
\ No newline at end of file +../../../../resources/en/welcome.html
\ No newline at end of file diff --git a/frontends/gtk/res/history.gtk2.ui b/frontends/gtk/res/globalhistory.gtk2.ui index 2b89ecb4b..2b89ecb4b 100644 --- a/frontends/gtk/res/history.gtk2.ui +++ b/frontends/gtk/res/globalhistory.gtk2.ui diff --git a/frontends/gtk/res/history.gtk3.ui b/frontends/gtk/res/globalhistory.gtk3.ui index 7fa598f1e..7fa598f1e 100644 --- a/frontends/gtk/res/history.gtk3.ui +++ b/frontends/gtk/res/globalhistory.gtk3.ui diff --git a/frontends/gtk/res/icons b/frontends/gtk/res/icons index 187efd6f9..94d2dc0df 120000 --- a/frontends/gtk/res/icons +++ b/frontends/gtk/res/icons @@ -1 +1 @@ -../../../!NetSurf/Resources/Icons/
\ No newline at end of file +../../../resources/icons
\ No newline at end of file diff --git a/frontends/gtk/res/internal.css b/frontends/gtk/res/internal.css index 17f9f1504..5583a9811 120000 --- a/frontends/gtk/res/internal.css +++ b/frontends/gtk/res/internal.css @@ -1 +1 @@ -../../../!NetSurf/Resources/internal.css,f79
\ No newline at end of file +../../../resources/internal.css
\ No newline at end of file diff --git a/frontends/gtk/res/it/credits.html b/frontends/gtk/res/it/credits.html index 64b78982e..2b7c99542 120000 --- a/frontends/gtk/res/it/credits.html +++ b/frontends/gtk/res/it/credits.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/it/credits.html,faf
\ No newline at end of file +../../../../resources/it/credits.html
\ No newline at end of file diff --git a/frontends/gtk/res/it/licence.html b/frontends/gtk/res/it/licence.html index 4abc825d3..92afce85b 120000 --- a/frontends/gtk/res/it/licence.html +++ b/frontends/gtk/res/it/licence.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/it/licence.html,faf
\ No newline at end of file +../../../../resources/it/licence.html
\ No newline at end of file diff --git a/frontends/gtk/res/it/welcome.html b/frontends/gtk/res/it/welcome.html index 59cef0551..2673ba948 120000 --- a/frontends/gtk/res/it/welcome.html +++ b/frontends/gtk/res/it/welcome.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/it/welcome.html,faf
\ No newline at end of file +../../../../resources/it/welcome.html
\ No newline at end of file diff --git a/frontends/gtk/res/ja/welcome.html b/frontends/gtk/res/ja/welcome.html index a2556ee4e..8b603f3df 120000 --- a/frontends/gtk/res/ja/welcome.html +++ b/frontends/gtk/res/ja/welcome.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/ja/welcome.html,faf
\ No newline at end of file +../../../../resources/ja/welcome.html
\ No newline at end of file diff --git a/frontends/gtk/res/localhistory.gtk2.ui b/frontends/gtk/res/localhistory.gtk2.ui new file mode 100644 index 000000000..9512b6289 --- /dev/null +++ b/frontends/gtk/res/localhistory.gtk2.ui @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <object class="GtkWindow" id="wndHistory"> + <property name="can_focus">False</property> + <property name="title" translatable="yes">NetSurf Local History</property> + <property name="window_position">center</property> + <property name="default_width">20</property> + <property name="default_height">20</property> + <property name="type_hint">utility</property> + <property name="decorated">False</property> + <child> + <object class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkScrolledWindow" id="HistoryScrolled"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkViewport" id="HistoryViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="resize_mode">queue</property> + <child> + <object class="GtkDrawingArea" id="HistoryDrawingArea"> + <property name="visible">True</property> + <property name="app_paintable">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK</property> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/frontends/gtk/res/localhistory.gtk3.ui b/frontends/gtk/res/localhistory.gtk3.ui new file mode 100644 index 000000000..1a4b9004d --- /dev/null +++ b/frontends/gtk/res/localhistory.gtk3.ui @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <object class="GtkWindow" id="wndHistory"> + <property name="can_focus">False</property> + <property name="title" translatable="yes">NetSurf Local History</property> + <property name="window_position">center</property> + <property name="default_width">20</property> + <property name="default_height">20</property> + <property name="type_hint">utility</property> + <property name="decorated">False</property> + <child> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkScrolledWindow" id="HistoryScrolled"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport" id="HistoryViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkDrawingArea" id="HistoryDrawingArea"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="events">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK</property> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/frontends/gtk/res/netsurf.gresource.xml b/frontends/gtk/res/netsurf.gresource.xml index c7626b053..e8243254a 100644 --- a/frontends/gtk/res/netsurf.gresource.xml +++ b/frontends/gtk/res/netsurf.gresource.xml @@ -2,30 +2,32 @@ <gresources> <gresource prefix="/org/netsurf"> <file>cookies.gtk2.ui</file> - <file>history.gtk3.ui</file> - <file>netsurf.gtk2.ui</file> - <file>password.gtk3.ui</file> - <file>toolbar.gtk2.ui</file> + <file>globalhistory.gtk3.ui</file> + <file>localhistory.gtk3.ui</file> + <file>netsurf.gtk2.ui</file> + <file>password.gtk3.ui</file> + <file>toolbar.gtk2.ui</file> <file>warning.gtk3.ui</file> - <file>cookies.gtk3.ui</file> - <file>hotlist.gtk2.ui</file> - <file>netsurf.gtk3.ui</file> - <file>ssl.gtk2.ui</file> + <file>cookies.gtk3.ui</file> + <file>hotlist.gtk2.ui</file> + <file>netsurf.gtk3.ui</file> + <file>ssl.gtk2.ui</file> <file>toolbar.gtk3.ui</file> - <file>downloads.gtk2.ui</file> - <file>hotlist.gtk3.ui</file> - <file>options.gtk2.ui</file> - <file>ssl.gtk3.ui</file> + <file>downloads.gtk2.ui</file> + <file>hotlist.gtk3.ui</file> + <file>options.gtk2.ui</file> + <file>ssl.gtk3.ui</file> <file>viewdata.gtk2.ui</file> - <file>downloads.gtk3.ui</file> - <file>login.gtk2.ui</file> - <file>options.gtk3.ui</file> - <file>tabcontents.gtk2.ui</file> + <file>downloads.gtk3.ui</file> + <file>login.gtk2.ui</file> + <file>options.gtk3.ui</file> + <file>tabcontents.gtk2.ui</file> <file>viewdata.gtk3.ui</file> - <file>history.gtk2.ui</file> - <file>login.gtk3.ui</file> - <file>password.gtk2.ui</file> - <file>tabcontents.gtk3.ui</file> + <file>localhistory.gtk2.ui</file> + <file>globalhistory.gtk2.ui</file> + <file>login.gtk3.ui</file> + <file>password.gtk2.ui</file> + <file>tabcontents.gtk3.ui</file> <file>warning.gtk2.ui</file> <file preprocess="to-pixdata">favicon.png</file> <file preprocess="to-pixdata">netsurf.xpm</file> @@ -66,5 +68,6 @@ <file>icons/hotlist-rmv.png</file> <file>icons/search.png</file> <file>languages</file> + <file>accelerators</file> </gresource> </gresources> diff --git a/frontends/gtk/res/netsurf.png b/frontends/gtk/res/netsurf.png index 905512c25..d0ab72a5e 120000 --- a/frontends/gtk/res/netsurf.png +++ b/frontends/gtk/res/netsurf.png @@ -1 +1 @@ -../../../!NetSurf/Resources/netsurf.png,b60
\ No newline at end of file +../../../resources/netsurf.png
\ No newline at end of file diff --git a/frontends/gtk/res/nl/credits.html b/frontends/gtk/res/nl/credits.html index 9c983987a..71b27e40a 120000 --- a/frontends/gtk/res/nl/credits.html +++ b/frontends/gtk/res/nl/credits.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/nl/credits.html,faf
\ No newline at end of file +../../../../resources/nl/credits.html
\ No newline at end of file diff --git a/frontends/gtk/res/nl/licence.html b/frontends/gtk/res/nl/licence.html index 8a10d2073..5aaf1cb44 120000 --- a/frontends/gtk/res/nl/licence.html +++ b/frontends/gtk/res/nl/licence.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/nl/licence.html,faf
\ No newline at end of file +../../../../resources/nl/licence.html
\ No newline at end of file diff --git a/frontends/gtk/res/nl/welcome.html b/frontends/gtk/res/nl/welcome.html index 6b2ba7742..ef7a97cc9 120000 --- a/frontends/gtk/res/nl/welcome.html +++ b/frontends/gtk/res/nl/welcome.html @@ -1 +1 @@ -../../../../!NetSurf/Resources/nl/welcome.html,faf
\ No newline at end of file +../../../../resources/nl/welcome.html
\ No newline at end of file diff --git a/frontends/gtk/res/options.gtk2.ui b/frontends/gtk/res/options.gtk2.ui index d5542ba5d..a1162585d 100644 --- a/frontends/gtk/res/options.gtk2.ui +++ b/frontends/gtk/res/options.gtk2.ui @@ -2,6 +2,297 @@ <interface> <requires lib="gtk+" version="2.16"/> <!-- interface-naming-policy project-wide --> + <object class="GtkAdjustment" id="adjustment_animation_time"> + <property name="lower">0.10000000000000001</property> + <property name="upper">10</property> + <property name="value">0.10000000000000001</property> + <property name="step_increment">0.10000000000000001</property> + <property name="page_increment">1</property> + </object> + <object class="GtkAdjustment" id="adjustment_cache_disc_size"> + <property name="upper">4096</property> + <property name="value">1024</property> + <property name="step_increment">32</property> + <property name="page_increment">256</property> + </object> + <object class="GtkAdjustment" id="adjustment_cache_memory_size"> + <property name="upper">2048</property> + <property name="value">16</property> + <property name="step_increment">4</property> + <property name="page_increment">16</property> + </object> + <object class="GtkAdjustment" id="adjustment_disc_cache_age"> + <property name="upper">999</property> + <property name="value">28</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment_fetching_cached"> + <property name="upper">100</property> + <property name="value">1</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment_fetching_max"> + <property name="lower">1</property> + <property name="upper">100</property> + <property name="value">10</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment_fetching_perhost"> + <property name="lower">1</property> + <property name="upper">100</property> + <property name="value">1</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment_font_default_size"> + <property name="lower">1</property> + <property name="upper">99.900000000000006</property> + <property name="value">16</property> + <property name="step_increment">0.10000000000000001</property> + <property name="page_increment">2</property> + </object> + <object class="GtkAdjustment" id="adjustment_history_age"> + <property name="upper">999</property> + <property name="value">28</property> + <property name="step_increment">1</property> + <property name="page_increment">28</property> + </object> + <object class="GtkAdjustment" id="adjustment_pdf_lmargin"> + <property name="upper">999</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment_pdf_scale"> + <property name="lower">1</property> + <property name="upper">1000</property> + <property name="value">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment_proxy_port"> + <property name="lower">1</property> + <property name="upper">65535</property> + <property name="value">3128</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xpad">3</property> + <property name="stock">gtk-apply</property> + </object> + <object class="GtkListStore" id="liststore_content_language"> + <columns> + <!-- column-name Code --> + <column type="gchararray"/> + <!-- column-name Description --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">en</col> + <col id="1" translatable="yes">English</col> + </row> + </data> + </object> + <object class="GtkListStore" id="liststore_defaultfont"> + <columns> + <!-- column-name Type --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">preferencesFonttypeSans</col> + </row> + <row> + <col id="0" translatable="yes">preferencesFonttypeSerif</col> + </row> + <row> + <col id="0" translatable="yes">preferencesFonttypeMonospace</col> + </row> + <row> + <col id="0" translatable="yes">preferencesFonttypeCursive</col> + </row> + <row> + <col id="0" translatable="yes">preferencesFonttypeFantasy</col> + </row> + </data> + </object> + <object class="GtkListStore" id="liststore_developer_view"> + <columns> + <!-- column-name Type --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">preferencesDeveloperViewWindow</col> + </row> + <row> + <col id="0" translatable="yes">preferencesDeveloperViewTab</col> + </row> + <row> + <col id="0" translatable="yes">preferencesDeveloperViewEditor</col> + </row> + </data> + </object> + <object class="GtkListStore" id="liststore_image_loading"> + <columns> + <!-- column-name Type --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">preferencesImageLoadBoth</col> + </row> + <row> + <col id="0" translatable="yes">preferencesImageLoadFore</col> + </row> + <row> + <col id="0" translatable="yes">preferencesImageLoadBack</col> + </row> + <row> + <col id="0" translatable="yes">preferencesImageLoadNone</col> + </row> + </data> + </object> + <object class="GtkListStore" id="liststore_proxy_type"> + <columns> + <!-- column-name Type --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">preferencesProxyTypeDirect</col> + </row> + <row> + <col id="0" translatable="yes">preferencesProxyTypeManual</col> + </row> + <row> + <col id="0" translatable="yes">preferencesProxyTypeBasic</col> + </row> + <row> + <col id="0" translatable="yes">preferencesProxyTypeNLTM</col> + </row> + <row> + <col id="0" translatable="yes">preferencesProxyTypeSystem</col> + </row> + </data> + </object> + <object class="GtkListStore" id="liststore_search_provider"> + <columns> + <!-- column-name Provider --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0">Google</col> + </row> + <row> + <col id="0">Yahoo!</col> + </row> + <row> + <col id="0">Microsoft Live</col> + </row> + <row> + <col id="0">Buisiness.com</col> + </row> + <row> + <col id="0">Omgili</col> + </row> + <row> + <col id="0">BBC News</col> + </row> + <row> + <col id="0">Ubuntu Packages</col> + </row> + <row> + <col id="0">Creative Commons</col> + </row> + <row> + <col id="0">Ask</col> + </row> + <row> + <col id="0">Answers</col> + </row> + <row> + <col id="0">Dictionary.com</col> + </row> + <row> + <col id="0">YouTube</col> + </row> + <row> + <col id="0">AeroMP3</col> + </row> + <row> + <col id="0">AOL</col> + </row> + <row> + <col id="0">Baidu</col> + </row> + <row> + <col id="0">Amazon</col> + </row> + <row> + <col id="0">Ebay</col> + </row> + <row> + <col id="0">IMBD</col> + </row> + <row> + <col id="0">ESPN</col> + </row> + <row> + <col id="0">Wikipedia</col> + </row> + <row> + <col id="0">DuckDuckGo</col> + </row> + </data> + </object> + <object class="GtkListStore" id="liststore_tab_position"> + <columns> + <!-- column-name Position --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">preferencesTabLocTop</col> + </row> + <row> + <col id="0" translatable="yes">preferencesTabLocLeft</col> + </row> + <row> + <col id="0" translatable="yes">preferencesTabLocRight</col> + </row> + <row> + <col id="0" translatable="yes">preferencesTabLocBottom</col> + </row> + </data> + </object> + <object class="GtkListStore" id="liststore_toolbar_buttontype"> + <columns> + <!-- column-name Type --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">preferencesButtonTypeSmall</col> + </row> + <row> + <col id="0" translatable="yes">preferencesButtonTypeLarge</col> + </row> + <row> + <col id="0" translatable="yes">preferencesButtonTypeLargeText</col> + </row> + <row> + <col id="0" translatable="yes">preferencesButtonTypeText</col> + </row> + </data> + </object> <object class="GtkDialog" id="dialogPreferences"> <property name="can_focus">False</property> <property name="border_width">5</property> @@ -2178,7 +2469,6 @@ </child> <child> <object class="GtkVBox" id="vbox_pdfexport"> - <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> <child> @@ -2583,6 +2873,12 @@ <property name="x_options">GTK_EXPAND</property> </packing> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="expand">True</property> @@ -2710,295 +3006,4 @@ <action-widget response="-7">close</action-widget> </action-widgets> </object> - <object class="GtkListStore" id="liststore_search_provider"> - <columns> - <!-- column-name Provider --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0">Google</col> - </row> - <row> - <col id="0">Yahoo!</col> - </row> - <row> - <col id="0">Microsoft Live</col> - </row> - <row> - <col id="0">Buisiness.com</col> - </row> - <row> - <col id="0">Omgili</col> - </row> - <row> - <col id="0">BBC News</col> - </row> - <row> - <col id="0">Ubuntu Packages</col> - </row> - <row> - <col id="0">Creative Commons</col> - </row> - <row> - <col id="0">Ask</col> - </row> - <row> - <col id="0">Answers</col> - </row> - <row> - <col id="0">Dictionary.com</col> - </row> - <row> - <col id="0">YouTube</col> - </row> - <row> - <col id="0">AeroMP3</col> - </row> - <row> - <col id="0">AOL</col> - </row> - <row> - <col id="0">Baidu</col> - </row> - <row> - <col id="0">Amazon</col> - </row> - <row> - <col id="0">Ebay</col> - </row> - <row> - <col id="0">IMBD</col> - </row> - <row> - <col id="0">ESPN</col> - </row> - <row> - <col id="0">Wikipedia</col> - </row> - <row> - <col id="0">DuckDuckGo</col> - </row> - </data> - </object> - <object class="GtkListStore" id="liststore_tab_position"> - <columns> - <!-- column-name Position --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">preferencesTabLocTop</col> - </row> - <row> - <col id="0" translatable="yes">preferencesTabLocLeft</col> - </row> - <row> - <col id="0" translatable="yes">preferencesTabLocRight</col> - </row> - <row> - <col id="0" translatable="yes">preferencesTabLocBottom</col> - </row> - </data> - </object> - <object class="GtkListStore" id="liststore_toolbar_buttontype"> - <columns> - <!-- column-name Type --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">preferencesButtonTypeSmall</col> - </row> - <row> - <col id="0" translatable="yes">preferencesButtonTypeLarge</col> - </row> - <row> - <col id="0" translatable="yes">preferencesButtonTypeLargeText</col> - </row> - <row> - <col id="0" translatable="yes">preferencesButtonTypeText</col> - </row> - </data> - </object> - <object class="GtkListStore" id="liststore_image_loading"> - <columns> - <!-- column-name Type --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">preferencesImageLoadBoth</col> - </row> - <row> - <col id="0" translatable="yes">preferencesImageLoadFore</col> - </row> - <row> - <col id="0" translatable="yes">preferencesImageLoadBack</col> - </row> - <row> - <col id="0" translatable="yes">preferencesImageLoadNone</col> - </row> - </data> - </object> - <object class="GtkListStore" id="liststore_defaultfont"> - <columns> - <!-- column-name Type --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">preferencesFonttypeSans</col> - </row> - <row> - <col id="0" translatable="yes">preferencesFonttypeSerif</col> - </row> - <row> - <col id="0" translatable="yes">preferencesFonttypeMonospace</col> - </row> - <row> - <col id="0" translatable="yes">preferencesFonttypeCursive</col> - </row> - <row> - <col id="0" translatable="yes">preferencesFonttypeFantasy</col> - </row> - </data> - </object> - <object class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xpad">3</property> - <property name="stock">gtk-apply</property> - </object> - <object class="GtkListStore" id="liststore_proxy_type"> - <columns> - <!-- column-name Type --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">preferencesProxyTypeDirect</col> - </row> - <row> - <col id="0" translatable="yes">preferencesProxyTypeManual</col> - </row> - <row> - <col id="0" translatable="yes">preferencesProxyTypeBasic</col> - </row> - <row> - <col id="0" translatable="yes">preferencesProxyTypeNLTM</col> - </row> - <row> - <col id="0" translatable="yes">preferencesProxyTypeSystem</col> - </row> - </data> - </object> - <object class="GtkAdjustment" id="adjustment_animation_time"> - <property name="value">0.10000000000000001</property> - <property name="lower">0.10000000000000001</property> - <property name="upper">10</property> - <property name="step_increment">0.10000000000000001</property> - <property name="page_increment">1</property> - </object> - <object class="GtkAdjustment" id="adjustment_font_default_size"> - <property name="value">16</property> - <property name="lower">1</property> - <property name="upper">99.900000000000006</property> - <property name="step_increment">0.10000000000000001</property> - <property name="page_increment">2</property> - </object> - <object class="GtkAdjustment" id="adjustment_history_age"> - <property name="value">28</property> - <property name="upper">999</property> - <property name="step_increment">1</property> - <property name="page_increment">28</property> - </object> - <object class="GtkAdjustment" id="adjustment_cache_memory_size"> - <property name="value">16</property> - <property name="upper">2048</property> - <property name="step_increment">4</property> - <property name="page_increment">16</property> - </object> - <object class="GtkAdjustment" id="adjustment_cache_disc_size"> - <property name="value">1024</property> - <property name="upper">4096</property> - <property name="step_increment">32</property> - <property name="page_increment">256</property> - </object> - <object class="GtkAdjustment" id="adjustment_disc_cache_age"> - <property name="value">28</property> - <property name="upper">999</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment_proxy_port"> - <property name="value">3128</property> - <property name="lower">1</property> - <property name="upper">65535</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment_fetching_max"> - <property name="value">10</property> - <property name="lower">1</property> - <property name="upper">100</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment_fetching_perhost"> - <property name="value">1</property> - <property name="lower">1</property> - <property name="upper">100</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment_fetching_cached"> - <property name="value">1</property> - <property name="upper">100</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment_pdf_scale"> - <property name="value">100</property> - <property name="lower">1</property> - <property name="upper">1000</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment_pdf_lmargin"> - <property name="upper">999</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkListStore" id="liststore_content_language"> - <columns> - <!-- column-name Code --> - <column type="gchararray"/> - <!-- column-name Description --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">en</col> - <col id="1" translatable="yes">English</col> - </row> - </data> - </object> - <object class="GtkListStore" id="liststore_developer_view"> - <columns> - <!-- column-name Type --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">preferencesDeveloperViewWindow</col> - </row> - <row> - <col id="0" translatable="yes">preferencesDeveloperViewTab</col> - </row> - <row> - <col id="0" translatable="yes">preferencesDeveloperViewEditor</col> - </row> - </data> - </object> </interface> diff --git a/frontends/gtk/res/quirks.css b/frontends/gtk/res/quirks.css index 88aabe48c..1e752cb9e 120000 --- a/frontends/gtk/res/quirks.css +++ b/frontends/gtk/res/quirks.css @@ -1 +1 @@ -../../../!NetSurf/Resources/Quirks,f79
\ No newline at end of file +../../../resources/quirks.css
\ No newline at end of file diff --git a/frontends/gtk/res/toolbar.gtk2.ui b/frontends/gtk/res/toolbar.gtk2.ui index d84db5c8c..4e8805a6f 100644 --- a/frontends/gtk/res/toolbar.gtk2.ui +++ b/frontends/gtk/res/toolbar.gtk2.ui @@ -1,67 +1,84 @@ -<?xml version="1.0"?> -<!--*- mode: xml -*--> +<?xml version="1.0" encoding="UTF-8"?> <interface> - <object class="GtkWindow" id="toolbarwindow"> + <!-- interface-requires gtk+ 2.12 --> + <!-- interface-naming-policy toplevel-contextual --> + <object class="GtkDialog" id="dialogToolbar"> <property name="width_request">700</property> <property name="height_request">450</property> - <property name="title" translatable="yes"/> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">False</property> - <property name="skip_pager_hint">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> - <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> - <property name="focus_on_map">True</property> - <property name="urgency_hint">False</property> - <child> - <object class="GtkVBox" id="windowvbox"> + <property name="can_focus">False</property> + <property name="border_width">5</property> + <property name="title" translatable="yes">gtkToolBarTitle</property> + <property name="window_position">center-on-parent</property> + <property name="destroy_with_parent">True</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox1"> <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <property name="can_focus">False</property> + <property name="spacing">2</property> <child> - <object class="GtkLabel" id="toolbarlabel"> + <object class="GtkHBox" id="hbox1"> <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> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> + <property name="can_focus">False</property> + <property name="homogeneous">True</property> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Move items from store to toolbar</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Rearrange items in toolbar</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Move items from toolbar to store</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> </object> <packing> - <property name="padding">0</property> <property name="expand">False</property> <property name="fill">True</property> + <property name="padding">2</property> + <property name="position">0</property> </packing> </child> <child> <object class="GtkScrolledWindow" id="scrolledwindow1"> <property name="visible">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + <property name="can_focus">False</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <object class="GtkViewport" id="viewport1"> <property name="visible">True</property> - <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="can_focus">False</property> <child> <object class="GtkVBox" id="widgetvbox"> <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <property name="can_focus">False</property> <child> <placeholder/> </child> @@ -71,119 +88,85 @@ </child> </object> <packing> - <property name="padding">0</property> <property name="expand">True</property> <property name="fill">True</property> + <property name="position">1</property> </packing> </child> - <child> - <object class="GtkHBox" id="buttonhbox"> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area1"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <property name="can_focus">False</property> + <property name="layout_style">end</property> <child> - <object class="GtkButton" id="resetbutton"> + <object class="GtkButton" id="reset"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> + <property name="receives_default">False</property> <child> <object class="GtkHBox" id="button1hbox"> <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <property name="can_focus">False</property> <child> <object class="GtkImage" id="image1"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="stock">gtk-refresh</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> </object> <packing> - <property name="padding">0</property> <property name="expand">False</property> <property name="fill">True</property> + <property name="position">0</property> </packing> </child> <child> <object class="GtkLabel" id="refreshbuttonlabel"> <property name="visible">True</property> + <property name="can_focus">False</property> <property name="label" translatable="yes">Reset to defaults</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> </object> <packing> - <property name="padding">0</property> <property name="expand">True</property> <property name="fill">True</property> + <property name="position">1</property> </packing> </child> </object> </child> </object> <packing> - <property name="padding">10</property> <property name="expand">False</property> <property name="fill">True</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <object class="GtkButton" id="okbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="label">gtk-apply</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - </object> - <packing> <property name="padding">10</property> - <property name="expand">False</property> - <property name="fill">True</property> + <property name="position">0</property> </packing> </child> <child> - <object class="GtkButton" id="cancelbutton"> + <object class="GtkButton" id="close"> + <property name="label">gtk-close</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> + <property name="receives_default">True</property> <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> </object> <packing> - <property name="padding">0</property> <property name="expand">False</property> - <property name="fill">True</property> + <property name="fill">False</property> + <property name="position">1</property> </packing> </child> </object> <packing> - <property name="padding">0</property> <property name="expand">False</property> <property name="fill">True</property> + <property name="position">2</property> </packing> </child> </object> </child> + <action-widgets> + <action-widget response="0">reset</action-widget> + <action-widget response="0">close</action-widget> + </action-widgets> </object> </interface> diff --git a/frontends/gtk/res/toolbar.gtk3.ui b/frontends/gtk/res/toolbar.gtk3.ui index d84db5c8c..1f1148703 100644 --- a/frontends/gtk/res/toolbar.gtk3.ui +++ b/frontends/gtk/res/toolbar.gtk3.ui @@ -1,186 +1,134 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.3 --> <!--*- mode: xml -*--> <interface> - <object class="GtkWindow" id="toolbarwindow"> + <requires lib="gtk+" version="3.0"/> + <object class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="stock">gtk-refresh</property> + </object> + <object class="GtkDialog" id="dialogToolbar"> <property name="width_request">700</property> <property name="height_request">450</property> - <property name="title" translatable="yes"/> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">False</property> - <property name="skip_pager_hint">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> - <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> - <property name="focus_on_map">True</property> - <property name="urgency_hint">False</property> - <child> - <object class="GtkVBox" id="windowvbox"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - <child> - <object 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> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </object> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - <child> - <object class="GtkScrolledWindow" id="scrolledwindow1"> - <property name="visible">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + <property name="can_focus">False</property> + <property name="title" translatable="yes">gtkToolBarTitle</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> <child> - <object class="GtkViewport" id="viewport1"> + <object class="GtkButton" id="reset"> + <property name="label" translatable="yes">Reset To Defaults</property> <property name="visible">True</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <child> - <object class="GtkVBox" id="widgetvbox"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - <child> - <placeholder/> - </child> - </object> - </child> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image2</property> + <property name="yalign">0.52999997138977051</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="close"> + <property name="label">gtk-close</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> </child> </object> <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> </packing> </child> <child> - <object class="GtkHBox" id="buttonhbox"> + <object class="GtkGrid" id="grid1"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <property name="can_focus">False</property> + <property name="column_homogeneous">True</property> <child> - <object class="GtkButton" id="resetbutton"> + <object class="GtkLabel" id="label1"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <child> - <object class="GtkHBox" id="button1hbox"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - <child> - <object class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="stock">gtk-refresh</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </object> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="refreshbuttonlabel"> - <property name="visible">True</property> - <property name="label" translatable="yes">Reset to defaults</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </object> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </object> - </child> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Move items from store to toolbar</property> </object> <packing> - <property name="padding">10</property> - <property name="expand">False</property> - <property name="fill">True</property> + <property name="left_attach">0</property> + <property name="top_attach">0</property> </packing> </child> <child> - <placeholder/> - </child> - <child> - <object class="GtkButton" id="okbutton"> + <object class="GtkLabel" id="label2"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="label">gtk-apply</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Rearrange items in toolbar</property> </object> <packing> - <property name="padding">10</property> - <property name="expand">False</property> - <property name="fill">True</property> + <property name="left_attach">1</property> + <property name="top_attach">0</property> </packing> </child> <child> - <object class="GtkButton" id="cancelbutton"> + <object class="GtkLabel" id="label3"> <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="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Move items from toolbar to store</property> </object> <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> + <property name="left_attach">2</property> + <property name="top_attach">0</property> </packing> </child> </object> <packing> - <property name="padding">0</property> <property name="expand">False</property> <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkViewport" id="viewport1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkVBox" id="widgetvbox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <placeholder/> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> </packing> </child> </object> diff --git a/frontends/gtk/resources.c b/frontends/gtk/resources.c index dfe3d3dad..fc3ac6ff3 100644 --- a/frontends/gtk/resources.c +++ b/frontends/gtk/resources.c @@ -81,7 +81,8 @@ static struct nsgtk_resource_s ui_resource[] = { RES_ENTRY("ssl"), RES_ENTRY("toolbar"), RES_ENTRY("downloads"), - RES_ENTRY("history"), + RES_ENTRY("globalhistory"), + RES_ENTRY("localhistory"), RES_ENTRY("options"), RES_ENTRY("hotlist"), RES_ENTRY("cookies"), @@ -128,6 +129,7 @@ static struct nsgtk_resource_s direct_resource[] = { RES_ENTRY("icons/hotlist-rmv.png"), RES_ENTRY("icons/search.png"), RES_ENTRY("languages"), + RES_ENTRY("accelerators"), RES_ENTRY("Messages"), { NULL, 0, NSGTK_RESOURCE_FILE, NULL }, }; @@ -177,11 +179,12 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) langv = g_get_language_names(); + /* look for resource under per language paths */ while (langv[langc] != NULL) { + /* allocate and fill a full resource name path buffer */ resnamelen = snprintf(NULL, 0, "/org/netsurf/%s/%s", langv[langc], resource->name); - resname = malloc(resnamelen + 1); if (resname == NULL) { return NSERROR_NOMEM; @@ -190,6 +193,7 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) "/org/netsurf/%s/%s", langv[langc], resource->name); + /* check if resource is present */ present = g_resources_get_info(resname, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL, NULL, NULL); @@ -197,16 +201,19 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) /* found an entry in the resources */ resource->path = resname; resource->type = NSGTK_RESOURCE_GLIB; - LOG("Found gresource path %s", resource->path); + NSLOG(netsurf, INFO, "Found gresource path %s", + resource->path); return NSERROR_OK; } - /*LOG("gresource \"%s\" not found", resname);*/ + NSLOG(netsurf, DEEPDEBUG, + "gresource \"%s\" not found", resname); free(resname); langc++; } - resnamelen = snprintf(NULL, 0, "/org/netsurf/%s", resource->name); + /* allocate and fill a full resource name path buffer with no language*/ + resnamelen = snprintf(NULL, 0, "/org/netsurf/%s", resource->name); resname = malloc(resnamelen + 1); if (resname == NULL) { return NSERROR_NOMEM; @@ -220,27 +227,31 @@ init_resource(char **respath, struct nsgtk_resource_s *resource) /* found an entry in the resources */ resource->path = resname; resource->type = NSGTK_RESOURCE_GLIB; - LOG("Found gresource path %s", resource->path); + NSLOG(netsurf, INFO, "Found gresource path %s", + resource->path); return NSERROR_OK; } - /*LOG("gresource \"%s\" not found", resname);*/ + NSLOG(netsurf, DEEPDEBUG, "gresource \"%s\" not found", resname); free(resname); #endif + /* look for file on disc */ resname = filepath_find(respath, resource->name); - if (resname == NULL) { - LOG("Unable to find resource %s on resource path", - resource->name); - return NSERROR_NOT_FOUND; + if (resname != NULL) { + /* found an entry on the path */ + resource->path = resname; + resource->type = NSGTK_RESOURCE_FILE; + + NSLOG(netsurf, INFO, + "Found file resource path %s", resource->path); + return NSERROR_OK; } - /* found an entry on the path */ - resource->path = resname; - resource->type = NSGTK_RESOURCE_FILE; + NSLOG(netsurf, INFO, "Unable to find resource %s on resource path", + resource->name); - LOG("Found file resource path %s", resource->path); - return NSERROR_OK; + return NSERROR_NOT_FOUND; } /** @@ -294,21 +305,21 @@ init_pixbuf_resource(char **respath, struct nsgtk_resource_s *resource) if (strncmp(resource->name, "menu_cursor.png", resource->len) == 0) { resource->path = (char *)&menu_cursor_pixdata[0]; resource->type = NSGTK_RESOURCE_INLINE; - LOG("Found builtin for %s", resource->name); + NSLOG(netsurf, INFO, "Found builtin for %s", resource->name); return NSERROR_OK; } if (strncmp(resource->name, "netsurf.xpm", resource->len) == 0) { resource->path = (char *)&netsurf_pixdata[0]; resource->type = NSGTK_RESOURCE_INLINE; - LOG("Found builtin for %s", resource->name); + NSLOG(netsurf, INFO, "Found builtin for %s", resource->name); return NSERROR_OK; } if (strncmp(resource->name, "favicon.png", resource->len) == 0) { resource->path = (char *)&favicon_pixdata[0]; resource->type = NSGTK_RESOURCE_INLINE; - LOG("Found builtin for %s", resource->name); + NSLOG(netsurf, INFO, "Found builtin for %s", resource->name); return NSERROR_OK; } #endif @@ -376,7 +387,7 @@ find_resource_from_name(const char *resname, struct nsgtk_resource_s *resource) #ifdef SHOW_GRESOURCE /** - * Debug dump of all resources compile din via GResource. + * Debug dump of all resources compiled in via GResource. */ static void list_gresource(void) { @@ -388,13 +399,13 @@ static void list_gresource(void) G_RESOURCE_LOOKUP_FLAGS_NONE, &gerror); if (gerror) { - LOG("gerror %s", gerror->message); + NSLOG(netsurf, INFO, "gerror %s", gerror->message); g_error_free(gerror); } else { cur = reslist; while (cur != NULL && *cur != NULL) { - LOG("gres %s", *cur); + NSLOG(netsurf, INFO, "gres %s", *cur); cur++; } g_strfreev(reslist); @@ -487,12 +498,17 @@ nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_out) if (new_pixbuf == NULL) { if (error != NULL) { - LOG("Unable to create pixbuf from file for %s with path %s \"%s\"", - resource->name, resource->path, error->message); + NSLOG(netsurf, INFO, + "Unable to create pixbuf from file for %s with path %s \"%s\"", + resource->name, + resource->path, + error->message); g_error_free(error); } else { - LOG("Unable to create pixbuf from file for %s with path %s", - resource->name, resource->path); + NSLOG(netsurf, INFO, + "Unable to create pixbuf from file for %s with path %s", + resource->name, + resource->path); } return NSERROR_INIT_FAILED; } @@ -520,8 +536,11 @@ nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out) if (!gtk_builder_add_from_file(new_builder, ui_res->path, &error)) { - LOG("Unable to add UI builder from file for %s with path %s \"%s\"", - ui_res->name, ui_res->path, error->message); + NSLOG(netsurf, INFO, + "Unable to add UI builder from file for %s with path %s \"%s\"", + ui_res->name, + ui_res->path, + error->message); g_error_free(error); g_object_unref(G_OBJECT(new_builder)); return NSERROR_INIT_FAILED; @@ -530,8 +549,11 @@ nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out) if (!nsgtk_builder_add_from_resource(new_builder, ui_res->path, &error)) { - LOG("Unable to add UI builder from resource for %s with path %s \"%s\"", - ui_res->name, ui_res->path, error->message); + NSLOG(netsurf, INFO, + "Unable to add UI builder from resource for %s with path %s \"%s\"", + ui_res->name, + ui_res->path, + error->message); g_error_free(error); g_object_unref(G_OBJECT(new_builder)); return NSERROR_INIT_FAILED; diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c index bbc568e15..bedad9140 100644 --- a/frontends/gtk/scaffolding.c +++ b/frontends/gtk/scaffolding.c @@ -61,6 +61,7 @@ #include "gtk/bitmap.h" #include "gtk/gui.h" #include "gtk/global_history.h" +#include "gtk/local_history.h" #include "gtk/hotlist.h" #include "gtk/download.h" #include "gtk/menu.h" @@ -103,15 +104,12 @@ static gboolean nsgtk_on_##q##_activate(GtkButton *widget, gpointer data) /** Core scaffolding structure. */ struct nsgtk_scaffolding { - /** global linked list of scaffoldings for gui interface adjustments */ + /** global linked list of scaffolding for gui interface adjustments */ struct nsgtk_scaffolding *next, *prev; /** currently active gui browsing context */ struct gui_window *top_level; - /** local history window */ - struct gtk_history_window *history_window; - /** Builder object scaffold was created from */ GtkBuilder *builder; @@ -150,7 +148,6 @@ struct nsgtk_scaffolding { /** link popup menu */ struct nsgtk_link_menu *link_menu; - }; /** current scaffold for model dialogue use */ @@ -159,19 +156,30 @@ static struct nsgtk_scaffolding *scaf_current; /** global list for interface changes */ static struct nsgtk_scaffolding *scaf_list = NULL; -/** holds the context data for what's under the pointer, when the contextual - * menu is opened. +/** + * holds the context data for what's under the pointer, when the + * contextual menu is opened. */ static struct browser_window_features current_menu_features; /** - * Helper to hide popup menu entries by grouping + * Helper to hide popup menu entries by grouping. + * + * \param menu The popup menu to modify. + * \param submenu flag to indicate if submenus should be hidden. + * \param nav flag to indicate if navigation entries should be hidden. + * \param cnp flag to indicate if cut and paste entries should be hidden. + * \param custom flag to indicate if menu customisation is hidden. */ -static void popup_menu_hide(struct nsgtk_popup_menu *menu, bool submenu, - bool nav, bool cnp, bool custom) +static void +popup_menu_hide(struct nsgtk_popup_menu *menu, + bool submenu, + bool nav, + bool cnp, + bool custom) { - if (submenu){ + if (submenu) { gtk_widget_hide(GTK_WIDGET(menu->file_menuitem)); gtk_widget_hide(GTK_WIDGET(menu->edit_menuitem)); gtk_widget_hide(GTK_WIDGET(menu->view_menuitem)); @@ -200,13 +208,24 @@ static void popup_menu_hide(struct nsgtk_popup_menu *menu, bool submenu, } + /** - * Helper to show popup menu entries by grouping + * Helper to show popup menu entries by grouping. + * + * \param menu The popup menu to modify. + * \param submenu flag to indicate if submenus should be visible. + * \param nav flag to indicate if navigation entries should be visible. + * \param cnp flag to indicate if cut and paste entries should be visible. + * \param custom flag to indicate if menu customisation is visible. */ -static void popup_menu_show(struct nsgtk_popup_menu *menu, bool submenu, - bool nav, bool cnp, bool custom) +static void +popup_menu_show(struct nsgtk_popup_menu *menu, + bool submenu, + bool nav, + bool cnp, + bool custom) { - if (submenu){ + if (submenu) { gtk_widget_show(GTK_WIDGET(menu->file_menuitem)); gtk_widget_show(GTK_WIDGET(menu->edit_menuitem)); gtk_widget_show(GTK_WIDGET(menu->view_menuitem)); @@ -232,7 +251,6 @@ static void popup_menu_show(struct nsgtk_popup_menu *menu, bool submenu, if (custom) { gtk_widget_show(GTK_WIDGET(menu->customize_menuitem)); } - } @@ -240,16 +258,20 @@ static void popup_menu_show(struct nsgtk_popup_menu *menu, bool submenu, /** * resource cleanup function for window destruction. + * + * gtk event called when window is being destroyed. Need to free any + * resources associated with this scaffold, + * + * \param widget the widget being destroyed + * \param data The context pointer passed when the connection was made. */ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data) { struct nsgtk_scaffolding *gs = data; - LOG("scaffold:%p", gs); + NSLOG(netsurf, INFO, "scaffold:%p", gs); - if ((gs->history_window) && (gs->history_window->window)) { - gtk_widget_destroy(GTK_WIDGET(gs->history_window->window)); - } + nsgtk_local_history_hide(); if (gs->prev != NULL) { gs->prev->next = gs->next; @@ -260,7 +282,7 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data) gs->next->prev = gs->prev; } - LOG("scaffold list head: %p", scaf_list); + NSLOG(netsurf, INFO, "scaffold list head: %p", scaf_list); if (scaf_list == NULL) { /* no more open windows - stop the browser */ @@ -268,11 +290,21 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data) } } -/* signal delivered on window delete event, allowing to halt close if - * download is in progress + +/** + * gtk event callback on window delete event. + * + * prevent window close if download is in progress + * + * \param widget The widget receiving the delete event + * \param event The event + * \param data The context pointer passed when the connection was made. + * \return TRUE to indicate message handled. */ -static gboolean scaffolding_window_delete_event(GtkWidget *widget, - GdkEvent *event, gpointer data) +static gboolean +scaffolding_window_delete_event(GtkWidget *widget, + GdkEvent *event, + gpointer data) { struct nsgtk_scaffolding *g = data; @@ -282,12 +314,16 @@ static gboolean scaffolding_window_delete_event(GtkWidget *widget, return TRUE; } + /** - * Update the scaffoling button sensitivity, url bar and local history size + * Update the scaffolding controls + * + * The button sensitivity, url bar and local history visibility are updated + * + * \param g The scaffolding context to update */ static void scaffolding_update_context(struct nsgtk_scaffolding *g) { - int width, height; struct browser_window *bw = nsgtk_get_browser_window(g->top_level); g->buttons[BACK_BUTTON]->sensitivity = @@ -300,34 +336,41 @@ static void scaffolding_update_context(struct nsgtk_scaffolding *g) /* update the url bar, particularly necessary when tabbing */ browser_window_refresh_url_bar(bw); - /* update the local history window, as well as queuing a redraw - * for it. - */ - browser_window_history_size(bw, &width, &height); - gtk_widget_set_size_request(GTK_WIDGET(g->history_window->drawing_area), - width, height); - gtk_widget_queue_draw(GTK_WIDGET(g->history_window->drawing_area)); + nsgtk_local_history_hide(); } + /** * Make the throbber run. + * + * scheduled callback to update the throbber + * + * \param p The context passed when scheduled. */ static void nsgtk_throb(void *p) { struct nsgtk_scaffolding *g = p; - if (g->throb_frame >= (nsgtk_throbber->nframes - 1)) + if (g->throb_frame >= (nsgtk_throbber->nframes - 1)) { g->throb_frame = 1; - else + } else { g->throb_frame++; + } - gtk_image_set_from_pixbuf(g->throbber, nsgtk_throbber->framedata[ - g->throb_frame]); + gtk_image_set_from_pixbuf(g->throbber, + nsgtk_throbber->framedata[g->throb_frame]); nsgtk_schedule(100, nsgtk_throb, p); } -static guint nsgtk_scaffolding_update_edit_actions_sensitivity( + +/** + * edit the sensitivity of focused widget + * + * \param g The scaffolding context. + */ +static guint +nsgtk_scaffolding_update_edit_actions_sensitivity( struct nsgtk_scaffolding *g) { GtkWidget *widget = gtk_window_get_focus(g->window); @@ -361,7 +404,13 @@ static guint nsgtk_scaffolding_update_edit_actions_sensitivity( } -static void nsgtk_scaffolding_enable_edit_actions_sensitivity( +/** + * make edit actions sensitive + * + * \param g The scaffolding context. + */ +static void +nsgtk_scaffolding_enable_edit_actions_sensitivity( struct nsgtk_scaffolding *g) { @@ -374,22 +423,46 @@ static void nsgtk_scaffolding_enable_edit_actions_sensitivity( } /* signal handling functions for the toolbar, URL bar, and menu bar */ -static gboolean nsgtk_window_edit_menu_clicked(GtkWidget *widget, - struct nsgtk_scaffolding *g) + +/** + * gtk event for edit menu being show + * + * \param widget The menu widget + * \param g scaffolding handle + * \return TRUE to indicate event handled + */ +static gboolean +nsgtk_window_edit_menu_shown(GtkWidget *widget, + struct nsgtk_scaffolding *g) { nsgtk_scaffolding_update_edit_actions_sensitivity(g); return TRUE; } -static gboolean nsgtk_window_edit_menu_hidden(GtkWidget *widget, - struct nsgtk_scaffolding *g) +/** + * gtk event handler for edit menu being hidden + * + * \param widget The menu widget + * \param g scaffolding handle + * \return TRUE to indicate event handled + */ +static gboolean +nsgtk_window_edit_menu_hidden(GtkWidget *widget, + struct nsgtk_scaffolding *g) { nsgtk_scaffolding_enable_edit_actions_sensitivity(g); return TRUE; } +/** + * gtk event handler for popup menu being hidden. + * + * \param widget The menu widget + * \param g scaffolding handle + * \return TRUE to indicate event handled + */ static gboolean nsgtk_window_popup_menu_hidden(GtkWidget *widget, struct nsgtk_scaffolding *g) { @@ -397,6 +470,7 @@ static gboolean nsgtk_window_popup_menu_hidden(GtkWidget *widget, return TRUE; } +/* exported interface documented in gtk/scaffolding.h */ gboolean nsgtk_window_url_activate_event(GtkWidget *widget, gpointer data) { struct nsgtk_scaffolding *g = data; @@ -419,8 +493,14 @@ gboolean nsgtk_window_url_activate_event(GtkWidget *widget, gpointer data) return TRUE; } + /** * update handler for URL entry widget + * + * \param widget The widget receiving the delete event + * \param event The event + * \param data The context pointer passed when the connection was made. + * \return TRUE to indicate signal handled. */ gboolean nsgtk_window_url_changed(GtkWidget *widget, @@ -430,11 +510,23 @@ nsgtk_window_url_changed(GtkWidget *widget, return nsgtk_completion_update(GTK_ENTRY(widget)); } + /** * Event handler for popup menu on toolbar. + * + * \param toolbar The toolbar being clicked + * \param x The x coordinate where the click happened + * \param y The x coordinate where the click happened + * \param button the buttons being pressed + * \param data The context pointer passed when the connection was made. + * \return TRUE to indicate event handled. */ -static gboolean nsgtk_window_tool_bar_clicked(GtkToolbar *toolbar, - gint x, gint y, gint button, gpointer data) +static gboolean +nsgtk_window_tool_bar_clicked(GtkToolbar *toolbar, + gint x, + gint y, + gint button, + gpointer data) { struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; @@ -448,23 +540,40 @@ static gboolean nsgtk_window_tool_bar_clicked(GtkToolbar *toolbar, return TRUE; } + /** * Update the menus when the number of tabs changes. + * + * \param notebook The notebook all the tabs are in + * \param page The newly added page container widget + * \param page_num The index of the newly added page + * \param g The scaffolding context containing the notebook */ -static void nsgtk_window_tabs_add(GtkNotebook *notebook, - GtkWidget *page, guint page_num, struct nsgtk_scaffolding *g) +static void +nsgtk_window_tabs_add(GtkNotebook *notebook, + GtkWidget *page, + guint page_num, + struct nsgtk_scaffolding *g) { gboolean visible = gtk_notebook_get_show_tabs(g->notebook); - g_object_set(g->menu_bar->view_submenu->tabs_menuitem, "visible", visible, NULL); - g_object_set(g->menu_popup->view_submenu->tabs_menuitem, "visible", visible, NULL); + g_object_set(g->menu_bar->view_submenu->tabs_menuitem, + "visible", visible, NULL); + g_object_set(g->menu_popup->view_submenu->tabs_menuitem, + "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); } + /** * Update the menus when the number of tabs changes. + * + * \param notebook The notebook all the tabs are in + * \param page The page container widget being removed + * \param page_num The index of the removed page + * \param gs The scaffolding context containing the notebook */ static void nsgtk_window_tabs_remove(GtkNotebook *notebook, @@ -473,7 +582,7 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook, struct nsgtk_scaffolding *gs) { /* if the scaffold is being destroyed it is not useful to - * update the state, futher many of the widgets may have + * update the state, further many of the widgets may have * already been destroyed. */ if (gtk_widget_in_destruction(GTK_WIDGET(gs->window)) == TRUE) { @@ -497,6 +606,8 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook, /** * Handle opening a file path. + * + * \param filename The filename to open. */ static void nsgtk_openfile_open(const char *filename) { @@ -560,6 +671,7 @@ MULTIHANDLER(newwindow) return TRUE; } +/* exported interface documented in gtk/scaffolding.h */ nserror nsgtk_scaffolding_new_tab(struct gui_window *gw) { struct browser_window *bw = nsgtk_get_browser_window(gw); @@ -629,8 +741,16 @@ MULTIHANDLER(openfile) return TRUE; } -static gboolean nsgtk_filter_directory(const GtkFileFilterInfo *info, - gpointer data) +/** + * callback to determine if a path is a directory. + * + * \param info The path information + * \param data context pointer set to NULL + * \return TRUE if path is a directory else false + */ +static gboolean +nsgtk_filter_directory(const GtkFileFilterInfo *info, + gpointer data) { DIR *d = opendir(info->filename); if (d == NULL) @@ -660,7 +780,7 @@ MULTIHANDLER(savepage) gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fc), filter); gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fc), filter); - res = nsurl_nice(browser_window_get_url( + res = nsurl_nice(browser_window_access_url( nsgtk_get_browser_window(g->top_level)), &path, false); if (res != NSERROR_OK) { path = strdup(messages_get("SaveText")); @@ -685,7 +805,10 @@ MULTIHANDLER(savepage) path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc)); d = opendir(path); if (d == NULL) { - LOG("Unable to open directory %s for complete save: %s", path, strerror(errno)); + NSLOG(netsurf, INFO, + "Unable to open directory %s for complete save: %s", + path, + strerror(errno)); if (errno == ENOTDIR) nsgtk_warning("NoDirError", path); else @@ -717,9 +840,9 @@ MULTIHANDLER(pdf) char *url_name; nserror res; - LOG("Print preview (generating PDF) started."); + NSLOG(netsurf, INFO, "Print preview (generating PDF) started."); - res = nsurl_nice(browser_window_get_url(bw), &url_name, true); + res = nsurl_nice(browser_window_access_url(bw), &url_name, true); if (res != NSERROR_OK) { nsgtk_warning(messages_get_errorcode(res), 0); return TRUE; @@ -735,7 +858,7 @@ MULTIHANDLER(pdf) strncat(dirname, "/", PATH_MAX - strlen(dirname)); dirname[PATH_MAX - 1] = '\0'; - /* this way the scale used by PDF functions is synchronized with that + /* this way the scale used by PDF functions is synchronised with that * used by the all-purpose print interface */ haru_nsfont_set_scale((float)option_export_scale / 100); @@ -792,7 +915,7 @@ MULTIHANDLER(plaintext) char *filename; nserror res; - res = nsurl_nice(browser_window_get_url( + res = nsurl_nice(browser_window_access_url( nsgtk_get_browser_window(g->top_level)), &filename, false); if (res != NSERROR_OK) { @@ -891,7 +1014,7 @@ MULTIHANDLER(print) CONTENT_TEXTPLAIN) { res = gtk_print_operation_run(print_op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, - g->window, + g->window, NULL); } @@ -1101,10 +1224,10 @@ MULTIHANDLER(selectall) struct browser_window *bw = nsgtk_get_browser_window(g->top_level); if (nsgtk_widget_has_focus(GTK_WIDGET(g->url_bar))) { - LOG("Selecting all URL bar text"); + NSLOG(netsurf, INFO, "Selecting all URL bar text"); gtk_editable_select_region(GTK_EDITABLE(g->url_bar), 0, -1); } else { - LOG("Selecting all document text"); + NSLOG(netsurf, INFO, "Selecting all document text"); browser_window_key_press(bw, NS_KEY_SELECT_ALL); } @@ -1466,31 +1589,13 @@ MULTIHANDLER(home) MULTIHANDLER(localhistory) { struct browser_window *bw = nsgtk_get_browser_window(g->top_level); + nserror res; - int x,y, width, height, mainwidth, mainheight, margin = 20; - /* if entries of the same url but different frag_ids have been added - * the history needs redrawing (what throbber code normally does) - */ - - scaffolding_update_context(g); - gtk_window_get_position(g->window, &x, &y); - gtk_window_get_size(g->window, &mainwidth, &mainheight); - browser_window_history_size(bw, &width, &height); - width = (width + g->historybase + margin > mainwidth) ? - mainwidth - g->historybase : width + margin; - height = (height + g->toolbarbase + margin > mainheight) ? - mainheight - g->toolbarbase : height + margin; - gtk_window_set_default_size(g->history_window->window, width, height); - gtk_widget_set_size_request(GTK_WIDGET(g->history_window->window), - -1, -1); - gtk_window_resize(g->history_window->window, width, height); - gtk_window_set_transient_for(g->history_window->window, g->window); - nsgtk_window_set_opacity(g->history_window->window, 0.9); - 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(nsgtk_widget_get_window(GTK_WIDGET(g->history_window->window))); - + res = nsgtk_local_history_present(g->window, bw); + if (res != NSERROR_OK) { + NSLOG(netsurf, INFO, + "Unable to initialise local history window."); + } return TRUE; } @@ -1499,7 +1604,8 @@ MULTIHANDLER(globalhistory) nserror res; res = nsgtk_global_history_present(); if (res != NSERROR_OK) { - LOG("Unable to initialise global history window."); + NSLOG(netsurf, INFO, + "Unable to initialise global history window."); } return TRUE; } @@ -1510,7 +1616,7 @@ MULTIHANDLER(addbookmarks) if (bw == NULL || !browser_window_has_content(bw)) return TRUE; - hotlist_add_url(browser_window_get_url(bw)); + hotlist_add_url(browser_window_access_url(bw)); return TRUE; } @@ -1519,7 +1625,7 @@ MULTIHANDLER(showbookmarks) nserror res; res = nsgtk_hotlist_present(); if (res != NSERROR_OK) { - LOG("Unable to initialise bookmark window."); + NSLOG(netsurf, INFO, "Unable to initialise bookmark window."); } return TRUE; } @@ -1529,7 +1635,7 @@ MULTIHANDLER(showcookies) nserror res; res = nsgtk_cookies_present(); if (res != NSERROR_OK) { - LOG("Unable to initialise cookies window."); + NSLOG(netsurf, INFO, "Unable to initialise cookies window."); } return TRUE; } @@ -1643,98 +1749,6 @@ BUTTONHANDLER(history) #undef CHECKHANDLER #undef BUTTONHANDLER -#if GTK_CHECK_VERSION(3,0,0) - -static gboolean -nsgtk_history_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data) -{ - struct rect clip; - struct gtk_history_window *hw = (struct gtk_history_window *)data; - struct browser_window *bw = - nsgtk_get_browser_window(hw->g->top_level); - - struct redraw_context ctx = { - .interactive = true, - .background_images = true, - .plot = &nsgtk_plotters - }; - double x1; - double y1; - double x2; - double y2; - - current_widget = widget; - current_cr = cr; - - cairo_clip_extents(cr, &x1, &y1, &x2, &y2); - - clip.x0 = x1; - clip.y0 = y1; - clip.x1 = x2; - clip.y1 = y2; - - ctx.plot->clip(&clip); - - browser_window_history_redraw(bw, &ctx); - - current_widget = NULL; - - return FALSE; -} -#else - -/* signal handler functions for the local history window */ -static gboolean -nsgtk_history_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer g) -{ - struct rect clip; - struct gtk_history_window *hw = (struct gtk_history_window *)g; - struct browser_window *bw = - nsgtk_get_browser_window(hw->g->top_level); - - struct redraw_context ctx = { - .interactive = true, - .background_images = true, - .plot = &nsgtk_plotters - }; - - current_widget = widget; - - current_cr = gdk_cairo_create(nsgtk_widget_get_window(widget)); - - clip.x0 = event->area.x; - clip.y0 = event->area.y; - clip.x1 = event->area.x + event->area.width; - clip.y1 = event->area.y + event->area.height; - ctx.plot->clip(&clip); - - browser_window_history_redraw(bw, &ctx); - - cairo_destroy(current_cr); - - current_widget = NULL; - - return FALSE; -} - -#endif /* GTK_CHECK_VERSION(3,0,0) */ - -static 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_window(hw->g->top_level); - - LOG("X=%g, Y=%g", event->x, event->y); - - browser_window_history_click(bw, event->x, event->y, false); - - return TRUE; -} - - - static void nsgtk_attach_menu_handlers(struct nsgtk_scaffolding *g) { for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { @@ -2059,12 +2073,13 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) int i; GtkAccelGroup *group; - gs = malloc(sizeof(*gs)); + gs = calloc(1, sizeof(*gs)); if (gs == NULL) { return NULL; } - LOG("Constructing a scaffold of %p for gui_window %p", gs, toplevel); + NSLOG(netsurf, INFO, + "Constructing a scaffold of %p for gui_window %p", gs, toplevel); gs->top_level = toplevel; @@ -2188,35 +2203,6 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) gtk_widget_set_size_request(GTK_WIDGET( gs->buttons[HISTORY_BUTTON]->button), 20, -1); - /* create the local history window to be associated with this scaffold */ - gs->history_window = malloc(sizeof(struct gtk_history_window)); - gs->history_window->g = gs; - gs->history_window->window = - GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); - gtk_window_set_transient_for(gs->history_window->window, gs->window); - gtk_window_set_title(gs->history_window->window, "NetSurf History"); - gtk_window_set_type_hint(gs->history_window->window, - GDK_WINDOW_TYPE_HINT_UTILITY); - gs->history_window->scrolled = - GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(0, 0)); - gtk_container_add(GTK_CONTAINER(gs->history_window->window), - GTK_WIDGET(gs->history_window->scrolled)); - - gtk_widget_show(GTK_WIDGET(gs->history_window->scrolled)); - gs->history_window->drawing_area = - GTK_DRAWING_AREA(gtk_drawing_area_new()); - - gtk_widget_set_events(GTK_WIDGET(gs->history_window->drawing_area), - GDK_EXPOSURE_MASK | - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_PRESS_MASK); - nsgtk_widget_override_background_color(GTK_WIDGET(gs->history_window->drawing_area), - GTK_STATE_NORMAL, - 0, 0xffff, 0xffff, 0xffff); - nsgtk_scrolled_window_add_with_viewport(gs->history_window->scrolled, - GTK_WIDGET(gs->history_window->drawing_area)); - gtk_widget_show(GTK_WIDGET(gs->history_window->drawing_area)); - /* set up URL bar completion */ gs->url_bar_completion = nsgtk_url_entry_completion_new(gs); @@ -2228,17 +2214,6 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) #define CONNECT(obj, sig, callback, ptr) \ g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr)) - /* connect history window signals to their handlers */ - nsgtk_connect_draw_event(GTK_WIDGET(gs->history_window->drawing_area), - G_CALLBACK(nsgtk_history_draw_event), - gs->history_window); - /*CONNECT(gs->history_window->drawing_area, "motion_notify_event", - nsgtk_history_motion_notify_event, gs->history_window);*/ - CONNECT(gs->history_window->drawing_area, "button_press_event", - nsgtk_history_button_press_event, gs->history_window); - CONNECT(gs->history_window->window, "delete_event", - gtk_widget_hide_on_delete, NULL); - g_signal_connect_after(gs->notebook, "page-added", G_CALLBACK(nsgtk_window_tabs_add), gs); g_signal_connect_after(gs->notebook, "page-removed", @@ -2252,7 +2227,7 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) /* toolbar URL bar menu bar search bar signal handlers */ CONNECT(gs->menu_bar->edit_submenu->edit, "show", - nsgtk_window_edit_menu_clicked, gs); + nsgtk_window_edit_menu_shown, gs); CONNECT(gs->menu_bar->edit_submenu->edit, "hide", nsgtk_window_edit_menu_hidden, gs); @@ -2309,7 +2284,7 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) /* finally, show the window. */ gtk_widget_show(GTK_WIDGET(gs->window)); - LOG("creation complete"); + NSLOG(netsurf, INFO, "creation complete"); return gs; } @@ -2497,7 +2472,8 @@ gui_search_web_provider_update(const char *provider_name, GdkPixbuf *srch_pixbuf = NULL; char *searchcontent; - LOG("name:%s bitmap %p", provider_name, provider_bitmap); + NSLOG(netsurf, INFO, "name:%s bitmap %p", provider_name, + provider_bitmap); if (provider_bitmap != NULL) { srch_pixbuf = nsgdk_pixbuf_get_from_surface(provider_bitmap->surface, 16, 16); @@ -2515,7 +2491,11 @@ gui_search_web_provider_update(const char *provider_name, /* set the search provider parameters up in each scaffold */ for (current = scaf_list; current != NULL; current = current->next) { - /* add ico to each window's toolbar */ + if (current->webSearchEntry == NULL) { + continue; + } + + /* add ico to each window's toolbar */ if (srch_pixbuf != NULL) { nsgtk_entry_set_icon_from_pixbuf(current->webSearchEntry, GTK_ENTRY_ICON_PRIMARY, @@ -2599,13 +2579,6 @@ GtkMenuBar *nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *g) } /* exported interface documented in gtk/scaffolding.h */ -struct gtk_history_window * -nsgtk_scaffolding_history_window(struct nsgtk_scaffolding *g) -{ - return g->history_window; -} - -/* exported interface documented in gtk/scaffolding.h */ struct nsgtk_scaffolding *nsgtk_scaffolding_iterate(struct nsgtk_scaffolding *g) { if (g == NULL) { @@ -2774,7 +2747,7 @@ void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g, gtk_widget_show(GTK_WIDGET(g->menu_popup->paste_menuitem)); } - /* hide customize */ + /* hide customise */ popup_menu_hide(g->menu_popup, false, false, false, true); } diff --git a/frontends/gtk/schedule.c b/frontends/gtk/schedule.c index cf0333388..d5b45674b 100644 --- a/frontends/gtk/schedule.c +++ b/frontends/gtk/schedule.c @@ -21,14 +21,10 @@ #include <stdbool.h> #include "utils/errors.h" +#include "utils/log.h" #include "gtk/schedule.h" -#ifdef DEBUG_GTK_SCHEDULE -#include "utils/log.h" -#else -#define LOG(format, args...) ((void) 0) -#endif /** Killable callback closure embodiment. */ typedef struct { @@ -50,7 +46,7 @@ nsgtk_schedule_generic_callback(gpointer data) _nsgtk_callback_t *cb = (_nsgtk_callback_t *)(data); if (cb->callback_killed) { /* This callback instance has been killed. */ - LOG("CB at %p already dead.", cb); + NSLOG(schedule, DEBUG, "CB at %p already dead.", cb); } queued_callbacks = g_list_remove(queued_callbacks, cb); pending_callbacks = g_list_append(pending_callbacks, cb); @@ -64,7 +60,9 @@ nsgtk_schedule_kill_callback(void *_target, void *_match) _nsgtk_callback_t *match = (_nsgtk_callback_t *)_match; if ((target->callback == match->callback) && (target->context == match->context)) { - LOG("Found match for %p(%p), killing.", target->callback, target->context); + NSLOG(schedule, DEBUG, + "Found match for %p(%p), killing.", + target->callback, target->context); target->callback = NULL; target->context = NULL; target->callback_killed = true; @@ -122,7 +120,9 @@ schedule_run(void) /* Clear the pending list. */ pending_callbacks = NULL; - LOG("Captured a run of %d callbacks to fire.", g_list_length(this_run)); + NSLOG(schedule, DEBUG, + "Captured a run of %d callbacks to fire.", + g_list_length(this_run)); /* Run all the callbacks which made it this far. */ while (this_run != NULL) { diff --git a/frontends/gtk/ssl_cert.c b/frontends/gtk/ssl_cert.c index 5388f0194..9d98db1f6 100644 --- a/frontends/gtk/ssl_cert.c +++ b/frontends/gtk/ssl_cert.c @@ -183,7 +183,7 @@ nserror gtk_cert_verify(struct nsurl *url, res = nsgtk_builder_new_from_resname("ssl", &ncwin->builder); if (res != NSERROR_OK) { - LOG("SSL UI builder init failed"); + NSLOG(netsurf, INFO, "SSL UI builder init failed"); free(ncwin); return res; } diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c index 6adce3a06..dbe9d405b 100644 --- a/frontends/gtk/tabs.c +++ b/frontends/gtk/tabs.c @@ -147,18 +147,20 @@ nsgtk_tab_switch_page_after(GtkNotebook *notebook, if ((srcpagenum != -1) && (srcpagenum != (gint)selpagenum)) { /* ensure the add tab is not actually selected */ - LOG("src %d sel %d", srcpagenum, selpagenum); + NSLOG(netsurf, INFO, "src %d sel %d", srcpagenum, + selpagenum); srcpage = gtk_notebook_get_nth_page(notebook, srcpagenum); gw = g_object_get_data(G_OBJECT(srcpage), "gui_window"); if ((gw != NULL) && (nsgtk_get_scaffold(gw) != NULL)) { error = nsgtk_scaffolding_new_tab(gw); if (error != NSERROR_OK) { - LOG("Failed to open new tab."); + NSLOG(netsurf, INFO, + "Failed to open new tab."); } } } } else { - LOG("sel %d", selpagenum); + NSLOG(netsurf, INFO, "sel %d", selpagenum); /* tab with page in it */ gw = g_object_get_data(G_OBJECT(selpage), "gui_window"); if (gw != NULL) { diff --git a/frontends/gtk/throbber.c b/frontends/gtk/throbber.c index 9392c3909..b8efceca1 100644 --- a/frontends/gtk/throbber.c +++ b/frontends/gtk/throbber.c @@ -59,12 +59,14 @@ nserror nsgtk_throbber_init(void) if (res != NSERROR_OK) { break; } - LOG("%s",resname); + NSLOG(netsurf, INFO, "%s", resname); } if (frame < 1) { /* we need at least two frames - one for idle, one for active */ - LOG("Insufficent number of frames (%d) in throbber animation.", frame); + NSLOG(netsurf, INFO, + "Insufficent number of frames (%d) in throbber animation.", + frame); res = NSERROR_INIT_FAILED; } diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c index ac24a78ca..e93bd49f9 100644 --- a/frontends/gtk/toolbar.c +++ b/frontends/gtk/toolbar.c @@ -26,6 +26,7 @@ #include "utils/log.h" #include "utils/messages.h" #include "utils/nsoption.h" +#include "utils/file.h" #include "gtk/gui.h" #include "gtk/warn.h" @@ -44,7 +45,7 @@ static bool edit_mode = false; struct nsgtk_toolbar_custom_store { GtkWidget *window; - GtkWidget *store_buttons[PLACEHOLDER_BUTTON]; + GtkWidget *store_buttons[PLACEHOLDER_BUTTON]; GtkWidget *widgetvbox; GtkWidget *currentbar; char numberh; /* current horizontal location while adding */ @@ -107,13 +108,13 @@ static char *remove_underscores(const char *s, bool replacespace) ret = malloc(len + 1); if (ret == NULL) { return NULL; - } + } for (i = 0, ii = 0; i < len; i++) { if (s[i] != '_') { ret[ii++] = s[i]; - } else if (replacespace) { + } else if (replacespace) { ret[ii++] = ' '; - } + } } ret[ii] = '\0'; return ret; @@ -125,6 +126,7 @@ static char *remove_underscores(const char *s, bool replacespace) * * \param tbbutton button reference * \param iconsize The size of icons to select. + * \param usedef Use the default image if not found. * \return default images. */ static GtkImage * @@ -193,6 +195,7 @@ nsgtk_theme_image_default(nsgtk_toolbar_button tbbutton, * * \param tbbutton search button reference * \param iconsize The size of icons to select. + * \param usedef Use the default image if not found. * \return default search image. */ @@ -206,18 +209,18 @@ nsgtk_theme_searchimage_default(nsgtk_search_buttons tbbutton, switch (tbbutton) { case (SEARCH_BACK_BUTTON): - image = GTK_IMAGE(nsgtk_image_new_from_stock(NSGTK_STOCK_GO_BACK, - iconsize)); + image = GTK_IMAGE(nsgtk_image_new_from_stock( + NSGTK_STOCK_GO_BACK, iconsize)); break; case (SEARCH_FORWARD_BUTTON): - image = GTK_IMAGE(nsgtk_image_new_from_stock(NSGTK_STOCK_GO_FORWARD, - iconsize)); + image = GTK_IMAGE(nsgtk_image_new_from_stock( + NSGTK_STOCK_GO_FORWARD, iconsize)); break; case (SEARCH_CLOSE_BUTTON): - image = GTK_IMAGE(nsgtk_image_new_from_stock(NSGTK_STOCK_CLOSE, - iconsize)); + image = GTK_IMAGE(nsgtk_image_new_from_stock( + NSGTK_STOCK_CLOSE, iconsize)); break; default: @@ -225,7 +228,8 @@ nsgtk_theme_searchimage_default(nsgtk_search_buttons tbbutton, } if (usedef && (image == NULL)) { - image = GTK_IMAGE(nsgtk_image_new_from_stock("gtk-missing-image", iconsize)); + image = GTK_IMAGE(nsgtk_image_new_from_stock( + "gtk-missing-image", iconsize)); } return image; @@ -253,7 +257,6 @@ static struct nsgtk_theme *nsgtk_theme_load(GtkIconSize iconsize, bool usedef) theme->image[btnloop] = nsgtk_theme_image_default(btnloop, iconsize, usedef); - } for (btnloop = SEARCH_BACK_BUTTON; @@ -821,8 +824,9 @@ static void nsgtk_toolbar_close(struct nsgtk_scaffolding *g) */ static gboolean nsgtk_toolbar_cancel_clicked(GtkWidget *widget, gpointer data) { - edit_mode = false; struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; + + edit_mode = false; /* reset g->buttons->location */ for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { nsgtk_scaffolding_button(g, i)->location = @@ -948,6 +952,7 @@ void nsgtk_toolbar_customization_load(struct nsgtk_scaffolding *g) */ static nserror nsgtk_toolbar_customization_save(struct nsgtk_scaffolding *g) { + char *choices = NULL; char *order; int order_len = PLACEHOLDER_BUTTON * 12; /* length of order buffer */ int tbidx; @@ -969,7 +974,8 @@ static nserror nsgtk_toolbar_customization_save(struct nsgtk_scaffolding *g) nsgtk_scaffolding_button(g, tbidx)->location); if (plen == order_len) { /* ran out of space, bail early */ - LOG("toolbar ordering exceeded available space"); + NSLOG(netsurf, INFO, + "toolbar ordering exceeded available space"); break; } cur += plen; @@ -978,6 +984,13 @@ static nserror nsgtk_toolbar_customization_save(struct nsgtk_scaffolding *g) nsoption_set_charp(toolbar_order, order); + /* ensure choices are saved */ + netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices"); + if (choices != NULL) { + nsoption_write(choices, NULL, NULL); + free(choices); + } + return NSERROR_OK; } @@ -987,8 +1000,9 @@ static nserror nsgtk_toolbar_customization_save(struct nsgtk_scaffolding *g) */ static gboolean nsgtk_toolbar_persist(GtkWidget *widget, gpointer data) { - edit_mode = false; struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; + + edit_mode = false; /* save state to file, update toolbars for all windows */ nsgtk_toolbar_customization_save(g); nsgtk_toolbar_cast(g); @@ -1095,7 +1109,6 @@ nsgtk_toolbar_store_action(GtkWidget *widget, GdkDragContext *gdc, */ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g) { - int x = 0, y = 0; struct nsgtk_theme *theme; nserror res; @@ -1108,8 +1121,8 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g) res = nsgtk_builder_new_from_resname("toolbar", &window->builder); if (res != NSERROR_OK) { - LOG("Toolbar UI builder init failed"); - nsgtk_warning(messages_get("NoMemory"), 0); + NSLOG(netsurf, INFO, "Toolbar UI builder init failed"); + nsgtk_warning("Toolbar UI builder init failed", 0); nsgtk_toolbar_cancel_clicked(NULL, g); free(theme); return; @@ -1117,8 +1130,8 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g) gtk_builder_connect_signals(window->builder, NULL); - window->window = GTK_WIDGET(gtk_builder_get_object(window->builder, - "toolbarwindow")); + window->window = GTK_WIDGET(gtk_builder_get_object( + window->builder, "dialogToolbar")); if (window->window == NULL) { nsgtk_warning(messages_get("NoMemory"), 0); nsgtk_toolbar_cancel_clicked(NULL, g); @@ -1126,8 +1139,11 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g) return; } - window->widgetvbox = GTK_WIDGET(gtk_builder_get_object(window->builder, - "widgetvbox")); + gtk_window_set_transient_for(GTK_WINDOW(window->window), + nsgtk_scaffolding_window(g)); + + window->widgetvbox = GTK_WIDGET(gtk_builder_get_object( + window->builder, "widgetvbox")); if (window->widgetvbox == NULL) { nsgtk_warning(messages_get("NoMemory"), 0); nsgtk_toolbar_cancel_clicked(NULL, g); @@ -1135,9 +1151,12 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g) return; } - window->numberh = NSGTK_STORE_WIDTH; /* preset to width [in buttons] of */ + /* preset to width [in buttons] of */ + window->numberh = NSGTK_STORE_WIDTH; + /* store to cause creation of a new toolbar */ window->currentbutton = -1; + /* load toolbuttons */ /* add toolbuttons to window */ /* set event handlers */ @@ -1157,33 +1176,20 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *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(GTK_WIDGET(gtk_builder_get_object(window->builder, - "cancelbutton")), - "clicked", - G_CALLBACK(nsgtk_toolbar_cancel_clicked), - g); - g_signal_connect(GTK_WIDGET(gtk_builder_get_object(window->builder, - "okbutton")), + g_signal_connect(GTK_WIDGET(gtk_builder_get_object( + window->builder, "close")), "clicked", G_CALLBACK(nsgtk_toolbar_persist), g); - g_signal_connect(GTK_WIDGET(gtk_builder_get_object(window->builder, - "resetbutton")), + g_signal_connect(GTK_WIDGET(gtk_builder_get_object( + window->builder, "reset")), "clicked", G_CALLBACK(nsgtk_toolbar_reset), g); @@ -1196,6 +1202,8 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g) g_signal_connect(window->window, "drag-motion", G_CALLBACK(nsgtk_toolbar_store_action), g); + + gtk_widget_show_all(window->window); } /** @@ -1339,33 +1347,37 @@ nsgtk_toolbar_set_handler(struct nsgtk_scaffolding *g, nsgtk_toolbar_button 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); + "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); + "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); + "activate", G_CALLBACK( + nsgtk_websearch_activate), g); g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_websearch(g)), - "button-press-event", G_CALLBACK( - nsgtk_websearch_clear), g); + "button-press-event", G_CALLBACK( + nsgtk_websearch_clear), g); break; + default: if ((nsgtk_scaffolding_button(g, i)->bhandler != NULL) && - (nsgtk_scaffolding_button(g, i)->button - != NULL)) - g_signal_connect(nsgtk_scaffolding_button(g, i)-> - button, "clicked", - G_CALLBACK(nsgtk_scaffolding_button(g, - i)->bhandler), g); - break; + (nsgtk_scaffolding_button(g, i)->button != NULL)) { + g_signal_connect( + nsgtk_scaffolding_button(g, i)->button, + "clicked", + G_CALLBACK(nsgtk_scaffolding_button( + g, i)->bhandler), g); + } + break; } } @@ -1457,7 +1469,8 @@ DATAHANDLER(prevtab, PREVTAB, window) DATAHANDLER(guide, GUIDE, window) DATAHANDLER(info, INFO, window) #undef DATAHANDLER -#define DATAHANDLER(p, q, r)\ + +#define DATAHANDLER(p, q, r) \ gboolean nsgtk_toolbar_##p##_button_data(GtkWidget *widget, GdkDragContext\ *cont, GtkSelectionData *selection, guint info, guint time,\ gpointer data)\ @@ -1478,5 +1491,3 @@ gboolean nsgtk_toolbar_##p##_toolbar_button_data(GtkWidget *widget,\ DATAHANDLER(throbber, THROBBER, window) DATAHANDLER(websearch, WEBSEARCH, window) #undef DATAHANDLER - - diff --git a/frontends/gtk/viewdata.c b/frontends/gtk/viewdata.c index 6ed9dd9ac..d633238d0 100644 --- a/frontends/gtk/viewdata.c +++ b/frontends/gtk/viewdata.c @@ -371,7 +371,7 @@ window_init(const char *title, res = nsgtk_builder_new_from_resname("viewdata", &newctx->builder); if (res != NSERROR_OK) { - LOG("Viewdata UI builder init failed"); + NSLOG(netsurf, INFO, "Viewdata UI builder init failed"); free(newctx); return res; } @@ -381,7 +381,7 @@ window_init(const char *title, window = GTK_WINDOW(gtk_builder_get_object(newctx->builder, "ViewDataWindow")); if (window == NULL) { - LOG("Unable to find window in builder "); + NSLOG(netsurf, INFO, "Unable to find window in builder "); /* free the builder */ g_object_unref(G_OBJECT(newctx->builder)); @@ -616,7 +616,7 @@ static char** xdg_data_strvec(void) xdg_data_home, xdg_data_dirs); } - LOG("%s", xdg_data_path); + NSLOG(netsurf, INFO, "%s", xdg_data_path); svec = filepath_path_to_strvec(xdg_data_path); free(xdg_data_path); @@ -651,7 +651,7 @@ static char *xdg_get_default_app(const char *path, const char *mimetype) fname = malloc(fname_len); snprintf(fname, fname_len, "%s/applications/defaults.list", path); - LOG("Checking %s", fname); + NSLOG(netsurf, INFO, "Checking %s", fname); fp = fopen(fname, "r"); free(fname); @@ -674,8 +674,11 @@ static char *xdg_get_default_app(const char *path, const char *mimetype) ret = strdup(line + mimetype_len + 1); - LOG("Found line match for %s length %zu\n", mimetype, rd); - LOG("Result %s", ret); + NSLOG(netsurf, INFO, + "Found line match for %s length %zu\n", + mimetype, + rd); + NSLOG(netsurf, INFO, "Result %s", ret); break; } @@ -714,7 +717,7 @@ static char *xdg_get_exec_cmd(const char *path, const char *desktop) fname = malloc(fname_len); snprintf(fname, fname_len, "%s/applications/%s", path, desktop); - LOG("Checking %s", fname); + NSLOG(netsurf, INFO, "Checking %s", fname); fp = fopen(fname, "r"); free(fname); @@ -735,8 +738,8 @@ static char *xdg_get_exec_cmd(const char *path, const char *desktop) ret = strdup(line + SLEN("Exec=")); - LOG("Found Exec length %zu", rd); - LOG("Result %s", ret); + NSLOG(netsurf, INFO, "Found Exec length %zu", rd); + NSLOG(netsurf, INFO, "Result %s", ret); break; } @@ -801,7 +804,7 @@ static char **build_exec_argv(const char *fname, const char *exec_cmd) argv[aidx] = exec_arg(start, cur - start, fname); if (argv[aidx] != NULL) { - LOG("adding \"%s\"", argv[aidx]); + NSLOG(netsurf, INFO, "adding \"%s\"", argv[aidx]); aidx++; } } diff --git a/frontends/gtk/viewsource.c b/frontends/gtk/viewsource.c index acf81018d..87ff6976a 100644 --- a/frontends/gtk/viewsource.c +++ b/frontends/gtk/viewsource.c @@ -52,7 +52,7 @@ nserror nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw) source_data = content_get_source_data(hlcontent, &source_size); - ret = nsurl_nice(browser_window_get_url(bw), &filename, false); + ret = nsurl_nice(browser_window_access_url(bw), &filename, false); if (ret != NSERROR_OK) { filename = strdup(messages_get("SaveSource")); if (filename == NULL) { @@ -60,12 +60,12 @@ nserror nsgtk_viewsource(GtkWindow *parent, struct browser_window *bw) } } - title = malloc(strlen(nsurl_access(browser_window_get_url(bw))) + SLEN("Source of - NetSurf") + 1); + title = malloc(strlen(nsurl_access(browser_window_access_url(bw))) + SLEN("Source of - NetSurf") + 1); if (title == NULL) { free(filename); return NSERROR_NOMEM; } - sprintf(title, "Source of %s - NetSurf", nsurl_access(browser_window_get_url(bw))); + sprintf(title, "Source of %s - NetSurf", nsurl_access(browser_window_access_url(bw))); ret = utf8_from_enc(source_data, content_get_encoding(hlcontent, CONTENT_ENCODING_NORMAL), diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c index 326e57395..7f24d40ac 100644 --- a/frontends/gtk/window.c +++ b/frontends/gtk/window.c @@ -42,7 +42,6 @@ #include "netsurf/plotters.h" #include "netsurf/form.h" #include "netsurf/keypress.h" -#include "desktop/textarea.h" #include "desktop/searchweb.h" #include "desktop/textinput.h" @@ -52,6 +51,7 @@ #include "gtk/compat.h" #include "gtk/gui.h" #include "gtk/scaffolding.h" +#include "gtk/local_history.h" #include "gtk/plotters.h" #include "gtk/schedule.h" #include "gtk/tabs.h" @@ -211,7 +211,6 @@ nsgtk_window_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data) assert(z); assert(GTK_WIDGET(gw->layout) == widget); - current_widget = (GtkWidget *)gw->layout; current_cr = cr; GtkAdjustment *vscroll = nsgtk_layout_get_vadjustment(gw->layout); @@ -234,8 +233,6 @@ nsgtk_window_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data) nsgtk_plot_caret(gw->caretx, gw->carety, gw->careth); } - current_widget = NULL; - return FALSE; } @@ -261,7 +258,6 @@ nsgtk_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) assert(z); assert(GTK_WIDGET(gw->layout) == widget); - current_widget = (GtkWidget *)gw->layout; current_cr = gdk_cairo_create(nsgtk_layout_get_bin_window(gw->layout)); clip.x0 = event->area.x; @@ -277,8 +273,6 @@ nsgtk_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) cairo_destroy(current_cr); - current_widget = NULL; - return FALSE; } @@ -345,8 +339,7 @@ static gboolean nsgtk_window_button_press_event(GtkWidget *widget, gtk_im_context_reset(g->input_method); gtk_widget_grab_focus(GTK_WIDGET(g->layout)); - gtk_widget_hide(GTK_WIDGET(nsgtk_scaffolding_history_window( - g->scaffold)->window)); + nsgtk_local_history_hide(); g->mouse.pressed_x = event->x / browser_window_get_scale(g->bw); g->mouse.pressed_y = event->y / browser_window_get_scale(g->bw); @@ -361,6 +354,7 @@ static gboolean nsgtk_window_button_press_event(GtkWidget *widget, break; case 3: /* Right button, usually. Action button, context menu. */ + /** \todo determine if hiding the caret here is necessary */ browser_window_remove_caret(g->bw, true); nsgtk_scaffolding_context_menu(g->scaffold, g->mouse.pressed_x, @@ -464,7 +458,7 @@ nsgtk_window_scroll_event(GtkWidget *widget, break; #endif default: - LOG("Unhandled mouse scroll direction"); + NSLOG(netsurf, INFO, "Unhandled mouse scroll direction"); return TRUE; } @@ -747,7 +741,7 @@ gui_window_create(struct browser_window *bw, res = nsgtk_builder_new_from_resname("tabcontents", &tab_builder); if (res != NSERROR_OK) { - LOG("Tab contents UI builder init failed"); + NSLOG(netsurf, INFO, "Tab contents UI builder init failed"); return NULL; } @@ -760,7 +754,8 @@ gui_window_create(struct browser_window *bw, return NULL; } - LOG("Creating gui window %p for browser window %p", g, bw); + NSLOG(netsurf, INFO, "Creating gui window %p for browser window %p", + g, bw); g->bw = bw; g->mouse.state = 0; @@ -901,21 +896,6 @@ void nsgtk_reflow_all_windows(void) } -/** - * callback from core to reformat a window. - */ -static void nsgtk_window_reformat(struct gui_window *gw) -{ - GtkAllocation alloc; - - if (gw != NULL) { - /** @todo consider gtk_widget_get_allocated_width() */ - nsgtk_widget_get_allocation(GTK_WIDGET(gw->layout), &alloc); - - browser_window_reformat(gw->bw, false, alloc.width, alloc.height); - } -} - void nsgtk_window_destroy_browser(struct gui_window *gw) { /* remove tab */ @@ -924,10 +904,10 @@ void nsgtk_window_destroy_browser(struct gui_window *gw) static void gui_window_destroy(struct gui_window *g) { - LOG("gui_window: %p", g); + NSLOG(netsurf, INFO, "gui_window: %p", g); assert(g != NULL); assert(g->bw != NULL); - LOG("scaffolding: %p", g->scaffold); + NSLOG(netsurf, INFO, "scaffolding: %p", g->scaffold); if (g->prev) { g->prev->next = g->next; @@ -939,7 +919,7 @@ static void gui_window_destroy(struct gui_window *g) g->next->prev = g->prev; } - LOG("window list head: %p", window_list); + NSLOG(netsurf, INFO, "window list head: %p", window_list); } /** @@ -961,13 +941,13 @@ static void gui_window_set_icon(struct gui_window *gw, struct hlcache_handle *ic if (icon != NULL) { icon_bitmap = content_get_bitmap(icon); if (icon_bitmap != NULL) { - LOG("Using %p bitmap", icon_bitmap); + NSLOG(netsurf, INFO, "Using %p bitmap", icon_bitmap); gw->icon = nsgdk_pixbuf_get_from_surface(icon_bitmap->surface, 16, 16); } } if (gw->icon == NULL) { - LOG("Using default favicon"); + NSLOG(netsurf, INFO, "Using default favicon"); g_object_ref(favicon_pixbuf); gw->icon = favicon_pixbuf; } @@ -1020,27 +1000,38 @@ static void gui_window_remove_caret(struct gui_window *g) } -static void gui_window_redraw_window(struct gui_window *g) -{ - gtk_widget_queue_draw(GTK_WIDGET(g->layout)); -} - -static void gui_window_update_box(struct gui_window *g, const struct rect *rect) +/** + * Invalidates an area of a GTK browser window + * + * \param g gui_window + * \param rect area to redraw or NULL for the entire window area + * \return NSERROR_OK on success or appropriate error code + */ +static nserror +nsgtk_window_invalidate_area(struct gui_window *g, const struct rect *rect) { int sx, sy; float scale; - if (!browser_window_has_content(g->bw)) - return; + if (rect == NULL) { + gtk_widget_queue_draw(GTK_WIDGET(g->layout)); + return NSERROR_OK; + } + + if (!browser_window_has_content(g->bw)) { + return NSERROR_OK; + } gui_window_get_scroll(g, &sx, &sy); scale = browser_window_get_scale(g->bw); gtk_widget_queue_draw_area(GTK_WIDGET(g->layout), - rect->x0 * scale - sx, - rect->y0 * scale - sy, - (rect->x1 - rect->x0) * scale, - (rect->y1 - rect->y0) * scale); + rect->x0 * scale - sx, + rect->y0 * scale - sy, + (rect->x1 - rect->x0) * scale, + (rect->y1 - rect->y0) * scale); + + return NSERROR_OK; } static void gui_window_set_status(struct gui_window *g, const char *text) @@ -1051,11 +1042,25 @@ static void gui_window_set_status(struct gui_window *g, const char *text) } -static void gui_window_set_scroll(struct gui_window *g, int sx, int sy) +/** + * Set the scroll position of a gtk browser window. + * + * Scrolls the viewport to ensure the specified rectangle of the + * content is shown. The GTK implementation scrolls the contents so + * the specified point in the content is at the top of the viewport. + * + * \param g gui window to scroll + * \param rect The rectangle to ensure is shown. + * \return NSERROR_OK on success or apropriate error code. + */ +static nserror +gui_window_set_scroll(struct gui_window *g, const struct rect *rect) { GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout); GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout); - gdouble vlower, vpage, vupper, hlower, hpage, hupper, x = (double)sx, y = (double)sy; + gdouble vlower, vpage, vupper, hlower, hpage, hupper; + gdouble x = (gdouble)rect->x0; + gdouble y = (gdouble)rect->y0; assert(vadj); assert(hadj); @@ -1063,17 +1068,23 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy) g_object_get(vadj, "page-size", &vpage, "lower", &vlower, "upper", &vupper, NULL); g_object_get(hadj, "page-size", &hpage, "lower", &hlower, "upper", &hupper, NULL); - if (x < hlower) + if (x < hlower) { x = hlower; - if (x > (hupper - hpage)) + } + if (x > (hupper - hpage)) { x = hupper - hpage; - if (y < vlower) + } + if (y < vlower) { y = vlower; - if (y > (vupper - vpage)) + } + if (y > (vupper - vpage)) { y = vupper - vpage; + } gtk_adjustment_set_value(vadj, y); gtk_adjustment_set_value(hadj, x); + + return NSERROR_OK; } static void gui_window_update_extent(struct gui_window *g) @@ -1198,24 +1209,37 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh } -static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, - bool scaled) +/** + * Find the current dimensions of a GTK browser window content area. + * + * \param gw The gui window to measure content area of. + * \param width receives width of window + * \param height receives height of window + * \param scaled whether to return scaled values + * \return NSERROR_OK on sucess and width and height updated + * else error code. + */ +static nserror +gui_window_get_dimensions(struct gui_window *gw, + int *width, int *height, + bool scaled) { GtkAllocation alloc; - /* @todo consider gtk_widget_get_allocated_width() */ - nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc); + /** @todo consider gtk_widget_get_allocated_width() */ + nsgtk_widget_get_allocation(GTK_WIDGET(gw->layout), &alloc); *width = alloc.width; *height = alloc.height; if (scaled) { - float scale = browser_window_get_scale(g->bw); + float scale = browser_window_get_scale(gw->bw); *width /= scale; *height /= scale; } - LOG("width: %i", *width); - LOG("height: %i", *height); + NSLOG(netsurf, INFO, "gw:%p width:%i height:%i", gw, *width, *height); + + return NSERROR_OK; } static void gui_window_start_selection(struct gui_window *g) @@ -1246,8 +1270,8 @@ static void gui_window_create_form_select_menu(struct gui_window *g, item = 0; option = form_select_get_option(control, item); while (option != NULL) { - LOG("Item %"PRIdPTR" option %p text %s", - item, option, option->text); + NSLOG(netsurf, INFO, "Item %"PRIdPTR" option %p text %s", + item, option, option->text); menu_item = gtk_check_menu_item_new_with_label(option->text); if (option->selected) { gtk_check_menu_item_set_active( @@ -1290,10 +1314,10 @@ gui_window_file_gadget_open(struct gui_window *g, NSGTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - LOG("*** open dialog: %p", dialog); + NSLOG(netsurf, INFO, "*** open dialog: %p", dialog); int ret = gtk_dialog_run(GTK_DIALOG(dialog)); - LOG("*** return value: %d", ret); + NSLOG(netsurf, INFO, "*** return value: %d", ret); if (ret == GTK_RESPONSE_ACCEPT) { char *filename; @@ -1301,7 +1325,7 @@ gui_window_file_gadget_open(struct gui_window *g, GTK_FILE_CHOOSER(dialog)); browser_window_set_gadget_filename(g->bw, gadget, filename); - + g_free(filename); } @@ -1311,13 +1335,11 @@ gui_window_file_gadget_open(struct gui_window *g, static struct gui_window_table window_table = { .create = gui_window_create, .destroy = gui_window_destroy, - .redraw = gui_window_redraw_window, - .update = gui_window_update_box, + .invalidate = nsgtk_window_invalidate_area, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, .update_extent = gui_window_update_extent, - .reformat = nsgtk_window_reformat, .set_icon = gui_window_set_icon, .set_status = gui_window_set_status, |