SVN Merging for button, radio, check and toggle
[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 `pkg-config --cflags --libs elementary` toolbar_example_02.c -o toolbar_example_02
9  * @endverbatim
10  */
11
12 #include <Elementary.h>
13 #ifdef HAVE_CONFIG_H
14 # include "elementary_config.h"
15 #else
16 # define __UNUSED__
17 #endif
18
19 static void
20 _on_done(void *data __UNUSED__,
21          Evas_Object *obj __UNUSED__,
22          void *event_info __UNUSED__)
23 {
24    elm_exit();
25 }
26
27 static void
28 _item_pressed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
29 {
30    Elm_Object_Item *tb_it = event_info;
31    elm_toolbar_item_state_set(tb_it, elm_toolbar_item_state_next(tb_it));
32    elm_toolbar_item_selected_set(tb_it, EINA_FALSE);
33 }
34
35 EAPI_MAIN int
36 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
37 {
38    Evas_Object *win, *bg, *bx, *tb, *bt;
39    Elm_Object_Item *tb_it;
40
41    win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC);
42    elm_win_title_set(win, "Toolbar Example");
43    evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
44
45    bg = elm_bg_add(win);
46    elm_win_resize_object_add(win, bg);
47    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
48    evas_object_show(bg);
49
50    bx = elm_box_add(win);
51    elm_win_resize_object_add(win, bx);
52    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
53    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
54    evas_object_show(bx);
55
56    bt = elm_button_add(win);
57    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
58    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
59    elm_object_text_set(bt, "Button");
60    evas_object_show(bt);
61
62    tb = elm_toolbar_add(win);
63    elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_HIDE);
64    evas_object_size_hint_weight_set(tb, 0.0, 0.0);
65    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
66    evas_object_show(tb);
67
68    elm_toolbar_item_append(tb, "document-print", "Print", NULL, NULL);
69    elm_toolbar_item_append(tb, "folder-new", "Folder", NULL, NULL);
70    elm_toolbar_item_append(tb, "clock", "Clock", NULL, NULL);
71    elm_toolbar_item_append(tb, "refresh", "Update", NULL, NULL);
72
73    tb_it = elm_toolbar_item_append(tb, "mail-send", "Send Mail",
74                                    _item_pressed, NULL);
75    elm_toolbar_item_state_add(tb_it, "emptytrash", "Empty Trash",
76                               _item_pressed, NULL);
77    elm_toolbar_item_state_add(tb_it, "trashcan_full", "Full Trash",
78                               _item_pressed, NULL);
79
80    elm_toolbar_item_priority_set(tb_it, 10);
81
82    elm_box_pack_end(bx, tb);
83    elm_box_pack_end(bx, bt);
84
85    evas_object_resize(win, 230, 200);
86    evas_object_show(win);
87
88    elm_run();
89    return 0;
90 }
91 ELM_MAIN()