1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
7 static Elm_Genlist_Item_Class itc;
9 static void _bstatus(void *data, Evas_Object *obj, void *event_info);
10 static void _tstatus(void *data, Evas_Object *obj, void *event_info);
11 static char *_label_get(void *data, Evas_Object *obj, const char *source);
12 static Evas_Object *_icon_get(void *data, Evas_Object *obj, const char *source);
13 static Eina_Bool _state_get(void *data, Evas_Object *obj, const char *source);
14 static void _item_del(void *data, Evas_Object *obj);
15 static void _fill_list(Evas_Object *obj);
16 static Eina_Bool _dir_has_subs(const char *path);
19 _tstatus(void *data, Evas_Object *obj, void *event_info __UNUSED__)
21 Elm_Toolbar_Item *sel;
24 if (elm_panel_hidden_get((Evas_Object*)data))
28 printf("The top panel is currently %s\n", status);
29 sel = elm_toolbar_selected_item_get(obj);
30 elm_toolbar_item_selected_set(sel, EINA_FALSE);
34 _bstatus(void *data, Evas_Object *obj, void *event_info __UNUSED__)
36 Elm_Toolbar_Item *sel;
39 if (elm_panel_hidden_get((Evas_Object*)data))
43 printf("The bottom panel is currently %s\n", status);
44 sel = elm_toolbar_selected_item_get(obj);
45 elm_toolbar_item_selected_set(sel, EINA_FALSE);
49 _label_get(void *data, Evas_Object *obj __UNUSED__, const char *source __UNUSED__)
51 return strdup(ecore_file_file_get(data));
55 _icon_get(void *data, Evas_Object *obj, const char *source)
57 if (!strcmp(source, "elm.swallow.icon"))
61 ic = elm_icon_add(obj);
62 if (ecore_file_is_dir((char *)data))
63 elm_icon_standard_set(ic, "folder");
65 elm_icon_standard_set(ic, "file");
66 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
74 _state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *source __UNUSED__)
80 _item_del(void *data, Evas_Object *obj __UNUSED__)
82 eina_stringshare_del(data);
86 _fill_list(Evas_Object *obj)
90 Eina_List *dirs = NULL, *l;
93 if (!(d = opendir(getenv("HOME")))) return;
94 while ((de = readdir(d)))
98 if (de->d_name[0] == '.') continue;
99 snprintf(buff, sizeof(buff), "%s/%s", getenv("HOME"), de->d_name);
100 if (!ecore_file_is_dir(buff)) continue;
101 real = ecore_file_realpath(buff);
102 dirs = eina_list_append(dirs, real);
106 dirs = eina_list_sort(dirs, eina_list_count(dirs), EINA_COMPARE_CB(strcoll));
108 EINA_LIST_FOREACH(dirs, l, real)
110 Eina_Bool result = EINA_FALSE;
112 result = _dir_has_subs(real);
114 elm_genlist_item_append(obj, &itc, eina_stringshare_add(real),
115 NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
117 elm_genlist_item_append(obj, &itc, eina_stringshare_add(real),
118 NULL, ELM_GENLIST_ITEM_SUBITEMS,
122 eina_list_free(dirs);
126 _dir_has_subs(const char *path)
130 Eina_Bool result = EINA_FALSE;
132 if (!path) return result;
133 if (!(d = opendir(path))) return result;
134 while ((de = readdir(d)))
138 if (de->d_name[0] == '.') continue;
139 snprintf(buff, sizeof(buff), "%s/%s", path, de->d_name);
140 if (ecore_file_is_dir(buff))
151 test_panel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
153 Evas_Object *win, *bg, *panel, *bx, *vbx, *toolbar;
156 win = elm_win_add(NULL, "panel", ELM_WIN_BASIC);
157 elm_win_title_set(win, "Panel");
158 elm_win_autodel_set(win, EINA_TRUE);
160 bg = elm_bg_add(win);
161 elm_win_resize_object_add(win, bg);
162 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
163 evas_object_show(bg);
165 vbx = elm_box_add(win);
166 elm_win_resize_object_add(win, vbx);
167 evas_object_size_hint_weight_set(vbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
168 evas_object_size_hint_align_set(vbx, EVAS_HINT_FILL, EVAS_HINT_FILL);
169 evas_object_show(vbx);
171 bx = elm_box_add(win);
172 elm_box_horizontal_set(bx, EINA_TRUE);
173 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
174 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
175 evas_object_show(bx);
177 panel = elm_panel_add(win);
178 elm_panel_orient_set(panel, ELM_PANEL_ORIENT_TOP);
179 evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, 0);
180 evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
182 toolbar = elm_toolbar_add(win);
183 elm_toolbar_homogeneous_set(toolbar, 0);
184 elm_toolbar_mode_shrink_set(toolbar, ELM_TOOLBAR_SHRINK_NONE);
185 evas_object_size_hint_weight_set(toolbar, EVAS_HINT_EXPAND, 0);
186 evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
187 evas_object_show(toolbar);
189 elm_toolbar_item_append(toolbar, "home", "Hello", _tstatus, panel);
191 elm_panel_content_set(panel, toolbar);
192 elm_box_pack_end(vbx, panel);
193 evas_object_show(panel);
195 panel = elm_panel_add(win);
196 elm_panel_orient_set(panel, ELM_PANEL_ORIENT_LEFT);
197 evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
198 evas_object_size_hint_align_set(panel, 0, EVAS_HINT_FILL);
200 itc.item_style = "default";
201 itc.func.label_get = _label_get;
202 itc.func.icon_get = _icon_get;
203 itc.func.state_get = _state_get;
204 itc.func.del = _item_del;
206 list = elm_genlist_add(win);
207 evas_object_size_hint_min_set(list, 100, -1);
208 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
209 evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
210 evas_object_show(list);
212 elm_panel_content_set(panel, list);
214 elm_box_pack_end(bx, panel);
215 evas_object_show(panel);
219 panel = elm_panel_add(win);
220 elm_panel_orient_set(panel, ELM_PANEL_ORIENT_RIGHT);
221 evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
222 evas_object_size_hint_align_set(panel, 1, EVAS_HINT_FILL);
223 elm_panel_hidden_set(panel, EINA_TRUE);
225 list = elm_genlist_add(win);
226 evas_object_size_hint_min_set(list, 100, -1);
227 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
228 evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
229 evas_object_show(list);
231 elm_panel_content_set(panel, list);
233 elm_box_pack_end(bx, panel);
234 evas_object_show(panel);
238 elm_box_pack_end(vbx, bx);
240 panel = elm_panel_add(win);
241 elm_panel_orient_set(panel, ELM_PANEL_ORIENT_BOTTOM);
242 evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, 0);
243 evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
244 elm_panel_hidden_set(panel, EINA_TRUE);
246 toolbar = elm_toolbar_add(win);
247 elm_toolbar_homogeneous_set(toolbar, 0);
248 elm_toolbar_mode_shrink_set(toolbar, ELM_TOOLBAR_SHRINK_NONE);
249 evas_object_size_hint_weight_set(toolbar, EVAS_HINT_EXPAND, 0);
250 evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
251 evas_object_show(toolbar);
253 elm_toolbar_item_append(toolbar, "home", "Hello", _bstatus, panel);
255 elm_panel_content_set(panel, toolbar);
256 elm_box_pack_end(vbx, panel);
257 evas_object_show(panel);
259 evas_object_resize(win, 320, 400);
260 evas_object_show(win);