Re: Notification of changes in has-focus property



> Delivered-To: gtk-devel-list gnome org
> To: gtk-devel-list gnome org
> Subject: Re: Notification of changes in has-focus property
> User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7
> MIME-Version: 1.0
> X-BeenThere: gtk-devel-list gnome org
> X-Loop: gtk-devel-list gnome org
> X-Mailman-Version: 2.0beta5
> List-Id: Development of GTK+ <gtk-devel-list.gnome.org>
> 
> 
> "Padraig O'Briain" <Padraig Obriain Sun COM> writes:
> 
> > 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.
> 
> Actually, the simple and reliable way of catching focus changes
> is listening to ::focus_in_event, ::focus_out_event.
> 

I had done it this way, but, after finding "has_focus" I thought I would use 
that as I have other properties I am interested in and I could use the same 
code.

> But, yes, if we have a has-focus property, we should properly
> notify on changes to it.
>  
> > Is the following change reasonable?
> 
> > ===================================================================
> > 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;
> 
> These are reasonable, but not complete; there was no default handler
> for focus_in/focus_out for GTK+-1.2, so many widgets override
> these signals and don't chain up.
> 
> Rather than adding the notification to all these widgets or requiring
> widgets to chain up, it might make sense to move both the flag setting
> and the notification gtk_window_real_set_focus().

Should I just raise a bug on this?


> 
> > @@ -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));
> >  }
> 
> Yes, this one is extraneous. grab_focus() is a request, not an action.
> 
> Regards,
>                                        Owen
> 
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list





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