summaryrefslogtreecommitdiff
path: root/src/examples/theme_example_01.c
diff options
context:
space:
mode:
authorIván Briano <sachieru@gmail.com>2011-06-22 19:06:01 +0000
committerIván Briano <sachieru@gmail.com>2011-06-22 19:06:01 +0000
commitda4ad838543f81451562bd2d5859620b4bc2906d (patch)
tree6df03ac4cf8496850115f3888c2809e68d3de6a7 /src/examples/theme_example_01.c
parent10840cec4fa66ce5384ce2d3e0478e7bbcd8f567 (diff)
Detailed docs, examples and explanations for the elm_theme set of funtions
SVN revision: 60603
Diffstat (limited to 'src/examples/theme_example_01.c')
-rw-r--r--src/examples/theme_example_01.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/examples/theme_example_01.c b/src/examples/theme_example_01.c
new file mode 100644
index 0000000..91554cb
--- /dev/null
+++ b/src/examples/theme_example_01.c
@@ -0,0 +1,83 @@
1/*
2 * gcc -o theme_example_01 theme_example_01.c `pkg-config --cflags --libs elementary`
3 */
4#include <Elementary.h>
5#ifdef HAVE_CONFIG_H
6# include "elementary_config.h"
7#else
8# define __UNUSED__
9#endif
10
11static void
12btn_extension_click_cb(void *data __UNUSED__, Evas_Object *btn, void *ev __UNUSED__)
13{
14 const char *lbl = elm_button_label_get(btn);
15
16 if (!strncmp(lbl, "Load", 4))
17 {
18 elm_theme_extension_add(NULL, "./theme_example.edj");
19 elm_button_label_set(btn, "Unload extension");
20 }
21 else if (!strncmp(lbl, "Unload", 6))
22 {
23 elm_theme_extension_del(NULL, "./theme_example.edj");
24 elm_button_label_set(btn, "Load extension");
25 }
26}
27
28static void
29btn_style_click_cb(void *data __UNUSED__, Evas_Object *btn, void *ev __UNUSED__)
30{
31 const char *styles[] = {
32 "chucknorris",
33 "default",
34 "anchor"
35 };
36 static int sel_style = 0;
37
38 sel_style = (sel_style + 1) % 3;
39 elm_object_style_set(btn, styles[sel_style]);
40}
41
42int
43elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
44{
45 Evas_Object *win, *bg, *box, *btn;
46
47 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
48
49 elm_theme_extension_add(NULL, "./theme_example.edj");
50
51 win = elm_win_add(NULL, "Theme example", ELM_WIN_BASIC);
52 elm_win_autodel_set(win, EINA_TRUE);
53 evas_object_resize(win, 300, 320);
54 evas_object_show(win);
55
56 bg = elm_bg_add(win);
57 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
58 elm_win_resize_object_add(win, bg);
59 evas_object_show(bg);
60
61 box = elm_box_add(win);
62 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
63 elm_win_resize_object_add(win, box);
64 evas_object_show(box);
65
66 btn = elm_button_add(win);
67 elm_button_label_set(btn, "Unload extension");
68 elm_box_pack_end(box, btn);
69 evas_object_show(btn);
70 evas_object_smart_callback_add(btn, "clicked", btn_extension_click_cb, NULL);
71
72 btn = elm_button_add(win);
73 elm_button_label_set(btn, "Switch style");
74 elm_object_style_set(btn, "chucknorris");
75 elm_box_pack_end(box, btn);
76 evas_object_show(btn);
77 evas_object_smart_callback_add(btn, "clicked", btn_style_click_cb, NULL);
78
79 elm_run();
80
81 return 0;
82}
83ELM_MAIN();