forked from AuroraMiddleware/gtk
widget actions: Add an explicit state type
Make the state type part of the API for installing stateful widget actions. That lets us introspect it. Update all callers.
This commit is contained in:
parent
9be0b3d76f
commit
152eabbaba
@ -446,11 +446,11 @@ gtk_action_muxer_query_action (GActionGroup *action_group,
|
||||
*enabled = muxer->widget_actions_enabled[i];
|
||||
if (parameter_type)
|
||||
*parameter_type = action->parameter_type;
|
||||
if (state_type)
|
||||
*state_type = action->state_type;
|
||||
|
||||
if (state_hint)
|
||||
*state_hint = NULL;
|
||||
if (state_type)
|
||||
*state_type = NULL;
|
||||
if (state)
|
||||
*state = NULL;
|
||||
|
||||
@ -460,8 +460,6 @@ gtk_action_muxer_query_action (GActionGroup *action_group,
|
||||
|
||||
s = g_variant_ref_sink (action->get_state (muxer->widget, action->name));
|
||||
|
||||
if (state_type)
|
||||
*state_type = g_variant_get_type (s);
|
||||
if (state)
|
||||
*state = g_variant_ref (s);
|
||||
|
||||
|
@ -35,6 +35,7 @@ typedef struct {
|
||||
char *name;
|
||||
|
||||
GVariantType *parameter_type;
|
||||
GVariantType *state_type;
|
||||
|
||||
GtkWidgetActionActivateFunc activate;
|
||||
GtkWidgetActionSetStateFunc set_state;
|
||||
|
@ -715,10 +715,10 @@ gtk_color_chooser_widget_class_init (GtkColorChooserWidgetClass *class)
|
||||
|
||||
gtk_widget_class_install_stateful_action (GTK_WIDGET_CLASS (class), "color.select",
|
||||
gtk_color_chooser_widget_activate_color_select,
|
||||
"(dddd)", NULL, NULL);
|
||||
"(dddd)", NULL, NULL, NULL);
|
||||
gtk_widget_class_install_stateful_action (GTK_WIDGET_CLASS (class), "color.customize",
|
||||
gtk_color_chooser_widget_activate_color_customize,
|
||||
"(dddd)", NULL, NULL);
|
||||
"(dddd)", NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/* GtkColorChooser implementation {{{1 */
|
||||
|
@ -1377,7 +1377,7 @@ gtk_text_class_init (GtkTextClass *class)
|
||||
gtk_text_activate_misc_insert_emoji);
|
||||
gtk_widget_class_install_stateful_action (widget_class, "misc.toggle-visibility",
|
||||
gtk_text_activate_misc_toggle_visibility,
|
||||
NULL,
|
||||
NULL, "b",
|
||||
gtk_text_set_misc_toggle_visibility,
|
||||
gtk_text_get_misc_toggle_visibility);
|
||||
}
|
||||
|
@ -13449,7 +13449,7 @@ gtk_widget_class_install_action (GtkWidgetClass *widget_class,
|
||||
GtkWidgetActionActivateFunc activate)
|
||||
{
|
||||
gtk_widget_class_install_stateful_action (widget_class, action_name, activate,
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -13458,9 +13458,10 @@ gtk_widget_class_install_action (GtkWidgetClass *widget_class,
|
||||
* @action_name: a prefixed action name, such as "clipboard.paste"
|
||||
* @activate: callback to use when the action is activated
|
||||
* @parameter_type: (allow-none): the parameter type, or %NULL
|
||||
* @query: (allow-none): callback to use when the action properties
|
||||
are queried, or %NULL for always-enabled stateless actions
|
||||
* @query_state: (allow-none): callback to use when the action state
|
||||
* @state_type: (allow-none): the state type, or %NULL
|
||||
* @set_state: (allow-none): callback to use when the action state
|
||||
is set, or %NULL for stateless actions
|
||||
* @get_state: (allow-none): callback to use when the action state
|
||||
is queried, or %NULL for stateless actions
|
||||
*
|
||||
* This should be called at class initialization time to specify
|
||||
@ -13474,6 +13475,7 @@ gtk_widget_class_install_stateful_action (GtkWidgetClass *widget_cl
|
||||
const char *action_name,
|
||||
GtkWidgetActionActivateFunc activate,
|
||||
const char *parameter_type,
|
||||
const char *state_type,
|
||||
GtkWidgetActionSetStateFunc set_state,
|
||||
GtkWidgetActionGetStateFunc get_state)
|
||||
{
|
||||
@ -13504,6 +13506,7 @@ gtk_widget_class_install_stateful_action (GtkWidgetClass *widget_cl
|
||||
action->name = g_strdup (action_name);
|
||||
action->activate = activate;
|
||||
action->parameter_type = parameter_type ? g_variant_type_new (parameter_type) : NULL;
|
||||
action->state_type = state_type ? g_variant_type_new (state_type) : NULL;
|
||||
action->set_state = set_state;
|
||||
action->get_state = get_state;
|
||||
|
||||
|
@ -1080,6 +1080,7 @@ void gtk_widget_class_install_stateful_action (GtkWidgetClass
|
||||
const char *action_name,
|
||||
GtkWidgetActionActivateFunc activate,
|
||||
const char *parameter_type,
|
||||
const char *state_type,
|
||||
GtkWidgetActionSetStateFunc set_state,
|
||||
GtkWidgetActionGetStateFunc get_state);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user