]> Pileus Git - ~andy/gtk/blob - gtk/gtkappchooser.c
Merge branch 'master' into open-with-dialog
[~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 #include "config.h"
25
26 #include "gtkappchooser.h"
27
28 #include "gtkintl.h"
29 #include "gtkappchooserprivate.h"
30 #include "gtkwidget.h"
31
32 #include <glib.h>
33
34 G_DEFINE_INTERFACE (GtkAppChooser, gtk_app_chooser, GTK_TYPE_WIDGET);
35
36 static void
37 gtk_app_chooser_default_init (GtkAppChooserIface *iface)
38 {
39   GParamSpec *pspec;
40
41   /**
42    * GtkAppChooser:content-type:
43    *
44    * The content type of the #GtkAppChooser object.
45    */
46   pspec = g_param_spec_string ("content-type",
47                                P_("Content type"),
48                                P_("The content type used by the open with object"),
49                                NULL,
50                                G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
51                                G_PARAM_STATIC_STRINGS);
52   g_object_interface_install_property (iface, pspec);
53 }
54
55
56 /**
57  * gtk_app_chooser_get_content_type:
58  * @self: a #GtkAppChooser
59  *
60  * Returns the current value of the #GtkAppChooser:content-type property.
61  *
62  * Returns: the content type of @self. Free with g_free()
63  *
64  * Since: 3.0
65  */
66 gchar *
67 gtk_app_chooser_get_content_type (GtkAppChooser *self)
68 {
69   gchar *retval = NULL;
70
71   g_return_val_if_fail (GTK_IS_APP_CHOOSER (self), NULL);
72
73   g_object_get (self,
74                 "content-type", &retval,
75                 NULL);
76
77   return retval;
78 }
79
80 /**
81  * gtk_app_chooser_get_app_info:
82  * @self: a #GtkAppChooser
83  *
84  * Returns the currently selected application.
85  *
86  * Returns: (transfer full): a #GAppInfo for the currently selected
87  *     application, or %NULL if none is selected. Free with g_object_unref()
88  *
89  * Since: 3.0
90  */
91 GAppInfo *
92 gtk_app_chooser_get_app_info (GtkAppChooser *self)
93 {
94   return GTK_APP_CHOOSER_GET_IFACE (self)->get_app_info (self);
95 }
96
97 /**
98  * gtk_app_chooser_refresh:
99  * @self: a #GtkAppChooser
100  *
101  * Reloads the list of applications.
102  *
103  * Since: 3.0
104  */
105 void
106 gtk_app_chooser_refresh (GtkAppChooser *self)
107 {
108   GTK_APP_CHOOSER_GET_IFACE (self)->refresh (self);
109 }