📄 gtkfilechooser.html
字号:
... toggle = gtk_check_button_new_with_label ("Open file read-only"); gtk_widget_show (toggle); gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);} </pre></div></div><br class="example-break"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> If you want to set more than one extra widget in the file chooser, you can a container such as a GtkVBox or a GtkTable and include your widgets in it. Then, set the container as the whole extra widget. </p></div></div><hr><div class="refsect2" lang="en"><a name="gtkfilechooser-key-bindings"></a><h3>Key Bindings</h3><p> Internally, GTK+ implements a file chooser's graphical user interface with the private <code class="classname">GtkFileChooserDefaultClass</code>. This widget has several <a class="link" href="gtk-Bindings.html" title="Bindings">key bindings</a> and their associated signals. This section describes the available key binding signals. </p><div class="example"><a name="gtkfilechooser-key-binding-example"></a><p class="title"><b>Example 32. GtkFileChooser key binding example</b></p><div class="example-contents"><p> The default keys that activate the key-binding signals in <code class="classname">GtkFileChooserDefaultClass</code> are as follows: </p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td>Signal name</td><td>Default key combinations</td></tr><tr><td>location-popup</td><td> <span class="keycap"><strong>Control</strong></span>+<span class="keycap"><strong>L</strong></span> (empty path); <span class="keycap"><strong>/</strong></span> (path of "/")<sup>[<a name="id4012079" href="#ftn.id4012079" class="footnote">a</a>]</sup>; <span class="keycap"><strong>~</strong></span> (path of "~") </td></tr><tr><td>up-folder</td><td> <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Up</strong></span><sup>[<a name="id4012118" href="#ftn.id4012118" class="footnote">b</a>]</sup> ; <span class="keycap"><strong>Backspace</strong></span> </td></tr><tr><td>down-folder</td><td><span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Down</strong></span></td></tr><tr><td>home-folder</td><td><span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Home</strong></span></td></tr><tr><td>desktop-folder</td><td><span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>D</strong></span></td></tr><tr><td>quick-bookmark</td><td><span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>1</strong></span> through <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>0</strong></span></td></tr></tbody><tbody class="footnotes"><tr><td colspan="2"><div class="footnote"><p><sup>[<a name="ftn.id4012079" href="#id4012079" class="para">a</a>] </sup> Both the individual <span class="keycap"><strong>/</strong></span> key and the numeric keypad's "divide" key are supported. </p></div><div class="footnote"><p><sup>[<a name="ftn.id4012118" href="#id4012118" class="para">b</a>] </sup> Both the individual Up key and the numeric keypad's Up key are supported. </p></div></td></tr></tbody></table></div><p> You can change these defaults to something else. For example, to add a <span class="keycap"><strong>Shift</strong></span> modifier to a few of the default bindings, you can include the following fragment in your <code class="filename">.gtkrc-2.0</code> file: </p><pre class="programlisting">binding "my-own-gtkfilechooser-bindings" { bind "<Alt><Shift>Up" { "up-folder" () } bind "<Alt><Shift>Down" { "down-folder" () } bind "<Alt><Shift>Home" { "home-folder" () }}class "GtkFileChooserDefault" binding "my-own-gtkfilechooser-bindings" </pre></div></div><br class="example-break"><div class="refsect3" lang="en"><a name="GtkFileChooserDefault-location-popup"></a><h4>The "GtkFileChooserDefault::location-popup" signal</h4><pre class="programlisting"> void user_function (GtkFileChooserDefault *chooser, const char *path, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> user_data); </pre><p> This is used to make the file chooser show a "Location" dialog which the user can use to manually type the name of the file he wishes to select. The <em class="parameter"><code>path</code></em> argument is a string that gets put in the text entry for the file name. By default this is bound to <span class="keycap"><strong>Control</strong></span>+<span class="keycap"><strong>L</strong></span> with a <em class="parameter"><code>path</code></em> string of "" (the empty string). It is also bound to <span class="keycap"><strong>/</strong></span> with a <em class="parameter"><code>path</code></em> string of "<code class="literal">/</code>" (a slash): this lets you type <span class="keycap"><strong>/</strong></span> and immediately type a path name. On Unix systems, this is bound to <span class="keycap"><strong>~</strong></span> (tilde) with a <em class="parameter"><code>path</code></em> string of "~" itself for access to home directories. </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>chooser</code></em> :</span></p></td><td> the object which received the signal. </td></tr><tr><td><p><span class="term"><em class="parameter"><code>path</code></em> :</span></p></td><td> default contents for the text entry for the file name </td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td><td> user data set when the signal handler was connected. </td></tr></tbody></table></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p> You can create your own bindings for the <span class="symbol">location-popup</span> signal with custom <em class="parameter"><code>path</code></em> strings, and have a crude form of easily-to-type bookmarks. For example, say you access the path <code class="filename">/home/username/misc</code> very frequently. You could then create an <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>M</strong></span> shortcut by including the following in your <code class="filename">.gtkrc-2.0</code>: </p><pre class="programlisting">binding "misc-shortcut" { bind "<Alt>M" { "location-popup" ("/home/username/misc") }}class "GtkFileChooserDefault" binding "misc-shortcut" </pre></div></div><div class="refsect3" lang="en"><a name="GtkFileChooserDefault-up-folder"></a><h4>The "GtkFileChooserDefault::up-folder" signal</h4><pre class="programlisting"> void user_function (GtkFileChooserDefault *chooser, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> user_data); </pre><p> This is used to make the file chooser go to the parent of the current folder in the file hierarchy. By default this is bound to <span class="keycap"><strong>Backspace</strong></span> and <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Up</strong></span> (the Up key in the numeric keypad also works). </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>chooser</code></em> :</span></p></td><td> the object which received the signal. </td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td><td> user data set when the signal handler was connected. </td></tr></tbody></table></div></div><div class="refsect3" lang="en"><a name="GtkFileChooserDefault-down-folder"></a><h4>The "GtkFileChooserDefault::down-folder" signal</h4><pre class="programlisting"> void user_function (GtkFileChooserDefault *chooser, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> user_data); </pre><p> This is used to make the file chooser go to a child of the current folder in the file hierarchy. The subfolder that will be used is displayed in the path bar widget of the file chooser. For example, if the path bar is showing "/foo/<span class="emphasis"><em>bar/</em></span>baz", then this will cause the file chooser to switch to the "baz" subfolder. By default this is bound to <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Down</strong></span> (the Down key in the numeric keypad also works). </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -