]> Pileus Git - ~andy/gtk/blob - gtk/gtkfilechooserdialog.c
gdk/x11: Add gdk_x11_device_manager_lookup()
[~andy/gtk] / gtk / gtkfilechooserdialog.c
1 /* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
2 /* GTK - The GIMP Toolkit
3  * gtkfilechooserdialog.c: File selector dialog
4  * Copyright (C) 2003, Red Hat, Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #include "config.h"
23
24 #include "gtkfilechooserdialog.h"
25
26 #include "gtkfilechooserprivate.h"
27 #include "gtkfilechooserwidget.h"
28 #include "gtkfilechooserutils.h"
29 #include "gtkfilechooserembed.h"
30 #include "gtkfilesystem.h"
31 #include "gtksizerequest.h"
32 #include "gtktypebuiltins.h"
33 #include "gtkintl.h"
34
35 #include <stdarg.h>
36
37
38 /**
39  * SECTION:gtkfilechooserdialog
40  * @Short_description: A file chooser dialog, suitable for "File/Open" or "File/Save" commands
41  * @Title: GtkFileChooserDialog
42  * @See_also: #GtkFileChooser, #GtkDialog
43  *
44  * #GtkFileChooserDialog is a dialog box suitable for use with
45  * "File/Open" or "File/Save as" commands.  This widget works by
46  * putting a #GtkFileChooserWidget inside a #GtkDialog.  It exposes
47  * the #GtkFileChooserIface interface, so you can use all of the
48  * #GtkFileChooser functions on the file chooser dialog as well as
49  * those for #GtkDialog.
50  *
51  * Note that #GtkFileChooserDialog does not have any methods of its
52  * own.  Instead, you should use the functions that work on a
53  * #GtkFileChooser.
54  *
55  * <example id="gtkfilechooser-typical-usage">
56  * <title>Typical usage</title>
57  * In the simplest of cases, you can the following code to use
58  * #GtkFileChooserDialog to select a file for opening:
59  * <para>
60  * <informalexample><programlisting>
61  * GtkWidget *dialog;
62  *
63  * dialog = gtk_file_chooser_dialog_new ("Open File",
64  *                                       parent_window,
65  *                                       GTK_FILE_CHOOSER_ACTION_OPEN,
66  *                                       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
67  *                                       GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
68  *                                       NULL);
69  *
70  * if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
71  *   {
72  *     char *filename;
73  *
74  *     filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
75  *     open_file (filename);
76  *     g_free (filename);
77  *   }
78  *
79  * gtk_widget_destroy (dialog);
80  * </programlisting></informalexample>
81  * </para>
82  * To use a dialog for saving, you can use this:
83  * <para>
84  * <informalexample><programlisting>
85  * GtkWidget *dialog;
86  *
87  * dialog = gtk_file_chooser_dialog_new ("Save File",
88  *                                       parent_window,
89  *                                       GTK_FILE_CHOOSER_ACTION_SAVE,
90  *                                       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
91  *                                       GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
92  *                                       NULL);
93  * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
94  *
95  * if (user_edited_a_new_document)
96  *   gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "Untitled document");
97  * else
98  *   gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), filename_for_existing_document);
99  *
100  * if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
101  *   {
102  *     char *filename;
103  *
104  *     filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
105  *     save_to_file (filename);
106  *     g_free (filename);
107  *   }
108  *
109  * gtk_widget_destroy (dialog);
110  * </programlisting></informalexample>
111  * </para>
112  * </example>
113  * <section id="gtkfilechooserdialog-setting-up">
114  * <title>Setting up a file chooser dialog</title>
115  * There are various cases in which you may need to use a #GtkFileChooserDialog:
116  * <itemizedlist>
117  *   <listitem>
118  *     <para>
119  *       To select a file for opening, as for a
120  *       <guimenuitem>File/Open</guimenuitem> command.  Use
121  *       #GTK_FILE_CHOOSER_ACTION_OPEN.
122  *     </para>
123  *   </listitem>
124  *
125  *   <listitem>
126  *     <para>
127  *       To save a file for the first time, as for a
128  *       <guimenuitem>File/Save</guimenuitem> command.  Use
129  *       #GTK_FILE_CHOOSER_ACTION_SAVE, and suggest a name such as
130  *       "Untitled" with gtk_file_chooser_set_current_name().
131  *     </para>
132  *   </listitem>
133  *
134  *   <listitem>
135  *     <para>
136  *       To save a file under a different name, as for a
137  *       <guimenuitem>File/Save As</guimenuitem> command.  Use
138  *       #GTK_FILE_CHOOSER_ACTION_SAVE, and set the existing filename
139  *       with gtk_file_chooser_set_filename().
140  *     </para>
141  *   </listitem>
142  *
143  *   <listitem>
144  *     <para>
145  *        To choose a folder instead of a file.  Use
146  *        #GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
147  *     </para>
148  *   </listitem>
149  * </itemizedlist>
150  * <note>
151  * <para>
152  * Old versions of the file chooser's documentation suggested
153  * using gtk_file_chooser_set_current_folder() in various
154  * situations, with the intention of letting the application
155  * suggest a reasonable default folder.  This is no longer
156  * considered to be a good policy, as now the file chooser is
157  * able to make good suggestions on its own.  In general, you
158  * should only cause the file chooser to show a specific folder
159  * when it is appropriate to use gtk_file_chooser_set_filename()
160  * - i.e. when you are doing a <guimenuitem>File/Save
161  * As</guimenuitem> command <emphasis>and</emphasis> you already
162  * have a file saved somewhere.
163  * </para>
164  * </note>
165  * </section>
166  * <section id="gtkfilechooserdialog-response-codes">
167  * <title>Response Codes</title>
168  * #GtkFileChooserDialog inherits from #GtkDialog, so buttons that
169  * go in its action area have response codes such as
170  * #GTK_RESPONSE_ACCEPT and #GTK_RESPONSE_CANCEL.  For example, you
171  * could call gtk_file_chooser_dialog_new() as follows:
172  * <para>
173  * <informalexample><programlisting>
174  * GtkWidget *dialog;
175  *
176  * dialog = gtk_file_chooser_dialog_new ("Open File",
177  *                                       parent_window,
178  *                                       GTK_FILE_CHOOSER_ACTION_OPEN,
179  *                                       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
180  *                                       GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
181  *                                       NULL);
182  * </programlisting></informalexample>
183  * </para>
184  * This will create buttons for "Cancel" and "Open" that use stock
185  * response identifiers from #GtkResponseType.  For most dialog
186  * boxes you can use your own custom response codes rather than the
187  * ones in #GtkResponseType, but #GtkFileChooserDialog assumes that
188  * its "accept"-type action, e.g. an "Open" or "Save" button,
189  * <emphasis>will</emphasis> have one of the following response
190  * codes:
191  * <para>
192  * <simplelist id="gtkfilechooserdialog-responses">
193  * <member>#GTK_RESPONSE_ACCEPT</member>
194  * <member>#GTK_RESPONSE_OK</member>
195  * <member>#GTK_RESPONSE_YES</member>
196  * <member>#GTK_RESPONSE_APPLY</member>
197  * </simplelist>
198  * </para>
199  * This is because #GtkFileChooserDialog must intercept responses
200  * and switch to folders if appropriate, rather than letting the
201  * dialog terminate &mdash; the implementation uses these known
202  * response codes to know which responses can be blocked if
203  * appropriate.
204  * <para>
205  * <note>
206  * To summarize, make sure you use a
207  * <link linkend="gtkfilechooserdialog-responses">stock response code</link>
208  * when you use #GtkFileChooserDialog to ensure proper operation.
209  * </note>
210  * </para>
211  * </section>
212  */
213
214
215 #define GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE(o)  (GTK_FILE_CHOOSER_DIALOG (o)->priv)
216
217 static void gtk_file_chooser_dialog_finalize   (GObject                   *object);
218
219 static GObject* gtk_file_chooser_dialog_constructor  (GType                  type,
220                                                       guint                  n_construct_properties,
221                                                       GObjectConstructParam *construct_params);
222 static void     gtk_file_chooser_dialog_set_property (GObject               *object,
223                                                       guint                  prop_id,
224                                                       const GValue          *value,
225                                                       GParamSpec            *pspec);
226 static void     gtk_file_chooser_dialog_get_property (GObject               *object,
227                                                       guint                  prop_id,
228                                                       GValue                *value,
229                                                       GParamSpec            *pspec);
230
231 static void     gtk_file_chooser_dialog_map          (GtkWidget             *widget);
232
233 static void response_cb (GtkDialog *dialog,
234                          gint       response_id);
235
236 G_DEFINE_TYPE_WITH_CODE (GtkFileChooserDialog, gtk_file_chooser_dialog, GTK_TYPE_DIALOG,
237                          G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER,
238                                                 _gtk_file_chooser_delegate_iface_init))
239
240 static void
241 gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class)
242 {
243   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
244   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
245
246   gobject_class->constructor = gtk_file_chooser_dialog_constructor;
247   gobject_class->set_property = gtk_file_chooser_dialog_set_property;
248   gobject_class->get_property = gtk_file_chooser_dialog_get_property;
249   gobject_class->finalize = gtk_file_chooser_dialog_finalize;
250
251   widget_class->map       = gtk_file_chooser_dialog_map;
252
253   _gtk_file_chooser_install_properties (gobject_class);
254
255   g_type_class_add_private (class, sizeof (GtkFileChooserDialogPrivate));
256 }
257
258 static void
259 gtk_file_chooser_dialog_init (GtkFileChooserDialog *dialog)
260 {
261   GtkWidget *action_area, *content_area;
262   GtkFileChooserDialogPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog,
263                                                                    GTK_TYPE_FILE_CHOOSER_DIALOG,
264                                                                    GtkFileChooserDialogPrivate);
265   GtkDialog *fc_dialog = GTK_DIALOG (dialog);
266
267   dialog->priv = priv;
268   dialog->priv->response_requested = FALSE;
269
270   content_area = gtk_dialog_get_content_area (fc_dialog);
271   action_area = gtk_dialog_get_action_area (fc_dialog);
272
273   gtk_container_set_border_width (GTK_CONTAINER (fc_dialog), 5);
274   gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
275   gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
276
277   /* We do a signal connection here rather than overriding the method in
278    * class_init because GtkDialog::response is a RUN_LAST signal.  We want *our*
279    * handler to be run *first*, regardless of whether the user installs response
280    * handlers of his own.
281    */
282   g_signal_connect (dialog, "response",
283                     G_CALLBACK (response_cb), NULL);
284 }
285
286 static void
287 gtk_file_chooser_dialog_finalize (GObject *object)
288 {
289   GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (object);
290
291   g_free (dialog->priv->file_system);
292
293   G_OBJECT_CLASS (gtk_file_chooser_dialog_parent_class)->finalize (object);  
294 }
295
296 static gboolean
297 is_stock_accept_response_id (int response_id)
298 {
299   return (response_id == GTK_RESPONSE_ACCEPT
300           || response_id == GTK_RESPONSE_OK
301           || response_id == GTK_RESPONSE_YES
302           || response_id == GTK_RESPONSE_APPLY);
303 }
304
305 /* Callback used when the user activates a file in the file chooser widget */
306 static void
307 file_chooser_widget_file_activated (GtkFileChooser       *chooser,
308                                     GtkFileChooserDialog *dialog)
309 {
310   GtkDialog *fc_dialog = GTK_DIALOG (dialog);
311   GtkWidget *action_area;
312   GList *children, *l;
313
314   if (gtk_window_activate_default (GTK_WINDOW (dialog)))
315     return;
316
317   /* There probably isn't a default widget, so make things easier for the
318    * programmer by looking for a reasonable button on our own.
319    */
320   action_area = gtk_dialog_get_action_area (fc_dialog);
321   children = gtk_container_get_children (GTK_CONTAINER (action_area));
322
323   for (l = children; l; l = l->next)
324     {
325       GtkWidget *widget;
326       int response_id;
327
328       widget = GTK_WIDGET (l->data);
329       response_id = gtk_dialog_get_response_for_widget (fc_dialog, widget);
330       if (gtk_widget_is_sensitive (widget) &&
331           is_stock_accept_response_id (response_id))
332         {
333           gtk_widget_activate (widget); /* Should we gtk_dialog_response (dialog, response_id) instead? */
334           break;
335         }
336     }
337
338   g_list_free (children);
339 }
340
341 #if 0
342 /* FIXME: to see why this function is ifdef-ed out, see the comment below in
343  * file_chooser_widget_default_size_changed().
344  */
345 static void
346 load_position (int *out_xpos, int *out_ypos)
347 {
348   GtkFileChooserSettings *settings;
349   int x, y, width, height;
350
351   settings = _gtk_file_chooser_settings_new ();
352   _gtk_file_chooser_settings_get_geometry (settings, &x, &y, &width, &height);
353   g_object_unref (settings);
354
355   *out_xpos = x;
356   *out_ypos = y;
357 }
358 #endif
359
360 static void
361 file_chooser_widget_default_size_changed (GtkWidget            *widget,
362                                           GtkFileChooserDialog *dialog)
363 {
364   GtkFileChooserDialogPrivate *priv;
365   gint default_width, default_height;
366   GtkRequisition req, widget_req;
367
368   priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
369
370   /* Unset any previously set size */
371   gtk_widget_set_size_request (GTK_WIDGET (dialog), -1, -1);
372
373   if (gtk_widget_is_drawable (widget))
374     {
375       /* Force a size request of everything before we start.  This will make sure
376        * that widget->requisition is meaningful. */
377       gtk_widget_get_preferred_size (GTK_WIDGET (dialog),
378                                      &req, NULL);
379       gtk_widget_get_preferred_size (widget,
380                                      &widget_req, NULL);
381     }
382
383   _gtk_file_chooser_embed_get_default_size (GTK_FILE_CHOOSER_EMBED (priv->widget),
384                                             &default_width, &default_height);
385
386   gtk_window_resize (GTK_WINDOW (dialog), default_width, default_height);
387
388   if (!gtk_widget_get_mapped (GTK_WIDGET (dialog)))
389     {
390 #if 0
391       /* FIXME: the code to restore the position does not work yet.  It is not
392        * clear whether it is actually desirable --- if enabled, applications
393        * would not be able to say "center the file chooser on top of my toplevel
394        * window".  So, we don't use this code at all.
395        */
396       load_position (&xpos, &ypos);
397       if (xpos >= 0 && ypos >= 0)
398         {
399           gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_NONE);
400           gtk_window_move (GTK_WINDOW (dialog), xpos, ypos);
401         }
402 #endif
403     }
404 }
405
406 static void
407 file_chooser_widget_response_requested (GtkWidget            *widget,
408                                         GtkFileChooserDialog *dialog)
409 {
410   GtkDialog *fc_dialog = GTK_DIALOG (dialog);
411   GtkWidget *action_area;
412   GList *children, *l;
413
414   dialog->priv->response_requested = TRUE;
415
416   if (gtk_window_activate_default (GTK_WINDOW (dialog)))
417     return;
418
419   /* There probably isn't a default widget, so make things easier for the
420    * programmer by looking for a reasonable button on our own.
421    */
422   action_area = gtk_dialog_get_action_area (fc_dialog);
423   children = gtk_container_get_children (GTK_CONTAINER (action_area));
424
425   for (l = children; l; l = l->next)
426     {
427       GtkWidget *widget;
428       int response_id;
429
430       widget = GTK_WIDGET (l->data);
431       response_id = gtk_dialog_get_response_for_widget (fc_dialog, widget);
432       if (gtk_widget_is_sensitive (widget) &&
433           is_stock_accept_response_id (response_id))
434         {
435           gtk_widget_activate (widget); /* Should we gtk_dialog_response (dialog, response_id) instead? */
436           break;
437         }
438     }
439
440   if (l == NULL)
441     dialog->priv->response_requested = FALSE;
442
443   g_list_free (children);
444 }
445   
446 static GObject*
447 gtk_file_chooser_dialog_constructor (GType                  type,
448                                      guint                  n_construct_properties,
449                                      GObjectConstructParam *construct_params)
450 {
451   GtkFileChooserDialogPrivate *priv;
452   GtkWidget *content_area;
453   GObject *object;
454
455   object = G_OBJECT_CLASS (gtk_file_chooser_dialog_parent_class)->constructor (type,
456                                                                                n_construct_properties,
457                                                                                construct_params);
458   priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (object);
459
460   gtk_widget_push_composite_child ();
461
462   if (priv->file_system)
463     priv->widget = g_object_new (GTK_TYPE_FILE_CHOOSER_WIDGET,
464                                  NULL);
465   else
466     priv->widget = g_object_new (GTK_TYPE_FILE_CHOOSER_WIDGET, NULL);
467
468   g_signal_connect (priv->widget, "file-activated",
469                     G_CALLBACK (file_chooser_widget_file_activated), object);
470   g_signal_connect (priv->widget, "default-size-changed",
471                     G_CALLBACK (file_chooser_widget_default_size_changed), object);
472   g_signal_connect (priv->widget, "response-requested",
473                     G_CALLBACK (file_chooser_widget_response_requested), object);
474
475   content_area = gtk_dialog_get_content_area (GTK_DIALOG (object));
476
477   gtk_container_set_border_width (GTK_CONTAINER (priv->widget), 5);
478   gtk_box_pack_start (GTK_BOX (content_area), priv->widget, TRUE, TRUE, 0);
479
480   gtk_widget_show (priv->widget);
481
482   _gtk_file_chooser_set_delegate (GTK_FILE_CHOOSER (object),
483                                   GTK_FILE_CHOOSER (priv->widget));
484
485   gtk_widget_pop_composite_child ();
486
487   return object;
488 }
489
490 static void
491 gtk_file_chooser_dialog_set_property (GObject         *object,
492                                       guint            prop_id,
493                                       const GValue    *value,
494                                       GParamSpec      *pspec)
495
496 {
497   GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (object);
498
499   switch (prop_id)
500     {
501     default:
502       g_object_set_property (G_OBJECT (priv->widget), pspec->name, value);
503       break;
504     }
505 }
506
507 static void
508 gtk_file_chooser_dialog_get_property (GObject         *object,
509                                       guint            prop_id,
510                                       GValue          *value,
511                                       GParamSpec      *pspec)
512 {
513   GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (object);
514
515   g_object_get_property (G_OBJECT (priv->widget), pspec->name, value);
516 }
517
518 static void
519 foreach_ensure_default_response_cb (GtkWidget *widget,
520                                     gpointer   data)
521 {
522   GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (data);
523   int response_id;
524
525   response_id = gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), widget);
526   if (is_stock_accept_response_id (response_id))
527     gtk_dialog_set_default_response (GTK_DIALOG (dialog), response_id);
528 }
529
530 static void
531 ensure_default_response (GtkFileChooserDialog *dialog)
532 {
533   GtkWidget *action_area;
534
535   action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
536   gtk_container_foreach (GTK_CONTAINER (action_area),
537                          foreach_ensure_default_response_cb,
538                          dialog);
539 }
540
541 /* GtkWidget::map handler */
542 static void
543 gtk_file_chooser_dialog_map (GtkWidget *widget)
544 {
545   GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget);
546   GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
547
548   ensure_default_response (dialog);
549
550   _gtk_file_chooser_embed_initial_focus (GTK_FILE_CHOOSER_EMBED (priv->widget));
551
552   GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->map (widget);
553 }
554
555 /* GtkDialog::response handler */
556 static void
557 response_cb (GtkDialog *dialog,
558              gint       response_id)
559 {
560   GtkFileChooserDialogPrivate *priv;
561
562   priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
563
564   /* Act only on response IDs we recognize */
565   if (is_stock_accept_response_id (response_id)
566       && !priv->response_requested
567       && !_gtk_file_chooser_embed_should_respond (GTK_FILE_CHOOSER_EMBED (priv->widget)))
568     {
569       g_signal_stop_emission_by_name (dialog, "response");
570     }
571
572   priv->response_requested = FALSE;
573 }
574
575 static GtkWidget *
576 gtk_file_chooser_dialog_new_valist (const gchar          *title,
577                                     GtkWindow            *parent,
578                                     GtkFileChooserAction  action,
579                                     const gchar          *first_button_text,
580                                     va_list               varargs)
581 {
582   GtkWidget *result;
583   const char *button_text = first_button_text;
584   gint response_id;
585
586   result = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
587                          "title", title,
588                          "action", action,
589                          NULL);
590
591   if (parent)
592     gtk_window_set_transient_for (GTK_WINDOW (result), parent);
593
594   while (button_text)
595     {
596       response_id = va_arg (varargs, gint);
597       gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id);
598       button_text = va_arg (varargs, const gchar *);
599     }
600
601   return result;
602 }
603
604 /**
605  * gtk_file_chooser_dialog_new:
606  * @title: (allow-none): Title of the dialog, or %NULL
607  * @parent: (allow-none): Transient parent of the dialog, or %NULL
608  * @action: Open or save mode for the dialog
609  * @first_button_text: (allow-none): stock ID or text to go in the first button, or %NULL
610  * @Varargs: response ID for the first button, then additional (button, id) pairs, ending with %NULL
611  *
612  * Creates a new #GtkFileChooserDialog.  This function is analogous to
613  * gtk_dialog_new_with_buttons().
614  *
615  * Return value: a new #GtkFileChooserDialog
616  *
617  * Since: 2.4
618  **/
619 GtkWidget *
620 gtk_file_chooser_dialog_new (const gchar         *title,
621                              GtkWindow           *parent,
622                              GtkFileChooserAction action,
623                              const gchar         *first_button_text,
624                              ...)
625 {
626   GtkWidget *result;
627   va_list varargs;
628   
629   va_start (varargs, first_button_text);
630   result = gtk_file_chooser_dialog_new_valist (title, parent, action,
631                                                first_button_text,
632                                                varargs);
633   va_end (varargs);
634
635   return result;
636 }