[gnome-shell] st/widget: Fix applying :insensitive to initially unreactive widgets
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st/widget: Fix applying :insensitive to initially unreactive widgets
- Date: Mon, 8 Feb 2021 08:09:45 +0000 (UTC)
commit 473e77e2c5ab380dcfcaefab699ed8cbff3ae915
Author: Florian Müllner <fmuellner gnome org>
Date: Sun Feb 7 23:21:55 2021 +0100
st/widget: Fix applying :insensitive to initially unreactive widgets
We are applying the :insensitive pseudo class to unreactive widgets,
or at least we are supposed to. As we currently only update the style
on notify, we don't apply it to initially unreactive widgets.
This was covered up partially until recently when Clutter started to
use G_PARAM_EXPLICIT_NOTIFY. Before that, the notify handler would run
when explicitly setting :reactive to FALSE at construction time.
Make sure we always apply the pseudo class correctly by updating it
after construct properties have been set.
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3685
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1648>
src/st/st-widget.c | 23 +++++++++++++++++++----
src/st/test-theme.c | 2 ++
2 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index 2ee74af081..7e03028c0d 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -142,6 +142,15 @@ static gboolean st_widget_real_navigate_focus (StWidget *widget,
static AtkObject * st_widget_get_accessible (ClutterActor *actor);
static gboolean st_widget_has_accessible (ClutterActor *actor);
+static void
+st_widget_update_insensitive (StWidget *widget)
+{
+ if (clutter_actor_get_reactive (CLUTTER_ACTOR (widget)))
+ st_widget_remove_style_pseudo_class (widget, "insensitive");
+ else
+ st_widget_add_style_pseudo_class (widget, "insensitive");
+}
+
static void
st_widget_set_property (GObject *gobject,
guint prop_id,
@@ -247,6 +256,14 @@ st_widget_get_property (GObject *gobject,
}
}
+static void
+st_widget_constructed (GObject *gobject)
+{
+ G_OBJECT_CLASS (st_widget_parent_class)->constructed (gobject);
+
+ st_widget_update_insensitive (ST_WIDGET (gobject));
+}
+
static void
st_widget_remove_transition (StWidget *widget)
{
@@ -840,6 +857,7 @@ st_widget_class_init (StWidgetClass *klass)
gobject_class->set_property = st_widget_set_property;
gobject_class->get_property = st_widget_get_property;
+ gobject_class->constructed = st_widget_constructed;
gobject_class->dispose = st_widget_dispose;
gobject_class->finalize = st_widget_finalize;
@@ -1471,10 +1489,7 @@ st_widget_reactive_notify (StWidget *widget,
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
- if (clutter_actor_get_reactive (CLUTTER_ACTOR (widget)))
- st_widget_remove_style_pseudo_class (widget, "insensitive");
- else
- st_widget_add_style_pseudo_class (widget, "insensitive");
+ st_widget_update_insensitive (widget);
if (priv->track_hover)
st_widget_sync_hover(widget);
diff --git a/src/st/test-theme.c b/src/st/test-theme.c
index d38b41f03e..6aff82b0dd 100644
--- a/src/st/test-theme.c
+++ b/src/st/test-theme.c
@@ -465,6 +465,8 @@ test_pseudo_class (void)
/* Test the StWidget add/remove pseudo_class interfaces */
label = st_label_new ("foo");
+ /* Make reactive, so we don't get the automatic :insensitive style */
+ clutter_actor_set_reactive (CLUTTER_ACTOR (label), TRUE);
clutter_actor_add_child (stage, CLUTTER_ACTOR (label));
labelNode = st_widget_get_theme_node (label);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]