summaryrefslogtreecommitdiff
path: root/legacy/elementary/src/bin/test_icon_desktops.c
blob: e4bdfcd59b5f4f4d5ec90b369bfcec9275c6465e (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
#include <Elementary.h>
#ifndef ELM_LIB_QUICKLAUNCH
static Elm_Genlist_Item_Class it_desk;

static char *
desk_gl_label_get(const void *data, Evas_Object *obj, const char *part)
{
#ifdef ELM_EFREET   
   Efreet_Desktop *d = (Efreet_Desktop *)data;
   return strdup(d->name);
#else
   return NULL;
#endif   
}
static Evas_Object *
desk_gl_icon_get(const void *data, Evas_Object *obj, const char *part)
{
   // FIXME: elm_icon should grok this
#ifdef ELM_EFREET   
   Efreet_Desktop *d = (Efreet_Desktop *)data;
   char *path;
   Evas_Object *ic;
   ic = elm_icon_add(obj);
   evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
   if (!(!strcmp(part, "elm.swallow.icon"))) return ic;
   if (!d->icon) return ic;
   path = efreet_icon_path_find("default", d->icon, 48);
   if (!path)
     {
        path = efreet_icon_path_find("hicolor", d->icon, 48);
        if (!path)
          {
             path = efreet_icon_path_find("gnome", d->icon, 48);
             if (!path)
               {
                  path = efreet_icon_path_find("Human", d->icon, 48);
               }
          }
     }
   if (path)
     {
        elm_icon_file_set(ic, path, NULL);
        free(path);
        return ic;
     }
   return ic;
#else
   return NULL;
#endif   
}
static void
desk_gl_del(const void *data, Evas_Object *obj)
{
#ifdef ELM_EFREET   
   Efreet_Desktop *d = (Efreet_Desktop *)data;
   efreet_desktop_free(d);
#endif   
}

static void
desktop_sel(void *data, Evas_Object *obj, void *event_info)
{
   printf("sel\n");
}

void
test_icon_desktops(void *data, Evas_Object *obj, void *event_info)
{
   Evas_Object *win, *bg, *gl;
   Eina_List *desktops, *l;
   
   win = elm_win_add(NULL, "icon_desktops", ELM_WIN_BASIC);
   elm_win_title_set(win, "Icon Desktops");
   elm_win_autodel_set(win, 1);

   bg = elm_bg_add(win);
   evas_object_size_hint_weight_set(bg, 1.0, 1.0);
   elm_win_resize_object_add(win, bg);
   evas_object_show(bg);

   it_desk.item_style     = "default";
   it_desk.func.label_get = desk_gl_label_get;
   it_desk.func.icon_get  = desk_gl_icon_get;
   it_desk.func.state_get = NULL;
   it_desk.func.del       = desk_gl_del;

   gl = elm_genlist_add(win);
   evas_object_size_hint_weight_set(gl, 1.0, 1.0);
   elm_win_resize_object_add(win, gl);
   evas_object_show(gl);

#ifdef ELM_EFREET   
   elm_need_efreet();
   desktops = efreet_util_desktop_name_glob_list("*");
   if (desktops)
     {
        Efreet_Desktop *d;
        
        EINA_LIST_FOREACH(desktops, l, d)
          {
             elm_genlist_item_append(gl, &it_desk, d, 
                                     NULL, ELM_GENLIST_ITEM_NONE,
                                     desktop_sel, NULL);
//             efreet_desktop_free(d);
          }
        eina_list_free(desktops);
     }
#endif
   
   evas_object_resize(win, 320, 480);
   evas_object_show(win);
}
#endif