summaryrefslogtreecommitdiff
path: root/gtk/gtk_gui.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2010-03-31 13:59:57 +0000
committerVincent Sanders <vince@netsurf-browser.org>2010-03-31 13:59:57 +0000
commit95e4a737de53dc2f02a2db95b26151d9d494bc0c (patch)
treea9dcb06c696a463f824d61865fb46d6a7bfa755b /gtk/gtk_gui.c
parent9f575c590b3c304ab02707ee3378bd2e4f4c9094 (diff)
downloadnetsurf-95e4a737de53dc2f02a2db95b26151d9d494bc0c.tar.gz
netsurf-95e4a737de53dc2f02a2db95b26151d9d494bc0c.tar.bz2
rationalise the usage of the file scheme
svn path=/trunk/netsurf/; revision=10221
Diffstat (limited to 'gtk/gtk_gui.c')
-rw-r--r--gtk/gtk_gui.c137
1 files changed, 68 insertions, 69 deletions
diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c
index ba2052083..c7c535fc5 100644
--- a/gtk/gtk_gui.c
+++ b/gtk/gtk_gui.c
@@ -97,8 +97,6 @@ static struct browser_window *select_menu_bw;
static struct form_control *select_menu_control;
static void nsgtk_init_glade(void);
-static char *nsgtk_find_resource(char *buf, const char *filename,
- const char *def);
static void nsgtk_check_homedir(void);
static void *nsgtk_hubbub_realloc(void *ptr, size_t len, void *pw);
static bool nsgtk_throbber_init(int framec);
@@ -114,6 +112,71 @@ static void nsgtk_PDF_no_pass(GtkButton *w, gpointer data);
#define THROBBER_FRAMES 9
+/**
+ * Locate a shared resource file by searching known places in order.
+ *
+ * \param buf buffer to write to. must be at least PATH_MAX chars. May be NULL and routine will allocate string which must be freed by caller.
+ * \param filename file to look for
+ * \param def default to return if file not found
+ * \return buf
+ *
+ * Search order is: ~/.netsurf/, $NETSURFRES/ (where NETSURFRES is an
+ * environment variable), and finally the path specified by the define
+ * GTK_RESPATH.
+ */
+static char *
+nsgtk_find_resource(char *buf, const char *filename, const char *def)
+{
+ char *cdir = getenv("HOME");
+ char t[PATH_MAX];
+
+ if (buf == NULL) {
+ buf = malloc(PATH_MAX);
+ if (buf == NULL)
+ return NULL;
+ }
+
+ if (cdir != NULL) {
+ strcpy(t, cdir);
+ strcat(t, "/.netsurf/");
+ strcat(t, filename);
+ if (realpath(t, buf) != NULL) {
+ if (access(buf, R_OK) == 0)
+ return buf;
+ }
+ }
+
+ cdir = getenv("NETSURFRES");
+
+ if (cdir != NULL) {
+ if (realpath(cdir, buf) != NULL) {
+ strcat(buf, "/");
+ strcat(buf, filename);
+ if (access(buf, R_OK) == 0)
+ return buf;
+ }
+ }
+
+ strcpy(t, GTK_RESPATH);
+ strcat(t, filename);
+ if (realpath(t, buf) != NULL) {
+ if (access(buf, R_OK) == 0)
+ return buf;
+ }
+
+ if (def[0] == '~') {
+ snprintf(t, PATH_MAX, "%s%s", getenv("HOME"), def + 1);
+ if (realpath(t, buf) == NULL) {
+ strcpy(buf, t);
+ }
+ } else {
+ if (realpath(def, buf) == NULL) {
+ strcpy(buf, def);
+ }
+ }
+
+ return buf;
+}
/**
@@ -421,70 +484,6 @@ void gui_quit(void)
}
-/**
- * Locate a shared resource file by searching known places in order.
- *
- * \param buf buffer to write to. must be at least PATH_MAX chars. May be NULL and routine will allocate string which must be freed by caller.
- * \param filename file to look for
- * \param def default to return if file not found
- * \return buf
- *
- * Search order is: ~/.netsurf/, $NETSURFRES/ (where NETSURFRES is an
- * environment variable), and finally the path specified by the define
- * GTK_RESPATH.
- */
-char *nsgtk_find_resource(char *buf, const char *filename, const char *def)
-{
- char *cdir = getenv("HOME");
- char t[PATH_MAX];
-
- if (buf == NULL) {
- buf = malloc(PATH_MAX);
- if (buf == NULL)
- return NULL;
- }
-
- if (cdir != NULL) {
- strcpy(t, cdir);
- strcat(t, "/.netsurf/");
- strcat(t, filename);
- if (realpath(t, buf) != NULL) {
- if (access(buf, R_OK) == 0)
- return buf;
- }
- }
-
- cdir = getenv("NETSURFRES");
-
- if (cdir != NULL) {
- if (realpath(cdir, buf) != NULL) {
- strcat(buf, "/");
- strcat(buf, filename);
- if (access(buf, R_OK) == 0)
- return buf;
- }
- }
-
- strcpy(t, GTK_RESPATH);
- strcat(t, filename);
- if (realpath(t, buf) != NULL) {
- if (access(buf, R_OK) == 0)
- return buf;
- }
-
- if (def[0] == '~') {
- snprintf(t, PATH_MAX, "%s%s", getenv("HOME"), def + 1);
- if (realpath(t, buf) == NULL) {
- strcpy(buf, t);
- }
- } else {
- if (realpath(def, buf) == NULL) {
- strcpy(buf, def);
- }
- }
-
- return buf;
-}
/**
@@ -729,9 +728,9 @@ utf8_convert_ret utf8_from_local_encoding(const char *string, size_t len,
char *path_to_url(const char *path)
{
- char *r = malloc(strlen(path) + SLEN("file://") + 1);
+ char *r = malloc(strlen(path) + FILE_SCHEME_PREFIX_LEN + 1);
- strcpy(r, "file://");
+ strcpy(r, FILE_SCHEME_PREFIX);
strcat(r, path);
return r;
@@ -740,7 +739,7 @@ char *path_to_url(const char *path)
char *url_to_path(const char *url)
{
- return strdup(url + 5);
+ return strdup(url + FILE_SCHEME_PREFIX_LEN);
}