move elementary to trunk base. out of TMP/st.
[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_label_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_icon_get(void *data, Evas_Object *obj, const char *part)
21 {
22    // FIXME: elm_icon should grok this
23 #ifdef ELM_EFREET   
24    Efreet_Desktop *d = (Efreet_Desktop *)data;
25    const char *path;
26    Evas_Object *ic;
27    ic = elm_icon_add(obj);
28    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
29    if (!(!strcmp(part, "elm.swallow.icon"))) return ic;
30    if (!d->icon) return ic;
31    path = efreet_icon_path_find(getenv("E_ICON_THEME"), d->icon, 48);
32    if (!path) 
33      {
34         path = efreet_icon_path_find("default", d->icon, 48);
35         if (!path)
36           {
37              path = efreet_icon_path_find("hicolor", d->icon, 48);
38              if (!path)
39                {
40                   path = efreet_icon_path_find("gnome", d->icon, 48);
41                   if (!path)
42                     {
43                        path = efreet_icon_path_find("Human", d->icon, 48);
44                     }
45                }
46           }
47      }
48    if (path)
49      {
50         elm_icon_file_set(ic, path, NULL);
51         return ic;
52      }
53    return ic;
54 #else
55    return NULL;
56    (void)data;
57    (void)obj;
58    (void)part;
59 #endif   
60 }
61 static void
62 desk_gl_del(void *data, Evas_Object *obj __UNUSED__)
63 {
64 #ifdef ELM_EFREET   
65    Efreet_Desktop *d = (Efreet_Desktop *)data;
66    efreet_desktop_free(d);
67 #else
68    return;
69    (void)data;
70 #endif   
71 }
72
73 #ifdef ELM_EFREET
74 static void
75 desktop_sel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
76 {
77    printf("sel\n");
78 }
79 #endif
80
81 void
82 test_icon_desktops(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
83 {
84    Evas_Object *win, *bg, *gl;
85 #ifdef ELM_EFREET
86    Eina_List *desktops;
87 #endif
88
89    win = elm_win_add(NULL, "icon_desktops", ELM_WIN_BASIC);
90    elm_win_title_set(win, "Icon Desktops");
91    elm_win_autodel_set(win, 1);
92
93    bg = elm_bg_add(win);
94    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
95    elm_win_resize_object_add(win, bg);
96    evas_object_show(bg);
97
98    it_desk.item_style     = "default";
99    it_desk.func.label_get = desk_gl_label_get;
100    it_desk.func.icon_get  = desk_gl_icon_get;
101    it_desk.func.state_get = NULL;
102    it_desk.func.del       = desk_gl_del;
103
104    gl = elm_genlist_add(win);
105    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
106    elm_win_resize_object_add(win, gl);
107    evas_object_show(gl);
108
109 #ifdef ELM_EFREET
110    if (elm_need_efreet())
111      {
112        desktops = efreet_util_desktop_name_glob_list("*");
113        if (desktops)
114          {
115            Efreet_Desktop *d;
116           
117            EINA_LIST_FREE(desktops, d)
118              elm_genlist_item_append(gl, &it_desk, d,
119                                     NULL, ELM_GENLIST_ITEM_NONE,
120                                     desktop_sel, NULL);
121          }
122      }
123 #endif
124
125    evas_object_resize(win, 320, 480);
126    evas_object_show(win);
127 }
128 #endif