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
This commit is contained in:
hyoyoung.chang 2010-12-02 08:25:36 +00:00 committed by Carsten Haitzler
parent b01e13faf2
commit 3cf111500d
2 changed files with 51 additions and 28 deletions

View File

@ -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<br>"
"uses markup <b>like this</> for styling and<br>"
"formatting <em>like this</>, as well as<br>"
"<a href=X><link>links in the text</></a>, so enter text<br>"
"in here to edit it. By the way, links are<br>"
"called <a href=anc-02>Anchors</a> so you will need<br>"
"to refer to them this way.<br>"
"<br>"
"Also you can stick in items with (relsize + ascent): "
"<item relsize=16x16 vsize=ascent href=emoticon/evil-laugh></item>"
" (full) "
"<item relsize=16x16 vsize=full href=emoticon/guilty-smile></item>"
" (to the left)<br>"
"Also (size + ascent): "
"<item size=16x16 vsize=ascent href=emoticon/haha></item>"
" (full) "
"<item size=16x16 vsize=full href=emoticon/happy-panting></item>"
" (before this)<br>"
"And as well (absize + ascent): "
"<item absize=64x64 vsize=ascent href=emoticon/knowing-grin></item>"
" (full) "
"<item absize=64x64 vsize=full href=emoticon/not-impressed></item>"
" ... end."
);
snprintf(buf, sizeof(buf),
"This is an entry widget in this window that<br>"
"uses markup <b>like this</> for styling and<br>"
"formatting <em>like this</>, as well as<br>"
"<a href=X><link>links in the text</></a>, so enter text<br>"
"in here to edit it. By the way, links are<br>"
"called <a href=anc-02>Anchors</a> so you will need<br>"
"to refer to them this way.<br>"
"<br>"
"Also you can stick in items with (relsize + ascent): "
"<item relsize=16x16 vsize=ascent href=emoticon/evil-laugh></item>"
" (full) "
"<item relsize=16x16 vsize=full href=emoticon/guilty-smile></item>"
" (to the left)<br>"
"Also (size + ascent): "
"<item size=16x16 vsize=ascent href=emoticon/haha></item>"
" (full) "
"<item size=16x16 vsize=full href=emoticon/happy-panting></item>"
" (before this)<br>"
"And as well (absize + ascent): "
"<item absize=64x64 vsize=ascent href=emoticon/knowing-grin></item>"
" (full) "
"<item absize=64x64 vsize=full href=emoticon/not-impressed></item>"
" or even paths to image files on disk too like: "
"<item absize=96x128 vsize=full href=file://%s/images/sky_01.jpg></item>"
" ... 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);

View File

@ -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));