[gtk+/color-management: 4/6] Load GIO modules at startup, and register an extension point for GtkColorEngine



commit 6e4786c90dababd058e2c202b00d1f105129353d
Author: Richard Hughes <richard hughsie com>
Date:   Tue Mar 2 14:13:37 2010 +0000

    Load GIO modules at startup, and register an extension point for GtkColorEngine

 gtk/gtkmain.c    |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkprivate.h |    2 ++
 2 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 497a99f..6fa6a48 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -27,6 +27,7 @@
 #include "config.h"
 
 #include <glib.h>
+#include <gio/gio.h>
 #include "gdkconfig.h"
 
 #include <locale.h>
@@ -50,6 +51,7 @@
 #include "gtkaccelmap.h"
 #include "gtkbox.h"
 #include "gtkclipboard.h"
+#include "gtkcolorengine.h"
 #include "gtkdnd.h"
 #include "gtkversion.h"
 #include "gtkmain.h"
@@ -822,6 +824,52 @@ gtk_get_option_group (gboolean open_default_display)
   return group;
 }
 
+static void
+_gtk_io_modules_ensure_extension_points_registered (void)
+{
+  static gboolean registered_extensions = FALSE;
+  GIOExtensionPoint *ep;
+
+  if (!registered_extensions)
+    {
+      registered_extensions = TRUE;
+      ep = g_io_extension_point_register (GTK_COLOR_ENGINE_EXTENSION_POINT_NAME);
+      g_io_extension_point_set_required_type (ep, GTK_TYPE_COLOR_ENGINE);
+    }
+}
+
+void
+_gtk_io_modules_ensure_loaded (void)
+{
+  static gboolean loaded_dirs = FALSE;
+  const gchar *module_path;
+  gchar *path;
+
+  _gtk_io_modules_ensure_extension_points_registered ();
+
+  if (!loaded_dirs)
+    {
+      loaded_dirs = TRUE;
+      path = g_build_filename (GTK_LIBDIR, "gtk-2.0", GTK_BINARY_VERSION, "giomodules", NULL);
+      g_io_modules_scan_all_in_directory (path);
+      g_free (path);
+
+      module_path = g_getenv ("GTK_EXTRA_GIOMODULES");
+      if (module_path)
+        {
+          gint i = 0;
+          gchar **paths;
+          paths = g_strsplit (module_path, ":", 0);
+          while (paths[i] != NULL)
+            {
+              g_io_modules_scan_all_in_directory (paths[i]);
+              i++;
+            }
+          g_strfreev (paths);
+        }
+    }
+}
+
 /**
  * gtk_init_with_args:
  * @argc: a pointer to the number of command line arguments.
diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
index 7ba5a5d..479a0f1 100644
--- a/gtk/gtkprivate.h
+++ b/gtk/gtkprivate.h
@@ -112,6 +112,8 @@ gboolean _gtk_fnmatch (const char *pattern,
 #define GTK_DEFAULT_ACCEL_MOD_MASK GDK_META_MASK
 #endif
 
+void _gtk_io_modules_ensure_loaded (void);
+
 G_END_DECLS
 
 #endif /* __GTK_PRIVATE_H__ */



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