~noskcaj/ubuntu/vivid/thunar/1.6.4

« back to all changes in this revision

Viewing changes to docs/manual/zh_TW/html/customizing-thunar.html

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2010-12-04 16:46:20 UTC
  • mto: (2.1.3 experimental) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 69.
  • Revision ID: james.westby@ubuntu.com-20101204164620-h7p4t2e9z6hfhz6l
Tags: upstream-1.1.4
Import upstream version 1.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Customizing Thunar</title><link rel="stylesheet" href="../thunar.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="Thunar &#27284;&#26696;&#32317;&#31649;"><link rel="up" href="index.html" title="Thunar &#27284;&#26696;&#32317;&#31649;"><link rel="prev" href="preferences.html" title="File Management Preferences"><link rel="next" href="advanced-topics.html" title="&#36914;&#38542;&#20839;&#23481;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Customizing Thunar</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="preferences.html">&#21069;&#19968;&#38913;</a>�</td><th width="60%" align="center">�</th><td width="20%" align="right">�<a accesskey="n" href="advanced-topics.html">&#19979;&#19968;&#38913;</a></td></tr></table><hr></div><div class="sect1" title="Customizing Thunar"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="customizing-thunar"></a>Customizing Thunar</h2></div></div></div><p>
2
 
      This chapter describes how to customize certain parts of the file manager to your own needs.
3
 
    </p><div class="sect2" title='The "Send To" Menu'><div class="titlepage"><div><div><h3 class="title"><a name="sendto"></a>The "Send To" Menu</h3></div></div></div><p>
4
 
        Thunar includes a <span class="guilabel"><strong>Send To</strong></span> menu, which provides possible targets where files and folders can
5
 
        be sent to. To access the <span class="guilabel"><strong>Send To</strong></span> menu, choose
6
 
        <span class="guimenu"><strong>File</strong></span> &#8594; <span class="guimenuitem"><strong>Send To</strong></span> from the main menu, or right-click
7
 
        on a file or folder and choose <span class="guimenuitem"><strong>Send To</strong></span>.
8
 
      </p><div class="screenshot"><div class="mediaobject"><img src="images/sendto-menu.png" alt='"Send To" Menu'></div></div><p>
9
 
        By default, the <span class="guilabel"><strong>Send To</strong></span> menu includes an entry named <span class="guilabel"><strong>Desktop (Create Link)</strong></span> for all
10
 
        files and folders, which simply creates a link on the desktop for each selected file. In addition, if the <span class="guilabel"><strong>Shortcuts
11
 
        Pane</strong></span> is active, the menu also includes an entry called <span class="guilabel"><strong>Side Pane (Create Shortcut)</strong></span> for folders,
12
 
        which allows users to add new shortcuts to the side pane. Following these entries, <strong class="application"><code>Thunar</code></strong> lists
13
 
        the removable drives currently plugged into the computer. In the screenshot above, the <span class="guilabel"><strong>Floppy Drive</strong></span>
14
 
        represents a possible target where files can be sent to. Note that the device is mounted automatically once selected from
15
 
        the <span class="guilabel"><strong>Send To</strong></span> menu, so you do not need to manually mount it.
16
 
      </p><p>
17
 
        In addition <strong class="application"><code>Thunar</code></strong> also ships the <strong class="application"><code>thunar-sendto-email</code></strong> plugin, which adds
18
 
        the entry <span class="guilabel"><strong>Mail Recipient</strong></span> to the menu, that opens the mail composer with the selected files attach to the
19
 
        new email. If the selection contains atleast one folder, the selected items are added to a ZIP archive before attaching them
20
 
        to the email. Otherwise, if the selection contains multiple files, or a single file, which is larger than 200Kib, the user will
21
 
        be prompted whether to pack the files into a ZIP archive, and send the ZIP archive.
22
 
      </p><p>
23
 
        Like most other features of <strong class="application"><code>Thunar</code></strong>, the <span class="guilabel"><strong>Send to</strong></span> menu can be easily extended
24
 
        by users and application developers with new targets, using standard <a class="ulink" href="http://freedesktop.org/wiki/Standards_2fdesktop_2dentry_2dspec" target="_top">desktop entry files</a>. These files must be
25
 
        installed into one of the <code class="filename">$XDG_DATA_DIRS/Thunar/sendto/</code> folders (see the <a class="ulink" href="http://freedesktop.org/wiki/Standards_2fbasedir_2dspec" target="_top">XDG Base Directory Specification</a> for details about the
26
 
        <code class="literal">$XDG_DATA_DIRS</code> variable).
27
 
      </p><p>
28
 
        The <code class="literal">MimeType</code> of the target <code class="filename">.desktop</code> specifies the types of files for which this action
29
 
        should be available in the <span class="guilabel"><strong>Send To</strong></span> menu. For example, say you want to add entry for a <a class="ulink" href="http://flickr.com/" target="_top">Flickr</a> uploader tool, then this entry should only show up if the selection contains JPEG
30
 
        files (other file formats are not supported by Flickr) and so you should add a line <code class="literal">MimeType=image/jpeg;</code>.
31
 
        If you do not specify any <code class="literal">MimeType</code> your entry will show up for all file types.
32
 
      </p><p>
33
 
        A complete example using the <strong class="application"><code>postr</code></strong> application is shown below:
34
 
      </p><pre class="programlisting">
35
 
# postr.desktop - Integrate postr into
36
 
#                 the "Send To" menu.
37
 
[Desktop Entry]
38
 
Type=Application
39
 
Version=1.0
40
 
Encoding=UTF-8
41
 
TryExec=postr
42
 
Exec=postr %F
43
 
Icon=postr
44
 
Name=Flickr
45
 
MimeType=image/jpeg;</pre><p>
46
 
        If you install this file to <code class="filename">~/.local/share/Thunar/sendto/</code> (create the folder if
47
 
        it does not exist yet), the <span class="guilabel"><strong>Send To</strong></span> menu for JPEG files will show the new entry <span class="guilabel"><strong>Flickr</strong></span>,
48
 
        which can be used to upload JPEG images to Flickr.
49
 
      </p><p>
50
 
        The <a class="ulink" href="http://thunar.xfce.org/pwiki/documentation/sendto_menu" target="_top">Thunar Project Wiki</a> contains
51
 
        additional examples of useful targets for the <span class="guilabel"><strong>Send To</strong></span> menu. Feel free to extend the Wiki page with
52
 
        new examples.
53
 
      </p></div><div class="sect2" title="Thumbnailers"><div class="titlepage"><div><div><h3 class="title"><a name="thumbnailers"></a>Thumbnailers</h3></div></div></div><p>
54
 
        Thunar uses small utilities to create thumbnails of certain file types and displays the thumbnails as preview of the
55
 
        file content. These small tools are called thumbnailers. Thunar ships with thumbnailers for image and font files, and
56
 
        makes use of the installed thumbnailers from GNOME automatically if it was installed with support for <code class="literal">gconf</code>.
57
 
        Users may however dynamically extend this basic functionality with thumbnailers for additional file types.
58
 
      </p><p>
59
 
        If you plan to write a custom thumbnailers, you need to start with a program that accepts atleast two command line parameters,
60
 
        the input file, which is of the file type you plan to support and the output file, which is a PNG file that complies with the
61
 
        format specified by the <a class="ulink" href="http://jens.triq.net/thumbnail-spec/creation.html#AEN139" target="_top">Thumbnail Management
62
 
        Standard</a>. Additionally your program may also accept the desired size of the thumbnail, which is optional but highly
63
 
        recommended. If you write the output file at an arbitrary image size, Thunar will afterwards scale it to the desired size,
64
 
        which might produce a less optimal result than generating the thumbnail with the requested dimensions.
65
 
      </p><p>
66
 
        Once your utility to generate the thumbnails is done, you will need to register your thumbnailer, so Thunar is able to locate
67
 
        and use it. Therefore all you need to do is to install a description file for the thumbnailer (a <code class="filename">.desktop</code> file)
68
 
        in one of the <code class="filename">$XDG_DATA_DIRS/thumbnailers/</code> paths. For example, if you want to register the
69
 
        thumbnailer for your user account only, you can install the file into the folder <code class="filename">~/.local/share/thumbnailers/</code>. The <code class="filename">.desktop</code> for thumbnailers has the following format.
70
 
      </p><div class="sect3" title="Thumbnailer Description File Format"><div class="titlepage"><div><div><h4 class="title"><a name="thumbnailer-desktop-file-format"></a>Thumbnailer Description File Format</h4></div></div></div><p>
71
 
          Thumbnailer description files utilize the <a class="ulink" href="http://standards.freedesktop.org/desktop-entry-spec/latest/" target="_top">Desktop
72
 
          Entry Format</a> with a special <code class="literal">Type</code> of <code class="literal">X-Thumbnailer</code> and special field
73
 
          <code class="literal">X-Thumbnailer-Exec</code> with new field codes. Basically, a thumbnailer description file has the following format.
74
 
        </p><pre class="programlisting">
75
 
[Desktop Entry]
76
 
Version=1.0
77
 
Encoding=UTF-8
78
 
Type=X-Thumbnailer
79
 
Name=Your Thumbnailer
80
 
MimeType=your-supported/mime-type;
81
 
X-Thumbnailer-Exec=your-thumbnailer %i %o %s</pre><p>
82
 
          The <code class="literal">Version</code> and <code class="literal">Encoding</code> are mandated by the Desktop Entry Specification, just use the values shown
83
 
          in the example above. The <code class="literal">Type</code> field must have the special value <code class="literal">X-Thumbnailer</code>, otherwise your
84
 
          thumbnailer will not be recognized. The <code class="literal">Name</code> value describes your thumbnailer.
85
 
        </p><p>
86
 
          The <code class="literal">X-Thumbnailer-Exec</code> field contains the command to run your thumbnailer, and supports certain field codes that will
87
 
          be substituted when the thumbnailer is run. Recognized field codes are as follows:
88
 
        </p><div class="variablelist"><dl><dt><span class="term"><code class="varname">%i</code></span></dt><dd>
89
 
              The local path to the input file for which to create a thumbnail. May be either a path relative to the directory from which the
90
 
              thumbnailer was invoked or an absolute path.
91
 
            </dd><dt><span class="term"><code class="varname">%o</code></span></dt><dd>
92
 
              The local path to the output file where to store the generated thumbnail. The output file must be written as valid PNG file according
93
 
              to the thumbnail standard (see above). Note that the path may not end with <code class="literal">.png</code>, which matters if you invoke certain
94
 
              third party tools.
95
 
            </dd><dt><span class="term"><code class="varname">%s</code></span></dt><dd>
96
 
              The desired size of the generated thumbnail in pixels. This parameter is optional.
97
 
            </dd><dt><span class="term"><code class="varname">%u</code></span></dt><dd>
98
 
              Similar to <code class="literal">%i</code>, but substituted with the URI of the file, rather than the path. This was added for compatibility with
99
 
              GNOME.
100
 
            </dd><dt><span class="term"><code class="varname">%%</code></span></dt><dd>
101
 
              Will be substituted with a single <code class="literal">%</code>.
102
 
            </dd></dl></div><p>
103
 
          You need to include atleast <code class="literal">%o</code> and <code class="literal">%i</code> or <code class="literal">%u</code>, otherwise your thumbnailer will
104
 
          be useless.
105
 
        </p><p>
106
 
          The <code class="literal">MimeType</code> lists the MIME types - separated by semicolon - for which your thumbnailer is able to create previews.
107
 
        </p></div><div class="sect3" title="Example EPS Thumbnailer"><div class="titlepage"><div><div><h4 class="title"><a name="eps-thumbnailer-example"></a>Example EPS Thumbnailer</h4></div></div></div><p>
108
 
          This example demonstrates how to write and install a new thumbnailer for <code class="filename">.eps</code> files, which uses the
109
 
          <span class="command"><strong>convert</strong></span> utility that ships as part of ImageMagick. First, we start with a simple script that invokes
110
 
          <span class="command"><strong>convert</strong></span> to generate a thumbnail at the requested size.
111
 
        </p><pre class="programlisting">
112
 
#!/bin/sh
113
 
#
114
 
# eps-thumbnailer - Example thumbnailer script for EPS files.
115
 
#
116
 
# Usage: esp-thumbnailer eps-file png-file size
117
 
#
118
 
 
119
 
# command line parameters
120
 
ifile=$1
121
 
ofile=$2
122
 
size=$3
123
 
 
124
 
# invoke convert (ImageMagick)
125
 
exec convert "eps:$ifile" -scale "$sizex$size" "png:$ofile"</pre><p>
126
 
          Save this script above to a file <code class="filename">eps-thumbnailer</code>, make sure the file is executable and install it
127
 
          to <code class="filename">/usr/local/bin</code>.
128
 
        </p><pre class="screen">
129
 
$ chmod +x eps-thumbnailer
130
 
$ sudo install eps-thumbnailer /usr/local/bin/eps-thumbnailer</pre><p>
131
 
          Next we need to create the thumbnail description file <code class="filename">eps-thumbnailer.desktop</code>, which looks like this:
132
 
        </p><pre class="programlisting">
133
 
[Desktop Entry]
134
 
Version=1.0
135
 
Encoding=UTF-8
136
 
Type=X-Thumbnailer
137
 
Name=EPS Thumbnailer
138
 
TryExec=convert
139
 
MimeType=image/x-eps;
140
 
X-Thumbnailer-Exec=/usr/local/bin/eps-thumbnailer %i %o %s</pre><p>
141
 
          This file must be installed to <code class="filename">/usr/local/share/thumbnailers</code> (create the folder if
142
 
          it does not exists).
143
 
        </p><pre class="screen">
144
 
$ sudo install -d /usr/local/share/thumbnailers
145
 
$ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbnailer.desktop</pre><p>
146
 
          The <code class="filename">eps-thumbnailer.desktop</code> file uses the special key <code class="literal">TryExec</code>, which, if specified,
147
 
          names a command that must be present on the system for the thumbnailer to be useful. In this case, our script is useless if
148
 
          the <span class="command"><strong>convert</strong></span> utility is not present.
149
 
        </p><p>
150
 
          The last step is to regenerate the thumbnailer cache, so Thunar will pick up our thumbnailer. The thumbnailer cache is located
151
 
          at <code class="filename">$XDG_CACHE_HOME/Thunar/thumbnailers.cache</code> (unless overridden by your or your system administrator, the
152
 
          <code class="varname">$XDG_CACHE_HOME</code> points to the folder <code class="filename">~/.cache/</code>). The thumbnailers
153
 
          cache is regenerated periodically by Thunar, but you can force to regenerate it by invoking the
154
 
          <code class="filename">thunar-vfs-update-thumbnailers-cache-1</code> utility, that ships as part of Thunar. This utility is usually installed
155
 
          in the <code class="filename">libexec</code> subfolder of your installation prefix (<code class="filename">sbin</code>
156
 
          on Debian/Ubuntu). So for example, if Thunar is installed in <code class="filename">/usr</code>, invoke the utility as
157
 
          follows:
158
 
        </p><pre class="screen">$ /usr/libexec/thunar-vfs-update-thumbnailers-cache-1</pre><p>
159
 
          But make sure you run the program from your user account, not the superuser account, since the thumbnailers cache is stored in
160
 
          your home folder, rather than a system wide location.
161
 
        </p><p>
162
 
          Now, if Thunar is compiled with support for file alteration monitoring (using the FAM or Gamin services), it will automatically
163
 
          pick up the new thumbnailers cache within a few seconds and afterwards be able to generate thumbnails using your custom
164
 
          thumbnailers. Otherwise you might need to completely restart Thunar to apply the changes, using
165
 
        </p><pre class="screen">$ Thunar -q</pre><p>
166
 
          to terminate any running instance, and afterwards restart it from your launcher.
167
 
        </p></div><div class="sect3" title="Cleaning up Thumbnails"><div class="titlepage"><div><div><h4 class="title"><a name="cleaning-up-thumbnails"></a>Cleaning up Thumbnails</h4></div></div></div><p>
168
 
          The generated thumbnails are stored in the folder <code class="filename">~/.thumbnails/</code> complying with the <a class="ulink" href="http://jens.triq.net/thumbnail-spec/index.html" target="_top">Thumbnail Management Standard</a>. While testing a new
169
 
          thumbnailer, it might help to clean up the thumbnail cache using
170
 
        </p><pre class="screen">$ rm -rf ~/.thumbnails/</pre><p>
171
 
          which will also give you some free space in your home folder. Since all the information stored within this folder was automatically
172
 
          generated from files in your file system, you will not loose any sensitive data.
173
 
        </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="preferences.html">&#21069;&#19968;&#38913;</a>�</td><td width="20%" align="center">�</td><td width="40%" align="right">�<a accesskey="n" href="advanced-topics.html">&#19979;&#19968;&#38913;</a></td></tr><tr><td width="40%" align="left" valign="top">File Management Preferences�</td><td width="20%" align="center"><a accesskey="h" href="index.html">&#20839;&#23481;</a></td><td width="40%" align="right" valign="top">�&#36914;&#38542;&#20839;&#23481;</td></tr></table></div></body></html>