giomodule: add a new "get default" function

_gio_module_get_default() is a very convenient function for modules
implementing a singleton -- it finds the default module by priority
subject to override by a given environment variable name, instantiates
it, and caches the instance for future calls.  It also has the ability
to query instances for being 'active' using a callback.

It doesn't work very well for non-singletons (like file monitors).

Add a new function _gio_module_get_default_type() that skips the
instantiation, returning the GType instead.  As a replacement for the
'active' callback, a vtable offset can be given for a virtual function
to use to query if a particular backend is supported.

https://bugzilla.gnome.org/show_bug.cgi?id=592211
This commit is contained in:
Ryan Lortie
2013-01-18 18:27:57 -05:00
committed by Matthias Clasen
parent ca58dae277
commit 3a7b44c007
2 changed files with 122 additions and 2 deletions

View File

@@ -35,6 +35,10 @@ gpointer _g_io_module_get_default (const gchar *extension_point,
const gchar *envvar,
GIOModuleVerifyFunc verify_func);
GType _g_io_module_get_default_type (const gchar *extension_point,
const gchar *envvar,
guint is_supported_offset);
#ifdef G_PLATFORM_WIN32
void *_g_io_win32_get_module (void);
#endif