summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2013-03-13 18:07:21 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2013-03-13 18:07:21 +0100
commitca1a74cafa8f75a20e42bbdf501f5c8e8f184920 (patch)
treef4e99bbc93abad34e24f7db89d786adb8fbfc834 /src
parent0c2a3b8d2f35ccc4dc67616e430df7fb72cb5e62 (diff)
downloadlibuca-ca1a74cafa8f75a20e42bbdf501f5c8e8f184920.tar.gz
libuca-ca1a74cafa8f75a20e42bbdf501f5c8e8f184920.tar.bz2
libuca-ca1a74cafa8f75a20e42bbdf501f5c8e8f184920.tar.xz
libuca-ca1a74cafa8f75a20e42bbdf501f5c8e8f184920.zip
Use GInitable to pass properties to plugins
Diffstat (limited to 'src')
-rw-r--r--src/uca-plugin-manager.c27
-rw-r--r--src/uca-plugin-manager.h4
2 files changed, 22 insertions, 9 deletions
diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c
index e99f478..e1bfb9e 100644
--- a/src/uca-plugin-manager.c
+++ b/src/uca-plugin-manager.c
@@ -32,6 +32,7 @@
*
* @Since: 1.1
*/
+#include <gio/gio.h>
#include <gmodule.h>
#include "uca-plugin-manager.h"
@@ -45,7 +46,7 @@ struct _UcaPluginManagerPrivate {
static const gchar *MODULE_PATTERN = "libuca([A-Za-z]+)";
-typedef UcaCamera * (*GetCameraFunc) (GError **error);
+typedef GType (*GetTypeFunc) (void);
/**
* UcaPluginManagerError:
@@ -217,20 +218,25 @@ find_camera_module_path (GList *search_paths, const gchar *name)
* Create a new camera instance with camera @name.
*
* Returns: (transfer full): A new #UcaCamera object.
+ * @Since: 1.2: Pass construction properties.
*/
UcaCamera *
-uca_plugin_manager_get_camera (UcaPluginManager *manager,
- const gchar *name,
- GError **error)
+uca_plugin_manager_get_camera (UcaPluginManager *manager,
+ const gchar *name,
+ GError **error,
+ const gchar *first_prop_name,
+ ...)
{
UcaPluginManagerPrivate *priv;
UcaCamera *camera;
GModule *module;
- GetCameraFunc *func;
gchar *module_path;
+ GetTypeFunc *func;
+ GType type;
+ va_list var_args;
GError *tmp_error = NULL;
- const gchar *symbol_name = "uca_camera_impl_new";
+ const gchar *symbol_name = "uca_camera_get_type";
g_return_val_if_fail (UCA_IS_PLUGIN_MANAGER (manager) && (name != NULL), NULL);
@@ -252,7 +258,7 @@ uca_plugin_manager_get_camera (UcaPluginManager *manager,
return NULL;
}
- func = g_malloc0 (sizeof (GetCameraFunc));
+ func = g_malloc0 (sizeof (GetTypeFunc));
if (!g_module_symbol (module, symbol_name, (gpointer *) func)) {
g_set_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_SYMBOL_NOT_FOUND,
@@ -265,7 +271,12 @@ uca_plugin_manager_get_camera (UcaPluginManager *manager,
return NULL;
}
- camera = (*func) (&tmp_error);
+ type = (*func) ();
+
+ va_start (var_args, first_prop_name);
+ camera = (UcaCamera *) g_initable_new (type, NULL, &tmp_error,
+ first_prop_name, var_args);
+ va_end (var_args);
if (tmp_error != NULL) {
g_propagate_error (error, tmp_error);
diff --git a/src/uca-plugin-manager.h b/src/uca-plugin-manager.h
index 6c3ab4e..3103684 100644
--- a/src/uca-plugin-manager.h
+++ b/src/uca-plugin-manager.h
@@ -57,7 +57,9 @@ GList *uca_plugin_manager_get_available_cameras
(UcaPluginManager *manager);
UcaCamera *uca_plugin_manager_get_camera (UcaPluginManager *manager,
const gchar *name,
- GError **error);
+ GError **error,
+ const gchar *first_prop_name,
+ ...);
GType uca_plugin_manager_get_type (void);
G_END_DECLS