2 * gtkappchooser.c: app-chooser interface
4 * Copyright (C) 2010 Red Hat, Inc.
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.
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.
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.
21 * Authors: Cosimo Cecchi <ccecchi@redhat.com>
25 * SECTION:gtkappchooser
26 * @Title: GtkAppChooser
27 * @Short_description: Interface implemented by widgets for choosing an application
28 * @See_also: #GAppInfo
30 * #GtkAppChooser is an interface that can be implemented by widgets which
31 * allow the user to choose an application (typically for the purpose of
32 * opening a file). The main objects that implement this interface are
33 * #GtkAppChooserWidget, #GtkAppChooserDialog and #GtkAppChooserButton.
35 * Applications are represented by GIO #GAppInfo objects here.
36 * GIO has a concept of recommended and fallback applications for a
37 * given content type. Recommended applications are those that claim
38 * to handle the content type itself, while fallback also includes
39 * applications that handle a more generic content type. GIO also
40 * knows the default and last-used application for a given content
41 * type. The #GtkAppChooserWidget provides detailed control over
42 * whether the shown list of applications should include default,
43 * recommended or fallback applications.
45 * To obtain the application that has been selected in a #GtkAppChooser,
46 * use gtk_app_chooser_get_app_info().
51 #include "gtkappchooser.h"
54 #include "gtkappchooserprivate.h"
55 #include "gtkwidget.h"
59 G_DEFINE_INTERFACE (GtkAppChooser, gtk_app_chooser, GTK_TYPE_WIDGET);
62 gtk_app_chooser_default_init (GtkAppChooserIface *iface)
67 * GtkAppChooser:content-type:
69 * The content type of the #GtkAppChooser object.
71 * See <link linkend="gio-GContentType"><type>GContentType</type></link>
72 * for more information about content types.
74 pspec = g_param_spec_string ("content-type",
76 P_("The content type used by the open with object"),
78 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
79 G_PARAM_STATIC_STRINGS);
80 g_object_interface_install_property (iface, pspec);
85 * gtk_app_chooser_get_content_type:
86 * @self: a #GtkAppChooser
88 * Returns the current value of the #GtkAppChooser:content-type property.
90 * Returns: the content type of @self. Free with g_free()
95 gtk_app_chooser_get_content_type (GtkAppChooser *self)
99 g_return_val_if_fail (GTK_IS_APP_CHOOSER (self), NULL);
102 "content-type", &retval,
109 * gtk_app_chooser_get_app_info:
110 * @self: a #GtkAppChooser
112 * Returns the currently selected application.
114 * Returns: (transfer full): a #GAppInfo for the currently selected
115 * application, or %NULL if none is selected. Free with g_object_unref()
120 gtk_app_chooser_get_app_info (GtkAppChooser *self)
122 return GTK_APP_CHOOSER_GET_IFACE (self)->get_app_info (self);
126 * gtk_app_chooser_refresh:
127 * @self: a #GtkAppChooser
129 * Reloads the list of applications.
134 gtk_app_chooser_refresh (GtkAppChooser *self)
136 GTK_APP_CHOOSER_GET_IFACE (self)->refresh (self);