2 * gcc -g `pkg-config --cflags --libs elementary` general_funcs_example.c -o general_funcs_example
5 #include <Elementary.h>
8 # include "elementary_config.h"
11 # define PACKAGE_BIN_DIR "/usr/bin"
12 # define PACKAGE_LIB_DIR "/usr/lib"
13 # define PACKAGE_DATA_DIR "/usr/share/elementary"
22 Eina_Bool btn_enabled;
23 Eina_Bool btn_gets_focus;
26 struct test_data d = {NULL, EINA_TRUE, EINA_TRUE};
29 _btn_enabled_cb(void *data __UNUSED__,
30 Evas_Object *obj __UNUSED__,
31 void *event __UNUSED__)
33 elm_object_disabled_set(d.btn, !d.btn_enabled);
38 _btn_focus_cb(void *data __UNUSED__,
39 Evas_Object *obj __UNUSED__,
40 void *event __UNUSED__)
42 elm_object_focus_set(d.btn, EINA_TRUE);
46 /* unfocus callback */
47 _btn_unfocus_cb(void *data __UNUSED__,
48 Evas_Object *obj __UNUSED__,
49 void *event __UNUSED__)
51 elm_object_focus_set(d.btn, EINA_FALSE);
55 /* focus allow callback */
56 _btn_focus_allow_cb(void *data __UNUSED__,
57 Evas_Object *obj __UNUSED__,
58 void *event __UNUSED__)
60 elm_object_focus_allow_set(d.btn, d.btn_gets_focus);
63 static void /* scaling callback */
64 _btn_scale_cb(void *data __UNUSED__,
66 void *event __UNUSED__)
68 elm_object_scale_set(d.btn, elm_slider_value_get(obj));
72 elm_main(int argc __UNUSED__,
73 char **argv __UNUSED__)
76 Evas_Object *win, *bg, *box, *frame, *check, *b, *slider;
78 /* tell elm about our app so it can figure out where to get files */
79 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
80 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
81 elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR);
82 elm_app_info_set(elm_main, "elementary", "images/logo.png");
84 fprintf(stdout, "prefix was set to: %s\n", elm_app_prefix_dir_get());
85 fprintf(stdout, "data directory is: %s\n", elm_app_data_dir_get());
86 fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get());
87 fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get());
89 win = elm_win_add(NULL, "top-level-funcs-example", ELM_WIN_BASIC);
90 elm_win_title_set(win, "Elementary Top-level Functions Example");
92 /* by using this policy value, we avoid having to
93 * evas_object_smart_callback_add(win, "delete,request", _on_exit, NULL),
94 * calling elm_exit() on that callback ourselves.
96 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
97 elm_win_autodel_set(win, EINA_TRUE);
100 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
101 elm_win_resize_object_add(win, bg);
102 evas_object_show(bg);
103 evas_object_size_hint_min_set(bg, 160, 160);
106 box = elm_box_add(win);
107 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
108 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
109 elm_win_resize_object_add(win, box);
110 evas_object_show(box);
112 frame = elm_frame_add(win);
113 elm_object_text_set(frame, "Button");
114 evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
115 evas_object_show(frame);
116 elm_box_pack_end(box, frame);
118 d.btn = elm_button_add(win);
119 elm_object_text_set(d.btn, "Click me");
120 elm_object_content_set(frame, d.btn);
122 fprintf(stdout, "Elementary's finger size is set to %d pixels\n.",
123 elm_config_finger_size_get());
124 elm_coords_finger_size_adjust(0, NULL, 3, &h);
125 /* so, button will be 3 fingers tall */
126 evas_object_size_hint_min_set(d.btn, 0, h);
127 evas_object_show(d.btn);
129 b = elm_box_add(win);
130 elm_box_horizontal_set(b, EINA_FALSE);
131 evas_object_size_hint_weight_set(b, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
132 evas_object_size_hint_align_set(b, EVAS_HINT_FILL, EVAS_HINT_FILL);
133 elm_win_resize_object_add(win, b);
134 elm_box_pack_end(box, b);
137 check = elm_check_add(win);
138 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
139 evas_object_size_hint_align_set(check, 0.0, 0.0);
140 elm_object_text_set(check, "Button enabled");
141 elm_check_state_pointer_set(check, &d.btn_enabled);
142 evas_object_smart_callback_add(check, "changed", _btn_enabled_cb, NULL);
143 elm_box_pack_end(box, check);
144 evas_object_show(check);
146 b = elm_button_add(win);
147 evas_object_size_hint_weight_set(b, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
148 evas_object_size_hint_align_set(b, 0.0, 0.0);
149 elm_object_text_set(b, "Focus top button");
150 evas_object_smart_callback_add(b, "clicked", _btn_focus_cb, NULL);
151 elm_box_pack_end(box, b);
154 b = elm_button_add(win);
155 evas_object_size_hint_weight_set(b, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
156 evas_object_size_hint_align_set(b, 0.0, 0.0);
157 elm_object_text_set(b, "Unfocus top button");
158 evas_object_smart_callback_add(b, "clicked", _btn_unfocus_cb, NULL);
159 elm_box_pack_end(box, b);
162 check = elm_check_add(win);
163 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
164 evas_object_size_hint_align_set(check, 0.0, 0.0);
165 elm_object_text_set(check, "Button gets focus");
166 elm_check_state_pointer_set(check, &d.btn_gets_focus);
167 evas_object_smart_callback_add(check, "changed", _btn_focus_allow_cb, NULL);
168 elm_box_pack_end(box, check);
169 evas_object_show(check);
171 slider = elm_slider_add(win);
172 elm_slider_min_max_set(slider, 0, 4);
173 elm_slider_unit_format_set(slider, "%1.1f");
174 elm_slider_indicator_format_set(slider, "%1.1f");
175 evas_object_size_hint_weight_set(
176 slider, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
177 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, EVAS_HINT_FILL);
178 evas_object_smart_callback_add(slider, "changed", _btn_scale_cb, NULL);
179 elm_box_pack_end(box, slider);
180 evas_object_show(slider);
182 evas_object_resize(win, WIDTH, HEIGHT);
183 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
184 evas_object_show(win);
186 elm_run(); /* and run the program now, starting to handle all
188 elm_shutdown(); /* clean up and shut down */