]> www.fi.muni.cz Git - evince.git/blobdiff - thumbnailer/evince-thumbnailer.c
Translation updated by Tino Meinen.
[evince.git] / thumbnailer / evince-thumbnailer.c
index 505f5f353007c0b3c8a504f5c242724bcb3f69fe..d4972474556f63748d4702d4d3458974c0862738 100644 (file)
@@ -1,3 +1,21 @@
+/*
+   Copyright (C) 2005 Fernando Herrera <fherrera@onirica.com>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
 #include <pdf-document.h>
 
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
 #include <pdf-document.h>
 
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
 
 #include <string.h>
 
 
 #include <string.h>
 
+#define THUMBNAIL_SIZE 128
+
 static gboolean
 static gboolean
-evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail)
+evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail, int size)
 {
        EvDocument *document = NULL;
        char *mime_type;
 {
        EvDocument *document = NULL;
        char *mime_type;
@@ -37,7 +57,7 @@ evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail)
        }
 
        pixbuf = ev_document_thumbnails_get_thumbnail
        }
 
        pixbuf = ev_document_thumbnails_get_thumbnail
-                       (EV_DOCUMENT_THUMBNAILS (document), 1, 100);
+                       (EV_DOCUMENT_THUMBNAILS (document), 1, size, FALSE);
        
        if (pixbuf != NULL) {
                GdkPixbuf *pdflogo;
        
        if (pixbuf != NULL) {
                GdkPixbuf *pdflogo;
@@ -77,19 +97,36 @@ int
 main (int argc, char *argv[])
 {
        int res;
 main (int argc, char *argv[])
 {
        int res;
+       char *input, *output;
+       int size;
        char *uri;
 
        char *uri;
 
-       if (argc != 3) {
-               g_print ("%s: thumbnailer for Nautilus\n", argv[0]);
-               g_print ("usage: %s <input-filename> <output-filename>\n", argv[0]);
+       if (argc <= 2 || argc > 5 || strcmp (argv[1], "-h") == 0 ||
+           strcmp (argv[1], "--help") == 0) {
+               g_print ("Usage: %s [-s <size>] <input> <output>\n", argv[0]);
                return -1;
        }
 
        res = gnome_vfs_init ();
 
                return -1;
        }
 
        res = gnome_vfs_init ();
 
-       uri = gnome_vfs_make_uri_from_shell_arg (argv[1]);
+       if (!strcmp (argv[1], "-s")) {
+               input = argv[3];
+               output = argv[4];
+               size = g_strtod (argv[2], NULL);
+       } else {
+               input = argv[1];
+               output = argv[2];
+               size = THUMBNAIL_SIZE;
+       }
+
+       if (size < 40) {
+               g_print ("Size cannot be smaller than 40 pixels\n");
+               return -1;
+       }
+
+       uri = gnome_vfs_make_uri_from_shell_arg (input);
 
 
-       if (evince_thumbnail_pngenc_get (uri, argv[2])) {
+       if (evince_thumbnail_pngenc_get (uri, output, size)) {
                g_free (uri);
                return 0;
        } else {
                g_free (uri);
                return 0;
        } else {