[Sugar-devel] Activity title update
James Cameron
quozl at laptop.org
Tue Jul 6 05:30:52 EDT 2010
On Tue, Jul 06, 2010 at 11:05:34AM +0200, Tomeu Vizoso wrote:
> On Mon, Jul 5, 2010 at 17:57, Bernie Innocenti <bernie at codewiz.org> wrote:
> > On Mon, 2010-07-05 at 16:37 +0200, Tomeu Vizoso wrote:
> >
> >> But you can do the same with Gtk+, cannot you?
> >>
> >> "This signal is emitted when the Return or Enter key is pressed or the
> >> line edit loses focus"
> >
> > No, GTK does not seem to send a "focus-out-event" when the user clicks
> > on the close button. Which is what makes my approach fail.
>
> Ok, that's quite different from what I read initially.
>
> Have made a little test that seems to show that when the user clicks
> on a button and a text field had the focus, the focus is moved from
> the field to the button and thus focus-out-event is emitted:
I've tested this fragment on F11 for XO-1.5, and I agree, it does seem
to be working fine. I added a changed callback, and as far as I can
tell a metadata update could be deferred until changed plus a delta
time, or focus-out, whichever occurs first.
import gtk
def changed_cb(entry):
print 'changed-event'
def focus_in_event_cb(entry, event):
print 'focus-in-event'
def focus_out_event_cb(entry, event):
print 'focus-out-event'
def button_activate_cb(button):
gtk.main_quit()
w = gtk.Window()
w.show()
hbox = gtk.HBox()
w.add(hbox)
hbox.show()
e = gtk.Entry()
e.connect('focus-in-event', focus_in_event_cb)
e.connect('focus-out-event', focus_out_event_cb)
e.connect('changed', changed_cb)
hbox.add(e)
e.show()
b = gtk.Button('mec')
b.connect('clicked', button_activate_cb)
hbox.add(b)
b.show()
gtk.main()
--
James Cameron
http://quozl.linux.org.au/
More information about the Sugar-devel
mailing list