[gtk+] Don't use GTK_WIDGET_*SET_FLAGS (wid, GTK_HAS_DEFAULT)



commit 41a073263a5b16c2ecde58d7ef0f6ad2d296b3ac
Author: Javier Jardón <jjardon gnome org>
Date:   Wed Apr 14 14:18:25 2010 +0200

    Don't use GTK_WIDGET_*SET_FLAGS (wid, GTK_HAS_DEFAULT)
    
    Introduce internal _gtk_widget_set_has_default() for this
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=614515

 gtk/gtkwidget.c |   10 ++++++++++
 gtk/gtkwidget.h |    2 ++
 gtk/gtkwindow.c |   12 ++++++------
 3 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 772619f..06bfe04 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5612,6 +5612,16 @@ gtk_widget_has_default (GtkWidget *widget)
   return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_DEFAULT) != 0;
 }
 
+void
+_gtk_widget_set_has_default (GtkWidget *widget,
+                             gboolean   has_default)
+{
+  if (has_default)
+    GTK_OBJECT_FLAGS (widget) |= GTK_HAS_DEFAULT;
+  else
+    GTK_OBJECT_FLAGS (widget) &= ~(GTK_HAS_DEFAULT);
+}
+
 /**
  * gtk_widget_grab_default:
  * @widget: a #GtkWidget
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 17bb2b6..f609873 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -1296,6 +1296,8 @@ void            gtk_requisition_free     (GtkRequisition       *requisition);
 #  define gtk_widget_unref g_object_unref
 #endif	/* GTK_TRACE_OBJECTS && __GNUC__ */
 
+void              _gtk_widget_set_has_default             (GtkWidget    *widget,
+                                                           gboolean      has_default);
 void              _gtk_widget_set_has_grab                (GtkWidget    *widget,
                                                            gboolean      has_grab);
 void              _gtk_widget_set_is_toplevel             (GtkWidget    *widget,
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 108a7c1..128e429 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1664,7 +1664,7 @@ gtk_window_set_default (GtkWindow *window,
 	  
 	  if (window->focus_widget != window->default_widget ||
 	      !gtk_widget_get_receives_default (window->default_widget))
-	    GTK_WIDGET_UNSET_FLAGS (window->default_widget, GTK_HAS_DEFAULT);
+            _gtk_widget_set_has_default (window->default_widget, FALSE);
 	  gtk_widget_queue_draw (window->default_widget);
 	}
 
@@ -1674,7 +1674,7 @@ gtk_window_set_default (GtkWindow *window,
 	{
 	  if (window->focus_widget == NULL ||
 	      !gtk_widget_get_receives_default (window->focus_widget))
-	    GTK_WIDGET_SET_FLAGS (window->default_widget, GTK_HAS_DEFAULT);
+            _gtk_widget_set_has_default (window->default_widget, TRUE);
 	  gtk_widget_queue_draw (window->default_widget);
 	}
 
@@ -5480,11 +5480,11 @@ gtk_window_real_set_focus (GtkWindow *window,
       if (gtk_widget_get_receives_default (window->focus_widget) &&
 	  (window->focus_widget != window->default_widget))
         {
-	  GTK_WIDGET_UNSET_FLAGS (window->focus_widget, GTK_HAS_DEFAULT);
+          _gtk_widget_set_has_default (window->focus_widget, FALSE);
 	  gtk_widget_queue_draw (window->focus_widget);
 	  
 	  if (window->default_widget)
-	    GTK_WIDGET_SET_FLAGS (window->default_widget, GTK_HAS_DEFAULT);
+            _gtk_widget_set_has_default (window->default_widget, TRUE);
 	}
 
       window->focus_widget = NULL;
@@ -5506,10 +5506,10 @@ gtk_window_real_set_focus (GtkWindow *window,
 	  (window->focus_widget != window->default_widget))
 	{
 	  if (gtk_widget_get_can_default (window->focus_widget))
-	    GTK_WIDGET_SET_FLAGS (window->focus_widget, GTK_HAS_DEFAULT);
+            _gtk_widget_set_has_default (window->focus_widget, TRUE);
 
 	  if (window->default_widget)
-	    GTK_WIDGET_UNSET_FLAGS (window->default_widget, GTK_HAS_DEFAULT);
+            _gtk_widget_set_has_default (window->default_widget, FALSE);
 	}
 
       if (window->has_focus)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]