dav
dav

Reputation: 1219

gtkmm application with Gio file monitors

I need to monitor multiple directories for changes. I'm using Gtk::Main, calling Gio::Init, and adding directory monitors exactly as the documentation suggests. However, the callback is never called, for any directory. Do I need another loop solely for the monitors, and if so, how would I use it in conjunction with Gtk::Main?

Upvotes: 1

Views: 744

Answers (2)

Andrea Azzarone
Andrea Azzarone

Reputation: 68

You can use just Gtk::Main loop because it is a Glib::MainLoop.

Upvotes: 1

antoyo
antoyo

Reputation: 11933

I had the same problem in Vala and here is the complete solution.

As pointed out by Andrea Azzarone, you can use the Gtk::Main loop.

However, pay attention to your Gio::FileMonitor reference. At the end of the function, it is destroyed so that the callback won't be called if you don't keep a reference to the Gio::FileMonitor object.

I found this idea in this answer.

Upvotes: 1

Related Questions