summaryrefslogtreecommitdiff
path: root/src/tests/efreet/ef_menu.c
blob: 7565768d7d4fc32fe3c29f77f8139485ec39b8ce (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include "Efreet.h"
#include "config.h"
#include <stdio.h>
#include <unistd.h>
#include "ef_test.h"

#if 0
static void
ef_menu_desktop_exec(Efreet_Menu *menu)
{
    Eina_List *l;

    if (menu->entries)
    {
        Efreet_Desktop *desktop;

        EINA_LIST_FOREACH(menu->entries, l, desktop)
            efreet_desktop_exec(desktop, NULL);
    }
    if (menu->sub_menus)
    {
        Efreet_Menu *sub_menu;

        EINA_LIST_FOREACH(menu->sub_menus, l, sub_menu)
            ef_menu_desktop_exec(sub_menu);
    }
}
#endif

int
ef_cb_menu_get(void)
{
    Efreet_Menu *menu;

    menu = efreet_menu_get();
//    menu = efreet_menu_parse(ef_test_path_get("test.menu"));
    if (!menu)
    {
        printf("efreet_menu_get() returned NULL\n");
        return 0;
    }
    printf("\n");
    efreet_menu_dump(menu, "");
    efreet_menu_free(menu);

    return 1;
}

int
ef_cb_menu_with_slashes(void)
{
    Efreet_Menu *menu;

    menu = efreet_menu_parse(ef_test_path_get("test_menu_slash_bad.menu"));
    if (menu)
    {
        printf("efreet_menu_get() didn't return NULL\n");
        return 0;
    }

    return 1;
}

int
ef_cb_menu_save(void)
{
    Efreet_Menu *menu;
    int ret;

//    menu = efreet_menu_get();
    menu = efreet_menu_parse(ef_test_path_get("test.menu"));
    if (!menu)
    {
        printf("efreet_menu_get() returned NULL\n");
        return 0;
    }
    unlink("/tmp/test.menu");
    ret = efreet_menu_save(menu, "/tmp/test.menu");
    efreet_menu_free(menu);
    return ret;
}

int
ef_cb_menu_edit(void)
{
    Efreet_Menu *menu, *entry;
    Efreet_Desktop *desktop;

//    menu = efreet_menu_get();
    menu = efreet_menu_parse(ef_test_path_get("test.menu"));
    if (!menu)
    {
        printf("efreet_menu_get() returned NULL\n");
        return 0;
    }
#if 0
    printf("\n");
    efreet_menu_dump(menu, "");
    printf("\n");
#endif

    desktop = efreet_desktop_get(ef_test_path_get("test.desktop"));
    if (!desktop)
    {
        efreet_menu_free(menu);
        printf("No desktop found.\n");
        return 0;
    }

    efreet_menu_desktop_insert(menu, desktop, 0);
#if 0
    printf("\n");
    efreet_menu_dump(menu, "");
    printf("\n");
#endif
    entry = eina_list_data_get(menu->entries);
    if (desktop != entry->desktop)
    {
        efreet_menu_free(menu);
        return 0;
    }

    efreet_menu_desktop_insert(menu, desktop, 2);
#if 0
    printf("\n");
    efreet_menu_dump(menu, "");
    printf("\n");
#endif
    entry = eina_list_nth(menu->entries, 2);
    if (desktop != entry->desktop)
    {
        efreet_menu_free(menu);
        return 0;
    }

    efreet_menu_desktop_insert(menu, desktop, -1);
#if 0
    printf("\n");
    efreet_menu_dump(menu, "");
    printf("\n");
#endif
    entry = eina_list_data_get(eina_list_last(menu->entries));
    if (desktop != entry->desktop)
    {
        efreet_menu_free(menu);
        return 0;
    }

    efreet_menu_free(menu);
    return 1;
}