prefs_example_03.c
//Compile with:
//gcc -o prefs_example_03 prefs_example_03.c -g `pkg-config --cflags --libs elementary`
#include <Elementary.h>
#define WIDTH (500)
#define HEIGHT (700)
#define MSG_ID_VEL (1)
static void
_update_animation(Evas_Object *prefs, Evas_Object *layout)
{
Eina_Value value;
Eina_Bool animation;
elm_prefs_item_value_get(prefs, "main:config:options:animation", &value);
eina_value_get(&value, &animation);
if (animation)
elm_layout_signal_emit(layout, "start", "animation");
else
elm_layout_signal_emit(layout, "stop", "animation");
}
static void
_update_animation_time(Evas_Object *prefs, Evas_Object *layout)
{
Eina_Value value;
float animation_time;
Edje_Message_Float msg;
elm_prefs_item_value_get(prefs, "main:config:options:animation_time", &value);
eina_value_get(&value, &animation_time);
if (animation_time < 0.01) animation_time = 0.01;
msg.val = animation_time;
edje_object_message_send(elm_layout_edje_get(layout), EDJE_MESSAGE_FLOAT,
MSG_ID_VEL, &msg);
}
static void
_update(Evas_Object *prefs, Evas_Object *layout)
{
_update_animation(prefs, layout);
_update_animation_time(prefs, layout);
}
static void
_page_loaded_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Evas_Object *layout = data;
_update(obj, layout);
}
static void
_item_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
const char *item = event_info;
Evas_Object *layout = data;
if (!strcmp(item, "main:config:options:animation_time"))
_update_animation_time(obj, layout);
else if (!strcmp(item, "main:config:options:animation"))
_update_animation(obj, layout);
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Evas_Object *win, *prefs, *layout;
Elm_Prefs_Data *prefs_data;
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_util_standard_add("Prefs", "Prefs Example 03");
elm_win_autodel_set(win, EINA_TRUE);
layout = elm_layout_add(win);
elm_layout_file_set(layout, "prefs_example_03.edj", "prefs_edje");
prefs = elm_prefs_add(win);
evas_object_size_hint_weight_set(prefs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_resize(prefs, WIDTH, HEIGHT);
evas_object_show(prefs);
evas_object_smart_callback_add(prefs, "page,loaded", _page_loaded_cb,
layout);
evas_object_smart_callback_add(prefs, "item,changed", _item_changed_cb,
layout);
elm_prefs_autosave_set(prefs, EINA_TRUE);
prefs_data =
elm_prefs_data_new("./prefs_example_03.cfg", NULL, EET_FILE_MODE_READ_WRITE);
elm_prefs_file_set(prefs, "prefs_example_03.epb", NULL);
elm_prefs_data_set(prefs, prefs_data);
elm_prefs_item_swallow(prefs, "main:swal", layout);
_update_animation_time(prefs, layout);
_update_animation(prefs, layout);
evas_object_resize(win, WIDTH, HEIGHT);
evas_object_show(win);
elm_run();
elm_prefs_data_unref(prefs_data);
return 0;
}
ELM_MAIN()
EVAS_HINT_EXPAND
#define EVAS_HINT_EXPAND
Use with evas_object_size_hint_weight_set(), evas_object_size_hint_weight_get(), evas_object_size_hin...
Definition Evas_Common.h:297
Edje_Message_Float
struct _Edje_Message_Float Edje_Message_Float
Alias for _Edje_Message_Float.
Definition Edje_Legacy.h:496
edje_object_message_send
void edje_object_message_send(Evas_Object *obj, Edje_Message_Type type, int id, void *msg)
Sends an (Edje) message to a given Edje object.
Definition edje_message_queue.c:1016
EDJE_MESSAGE_FLOAT
@ EDJE_MESSAGE_FLOAT
A message with a floating pointer number as value.
Definition Edje_Legacy.h:580
EET_FILE_MODE_READ_WRITE
@ EET_FILE_MODE_READ_WRITE
File is for both read and write.
Definition Eet.h:481
EINA_TRUE
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition eina_types.h:539
Eina_Bool
unsigned char Eina_Bool
Type to mimic a boolean.
Definition eina_types.h:527
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition eina_types.h:339
Eina_Value
struct _Eina_Value Eina_Value
Store generic values.
Definition eina_value.h:307
ELM_MAIN
#define ELM_MAIN()
macro to be used after the elm_main() function
Definition elm_general.h:556
elm_policy_set
Eina_Bool elm_policy_set(unsigned int policy, int value)
Set a new policy's value (for a given policy group/identifier).
Definition elm_main.c:1380
elm_run
void elm_run(void)
Run Elementary's main loop.
Definition elm_main.c:1357
ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
@ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
quit when the application's last window is closed
Definition elm_general.h:248
ELM_POLICY_QUIT
@ ELM_POLICY_QUIT
under which circumstances the application should quit automatically.
Definition elm_general.h:227
elm_layout_edje_get
Evas_Object * elm_layout_edje_get(const Eo *obj)
Get the edje layout.
Definition efl_ui_layout.c:1883
elm_layout_add
Evas_Object * elm_layout_add(Evas_Object *parent)
Add a new layout to the parent.
Definition efl_ui_layout.c:3067
elm_layout_file_set
Eina_Bool elm_layout_file_set(Eo *obj, const char *file, const char *group)
Set the file that will be used as layout.
Definition efl_ui_layout.c:3074
elm_layout_signal_emit
void elm_layout_signal_emit(Eo *obj, const char *emission, const char *source)
Send a (Edje) signal to a given layout widget's underlying Edje object.
Definition efl_ui_layout.c:3388
elm_prefs_data_new
Elm_Prefs_Data * elm_prefs_data_new(const char *data_file, const char *key, Eet_File_Mode mode)
Create a new prefs data handle.
Definition elm_prefs_data.c:329
elm_prefs_add
Evas_Object * elm_prefs_add(Evas_Object *parent)
Add a new prefs widget.
Definition elm_prefs.c:478
elm_prefs_data_unref
void elm_prefs_data_unref(Elm_Prefs_Data *prefs_data)
Decrement reference count on a given prefs data handle.
Definition elm_prefs_data.c:649
Elm_Prefs_Data
struct _Elm_Prefs_Data Elm_Prefs_Data
An Elm Prefs Data handle.
Definition elm_prefs_data.h:89
elm_win_util_standard_add
Evas_Object * elm_win_util_standard_add(const char *name, const char *title)
Adds a window object with standard setup.
Definition efl_ui_win.c:9587
elm_win_autodel_set
void elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
Set the window's autodel state.
Definition efl_ui_win.c:6199
evas_object_show
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition evas_object_main.c:1814
evas_object_size_hint_weight_set
EVAS_API void evas_object_size_hint_weight_set(Evas_Object *obj, double x, double y)
Sets the hints for an object's weight.
Definition evas_object_main.c:2638
Evas_Object
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition Evas_Common.h:185
evas_object_resize
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition evas_object_main.c:1236
evas_object_smart_callback_add
EVAS_API void evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smart_Cb func, const void *data)
Add (register) a callback function to the smart event specified by event on the smart object obj.
Definition evas_object_smart.c:1040
_Edje_Message_Float::val
double val
The message's value.
Definition Edje_Legacy.h:517