[gtk/action-muxer-speedup: 5/11] actionmuxer: Port internal users
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/action-muxer-speedup: 5/11] actionmuxer: Port internal users
- Date: Sun, 19 Jul 2020 21:07:24 +0000 (UTC)
commit 42e0eb9295bff88d491ed60949ffea537b0db48a
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jul 18 22:30:02 2020 -0400
actionmuxer: Port internal users
Port all internal users of the action muxer
from the GActionGroup interface to the new
action muxer apis.
gtk/gtkactionhelper.c | 16 +++++++++-------
gtk/gtkmenutrackeritem.c | 15 +++++++--------
gtk/gtkshortcutaction.c | 12 +++++++-----
gtk/gtktext.c | 5 ++++-
gtk/gtktextview.c | 8 ++++----
gtk/gtkwidget.c | 5 +++--
gtk/gtkwindowhandle.c | 14 ++++++++------
7 files changed, 42 insertions(+), 33 deletions(-)
---
diff --git a/gtk/gtkactionhelper.c b/gtk/gtkactionhelper.c
index d36e285951..7de1740dc5 100644
--- a/gtk/gtkactionhelper.c
+++ b/gtk/gtkactionhelper.c
@@ -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, ¶meter_type, NULL, NULL, &state))
+ if (gtk_action_muxer_query_action (helper->action_context, helper->action_name,
+ &enabled, ¶meter_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, ¶meter_type,
- NULL, NULL, &state))
+ if (gtk_action_muxer_query_action (helper->action_context,
+ helper->action_name, &enabled, ¶meter_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);
}
diff --git a/gtk/gtkmenutrackeritem.c b/gtk/gtkmenutrackeritem.c
index 3336d8abd5..64b898917d 100644
--- a/gtk/gtkmenutrackeritem.c
+++ b/gtk/gtkmenutrackeritem.c
@@ -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, ¶meter_type, NULL, NULL,
&state);
+ found = gtk_action_muxer_query_action (muxer, action_name, &enabled, ¶meter_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;
}
}
diff --git a/gtk/gtkshortcutaction.c b/gtk/gtkshortcutaction.c
index 4bdb7daf85..b4f36956bc 100644
--- a/gtk/gtkshortcutaction.c
+++ b/gtk/gtkshortcutaction.c
@@ -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, ¶meter_type, NULL, NULL, NULL))
+ if (!gtk_action_muxer_query_action (muxer, self->name,
+ &enabled, ¶meter_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;
}
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 7e91afffab..1dfd553022 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -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 ();
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index f2993b4c28..1f899176e2 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -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, ¶m_type, &state_type, NULL, NULL);
+ gtk_action_muxer_query_action (muxer, action_name, &enabled, ¶m_type, &state_type, NULL, NULL);
if (!enabled)
return;
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 81c7c3e3f5..06f95b3e86 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -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;
}
diff --git a/gtk/gtkwindowhandle.c b/gtk/gtkwindowhandle.c
index 437a13c7c6..d1b35f72d6 100644
--- a/gtk/gtkwindowhandle.c
+++ b/gtk/gtkwindowhandle.c
@@ -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
@@ -295,15 +297,15 @@ perform_titlebar_action (GtkWindowHandle *self,
retval = FALSE;
/* treat all maximization variants the same */
else if (g_str_has_prefix (action, "toggle-maximize"))
- g_action_group_activate_action (G_ACTION_GROUP (context),
- "window.toggle-maximized",
- NULL);
+ gtk_action_muxer_activate_action (context,
+ "window.toggle-maximized",
+ NULL);
else if (g_str_equal (action, "lower"))
lower_window (self);
else if (g_str_equal (action, "minimize"))
- g_action_group_activate_action (G_ACTION_GROUP (context),
- "window.minimize",
- NULL);
+ gtk_action_muxer_activate_action (context,
+ "window.minimize",
+ NULL);
else if (g_str_equal (action, "menu"))
do_popup (self, event);
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]