[gtk+] widget: Don't change sensitive state with insensitve parent
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] widget: Don't change sensitive state with insensitve parent
- Date: Fri, 16 Dec 2011 03:56:12 +0000 (UTC)
commit 94f00eb04dd1433cf1cc9a3341f485124e38abd1
Author: Benjamin Otte <otte redhat com>
Date: Thu Dec 15 20:32:54 2011 +0100
widget: Don't change sensitive state with insensitve parent
This way child.set_sensitive(True) with an insensitive parent doesn't
cause child to become sensitive.
gtk/gtkwidget.c | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 4788747..7c189c4 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -7663,7 +7663,6 @@ gtk_widget_set_sensitive (GtkWidget *widget,
gboolean sensitive)
{
GtkWidgetPrivate *priv;
- GtkStateData data;
g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -7674,24 +7673,30 @@ gtk_widget_set_sensitive (GtkWidget *widget,
if (priv->sensitive == sensitive)
return;
- data.flags = GTK_STATE_FLAG_INSENSITIVE;
-
- if (sensitive)
- {
- priv->sensitive = TRUE;
- data.operation = STATE_CHANGE_UNSET;
- }
- else
+ if (priv->parent == NULL
+ || gtk_widget_is_sensitive (priv->parent))
{
- priv->sensitive = FALSE;
- data.operation = STATE_CHANGE_SET;
- }
+ GtkStateData data;
- data.use_forall = TRUE;
+ data.flags = GTK_STATE_FLAG_INSENSITIVE;
- gtk_widget_propagate_state (widget, &data);
+ if (sensitive)
+ {
+ priv->sensitive = TRUE;
+ data.operation = STATE_CHANGE_UNSET;
+ }
+ else
+ {
+ priv->sensitive = FALSE;
+ data.operation = STATE_CHANGE_SET;
+ }
- gtk_widget_queue_resize (widget);
+ data.use_forall = TRUE;
+
+ gtk_widget_propagate_state (widget, &data);
+
+ gtk_widget_queue_resize (widget);
+ }
g_object_notify (G_OBJECT (widget), "sensitive");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]