--- a/gplugin/gplugin-core.c Thu Sep 23 23:30:36 2021 -0500
+++ b/gplugin/gplugin-core.c Fri Sep 24 01:14:44 2021 -0500
@@ -35,12 +35,16 @@
* @GPLUGIN_CORE_FLAGS_NONE: No flags.
* @GPLUGIN_CORE_FLAGS_DISABLE_NATIVE_LOADER: Disable the native plugin loader.
+ * @GPLUGIN_CORE_FLAGS_LOG_PLUGIN_STATE_CHANGES: Log plugin state changes with + * g_message. Since: 0.34.0 * Flags to configure behaviors in GPlugin.
+static GPluginCoreFlags core_flags = 0; /******************************************************************************
*****************************************************************************/
@@ -77,6 +81,8 @@
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
if(flags & GPLUGIN_CORE_FLAGS_DISABLE_NATIVE_LOADER) {
register_native_loader = FALSE;
@@ -94,3 +100,18 @@
gplugin_manager_private_uninit();
+ * gplugin_core_get_flags: + * Gets the #GPluginCoreFlags that were passed to gplugin_init(). + * Returns: The #GPluginCoreFlags that GPlugin was initialized with. --- a/gplugin/gplugin-core.h Thu Sep 23 23:30:36 2021 -0500
+++ b/gplugin/gplugin-core.h Fri Sep 24 01:14:44 2021 -0500
@@ -31,6 +31,7 @@
typedef enum /*< flags,prefix=GPLUGIN_CORE_FLAGS,underscore_name=GPLUGIN_CORE >*/ {
GPLUGIN_CORE_FLAGS_NONE = 0,
GPLUGIN_CORE_FLAGS_DISABLE_NATIVE_LOADER = 1 << 0,
+ GPLUGIN_CORE_FLAGS_LOG_PLUGIN_STATE_CHANGES = 1 << 1, @@ -39,6 +40,8 @@
void gplugin_init(GPluginCoreFlags flags);
void gplugin_uninit(void);
+GPluginCoreFlags gplugin_get_flags(void); #endif /* GPLUGIN_CORE_H */
--- a/gplugin/gplugin-plugin.c Thu Sep 23 23:30:36 2021 -0500
+++ b/gplugin/gplugin-plugin.c Fri Sep 24 01:14:44 2021 -0500
@@ -1,5 +1,5 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ * Copyright (C) 2011-2021 Gary Kramlich <grim@reaperworld.com> * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -15,8 +15,10 @@
* License along with this library; if not, see <https://www.gnu.org/licenses/>.
+#include <gplugin/gplugin-plugin.h> +#include <gplugin/gplugin-core.h> #include <gplugin/gplugin-enums.h>
-#include <gplugin/gplugin-plugin.h>
#include <gplugin/gplugin-private.h>
@@ -278,6 +280,19 @@
g_object_set(G_OBJECT(plugin), "state", state, NULL);
+ if(gplugin_get_flags() & GPLUGIN_CORE_FLAGS_LOG_PLUGIN_STATE_CHANGES) { + GPluginPluginInfo *info = gplugin_plugin_get_info(plugin); + "plugin %s state changed from %s to %s: filename=%s", + gplugin_plugin_info_get_id(info), + gplugin_plugin_state_to_string(oldstate), + gplugin_plugin_state_to_string(state), + gplugin_plugin_get_filename(plugin)); g_signal_emit(plugin, signals[SIG_STATE_CHANGED], 0, oldstate, state);
@@ -301,3 +316,42 @@
+ * gplugin_plugin_state_to_string: + * @state: The #GPluginPluginState. + * Gets a string representation of @state. + * Returns: The string representation of @state. +gplugin_plugin_state_to_string(GPluginPluginState state) + const gchar *state_str = NULL; + case GPLUGIN_PLUGIN_STATE_QUERIED: + case GPLUGIN_PLUGIN_STATE_REQUERY: + case GPLUGIN_PLUGIN_STATE_LOADED: + case GPLUGIN_PLUGIN_STATE_LOAD_FAILED: + state_str = "load-failed"; + case GPLUGIN_PLUGIN_STATE_UNLOAD_FAILED: + state_str = "unload-failed"; --- a/gplugin/gplugin-plugin.h Thu Sep 23 23:30:36 2021 -0500
+++ b/gplugin/gplugin-plugin.h Fri Sep 24 01:14:44 2021 -0500
@@ -1,5 +1,5 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ * Copyright (C) 2011-2021 Gary Kramlich <grim@reaperworld.com> * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -72,6 +72,8 @@
GError *gplugin_plugin_get_error(GPluginPlugin *plugin);
+const gchar *gplugin_plugin_state_to_string(GPluginPluginState state); #endif /* GPLUGIN_PLUGIN_H */