From 0611ae3959ab7031488c8913ce419593168b0722 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Tue, 6 Nov 2012 15:26:34 +0900 Subject: [PATCH] Handling the font size/type change event. Change-Id: Ie3aa12dc033bc2c7c94194d3d6a45cdc281912b1 --- CMakeLists.txt | 3 ++ packaging/liblivebox-edje.spec | 5 ++- src/script_port.c | 91 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bd0e11..51c0c78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,9 @@ pkg_check_modules(live_edje REQUIRED edje dlog eet + ecore-x + ecore + vconf ) FOREACH (flag ${live_edje_CFLAGS}) diff --git a/packaging/liblivebox-edje.spec b/packaging/liblivebox-edje.spec index eea1f7a..9f29288 100644 --- a/packaging/liblivebox-edje.spec +++ b/packaging/liblivebox-edje.spec @@ -1,6 +1,6 @@ Name: liblivebox-edje Summary: EDJE Script loader for the data provider master -Version: 0.1.9 +Version: 0.1.10 Release: 1 Group: main/app License: Samsung Proprietary License @@ -11,6 +11,9 @@ BuildRequires: pkgconfig(eina) BuildRequires: pkgconfig(evas) BuildRequires: pkgconfig(edje) BuildRequires: pkgconfig(eet) +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(ecore-x) +BuildRequires: pkgconfig(ecore) %description EDJE Script loader plugin for the data provider master diff --git a/src/script_port.c b/src/script_port.c index d962a42..2bfcc95 100644 --- a/src/script_port.c +++ b/src/script_port.c @@ -5,14 +5,19 @@ #include #include #include +#include #include #include +#include #include #include +#include #include "script_port.h" +#define TEXT_CLASS "slp" + struct info { char *file; char *group; @@ -25,6 +30,16 @@ struct info { Eina_List *obj_list; }; +struct { + Ecore_Event_Handler *property_handler; + char *font; + int size; +} s_info = { + .property_handler = NULL, + .font = NULL, + .size = -100, +}; + /*! * \NOTE * Reservce this for future use @@ -225,6 +240,7 @@ int script_update_script(void *h, Evas *e, const char *id, const char *part, con return -EFAULT; } + edje_object_text_class_set(obj, TEXT_CLASS, s_info.font, s_info.size); if (!edje_object_file_set(obj, path, group)) { int err; const char *errmsg; @@ -385,6 +401,7 @@ int script_load(void *_handle, Evas *e, int w, int h) return -EFAULT; } + edje_object_text_class_set(edje, TEXT_CLASS, s_info.font, s_info.size); DbgPrint("Load edje: %s - %s\n", handle->file, handle->group); if (!edje_object_file_set(edje, handle->file, handle->group)) { int err; @@ -435,14 +452,88 @@ int script_unload(void *_handle, Evas *e) return 0; } +static Eina_Bool property_cb(void *data, int type, void *event) +{ + Ecore_X_Event_Window_Property *info = (Ecore_X_Event_Window_Property *)event; + + if (info->atom == ecore_x_atom_get("FONT_TYPE_change") || info->atom == ecore_x_atom_get("BADA_FONT_change")) { + Eina_List *list; + char *text; + char *font; + + list = edje_text_class_list(); + EINA_LIST_FREE(list, text) { + DbgPrint("Text Class: %s\n", text); + free(text); + } + + font = vconf_get_str("db/setting/accessibility/font_name"); + if (!font) + return ECORE_CALLBACK_PASS_ON; + + if (s_info.font) + free(s_info.font); + + s_info.font = font; + DbgPrint("Changed font to %s\n", font); + } + + return ECORE_CALLBACK_PASS_ON; +} + +static void font_name_cb(keynode_t *node, void *user_data) +{ + const char *font; + + if (!node) + return; + + font = vconf_keynode_get_str(node); + if (!font) + return; + + DbgPrint("Font changed to %s\n", font); +} + +static void font_size_cb(keynode_t *node, void *user_data) +{ + int size; + if (!node) + return; + /*! + * \TODO + */ + s_info.size = vconf_keynode_get_int(node); + DbgPrint("Font size is changed to %d\n", size); +} + int script_init(void) { + int ret; + /* ecore is already initialized */ edje_init(); + s_info.property_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, property_cb, NULL); + if (!s_info.property_handler) + ErrPrint("Failed to add a property change event handler\n"); + + ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, font_size_cb, NULL); + if (ret < 0) + ErrPrint("Failed to add vconf for font size change\n"); + + ret = vconf_notify_key_changed("db/setting/accessibility/font_name", font_name_cb, NULL); + if (ret < 0) + ErrPrint("Failed to add vconf for font name change\n"); + return 0; } int script_fini(void) { + + vconf_ignore_key_changed("db/setting/accessibility/font_name", font_name_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, font_size_cb); + ecore_event_handler_del(s_info.property_handler); + s_info.property_handler = NULL; edje_shutdown(); return 0; } -- 2.7.4