]> git.street.me.uk Git - andy/viking.git/blobdiff - src/thumbnails.c
Add Refresh to consider reloading a Mapnik Rendering configuration.
[andy/viking.git] / src / thumbnails.c
index 8b48dce6a21cfcf8d9aee19154b623f0d5b26eed..40914049a571bbe76ac5d31f956d4f63d92a4d3a 100644 (file)
@@ -55,7 +55,6 @@
 
 #undef MIN /* quit yer whining, gcc */
 #undef MAX
 
 #undef MIN /* quit yer whining, gcc */
 #undef MAX
-#include <sys/param.h> /* for realpath() */
 #ifndef MAX
 /* We need MAX macro and some system does not offer it */
 #define MAX(a,b) (((a)>(b))?(a):(b))
 #ifndef MAX
 /* We need MAX macro and some system does not offer it */
 #define MAX(a,b) (((a)>(b))?(a):(b))
@@ -66,8 +65,6 @@
 #ifdef WINDOWS
 #define THUMB_DIR "\\THUMBNAILS\\" /* viking maps default viking\maps */
 #define THUMB_SUB_DIR "normal\\"
 #ifdef WINDOWS
 #define THUMB_DIR "\\THUMBNAILS\\" /* viking maps default viking\maps */
 #define THUMB_SUB_DIR "normal\\"
-#define realpath(X,Y) _fullpath(Y,X,MAX_PATH)
-
 #else
 #define THUMB_DIR "/.thumbnails/"
 #define THUMB_SUB_DIR "normal/"
 #else
 #define THUMB_DIR "/.thumbnails/"
 #define THUMB_SUB_DIR "normal/"
 
 #define PIXMAP_THUMB_SIZE  128
 
 
 #define PIXMAP_THUMB_SIZE  128
 
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
-#endif
-
 static char *md5_hash(const char *message);
 static char *md5_hash(const char *message);
-static char *pathdup(const char *path);
 static GdkPixbuf *save_thumbnail(const char *pathname, GdkPixbuf *full);
 static GdkPixbuf *child_create_thumbnail(const gchar *path);
 
 static GdkPixbuf *save_thumbnail(const char *pathname, GdkPixbuf *full);
 static GdkPixbuf *child_create_thumbnail(const gchar *path);
 
@@ -122,7 +114,7 @@ GdkPixbuf *a_thumbnails_scale_pixbuf(GdkPixbuf *src, int max_w, int max_h)
 
        if (w <= max_w && h <= max_h)
        {
 
        if (w <= max_w && h <= max_h)
        {
-               gdk_pixbuf_ref(src);
+               g_object_ref ( G_OBJECT ( src ) );
                return src;
        }
        else
                return src;
        }
        else
@@ -155,7 +147,7 @@ static GdkPixbuf *child_create_thumbnail(const gchar *path)
        if (image)
         {
                GdkPixbuf *thumb = save_thumbnail(path, image);
        if (image)
         {
                GdkPixbuf *thumb = save_thumbnail(path, image);
-               gdk_pixbuf_unref ( image );
+               g_object_unref ( G_OBJECT ( image ) );
                return thumb;
        }
 
                return thumb;
        }
 
@@ -190,7 +182,7 @@ static GdkPixbuf *save_thumbnail(const char *pathname, GdkPixbuf *full)
        ssize = g_strdup_printf(ST_SIZE_FMT, info.st_size);
        smtime = g_strdup_printf("%ld", (long) info.st_mtime);
 
        ssize = g_strdup_printf(ST_SIZE_FMT, info.st_size);
        smtime = g_strdup_printf("%ld", (long) info.st_mtime);
 
-       path = pathdup(pathname);
+       path = file_realpath_dup(pathname);
        uri = g_strconcat("file://", path, NULL);
        md5 = md5_hash(uri);
        g_free(path);
        uri = g_strconcat("file://", path, NULL);
        md5 = md5_hash(uri);
        g_free(path);
@@ -258,7 +250,7 @@ GdkPixbuf *a_thumbnails_get(const gchar *pathname)
        const char *ssize, *smtime;
        struct stat info;
 
        const char *ssize, *smtime;
        struct stat info;
 
-       path = pathdup(pathname);
+       path = file_realpath_dup(pathname);
        uri = g_strconcat("file://", path, NULL);
        md5 = md5_hash(uri);
        g_free(uri);
        uri = g_strconcat("file://", path, NULL);
        md5 = md5_hash(uri);
        g_free(uri);
@@ -289,7 +281,7 @@ GdkPixbuf *a_thumbnails_get(const gchar *pathname)
        goto out;
 err:
        if (thumb)
        goto out;
 err:
        if (thumb)
-               gdk_pixbuf_unref(thumb);
+               g_object_unref ( G_OBJECT ( thumb ) );
        thumb = NULL;
 out:
        g_free(path);
        thumb = NULL;
 out:
        g_free(path);
@@ -297,20 +289,6 @@ out:
        return thumb;
 }
 
        return thumb;
 }
 
-/* pathdup() stuff */
-
-static char *pathdup(const char *path)
-{
-       char real[MAXPATHLEN];
-
-       g_return_val_if_fail(path != NULL, NULL);
-
-       if (realpath(path, real))
-               return g_strdup(real);
-
-       return g_strdup(path);
-}
-
 /*
  * This code implements the MD5 message-digest algorithm.
  * The algorithm is due to Ron Rivest. The original code was
 /*
  * This code implements the MD5 message-digest algorithm.
  * The algorithm is due to Ron Rivest. The original code was