/*
- * Copyright 2012 Samsung Electronics Co., Ltd
+ * Copyright 2013 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.tizenopensource.org/license
+ * http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
#include <unistd.h>
#include <ctype.h>
+#include <Elementary.h>
#include <Evas.h>
#include <Edje.h>
#include <Eina.h>
#include <Eet.h>
#include <Ecore_X.h>
+#include <system_settings.h>
+
#include <dlog.h>
#include <debug.h>
#include <vconf.h>
+#include <livebox-errno.h>
+#include <livebox-service.h>
#include "script_port.h"
#define PUBLIC __attribute__((visibility("default")))
-extern void evas_common_font_flush(void);
-extern int evas_common_font_cache_get(void);
-extern void evas_common_font_cache_set(int size);
-
struct image_option {
int orient;
int aspect;
struct obj_info {
char *id;
Eina_List *children;
+ Evas_Object *win;
+ Eina_List *access_chain;
};
static struct {
- Ecore_Event_Handler *property_handler;
- char *font;
- int size;
+ char *font_name;
+ int font_size;
} s_info = {
- .property_handler = NULL,
- .font = NULL,
- .size = -100,
+ .font_name = NULL,
+ .font_size = 1,
};
static inline double scale_get(void)
return (double)width / BASE_WIDTH;
}
-/*!
- * \NOTE
- * Reservce this for future use
-static inline void common_cache_flush(void *evas)
-{
- int file_cache;
- int collection_cache;
- int image_cache;
- int font_cache;
-
- file_cache = edje_file_cache_get();
- collection_cache = edje_collection_cache_get();
- image_cache = evas_image_cache_get(evas);
- font_cache = evas_font_cache_get(evas);
-
- edje_file_cache_set(file_cache);
- edje_collection_cache_set(collection_cache);
- evas_image_cache_set(evas, 0);
- evas_font_cache_set(evas, 0);
-
- evas_image_cache_flush(evas);
- evas_render_idle_flush(evas);
- evas_font_cache_flush(evas);
-
- edje_file_cache_flush();
- edje_collection_cache_flush();
-
- edje_file_cache_set(file_cache);
- edje_collection_cache_set(collection_cache);
- evas_image_cache_set(evas, image_cache);
- evas_font_cache_set(evas, font_cache);
-
- eet_clearcache();
-}
- */
-
static inline Evas_Object *find_edje(struct info *handle, const char *id)
{
Eina_List *l;
return NULL;
}
+static inline void rebuild_focus_chain(Evas_Object *obj)
+{
+ struct obj_info *obj_info;
+ Evas_Object *ao;
+ Eina_List *l;
+
+ obj_info = evas_object_data_get(obj, "obj_info");
+ if (!obj_info) {
+ ErrPrint("Object info is not available\n");
+ return;
+ }
+
+ elm_object_focus_custom_chain_unset(obj);
+
+ DbgPrint("Rebuild focus chain begin\n");
+ EINA_LIST_FOREACH(obj_info->access_chain, l, ao) {
+ DbgPrint("Append %p\n", ao);
+ elm_object_focus_custom_chain_append(obj, ao, NULL);
+ }
+ DbgPrint("Rebuild focus chain done\n");
+}
+
PUBLIC const char *script_magic_id(void)
{
return "edje";
edje = find_edje(handle, id);
if (!edje)
- return -ENOENT;
+ return LB_STATUS_ERROR_NOT_EXIST;
ret = sscanf(rgba, "%d %d %d %d %d %d %d %d %d %d %d %d",
r, g, b, a, /* OBJECT */
r + 2, g + 2, b + 2, a + 2); /* SHADOW */
if (ret != 12) {
DbgPrint("id[%s] part[%s] rgba[%s]\n", id, part, rgba);
- return -EINVAL;
+ return LB_STATUS_ERROR_INVALID;
}
- ret = edje_object_color_class_set(edje, part,
+ ret = edje_object_color_class_set(elm_layout_edje_get(edje), part,
r[0], g[0], b[0], a[0], /* OBJECT */
r[1], g[1], b[1], a[1], /* OUTLINE */
r[2], g[2], b[2], a[2]); /* SHADOW */
DbgPrint("EDJE[%s] color class is %s changed", id, ret == EINA_TRUE ? "successfully" : "not");
- return 0;
+ return LB_STATUS_SUCCESS;
+}
+
+static void activate_cb(void *data, Evas_Object *part_obj, Elm_Object_Item *item)
+{
+ Evas_Object *ao;
+ Evas_Object *edje;
+ Evas *e;
+ int x;
+ int y;
+ int w;
+ int h;
+ struct timeval tv;
+ double timestamp;
+
+ ao = evas_object_data_get(part_obj, "ao");
+ if (!ao)
+ return;
+
+ edje = evas_object_data_get(ao, "edje");
+ if (!edje)
+ return;
+
+ e = evas_object_evas_get(part_obj);
+ evas_object_geometry_get(part_obj, &x, &y, &w, &h);
+ x += w / 2;
+ y += h / 2;
+
+ if (gettimeofday(&tv, NULL) < 0) {
+ ErrPrint("Failed to get time\n");
+ timestamp = 0.0f;
+ } else {
+ timestamp = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0f);
+ }
+
+ DbgPrint("Cursor is on %dx%d\n", x, y);
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
+ evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
+ evas_event_feed_mouse_move(e, x, y, timestamp + 0.02f, NULL);
+ evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.03f, NULL);
}
PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part, const char *text)
{
+ struct obj_info *obj_info;
struct info *handle = h;
Evas_Object *edje;
+ Evas_Object *to;
edje = find_edje(handle, id);
- if (!edje)
- return -ENOENT;
+ if (!edje) {
+ ErrPrint("Failed to find EDJE\n");
+ return LB_STATUS_ERROR_NOT_EXIST;
+ }
+
+ obj_info = evas_object_data_get(edje, "obj_info");
+ if (!obj_info) {
+ ErrPrint("Object info is not available\n");
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ elm_object_part_text_set(edje, part, text ? text : "");
+
+ to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
+ if (to) {
+ Evas_Object *ao;
+ char *utf8;
+
+ ao = evas_object_data_get(to, "ao");
+ if (!ao) {
+ ao = elm_access_object_register(to, edje);
+ if (!ao) {
+ ErrPrint("Unable to add ao: %s\n", part);
+ goto out;
+ }
+ obj_info->access_chain = eina_list_append(obj_info->access_chain, ao);
+ evas_object_data_set(to, "ao", ao);
+ evas_object_data_set(ao, "edje", edje);
+ elm_access_activate_cb_set(ao, activate_cb, NULL);
+ elm_object_focus_custom_chain_append(edje, ao, NULL);
+ }
+
+ if (!text || !strlen(text)) {
+ obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
+ evas_object_data_del(to, "ao");
+ evas_object_data_del(ao, "edje");
+ elm_access_object_unregister(ao);
+ DbgPrint("[%s] Remove access object\n", part);
+
+ rebuild_focus_chain(edje);
+ goto out;
+ }
- edje_object_part_text_set(edje, part, text);
- return 0;
+ utf8 = elm_entry_markup_to_utf8(text);
+ if ((!utf8 || !strlen(utf8))) {
+ free(utf8);
+
+ obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
+ evas_object_data_del(to, "ao");
+ evas_object_data_del(ao, "edje");
+ elm_access_object_unregister(ao);
+ DbgPrint("[%s] Remove access object\n", part);
+
+ rebuild_focus_chain(edje);
+ goto out;
+ }
+
+ elm_access_info_set(ao, ELM_ACCESS_INFO, utf8);
+ DbgPrint("[%s] Update access object (%s)\n", part, utf8);
+ free(utf8);
+ } else {
+ ErrPrint("Unable to get text part[%s]\n", part);
+ }
+
+out:
+ return LB_STATUS_SUCCESS;
}
static void parse_aspect(struct image_option *img_opt, const char *value, int len)
return;
img_opt->orient = !strncasecmp(value, "true", 4);
- DbgPrint("Parsed ORIENT: %d (%s)\n", img_opt->aspect, value);
+ DbgPrint("Parsed ORIENT: %d (%s)\n", img_opt->orient, value);
}
static void parse_size(struct image_option *img_opt, const char *value, int len)
}
}
+PUBLIC int script_update_access(void *_h, Evas *e, const char *id, const char *part, const char *text, const char *option)
+{
+ struct info *handle = _h;
+ Evas_Object *edje;
+ struct obj_info *obj_info;
+ Evas_Object *to;
+
+ edje = find_edje(handle, id);
+ if (!edje) {
+ ErrPrint("No such object: %s\n", id);
+ return LB_STATUS_ERROR_NOT_EXIST;
+ }
+
+ obj_info = evas_object_data_get(edje, "obj_info");
+ if (!obj_info) {
+ ErrPrint("Object info is not available\n");
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
+ if (to) {
+ Evas_Object *ao;
+
+ ao = evas_object_data_get(to, "ao");
+ if (ao) {
+ DbgPrint("[%s] Update access object (%s)\n", part, text);
+ if (text && strlen(text)) {
+ elm_access_info_set(ao, ELM_ACCESS_INFO, text);
+ } else {
+ obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
+ evas_object_data_del(to, "ao");
+ evas_object_data_del(ao, "edje");
+ elm_access_object_unregister(ao);
+ DbgPrint("Successfully unregistered\n");
+
+ rebuild_focus_chain(edje);
+ }
+ } else if (text && strlen(text)) {
+ ao = elm_access_object_register(to, edje);
+ if (!ao) {
+ ErrPrint("Unable to register access object\n");
+ } else {
+ elm_access_info_set(ao, ELM_ACCESS_INFO, text);
+ obj_info->access_chain = eina_list_append(obj_info->access_chain, ao);
+ evas_object_data_set(to, "ao", ao);
+ elm_object_focus_custom_chain_append(edje, ao, NULL);
+ DbgPrint("[%s] Register access info: (%s)\n", part, text);
+ evas_object_data_set(ao, "edje", edje);
+ elm_access_activate_cb_set(ao, activate_cb, NULL);
+ }
+ }
+ } else {
+ ErrPrint("[%s] is not exists\n", part);
+ }
+
+ return LB_STATUS_SUCCESS;
+}
+
PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *part, const char *path, const char *option)
{
struct info *handle = _h;
edje = find_edje(handle, id);
if (!edje) {
ErrPrint("No such object: %s\n", id);
- return -ENOENT;
+ return LB_STATUS_ERROR_NOT_EXIST;
}
obj_info = evas_object_data_get(edje, "obj_info");
if (!obj_info) {
ErrPrint("Object info is not available\n");
- return -EFAULT;
+ return LB_STATUS_ERROR_FAULT;
}
- img = edje_object_part_swallow_get(edje, part);
+ img = elm_object_part_content_unset(edje, part);
if (img) {
Eina_List *l;
Eina_List *n;
-
- edje_object_part_unswallow(edje, img);
+ Evas_Object *ao;
EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) {
if (child->obj != img)
}
DbgPrint("delete object %s %p\n", part, img);
+ ao = evas_object_data_del(img, "ao");
+ if (ao) {
+ obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
+ evas_object_data_del(ao, "edje");
+ elm_access_object_unregister(ao);
+ DbgPrint("Successfully unregistered\n");
+ }
evas_object_del(img);
+
+ rebuild_focus_chain(edje);
}
if (!path || !strlen(path) || access(path, R_OK) != 0) {
DbgPrint("SKIP - Path: [%s]\n", path);
- return 0;
+ return LB_STATUS_SUCCESS;
}
child = malloc(sizeof(*child));
if (!child) {
ErrPrint("Heap: %s\n", strerror(errno));
- return -ENOMEM;
+ return LB_STATUS_ERROR_MEMORY;
}
child->part = strdup(part);
if (!child->part) {
ErrPrint("Heap: %s\n", strerror(errno));
free(child);
- return -ENOMEM;
+ return LB_STATUS_ERROR_MEMORY;
}
img = evas_object_image_add(e);
ErrPrint("Failed to add an image object\n");
free(child->part);
free(child);
- return -EFAULT;
+ return LB_STATUS_ERROR_FAULT;
}
evas_object_image_preload(img, EINA_FALSE);
evas_object_del(img);
free(child->part);
free(child);
- return -EIO;
+ return LB_STATUS_ERROR_IO;
}
evas_object_image_size_get(img, &w, &h);
} else {
part_w = 0;
part_h = 0;
- edje_object_part_geometry_get(edje, part, NULL, NULL, &part_w, &part_h);
+ edje_object_part_geometry_get(elm_layout_edje_get(edje), part, NULL, NULL, &part_w, &part_h);
}
DbgPrint("Original %dx%d (part: %dx%d)\n", w, h, part_w, part_h);
evas_object_image_load_region_set(img, (w - part_w) / 2, (h - part_h) / 2, part_w, part_h);
evas_object_image_fill_set(img, 0, 0, part_w, part_h);
evas_object_image_reload(img);
+ } else if (img_opt.fill == FILL_IN_SIZE) {
+ Evas_Coord part_w;
+ Evas_Coord part_h;
+
+ if (img_opt.width >= 0 && img_opt.height >= 0) {
+ part_w = img_opt.width * scale_get();
+ part_h = img_opt.height * scale_get();
+ } else {
+ part_w = 0;
+ part_h = 0;
+ edje_object_part_geometry_get(elm_layout_edje_get(edje), part, NULL, NULL, &part_w, &part_h);
+ }
+ DbgPrint("Original %dx%d (part: %dx%d)\n", w, h, part_w, part_h);
+
+ if (part_w > w || part_h > h) {
+ double fw;
+ double fh;
+
+ fw = (double)part_w / (double)w;
+ fh = (double)part_h / (double)h;
+
+ if (fw > fh) {
+ w = part_w;
+ h = (double)h * fw;
+ } else {
+ h = part_h;
+ w = (double)w * fh;
+ }
+ }
+ DbgPrint("Size: %dx%d\n", w, h);
+ evas_object_image_fill_set(img, 0, 0, part_w, part_h);
+ evas_object_size_hint_fill_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
} else {
evas_object_image_fill_set(img, 0, 0, w, h);
evas_object_size_hint_fill_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);
*/
DbgPrint("%s part swallow image %p (%dx%d)\n", part, img, w, h);
child->obj = img;
- edje_object_part_swallow(edje, part, img);
+ elm_object_part_content_set(edje, part, img);
obj_info->children = eina_list_append(obj_info->children, child);
- return 0;
+ /*!
+ * \note
+ * This object is not registered as an access object.
+ * So the developer should add it to access list manually, using DESC_ACCESS block.
+ */
+ return LB_STATUS_SUCCESS;
}
static void script_signal_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
double ey;
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
- edje_object_part_geometry_get(obj, source, &px, &py, &pw, &ph);
+ edje_object_part_geometry_get(elm_layout_edje_get(obj), source, &px, &py, &pw, &ph);
sx = ex = 0.0f;
if (w) {
struct info *handle = _info;
struct obj_info *obj_info;
struct child *child;
+ Evas_Object *ao;
handle->obj_list = eina_list_remove(handle->obj_list, obj);
DbgPrint("delete object %s %p\n", obj_info->id, obj);
- edje_object_signal_callback_del_full(obj, "*", "*", script_signal_cb, handle);
+ elm_object_signal_callback_del(obj, "*", "*", script_signal_cb);
+
+ elm_object_focus_custom_chain_unset(obj);
EINA_LIST_FREE(obj_info->children, child) {
DbgPrint("delete object %s %p\n", child->part, child->obj);
- if (child->obj)
+ if (child->obj) {
+ Evas_Object *ao;
+ ao = evas_object_data_del(child->obj, "ao");
+ if (ao) {
+ obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
+ evas_object_data_del(ao, "edje");
+ elm_access_object_unregister(ao);
+ }
evas_object_del(child->obj);
+ }
free(child->part);
free(child);
}
+ EINA_LIST_FREE(obj_info->access_chain, ao) {
+ evas_object_data_del(ao, "edje");
+ elm_access_object_unregister(ao);
+ }
+
free(obj_info->id);
free(obj_info);
}
+/*!
+ LB_ACCESS_HIGHLIGHT 0
+ LB_ACCESS_HIGHLIGHT_NEXT 1
+ LB_ACCESS_HIGHLIGHT_PREV 2
+ LB_ACCESS_ACTIVATE 3
+ LB_ACCESS_VALUE_CHANGE 4
+ LB_ACCESS_SCROLL 5
+*/
+PUBLIC int script_feed_event(void *h, Evas *e, int event_type, int x, int y, int down, double timestamp)
+{
+ struct info *handle = h;
+ Evas_Object *edje;
+ struct obj_info *obj_info;
+ int ret = LB_STATUS_SUCCESS;
+
+ DbgPrint("event: %d, x: %d, y: %d\n", event_type, x, y);
+
+ edje = find_edje(handle, NULL); /*!< Get the base layout */
+ if (!edje) {
+ ErrPrint("Base layout is not exist\n");
+ return LB_STATUS_ERROR_NOT_EXIST;
+ }
+
+ obj_info = evas_object_data_get(edje, "obj_info");
+ if (!obj_info) {
+ ErrPrint("Object info is not valid\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (event_type & LB_SCRIPT_ACCESS_EVENT) {
+ Elm_Access_Action_Info *info;
+ Elm_Access_Action_Type action;
+ const Eina_List *chain;
+
+ info = calloc(1, sizeof(*info));
+ if (!info) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ return LB_STATUS_ERROR_MEMORY;
+ }
+
+ chain = elm_object_focus_custom_chain_get(edje);
+ DbgPrint("Focus chain : %d\n", eina_list_count(chain));
+
+ if ((event_type & LB_SCRIPT_ACCESS_HIGHLIGHT) == LB_SCRIPT_ACCESS_HIGHLIGHT) {
+ action = ELM_ACCESS_ACTION_HIGHLIGHT;
+ info->x = x;
+ info->y = y;
+ ret = elm_access_action(edje, action, info);
+ DbgPrint("ACCESS_HIGHLIGHT: %dx%d returns %d\n", x, y, ret);
+ ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+ } else if ((event_type & LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT) == LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT) {
+ action = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
+ info->highlight_cycle = EINA_FALSE;
+ ret = elm_access_action(edje, action, info);
+ DbgPrint("ACCESS_HIGHLIGHT_NEXT, returns %d\n", ret);
+ ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_LAST : LB_ACCESS_STATUS_DONE;
+ } else if ((event_type & LB_SCRIPT_ACCESS_HIGHLIGHT_PREV) == LB_SCRIPT_ACCESS_HIGHLIGHT_PREV) {
+ action = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
+ info->highlight_cycle = EINA_FALSE;
+ ret = elm_access_action(edje, action, info);
+ DbgPrint("ACCESS_HIGHLIGHT_PREV, returns %d\n", ret);
+ ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_FIRST : LB_ACCESS_STATUS_DONE;
+ } else if ((event_type & LB_SCRIPT_ACCESS_ACTIVATE) == LB_SCRIPT_ACCESS_ACTIVATE) {
+ action = ELM_ACCESS_ACTION_ACTIVATE;
+ ret = elm_access_action(edje, action, info);
+ DbgPrint("ACCESS_HIGHLIGHT_ACTIVATE, returns %d\n", ret);
+ ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+ } else if ((event_type & LB_SCRIPT_ACCESS_VALUE_CHANGE) == LB_SCRIPT_ACCESS_VALUE_CHANGE) {
+ action = ELM_ACCESS_ACTION_VALUE_CHANGE;
+ ret = elm_access_action(edje, action, info);
+ DbgPrint("ACCESS_HIGHLIGHT_VALUE_CHANGE, returns %d\n", ret);
+ ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+ } else if ((event_type & LB_SCRIPT_ACCESS_SCROLL) == LB_SCRIPT_ACCESS_SCROLL) {
+ action = ELM_ACCESS_ACTION_SCROLL;
+ info->x = x;
+ info->y = y;
+ switch (down) {
+ case 0: info->mouse_type = 0; break;
+ case -1: info->mouse_type = 1; break;
+ case 1: info->mouse_type = 2; break;
+ default:
+ break;
+ }
+ ret = elm_access_action(edje, action, info);
+ DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret);
+ ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+ } else if ((event_type & LB_SCRIPT_ACCESS_UNHIGHLIGHT) == LB_SCRIPT_ACCESS_UNHIGHLIGHT) {
+ action = ELM_ACCESS_ACTION_UNHIGHLIGHT;
+ ret = elm_access_action(edje, action, info);
+ DbgPrint("ACCESS_UNHIGHLIGHT, returns %d\n", ret);
+ ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE;
+ } else {
+ DbgPrint("Invalid event\n");
+ ret = LB_ACCESS_STATUS_ERROR;
+ }
+
+ free(info);
+ } else if (event_type & LB_SCRIPT_MOUSE_EVENT) {
+ switch (event_type) {
+ case LB_SCRIPT_MOUSE_DOWN:
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
+ evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL);
+ break;
+ case LB_SCRIPT_MOUSE_MOVE:
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
+ break;
+ case LB_SCRIPT_MOUSE_UP:
+ evas_event_feed_mouse_move(e, x, y, timestamp, NULL);
+ evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL);
+ break;
+ case LB_SCRIPT_MOUSE_IN:
+ evas_event_feed_mouse_in(e, timestamp, NULL);
+ break;
+ case LB_SCRIPT_MOUSE_OUT:
+ evas_event_feed_mouse_out(e, timestamp, NULL);
+ break;
+ default:
+ return LB_STATUS_ERROR_INVALID;
+ }
+ } else if (event_type & LB_SCRIPT_KEY_EVENT) {
+ DbgPrint("Key event is not implemented\n");
+ return LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return ret;
+}
+
PUBLIC int script_update_script(void *h, Evas *e, const char *src_id, const char *target_id, const char *part, const char *path, const char *group)
{
struct info *handle = h;
edje = find_edje(handle, src_id);
if (!edje) {
ErrPrint("Edje is not exists\n");
- return -ENOENT;
+ return LB_STATUS_ERROR_NOT_EXIST;
}
obj_info = evas_object_data_get(edje, "obj_info");
if (!obj_info) {
ErrPrint("Object info is not valid\n");
- return -EINVAL;
+ return LB_STATUS_ERROR_INVALID;
}
- obj = edje_object_part_swallow_get(edje, part);
+ obj = elm_object_part_content_unset(edje, part);
if (obj) {
Eina_List *l;
Eina_List *n;
- edje_object_part_unswallow(edje, obj);
-
EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) {
if (child->obj != obj)
continue;
obj_info->children = eina_list_remove(obj_info->children, child);
+
free(child->part);
free(child);
break;
}
DbgPrint("delete object %s %p\n", part, obj);
+ /*!
+ * \note
+ * This will call the edje_del_cb.
+ * It will delete all access objects
+ */
evas_object_del(obj);
}
if (!path || !strlen(path) || access(path, R_OK) != 0) {
DbgPrint("SKIP - Path: [%s]\n", path);
- return 0;
+ return LB_STATUS_SUCCESS;
}
- obj = edje_object_add(e);
+ obj = elm_layout_add(edje);
if (!obj) {
ErrPrint("Failed to add a new edje object\n");
- return -EFAULT;
+ return LB_STATUS_ERROR_FAULT;
}
- if (!edje_object_file_set(obj, path, group)) {
+ if (!elm_layout_file_set(obj, path, group)) {
int err;
const char *errmsg;
- err = edje_object_load_error_get(obj);
+ err = edje_object_load_error_get(elm_layout_edje_get(obj));
errmsg = edje_load_error_str(err);
ErrPrint("Could not load %s from %s: %s\n", group, path, errmsg);
evas_object_del(obj);
- return -EIO;
+ return LB_STATUS_ERROR_IO;
}
evas_object_show(obj);
if (!obj_info) {
ErrPrint("Failed to add a obj_info\n");
evas_object_del(obj);
- return -ENOMEM;
+ return LB_STATUS_ERROR_MEMORY;
}
obj_info->id = strdup(target_id);
ErrPrint("Failed to add a obj_info\n");
free(obj_info);
evas_object_del(obj);
- return -ENOMEM;
+ return LB_STATUS_ERROR_MEMORY;
}
child = malloc(sizeof(*child));
free(obj_info->id);
free(obj_info);
evas_object_del(obj);
- return -ENOMEM;
+ return LB_STATUS_ERROR_MEMORY;
}
child->part = strdup(part);
free(obj_info->id);
free(obj_info);
evas_object_del(obj);
- return -ENOMEM;
+ return LB_STATUS_ERROR_MEMORY;
}
child->obj = obj;
evas_object_data_set(obj, "obj_info", obj_info);
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, edje_del_cb, handle);
- edje_object_signal_callback_add(obj, "*", "*", script_signal_cb, handle);
+ elm_object_signal_callback_add(obj, "*", "*", script_signal_cb, handle);
handle->obj_list = eina_list_append(handle->obj_list, obj);
DbgPrint("%s part swallow edje %p\n", part, obj);
- edje_object_part_swallow(edje, part, obj);
+ elm_object_part_content_set(edje, part, obj);
obj_info = evas_object_data_get(edje, "obj_info");
obj_info->children = eina_list_append(obj_info->children, child);
- return 0;
+ return LB_STATUS_SUCCESS;
}
PUBLIC int script_update_signal(void *h, Evas *e, const char *id, const char *part, const char *signal)
edje = find_edje(handle, id);
if (!edje)
- return -ENOENT;
+ return LB_STATUS_ERROR_NOT_EXIST;
- edje_object_signal_emit(edje, signal, part);
- return 0;
+ elm_object_signal_emit(edje, signal, part);
+ return LB_STATUS_SUCCESS;
}
PUBLIC int script_update_drag(void *h, Evas *e, const char *id, const char *part, double x, double y)
edje = find_edje(handle, id);
if (!edje)
- return -ENOENT;
+ return LB_STATUS_ERROR_NOT_EXIST;
- edje_object_part_drag_value_set(edje, part, x, y);
- return 0;
+ edje_object_part_drag_value_set(elm_layout_edje_get(edje), part, x, y);
+ return LB_STATUS_SUCCESS;
}
PUBLIC int script_update_size(void *han, Evas *e, const char *id, int w, int h)
edje = find_edje(handle, id);
if (!edje)
- return -ENOENT;
+ return LB_STATUS_ERROR_NOT_EXIST;
if (!id) {
handle->w = w;
DbgPrint("Resize object to %dx%d\n", w, h);
evas_object_resize(edje, w, h);
- return 0;
+ return LB_STATUS_SUCCESS;
}
PUBLIC int script_update_category(void *h, Evas *e, const char *id, const char *category)
}
if (!category)
- return 0;
+ return LB_STATUS_SUCCESS;
handle->category = strdup(category);
if (!handle->category) {
ErrPrint("Error: %s\n", strerror(errno));
- return -ENOMEM;
+ return LB_STATUS_ERROR_MEMORY;
}
- return 0;
+ return LB_STATUS_SUCCESS;
}
PUBLIC void *script_create(const char *file, const char *group)
free(handle->file);
free(handle->group);
free(handle);
- return 0;
+ return LB_STATUS_SUCCESS;
}
PUBLIC int script_load(void *_handle, Evas *e, int w, int h)
obj_info = calloc(1, sizeof(*obj_info));
if (!obj_info) {
ErrPrint("Heap: %s\n", strerror(errno));
- return -ENOMEM;
+ return LB_STATUS_ERROR_MEMORY;
+ }
+
+ obj_info->win = evas_object_rectangle_add(e);
+ if (!obj_info->win) {
+ free(obj_info);
+ return LB_STATUS_ERROR_FAULT;
}
- edje = edje_object_add(e);
+ edje = elm_layout_add(obj_info->win);
if (!edje) {
ErrPrint("Failed to create an edje object\n");
+ evas_object_del(obj_info->win);
free(obj_info);
- return -EFAULT;
+ return LB_STATUS_ERROR_FAULT;
}
DbgPrint("Load edje: %s - %s\n", handle->file, handle->group);
- if (!edje_object_file_set(edje, handle->file, handle->group)) {
+ if (!elm_layout_file_set(edje, handle->file, handle->group)) {
int err;
const char *errmsg;
- err = edje_object_load_error_get(edje);
+ err = edje_object_load_error_get(elm_layout_edje_get(edje));
errmsg = edje_load_error_str(err);
ErrPrint("Could not load %s from %s: %s\n", handle->group, handle->file, errmsg);
evas_object_del(edje);
+ evas_object_del(obj_info->win);
free(obj_info);
- return -EIO;
+ return LB_STATUS_ERROR_IO;
}
handle->e = e;
handle->w = w;
handle->h = h;
- edje_object_signal_callback_add(edje, "*", "*", script_signal_cb, handle);
+ elm_object_signal_callback_add(edje, "*", "*", script_signal_cb, handle);
evas_object_event_callback_add(edje, EVAS_CALLBACK_DEL, edje_del_cb, handle);
evas_object_size_hint_weight_set(edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(edje, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_data_set(edje, "obj_info", obj_info);
handle->obj_list = eina_list_append(handle->obj_list, edje);
- return 0;
+ return LB_STATUS_SUCCESS;
}
PUBLIC int script_unload(void *_handle, Evas *e)
if (edje)
evas_object_del(edje);
handle->e = NULL;
- return 0;
+ return LB_STATUS_SUCCESS;
}
-static inline int update_font(const char *font)
+static void access_cb(keynode_t *node, void *user_data)
{
- Eina_List *list;
- char *text;
- int cache;
-
- cache = evas_common_font_cache_get();
- evas_common_font_cache_set(0);
- evas_common_font_flush();
-
- list = edje_text_class_list();
- EINA_LIST_FREE(list, text) {
- if (!strncasecmp(text, TEXT_CLASS, strlen(TEXT_CLASS))) {
- edje_text_class_del(text);
- edje_text_class_set(text, s_info.font, s_info.size);
- DbgPrint("Update text class %s (%s, %d)\n", text, s_info.font, s_info.size);
- } else {
- DbgPrint("Skip text class %s\n", text);
+ int state;
+
+ if (!node) {
+ if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &state) != 0) {
+ ErrPrint("Idle lock state is not valid\n");
+ state = 0; /* DISABLED */
}
+ } else {
+ state = vconf_keynode_get_bool(node);
}
- DbgPrint("Font for text_class is updated\n");
- evas_common_font_cache_set(cache);
- return 0;
+ DbgPrint("ELM CONFIG ACCESS: %d\n", state);
+ elm_config_access_set(state);
}
-static Eina_Bool property_cb(void *data, int type, void *event)
+static void update_font_cb(void *data)
{
- 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")) {
- char *font;
-
- font = vconf_get_str("db/setting/accessibility/font_name");
- if (!font)
- return ECORE_CALLBACK_PASS_ON;
-
- if (s_info.font && !strcmp(s_info.font, font)) {
- DbgPrint("Font is not changed (%s)\n", font);
- free(font);
- return ECORE_CALLBACK_PASS_ON;
- }
-
- if (s_info.font)
- free(s_info.font);
-
- s_info.font = font;
-
- update_font(font);
- }
-
- return ECORE_CALLBACK_PASS_ON;
+ elm_config_font_overlay_set(TEXT_CLASS, s_info.font_name, s_info.font_size);
+ DbgPrint("Update text class %s (%s, %d)\n", TEXT_CLASS, s_info.font_name, s_info.font_size);
}
-static void font_name_cb(keynode_t *node, void *user_data)
+static void font_changed_cb(system_settings_key_e key, void *user_data)
{
- const char *font;
-
- if (!node)
- return;
+ int ret;
+ char *font_name;
- font = vconf_keynode_get_str(node);
- if (!font)
+ ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &font_name);
+ if (ret != SYSTEM_SETTINGS_ERROR_NONE || !font_name)
return;
- if (s_info.font && !strcmp(s_info.font, font)) {
+ if (s_info.font_name && !strcmp(s_info.font_name, font_name)) {
DbgPrint("Font is not changed\n");
+ free(font_name);
return;
}
- DbgPrint("Font changed to %s\n", font);
-
- if (s_info.font)
- free(s_info.font);
+ if (s_info.font_name) {
+ free(s_info.font_name);
+ s_info.font_name = NULL;
+ }
- s_info.font = strdup(font);
- if (!s_info.font)
- ErrPrint("Heap: %s\n", strerror(errno));
+ s_info.font_name = font_name;
+ DbgPrint("Font name is changed to %s\n", s_info.font_name);
- update_font(font);
+ /*!
+ * \NOTE
+ * Try to update all liveboxes
+ */
+ update_font_cb(NULL);
}
-static void font_size_cb(keynode_t *node, void *user_data)
+static void font_size_cb(system_settings_key_e key, void *user_data)
{
- if (!node)
+ int size;
+
+ if (system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &size) != SYSTEM_SETTINGS_ERROR_NONE)
return;
- /*!
- * \TODO
- * Implementing me.
- */
- DbgPrint("Size type: %d\n", vconf_keynode_get_int(node));
+
+ if (size == s_info.font_size) {
+ DbgPrint("Font size is not changed\n");
+ return;
+ }
+
+ s_info.font_size = size;
+ DbgPrint("Font size is changed to %d\n", size);
+
+ update_font_cb(NULL);
}
PUBLIC int script_init(void)
{
int ret;
+ char *argv[] = {
+ "livebox.edje",
+ NULL,
+ };
/* ecore is already initialized */
- edje_init();
- edje_scale_set(scale_get());
+ elm_init(1, argv);
+ elm_config_scale_set(scale_get());
- 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);
+ ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, access_cb, NULL);
if (ret < 0)
- ErrPrint("Failed to add vconf for font size change\n");
+ ErrPrint("Failed to access cb\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");
+ access_cb(NULL, NULL);
+
+ ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE, font_changed_cb, NULL);
+ DbgPrint("System font is changed: %d\n", ret);
+
+ ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, font_size_cb, NULL);
+ DbgPrint("System font size is changed: %d\n", ret);
- return 0;
+ ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &s_info.font_name);
+ if (ret == SYSTEM_SETTINGS_ERROR_NONE)
+ DbgPrint("Current font: %s\n", s_info.font_name);
+
+ ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &s_info.font_size);
+ if (ret == SYSTEM_SETTINGS_ERROR_NONE)
+ DbgPrint("Current size: %d\n", s_info.font_size);
+
+ return LB_STATUS_SUCCESS;
}
PUBLIC 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;
+ int ret;
+ ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE);
+ ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE);
+ ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, access_cb);
+ elm_shutdown();
+ return LB_STATUS_SUCCESS;
}
/* End of a file */