summaryrefslogtreecommitdiff
path: root/gtk/gui.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-06-17 21:29:48 +0100
committerVincent Sanders <vince@kyllikki.org>2015-06-17 21:35:45 +0100
commite1bbe4528b479881a1912f96f3160ab6e2fbb2ec (patch)
tree4e0a38e4a50ea435f7e70e52a5ad06e3e5cc51e4 /gtk/gui.c
parente9b89f776db705ee4403a2235ec21aabab12c8f6 (diff)
downloadnetsurf-e1bbe4528b479881a1912f96f3160ab6e2fbb2ec.tar.gz
netsurf-e1bbe4528b479881a1912f96f3160ab6e2fbb2ec.tar.bz2
Add direct resources to GTK
This adds API to obtain direct pointers to arrays of data from compiled in resources. Additionally it hooks this up to provide data for the resourece scheme handler.
Diffstat (limited to 'gtk/gui.c')
-rw-r--r--gtk/gui.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/gtk/gui.c b/gtk/gui.c
index 1df7bfc56..4986f425f 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -99,14 +99,15 @@ static void die(const char * const error)
exit(EXIT_FAILURE);
}
-/** Create an array of valid paths to search for resources.
+/**
+ * Create an array of valid paths to search for resources.
*
* The idea is that all the complex path computation to find resources
* is performed here, once, rather than every time a resource is
* searched for.
*/
static char **
-nsgtk_init_resource(const char *resource_path)
+nsgtk_init_resource_path(const char *resource_path)
{
const gchar * const *langv;
char **pathv; /* resource path string vector */
@@ -234,13 +235,6 @@ static nserror nsgtk_init(int argc, char** argv, char **respath)
strlen(languages_file_location) - 9);
LOG("Using '%s' for resource path", res_dir_location);
- /* initialise the gtk resource handling */
- error = nsgtk_init_resources(respath);
- if (error != NSERROR_OK) {
- LOG("Unable to initialise resources");
- return error;
- }
-
error = nsgtk_builder_new_from_resname("warning", &warning_builder);
if (error != NSERROR_OK) {
LOG("Unable to initialise warning dialog");
@@ -268,12 +262,15 @@ static nserror nsgtk_init(int argc, char** argv, char **respath)
/* Default favicon */
error = nsgdk_pixbuf_new_from_resname("favicon.png", &favicon_pixbuf);
if (error != NSERROR_OK) {
- favicon_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 16,16);
+ favicon_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
+ false, 8, 16,16);
}
/* Toolbar inicies file */
- toolbar_indices_file_location = filepath_find(respath, "toolbarIndices");
- LOG("Using '%s' as custom toolbar settings file", toolbar_indices_file_location);
+ toolbar_indices_file_location = filepath_find(respath,
+ "toolbarIndices");
+ LOG("Using '%s' as custom toolbar settings file",
+ toolbar_indices_file_location);
/* initialise throbber */
error = nsgtk_throbber_init();
@@ -1011,7 +1008,7 @@ static struct gui_browser_table nsgtk_browser_table = {
.quit = gui_quit,
.launch_url = gui_launch_url,
.cert_verify = gtk_cert_verify,
- .login = gui_401login_open,
+ .login = gui_401login_open,
.pdf_password = nsgtk_pdf_password,
};
@@ -1035,13 +1032,10 @@ int main(int argc, char** argv)
.bitmap = nsgtk_bitmap_table,
};
- ret = netsurf_register(&nsgtk_table);
- if (ret != NSERROR_OK) {
+ ret = netsurf_register(&nsgtk_table);
+ if (ret != NSERROR_OK) {
die("NetSurf operation table failed registration\n");
- }
-
- /* build the common resource path list */
- respaths = nsgtk_init_resource("${HOME}/.netsurf/:${NETSURFRES}:"GTK_RESPATH":./gtk/res");
+ }
/* Locate the correct user configuration directory path */
ret = get_config_home(&nsgtk_config_home);
@@ -1062,6 +1056,17 @@ int main(int argc, char** argv)
*/
nslog_init(nslog_stream_configure, &argc, argv);
+ /* build the common resource path list */
+ respaths = nsgtk_init_resource_path("${HOME}/.netsurf/:${NETSURFRES}:"GTK_RESPATH":./gtk/res");
+
+ /* initialise the gtk resource handling */
+ ret = nsgtk_init_resources(respaths);
+ if (ret != NSERROR_OK) {
+ fprintf(stderr, "GTK resources failed to initialise (%s)\n",
+ messages_get_errorcode(ret));
+ return 1;
+ }
+
/* Initialise user options */
ret = nsgtk_option_init(&argc, argv);
if (ret != NSERROR_OK) {