summaryrefslogtreecommitdiff
path: root/src/tests/efreet/efreet_spec_test.c
blob: 776b6546870cd60d711d953e02c3d79688ea28d8 (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
60
61
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <Efreet.h>
#include <stdio.h>
#include <limits.h>
#include "ef_test.h"

static void dump(Efreet_Menu *menu, const char *path);

int
main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
    Efreet_Menu *menu;

    if (!efreet_init())
    {
        fprintf(stderr, "Failed to init Efreet\n");
        return 1;
    }

    menu = efreet_menu_get();
    if (!menu)
    {
        fprintf(stderr, "Failed to read menu\n");
        return 1;
    }

    dump(menu, "");

    efreet_menu_free(menu);
    efreet_shutdown();
    return 0;
}

static void
dump(Efreet_Menu *menu, const char *path)
{
    Efreet_Menu *entry;
    Eina_List *l;

    if (!menu || !menu->entries) return;

    EINA_LIST_FOREACH(menu->entries, l, entry)
    {
        if (entry->type == EFREET_MENU_ENTRY_DESKTOP)
        {
            if (!path || !*path) path = "/";
            printf("%s\t%s\t%s\n", path, entry->id,
                                    entry->desktop->orig_path);
        }
        else if (entry->type == EFREET_MENU_ENTRY_MENU)
        {
            char new_path[PATH_MAX];

            snprintf(new_path, sizeof(new_path), "%s%s/", path, entry->name);
            dump(entry, new_path);
        }
    }
}