X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=thumbnailer%2Fevince-thumbnailer.c;h=d4972474556f63748d4702d4d3458974c0862738;hb=0278ffdb57c2e17e33acb52bb5569d746246f671;hp=505f5f353007c0b3c8a504f5c242724bcb3f69fe;hpb=d60348a1b1b0f5b9967dd4677118a94d1031171a;p=evince.git diff --git a/thumbnailer/evince-thumbnailer.c b/thumbnailer/evince-thumbnailer.c index 505f5f35..d4972474 100644 --- a/thumbnailer/evince-thumbnailer.c +++ b/thumbnailer/evince-thumbnailer.c @@ -1,3 +1,21 @@ +/* + Copyright (C) 2005 Fernando Herrera + + 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 #include @@ -10,8 +28,10 @@ #include +#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; @@ -37,7 +57,7 @@ evince_thumbnail_pngenc_get (const char *uri, const char *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; @@ -77,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 {