[gtk] Make actions minimally introspectable
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] Make actions minimally introspectable
- Date: Sat, 22 Jun 2019 02:48:08 +0000 (UTC)
commit ea456b80daed0f954c59b788abe1e904ccbbc9bb
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 22 01:16:55 2019 +0000
Make actions minimally introspectable
This will let us autogenerate some docs for
actions, in the future.
docs/reference/gtk/gtk4-sections.txt | 1 +
gtk/gtkwidget.c | 38 ++++++++++++++++++++++++++++++++++++
gtk/gtkwidget.h | 7 +++++++
3 files changed, 46 insertions(+)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 12f15559c3..cfb88c7efd 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4634,6 +4634,7 @@ GtkWidgetActionSetStateFunc
GtkWidgetActionGetStateFunc
gtk_widget_class_install_action
gtk_widget_class_install_stateful_action
+gtk_widget_class_query_action
gtk_widget_action_enabled_changed
gtk_widget_action_state_changed
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 4b093bfaa8..c96909a5e0 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13563,3 +13563,41 @@ gtk_widget_action_state_changed (GtkWidget *widget,
muxer = _gtk_widget_get_action_muxer (widget, TRUE);
gtk_action_muxer_action_state_changed (muxer, action_name, state);
}
+
+/**
+ * gtk_widget_class_query_action:
+ * @widget_class: a #GtkWidgetClass
+ * @index_: position of the action to query
+ * @action_name: return location for the action name
+ * @parameter_type: return location for the parameter type
+ * @state_type: return location for the state type
+ *
+ * Queries the actions that have been installed for
+ * a widget class using gtk_widget_class_install_action()
+ * during class initialization.
+ *
+ * Returns: %TRUE if the action was found,
+ * %FALSE if @index_ is out of range
+ */
+gboolean
+gtk_widget_class_query_action (GtkWidgetClass *widget_class,
+ guint index_,
+ const char **action_name,
+ const GVariantType **parameter_type,
+ const GVariantType **state_type)
+{
+ GtkWidgetClassPrivate *priv = widget_class->priv;
+
+ if (priv->actions && index_ < priv->actions->len)
+ {
+ GtkWidgetAction *action = g_ptr_array_index (priv->actions, index_);
+
+ *action_name = action->name;
+ *parameter_type = action->parameter_type;
+ *state_type = action->state_type;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index d52dff446a..31161141ed 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -1084,6 +1084,13 @@ void gtk_widget_class_install_stateful_action (GtkWidgetClass
GtkWidgetActionSetStateFunc set_state,
GtkWidgetActionGetStateFunc get_state);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_widget_class_query_action (GtkWidgetClass *widget_class,
+ guint index_,
+ const char **action_name,
+ const GVariantType **parameter_type,
+ const GVariantType **state_type);
+
GDK_AVAILABLE_IN_ALL
void gtk_widget_action_enabled_changed (GtkWidget *widget,
const char *action_name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]