]> Pileus Git - ~andy/gtk/blob - gtk/gtkappchooser.c
Merge branch 'bgo593793-filechooser-recent-folders-master'
[~andy/gtk] / gtk / gtkappchooser.c
1 /*
2  * gtkappchooser.c: app-chooser interface
3  *
4  * Copyright (C) 2010 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 Library General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * 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  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with the Gnome Library; see the file COPYING.LIB.  If not,
18  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  * Authors: Cosimo Cecchi <ccecchi@redhat.com>
22  */
23
24 /**
25  * SECTION:gtkappchooser
26  * @Title: GtkAppChooser
27  * @Short_description: Interface implemented by widgets for choosing an application
28  *
29  * #GtkAppChooser is an interface that can be implemented by widgets which
30  * allow the user to choose an application (typically for the purpose of
31  * opening a file). The main objects that implement this interface are
32  * #GtkAppChooserWidget, #GtkAppChooserDialog and #GtkAppChooserButton.
33  */
34
35 #include "config.h"
36
37 #include "gtkappchooser.h"
38
39 #include "gtkintl.h"
40 #include "gtkappchooserprivate.h"
41 #include "gtkwidget.h"
42
43 #include <glib.h>
44
45 G_DEFINE_INTERFACE (GtkAppChooser, gtk_app_chooser, GTK_TYPE_WIDGET);
46
47 static void
48 gtk_app_chooser_default_init (GtkAppChooserIface *iface)
49 {
50   GParamSpec *pspec;
51
52   /**
53    * GtkAppChooser:content-type:
54    *
55    * The content type of the #GtkAppChooser object.
56    *
57    * See <link linkend="gio-GContentType"><type>GContentType</type></link>
58    * for more information about content types.
59    */
60   pspec = g_param_spec_string ("content-type",
61                                P_("Content type"),
62                                P_("The content type used by the open with object"),
63                                NULL,
64                                G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
65                                G_PARAM_STATIC_STRINGS);
66   g_object_interface_install_property (iface, pspec);
67 }
68
69
70 /**
71  * gtk_app_chooser_get_content_type:
72  * @self: a #GtkAppChooser
73  *
74  * Returns the current value of the #GtkAppChooser:content-type property.
75  *
76  * Returns: the content type of @self. Free with g_free()
77  *
78  * Since: 3.0
79  */
80 gchar *
81 gtk_app_chooser_get_content_type (GtkAppChooser *self)
82 {
83   gchar *retval = NULL;
84
85   g_return_val_if_fail (GTK_IS_APP_CHOOSER (self), NULL);
86
87   g_object_get (self,
88                 "content-type", &retval,
89                 NULL);
90
91   return retval;
92 }
93
94 /**
95  * gtk_app_chooser_get_app_info:
96  * @self: a #GtkAppChooser
97  *
98  * Returns the currently selected application.
99  *
100  * Returns: (transfer full): a #GAppInfo for the currently selected
101  *     application, or %NULL if none is selected. Free with g_object_unref()
102  *
103  * Since: 3.0
104  */
105 GAppInfo *
106 gtk_app_chooser_get_app_info (GtkAppChooser *self)
107 {
108   return GTK_APP_CHOOSER_GET_IFACE (self)->get_app_info (self);
109 }
110
111 /**
112  * gtk_app_chooser_refresh:
113  * @self: a #GtkAppChooser
114  *
115  * Reloads the list of applications.
116  *
117  * Since: 3.0
118  */
119 void
120 gtk_app_chooser_refresh (GtkAppChooser *self)
121 {
122   GTK_APP_CHOOSER_GET_IFACE (self)->refresh (self);
123 }