Hello! I'm having issues getting signals to callback in my Vala application and I'm kind of at a loss. I'm fairly confident that this is a setup issue relating to Gtk.Appplication.run() and Gtk.main() but I cannot be sure. Here's my basic setup:
main () creates and runs a Gtk.Application which creates a Gtk.Window (MainWindow) containing basic buttons and a search entry. The signals related to these widgets work just fine and will merrily call back. However, I have a Gtk.TreeView with a Gtk.TreeStore that is contained within a class called ApplicationProcessModel which inherits from GLib.Object -- these are all created in the MainWindow constructor. The ApplicationProcessModel is supposed to update the Gtk.TreeStore with information relating to running applications and processes. To do this, I'm using libbamf-3.0 which has a number of signals relating to when an application or window is launched and a custom /proc/ parser which I am writing. In ApplicationProcessModel's constructor, I do a connect() to the signals from libbamf just fine and the compiler doesn't complain at all, however, the callbacks never run. I actually get a list of running applications from libbamf and it works just fine. Now, initially, my thought was that I didn't understand how libbamf's signals worked and I was just doing it wrong. So I looked at Plank's (another Vala application using libbamf) source code and it was doing nearly the same thing that I was doing, and it was obviously working. So I tried a couple other signals and callbacks that I knew worked. None of them worked from within ApplicationProcessModel. Then, in desperation to get anything to callback, I went ahead and tried putting a Glib.Timeout that would trigger a callback every second in the ApplicationProcessModel. You can imagine my surprise when, not only is the callback from the Timeout called properly, suddenly my libbamf signal handlers are called, and not just when the timer triggers, but whenever a window is created or closed (like is the intended behavior of the signals). Now, this is great, because it now kind of works -- but I have no idea what exactly putting in the Timeout did to make it work! Moving the Timeout to MainWindow from ApplicationProcessModel causes the fix to not work. I suspect that there is some setup that I'm missing that creating a Timeout does, perhaps related to how the signal is checked and dispatched from the main loop in Gtk.Application.run() or Gtk.main(). I've tried moving to a simpler setup without Gtk.Application with MainWindow created by main() with calls to Gtk.init() at the beginning and Gtk.main() at the end, but that didn't actually change any behavior at all, it still doesn't work normally and works with the Timeout. I'm sure that I'm just missing out on some vital piece of information regarding callbacks. I can provide code if that is needed. Any ideas? Michael P. Starkweather _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list