fixed plugin image size problem
[framework/uifw/elementary.git] / src / examples / toolbar_example_02.c
1 /**
2  * Simple Elementary's <b>toolbar widget</b> example, illustrating its
3  * usage and API.
4  *
5  * See stdout/stderr for output. Compile with:
6  *
7  * @verbatim
8  * gcc -g toolbar_example_02.c -o toolbar_example_02 `pkg-config --cflags --libs elementary`
9  * @endverbatim
10  */
11
12 #include <Elementary.h>
13
14 static void
15 _on_done(void *data,
16          Evas_Object *obj,
17          void *event_info)
18 {
19    elm_exit();
20 }
21
22 static void
23 _item_pressed(void *data, Evas_Object *obj, void *event_info)
24 {
25    Elm_Object_Item *tb_it = event_info;
26    elm_toolbar_item_state_set(tb_it, elm_toolbar_item_state_next(tb_it));
27    elm_toolbar_item_selected_set(tb_it, EINA_FALSE);
28 }
29
30 EAPI_MAIN int
31 elm_main(int argc, char **argv)
32 {
33    Evas_Object *win, *bg, *bx, *tb, *bt;
34    Elm_Object_Item *tb_it;
35
36    win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC);
37    elm_win_title_set(win, "Toolbar Example");
38    evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
39
40    bg = elm_bg_add(win);
41    elm_win_resize_object_add(win, bg);
42    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43    evas_object_show(bg);
44
45    bx = elm_box_add(win);
46    elm_win_resize_object_add(win, bx);
47    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
48    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
49    evas_object_show(bx);
50
51    bt = elm_button_add(win);
52    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
53    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
54    elm_object_text_set(bt, "Button");
55    evas_object_show(bt);
56
57    tb = elm_toolbar_add(win);
58    elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_HIDE);
59    evas_object_size_hint_weight_set(tb, 0.0, 0.0);
60    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
61    evas_object_show(tb);
62
63    elm_toolbar_item_append(tb, "document-print", "Print", NULL, NULL);
64    elm_toolbar_item_append(tb, "folder-new", "Folder", NULL, NULL);
65    elm_toolbar_item_append(tb, "clock", "Clock", NULL, NULL);
66    elm_toolbar_item_append(tb, "refresh", "Update", NULL, NULL);
67
68    tb_it = elm_toolbar_item_append(tb, "mail-send", "Send Mail",
69                                    _item_pressed, NULL);
70    elm_toolbar_item_state_add(tb_it, "emptytrash", "Empty Trash",
71                               _item_pressed, NULL);
72    elm_toolbar_item_state_add(tb_it, "trashcan_full", "Full Trash",
73                               _item_pressed, NULL);
74
75    elm_toolbar_item_priority_set(tb_it, 10);
76
77    elm_box_pack_end(bx, tb);
78    elm_box_pack_end(bx, bt);
79
80    evas_object_resize(win, 230, 200);
81    evas_object_show(win);
82
83    elm_run();
84    elm_shutdown();
85
86    return 0;
87 }
88 ELM_MAIN()