summaryrefslogtreecommitdiff
path: root/src-ng/main.c
blob: 0a3ad0a602b9f01033d36c3e4aaf7878f83d4087 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdlib.h>

#include <glib.h>

#include "nautilus-file.h"
#include "nautilus-task-manager.h"

static void
got_info (NautilusFile *file,
          GFileInfo    *info,
          GError       *error,
          gpointer      user_data)
{
    g_message ("Got info for %p\n\tDisplay name: %s",
               (gpointer) file,
               g_file_info_get_display_name (info));

    g_object_unref (info);

    g_main_loop_quit ((GMainLoop *) user_data);
}

int
main (int    argc,
      char **argv)
{
    g_autoptr (NautilusTaskManager) manager = NULL;
    g_autoptr (GFile) location = NULL;
    g_autoptr (NautilusFile) file = NULL;
    g_autoptr (NautilusFile) duplicate_file = NULL;
    GMainLoop *loop;

    if (!(argc > 1))
    {
        g_message ("No file provided, exiting");
        return EXIT_SUCCESS;
    }

    manager = nautilus_task_manager_dup_singleton ();
    location = g_file_new_for_commandline_arg (argv[1]);

    g_message ("Creating NautilusFile");
    file = nautilus_file_new (location);
    g_message ("Got %p\n", (gpointer) file);

    g_message ("Creating another NautilusFile for the same location");
    duplicate_file = nautilus_file_new (location);
    g_message ("Got %p, which is %s\n",
               (gpointer) duplicate_file,
               file == duplicate_file? "the same" : "not the same");

    loop = g_main_loop_new (NULL, TRUE);

    nautilus_file_query_info (file, NULL, got_info, loop);

    g_main_loop_run (loop);

    return EXIT_SUCCESS;
}