2 * gcc -g general_funcs_example.c -o general_funcs_example `pkg-config --cflags --libs elementary`
5 #include <Elementary.h>
7 #define BIN_DIR "/usr/bin"
8 #define LIB_DIR "/usr/lib"
9 #define DATA_DIR "/usr/local/share/elementary"
17 Eina_Bool btn_enabled;
18 Eina_Bool btn_gets_focus;
21 struct test_data d = {NULL, EINA_TRUE, EINA_TRUE};
24 _btn_enabled_cb(void *data,
28 elm_object_disabled_set(d.btn, !d.btn_enabled);
33 _btn_focus_cb(void *data,
37 elm_object_focus_set(d.btn, EINA_TRUE);
41 /* unfocus callback */
42 _btn_unfocus_cb(void *data,
46 elm_object_focus_set(d.btn, EINA_FALSE);
50 /* focus allow callback */
51 _btn_focus_allow_cb(void *data,
55 elm_object_focus_allow_set(d.btn, d.btn_gets_focus);
58 static void /* scaling callback */
59 _btn_scale_cb(void *data,
63 elm_object_scale_set(d.btn, elm_slider_value_get(obj));
70 Evas_Object *win, *bg, *box, *frame, *check, *b, *slider;
72 /* tell elm about our app so it can figure out where to get files */
73 elm_app_compile_bin_dir_set(BIN_DIR);
74 elm_app_compile_data_dir_set(DATA_DIR);
75 elm_app_compile_lib_dir_set(LIB_DIR);
76 elm_app_info_set(elm_main, "elementary", "images/logo.png");
78 fprintf(stdout, "prefix was set to: %s\n", elm_app_prefix_dir_get());
79 fprintf(stdout, "data directory is: %s\n", elm_app_data_dir_get());
80 fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get());
81 fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get());
83 win = elm_win_add(NULL, "top-level-funcs-example", ELM_WIN_BASIC);
84 elm_win_title_set(win, "Elementary Top-level Functions Example");
86 /* by using this policy value, we avoid having to
87 * evas_object_smart_callback_add(win, "delete,request", _on_exit, NULL),
88 * calling elm_exit() on that callback ourselves.
90 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
91 elm_win_autodel_set(win, EINA_TRUE);
94 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
95 elm_win_resize_object_add(win, bg);
99 box = elm_box_add(win);
100 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
101 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
102 elm_win_resize_object_add(win, box);
103 evas_object_show(box);
105 frame = elm_frame_add(win);
106 elm_object_text_set(frame, "Button");
107 evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
108 evas_object_show(frame);
109 elm_box_pack_end(box, frame);
111 d.btn = elm_button_add(win);
112 elm_object_text_set(d.btn, "Click me");
113 elm_object_content_set(frame, d.btn);
114 fprintf(stdout, "Elementary's finger size is set to %d pixels\n.",
115 elm_config_finger_size_get());
116 evas_object_show(d.btn);
118 b = elm_box_add(win);
119 elm_box_horizontal_set(b, EINA_FALSE);
120 evas_object_size_hint_weight_set(b, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
121 evas_object_size_hint_align_set(b, EVAS_HINT_FILL, EVAS_HINT_FILL);
122 elm_win_resize_object_add(win, b);
123 elm_box_pack_end(box, b);
126 check = elm_check_add(win);
127 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
128 evas_object_size_hint_align_set(check, 0.0, 0.0);
129 elm_object_text_set(check, "Button enabled");
130 elm_check_state_pointer_set(check, &d.btn_enabled);
131 evas_object_smart_callback_add(check, "changed", _btn_enabled_cb, NULL);
132 elm_box_pack_end(box, check);
133 evas_object_show(check);
135 b = elm_button_add(win);
136 evas_object_size_hint_weight_set(b, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
137 evas_object_size_hint_align_set(b, 0.0, 0.0);
138 elm_object_text_set(b, "Focus top button");
139 evas_object_smart_callback_add(b, "clicked", _btn_focus_cb, NULL);
140 elm_box_pack_end(box, b);
143 b = elm_button_add(win);
144 evas_object_size_hint_weight_set(b, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
145 evas_object_size_hint_align_set(b, 0.0, 0.0);
146 elm_object_text_set(b, "Unfocus top button");
147 evas_object_smart_callback_add(b, "clicked", _btn_unfocus_cb, NULL);
148 elm_box_pack_end(box, b);
151 check = elm_check_add(win);
152 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
153 evas_object_size_hint_align_set(check, 0.0, 0.0);
154 elm_object_text_set(check, "Button gets focus");
155 elm_check_state_pointer_set(check, &d.btn_gets_focus);
156 evas_object_smart_callback_add(check, "changed", _btn_focus_allow_cb, NULL);
157 elm_box_pack_end(box, check);
158 evas_object_show(check);
160 slider = elm_slider_add(win);
161 elm_slider_min_max_set(slider, 0, 4);
162 elm_slider_unit_format_set(slider, "%1.1f");
163 elm_slider_indicator_format_set(slider, "%1.1f");
164 evas_object_size_hint_weight_set(
165 slider, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
166 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, EVAS_HINT_FILL);
167 evas_object_smart_callback_add(slider, "changed", _btn_scale_cb, NULL);
168 elm_box_pack_end(box, slider);
169 evas_object_show(slider);
171 evas_object_resize(win, WIDTH, HEIGHT);
172 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
173 evas_object_show(win);
175 elm_run(); /* and run the program now, starting to handle all
177 elm_shutdown(); /* clean up and shut down */