Notification of changes in has-focus property



I am trying to use the notify signal generated when the "has-focus" property 
changes on a GtkWidget to become aware of when a widget gains or loses focus. I 
have not been successful as it seems that the calls to g_object_notify (G_OBJECT 
(widget), "has_focus") are not made when the has-focus property changes.

Is the following change reasonable?

Padraig

===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.c,v
retrieving revision 1.214
diff -u -p -r1.214 gtkwidget.c
--- gtkwidget.c 2001/05/03 20:11:07     1.214
+++ gtkwidget.c 2001/05/11 12:27:32
@@ -2511,6 +2511,7 @@ gtk_widget_real_focus_in_event (GtkWidge
                                 GdkEventFocus *event)
 {
   GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
+  g_object_notify (G_OBJECT (widget), "has_focus");
   gtk_widget_queue_draw (widget);
 
   return FALSE;
@@ -2521,6 +2522,7 @@ gtk_widget_real_focus_out_event (GtkWidg
                                  GdkEventFocus *event)
 {
   GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
+  g_object_notify (G_OBJECT (widget), "has_focus");
   gtk_widget_queue_draw (widget);
 
   return FALSE;
@@ -2951,7 +2953,6 @@ gtk_widget_grab_focus (GtkWidget *widget
 
   g_object_ref (G_OBJECT (widget));
   gtk_signal_emit (GTK_OBJECT (widget), widget_signals[GRAB_FOCUS]);
-  g_object_notify (G_OBJECT (widget), "has_focus");
   g_object_unref (G_OBJECT (widget));
 }
 





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