replicate new bug from 68495
[framework/uifw/elementary.git] / src / bin / test_toolbar.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6 static void
7 tb_1(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
8 {
9    char buf[PATH_MAX];
10    snprintf(buf, sizeof(buf), "%s/images/panel_01.jpg", elm_app_data_dir_get());
11    elm_photo_file_set(data, buf);
12 }
13
14 static void
15 tb_2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
16 {
17    char buf[PATH_MAX];
18    snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
19    elm_photo_file_set(data, buf);
20 }
21
22 static void
23 tb_3(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
24 {
25    char buf[PATH_MAX];
26    snprintf(buf, sizeof(buf), "%s/images/wood_01.jpg", elm_app_data_dir_get());
27    elm_photo_file_set(data, buf);
28 }
29
30 static void
31 tb_3a(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
32 {
33    tb_3(data, obj, event_info);
34    elm_toolbar_item_state_set(event_info, elm_toolbar_item_state_next(event_info));
35 }
36
37 static void
38 tb_3b(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
39 {
40    tb_3(data, obj, event_info);
41    elm_toolbar_item_state_unset(event_info);
42 }
43
44 static void
45 tb_4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
46 {
47    char buf[PATH_MAX];
48    snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", elm_app_data_dir_get());
49    elm_photo_file_set(data, buf);
50 }
51
52 static void
53 tb_4a(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
54 {
55    elm_toolbar_item_state_set(event_info, elm_toolbar_item_state_prev(event_info));
56 }
57
58 static void
59 tb_5(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
60 {
61    elm_photo_file_set(data, NULL);
62 }
63
64 void
65 test_toolbar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
66 {
67    Evas_Object *win, *bg, *bx, *tb, *ph, *menu;
68    Evas_Object *ph1, *ph2, *ph3, *ph4;
69    Elm_Object_Item *tb_it;
70    Elm_Object_Item *menu_it;
71    char buf[PATH_MAX];
72
73    win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC);
74    elm_win_title_set(win, "Toolbar");
75    elm_win_autodel_set(win, EINA_TRUE);
76
77    bg = elm_bg_add(win);
78    elm_win_resize_object_add(win, bg);
79    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
80    evas_object_show(bg);
81
82    bx = elm_box_add(win);
83    elm_win_resize_object_add(win, bx);
84    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
85    evas_object_show(bx);
86
87    tb = elm_toolbar_add(win);
88    elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_MENU);
89    evas_object_size_hint_weight_set(tb, 0.0, 0.0);
90    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
91    elm_object_scale_set(tb, 0.9);
92
93    ph1 = elm_photo_add(win);
94    ph2 = elm_photo_add(win);
95    ph3 = elm_photo_add(win);
96    ph4 = elm_photo_add(win);
97
98    tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1);
99    elm_object_item_disabled_set(tb_it, EINA_TRUE);
100    elm_toolbar_item_priority_set(tb_it, 100);
101
102    tb_it = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1);
103    elm_toolbar_item_priority_set(tb_it, -100);
104
105    tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4);
106    elm_toolbar_item_priority_set(tb_it, 150);
107
108    tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4);
109    elm_toolbar_item_priority_set(tb_it, 0);
110
111    tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4);
112    elm_toolbar_item_priority_set(tb_it, -200);
113
114    tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL);
115    elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
116    elm_toolbar_item_priority_set(tb_it, -999999);
117    elm_toolbar_menu_parent_set(tb, win);
118    menu = elm_toolbar_item_menu_get(tb_it);
119
120    elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4);
121    menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4);
122    elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4);
123    elm_menu_item_add(menu, NULL, "edit-delete", "Menu", tb_5, ph4);
124
125    elm_box_pack_end(bx, tb);
126    evas_object_show(tb);
127
128    tb = elm_table_add(win);
129    //elm_table_homogeneous_set(tb, 1);
130    evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
131    evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
132
133    ph = ph1;
134    elm_photo_size_set(ph, 40);
135    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
136    elm_photo_file_set(ph, buf);
137    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
138    evas_object_size_hint_align_set(ph, 0.5, 0.5);
139    elm_table_pack(tb, ph, 0, 0, 1, 1);
140    evas_object_show(ph);
141
142    ph = ph2;
143    elm_photo_size_set(ph, 80);
144    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
145    evas_object_size_hint_align_set(ph, 0.5, 0.5);
146    elm_table_pack(tb, ph, 1, 0, 1, 1);
147    evas_object_show(ph);
148
149    ph = ph3;
150    elm_photo_size_set(ph, 20);
151    snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
152    elm_photo_file_set(ph, buf);
153    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
154    evas_object_size_hint_align_set(ph, 0.5, 0.5);
155    elm_table_pack(tb, ph, 0, 1, 1, 1);
156    evas_object_show(ph);
157
158    ph = ph4;
159    elm_photo_size_set(ph, 60);
160    snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get());
161    elm_photo_file_set(ph, buf);
162    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
163    evas_object_size_hint_align_set(ph, 0.5, 0.5);
164    elm_table_pack(tb, ph, 1, 1, 1, 1);
165    evas_object_show(ph);
166
167    elm_box_pack_end(bx, tb);
168    evas_object_show(tb);
169
170    evas_object_resize(win, 320, 300);
171    evas_object_show(win);
172 }
173
174 void
175 test_toolbar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
176 {
177    Evas_Object *win, *bg, *bx, *tb, *ph, *menu;
178    Evas_Object *ph1, *ph2, *ph3, *ph4;
179    Elm_Object_Item *item;
180    Elm_Object_Item *menu_it;
181    char buf[PATH_MAX];
182
183    win = elm_win_add(NULL, "toolbar2", ELM_WIN_BASIC);
184    elm_win_title_set(win, "Toolbar 2");
185    elm_win_autodel_set(win, EINA_TRUE);
186
187    bg = elm_bg_add(win);
188    elm_win_resize_object_add(win, bg);
189    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
190    evas_object_show(bg);
191
192    bx = elm_box_add(win);
193    elm_win_resize_object_add(win, bx);
194    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
195    evas_object_show(bx);
196
197    tb = elm_toolbar_add(win);
198    elm_toolbar_homogeneous_set(tb, 0);
199    elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);
200    evas_object_size_hint_weight_set(tb, 0.0, 0.0);
201    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
202
203    ph1 = elm_photo_add(win);
204    ph2 = elm_photo_add(win);
205    ph3 = elm_photo_add(win);
206    ph4 = elm_photo_add(win);
207
208    item = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1);
209    elm_object_item_disabled_set(item, EINA_TRUE);
210    elm_toolbar_item_priority_set(item, -100);
211
212    item = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1);
213    elm_toolbar_item_priority_set(item, 100);
214
215    item = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4);
216    elm_toolbar_item_priority_set(item, -150);
217
218    item = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4);
219    elm_toolbar_item_priority_set(item, -200);
220
221    item = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4);
222    elm_toolbar_item_priority_set(item, 0);
223
224    item = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL);
225    elm_toolbar_item_menu_set(item, EINA_TRUE);
226    elm_toolbar_item_priority_set(item, -999999);
227    elm_toolbar_menu_parent_set(tb, win);
228    menu = elm_toolbar_item_menu_get(item);
229
230    elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4);
231    menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4);
232    elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4);
233    elm_menu_item_add(menu, NULL, "edit-delete", "Scroll", tb_5, ph4);
234
235    elm_box_pack_end(bx, tb);
236    evas_object_show(tb);
237
238    tb = elm_table_add(win);
239    //elm_table_homogeneous_set(tb, 1);
240    evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
241    evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
242
243    ph = ph1;
244    elm_photo_size_set(ph, 40);
245    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
246    elm_photo_file_set(ph, buf);
247    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
248    evas_object_size_hint_align_set(ph, 0.5, 0.5);
249    elm_table_pack(tb, ph, 0, 0, 1, 1);
250    evas_object_show(ph);
251
252    ph = ph2;
253    elm_photo_size_set(ph, 80);
254    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
255    evas_object_size_hint_align_set(ph, 0.5, 0.5);
256    elm_table_pack(tb, ph, 1, 0, 1, 1);
257    evas_object_show(ph);
258
259    ph = ph3;
260    elm_photo_size_set(ph, 20);
261    snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
262    elm_photo_file_set(ph, buf);
263    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
264    evas_object_size_hint_align_set(ph, 0.5, 0.5);
265    elm_table_pack(tb, ph, 0, 1, 1, 1);
266    evas_object_show(ph);
267
268    ph = ph4;
269    elm_photo_size_set(ph, 60);
270    snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get());
271    elm_photo_file_set(ph, buf);
272    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
273    evas_object_size_hint_align_set(ph, 0.5, 0.5);
274    elm_table_pack(tb, ph, 1, 1, 1, 1);
275    evas_object_show(ph);
276
277    elm_box_pack_end(bx, tb);
278    evas_object_show(tb);
279
280    evas_object_resize(win, 320, 300);
281    evas_object_show(win);
282 }
283
284 void
285 test_toolbar3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
286 {
287    Evas_Object *win, *bg, *bx, *tb, *ph, *menu;
288    Evas_Object *ph1, *ph2, *ph3, *ph4;
289    Elm_Object_Item *tb_it;
290    Elm_Object_Item *menu_it;
291    char buf[PATH_MAX];
292
293    win = elm_win_add(NULL, "toolbar3", ELM_WIN_BASIC);
294    elm_win_title_set(win, "Toolbar 3");
295    elm_win_autodel_set(win, EINA_TRUE);
296
297    bg = elm_bg_add(win);
298    elm_win_resize_object_add(win, bg);
299    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
300    evas_object_show(bg);
301
302    bx = elm_box_add(win);
303    elm_win_resize_object_add(win, bx);
304    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
305    evas_object_show(bx);
306
307    tb = elm_toolbar_add(win);
308    elm_toolbar_homogeneous_set(tb, EINA_FALSE);
309    elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_NONE);
310    evas_object_size_hint_weight_set(tb, 0.0, 0.0);
311    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
312
313    ph1 = elm_photo_add(win);
314    ph2 = elm_photo_add(win);
315    ph3 = elm_photo_add(win);
316    ph4 = elm_photo_add(win);
317
318    tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1);
319    elm_object_item_disabled_set(tb_it, EINA_TRUE);
320    elm_toolbar_item_priority_set(tb_it, EINA_FALSE);
321
322    tb_it = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1);
323    elm_toolbar_item_priority_set(tb_it, -200);
324
325    tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4);
326    elm_toolbar_item_priority_set(tb_it, EINA_TRUE);
327
328    tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4);
329    elm_toolbar_item_priority_set(tb_it, -10);
330
331    tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4);
332    elm_toolbar_item_priority_set(tb_it, 50);
333
334    tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL);
335    elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
336    elm_toolbar_item_priority_set(tb_it, 999999);
337    elm_toolbar_menu_parent_set(tb, win);
338    menu = elm_toolbar_item_menu_get(tb_it);
339
340    elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4);
341    menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4);
342    elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4);
343    elm_menu_item_add(menu, NULL, "edit-delete", "None", tb_5, ph4);
344
345    elm_box_pack_end(bx, tb);
346    evas_object_show(tb);
347
348    tb = elm_table_add(win);
349    evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
350    evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
351
352    ph = ph1;
353    elm_photo_size_set(ph, 40);
354    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
355    elm_photo_file_set(ph, buf);
356    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
357    evas_object_size_hint_align_set(ph, 0.5, 0.5);
358    elm_table_pack(tb, ph, 0, 0, 1, 1);
359    evas_object_show(ph);
360
361    ph = ph2;
362    elm_photo_size_set(ph, 80);
363    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
364    evas_object_size_hint_align_set(ph, 0.5, 0.5);
365    elm_table_pack(tb, ph, 1, 0, 1, 1);
366    evas_object_show(ph);
367
368    ph = ph3;
369    elm_photo_size_set(ph, 20);
370    snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
371    elm_photo_file_set(ph, buf);
372    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
373    evas_object_size_hint_align_set(ph, 0.5, 0.5);
374    elm_table_pack(tb, ph, 0, 1, 1, 1);
375    evas_object_show(ph);
376
377    ph = ph4;
378    elm_photo_size_set(ph, 60);
379    snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get());
380    elm_photo_file_set(ph, buf);
381    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
382    evas_object_size_hint_align_set(ph, 0.5, 0.5);
383    elm_table_pack(tb, ph, 1, 1, 1, 1);
384    evas_object_show(ph);
385
386    elm_box_pack_end(bx, tb);
387    evas_object_show(tb);
388
389    evas_object_resize(win, 320, 300);
390    evas_object_show(win);
391 }
392
393 /* The same test of toolbar, but using hide shrink mode instead of menu */
394 void
395 test_toolbar4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
396 {
397    Evas_Object *win, *bg, *bx, *tb, *ph, *menu;
398    Evas_Object *ph1, *ph2, *ph3, *ph4;
399    Elm_Object_Item *tb_it;
400    Elm_Object_Item *menu_it;
401    char buf[PATH_MAX];
402
403    win = elm_win_add(NULL, "toolbar4", ELM_WIN_BASIC);
404    elm_win_title_set(win, "Toolbar 4");
405    elm_win_autodel_set(win, EINA_TRUE);
406
407    bg = elm_bg_add(win);
408    elm_win_resize_object_add(win, bg);
409    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
410    evas_object_show(bg);
411
412    bx = elm_box_add(win);
413    elm_win_resize_object_add(win, bx);
414    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
415    evas_object_show(bx);
416
417    tb = elm_toolbar_add(win);
418    elm_toolbar_homogeneous_set(tb, 0);
419    elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_HIDE);
420    evas_object_size_hint_weight_set(tb, 0.0, 0.0);
421    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
422
423    ph1 = elm_photo_add(win);
424    ph2 = elm_photo_add(win);
425    ph3 = elm_photo_add(win);
426    ph4 = elm_photo_add(win);
427
428    tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1);
429    elm_object_item_disabled_set(tb_it, EINA_TRUE);
430    elm_toolbar_item_priority_set(tb_it, 100);
431
432    tb_it = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1);
433    elm_toolbar_item_priority_set(tb_it, -100);
434
435    tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4);
436    elm_toolbar_item_priority_set(tb_it, 150);
437
438    tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4);
439    elm_toolbar_item_priority_set(tb_it, 0);
440
441    tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4);
442    elm_toolbar_item_priority_set(tb_it, -200);
443
444    tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL);
445    elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
446    elm_toolbar_item_priority_set(tb_it, -999999);
447    elm_toolbar_menu_parent_set(tb, win);
448    menu = elm_toolbar_item_menu_get(tb_it);
449
450    elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4);
451    menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4);
452    elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4);
453    elm_menu_item_add(menu, NULL, "edit-delete", "Menu", tb_5, ph4);
454
455    elm_box_pack_end(bx, tb);
456    evas_object_show(tb);
457
458    tb = elm_table_add(win);
459    evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
460    evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
461
462    ph = ph1;
463    elm_photo_size_set(ph, 40);
464    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
465    elm_photo_file_set(ph, buf);
466    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
467    evas_object_size_hint_align_set(ph, 0.5, 0.5);
468    elm_table_pack(tb, ph, 0, 0, 1, 1);
469    evas_object_show(ph);
470
471    ph = ph2;
472    elm_photo_size_set(ph, 80);
473    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
474    evas_object_size_hint_align_set(ph, 0.5, 0.5);
475    elm_table_pack(tb, ph, 1, 0, 1, 1);
476    evas_object_show(ph);
477
478    ph = ph3;
479    elm_photo_size_set(ph, 20);
480    snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
481    elm_photo_file_set(ph, buf);
482    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
483    evas_object_size_hint_align_set(ph, 0.5, 0.5);
484    elm_table_pack(tb, ph, 0, 1, 1, 1);
485    evas_object_show(ph);
486
487    ph = ph4;
488    elm_photo_size_set(ph, 60);
489    snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get());
490    elm_photo_file_set(ph, buf);
491    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
492    evas_object_size_hint_align_set(ph, 0.5, 0.5);
493    elm_table_pack(tb, ph, 1, 1, 1, 1);
494    evas_object_show(ph);
495
496    elm_box_pack_end(bx, tb);
497    evas_object_show(tb);
498
499    evas_object_resize(win, 320, 300);
500    evas_object_show(win);
501 }
502
503 /* Toolbar with multiple state buttons */
504 void
505 test_toolbar5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
506 {
507    Evas_Object *win, *bg, *bx, *tb, *ph, *menu;
508    Evas_Object *ph1, *ph2, *ph3, *ph4;
509    Elm_Object_Item *tb_it;
510    Elm_Object_Item *menu_it;
511    char buf[PATH_MAX];
512
513    win = elm_win_add(NULL, "toolbar5", ELM_WIN_BASIC);
514    elm_win_title_set(win, "Toolbar 5");
515    elm_win_autodel_set(win, EINA_TRUE);
516
517    bg = elm_bg_add(win);
518    elm_win_resize_object_add(win, bg);
519    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
520    evas_object_show(bg);
521
522    bx = elm_box_add(win);
523    elm_win_resize_object_add(win, bx);
524    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
525    evas_object_show(bx);
526
527    tb = elm_toolbar_add(win);
528    elm_toolbar_homogeneous_set(tb, 0);
529    elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_MENU);
530    evas_object_size_hint_weight_set(tb, 0.0, 0.0);
531    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
532    elm_toolbar_no_select_mode_set(tb, EINA_TRUE);
533
534    ph1 = elm_photo_add(win);
535    ph2 = elm_photo_add(win);
536    ph3 = elm_photo_add(win);
537    ph4 = elm_photo_add(win);
538
539    tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1);
540    elm_object_item_disabled_set(tb_it, EINA_TRUE);
541    elm_toolbar_item_priority_set(tb_it, 100);
542
543    snprintf(buf, sizeof(buf), "%s/images/icon_04.pngj", elm_app_data_dir_get());
544    tb_it = elm_toolbar_item_append(tb, buf, "World", tb_2, ph1);
545    elm_toolbar_item_priority_set(tb_it, -100);
546
547    tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3a, ph4);
548    elm_toolbar_item_state_add(tb_it, "object-rotate-left", "H2", tb_3b, ph4);
549    elm_toolbar_item_priority_set(tb_it, 150);
550
551    tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4a, ph4);
552    elm_toolbar_item_state_add(tb_it, "emptytrash", "Comes2", tb_4a, ph4);
553    elm_toolbar_item_state_add(tb_it, "trashcan_full", "Comes3", tb_4a, ph4);
554    elm_toolbar_item_priority_set(tb_it, 0);
555
556    tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4);
557    elm_toolbar_item_priority_set(tb_it, -200);
558
559    tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL);
560    elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
561    elm_toolbar_item_priority_set(tb_it, -999999);
562    elm_toolbar_menu_parent_set(tb, win);
563    menu = elm_toolbar_item_menu_get(tb_it);
564
565    elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4);
566    menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4);
567    elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4);
568    elm_menu_item_add(menu, NULL, "edit-delete", "Menu", tb_5, ph4);
569
570    elm_box_pack_end(bx, tb);
571    evas_object_show(tb);
572
573    tb = elm_table_add(win);
574    evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
575    evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
576
577    ph = ph1;
578    elm_photo_size_set(ph, 40);
579    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
580    elm_photo_file_set(ph, buf);
581    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
582    evas_object_size_hint_align_set(ph, 0.5, 0.5);
583    elm_table_pack(tb, ph, 0, 0, 1, 1);
584    evas_object_show(ph);
585
586    ph = ph2;
587    elm_photo_size_set(ph, 80);
588    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
589    evas_object_size_hint_align_set(ph, 0.5, 0.5);
590    elm_table_pack(tb, ph, 1, 0, 1, 1);
591    evas_object_show(ph);
592
593    ph = ph3;
594    elm_photo_size_set(ph, 20);
595    snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
596    elm_photo_file_set(ph, buf);
597    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
598    evas_object_size_hint_align_set(ph, 0.5, 0.5);
599    elm_table_pack(tb, ph, 0, 1, 1, 1);
600    evas_object_show(ph);
601
602    ph = ph4;
603    elm_photo_size_set(ph, 60);
604    snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get());
605    elm_photo_file_set(ph, buf);
606    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
607    evas_object_size_hint_align_set(ph, 0.5, 0.5);
608    elm_table_pack(tb, ph, 1, 1, 1, 1);
609    evas_object_show(ph);
610
611    elm_box_pack_end(bx, tb);
612    evas_object_show(tb);
613
614    evas_object_resize(win, 320, 300);
615    evas_object_show(win);
616 }
617
618 void
619 test_toolbar6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
620 {
621    Evas_Object *win, *bg, *bx, *tb, *ph, *menu;
622    Evas_Object *ph1, *ph2, *ph3, *ph4;
623    Elm_Object_Item *tb_it;
624    Elm_Object_Item *menu_it;
625    char buf[PATH_MAX];
626
627    win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC);
628    elm_win_title_set(win, "Toolbar");
629    elm_win_autodel_set(win, EINA_TRUE);
630
631    bg = elm_bg_add(win);
632    elm_win_resize_object_add(win, bg);
633    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
634    evas_object_show(bg);
635
636    bx = elm_box_add(win);
637    elm_win_resize_object_add(win, bx);
638    elm_box_horizontal_set(bx, EINA_TRUE);
639    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
640    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
641    evas_object_show(bx);
642
643    tb = elm_toolbar_add(win);
644    elm_toolbar_horizontal_set(tb, EINA_FALSE);
645    elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_MENU);
646    evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
647    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
648
649    ph1 = elm_photo_add(win);
650    ph2 = elm_photo_add(win);
651    ph3 = elm_photo_add(win);
652    ph4 = elm_photo_add(win);
653
654    tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1);
655    elm_object_item_disabled_set(tb_it, EINA_TRUE);
656    elm_toolbar_item_priority_set(tb_it, 100);
657
658    tb_it = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1);
659    elm_toolbar_item_priority_set(tb_it, -100);
660
661    tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4);
662    elm_toolbar_item_priority_set(tb_it, 150);
663
664    tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4);
665    elm_toolbar_item_priority_set(tb_it, 0);
666
667    tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4);
668    elm_toolbar_item_priority_set(tb_it, -200);
669
670    tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL);
671    elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
672    elm_toolbar_item_priority_set(tb_it, -999999);
673    elm_toolbar_menu_parent_set(tb, win);
674    menu = elm_toolbar_item_menu_get(tb_it);
675
676    elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4);
677    menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4);
678    elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4);
679    elm_menu_item_add(menu, NULL, "edit-delete", "Menu", tb_5, ph4);
680
681    elm_box_pack_end(bx, tb);
682    evas_object_show(tb);
683
684    tb = elm_table_add(win);
685    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
686    evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
687
688    ph = ph1;
689    elm_photo_size_set(ph, 40);
690    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
691    elm_photo_file_set(ph, buf);
692    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
693    evas_object_size_hint_align_set(ph, 0.5, 0.5);
694    elm_table_pack(tb, ph, 0, 0, 1, 1);
695    evas_object_show(ph);
696
697    ph = ph2;
698    elm_photo_size_set(ph, 80);
699    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
700    evas_object_size_hint_align_set(ph, 0.5, 0.5);
701    elm_table_pack(tb, ph, 1, 0, 1, 1);
702    evas_object_show(ph);
703
704    ph = ph3;
705    elm_photo_size_set(ph, 20);
706    snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
707    elm_photo_file_set(ph, buf);
708    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
709    evas_object_size_hint_align_set(ph, 0.5, 0.5);
710    elm_table_pack(tb, ph, 0, 1, 1, 1);
711    evas_object_show(ph);
712
713    ph = ph4;
714    elm_photo_size_set(ph, 60);
715    snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get());
716    elm_photo_file_set(ph, buf);
717    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
718    evas_object_size_hint_align_set(ph, 0.5, 0.5);
719    elm_table_pack(tb, ph, 1, 1, 1, 1);
720    evas_object_show(ph);
721
722    elm_box_pack_end(bx, tb);
723    evas_object_show(tb);
724
725    evas_object_resize(win, 320, 300);
726    evas_object_show(win);
727 }
728
729 void
730 test_toolbar7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
731 {
732    Evas_Object *win, *bg, *bx, *tb, *ph, *menu;
733    Evas_Object *ph1, *ph2, *ph3, *ph4;
734    Elm_Object_Item *tb_it;
735    Elm_Object_Item *menu_it;
736    char buf[PATH_MAX];
737
738    win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC);
739    elm_win_title_set(win, "Toolbar");
740    elm_win_autodel_set(win, EINA_TRUE);
741
742    bg = elm_bg_add(win);
743    elm_win_resize_object_add(win, bg);
744    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
745    evas_object_show(bg);
746
747    bx = elm_box_add(win);
748    elm_win_resize_object_add(win, bx);
749    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
750    evas_object_show(bx);
751
752    tb = elm_toolbar_add(win);
753    elm_object_style_set(tb, "item_horizontal");
754    elm_toolbar_homogeneous_set(tb, 0);
755    elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_MENU);
756    evas_object_size_hint_weight_set(tb, 0.0, 0.0);
757    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
758
759    ph1 = elm_photo_add(win);
760    ph2 = elm_photo_add(win);
761    ph3 = elm_photo_add(win);
762    ph4 = elm_photo_add(win);
763
764    tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1);
765    elm_object_item_disabled_set(tb_it, EINA_TRUE);
766    elm_toolbar_item_priority_set(tb_it, 100);
767
768    tb_it = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1);
769    elm_toolbar_item_priority_set(tb_it, -100);
770
771    tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4);
772    elm_toolbar_item_priority_set(tb_it, 150);
773
774    tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4);
775    elm_toolbar_item_priority_set(tb_it, 0);
776
777    tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4);
778    elm_toolbar_item_priority_set(tb_it, -200);
779
780    tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL);
781    elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
782    elm_toolbar_item_priority_set(tb_it, -999999);
783    elm_toolbar_menu_parent_set(tb, win);
784    menu = elm_toolbar_item_menu_get(tb_it);
785
786    elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4);
787    menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4);
788    elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4);
789    elm_menu_item_add(menu, NULL, "edit-delete", "Menu", tb_5, ph4);
790
791    elm_box_pack_end(bx, tb);
792    evas_object_show(tb);
793
794    tb = elm_table_add(win);
795    //elm_table_homogeneous_set(tb, 1);
796    evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
797    evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
798
799    ph = ph1;
800    elm_photo_size_set(ph, 40);
801    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
802    elm_photo_file_set(ph, buf);
803    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
804    evas_object_size_hint_align_set(ph, 0.5, 0.5);
805    elm_table_pack(tb, ph, 0, 0, 1, 1);
806    evas_object_show(ph);
807
808    ph = ph2;
809    elm_photo_size_set(ph, 80);
810    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
811    evas_object_size_hint_align_set(ph, 0.5, 0.5);
812    elm_table_pack(tb, ph, 1, 0, 1, 1);
813    evas_object_show(ph);
814
815    ph = ph3;
816    elm_photo_size_set(ph, 20);
817    snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
818    elm_photo_file_set(ph, buf);
819    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
820    evas_object_size_hint_align_set(ph, 0.5, 0.5);
821    elm_table_pack(tb, ph, 0, 1, 1, 1);
822    evas_object_show(ph);
823
824    ph = ph4;
825    elm_photo_size_set(ph, 60);
826    snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get());
827    elm_photo_file_set(ph, buf);
828    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
829    evas_object_size_hint_align_set(ph, 0.5, 0.5);
830    elm_table_pack(tb, ph, 1, 1, 1, 1);
831    evas_object_show(ph);
832
833    elm_box_pack_end(bx, tb);
834    evas_object_show(tb);
835
836    evas_object_resize(win, 320, 300);
837    evas_object_show(win);
838 }
839 #endif