19fd36aef0795ee7d5180478c1dc13dcd9cacde7
[framework/uifw/elementary.git] / src / bin / test_icon_desktops.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6 static Elm_Genlist_Item_Class it_desk;
7
8 static char *
9 desk_gl_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
10 {
11 #ifdef ELM_EFREET
12    Efreet_Desktop *d = (Efreet_Desktop *)data;
13    return strdup(d->name);
14 #else
15    return NULL;
16    (void)data;
17 #endif
18 }
19 static Evas_Object *
20 desk_gl_content_get(void *data, Evas_Object *obj, const char *part)
21 {
22 #ifdef ELM_EFREET
23    Efreet_Desktop *d = (Efreet_Desktop *)data;
24    Evas_Object *ic;
25
26    ic = elm_icon_add(obj);
27    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
28    if (!(!strcmp(part, "elm.swallow.icon"))) return ic;
29    if (!d->icon) return ic;
30    elm_icon_standard_set(ic, d->icon);
31    return ic;
32 #else
33    return NULL;
34    (void)data;
35    (void)obj;
36    (void)part;
37 #endif
38 }
39 static void
40 desk_gl_del(void *data, Evas_Object *obj __UNUSED__)
41 {
42 #ifdef ELM_EFREET
43    Efreet_Desktop *d = (Efreet_Desktop *)data;
44    efreet_desktop_free(d);
45 #else
46    return;
47    (void)data;
48 #endif
49 }
50
51 #ifdef ELM_EFREET
52 static void
53 desktop_sel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
54 {
55    printf("sel\n");
56 }
57 #endif
58
59 void
60 test_icon_desktops(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
61 {
62    Evas_Object *win, *bg, *gl;
63 #ifdef ELM_EFREET
64    Eina_List *desktops;
65 #endif
66
67    win = elm_win_add(NULL, "icon-desktops", ELM_WIN_BASIC);
68    elm_win_title_set(win, "Icon Desktops");
69    elm_win_autodel_set(win, EINA_TRUE);
70
71    bg = elm_bg_add(win);
72    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
73    elm_win_resize_object_add(win, bg);
74    evas_object_show(bg);
75
76    it_desk.item_style     = "default";
77    it_desk.func.text_get = desk_gl_text_get;
78    it_desk.func.content_get  = desk_gl_content_get;
79    it_desk.func.state_get = NULL;
80    it_desk.func.del       = desk_gl_del;
81
82    gl = elm_genlist_add(win);
83    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
84    elm_win_resize_object_add(win, gl);
85    evas_object_show(gl);
86
87 #ifdef ELM_EFREET
88    if (elm_need_efreet())
89      {
90        desktops = efreet_util_desktop_name_glob_list("*");
91        if (desktops)
92          {
93            Efreet_Desktop *d;
94
95            EINA_LIST_FREE(desktops, d)
96              elm_genlist_item_append(gl, &it_desk, d,
97                                     NULL, ELM_GENLIST_ITEM_NONE,
98                                     desktop_sel, NULL);
99          }
100      }
101 #endif
102
103    evas_object_resize(win, 320, 480);
104    evas_object_show(win);
105 }
106 #endif