[grilo] Add grl_init() function



commit 9696f6dfd8a95548ebc98d7144d87fe00d1cf5ac
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Thu Jun 10 14:22:07 2010 +0200

    Add grl_init() function
    
    It initializes all stuff required in Grilo.
    
    More specifically:
    
      - It registers default metadata keys in the registry.
      - It registers grilo media types in glib type-system.

 src/Makefile.am            |    2 +-
 src/grilo.c                |   50 ++++++++++++++++++++++++++++++++++++++++++++
 src/grilo.h                |    6 +++++
 src/grl-plugin-registry.c  |    2 -
 tools/grilo-test-ui/main.c |    1 +
 5 files changed, 58 insertions(+), 3 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 59c35e8..8770014 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,7 @@ lib GRL_NAME@_la_SOURCES =					\
 	grl-metadata-key.c grl-metadata-key-priv.h		\
 	grl-metadata-source.c grl-metadata-source-priv.h	\
 	grl-media-source.c					\
-	grl-log.c
+	grl-log.c grilo.c
 
 data_c_sources =		\
 	data/grl-data.c		\
diff --git a/src/grilo.c b/src/grilo.c
new file mode 100644
index 0000000..9881f5a
--- /dev/null
+++ b/src/grilo.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * Contact: Iago Toral Quiroga <itoral igalia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include "grilo.h"
+#include "grl-metadata-key-priv.h"
+
+static gboolean grl_initialized = FALSE;
+
+void
+grl_init (gint *argc,
+          gchar **argv[])
+{
+  GrlPluginRegistry *registry;
+
+  if (grl_initialized) {
+    g_debug ("already initialized grl");
+    return;
+  }
+
+  /* Register default metadata keys */
+  registry = grl_plugin_registry_get_instance ();
+  grl_metadata_key_setup_system_keys (registry);
+
+  /* Register GrlMedia in glib typesystem */
+  g_type_class_ref (GRL_TYPE_MEDIA_BOX);
+  g_type_class_ref (GRL_TYPE_MEDIA_AUDIO);
+  g_type_class_ref (GRL_TYPE_MEDIA_VIDEO);
+  g_type_class_ref (GRL_TYPE_MEDIA_IMAGE);
+
+  grl_initialized = TRUE;
+}
diff --git a/src/grilo.h b/src/grilo.h
index e65503b..9380cf2 100644
--- a/src/grilo.h
+++ b/src/grilo.h
@@ -48,4 +48,10 @@
 
 #undef _GRILO_H_INSIDE_
 
+G_BEGIN_DECLS
+
+void grl_init (gint *argc, gchar **argv[]);
+
+G_END_DECLS
+
 #endif /* _GRILO_H_ */
diff --git a/src/grl-plugin-registry.c b/src/grl-plugin-registry.c
index d95da01..7a9f720 100644
--- a/src/grl-plugin-registry.c
+++ b/src/grl-plugin-registry.c
@@ -39,7 +39,6 @@
 
 #include "grl-plugin-registry.h"
 #include "grl-media-plugin-priv.h"
-#include "grl-metadata-key-priv.h"
 #include "config.h"
 
 #include <string.h>
@@ -133,7 +132,6 @@ grl_plugin_registry_init (GrlPluginRegistry *registry)
   registry->priv->system_keys =
     g_param_spec_pool_new (FALSE);
 
-  grl_metadata_key_setup_system_keys (registry);
   grl_plugin_registry_setup_ranks (registry);
 }
 
diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c
index 6c26ed2..e7d4f53 100644
--- a/tools/grilo-test-ui/main.c
+++ b/tools/grilo-test-ui/main.c
@@ -1532,6 +1532,7 @@ int
 main (int argc, gchar *argv[])
 {
   gtk_init (&argc, &argv);
+  grl_init (&argc, &argv);
   grl_log_init ("*:*");
   launchers_setup ();
   ui_setup ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]