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>
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, MMApplicationDetails))
34 G_DEFINE_TYPE (MMApplication
, mm_application
, G_TYPE_OBJECT
);
41 struct _MMApplicationDetails
{
42 GDesktopAppInfo
*info
;
44 MMApplicationType supported_type
;
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
);
57 mm_application_get_property (GObject
*o
,
62 MMApplicationDetails
*details
= MM_APPLICATION (o
)->details
;
65 case PROP_SUPPORTED_TYPE
:
66 g_value_set_enum (value
, details
->supported_type
);
74 mm_application_set_property (GObject
*o
,
79 MMApplicationDetails
*details
= MM_APPLICATION (o
)->details
;
82 case PROP_SUPPORTED_TYPE
:
83 details
->supported_type
= g_value_get_enum (value
);
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
,
101 g_param_spec_enum ("supported-type",
103 "Media type supported by the application",
104 MM_TYPE_MAPPLICATION_TYPE
,
106 G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS
));
108 g_type_class_add_private (klass
, sizeof (MMApplicationDetails
));
112 mm_application_init (MMApplication
*a
)
114 MMApplicationDetails
*details
= a
->details
= MM_APPLICATION_GET_PRIVATE (a
);
116 details
->info
= NULL
;
117 details
->supported_type
= MM_APPLICATION_NONE
;
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.
134 mm_application_set_attributes (MMApplication
*application
,
135 const char *desktop_id
,
136 MMApplicationType supported_type
,
139 g_object_set (application
,
140 "supported-type", supported_type
,
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 * @a: a #MMApplication.
151 * Gets the #GAppInfo object corresponding to @a.
153 * Return value: a #GAppInfo containing the information about @a.
157 mm_application_get_app_info (MMApplication
*a
)
159 g_return_val_if_fail (a
!= NULL
, NULL
);
160 g_return_val_if_fail (MM_IS_APPLICATION (a
), NULL
);
162 return g_object_ref (G_APP_INFO (a
->details
->info
));
166 * mm_application_get_id:
167 * @a: a #MMApplication.
169 * Gets the unique identifier of @a.
171 * Return value: a string containing the unique identifier of @a.
175 mm_application_get_id (MMApplication
*a
)
177 g_return_val_if_fail (a
!= NULL
, NULL
);
178 g_return_val_if_fail (MM_IS_APPLICATION (a
), NULL
);
180 return a
->details
->id
;
184 * mm_application_get_categories:
185 * @a: a #MMApplication.
188 * Gets a list of all the #MMCategory objects exposed by @a.
190 * Return value: a #GList of #MMCategory objects. Use #g_list_free when done.
194 mm_application_get_categories (MMApplication
*a
, GError
**error
)
196 g_return_val_if_fail (a
!= NULL
, NULL
);
197 g_return_val_if_fail (MM_IS_APPLICATION (a
), NULL
);
199 /* return NULL if we can't find the method in the subclass */
200 return (MM_APPLICATION_CLASS (G_OBJECT_GET_CLASS (a
))->get_categories
== NULL
) ?
201 NULL
: ((* MM_APPLICATION_CLASS (G_OBJECT_GET_CLASS (a
))->get_categories
) (a
, error
));