general_funcs_example.c
/* Compile with:
* gcc -g general_funcs_example.c -o general_funcs_example `pkg-config --cflags --libs elementary`
*/
#include <Elementary.h>
#define BIN_DIR "/usr/bin"
#define LIB_DIR "/usr/lib"
#define DATA_DIR "/usr/local/share/elementary"
#define WIDTH 300
#define HEIGHT 300
struct test_data
{
Eina_Bool btn_enabled;
Eina_Bool btn_gets_focus;
};
struct test_data d = {NULL, EINA_TRUE, EINA_TRUE};
static void
_btn_enabled_cb(void *data EINA_UNUSED,
void *event EINA_UNUSED)
{
elm_object_disabled_set(d.btn, !d.btn_enabled);
}
static void
/* focus callback */
_btn_focus_cb(void *data EINA_UNUSED,
void *event EINA_UNUSED)
{
}
static void
/* unfocus callback */
_btn_unfocus_cb(void *data EINA_UNUSED,
void *event EINA_UNUSED)
{
}
static void
/* focus allow callback */
_btn_focus_allow_cb(void *data EINA_UNUSED,
void *event EINA_UNUSED)
{
elm_object_focus_allow_set(d.btn, d.btn_gets_focus);
}
static void /* scaling callback */
_btn_scale_cb(void *data EINA_UNUSED,
void *event EINA_UNUSED)
{
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED,
char **argv EINA_UNUSED)
{
Evas_Object *win, *box, *frame, *check, *b, *slider;
/* tell elm about our app so it can figure out where to get files */
elm_app_info_set(elm_main, "elementary", "images/logo.png");
printf("prefix was set to: %s\n", elm_app_prefix_dir_get());
printf("data directory is: %s\n", elm_app_data_dir_get());
printf("library directory is: %s\n", elm_app_lib_dir_get());
printf("locale directory is: %s\n", elm_app_locale_dir_get());
win = elm_win_util_standard_add("top-level-funcs-example",
"Elementary Top-level Functions Example");
/* by using this policy value, we avoid having to
* evas_object_smart_callback_add(win, "delete,request", _on_exit, NULL),
* calling elm_exit() on that callback ourselves.
*/
/* outer box */
box = elm_box_add(win);
frame = elm_frame_add(win);
elm_object_text_set(frame, "Button");
elm_box_pack_end(box, frame);
d.btn = elm_button_add(win);
elm_object_text_set(d.btn, "Click me");
elm_object_content_set(frame, d.btn);
printf("Elementary's finger size is set to %d pixels\n.",
b = elm_box_add(win);
check = elm_check_add(win);
elm_object_text_set(check, "Button enabled");
elm_check_state_pointer_set(check, &d.btn_enabled);
evas_object_smart_callback_add(check, "changed", _btn_enabled_cb, NULL);
elm_box_pack_end(box, check);
b = elm_button_add(win);
elm_object_text_set(b, "Focus top button");
evas_object_smart_callback_add(b, "clicked", _btn_focus_cb, NULL);
b = elm_button_add(win);
elm_object_text_set(b, "Unfocus top button");
evas_object_smart_callback_add(b, "clicked", _btn_unfocus_cb, NULL);
check = elm_check_add(win);
elm_object_text_set(check, "Button gets focus");
elm_check_state_pointer_set(check, &d.btn_gets_focus);
evas_object_smart_callback_add(check, "changed", _btn_focus_allow_cb, NULL);
elm_box_pack_end(box, check);
slider = elm_slider_add(win);
elm_slider_min_max_set(slider, 0, 4);
elm_slider_unit_format_set(slider, "%1.1f");
evas_object_smart_callback_add(slider, "changed", _btn_scale_cb, NULL);
elm_box_pack_end(box, slider);
evas_object_resize(win, WIDTH, HEIGHT);
elm_run(); /* and run the program now, starting to handle all
* events, etc. */
/* exit code */
return 0;
}