HOWTO: Postscript/PDF/xfig thumbnails without rebuilding nautilus



Below is an example of how to add external thumbnailers via
gconf entries. I searched google for a way to do pdf thumbnails
in nautilus, but I only found patches for Nautilus itself. So
I don't think this technique is widely known and thought someone
else may find it useful.

I used perl scripts, because nautilus passes URLs for the source
filename, and I was too lazy to write shell code to decode them.

Note that these are somewhat inefficient, being perl scripts,
and they only work for local files. To install, place the 
scripts in /usr/lib/nautilus and then do:

  gconftool --install-schema-file ps-thumbnail.schema

I believe you need to restart gconfd and nautilus afterwards.

(This was done with gnome 2.2 on Debian.)


Steve
dunham lambvindaloo org

<gconfschemafile>
    <schemalist>

	<!-- application/pdf -->
        <schema>
            <key>/schemas/desktop/gnome/thumbnailers/application pdf/enable</key>
            <applyto>/desktop/gnome/thumbnailers/application pdf/enable</applyto>
            <owner>ps-thumbnail</owner>
            <type>bool</type>
            <default>true</default>
            <locale name="C">
                <short></short>
                <long></long>
            </locale>
        </schema>
        <schema>
            <key>/schemas/desktop/gnome/thumbnailers/application pdf/command</key>
            <applyto>/desktop/gnome/thumbnailers/application pdf/command</applyto>
            <owner>ps-thumbnail</owner>
            <type>string</type>
            <default>/usr/lib/nautilus/mkpsthumb %u %o</default>
            <locale name="C">
                <short></short>
                <long></long>
            </locale>
        </schema>


	<!-- application/postscript -->
        <schema>
            <key>/schemas/desktop/gnome/thumbnailers/application postscript/enable</key>
            <applyto>/desktop/gnome/thumbnailers/application postscript/enable</applyto>
            <owner>ps-thumbnail</owner>
            <type>bool</type>
            <default>true</default>
            <locale name="C">
                <short></short>
                <long></long>
            </locale>
        </schema>
        <schema>
            <key>/schemas/desktop/gnome/thumbnailers/application postscript/command</key>
            <applyto>/desktop/gnome/thumbnailers/application postscript/command</applyto>
            <owner>ps-thumbnail</owner>
            <type>string</type>
            <default>/usr/lib/nautilus/mkpsthumb %u %o</default>
            <locale name="C">
                <short></short>
                <long></long>
            </locale>
        </schema>

	<!-- image/x-xfig -->
        <schema>
            <key>/schemas/desktop/gnome/thumbnailers/image x-xfig/enable</key>
            <applyto>/desktop/gnome/thumbnailers/image x-xfig/enable</applyto>
            <owner>ps-thumbnail</owner>
            <type>bool</type>
            <default>true</default>
            <locale name="C">
                <short></short>
                <long></long>
            </locale>
        </schema>
        <schema>
            <key>/schemas/desktop/gnome/thumbnailers/image x-xfig/command</key>
            <applyto>/desktop/gnome/thumbnailers/image x-xfig/command</applyto>
            <owner>ps-thumbnail</owner>
            <type>string</type>
            <default>/usr/lib/nautilus/mkfigthumb %u %o</default>
            <locale name="C">
                <short></short>
                <long></long>
            </locale>
        </schema>


    </schemalist>
</gconfschemafile>
#!/usr/bin/perl

use strict;
use URI::URL;
open STDOUT, ">/dev/null";
my $url = new URI::URL($ARGV[0]);
system("gs", "-dNOPAUSE", "-dBATCH", "-dSAFER", "-sDEVICE=png256",
        "-sOutputFile=$ARGV[1]", "-dLastPage=1",  $url->path);
#!/usr/bin/perl

use strict;
use URI::URL;
open STDOUT, ">/dev/null";
my $url = new URI::URL($ARGV[0]);
system("fig2dev", "-L", "png", $url->path, "$ARGV[1]");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]