diff options
author | Vincent Sanders <vince@kyllikki.org> | 2015-06-13 11:31:23 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2015-06-17 21:35:40 +0100 |
commit | 8ef292b9caf5cae2197493a87480723138f10344 (patch) | |
tree | fa39583104ab806b81f382eb85bc9f5a05331dfd /gtk/viewdata.c | |
parent | 16fbb97dbb1688fd9b6f19546792b4173bc30bf1 (diff) | |
download | netsurf-8ef292b9caf5cae2197493a87480723138f10344.tar.gz netsurf-8ef292b9caf5cae2197493a87480723138f10344.tar.bz2 |
Change GTK UI builder handling to use resource API
GTK UI builder resources have till now been exclusively stored on disc
requiring netsurf to ship numerous additional resource files. This
requires going to disc every time a UI action is performed which can
become a lot of unwanted file handling.
GLib/GTK has moved towards GResource handling for such resources
instead. It now seems that migrating to this style of usage is
expected and indeed the only portable way to include pixbufs.
This introduces an API to hide the various implementation details of
how resources are handled from the rest of the codebase.
Diffstat (limited to 'gtk/viewdata.c')
-rw-r--r-- | gtk/viewdata.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/gtk/viewdata.c b/gtk/viewdata.c index 94dc5c573..7cd640fa2 100644 --- a/gtk/viewdata.c +++ b/gtk/viewdata.c @@ -45,7 +45,7 @@ #include "gtk/about.h" #include "gtk/fetch.h" #include "gtk/compat.h" -#include "gtk/gui.h" +#include "gtk/resources.h" #include "gtk/viewdata.h" struct nsgtk_viewdata_ctx { @@ -351,7 +351,6 @@ window_init(const char *title, char *ndata, size_t ndata_len) { - GError* error = NULL; GtkWindow *window; GtkWidget *cutbutton; GtkWidget *pastebutton; @@ -361,30 +360,24 @@ window_init(const char *title, PangoFontDescription *fontdesc; GtkTextBuffer *tb; struct nsgtk_viewdata_ctx *newctx; + nserror res; newctx = malloc(sizeof(struct nsgtk_viewdata_ctx)); if (newctx == NULL) { return NSERROR_NOMEM; } - newctx->builder = gtk_builder_new(); - if (newctx->builder == NULL) { + res = nsgtk_builder_new_from_resname("viewdata", &newctx->builder); + if (res != NSERROR_OK) { + LOG("Viewdata UI builder init failed"); free(newctx); - return NSERROR_INIT_FAILED; - } - - if (!gtk_builder_add_from_file(newctx->builder, - glade_file_location->viewdata, - &error)) { - LOG("Couldn't load builder file: %s", error->message); - g_error_free(error); - free(newctx); - return NSERROR_INIT_FAILED; + return res; } + gtk_builder_connect_signals(newctx->builder, NULL); - window = GTK_WINDOW(gtk_builder_get_object(newctx->builder, "ViewDataWindow")); - + window = GTK_WINDOW(gtk_builder_get_object(newctx->builder, + "ViewDataWindow")); if (window == NULL) { LOG("Unable to find window in builder "); |