From 51a8dc6ff3d2d92dfe1e8fc99c73ec84e4948354 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 5 Sep 2011 21:16:23 +0200 Subject: plugin-manager: let it be initable Looking for plugins and loading them will be done during the object creation, so the operation may fail and we need to report it. --- src/mm-plugin-manager.c | 29 ++++++++++++++++++++++++++--- src/mm-plugin-manager.h | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mm-plugin-manager.c b/src/mm-plugin-manager.c index 6a32af84..e007887b 100644 --- a/src/mm-plugin-manager.c +++ b/src/mm-plugin-manager.c @@ -16,18 +16,27 @@ #include #include +#include + #include "mm-plugin-manager.h" -G_DEFINE_TYPE (MMPluginManager, mm_plugin_manager, G_TYPE_OBJECT); +static void initable_iface_init (GInitableIface *iface); + +G_DEFINE_TYPE_EXTENDED (MMPluginManager, mm_plugin_manager, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, + initable_iface_init)); struct _MMPluginManagerPrivate { gpointer dummy; }; MMPluginManager * -mm_plugin_manager_new (void) +mm_plugin_manager_new (GError **error) { - return g_object_new (MM_TYPE_PLUGIN_MANAGER, NULL); + return g_initable_new (MM_TYPE_PLUGIN_MANAGER, + NULL, + error, + NULL); } static void @@ -39,12 +48,26 @@ mm_plugin_manager_init (MMPluginManager *manager) MMPluginManagerPrivate); } +static gboolean +initable_init (GInitable *initable, + GCancellable *cancellable, + GError **error) +{ + return TRUE; +} + static void finalize (GObject *object) { G_OBJECT_CLASS (mm_plugin_manager_parent_class)->finalize (object); } +static void +initable_iface_init (GInitableIface *iface) +{ + iface->init = initable_init; +} + static void mm_plugin_manager_class_init (MMPluginManagerClass *manager_class) { diff --git a/src/mm-plugin-manager.h b/src/mm-plugin-manager.h index c70592da..906c7ef3 100644 --- a/src/mm-plugin-manager.h +++ b/src/mm-plugin-manager.h @@ -38,6 +38,6 @@ typedef struct { GType mm_plugin_manager_get_type (void); -MMPluginManager *mm_plugin_manager_new (void); +MMPluginManager *mm_plugin_manager_new (GError **error); #endif /* MM_PLUGIN_MANAGER_H */ -- cgit v1.2.3-70-g09d2