コード例 #1
0
static void
constructed (GObject *object)
{
	G_OBJECT_CLASS (nm_inotify_helper_parent_class)->constructed (object);

	init_inotify (NM_INOTIFY_HELPER (object));
}
コード例 #2
0
static gboolean
inotify_event_handler (GIOChannel *channel, GIOCondition cond, gpointer user_data)
{
	NMInotifyHelper *self = NM_INOTIFY_HELPER (user_data);
	struct inotify_event evt;

	/* read the notifications from the watch descriptor */
	while (g_io_channel_read_chars (channel, (gchar *) &evt, sizeof (struct inotify_event), NULL, NULL) == G_IO_STATUS_NORMAL) {
		gchar filename[PATH_MAX + 1];

		filename[0] = '\0';
		if (evt.len > 0) {
			g_io_channel_read_chars (channel,
			                        filename,
			                        evt.len > PATH_MAX ? PATH_MAX : evt.len,
			                        NULL, NULL);
		}

		if (!(evt.mask & IN_IGNORED))
			g_signal_emit (self, signals[EVENT], 0, &evt, &filename[0]);
	}

	return TRUE;
}