]> Pileus Git - ~andy/gtk/blob - gtk/gtkappchooser.c
stylecontext: Do invalidation on first resize container
[~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 this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Authors: Cosimo Cecchi <ccecchi@redhat.com>
20  */
21
22 /**
23  * SECTION:gtkappchooser
24  * @Title: GtkAppChooser
25  * @Short_description: Interface implemented by widgets for choosing an application
26  * @See_also: #GAppInfo
27  *
28  * #GtkAppChooser is an interface that can be implemented by widgets which
29  * allow the user to choose an application (typically for the purpose of
30  * opening a file). The main objects that implement this interface are
31  * #GtkAppChooserWidget, #GtkAppChooserDialog and #GtkAppChooserButton.
32  *
33  * Applications are represented by GIO #GAppInfo objects here.
34  * GIO has a concept of recommended and fallback applications for a
35  * given content type. Recommended applications are those that claim
36  * to handle the content type itself, while fallback also includes
37  * applications that handle a more generic content type. GIO also
38  * knows the default and last-used application for a given content
39  * type. The #GtkAppChooserWidget provides detailed control over
40  * whether the shown list of applications should include default,
41  * recommended or fallback applications.
42  *
43  * To obtain the application that has been selected in a #GtkAppChooser,
44  * use gtk_app_chooser_get_app_info().
45  */
46
47 #include "config.h"
48
49 #include "gtkappchooser.h"
50
51 #include "gtkintl.h"
52 #include "gtkappchooserprivate.h"
53 #include "gtkwidget.h"
54
55 #include <glib.h>
56
57 G_DEFINE_INTERFACE (GtkAppChooser, gtk_app_chooser, GTK_TYPE_WIDGET);
58
59 static void
60 gtk_app_chooser_default_init (GtkAppChooserIface *iface)
61 {
62   GParamSpec *pspec;
63
64   /**
65    * GtkAppChooser:content-type:
66    *
67    * The content type of the #GtkAppChooser object.
68    *
69    * See <link linkend="gio-GContentType"><type>GContentType</type></link>
70    * for more information about content types.
71    */
72   pspec = g_param_spec_string ("content-type",
73                                P_("Content type"),
74                                P_("The content type used by the open with object"),
75                                NULL,
76                                G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
77                                G_PARAM_STATIC_STRINGS);
78   g_object_interface_install_property (iface, pspec);
79 }
80
81
82 /**
83  * gtk_app_chooser_get_content_type:
84  * @self: a #GtkAppChooser
85  *
86  * Returns the current value of the #GtkAppChooser:content-type property.
87  *
88  * Returns: the content type of @self. Free with g_free()
89  *
90  * Since: 3.0
91  */
92 gchar *
93 gtk_app_chooser_get_content_type (GtkAppChooser *self)
94 {
95   gchar *retval = NULL;
96
97   g_return_val_if_fail (GTK_IS_APP_CHOOSER (self), NULL);
98
99   g_object_get (self,
100                 "content-type", &retval,
101                 NULL);
102
103   return retval;
104 }
105
106 /**
107  * gtk_app_chooser_get_app_info:
108  * @self: a #GtkAppChooser
109  *
110  * Returns the currently selected application.
111  *
112  * Returns: (transfer full): a #GAppInfo for the currently selected
113  *     application, or %NULL if none is selected. Free with g_object_unref()
114  *
115  * Since: 3.0
116  */
117 GAppInfo *
118 gtk_app_chooser_get_app_info (GtkAppChooser *self)
119 {
120   return GTK_APP_CHOOSER_GET_IFACE (self)->get_app_info (self);
121 }
122
123 /**
124  * gtk_app_chooser_refresh:
125  * @self: a #GtkAppChooser
126  *
127  * Reloads the list of applications.
128  *
129  * Since: 3.0
130  */
131 void
132 gtk_app_chooser_refresh (GtkAppChooser *self)
133 {
134   GTK_APP_CHOOSER_GET_IFACE (self)->refresh (self);
135 }