summaryrefslogtreecommitdiff
path: root/gtk/fetch.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/fetch.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/fetch.c')
-rw-r--r--gtk/fetch.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/gtk/fetch.c b/gtk/fetch.c
index f68f203d5..0e5a37c5a 100644
--- a/gtk/fetch.c
+++ b/gtk/fetch.c
@@ -34,6 +34,7 @@
#include "desktop/gui_fetch.h"
#include "gtk/gui.h"
+#include "gtk/resources.h"
#include "gtk/fetch.h"
static struct hash_table *mime_hash = NULL;
@@ -172,13 +173,13 @@ const char *fetch_filetype(const char *unix_path)
const char *type;
int l;
- if (stat(unix_path, &statbuf) != 0) {
- /* stat failed */
- return "text/plain";
- }
+ /* stat the path to attempt to determine if the file is special */
+ if (stat(unix_path, &statbuf) == 0) {
+ /* stat suceeded so can check for directory */
- if (S_ISDIR(statbuf.st_mode)) {
- return "application/x-netsurf-directory";
+ if (S_ISDIR(statbuf.st_mode)) {
+ return "application/x-netsurf-directory";
+ }
}
l = strlen(unix_path);
@@ -230,7 +231,7 @@ const char *fetch_filetype(const char *unix_path)
}
-static nsurl *gui_get_resource_url(const char *path)
+static nsurl *nsgtk_get_resource_url(const char *path)
{
char buf[PATH_MAX];
nsurl *url = NULL;
@@ -253,7 +254,8 @@ static nsurl *gui_get_resource_url(const char *path)
static struct gui_fetch_table fetch_table = {
.filetype = fetch_filetype,
- .get_resource_url = gui_get_resource_url,
+ .get_resource_url = nsgtk_get_resource_url,
+ .get_resource_data = nsgtk_data_from_resname,
};
struct gui_fetch_table *nsgtk_fetch_table = &fetch_table;