1 /* GTK - The GIMP Toolkit
2 * gtkfilechooserwidget.c: Embeddable file selector widget
3 * Copyright (C) 2003, Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 #include "gtkfilechooserprivate.h"
24 #include "gtkfilechooserwidget.h"
25 #include "gtkfilechooserdefault.h"
26 #include "gtkfilechooserutils.h"
27 #include "gtktypebuiltins.h"
28 #include "gtkfilechooserembed.h"
29 #include "gtkorientable.h"
34 * SECTION:gtkfilechooserwidget
35 * @Short_description: File chooser widget that can be embedded in other widgets
36 * @Title: GtkFileChooserWidget
37 * @See_also: #GtkFileChooser, #GtkFileChooserDialog
39 * #GtkFileChooserWidget is a widget suitable for selecting files.
40 * It is the main building block of a #GtkFileChooserDialog. Most
41 * applications will only need to use the latter; you can use
42 * #GtkFileChooserWidget as part of a larger window if you have
45 * Note that #GtkFileChooserWidget does not have any methods of its
46 * own. Instead, you should use the functions that work on a
51 #define GTK_FILE_CHOOSER_WIDGET_GET_PRIVATE(o) (GTK_FILE_CHOOSER_WIDGET (o)->priv)
53 static void gtk_file_chooser_widget_finalize (GObject *object);
55 static GObject* gtk_file_chooser_widget_constructor (GType type,
56 guint n_construct_properties,
57 GObjectConstructParam *construct_params);
58 static void gtk_file_chooser_widget_set_property (GObject *object,
62 static void gtk_file_chooser_widget_get_property (GObject *object,
67 G_DEFINE_TYPE_WITH_CODE (GtkFileChooserWidget, gtk_file_chooser_widget, GTK_TYPE_BOX,
68 G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER,
69 _gtk_file_chooser_delegate_iface_init)
70 G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER_EMBED,
71 _gtk_file_chooser_embed_delegate_iface_init))
74 gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
76 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
78 gobject_class->constructor = gtk_file_chooser_widget_constructor;
79 gobject_class->set_property = gtk_file_chooser_widget_set_property;
80 gobject_class->get_property = gtk_file_chooser_widget_get_property;
81 gobject_class->finalize = gtk_file_chooser_widget_finalize;
83 _gtk_file_chooser_install_properties (gobject_class);
85 g_type_class_add_private (class, sizeof (GtkFileChooserWidgetPrivate));
89 gtk_file_chooser_widget_init (GtkFileChooserWidget *chooser_widget)
91 GtkFileChooserWidgetPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser_widget,
92 GTK_TYPE_FILE_CHOOSER_WIDGET,
93 GtkFileChooserWidgetPrivate);
94 chooser_widget->priv = priv;
95 gtk_orientable_set_orientation (GTK_ORIENTABLE (chooser_widget),
96 GTK_ORIENTATION_VERTICAL);
100 gtk_file_chooser_widget_finalize (GObject *object)
102 GtkFileChooserWidget *chooser = GTK_FILE_CHOOSER_WIDGET (object);
104 g_free (chooser->priv->file_system);
106 G_OBJECT_CLASS (gtk_file_chooser_widget_parent_class)->finalize (object);
110 gtk_file_chooser_widget_constructor (GType type,
111 guint n_construct_properties,
112 GObjectConstructParam *construct_params)
114 GtkFileChooserWidgetPrivate *priv;
117 object = G_OBJECT_CLASS (gtk_file_chooser_widget_parent_class)->constructor (type,
118 n_construct_properties,
120 priv = GTK_FILE_CHOOSER_WIDGET_GET_PRIVATE (object);
122 gtk_widget_push_composite_child ();
124 priv->impl = _gtk_file_chooser_default_new ();
126 gtk_box_pack_start (GTK_BOX (object), priv->impl, TRUE, TRUE, 0);
127 gtk_widget_show (priv->impl);
129 _gtk_file_chooser_set_delegate (GTK_FILE_CHOOSER (object),
130 GTK_FILE_CHOOSER (priv->impl));
132 _gtk_file_chooser_embed_set_delegate (GTK_FILE_CHOOSER_EMBED (object),
133 GTK_FILE_CHOOSER_EMBED (priv->impl));
135 gtk_widget_pop_composite_child ();
141 gtk_file_chooser_widget_set_property (GObject *object,
146 GtkFileChooserWidgetPrivate *priv = GTK_FILE_CHOOSER_WIDGET_GET_PRIVATE (object);
151 g_object_set_property (G_OBJECT (priv->impl), pspec->name, value);
157 gtk_file_chooser_widget_get_property (GObject *object,
162 GtkFileChooserWidgetPrivate *priv = GTK_FILE_CHOOSER_WIDGET_GET_PRIVATE (object);
164 g_object_get_property (G_OBJECT (priv->impl), pspec->name, value);
168 * gtk_file_chooser_widget_new:
169 * @action: Open or save mode for the widget
171 * Creates a new #GtkFileChooserWidget. This is a file chooser widget that can
172 * be embedded in custom windows, and it is the same widget that is used by
173 * #GtkFileChooserDialog.
175 * Return value: a new #GtkFileChooserWidget
180 gtk_file_chooser_widget_new (GtkFileChooserAction action)
182 return g_object_new (GTK_TYPE_FILE_CHOOSER_WIDGET,