Use GFileMonitor from GIO instead of directly dealing with inotify.

Ciao,
 Emmanuele.

On Tue, 28 Mar 2017 at 07:58, David C. Rankin <
drankina...@suddenlinkmail.com> wrote:

> All,
>
>   I have a small editor project I've worked on the past several months[1].
> I
> want to add an `inotify` watch on the current filename after each open or
> save
> to detect modification by a foreign process. I have the details of adding
> the
> watch and polling the file descriptor with `pselect`, creating a new
> signal to
> be emitted on the inotify events, and blocking/unblocking the signal for
> normal saves from within the editor, but where I'm stuck is how to
> incorporate
> monitoring `pselect` from the event loop after the `inotify` watchset is
> created?
>
>   Where normally, you would simply call a function that would check whether
> input was available on the file descriptor set monitored by `pselect` in a
> loop, where in the GTK event loop would you incorporate the call to
> `pselect`?
>
>   I may have the answer, but what I'm looking for in an answer is "Yes,
> that's
> a logical approach." or a "No, dummy that's going nowhere."
>
>   From the glib documentation, it appears that one logical vehicle for
> doing
> this is the `g_idle_add()` function which "Adds a function to be called
> whenever there are no higher priority events pending to the default main
> loop." This seems to match exactly what I'm trying to do. I could pass a
> flag
> via the data to control the return of TRUE/FALSE to remove from the list of
> funcitons called when the filename changes, etc.. and within the function
> check the return of `pselect` for any input and emit a signal if any
> changes
> were made to the file by a foreign process between the last check and now.
>
>   Is this the proper vehicle for adding/removing a bit of code to the event
> loop that I could use to monitor `pselect` or is there a better way of
> doing
> this? (the code is GTK+2, using the current glib functions, not the old
> `gtk_idle_add()`, if that makes any difference)
>
>   What say the experts?
>
> footnote 1: https://github.com/drankinatty/gtkwrite
>
> --
> David C. Rankin, J.D.,P.E.
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to