2 //gcc -o prefs_example_03 prefs_example_03.c -g `pkg-config --cflags --libs elementary`
4 #include <Elementary.h>
11 _update_animation(Evas_Object *prefs, Evas_Object *layout)
16 elm_prefs_item_value_get(prefs, "main:config:options:animation", &value);
17 eina_value_get(&value, &animation);
19 elm_layout_signal_emit(layout, "start", "animation");
21 elm_layout_signal_emit(layout, "stop", "animation");
25 _update_animation_time(Evas_Object *prefs, Evas_Object *layout)
29 Edje_Message_Float msg;
31 elm_prefs_item_value_get(prefs, "main:config:options:animation_time", &value);
32 eina_value_get(&value, &animation_time);
33 if (animation_time < 0.01) animation_time = 0.01;
34 msg.val = animation_time;
35 edje_object_message_send(elm_layout_edje_get(layout), EDJE_MESSAGE_FLOAT,
40 _update(Evas_Object *prefs, Evas_Object *layout)
42 _update_animation(prefs, layout);
43 _update_animation_time(prefs, layout);
47 _page_loaded_cb(void *data, Evas_Object *obj, void *event_info)
49 Evas_Object *layout = data;
55 _item_changed_cb(void *data, Evas_Object *obj, void *event_info)
57 const char *item = event_info;
58 Evas_Object *layout = data;
60 if (!strcmp(item, "main:config:options:animation_time"))
61 _update_animation_time(obj, layout);
62 else if (!strcmp(item, "main:config:options:animation"))
63 _update_animation(obj, layout);
67 elm_main(int argc, char **argv)
69 Evas_Object *win, *prefs, *layout;
70 Elm_Prefs_Data *prefs_data;
72 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
74 win = elm_win_util_standard_add("Prefs", "Prefs Example 03");
75 elm_win_autodel_set(win, EINA_TRUE);
77 layout = elm_layout_add(win);
78 elm_layout_file_set(layout, "prefs_example_03.edj", "prefs_edje");
80 prefs = elm_prefs_add(win);
81 evas_object_size_hint_weight_set(prefs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
82 evas_object_resize(prefs, WIDTH, HEIGHT);
83 evas_object_show(prefs);
85 evas_object_smart_callback_add(prefs, "page,loaded", _page_loaded_cb,
87 evas_object_smart_callback_add(prefs, "item,changed", _item_changed_cb,
90 elm_prefs_autosave_set(prefs, EINA_TRUE);
93 elm_prefs_data_new("./prefs_example_03.cfg", NULL, EET_FILE_MODE_READ_WRITE);
95 elm_prefs_file_set(prefs, "prefs_example_03.epb", NULL);
96 elm_prefs_data_set(prefs, prefs_data);
98 elm_prefs_item_swallow(prefs, "main:swal", layout);
100 _update_animation_time(prefs, layout);
101 _update_animation(prefs, layout);
103 evas_object_resize(win, WIDTH, HEIGHT);
104 evas_object_show(win);
108 elm_prefs_data_unref(prefs_data);