From a1d23945ee23bd34289749e07f19bfe152c91482 Mon Sep 17 00:00:00 2001 From: "hyoyoung.chang" Date: Thu, 2 Dec 2010 08:25:36 +0000 Subject: [PATCH] From: hyoyoung.chang@samsung.com As we talked last week, I made a version of adding external image in elm_entry. It seeks a local file if prefix is 'file://' then it loads image and adds it. If image file can't be loaded, adding wft emoticon. patch in with minor fix for path and an added actual test case in elm entry test. SVN revision: 55134 --- src/bin/test_entry.c | 61 ++++++++++++++++++++++++++++------------------------ src/lib/elm_entry.c | 18 ++++++++++++++++ 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/bin/test_entry.c b/src/bin/test_entry.c index 4421148..0d44331 100644 --- a/src/bin/test_entry.c +++ b/src/bin/test_entry.c @@ -59,6 +59,7 @@ void test_entry(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *win, *bg, *bx, *bx2, *bt, *en; + char buf[4096]; win = elm_win_add(NULL, "entry", ELM_WIN_BASIC); elm_win_title_set(win, "Entry"); @@ -76,34 +77,38 @@ test_entry(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info en = elm_entry_add(win); elm_entry_line_wrap_set(en, 0); - elm_entry_entry_set(en, - "This is an entry widget in this window that
" - "uses markup like this for styling and
" - "formatting like this, as well as
" - "links in the text, so enter text
" - "in here to edit it. By the way, links are
" - "called Anchors so you will need
" - "to refer to them this way.
" - "
" - - "Also you can stick in items with (relsize + ascent): " - "" - " (full) " - "" - " (to the left)
" - - "Also (size + ascent): " - "" - " (full) " - "" - " (before this)
" - - "And as well (absize + ascent): " - "" - " (full) " - "" - " ... end." - ); + snprintf(buf, sizeof(buf), + "This is an entry widget in this window that
" + "uses markup like this for styling and
" + "formatting like this, as well as
" + "links in the text, so enter text
" + "in here to edit it. By the way, links are
" + "called Anchors so you will need
" + "to refer to them this way.
" + "
" + + "Also you can stick in items with (relsize + ascent): " + "" + " (full) " + "" + " (to the left)
" + + "Also (size + ascent): " + "" + " (full) " + "" + " (before this)
" + + "And as well (absize + ascent): " + "" + " (full) " + "" + " or even paths to image files on disk too like: " + "" + " ... end." + , PACKAGE_DATA_DIR + ); + elm_entry_entry_set(en, buf); evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_box_pack_end(bx, en); diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index d7edf55..46a8619 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -1515,6 +1515,24 @@ _get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, o = ip->func(ip->data, data, item); if (o) return o; } + if (!strncmp(item, "file://", 7)) + { + char *fname = item + 7; + + o = evas_object_image_filled_add(evas_object_evas_get(data)); + evas_object_image_file_set(o, fname, NULL); + if (evas_object_image_load_error_get(o) == EVAS_LOAD_ERROR_NONE) + { + evas_object_show(o); + } + else + { + evas_object_del(o); + o = edje_object_add(evas_object_evas_get(data)); + _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data)); + } + return o; + } o = edje_object_add(evas_object_evas_get(data)); if (!_elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data))) _elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data)); -- 2.7.4