summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/dialogs/gtk_options.c2
-rw-r--r--gtk/dialogs/gtk_source.c44
-rw-r--r--gtk/gtk_gui.c20
-rw-r--r--gtk/gtk_login.c7
-rw-r--r--gtk/gtk_print.c3
-rw-r--r--gtk/gtk_print.h4
-rw-r--r--gtk/gtk_scaffolding.c171
-rw-r--r--gtk/gtk_search.c6
-rw-r--r--gtk/gtk_theme.c29
-rw-r--r--gtk/gtk_thumbnail.c19
-rw-r--r--gtk/gtk_toolbar.c7
-rw-r--r--gtk/gtk_window.c15
12 files changed, 184 insertions, 143 deletions
diff --git a/gtk/dialogs/gtk_options.c b/gtk/dialogs/gtk_options.c
index eb7429223..b883195b4 100644
--- a/gtk/dialogs/gtk_options.c
+++ b/gtk/dialogs/gtk_options.c
@@ -570,7 +570,7 @@ ENTRY_CHANGED(entryHomePageURL, option_homepage_url)
END_HANDLER
BUTTON_CLICKED(setCurrentPage)
- const gchar *url = current_browser->current_content->url;
+ const gchar *url = content_get_url(current_browser->current_content);
gtk_entry_set_text(GTK_ENTRY(entryHomePageURL), url);
option_homepage_url =
strdup(gtk_entry_get_text(GTK_ENTRY(entryHomePageURL)));
diff --git a/gtk/dialogs/gtk_source.c b/gtk/dialogs/gtk_source.c
index 7ee3ef849..842d4c4ef 100644
--- a/gtk/dialogs/gtk_source.c
+++ b/gtk/dialogs/gtk_source.c
@@ -107,7 +107,7 @@ void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw)
{
char glade_Location[strlen(res_dir_location) + SLEN("source.glade")
+ 1];
- if (bw->current_content->type != CONTENT_HTML)
+ if (content_get_type(bw->current_content) != CONTENT_HTML)
return;
if (option_source_tab) {
@@ -121,12 +121,17 @@ void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw)
LOG(("error loading glade tree"));
}
+ const char *source_data;
+ unsigned long source_size;
char *data = NULL;
+ source_data = content_get_source_data(bw->current_content,
+ &source_size);
+
utf8_convert_ret r = utf8_from_enc(
- bw->current_content->source_data,
- bw->current_content->data.html.encoding,
- bw->current_content->source_size,
+ source_data,
+ html_get_encoding(bw->current_content),
+ source_size,
&data);
if (r == UTF8_CONVERT_NOMEM) {
warn_user("NoMemory",0);
@@ -160,7 +165,7 @@ void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw)
return;
}
- thiswindow->url = strdup(bw->current_content->url);
+ thiswindow->url = strdup(content_get_url(bw->current_content));
if (thiswindow->url == NULL) {
free(thiswindow);
free(data);
@@ -173,8 +178,8 @@ void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw)
thiswindow->sourcewindow = wndSource;
thiswindow->bw = bw;
- char title[strlen(bw->current_content->url) + SLEN("Source of ") + 1];
- sprintf(title, "Source of %s", bw->current_content->url);
+ char title[strlen(thiswindow->url) + SLEN("Source of ") + 1];
+ sprintf(title, "Source of %s", thiswindow->url);
thiswindow->next = nsgtk_source_list;
thiswindow->prev = NULL;
@@ -209,11 +214,17 @@ void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw)
}
void nsgtk_source_tab_init(GtkWindow *parent, struct browser_window *bw)
{
+ const char *source_data;
+ unsigned long source_size;
char *ndata = 0;
+
+ source_data = content_get_source_data(bw->current_content,
+ &source_size);
+
utf8_convert_ret r = utf8_from_enc(
- bw->current_content->source_data,
- bw->current_content->data.html.encoding,
- bw->current_content->source_size,
+ source_data,
+ html_get_encoding(bw->current_content),
+ source_size,
&ndata);
if (r == UTF8_CONVERT_NOMEM) {
warn_user("NoMemory",0);
@@ -245,18 +256,9 @@ void nsgtk_source_tab_init(GtkWindow *parent, struct browser_window *bw)
warn_user(messages_get("NoMemory"), 0);
return;
}
- struct browser_window *newbw = browser_window_create(fileurl, bw,
- NULL, false, true);
+ /* Open tab */
+ browser_window_create(fileurl, bw, NULL, false, true);
free(fileurl);
- if (newbw->current_content) {
- newbw->current_content->title = malloc(
- strlen(bw->current_content->url) +
- SLEN("source of ") + 1);
- if (newbw->current_content->title == NULL)
- return;
- sprintf(newbw->current_content->title, "source of %s",
- bw->current_content->url);
- }
}
diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c
index 0251e173f..da8574a79 100644
--- a/gtk/gtk_gui.c
+++ b/gtk/gtk_gui.c
@@ -42,6 +42,7 @@
#include "content/content.h"
#include "content/fetch.h"
#include "content/fetchers/fetch_curl.h"
+#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/401login.h"
#include "desktop/browser.h"
@@ -122,7 +123,14 @@ int main(int argc, char** argv)
setbuf(stderr, NULL);
- return netsurf_main(argc, argv);
+ /* initialise netsurf */
+ netsurf_init(argc, argv);
+
+ netsurf_main_loop();
+
+ netsurf_exit();
+
+ return 0;
}
@@ -599,7 +607,8 @@ void gui_create_form_select_menu(struct browser_window *bw,
}
-void gui_window_save_as_link(struct gui_window *g, struct content *c)
+void gui_window_save_link(struct gui_window *g, const char *url,
+ const char *title)
{
}
@@ -630,12 +639,11 @@ void die(const char * const error)
}
-void hotlist_visited(struct content *content)
+void hotlist_visited(hlcache_handle *content)
{
}
-
-void gui_cert_verify(struct browser_window *bw, struct content *c,
+void gui_cert_verify(struct browser_window *bw, hlcache_handle *c,
const struct ssl_cert_info *certs, unsigned long num)
{
GladeXML *x = glade_xml_new(glade_ssl_file_location, NULL, NULL);
@@ -644,7 +652,7 @@ void gui_cert_verify(struct browser_window *bw, struct content *c,
void **session = calloc(sizeof(void *), 4);
session[0] = bw;
- session[1] = strdup(c->url);
+ session[1] = strdup(content_get_url(c));
session[2] = x;
session[3] = wnd;
diff --git a/gtk/gtk_login.c b/gtk/gtk_login.c
index 3bb11a66b..ed6f92407 100644
--- a/gtk/gtk_login.c
+++ b/gtk/gtk_login.c
@@ -25,6 +25,7 @@
#include "utils/log.h"
#include "gtk/gtk_gui.h"
#include "content/content.h"
+#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/browser.h"
#include "desktop/401login.h"
@@ -51,16 +52,16 @@ static void nsgtk_login_next(GtkWidget *w, gpointer data);
static void nsgtk_login_ok_clicked(GtkButton *w, gpointer data);
static void nsgtk_login_cancel_clicked(GtkButton *w, gpointer data);
-void gui_401login_open(struct browser_window *bw, struct content *c,
+void gui_401login_open(struct browser_window *bw, hlcache_handle *c,
const char *realm)
{
char *host;
url_func_result res;
- res = url_host(c->url, &host);
+ res = url_host(content_get_url(c), &host);
assert(res == URL_FUNC_OK);
- create_login_window(bw, host, realm, c->url);
+ create_login_window(bw, host, realm, content_get_url(c));
free(host);
}
diff --git a/gtk/gtk_print.c b/gtk/gtk_print.c
index 98b43cb89..f08880157 100644
--- a/gtk/gtk_print.c
+++ b/gtk/gtk_print.c
@@ -32,6 +32,7 @@
#include <gtk/gtk.h>
#include "content/content.h"
+#include "content/hlcache.h"
#include "desktop/options.h"
#include "desktop/plotters.h"
#include "desktop/print.h"
@@ -48,7 +49,7 @@
/* Globals */
cairo_t *gtk_print_current_cr;
static struct print_settings* settings;
-struct content *content_to_print;
+hlcache_handle *content_to_print;
static GdkRectangle cliprect;
static inline void nsgtk_print_set_colour(colour c)
diff --git a/gtk/gtk_print.h b/gtk/gtk_print.h
index d2b89b92d..d44fad31f 100644
--- a/gtk/gtk_print.h
+++ b/gtk/gtk_print.h
@@ -26,9 +26,11 @@
#include <gtk/gtk.h>
+struct hlcache_handle;
+
extern cairo_t *gtk_print_current_cr;
-extern struct content *content_to_print;
+extern struct hlcache_handle *content_to_print;
/*handlers for signals from the GTK print operation*/
diff --git a/gtk/gtk_scaffolding.c b/gtk/gtk_scaffolding.c
index f8ac3daa3..381711377 100644
--- a/gtk/gtk_scaffolding.c
+++ b/gtk/gtk_scaffolding.c
@@ -30,6 +30,7 @@
#include <libxml/debugXML.h>
#include "gtk/gtk_scaffolding.h"
#include "content/content.h"
+#include "content/hlcache.h"
#include "css/utils.h"
#include "desktop/browser.h"
#include "desktop/history_core.h"
@@ -271,8 +272,10 @@ void nsgtk_window_update_back_forward(struct gtk_scaffolding *g)
nsgtk_scaffolding_set_sensitivity(g);
/* update the url bar, particularly necessary when tabbing */
- if (bw->current_content != NULL && bw->current_content->url != NULL)
- browser_window_refresh_url_bar(bw, bw->current_content->url,
+ if (bw->current_content != NULL &&
+ content_get_url(bw->current_content) != NULL)
+ browser_window_refresh_url_bar(bw,
+ content_get_url(bw->current_content),
bw->frag_id);
/* update the local history window, as well as queuing a redraw
@@ -493,8 +496,8 @@ MULTIHANDLER(savepage)
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fc), filter);
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fc), filter);
- res = url_nice(gui_window_get_browser_window(
- g->top_level)->current_content->url, &path, false);
+ res = url_nice(content_get_url(gui_window_get_browser_window(
+ g->top_level)->current_content), &path, false);
if (res != URL_FUNC_OK) {
path = strdup(messages_get("SaveText"));
if (path == NULL) {
@@ -549,7 +552,7 @@ MULTIHANDLER(pdf)
LOG(("Print preview (generating PDF) started."));
- res = url_nice(bw->current_content->url, &url_name, true);
+ res = url_nice(content_get_url(bw->current_content), &url_name, true);
if (res != URL_FUNC_OK) {
warn_user(messages_get(res == URL_FUNC_NOMEM ? "NoMemory"
: "URIError"), 0);
@@ -622,8 +625,8 @@ MULTIHANDLER(plaintext)
char *filename;
url_func_result res;
- res = url_nice(gui_window_get_browser_window(
- g->top_level)->current_content->url, &filename, false);
+ res = url_nice(content_get_url(gui_window_get_browser_window(
+ g->top_level)->current_content), &filename, false);
if (res != URL_FUNC_OK) {
filename = strdup(messages_get("SaveText"));
if (filename == NULL) {
@@ -710,7 +713,7 @@ MULTIHANDLER(print)
G_CALLBACK(gtk_print_signal_draw_page), NULL);
g_signal_connect(print_op, "end_print",
G_CALLBACK(gtk_print_signal_end_print), settings);
- if (bw->current_content->type != CONTENT_TEXTPLAIN)
+ if (content_get_type(bw->current_content) != CONTENT_TEXTPLAIN)
res = gtk_print_operation_run(print_op,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
g->window,
@@ -762,7 +765,7 @@ MENUHANDLER(savelink)
return FALSE;
browser_window_download(bw, current_menu_link_box->href,
- bw->current_content->url);
+ content_get_url(bw->current_content));
return TRUE;
}
@@ -1125,11 +1128,11 @@ MULTIHANDLER(saveboxtree)
struct browser_window *bw;
bw = gui_window_get_browser_window(g->top_level);
- if (bw->current_content &&
- bw->current_content->type ==
+ if (bw->current_content &&
+ content_get_type(bw->current_content) ==
CONTENT_HTML) {
box_dump(fh,
- bw->current_content->data.html.layout,
+ html_get_box_tree(bw->current_content),
0);
}
@@ -1174,12 +1177,11 @@ MULTIHANDLER(savedomtree)
struct browser_window *bw;
bw = gui_window_get_browser_window(g->top_level);
- if (bw->current_content &&
- bw->current_content->type ==
+ if (bw->current_content &&
+ content_get_type(bw->current_content) ==
CONTENT_HTML) {
xmlDebugDumpDocument(fh,
- bw->current_content->
- data.html.document);
+ html_get_document(bw->current_content));
}
fclose(fh);
@@ -1871,80 +1873,93 @@ void gui_window_stop_throbber(struct gui_window* _g)
/**
* set favicon
*/
-void gui_window_set_icon(struct gui_window *_g, struct content *icon)
+void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon)
{
struct gtk_scaffolding *g = nsgtk_get_scaffold(_g);
- GtkImage *iconImage = NULL;
- if (g->icoFav != NULL)
- g_object_unref(g->icoFav);
+ struct bitmap *icon_bitmap;
+ GtkImage *iconImage;
+
+ if (icon == NULL)
+ return;
+
#ifdef WITH_BMP
- if ((icon != NULL) && (icon->type == CONTENT_ICO)) {
+ if (content_get_type(icon) == CONTENT_ICO)
nsico_set_bitmap_from_size(icon, 16, 16);
- }
#endif
- if ((icon != NULL) && (icon->bitmap != NULL)) {
- GdkPixbuf *pb = gtk_bitmap_get_primary(icon->bitmap);
- if ((pb != NULL) && (gdk_pixbuf_get_width(pb) > 0) &&
- (gdk_pixbuf_get_height(pb) > 0)) {
- pb = gdk_pixbuf_scale_simple(pb, 16, 16,
- GDK_INTERP_HYPER);
- iconImage = GTK_IMAGE(
- gtk_image_new_from_pixbuf(pb));
- } else {
- iconImage = NULL;
- }
- }
- if (iconImage == NULL) {
- char imagepath[strlen(res_dir_location) + SLEN("favicon.png")
- + 1];
+
+ icon_bitmap = content_get_bitmap(icon);
+ if (icon_bitmap == NULL)
+ return;
+
+ GdkPixbuf *pb = gtk_bitmap_get_primary(icon_bitmap);
+ if (pb != NULL && gdk_pixbuf_get_width(pb) > 0 &&
+ gdk_pixbuf_get_height(pb) > 0) {
+ pb = gdk_pixbuf_scale_simple(pb, 16, 16, GDK_INTERP_HYPER);
+ iconImage = GTK_IMAGE(gtk_image_new_from_pixbuf(pb));
+ } else {
+ /** \todo Does pb need cleaning up? */
+ char imagepath[strlen(res_dir_location) +
+ SLEN("favicon.png") + 1];
sprintf(imagepath, "%sfavicon.png", res_dir_location);
iconImage = GTK_IMAGE(gtk_image_new_from_file(imagepath));
}
+
+ if (iconImage == NULL)
+ return;
+
+ if (g->icoFav != NULL)
+ g_object_unref(g->icoFav);
g->icoFav = iconImage;
- sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(g->url_bar),
+
+ sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(g->url_bar),
SEXY_ICON_ENTRY_PRIMARY, GTK_IMAGE(g->icoFav));
gtk_widget_show_all(GTK_WIDGET(g->buttons[URL_BAR_ITEM]->button));
}
-void gui_window_set_search_ico(struct content *ico)
+void gui_window_set_search_ico(hlcache_handle *ico)
{
- GdkPixbuf *pbico = NULL;
- GtkImage *searchico = NULL;
+ GdkPixbuf *pbico;
+ GtkImage *searchico;
+ struct bitmap *ico_bitmap;
nsgtk_scaffolding *current;
- if (ico == NULL)
- ico = search_web_ico();
+
+ if (ico == NULL && (ico = search_web_ico()) == NULL)
+ return;
#ifdef WITH_BMP
- if ((ico != NULL) && (ico->type == CONTENT_ICO)) {
+ if (content_get_type(ico) == CONTENT_ICO)
nsico_set_bitmap_from_size(ico, 20, 20);
- }
#endif
- if ((ico != NULL) && (ico->bitmap != NULL)) {
- pbico = gtk_bitmap_get_primary(ico->bitmap);
- if ((pbico != NULL) && (gdk_pixbuf_get_width(pbico) > 0) &&
- (gdk_pixbuf_get_height(pbico) > 0)) {
- pbico = gdk_pixbuf_scale_simple(pbico, 20, 20,
- GDK_INTERP_HYPER);
- current = scaf_list;
- searchico = GTK_IMAGE(
- gtk_image_new_from_pixbuf(pbico));
- } else {
- searchico = NULL;
- }
+ ico_bitmap = content_get_bitmap(ico);
+ if (ico_bitmap == NULL)
+ return;
+
+ pbico = gtk_bitmap_get_primary(ico_bitmap);
+ if (pbico != NULL && gdk_pixbuf_get_width(pbico) > 0 &&
+ gdk_pixbuf_get_height(pbico) > 0) {
+ pbico = gdk_pixbuf_scale_simple(pbico, 20, 20,
+ GDK_INTERP_HYPER);
+ searchico = GTK_IMAGE(gtk_image_new_from_pixbuf(pbico));
+ } else {
+ /** \todo Does pbico need cleaning up? */
+ return;
}
- /* add ico to toolbar */
- current = scaf_list;
- while (current) {
+
+ /* add ico to each window's toolbar */
+ for (current = scaf_list; current != NULL; current = current->next) {
if (searchico != NULL) {
+ /** \todo Are we leaking webSearchIco here? */
current->webSearchIco = searchico;
sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(
current->webSearchEntry),
SEXY_ICON_ENTRY_PRIMARY,
current->webSearchIco);
}
- searchico = GTK_IMAGE(gtk_image_new_from_pixbuf(pbico));
- current = current->next;
+ if (pbico != NULL)
+ searchico = GTK_IMAGE(gtk_image_new_from_pixbuf(pbico));
+ else
+ searchico = NULL;
}
}
@@ -2117,33 +2132,26 @@ void nsgtk_scaffolding_set_top_level (struct gui_window *gw)
nsgtk_get_scaffold(gw)->top_level = gw;
struct browser_window *bw = gui_window_get_browser_window(gw);
+ assert(bw != NULL);
+
/* Synchronise the history (will also update the URL bar) */
nsgtk_window_update_back_forward(nsgtk_get_scaffold(gw));
+
/* clear effects of potential searches */
- if ((bw != NULL) && (bw->search_context != NULL))
+ if (bw->search_context != NULL)
search_destroy_context(bw->search_context);
+
nsgtk_search_set_forward_state(true, bw);
nsgtk_search_set_back_state(true, bw);
/* Ensure the window's title bar as well as favicon are updated */
- if (gui_window_get_browser_window(gw) != NULL &&
- gui_window_get_browser_window(gw)->current_content
- != NULL) {
- if (gui_window_get_browser_window(gw)->current_content->title
- != NULL) {
- gui_window_set_title(gw,
- gui_window_get_browser_window(gw)->
- current_content->title);
- } else {
- gui_window_set_title(gw,
- gui_window_get_browser_window(gw)->
- current_content->url);
- }
- if (gui_window_get_browser_window(gw)->current_content->type
- == CONTENT_HTML)
+ if (bw->current_content != NULL) {
+ gui_window_set_title(gw,
+ content_get_title(bw->current_content));
+
+ if (content_get_type(bw->current_content) == CONTENT_HTML)
gui_window_set_icon(gw,
- gui_window_get_browser_window(gw)->
- current_content->data.html.favicon);
+ html_get_favicon(bw->current_content));
}
}
@@ -2287,7 +2295,8 @@ static guint nsgtk_scaffolding_update_link_operations_sensitivity(
struct browser_window *bw = gui_window_get_browser_window(g->top_level);
current_menu_link_box = NULL;
- if (bw->current_content && bw->current_content->type == CONTENT_HTML) {
+ if (bw->current_content &&
+ content_get_type(bw->current_content) == CONTENT_HTML) {
current_menu_link_box = box_href_at_point(bw->current_content,
x, y);
}
diff --git a/gtk/gtk_search.c b/gtk/gtk_search.c
index bb5d0138c..30075be02 100644
--- a/gtk/gtk_search.c
+++ b/gtk/gtk_search.c
@@ -28,6 +28,7 @@
#include "gtk/gtk_window.h"
#include "utils/config.h"
#include "content/content.h"
+#include "content/hlcache.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
#include "desktop/search.h"
@@ -99,7 +100,7 @@ gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data)
void nsgtk_search_init(struct gtk_scaffolding *g)
{
- struct content *c;
+ hlcache_handle *c;
assert(gui_window_get_browser_window(nsgtk_scaffolding_top_level(g))
!= NULL);
@@ -107,7 +108,8 @@ void nsgtk_search_init(struct gtk_scaffolding *g)
c = gui_window_get_browser_window(nsgtk_scaffolding_top_level(g))->
current_content;
- if ((!c) || (c->type != CONTENT_HTML && c->type != CONTENT_TEXTPLAIN))
+ if ((!c) || (content_get_type(c) != CONTENT_HTML &&
+ content_get_type(c) != CONTENT_TEXTPLAIN))
return;
}
diff --git a/gtk/gtk_theme.c b/gtk/gtk_theme.c
index 146d9f158..1995a3774 100644
--- a/gtk/gtk_theme.c
+++ b/gtk/gtk_theme.c
@@ -22,6 +22,7 @@
#include <unistd.h>
#include "content/content.h"
#include "content/content_type.h"
+#include "content/hlcache.h"
#include "gtk/gtk_gui.h"
#include "gtk/gtk_scaffolding.h"
#include "gtk/gtk_menu.h"
@@ -62,10 +63,10 @@ static void nsgtk_theme_cache_searchimage(nsgtk_search_buttons i,
const char *filename, const char *path);
#ifdef WITH_THEME_INSTALL
-static struct content *theme_install_content = NULL;
+static hlcache_handle *theme_install_content = NULL;
-static void theme_install_callback(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data);
+static void theme_install_callback(hlcache_handle *c, content_msg msg,
+ union content_msg_data data, void *pw);
static bool theme_install_read(const char *data, unsigned long len);
#endif
@@ -674,14 +675,14 @@ GtkImage *nsgtk_theme_image_default(nsgtk_toolbar_button i, GtkIconSize s)
/**
* when CONTENT_THEME needs handling call this function
*/
-void theme_install_start(struct content *c)
+void theme_install_start(hlcache_handle *c)
{
assert(c);
- assert(c->type == CONTENT_THEME);
+ assert(content_get_type(c) == CONTENT_THEME);
/* stop theme sitting in memory cache */
- c->fresh = false;
- if (!content_add_user(c, theme_install_callback, 0, 0)) {
+ content_invalidate_reuse_data(c);
+ if (!content_add_user(c, theme_install_callback, NULL)) {
warn_user("NoMemory", 0);
return;
}
@@ -692,17 +693,25 @@ void theme_install_start(struct content *c)
* Callback for fetchcache() for theme install fetches.
*/
-void theme_install_callback(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data)
+void theme_install_callback(hlcache_handle *c, content_msg msg,
+ union content_msg_data data, void *pw)
{
switch (msg) {
case CONTENT_MSG_READY:
break;
case CONTENT_MSG_DONE:
+ {
+ const char *source_data;
+ unsigned long source_size;
+
theme_install_content = c;
- if (!theme_install_read(c->source_data, c->source_size))
+
+ source_data = content_get_source_data(c, &source_size);
+
+ if (!theme_install_read(source_data, source_size))
warn_user("ThemeInvalid", 0);
+ }
break;
case CONTENT_MSG_ERROR:
diff --git a/gtk/gtk_thumbnail.c b/gtk/gtk_thumbnail.c
index bbf7c4dd2..ec538da36 100644
--- a/gtk/gtk_thumbnail.c
+++ b/gtk/gtk_thumbnail.c
@@ -27,6 +27,7 @@
#include <assert.h>
#include <gtk/gtk.h>
#include "content/content.h"
+#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/plotters.h"
#include "desktop/browser.h"
@@ -45,7 +46,7 @@
* \param bitmap the bitmap to draw to
* \param url the URL the thumnail belongs to, or NULL
*/
-bool thumbnail_create(struct content *content, struct bitmap *bitmap,
+bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
const char *url)
{
GdkPixbuf *pixbuf;
@@ -59,8 +60,8 @@ bool thumbnail_create(struct content *content, struct bitmap *bitmap,
assert(content);
assert(bitmap);
- cwidth = min(content->width, 1024);
- cheight = min(content->height, 768);
+ cwidth = min(content_get_width(content), 1024);
+ cheight = min(content_get_height(content), 768);
pixbuf = gtk_bitmap_get_primary(bitmap);
width = gdk_pixbuf_get_width(pixbuf);
@@ -68,7 +69,8 @@ bool thumbnail_create(struct content *content, struct bitmap *bitmap,
depth = (gdk_screen_get_system_visual(gdk_screen_get_default()))->depth;
LOG(("Trying to create a thumbnail pixmap for a content of %dx%d@%d",
- content->width, content->width, depth));
+ content_get_width(content), content_get_height(content),
+ depth));
pixmap = gdk_pixmap_new(NULL, cwidth, cwidth, depth);
@@ -87,7 +89,8 @@ bool thumbnail_create(struct content *content, struct bitmap *bitmap,
/* set the plotting functions up */
plot = nsgtk_plotters;
- nsgtk_plot_set_scale((double) cwidth / (double) content->width);
+ nsgtk_plot_set_scale((double) cwidth /
+ (double) content_get_width(content));
/* set to plot to pixmap */
current_drawable = pixmap;
@@ -98,8 +101,10 @@ bool thumbnail_create(struct content *content, struct bitmap *bitmap,
plot.rectangle(0, 0, cwidth, cwidth, plot_style_fill_white);
/* render the content */
- content_redraw(content, 0, 0, content->width, content->width,
- 0, 0, content->width, content->width, 1.0, 0xFFFFFF);
+ content_redraw(content, 0, 0, content_get_width(content),
+ content_get_width(content),
+ 0, 0, content_get_width(content),
+ content_get_width(content), 1.0, 0xFFFFFF);
/* resample the large plot down to the size of our thumbnail */
big = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, 0,
diff --git a/gtk/gtk_toolbar.c b/gtk/gtk_toolbar.c
index d3a5b52a1..b63163c90 100644
--- a/gtk/gtk_toolbar.c
+++ b/gtk/gtk_toolbar.c
@@ -412,15 +412,16 @@ void nsgtk_toolbar_close(nsgtk_scaffolding *g)
NSGTK_WINDOW_SIGNAL_REDRAW));
if ((gui_window_get_browser_window(nsgtk_scaffolding_top_level(
list))->current_content != NULL) &&
- (gui_window_get_browser_window(
+ (content_get_url(gui_window_get_browser_window(
nsgtk_scaffolding_top_level(list))->
- current_content->url != NULL))
+ current_content) != NULL))
browser_window_refresh_url_bar(
gui_window_get_browser_window(
nsgtk_scaffolding_top_level(list)),
+ content_get_url(
gui_window_get_browser_window(
nsgtk_scaffolding_top_level(list))->
- current_content->url,
+ current_content),
gui_window_get_browser_window(
nsgtk_scaffolding_top_level(list))->
frag_id);
diff --git a/gtk/gtk_window.c b/gtk/gtk_window.c
index 54e9c16a1..29ce2f431 100644
--- a/gtk/gtk_window.c
+++ b/gtk/gtk_window.c
@@ -19,6 +19,7 @@
#include <inttypes.h>
#include <string.h>
+#include "content/hlcache.h"
#include "gtk/gtk_window.h"
#include "desktop/browser.h"
#include "desktop/options.h"
@@ -144,7 +145,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct gui_window *g; /**< what we're creating to return */
GtkPolicyType scrollpolicy;
- g = malloc(sizeof(*g));
+ g = calloc(1, sizeof(*g));
if (!g) {
warn_user("NoMemory", 0);
return 0;
@@ -349,7 +350,7 @@ gboolean nsgtk_window_expose_event(GtkWidget *widget,
GdkEventExpose *event, gpointer data)
{
struct gui_window *g = data;
- struct content *c;
+ hlcache_handle *c;
float scale = g->bw->scale;
assert(g);
@@ -366,7 +367,7 @@ gboolean nsgtk_window_expose_event(GtkWidget *widget,
return FALSE;
/* HTML rendering handles scale itself */
- if (c->type == CONTENT_HTML)
+ if (content_get_type(c) == CONTENT_HTML)
scale = 1;
current_widget = (GtkWidget *)g->drawing_area;
@@ -712,7 +713,7 @@ void gui_window_redraw_window(struct gui_window *g)
void gui_window_update_box(struct gui_window *g,
const union content_msg_data *data)
{
- struct content *c = g->bw->current_content;
+ hlcache_handle *c = g->bw->current_content;
if (c == NULL)
return;
@@ -788,8 +789,8 @@ void gui_window_update_extent(struct gui_window *g)
return;
gtk_widget_set_size_request(GTK_WIDGET(g->drawing_area),
- g->bw->current_content->width * g->bw->scale,
- g->bw->current_content->height * g->bw->scale);
+ content_get_width(g->bw->current_content) * g->bw->scale,
+ content_get_height(g->bw->current_content) * g->bw->scale);
gtk_widget_set_size_request(GTK_WIDGET(g->viewport), 0, 0);
@@ -958,7 +959,7 @@ bool gui_window_box_scroll_start(struct gui_window *g,
return true;
}
-void gui_drag_save_object(gui_save_type type, struct content *c,
+void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *g)
{