Make actions minimally introspectable

This will let us autogenerate some docs for
actions, in the future.
This commit is contained in:
Matthias Clasen 2019-06-22 01:16:55 +00:00
parent 152eabbaba
commit ea456b80da
3 changed files with 46 additions and 0 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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,