[glib: 1/2] gvolumemonitor: Use GIOModule methods for getting default type
- From: Nirbheek Chauhan <nirbheekc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gvolumemonitor: Use GIOModule methods for getting default type
- Date: Mon, 26 Aug 2019 11:47:28 +0000 (UTC)
commit 833c24f45a82afb8b9dff95b21f0ab4fdb1874ff
Author: Philip Withnall <withnall endlessm com>
Date: Mon Aug 26 13:41:26 2019 +0300
gvolumemonitor: Use GIOModule methods for getting default type
This fixes use of `GIO_USE_VOLUME_MONITOR=help`, and simplifies the
code. The reason this wasn’t used already seems to just be because it
was missed when `_g_io_module_get_default_type()` was introduced in
2013. The previous `get_default_native_class()` code in
`gunionvolumemonitor.c` was introduced in 2007.
Signed-off-by: Philip Withnall <withnall endlessm com>
Closes: #1881
gio/gunionvolumemonitor.c | 55 +++--------------------------------------------
1 file changed, 3 insertions(+), 52 deletions(-)
---
diff --git a/gio/gunionvolumemonitor.c b/gio/gunionvolumemonitor.c
index eeb4c5ffc..93b74e524 100644
--- a/gio/gunionvolumemonitor.c
+++ b/gio/gunionvolumemonitor.c
@@ -423,58 +423,9 @@ g_union_volume_monitor_remove_monitor (GUnionVolumeMonitor *union_monitor,
static GType
get_default_native_class (gpointer data)
{
- GNativeVolumeMonitorClass *klass, *native_class, **native_class_out;
- const char *use_this;
- GIOExtensionPoint *ep;
- GIOExtension *extension;
- GList *l;
-
- native_class_out = data;
-
- use_this = g_getenv ("GIO_USE_VOLUME_MONITOR");
-
- /* Ensure vfs in modules loaded */
- _g_io_modules_ensure_loaded ();
-
- ep = g_io_extension_point_lookup (G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME);
-
- native_class = NULL;
- if (use_this)
- {
- extension = g_io_extension_point_get_extension_by_name (ep, use_this);
- if (extension)
- {
- klass = G_NATIVE_VOLUME_MONITOR_CLASS (g_io_extension_ref_class (extension));
- if (G_VOLUME_MONITOR_CLASS (klass)->is_supported())
- native_class = klass;
- else
- g_type_class_unref (klass);
- }
- }
-
- if (native_class == NULL)
- {
- for (l = g_io_extension_point_get_extensions (ep); l != NULL; l = l->next)
- {
- extension = l->data;
- klass = G_NATIVE_VOLUME_MONITOR_CLASS (g_io_extension_ref_class (extension));
- if (G_VOLUME_MONITOR_CLASS (klass)->is_supported())
- {
- native_class = klass;
- break;
- }
- else
- g_type_class_unref (klass);
- }
- }
-
- if (native_class)
- {
- *native_class_out = native_class;
- return G_TYPE_FROM_CLASS (native_class);
- }
- else
- return G_TYPE_INVALID;
+ return _g_io_module_get_default_type (G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME,
+ "GIO_USE_VOLUME_MONITOR",
+ G_STRUCT_OFFSET (GVolumeMonitorClass, is_supported));
}
/* We return the class, with a ref taken.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]