New upstream version 3.23.0

This commit is contained in:
Iain Lane
2018-07-18 14:06:19 +01:00
731 changed files with 556100 additions and 542972 deletions

View File

@ -3,12 +3,12 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GtkFileChooser: GTK+ 3 Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="GTK+ 3 Reference Manual">
<link rel="up" href="SelectorWidgets.html" title="Selector Widgets and Dialogs">
<link rel="prev" href="GtkColorChooserDialog.html" title="GtkColorChooserDialog">
<link rel="next" href="GtkFileChooserButton.html" title="GtkFileChooserButton">
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
<meta name="generator" content="GTK-Doc V1.25 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@ -740,81 +740,41 @@ flag that indicates whether your callback could successfully
generate a preview.</p>
<div class="refsect3">
<a name="gtkfilechooser-preview"></a><h4>Example: Using a Preview Widget</h4>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="cbracket">{</span>
<span class="normal"> </span><span class="usertype">GtkImage</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">preview</span><span class="symbol">;</span>
<div class="informalexample"><pre class="programlisting">
{
GtkImage *preview;
<span class="normal"> </span><span class="symbol">...</span>
...
<span class="normal"> preview </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="GtkImage.html#gtk-image-new">gtk_image_new</a></span><span class="normal"> </span><span class="symbol">();</span>
preview = gtk_image_new ();
<span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-preview-widget">gtk_file_chooser_set_preview_widget</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">my_file_chooser</span><span class="symbol">,</span><span class="normal"> preview</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function">g_signal_connect</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">my_file_chooser</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"update-preview"</span><span class="symbol">,</span>
<span class="normal"> </span><span class="function">G_CALLBACK</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">update_preview_cb</span><span class="symbol">),</span><span class="normal"> preview</span><span class="symbol">);</span>
<span class="cbracket">}</span>
gtk_file_chooser_set_preview_widget (my_file_chooser, preview);
g_signal_connect (my_file_chooser, "update-preview",
G_CALLBACK (update_preview_cb), preview);
}
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">update_preview_cb</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">GtkFileChooser</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">file_chooser</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">gpointer</span><span class="normal"> data</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="usertype">GtkWidget</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">preview</span><span class="symbol">;</span>
<span class="normal"> </span><span class="type">char</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">filename</span><span class="symbol">;</span>
<span class="normal"> </span><span class="usertype">GdkPixbuf</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">pixbuf</span><span class="symbol">;</span>
<span class="normal"> </span><span class="usertype">gboolean</span><span class="normal"> have_preview</span><span class="symbol">;</span>
static void
update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
{
GtkWidget *preview;
char *filename;
GdkPixbuf *pixbuf;
gboolean have_preview;
<span class="normal"> preview </span><span class="symbol">=</span><span class="normal"> </span><span class="function">GTK_WIDGET</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">data</span><span class="symbol">);</span>
<span class="normal"> filename </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-get-preview-filename">gtk_file_chooser_get_preview_filename</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">file_chooser</span><span class="symbol">);</span>
preview = GTK_WIDGET (data);
filename = gtk_file_chooser_get_preview_filename (file_chooser);
<span class="normal"> pixbuf </span><span class="symbol">=</span><span class="normal"> </span><span class="function">gdk_pixbuf_new_from_file_at_size</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">filename</span><span class="symbol">,</span><span class="normal"> </span><span class="number">128</span><span class="symbol">,</span><span class="normal"> </span><span class="number">128</span><span class="symbol">,</span><span class="normal"> NULL</span><span class="symbol">);</span>
<span class="normal"> have_preview </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">pixbuf </span><span class="symbol">!=</span><span class="normal"> NULL</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function">g_free</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">filename</span><span class="symbol">);</span>
pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
have_preview = (pixbuf != NULL);
g_free (filename);
<span class="normal"> </span><span class="function"><a href="GtkImage.html#gtk-image-set-from-pixbuf">gtk_image_set_from_pixbuf</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">GTK_IMAGE</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">preview</span><span class="symbol">),</span><span class="normal"> pixbuf</span><span class="symbol">);</span>
<span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">pixbuf</span><span class="symbol">)</span>
<span class="normal"> </span><span class="function">g_object_unref</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">pixbuf</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-preview-widget-active">gtk_file_chooser_set_preview_widget_active</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">file_chooser</span><span class="symbol">,</span><span class="normal"> have_preview</span><span class="symbol">);</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
if (pixbuf)
g_object_unref (pixbuf);
gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
}
</pre></div>
<p></p>
</div>
</div>
@ -828,31 +788,17 @@ file in read-only mode. You can use
<a class="link" href="GtkFileChooser.html#gtk-file-chooser-set-extra-widget" title="gtk_file_chooser_set_extra_widget ()"><code class="function">gtk_file_chooser_set_extra_widget()</code></a> to insert additional
widgets in a file chooser.</p>
<p>An example for adding extra widgets:</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="usertype">GtkWidget</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">toggle</span><span class="symbol">;</span>
<div class="informalexample"><pre class="programlisting">
<span class="symbol">...</span>
GtkWidget *toggle;
<span class="normal">toggle </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="GtkCheckButton.html#gtk-check-button-new-with-label">gtk_check_button_new_with_label</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"Open file read-only"</span><span class="symbol">);</span>
<span class="function"><a href="GtkWidget.html#gtk-widget-show">gtk_widget_show</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">toggle</span><span class="symbol">);</span>
<span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-extra-widget">gtk_file_chooser_set_extra_widget</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">my_file_chooser</span><span class="symbol">,</span><span class="normal"> toggle</span><span class="symbol">);</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
...
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>
<p></p>
<p>If you want to set more than one extra widget in the file
chooser, you can a container such as a <a class="link" href="GtkBox.html" title="GtkBox"><span class="type">GtkBox</span></a> or a <a class="link" href="GtkGrid.html" title="GtkGrid"><span class="type">GtkGrid</span></a>
@ -1279,7 +1225,7 @@ Please see the documentation for those functions for an example of using
</tr>
<tr>
<td class="parameter_name"><p>name</p></td>
<td class="parameter_description"><p>the filename to use, as a UTF-8 string. </p></td>
<td class="parameter_description"><p> the filename to use, as a UTF-8 string. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> filename]</span></td>
</tr>
</tbody>
@ -1351,7 +1297,7 @@ folder.</p>
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-filename.returns"></a><h4>Returns</h4>
<p>The currently selected filename,
<p> The currently selected filename,
or <code class="literal">NULL</code> if no file is selected, or the selected file can't
be represented with a local filename. Free with <code class="function">g_free()</code>. </p>
<p><span class="annotation">[<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>][<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> filename]</span></p>
@ -1380,35 +1326,18 @@ then does Save As... to save a copy or
a modified version. If you dont have a file name already — for
example, if the user just created a new file and is saving it for the first
time, do not call this function. Instead, use something similar to this:</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">document_is_new</span><span class="symbol">)</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="comment">// the user just created a new document</span>
<span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-current-name">gtk_file_chooser_set_current_name</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"Untitled document"</span><span class="symbol">);</span>
<span class="normal"> </span><span class="cbracket">}</span>
<span class="keyword">else</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="comment">// the user edited an existing document</span>
<span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-filename">gtk_file_chooser_set_filename</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">,</span><span class="normal"> existing_filename</span><span class="symbol">);</span>
<span class="normal"> </span><span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<div class="informalexample"><pre class="programlisting">
if (document_is_new)
{
// the user just created a new document
gtk_file_chooser_set_current_name (chooser, "Untitled document");
}
else
{
// the user edited an existing document
gtk_file_chooser_set_filename (chooser, existing_filename);
}
</pre></div>
<p></p>
<p>In the first case, the file chooser will present the user with useful suggestions
as to where to save his new file. In the second case, the files existing location
@ -1429,7 +1358,7 @@ is already known, so the file chooser will use it.</p>
</tr>
<tr>
<td class="parameter_name"><p>filename</p></td>
<td class="parameter_description"><p>the filename to set as current. </p></td>
<td class="parameter_description"><p> the filename to set as current. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> filename]</span></td>
</tr>
</tbody>
@ -1469,7 +1398,7 @@ be changed to the folder containing <em class="parameter"><code>filename</code><
</tr>
<tr>
<td class="parameter_name"><p>filename</p></td>
<td class="parameter_description"><p>the filename to select. </p></td>
<td class="parameter_description"><p> the filename to select. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> filename]</span></td>
</tr>
</tbody>
@ -1507,7 +1436,7 @@ is otherwise not currently selected, does nothing.</p>
</tr>
<tr>
<td class="parameter_name"><p>filename</p></td>
<td class="parameter_description"><p>the filename to unselect. </p></td>
<td class="parameter_description"><p> the filename to unselect. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> filename]</span></td>
</tr>
</tbody>
@ -1588,7 +1517,7 @@ folder cannot be represented as local filenames they will be ignored. (See
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-filenames.returns"></a><h4>Returns</h4>
<p>a <span class="type">GSList</span>
<p> a <span class="type">GSList</span>
containing the filenames of all selected files and subfolders in
the current folder. Free the returned list with <code class="function">g_slist_free()</code>,
and the filenames with <code class="function">g_free()</code>. </p>
@ -1625,7 +1554,7 @@ for the rationale behind this.</p>
</tr>
<tr>
<td class="parameter_name"><p>filename</p></td>
<td class="parameter_description"><p>the full path of the new current folder. </p></td>
<td class="parameter_description"><p> the full path of the new current folder. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> filename]</span></td>
</tr>
</tbody>
@ -1669,7 +1598,7 @@ usual way to get the selection.</p>
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-current-folder.returns"></a><h4>Returns</h4>
<p>the full path of the current
<p> the full path of the current
folder, or <code class="literal">NULL</code> if the current path cannot be represented as a local
filename. Free with <code class="function">g_free()</code>. This function will also return
<code class="literal">NULL</code> if the file chooser was unable to load the last folder that
@ -1706,7 +1635,7 @@ folder.</p>
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-uri.returns"></a><h4>Returns</h4>
<p>The currently selected URI, or <code class="literal">NULL</code>
<p> The currently selected URI, or <code class="literal">NULL</code>
if no file is selected. If <a class="link" href="GtkFileChooser.html#gtk-file-chooser-set-local-only" title="gtk_file_chooser_set_local_only ()"><code class="function">gtk_file_chooser_set_local_only()</code></a> is set to
<code class="literal">TRUE</code> (the default) a local URI will be returned for any FUSE locations.
Free with <code class="function">g_free()</code>. </p>
@ -1735,35 +1664,18 @@ does Save As... to save a copy or a
modified version. If you dont have a file name already — for example,
if the user just created a new file and is saving it for the first time, do
not call this function. Instead, use something similar to this:</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">document_is_new</span><span class="symbol">)</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="comment">// the user just created a new document</span>
<span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-current-name">gtk_file_chooser_set_current_name</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"Untitled document"</span><span class="symbol">);</span>
<span class="normal"> </span><span class="cbracket">}</span>
<span class="keyword">else</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="comment">// the user edited an existing document</span>
<span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-uri">gtk_file_chooser_set_uri</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">,</span><span class="normal"> existing_uri</span><span class="symbol">);</span>
<span class="normal"> </span><span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<div class="informalexample"><pre class="programlisting">
if (document_is_new)
{
// the user just created a new document
gtk_file_chooser_set_current_name (chooser, "Untitled document");
}
else
{
// the user edited an existing document
gtk_file_chooser_set_uri (chooser, existing_uri);
}
</pre></div>
<p></p>
<p>In the first case, the file chooser will present the user with useful suggestions
as to where to save his new file. In the second case, the files existing location
@ -1896,7 +1808,7 @@ gtk_file_chooser_get_uris (<em class="parameter"><code><a class="link" href="Gtk
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-uris.returns"></a><h4>Returns</h4>
<p>a <span class="type">GSList</span> containing the URIs of all selected
<p> a <span class="type">GSList</span> containing the URIs of all selected
files and subfolders in the current folder. Free the returned list
with <code class="function">g_slist_free()</code>, and the filenames with <code class="function">g_free()</code>. </p>
<p><span class="annotation">[<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> utf8][<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
@ -1979,7 +1891,7 @@ usual way to get the selection.</p>
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-current-folder-uri.returns"></a><h4>Returns</h4>
<p>the URI for the current folder.
<p> the URI for the current folder.
Free with <code class="function">g_free()</code>. This function will also return <code class="literal">NULL</code> if the file chooser
was unable to load the last folder that was requested from it; for example,
as would be for calling <a class="link" href="GtkFileChooser.html#gtk-file-chooser-set-current-folder-uri" title="gtk_file_chooser_set_current_folder_uri ()"><code class="function">gtk_file_chooser_set_current_folder_uri()</code></a> on a
@ -2053,7 +1965,7 @@ gtk_file_chooser_get_preview_widget (<em class="parameter"><code><a class="link"
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-preview-widget.returns"></a><h4>Returns</h4>
<p>the current preview widget, or <code class="literal">NULL</code>. </p>
<p> the current preview widget, or <code class="literal">NULL</code>. </p>
<p><span class="annotation">[<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>][<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
</div>
<p class="since">Since: 2.4</p>
@ -2215,7 +2127,7 @@ widget. See <a class="link" href="GtkFileChooser.html#gtk-file-chooser-set-previ
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-preview-filename.returns"></a><h4>Returns</h4>
<p>the filename to preview, or <code class="literal">NULL</code> if
<p> the filename to preview, or <code class="literal">NULL</code> if
no file is selected, or if the selected file cannot be represented
as a local filename. Free with <code class="function">g_free()</code>. </p>
<p><span class="annotation">[<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>][<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> filename]</span></p>
@ -2246,7 +2158,7 @@ widget. See <a class="link" href="GtkFileChooser.html#gtk-file-chooser-set-previ
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-preview-uri.returns"></a><h4>Returns</h4>
<p>the URI for the file to preview,
<p> the URI for the file to preview,
or <code class="literal">NULL</code> if no file is selected. Free with <code class="function">g_free()</code>. </p>
<p><span class="annotation">[<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>][<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
@ -2307,7 +2219,7 @@ gtk_file_chooser_get_extra_widget (<em class="parameter"><code><a class="link" h
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-extra-widget.returns"></a><h4>Returns</h4>
<p>the current extra widget, or <code class="literal">NULL</code>. </p>
<p> the current extra widget, or <code class="literal">NULL</code>. </p>
<p><span class="annotation">[<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>][<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
</div>
<p class="since">Since: 2.4</p>
@ -2341,7 +2253,7 @@ ref and sink it if you want to keep a reference.</p>
</tr>
<tr>
<td class="parameter_name"><p>filter</p></td>
<td class="parameter_description"><p>a <a class="link" href="GtkFileFilter.html" title="GtkFileFilter"><span class="type">GtkFileFilter</span></a>. </p></td>
<td class="parameter_description"><p> a <a class="link" href="GtkFileFilter.html" title="GtkFileFilter"><span class="type">GtkFileFilter</span></a>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></td>
</tr>
</tbody>
@ -2405,7 +2317,7 @@ gtk_file_chooser_list_filters (<em class="parameter"><code><a class="link" href=
</div>
<div class="refsect3">
<a name="gtk-file-chooser-list-filters.returns"></a><h4>Returns</h4>
<p>a
<p> a
<span class="type">GSList</span> containing the current set of user selectable filters. The
contents of the list are owned by GTK+, but you must free the list
itself with <code class="function">g_slist_free()</code> when you are done with it. </p>
@ -2472,7 +2384,7 @@ gtk_file_chooser_get_filter (<em class="parameter"><code><a class="link" href="G
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-filter.returns"></a><h4>Returns</h4>
<p>the current filter, or <code class="literal">NULL</code>. </p>
<p> the current filter, or <code class="literal">NULL</code>. </p>
<p><span class="annotation">[<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>][<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
</div>
<p class="since">Since: 2.4</p>
@ -2504,12 +2416,12 @@ application. For example, you can use this to add a
</tr>
<tr>
<td class="parameter_name"><p>folder</p></td>
<td class="parameter_description"><p>filename of the folder to add. </p></td>
<td class="parameter_description"><p> filename of the folder to add. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> filename]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_description"><p> location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
</tbody>
@ -2548,12 +2460,12 @@ gtk_file_chooser_remove_shortcut_folder
</tr>
<tr>
<td class="parameter_name"><p>folder</p></td>
<td class="parameter_description"><p>filename of the folder to remove. </p></td>
<td class="parameter_description"><p> filename of the folder to remove. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> filename]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_description"><p> location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
</tbody>
@ -2593,7 +2505,7 @@ gtk_file_chooser_list_shortcut_folders
</div>
<div class="refsect3">
<a name="gtk-file-chooser-list-shortcut-folders.returns"></a><h4>Returns</h4>
<p>A list
<p> A list
of folder filenames, or <code class="literal">NULL</code> if there are no shortcut folders.
Free the returned list with <code class="function">g_slist_free()</code>, and the filenames with
<code class="function">g_free()</code>. </p>
@ -2634,7 +2546,7 @@ by the application. For example, you can use this to add a
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_description"><p> location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
</tbody>
@ -2678,7 +2590,7 @@ gtk_file_chooser_remove_shortcut_folder_uri
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_description"><p> location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
</tbody>
@ -2718,7 +2630,7 @@ gtk_file_chooser_list_shortcut_folder_uris
</div>
<div class="refsect3">
<a name="gtk-file-chooser-list-shortcut-folder-uris.returns"></a><h4>Returns</h4>
<p>A list of
<p> A list of
folder URIs, or <code class="literal">NULL</code> if there are no shortcut folders. Free the
returned list with <code class="function">g_slist_free()</code>, and the URIs with <code class="function">g_free()</code>. </p>
<p><span class="annotation">[<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>][<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> utf8][<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
@ -2751,7 +2663,7 @@ See <a class="link" href="GtkFileChooser.html#gtk-file-chooser-get-current-folde
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-current-folder-file.returns"></a><h4>Returns</h4>
<p>the <span class="type">GFile</span> for the current folder. </p>
<p> the <span class="type">GFile</span> for the current folder. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
<p class="since">Since: 2.14</p>
@ -2783,7 +2695,7 @@ folder.</p>
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-file.returns"></a><h4>Returns</h4>
<p>a selected <span class="type">GFile</span>. You own the returned file;
<p> a selected <span class="type">GFile</span>. You own the returned file;
use <code class="function">g_object_unref()</code> to release it. </p>
<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
@ -2814,7 +2726,7 @@ as <span class="type">GFile</span>. An internal function, see <a class="link" hr
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-files.returns"></a><h4>Returns</h4>
<p>a <span class="type">GSList</span>
<p> a <span class="type">GSList</span>
containing a <span class="type">GFile</span> for each selected file and subfolder in the
current folder. Free the returned list with <code class="function">g_slist_free()</code>, and
the files with <code class="function">g_object_unref()</code>. </p>
@ -2846,7 +2758,7 @@ Internal function, see <a class="link" href="GtkFileChooser.html#gtk-file-choose
</div>
<div class="refsect3">
<a name="gtk-file-chooser-get-preview-file.returns"></a><h4>Returns</h4>
<p>the <span class="type">GFile</span> for the file to preview,
<p> the <span class="type">GFile</span> for the file to preview,
or <code class="literal">NULL</code> if no file is selected. Free with <code class="function">g_object_unref()</code>. </p>
<p><span class="annotation">[<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>][<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p>
</div>
@ -2883,7 +2795,7 @@ gtk_file_chooser_select_file (<em class="parameter"><code><a class="link" href="
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_description"><p> location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
</tbody>
@ -2927,7 +2839,7 @@ Internal function, see <a class="link" href="GtkFileChooser.html#gtk-file-choose
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_description"><p> location to store error, or <code class="literal">NULL</code>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
</tbody>
@ -2969,37 +2881,19 @@ does Save As... If you dont have
a file name already — for example, if the user just created a new
file and is saving it for the first time, do not call this function.
Instead, use something similar to this:</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">document_is_new</span><span class="symbol">)</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="comment">// the user just created a new document</span>
<span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-current-folder-file">gtk_file_chooser_set_current_folder_file</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">,</span><span class="normal"> default_file_for_saving</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-current-name">gtk_file_chooser_set_current_name</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"Untitled document"</span><span class="symbol">);</span>
<span class="normal"> </span><span class="cbracket">}</span>
<span class="keyword">else</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="comment">// the user edited an existing document</span>
<span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-file">gtk_file_chooser_set_file</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">,</span><span class="normal"> existing_file</span><span class="symbol">);</span>
<span class="normal"> </span><span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<div class="informalexample"><pre class="programlisting">
if (document_is_new)
{
// the user just created a new document
gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
gtk_file_chooser_set_current_name (chooser, "Untitled document");
}
else
{
// the user edited an existing document
gtk_file_chooser_set_file (chooser, existing_file);
}
</pre></div>
<p></p>
<div class="refsect3">
<a name="gtk-file-chooser-set-file.parameters"></a><h4>Parameters</h4>
@ -3022,7 +2916,7 @@ Instead, use something similar to this:</p>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>location to store the error, or <code class="literal">NULL</code> to ignore errors. </p></td>
<td class="parameter_description"><p> location to store the error, or <code class="literal">NULL</code> to ignore errors. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
</tbody>
@ -3351,73 +3245,37 @@ dialog should be used, it should return
illustrates this.</p>
<div class="refsect3">
<a name="gtkfilechooser-confirmation"></a><h4>Custom confirmation</h4>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="GtkFileChooser.html#GtkFileChooserConfirmation">GtkFileChooserConfirmation</a></span>
<span class="function">confirm_overwrite_callback</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">GtkFileChooser</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">chooser</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">gpointer</span><span class="normal"> data</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="type">char</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">uri</span><span class="symbol">;</span>
<div class="informalexample"><pre class="programlisting">
static GtkFileChooserConfirmation
confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
{
char *uri;
<span class="normal"> uri </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-get-uri">gtk_file_chooser_get_uri</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">);</span>
uri = gtk_file_chooser_get_uri (chooser);
<span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function">is_uri_read_only</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">uri</span><span class="symbol">))</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function">user_wants_to_replace_read_only_file</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">uri</span><span class="symbol">))</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> <a href="GtkFileChooser.html#GTK-FILE-CHOOSER-CONFIRMATION-ACCEPT-FILENAME:CAPS">GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME</a></span><span class="symbol">;</span>
<span class="normal"> </span><span class="keyword">else</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> <a href="GtkFileChooser.html#GTK-FILE-CHOOSER-CONFIRMATION-SELECT-AGAIN:CAPS">GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN</a></span><span class="symbol">;</span>
<span class="normal"> </span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> <a href="GtkFileChooser.html#GTK-FILE-CHOOSER-CONFIRMATION-CONFIRM:CAPS">GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM</a></span><span class="symbol">;</span><span class="normal"> </span><span class="comment">// fall back to the default dialog</span>
<span class="cbracket">}</span>
if (is_uri_read_only (uri))
{
if (user_wants_to_replace_read_only_file (uri))
return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
else
return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
} else
return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
}
<span class="symbol">...</span>
...
<span class="normal">chooser </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="GtkFileChooserDialog.html#gtk-file-chooser-dialog-new">gtk_file_chooser_dialog_new</a></span><span class="normal"> </span><span class="symbol">(...);</span>
chooser = gtk_file_chooser_dialog_new (...);
<span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-set-do-overwrite-confirmation">gtk_file_chooser_set_do_overwrite_confirmation</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">GTK_FILE_CHOOSER</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">dialog</span><span class="symbol">),</span><span class="normal"> TRUE</span><span class="symbol">);</span>
<span class="function">g_signal_connect</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"confirm-overwrite"</span><span class="symbol">,</span>
<span class="normal"> </span><span class="function">G_CALLBACK</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">confirm_overwrite_callback</span><span class="symbol">),</span><span class="normal"> NULL</span><span class="symbol">);</span>
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
g_signal_connect (chooser, "confirm-overwrite",
G_CALLBACK (confirm_overwrite_callback), NULL);
<span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="GtkDialog.html#gtk-dialog-run">gtk_dialog_run</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">==</span><span class="normal"> <a href="GtkDialog.html#GTK-RESPONSE-ACCEPT:CAPS">GTK_RESPONSE_ACCEPT</a></span><span class="symbol">)</span>
<span class="normal"> </span><span class="function">save_to_file</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="GtkFileChooser.html#gtk-file-chooser-get-filename">gtk_file_chooser_get_filename</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">GTK_FILE_CHOOSER</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">));</span>
<span class="function"><a href="GtkWidget.html#gtk-widget-destroy">gtk_widget_destroy</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">chooser</span><span class="symbol">);</span></pre></td>
</tr>
</tbody>
</table>
</div>
if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
gtk_widget_destroy (chooser);
</pre></div>
<p></p>
</div>
<div class="refsect3">
@ -3628,6 +3486,6 @@ chooser about whether the preview was generated successfully or not.</p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.27</div>
<hr>Generated by GTK-Doc V1.25</div>
</body>
</html>