It is usefull to load html string instead of url, especially for testing.
#endif
#ifdef HAVE_ELEMENTARY_WEB
void test_web(void *data, Evas_Object *obj, void *event_info);
+void test_web_ui(void *data, Evas_Object *obj, void *event_info);
#endif
void test_dnd_genlist_default_anim(void *data, Evas_Object *obj, void *event_info);
void test_dnd_genlist_user_anim(void *data, Evas_Object *obj, void *event_info);
//------------------------------//
#ifdef HAVE_ELEMENTARY_WEB
ADD_TEST(NULL, "Web", "Web", test_web);
+ ADD_TEST(NULL, "Web", "Web UI", test_web_ui);
#endif
//------------------------------//
evas_object_resize(win, 320, 480);
evas_object_show(win);
}
+
+void
+test_web_ui(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ Evas_Object *win, *bx, *web;
+ Web_Test *wt;
+
+ elm_need_web();
+
+ wt = calloc(1, sizeof(*wt));
+ win = elm_win_util_standard_add("web", "Web");
+
+ elm_win_autodel_set(win, EINA_TRUE);
+
+ bx = elm_box_add(win);
+ evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bx);
+ evas_object_show(bx);
+
+ web = elm_web_add(win);
+ evas_object_size_hint_weight_set(web, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(web, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(bx, web);
+ evas_object_show(web);
+
+ evas_object_event_callback_add(web, EVAS_CALLBACK_DEL, _main_web_del_cb, wt);
+ wt->web = web;
+
+ elm_web_html_string_load(wt->web,
+ "<!doctype html><body>Hello, WebKit/Efl</body>",
+ NULL, NULL);
+
+ evas_object_resize(win, 320, 480);
+ evas_object_show(win);
+}
#endif
}
+EAPI Eina_Bool
+elm_web_html_string_load(Evas_Object *obj, const char *html, const char *base_url, const char *unreachable_url)
+{
+#ifdef HAVE_ELEMENTARY_WEB
+ ELM_WEB_CHECK(obj) EINA_FALSE;
+ Eina_Bool ret = EINA_FALSE;
+ eo_do(obj, elm_obj_web_html_string_load(html, base_url, unreachable_url, &ret));
+ return ret;
+#else
+ (void)obj;
+ (void)html;
+ (void)base_url;
+ (void)unreachable_url;
+ return EINA_FALSE;
+#endif
+}
+
+static void
+_html_string_load(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
+{
+ const char *html = va_arg(*list, const char *);
+ const char *base_url = va_arg(*list, const char *);
+ const char *unreachable_url = va_arg(*list, const char *);
+ Eina_Bool *ret = va_arg(*list, Eina_Bool *);
+ if (ret) *ret = EINA_FALSE;
+
+#ifdef HAVE_ELEMENTARY_WEB
+ Eina_Bool int_ret;
+
+ ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
+
+ if (!unreachable_url)
+ int_ret = ewk_frame_contents_set(
+ ewk_view_frame_main_get(wd->resize_obj),
+ html, 0, NULL, NULL,
+ base_url);
+ else
+ int_ret = ewk_frame_contents_alternate_set(
+ ewk_view_frame_main_get(wd->resize_obj),
+ html, 0, NULL, NULL,
+ base_url, unreachable_url);
+
+ if (ret) *ret = int_ret;
+#else
+ (void)obj;
+ (void)html;
+ (void)base_url;
+ (void)unreachable_url;
+#endif
+}
+
EAPI const char *
elm_web_title_get(const Evas_Object *obj)
{
EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_TAB_PROPAGATE_SET), _tab_propagate_set),
EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_URL_SET), _url_set),
EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_URL_GET), _url_get),
+ EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_HTML_STRING_LOAD), _html_string_load),
EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_TITLE_GET), _title_get),
EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_BG_COLOR_SET), _bg_color_set),
EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_BG_COLOR_GET), _bg_color_get),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_TAB_PROPAGATE_SET, "Sets whether to use tab propagation."),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_URL_SET, "Sets the URL for the web object."),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_URL_GET, "Get the current URL for the object."),
+ EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_HTML_STRING_LOAD, "Loads the specified html string as the content of the object."),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_TITLE_GET, "Get the current title."),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_BG_COLOR_SET, "Sets the background color to be used by the web object."),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_BG_COLOR_GET, "Get the background color to be used by the web object."),
*ret = ewk_view_url_get(wd->resize_obj);
}
+EAPI Eina_Bool
+elm_web_html_string_load(Evas_Object *obj, const char *html, const char *base_url, const char *unreachable_url)
+{
+ ELM_WEB_CHECK(obj) EINA_FALSE;
+ Eina_Bool ret = EINA_FALSE;
+ eo_do(obj, elm_obj_web_html_string_load(html, base_url, unreachable_url, &ret));
+ return ret;
+}
+
+static void
+_html_string_load(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
+{
+ const char *html = va_arg(*list, const char *);
+ const char *base_url = va_arg(*list, const char *);
+ const char *unreachable_url = va_arg(*list, const char *);
+ Eina_Bool *ret = va_arg(*list, Eina_Bool *);
+
+ if (ret) *ret = EINA_FALSE;
+
+ ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
+
+ if (ret) *ret = ewk_view_html_string_load(wd->resize_obj,
+ html, base_url, unreachable_url);
+}
+
EAPI const char *
elm_web_title_get(const Evas_Object *obj)
{
EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_URL_SET), _url_set),
EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_URL_GET), _url_get),
+ EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_HTML_STRING_LOAD), _html_string_load),
EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_TITLE_GET), _title_get),
EO_OP_FUNC(ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_BG_COLOR_SET), _bg_color_set),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_TAB_PROPAGATE_SET, "Sets whether to use tab propagation."),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_URL_SET, "Sets the URL for the web object."),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_URL_GET, "Get the current URL for the object."),
+ EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_HTML_STRING_LOAD, "Loads the specified html string as the content of the object."),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_TITLE_GET, "Get the current title."),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_BG_COLOR_SET, "Sets the background color to be used by the web object."),
EO_OP_DESCRIPTION(ELM_OBJ_WEB_SUB_ID_BG_COLOR_GET, "Get the background color to be used by the web object."),
ELM_OBJ_WEB_SUB_ID_TAB_PROPAGATE_SET,
ELM_OBJ_WEB_SUB_ID_URL_SET,
ELM_OBJ_WEB_SUB_ID_URL_GET,
+ ELM_OBJ_WEB_SUB_ID_HTML_STRING_LOAD,
ELM_OBJ_WEB_SUB_ID_TITLE_GET,
ELM_OBJ_WEB_SUB_ID_BG_COLOR_SET,
ELM_OBJ_WEB_SUB_ID_BG_COLOR_GET,
#define elm_obj_web_url_get(ret) ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_URL_GET), EO_TYPECHECK(const char **, ret)
/**
+ * @def elm_obj_web_html_string_load
+ * @since 1.9
+ *
+ * Loads the specified @a html string as the content of the web object
+ *
+ * @param[in] html
+ * @param[in] base_url
+ * @param[in] unreachable_url
+ * @param[out] ret
+ *
+ * @see elm_web_html_string_load
+ *
+ * @ingroup Web
+ */
+#define elm_obj_web_html_string_load(html, base_url, unreachable_url, ret) ELM_OBJ_WEB_ID(ELM_OBJ_WEB_SUB_ID_HTML_STRING_LOAD), EO_TYPECHECK(const char *, html), EO_TYPECHECK(const char *, base_url), EO_TYPECHECK(const char *, unreachable_url), EO_TYPECHECK(Eina_Bool *, ret)
+
+/**
* @def elm_obj_web_title_get
* @since 1.8
*
EAPI Eina_Bool elm_web_url_set(Evas_Object *obj, const char *url);
/**
+ * Loads the specified @a html string as the content of the web object
+ *
+ * @param obj The web object
+ * @param html HTML data to load
+ * @param base_url Base URL used for relative paths to external objects (optional)
+ * @param unreachable_url URL that could not be reached (optional)
+ *
+ * @return @c EINA_TRUE if it the HTML was successfully loaded, @c EINA_FALSE otherwise
+ *
+ * External objects such as stylesheets or images referenced in the HTML
+ * document are located relative to @a base_url.
+ *
+ * If an @a unreachable_url is passed it is used as the url for the loaded
+ * content. This is typically used to display error pages for a failed
+ * load.
+ *
+ * @since 1.9
+ * @ingroup Web
+ */
+EAPI Eina_Bool elm_web_html_string_load(Evas_Object *obj, const char *html, const char *base_url, const char *unreachable_url);
+
+/**
* Get the current URL for the object
*
* The returned string must not be freed and is guaranteed to be