[gnome-software/1166-repository-dialog-design-updates: 70/73] gs-plugin: Introduce gs_plugin_get_action_supported()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1166-repository-dialog-design-updates: 70/73] gs-plugin: Introduce gs_plugin_get_action_supported()
- Date: Mon, 2 Aug 2021 13:00:19 +0000 (UTC)
commit cbf428ab000fa19f41389f0bfe5a2723de838a25
Author: Milan Crha <mcrha redhat com>
Date: Wed Jul 21 08:00:27 2021 +0200
gs-plugin: Introduce gs_plugin_get_action_supported()
Helps to check whether certain plugin supports certain action, which
can be used to enable/disable certain features in the GUI or similar
places.
lib/gs-plugin.c | 26 ++++++++++++++++++++++++++
lib/gs-plugin.h | 2 ++
2 files changed, 28 insertions(+)
---
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 47e1ec7d5..186bf3159 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -2143,3 +2143,29 @@ gs_plugin_update_cache_state_for_repository (GsPlugin *plugin,
}
}
}
+
+/**
+ * gs_plugin_get_action_supported:
+ * @plugin: a #GsPlugin
+ * @action: a #GsPluginAction
+ *
+ * Checks whether the @plugin supports @action, meaning whether
+ * the @plugin can execute the @action.
+ *
+ * Returns: Whether the @plugin supports the @action
+ *
+ * Since: 41
+ **/
+gboolean
+gs_plugin_get_action_supported (GsPlugin *plugin,
+ GsPluginAction action)
+{
+ const gchar *function_name;
+
+ g_return_val_if_fail (GS_IS_PLUGIN (plugin), FALSE);
+
+ function_name = gs_plugin_action_to_function_name (action);
+ g_return_val_if_fail (function_name != NULL, FALSE);
+
+ return gs_plugin_get_symbol (plugin, function_name) != NULL;
+}
diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h
index 91a65488a..fbd64ee27 100644
--- a/lib/gs-plugin.h
+++ b/lib/gs-plugin.h
@@ -136,5 +136,7 @@ void gs_plugin_repository_changed (GsPlugin *plugin,
void gs_plugin_update_cache_state_for_repository
(GsPlugin *plugin,
GsApp *repository);
+gboolean gs_plugin_get_action_supported (GsPlugin *plugin,
+ GsPluginAction action);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]