diff options
author | Thomas White <taw@bitwiz.org.uk> | 2013-08-27 23:00:18 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2013-08-27 23:00:18 +0200 |
commit | 326ca976b24850ed887f967b521bafac77d9223a (patch) | |
tree | 6a188f48621497aee39c6f6cf08af8f14e0bff3f /src | |
parent | 3f9b053d662ec26564765b7984443a52b609163b (diff) |
Try a global "image repository" folder
Diffstat (limited to 'src')
-rw-r--r-- | src/imagestore.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/imagestore.c b/src/imagestore.c index 7712e65..a6da607 100644 --- a/src/imagestore.c +++ b/src/imagestore.c @@ -120,22 +120,34 @@ static GdkPixbuf *try_all_locations(const char *filename, int w, ImageStore *is) GError *error = NULL; GdkPixbuf *t; char *tmp; + const char *image_folder = "/home/taw/Documents/Slides"; /* FIXME ! */ /* Try the filename as is */ t = gdk_pixbuf_new_from_file_at_size(filename, w, -1, &error); if ( t != NULL ) return t; - if ( is->dname == NULL ) return NULL; + /* Try the file prefixed with the directory the presentation is in */ + if ( is->dname != NULL ) { - /* Try the file prefixed with the directory the presentation - * is in */ + error = NULL; + tmp = malloc(strlen(filename) + strlen(is->dname) + 2); + if ( tmp == NULL ) return NULL; + strcpy(tmp, is->dname); + strcat(tmp, "/"); + strcat(tmp, filename); + t = gdk_pixbuf_new_from_file_at_size(tmp, w, -1, &error); + free(tmp); + if ( t != NULL ) return t; + + } + + /* Try prefixed with image pathname */ error = NULL; - tmp = malloc(strlen(filename) + strlen(is->dname) + 2); + tmp = malloc(strlen(filename) + strlen(image_folder) + 2); if ( tmp == NULL ) return NULL; - strcpy(tmp, is->dname); + strcpy(tmp, image_folder); strcat(tmp, "/"); strcat(tmp, filename); - printf("Trying '%s'\n", tmp); t = gdk_pixbuf_new_from_file_at_size(tmp, w, -1, &error); free(tmp); if ( t != NULL ) return t; |