#include <gtk/gtk.h>
#include <gio/gio.h>

static void on_changed(GFileMonitor     *monitor,
    GFile            *file,
    GFile            *other_file,
    GFileMonitorEvent event_type,
    gpointer          user_data)
{
    char* name = g_file_get_parse_name(file);
    g_debug("changed: %s", name);
    g_free(name);
}

int main(int argc, char** argv)
{
    gtk_init(&argc, &argv);
    if(argc > 1)
    {
        GFile *gf = g_file_new_for_path(argv[1]);
        GFileMonitor* mon = g_file_monitor_directory(gf, 0, NULL, NULL);
        g_signal_connect(mon, "changed", G_CALLBACK(on_changed), NULL);
        g_object_unref(gf);
        gtk_main();
        g_file_monitor_cancel(mon);
        g_object_unref(mon);
    }
    return 0;
}
