]> www.fi.muni.cz Git - evince.git/commitdiff
add -s option for thumbnail size.
authorFernando Herrera <fherrera@onirica.com>
Tue, 8 Mar 2005 09:58:52 +0000 (09:58 +0000)
committerFernando Herrera de las Heras <fherrera@src.gnome.org>
Tue, 8 Mar 2005 09:58:52 +0000 (09:58 +0000)
2005-03-08  Fernando Herrera  <fherrera@onirica.com>

        * thumbnailer/evince-thumbnailer.schemas:
        * thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get),
        (main): add -s option for thumbnail size.

ChangeLog
thumbnailer/evince-thumbnailer.c
thumbnailer/evince-thumbnailer.schemas

index ca87fa24d64a9254938d29394b6b9b95dc3ee053..d528cc4cb36a941019bbab996a3a9881a317d2ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-03-08  Fernando Herrera  <fherrera@onirica.com>
+
+       * thumbnailer/evince-thumbnailer.schemas:
+       * thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get),
+       (main): add -s option for thumbnail size.
+
 2005-03-07  Christian Persch  <chpe@cvs.gnome.org>
 
        * configure.ac:
index d7db2654a864122592fb232609d94b9ebef2329f..6794a692ef406f8a53149776d46c6935edbc00b8 100644 (file)
@@ -31,7 +31,7 @@
 #define THUMBNAIL_SIZE 128
 
 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;
@@ -57,7 +57,7 @@ evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail)
        }
 
        pixbuf = ev_document_thumbnails_get_thumbnail
-                       (EV_DOCUMENT_THUMBNAILS (document), 0, THUMBNAIL_SIZE, FALSE);
+                       (EV_DOCUMENT_THUMBNAILS (document), 0, size, FALSE);
        
        if (pixbuf != NULL) {
                GdkPixbuf *pdflogo;
@@ -97,19 +97,36 @@ int
 main (int argc, char *argv[])
 {
        int res;
+       char *input, *output;
+       int size;
        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 ();
 
-       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 {
index 2cc5f28ea04a1db835b1be4d8c29b50cc5c88c9e..cf82b9d7ed5bc356456dcd6fcdeb0ab02c7ad1f1 100644 (file)
@@ -19,7 +19,7 @@
             <applyto>/desktop/gnome/thumbnailers/application@pdf/command</applyto>
             <owner>evince</owner>
             <type>string</type>
-            <default>evince-thumbnailer %u %o</default>
+            <default>evince-thumbnailer -s %s %u %o</default>
             <locale name="C">
                 <short></short>
                 <long></long>