]> Pileus Git - ~andy/gtk/blob - gtk/gtkappchooseronline.c
app-chooser: rename GtkOpenWith to GtkAppChooser
[~andy/gtk] / gtk / gtkappchooseronline.c
1 /*
2  * gtkappchooseronline.h: an extension point for online integration
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 "gtkappchooseronline.h"
27
28 #include "gtkappchooseronlinedummy.h"
29 #include "gtkappchoosermodule.h"
30
31 #include <gio/gio.h>
32
33 G_DEFINE_INTERFACE (GtkAppChooserOnline, gtk_app_chooser_online, G_TYPE_OBJECT);
34
35 static void
36 gtk_app_chooser_online_default_init (GtkAppChooserOnlineInterface *iface)
37 {
38   /* do nothing */
39 }
40
41 GtkAppChooserOnline *
42 gtk_app_chooser_online_get_default (void)
43 {
44   GIOExtensionPoint *ep;
45   GIOExtension *extension;
46   GList *extensions;
47   GtkAppChooserOnline *retval;
48
49   _gtk_app_chooser_module_ensure ();
50
51   ep = g_io_extension_point_lookup ("gtkappchooser-online");
52   extensions = g_io_extension_point_get_extensions (ep);
53
54   if (extensions != NULL)
55     {
56       /* pick the first */
57       extension = extensions->data;
58       retval = g_object_new (g_io_extension_get_type (extension),
59                              NULL);
60     }
61   else
62     {
63       retval = g_object_new (GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY,
64                              NULL);
65     }
66
67   return retval;
68 }
69
70 void
71 gtk_app_chooser_online_search_for_mimetype_async (GtkAppChooserOnline *self,
72                                                   const gchar *content_type,
73                                                   GtkWindow *parent,
74                                                   GAsyncReadyCallback callback,
75                                                   gpointer user_data)
76 {
77   GtkAppChooserOnlineInterface *iface;
78
79   g_return_if_fail (GTK_IS_APP_CHOOSER_ONLINE (self));
80
81   iface = GTK_APP_CHOOSER_ONLINE_GET_IFACE (self);
82
83   (* iface->search_for_mimetype_async) (self, content_type, parent, callback, user_data);
84 }
85
86 gboolean
87 gtk_app_chooser_online_search_for_mimetype_finish (GtkAppChooserOnline *self,
88                                                    GAsyncResult *res,
89                                                    GError **error)
90 {
91   GtkAppChooserOnlineInterface *iface;
92
93   g_return_val_if_fail (GTK_IS_APP_CHOOSER_ONLINE (self), FALSE);
94
95   iface = GTK_APP_CHOOSER_ONLINE_GET_IFACE (self);
96
97   return ((* iface->search_for_mimetype_finish) (self, res, error));
98 }