From 09aa3e2b90d20966010f76a7e5459f4581ef3247 Mon Sep 17 00:00:00 2001 From: Fernando Herrera Date: Tue, 8 Mar 2005 09:58:52 +0000 Subject: [PATCH] add -s option for thumbnail size. 2005-03-08 Fernando Herrera * thumbnailer/evince-thumbnailer.schemas: * thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get), (main): add -s option for thumbnail size. --- ChangeLog | 6 +++++ thumbnailer/evince-thumbnailer.c | 31 ++++++++++++++++++++------ thumbnailer/evince-thumbnailer.schemas | 2 +- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index ca87fa24..d528cc4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-03-08 Fernando Herrera + + * thumbnailer/evince-thumbnailer.schemas: + * thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get), + (main): add -s option for thumbnail size. + 2005-03-07 Christian Persch * configure.ac: diff --git a/thumbnailer/evince-thumbnailer.c b/thumbnailer/evince-thumbnailer.c index d7db2654..6794a692 100644 --- a/thumbnailer/evince-thumbnailer.c +++ b/thumbnailer/evince-thumbnailer.c @@ -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 \n", argv[0]); + if (argc <= 2 || argc > 5 || strcmp (argv[1], "-h") == 0 || + strcmp (argv[1], "--help") == 0) { + g_print ("Usage: %s [-s ] \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 { diff --git a/thumbnailer/evince-thumbnailer.schemas b/thumbnailer/evince-thumbnailer.schemas index 2cc5f28e..cf82b9d7 100644 --- a/thumbnailer/evince-thumbnailer.schemas +++ b/thumbnailer/evince-thumbnailer.schemas @@ -19,7 +19,7 @@ /desktop/gnome/thumbnailers/application@pdf/command evince string - evince-thumbnailer %u %o + evince-thumbnailer -s %s %u %o -- 2.43.5