tizen 2.4 release
[framework/uifw/elementary.git] / src / examples / theme_example_01.c
1 /*
2  * gcc -o theme_example_01 theme_example_01.c `pkg-config --cflags --libs elementary`
3  */
4 #include <Elementary.h>
5
6 static void
7 btn_extension_click_cb(void *data, Evas_Object *btn, void *ev)
8 {
9    const char *lbl = elm_object_text_get(btn);
10
11    if (!strncmp(lbl, "Load", 4))
12      {
13         elm_theme_extension_add(NULL, "./theme_example.edj");
14         elm_object_text_set(btn, "Unload extension");
15      }
16    else if (!strncmp(lbl, "Unload", 6))
17      {
18         elm_theme_extension_del(NULL, "./theme_example.edj");
19         elm_object_text_set(btn, "Load extension");
20      }
21 }
22
23 static void
24 btn_style_click_cb(void *data, Evas_Object *btn, void *ev)
25 {
26    const char *styles[] = {
27         "chucknorris",
28         "default",
29         "anchor"
30    };
31    static int sel_style = 0;
32
33    sel_style = (sel_style + 1) % 3;
34    elm_object_style_set(btn, styles[sel_style]);
35 }
36
37 EAPI_MAIN int
38 elm_main(int argc, char *argv[])
39 {
40    Evas_Object *win, *box, *btn;
41
42    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
43
44    elm_theme_extension_add(NULL, "./theme_example.edj");
45
46    win = elm_win_util_standard_add("theme", "Theme example");
47    elm_win_autodel_set(win, EINA_TRUE);
48
49    box = elm_box_add(win);
50    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
51    elm_win_resize_object_add(win, box);
52    evas_object_show(box);
53
54    btn = elm_button_add(win);
55    elm_object_text_set(btn, "Unload extension");
56    elm_box_pack_end(box, btn);
57    evas_object_show(btn);
58    evas_object_smart_callback_add(btn, "clicked", btn_extension_click_cb, NULL);
59
60    btn = elm_button_add(win);
61    elm_object_text_set(btn, "Switch style");
62    elm_object_style_set(btn, "chucknorris");
63    elm_box_pack_end(box, btn);
64    evas_object_show(btn);
65    evas_object_smart_callback_add(btn, "clicked", btn_style_click_cb, NULL);
66
67    evas_object_resize(win, 300, 320);
68    evas_object_show(win);
69
70    elm_run();
71
72    return 0;
73 }
74 ELM_MAIN()