/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */
/*
   Build with:
   gcc -o gkeyfile-test `pkg-config --cflags --libs glib-2.0` gkeyfile-test.c

*/

#include <glib.h>

int
main (int argc, char **argv)
{
        GKeyFile *key_file;
        GPtrArray *dirs;
        gboolean found;
        const char *file;
        char *full_path;
        GError *error;

        dirs = g_ptr_array_sized_new (5);
        g_ptr_array_add (dirs, "/usr/share/gdm/BuiltInSessions");
        g_ptr_array_add (dirs, "/usr/share/xsessions");
        g_ptr_array_add (dirs, "/usr/share/applications/");
        g_ptr_array_add (dirs, NULL);

        key_file = g_key_file_new ();

        file = "gnome.desktop";
        full_path = NULL;
        error = NULL;
        found = g_key_file_load_from_dirs (key_file,
                                           file,
                                           (const char **)dirs->pdata,
                                           &full_path,
                                           G_KEY_FILE_NONE,
                                           &error);
        if (found) {
                g_message ("File found at %s", full_path);
        } else {
                g_message ("File not found: %s", error->message);
        }

        g_free (full_path);

        g_ptr_array_free (dirs, TRUE);

        g_key_file_free (key_file);

        return 0;
}
