Rename FoobarDetails to FoobarPrivate; that does the trick for gtk-doc
[mmediamanager.git] / libmmanager / mm-application.c
blobd4ff8f7a2a8dc98bdb89e5afc763b4c62b49f59d
1 /* MManager - a Desktop wide manager for multimedia applications.
3 * Copyright (C) 2008 Cosimo Cecchi <cosimoc@gnome.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #include <glib-object.h>
22 #include <glib.h>
24 #include "mm-application.h"
25 #include "mm-application-provider.h"
26 #include "mm-category-provider.h"
27 #include "mm-module-manager.h"
28 #include "mm-manager.h"
29 #include "mm-type-builtins.h"
31 #define MM_APPLICATION_GET_PRIVATE(o) \
32 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_APPLICATION, MMApplicationPrivate))
34 G_DEFINE_TYPE (MMApplication, mm_application, G_TYPE_OBJECT);
36 enum {
37 PROP_0,
38 PROP_SUPPORTED_TYPE
41 struct _MMApplicationPrivate {
42 GDesktopAppInfo *info;
43 char *id;
44 MMApplicationType supported_type;
47 static void
48 mm_application_finalize (GObject *o)
50 g_object_unref (MM_APPLICATION (o)->details->info);
51 g_free (MM_APPLICATION (o)->details->id);
53 G_OBJECT_CLASS (mm_application_parent_class)->finalize (o);
56 static void
57 mm_application_get_property (GObject *o,
58 guint prop_id,
59 GValue *value,
60 GParamSpec *pspec)
62 MMApplicationPrivate *details = MM_APPLICATION (o)->details;
64 switch (prop_id) {
65 case PROP_SUPPORTED_TYPE:
66 g_value_set_enum (value, details->supported_type);
67 break;
68 default:
69 break;
73 static void
74 mm_application_set_property (GObject *o,
75 guint prop_id,
76 const GValue *value,
77 GParamSpec *pspec)
79 MMApplicationPrivate *details = MM_APPLICATION (o)->details;
81 switch (prop_id) {
82 case PROP_SUPPORTED_TYPE:
83 details->supported_type = g_value_get_enum (value);
84 break;
85 default:
86 break;
90 static void
91 mm_application_class_init (MMApplicationClass *klass)
93 GObjectClass *oclass = G_OBJECT_CLASS (klass);
95 oclass->get_property = mm_application_get_property;
96 oclass->set_property = mm_application_set_property;
97 oclass->finalize = mm_application_finalize;
99 g_object_class_install_property (oclass,
100 PROP_SUPPORTED_TYPE,
101 g_param_spec_enum ("supported-type",
102 "Supported Type",
103 "Media type supported by the application",
104 MM_TYPE_MAPPLICATION_TYPE,
105 MM_APPLICATION_NONE,
106 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
108 g_type_class_add_private (klass, sizeof (MMApplicationPrivate));
111 static void
112 mm_application_init (MMApplication *a)
114 MMApplicationPrivate *details = a->details = MM_APPLICATION_GET_PRIVATE (a);
116 details->info = NULL;
117 details->supported_type = MM_APPLICATION_NONE;
120 /* public methods */
123 * mm_application_set_attributes:
124 * @application: a #MMApplication.
125 * @desktop_id: the desktop file identifier of the implementing application.
126 * @supported_type: the multimedia format supported by @application.
127 * @id: an unique identifier for @application, e.g. its name.
129 * Sets all the properties on @application to the specified values. This is
130 * useful only for implementations.
133 void
134 mm_application_set_attributes (MMApplication *application,
135 const char *desktop_id,
136 MMApplicationType supported_type,
137 const char *id)
139 g_object_set (application,
140 "supported-type", supported_type,
141 NULL);
143 application->details->info = g_desktop_app_info_new (desktop_id);
144 application->details->id = g_strdup (id);
148 * mm_application_get_app_info:
149 * @application: a #MMApplication.
151 * Gets the #GAppInfo object corresponding to @application.
153 * Return value: a #GAppInfo containing the information about @application.
156 GAppInfo *
157 mm_application_get_app_info (MMApplication *application)
159 g_return_val_if_fail (application != NULL, NULL);
160 g_return_val_if_fail (MM_IS_APPLICATION (application), NULL);
162 return g_object_ref (G_APP_INFO (application->details->info));
166 * mm_application_get_id:
167 * @application: a #MMApplication.
169 * Gets the unique identifier of @application.
171 * Return value: a string containing the unique identifier of @application.
174 const char *
175 mm_application_get_id (MMApplication *application)
177 g_return_val_if_fail (application != NULL, NULL);
178 g_return_val_if_fail (MM_IS_APPLICATION (application), NULL);
180 return application->details->id;
184 * mm_application_get_categories:
185 * @application: a #MMApplication.
186 * @error: a #GError.
188 * Gets a list of all the #MMCategory objects exposed by @application.
190 * Return value: a #GList of #MMCategory objects. Use #g_list_free when done.
193 GList *
194 mm_application_get_categories (MMApplication *application, GError **error)
196 g_return_val_if_fail (application != NULL, NULL);
197 g_return_val_if_fail (MM_IS_APPLICATION (application), NULL);
199 /* return NULL if we can't find the method in the subclass */
200 return (MM_APPLICATION_CLASS (G_OBJECT_GET_CLASS (application))->get_categories == NULL) ?
201 NULL : ((* MM_APPLICATION_CLASS (G_OBJECT_GET_CLASS (application))->get_categories)
202 (application, error));