4
4
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5
5
<title>Migrating from GtkFileSelection to GtkFileChooser</title>
6
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
6
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
7
7
<link rel="start" href="index.html" title="GTK+ Reference Manual">
8
8
<link rel="up" href="migrating.html" title="Part IV. Migrating from Previous Versions of GTK+">
9
9
<link rel="prev" href="gtk-changes-2-0.html" title="Changes from 1.2 to 2.0">
10
10
<link rel="next" href="gtkfilechooser-selection-modes.html" title="Selection Modes">
11
<meta name="generator" content="GTK-Doc V1.7 (XML mode)">
11
<meta name="generator" content="GTK-Doc V1.8 (XML mode)">
12
12
<link rel="stylesheet" href="style.css" type="text/css">
13
13
<link rel="part" href="gtk.html" title="Part I. GTK+ Overview">
14
14
<link rel="part" href="gtkbase.html" title="Part II. GTK+ Core Reference">
88
88
<dt><span class="section"><a href="gtkfilechooser-new-features.html">New features</a></span></dt>
91
<a href="GtkFileChooser.html" title="GtkFileChooser"><span class="type">GtkFileChooser</span></a>, starting with GTK+ 2.4, is the new set of APIs for file
92
selection widgets and dialogs. Previous versions of GTK+ used <a href="GtkFileSelection.html" title="GtkFileSelection"><span class="type">GtkFileSelection</span></a>,
91
<a class="link" href="GtkFileChooser.html" title="GtkFileChooser"><span class="type">GtkFileChooser</span></a>, starting with GTK+ 2.4, is the new set of APIs for file
92
selection widgets and dialogs. Previous versions of GTK+ used <a class="link" href="GtkFileSelection.html" title="GtkFileSelection"><span class="type">GtkFileSelection</span></a>,
93
93
which has numerous problems.
96
<a href="GtkFileChooser.html" title="GtkFileChooser"><span class="type">GtkFileChooser</span></a> is an abstract interface that can be implemented by widgets
96
<a class="link" href="GtkFileChooser.html" title="GtkFileChooser"><span class="type">GtkFileChooser</span></a> is an abstract interface that can be implemented by widgets
97
97
that perform file selection tasks. Two widgets in GTK+ implement this
98
interface: <a href="GtkFileChooserDialog.html" title="GtkFileChooserDialog"><span class="type">GtkFileChooserDialog</span></a> and <a href="GtkFileChooserWidget.html" title="GtkFileChooserWidget"><span class="type">GtkFileChooserWidget</span></a>. Most applications
99
simply need to use <a href="GtkFileChooserDialog.html" title="GtkFileChooserDialog"><span class="type">GtkFileChooserDialog</span></a>, which is a dialog box that allows the
98
interface: <a class="link" href="GtkFileChooserDialog.html" title="GtkFileChooserDialog"><span class="type">GtkFileChooserDialog</span></a> and <a class="link" href="GtkFileChooserWidget.html" title="GtkFileChooserWidget"><span class="type">GtkFileChooserWidget</span></a>. Most applications
99
simply need to use <a class="link" href="GtkFileChooserDialog.html" title="GtkFileChooserDialog"><span class="type">GtkFileChooserDialog</span></a>, which is a dialog box that allows the
100
100
user to select existing files for opening them, or to pick new filenames for
101
saving documents. <a href="GtkFileChooserWidget.html" title="GtkFileChooserWidget"><span class="type">GtkFileChooserWidget</span></a> is for special applications that need to
101
saving documents. <a class="link" href="GtkFileChooserWidget.html" title="GtkFileChooserWidget"><span class="type">GtkFileChooserWidget</span></a> is for special applications that need to
102
102
embed a file selection widget inside a larger window. In the context of GTK+,
103
<a href="GtkFileChooserDialog.html" title="GtkFileChooserDialog"><span class="type">GtkFileChooserDialog</span></a> is simply a <a href="GtkDialog.html" title="GtkDialog"><span class="type">GtkDialog</span></a> box with a <a href="GtkFileChooserWidget.html" title="GtkFileChooserWidget"><span class="type">GtkFileChooserWidget</span></a>.
103
<a class="link" href="GtkFileChooserDialog.html" title="GtkFileChooserDialog"><span class="type">GtkFileChooserDialog</span></a> is simply a <a class="link" href="GtkDialog.html" title="GtkDialog"><span class="type">GtkDialog</span></a> box with a <a class="link" href="GtkFileChooserWidget.html" title="GtkFileChooserWidget"><span class="type">GtkFileChooserWidget</span></a>.
106
106
<div class="section" lang="en">
107
107
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
108
108
<a name="gtkfilechooser-creating"></a>Creating a GtkFileChooserDialog</h2></div></div></div>
110
To create a <a href="GtkFileChooserDialog.html" title="GtkFileChooserDialog"><span class="type">GtkFileChooserDialog</span></a>, you simply call <a href="GtkFileChooserDialog.html#gtk-file-chooser-dialog-new"><code class="function">gtk_file_chooser_dialog_new()</code></a>.
111
This function is similar to <a href="GtkDialog.html#gtk-dialog-new"><code class="function">gtk_dialog_new()</code></a> in that it takes parameters for the
110
To create a <a class="link" href="GtkFileChooserDialog.html" title="GtkFileChooserDialog"><span class="type">GtkFileChooserDialog</span></a>, you simply call <a class="link" href="GtkFileChooserDialog.html#gtk-file-chooser-dialog-new"><code class="function">gtk_file_chooser_dialog_new()</code></a>.
111
This function is similar to <a class="link" href="GtkDialog.html#gtk-dialog-new"><code class="function">gtk_dialog_new()</code></a> in that it takes parameters for the
112
112
title of the dialog box and its transient parent, as well as its
113
113
buttons. In addition, it takes in an argument that determines
114
114
whether the file chooser dialog will be used for opening
115
115
existing files or for saving to a possibly new file.
118
Please see <a href="GtkFileChooserDialog.html#gtkfilechooser-typical-usage" title="Example 36. Typical usage">Example 36, “Typical usage”</a> for
118
Please see <a class="xref" href="GtkFileChooserDialog.html#gtkfilechooser-typical-usage" title="Example 36. Typical usage">Example 36, “Typical usage”</a> for
119
119
how to create a simple file chooser dialog and extract the
120
120
selected filename from it.