maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   gtk/hildon: is there a signal for when the *window* gets focus (https://talk.maemo.org/showthread.php?t=48513)

rambo 2010-03-28 05:36

gtk/hildon: is there a signal for when the *window* gets focus
 
the "set-focus" -signal is for any widget in the window which is way too often for my needs. I just want to check if certain data is still fresh when the program main window gets focus (either via task manager [if it was in background] or when returning from a subview [which I could do via other means too but one signal to rule them all would be great]).

I'm doing this in python in case that detail matters (it should not).

I tried to look for it last night but I may have been blind (or just tired).

conny 2010-03-28 07:31

Re: gtk/hildon: is there a signal for when the *window* gets focus
 
Try the "notify::is-topmost" property of HildonWindow. That should do the trick.
http://maemo.org/api_refs/5.0/5.0-fi...ow--is-topmost

rambo 2010-03-29 18:50

Re: gtk/hildon: is there a signal for when the *window* gets focus
 
Quote:

Originally Posted by conny (Post 585086)
Try the "notify::is-topmost" property of HildonWindow. That should do the trick.
http://maemo.org/api_refs/5.0/5.0-fi...ow--is-topmost

Finally got around testing this, the problem is that it's a property, how do I trigger a signal ?

I found that there is 'focus' signal on gtk.Widget from which just about everything inherits from but unfortunatly that gets triggered for the window only at program start (even switching between programs does not trigger it), same for 'window-state-event'

I guess part of the problem is using window vs stackablewindow offer no difference here (and stackablewindow is definitely the way to go).

edit: and also the set-focus is not usable since when I return from stackable window or other application the previous widget still retains it's focus...

conny 2010-03-29 18:59

Re: gtk/hildon: is there a signal for when the *window* gets focus
 
Every property emits a signal whenever it's value is changed. The "notify::" part will do the trick. Try something like this:
Code:

g_signal_connect (win, "notify::is-topmost", G_CALLBACK(cb_func), NULL);

rambo 2010-03-29 20:27

Re: gtk/hildon: is there a signal for when the *window* gets focus
 
Quote:

Originally Posted by conny (Post 587176)
Every property emits a signal whenever it's value is changed.

Recalled something like that but the problem is attaching the signal to the property

Quote:

Originally Posted by conny (Post 587176)
The "notify::" part will do the trick. Try something like this:
Code:

g_signal_connect (win, "notify::is-topmost", G_CALLBACK(cb_func), NULL);

Any idea how to do that in python ?

Edit: I was stupid (and tired) and parsed the C wrong at first...

Code:

self.mainwindow.connect('notify::is-topmost', self.got_focus, 'notify::is-topmost')
Works fine.

"Problem" is that I get this signal for every subwindow instantiated as well but that is a minor annoyance, thanks.

edit2: I realized that of course I get the signal every time I change away from the window, it's no longer topmost... duh! (yes I was tired last night)

yerga 2010-03-29 20:40

Re: gtk/hildon: is there a signal for when the *window* gets focus
 
Quote:

Originally Posted by rambo (Post 587258)
Any idea how to do that in python ?

I think that the normal way should work:
window.connect("notify::is-topmost", callback)


All times are GMT. The time now is 21:15.

vBulletin® Version 3.8.8