actionmuxer: Port internal users

Port all internal users of the action muxer
from the GActionGroup interface to the new
action muxer apis.
This commit is contained in:
Matthias Clasen 2020-07-18 22:30:02 -04:00
parent 14bb12125f
commit 4786a16696
7 changed files with 36 additions and 27 deletions

View File

@ -444,8 +444,9 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper,
helper->action_name,
GTK_ACTION_OBSERVER (helper));
if (g_action_group_query_action (G_ACTION_GROUP (helper->action_context), helper->action_name,
&enabled, &parameter_type, NULL, NULL, &state))
if (gtk_action_muxer_query_action (helper->action_context, helper->action_name,
&enabled, &parameter_type,
NULL, NULL, &state))
{
GTK_NOTE(ACTIONS, g_message ("%s: action %s existed from the start", "actionhelper", helper->action_name));
@ -531,9 +532,9 @@ gtk_action_helper_set_action_target_value (GtkActionHelper *helper,
gboolean enabled;
GVariant *state;
if (g_action_group_query_action (G_ACTION_GROUP (helper->action_context),
helper->action_name, &enabled, &parameter_type,
NULL, NULL, &state))
if (gtk_action_muxer_query_action (helper->action_context,
helper->action_name, &enabled, &parameter_type,
NULL, NULL, &state))
{
gtk_action_helper_action_added (helper, enabled, parameter_type, state, FALSE);
@ -593,6 +594,7 @@ gtk_action_helper_activate (GtkActionHelper *helper)
if (!helper->can_activate || helper->reporting)
return;
g_action_group_activate_action (G_ACTION_GROUP (helper->action_context),
helper->action_name, helper->target);
gtk_action_muxer_activate_action (helper->action_context,
helper->action_name,
helper->target);
}

View File

@ -522,7 +522,7 @@ _gtk_menu_tracker_item_new (GtkActionObservable *observable,
if (!is_separator && g_menu_item_get_attribute (self->item, "action", "&s", &action_name))
{
GActionGroup *group = G_ACTION_GROUP (observable);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (observable);
const GVariantType *parameter_type;
GVariant *target;
gboolean enabled;
@ -546,7 +546,7 @@ _gtk_menu_tracker_item_new (GtkActionObservable *observable,
state = NULL;
gtk_action_observable_register_observer (self->observable, action_name, GTK_ACTION_OBSERVER (self));
found = g_action_group_query_action (group, action_name, &enabled, &parameter_type, NULL, NULL, &state);
found = gtk_action_muxer_query_action (muxer, action_name, &enabled, &parameter_type, NULL, NULL, &state);
if (found)
{
@ -795,7 +795,7 @@ gtk_menu_tracker_item_activated (GtkMenuTrackerItem *self)
action_name = strrchr (self->action_and_target, '|') + 1;
action_target = g_menu_item_get_attribute_value (self->item, G_MENU_ATTRIBUTE_TARGET, NULL);
g_action_group_activate_action (G_ACTION_GROUP (self->observable), action_name, action_target);
gtk_action_muxer_activate_action (GTK_ACTION_MUXER (self->observable), action_name, action_target);
if (action_target)
g_variant_unref (action_target);
@ -811,8 +811,9 @@ typedef struct
static void
gtk_menu_tracker_opener_update (GtkMenuTrackerOpener *opener)
{
GActionGroup *group = G_ACTION_GROUP (opener->item->observable);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (opener->item->observable);
gboolean is_open = TRUE;
GVariant *state;
/* We consider the menu as being "open" if the action does not exist
* or if there is another problem (no state, wrong state type, etc.).
@ -828,10 +829,8 @@ gtk_menu_tracker_opener_update (GtkMenuTrackerOpener *opener)
* That is handled in _free() below.
*/
if (g_action_group_has_action (group, opener->submenu_action))
if (gtk_action_muxer_query_action (muxer, opener->submenu_action, NULL, NULL, NULL, NULL, &state))
{
GVariant *state = g_action_group_get_action_state (group, opener->submenu_action);
if (state)
{
if (g_variant_is_of_type (state, G_VARIANT_TYPE_BOOLEAN))
@ -849,7 +848,7 @@ gtk_menu_tracker_opener_update (GtkMenuTrackerOpener *opener)
if (!is_open || opener->first_time)
{
g_action_group_change_action_state (group, opener->submenu_action, g_variant_new_boolean (TRUE));
gtk_action_muxer_change_action_state (muxer, opener->submenu_action, g_variant_new_boolean (TRUE));
opener->first_time = FALSE;
}
}

View File

@ -1072,14 +1072,16 @@ gtk_named_action_activate (GtkShortcutAction *action,
{
GtkNamedAction *self = GTK_NAMED_ACTION (action);
const GVariantType *parameter_type;
GActionGroup *action_group;
GtkActionMuxer *muxer;
gboolean enabled;
action_group = G_ACTION_GROUP (_gtk_widget_get_action_muxer (widget, FALSE));
if (action_group == NULL)
muxer = _gtk_widget_get_action_muxer (widget, FALSE);
if (muxer == NULL)
return FALSE;
if (!g_action_group_query_action (action_group, self->name, &enabled, &parameter_type, NULL, NULL, NULL))
if (!gtk_action_muxer_query_action (muxer, self->name,
&enabled, &parameter_type,
NULL, NULL, NULL))
return FALSE;
if (!enabled)
@ -1095,7 +1097,7 @@ gtk_named_action_activate (GtkShortcutAction *action,
if (!check_parameter_type (args, parameter_type))
return FALSE;
g_action_group_activate_action (action_group, self->name, args);
gtk_action_muxer_activate_action (muxer, self->name, args);
return TRUE;
}

View File

@ -6015,6 +6015,7 @@ append_bubble_item (GtkText *self,
const char *icon_name;
const char *action_name;
GMenuModel *link;
gboolean enabled;
link = g_menu_model_get_item_link (model, index, "section");
if (link)
@ -6040,7 +6041,9 @@ append_bubble_item (GtkText *self,
g_variant_unref (att);
muxer = _gtk_widget_get_action_muxer (GTK_WIDGET (self), FALSE);
if (!g_action_group_get_action_enabled (G_ACTION_GROUP (muxer), action_name))
if (!gtk_action_muxer_query_action (muxer, action_name, &enabled,
NULL, NULL, NULL, NULL) ||
!enabled)
return;
item = gtk_button_new ();

View File

@ -8741,7 +8741,7 @@ append_bubble_item (GtkTextView *text_view,
const char *action_name;
GMenuModel *link;
gboolean is_toggle_action = FALSE;
GActionGroup *group = NULL;
GtkActionMuxer *muxer;
gboolean enabled;
const GVariantType *param_type;
const GVariantType *state_type;
@ -8769,10 +8769,10 @@ append_bubble_item (GtkTextView *text_view,
action_name = g_variant_get_string (att, NULL);
g_variant_unref (att);
group = G_ACTION_GROUP (_gtk_widget_get_action_muxer (GTK_WIDGET (text_view), FALSE));
if (group)
muxer = _gtk_widget_get_action_muxer (GTK_WIDGET (text_view), FALSE);
if (muxer)
{
g_action_group_query_action (group, action_name, &enabled, &param_type, &state_type, NULL, NULL);
gtk_action_muxer_query_action (muxer, action_name, &enabled, &param_type, &state_type, NULL, NULL);
if (!enabled)
return;

View File

@ -28,6 +28,7 @@
#include "gtkaccelgroupprivate.h"
#include "gtkaccessible.h"
#include "gtkactionobserverprivate.h"
#include "gtkapplicationprivate.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
@ -11075,10 +11076,10 @@ gtk_widget_activate_action_variant (GtkWidget *widget,
if (muxer == NULL)
return FALSE;
if (!g_action_group_has_action (G_ACTION_GROUP (muxer), name))
if (!gtk_action_muxer_has_action (muxer, name))
return FALSE;
g_action_group_activate_action (G_ACTION_GROUP (muxer), name, args);
gtk_action_muxer_activate_action (muxer, name, args);
return TRUE;
}

View File

@ -20,6 +20,7 @@
#include "gtkwindowhandle.h"
#include "gtkactionmuxerprivate.h"
#include "gtkbinlayout.h"
#include "gtkbox.h"
#include "gtkbuildable.h"
@ -34,6 +35,7 @@
#include "gtkseparator.h"
#include "gtkwidgetprivate.h"
/**
* SECTION:gtkwindowhandle
* @Short_description: A titlebar area widget