[gtk/new-style-menu: 29/48] label: Fix mnemonic visibility handling
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/new-style-menu: 29/48] label: Fix mnemonic visibility handling
- Date: Sun, 9 Jun 2019 17:45:26 +0000 (UTC)
commit 6f689ec5b17dcf5a1fe02a352c6a33040681b7b1
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 8 13:40:59 2019 +0000
label: Fix mnemonic visibility handling
With non-widgets having children, we can no
longer assume that using gtk_container_forall
lets us walk the entire tree.
gtk/gtklabel.c | 61 +++++++++++++++++++++++-----------------------------------
1 file changed, 24 insertions(+), 37 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index ff62dd3302..ffc6d05e6e 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -1904,42 +1904,32 @@ gtk_label_unroot (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_label_parent_class)->unroot (widget);
}
-static void
-mnemonics_visible_apply (GtkWidget *widget,
- gboolean mnemonics_visible)
+void
+_gtk_label_mnemonics_visible_apply_recursively (GtkWidget *widget,
+ gboolean visible)
{
- GtkLabel *label = GTK_LABEL (widget);
- GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
-
- mnemonics_visible = mnemonics_visible != FALSE;
-
- if (priv->mnemonics_visible != mnemonics_visible)
+ if (GTK_IS_LABEL (widget))
{
- priv->mnemonics_visible = mnemonics_visible;
+ GtkLabel *label = GTK_LABEL (widget);
+ GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
- gtk_label_recalculate (label);
+ if (priv->mnemonics_visible != visible)
+ {
+ priv->mnemonics_visible = visible;
+ gtk_label_recalculate (label);
+ }
}
-}
-
-static void
-label_mnemonics_visible_traverse_container (GtkWidget *widget,
- gpointer data)
-{
- gboolean mnemonics_visible = GPOINTER_TO_INT (data);
-
- _gtk_label_mnemonics_visible_apply_recursively (widget, mnemonics_visible);
-}
+ else
+ {
+ GtkWidget *child;
-void
-_gtk_label_mnemonics_visible_apply_recursively (GtkWidget *widget,
- gboolean mnemonics_visible)
-{
- if (GTK_IS_LABEL (widget))
- mnemonics_visible_apply (widget, mnemonics_visible);
- else if (GTK_IS_CONTAINER (widget))
- gtk_container_forall (GTK_CONTAINER (widget),
- label_mnemonics_visible_traverse_container,
- GINT_TO_POINTER (mnemonics_visible));
+ for (child = gtk_widget_get_first_child (widget);
+ child;
+ child = gtk_widget_get_next_sibling (child))
+ {
+ _gtk_label_mnemonics_visible_apply_recursively (child, visible);
+ }
+ }
}
static void
@@ -1947,13 +1937,10 @@ label_mnemonics_visible_changed (GtkWindow *window,
GParamSpec *pspec,
gpointer data)
{
- gboolean mnemonics_visible;
-
- g_object_get (window, "mnemonics-visible", &mnemonics_visible, NULL);
+ gboolean visible;
- gtk_container_forall (GTK_CONTAINER (window),
- label_mnemonics_visible_traverse_container,
- GINT_TO_POINTER (mnemonics_visible));
+ g_object_get (window, "mnemonics-visible", &visible, NULL);
+ _gtk_label_mnemonics_visible_apply_recursively (GTK_WIDGET (window), visible);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]