Evas_Object* ewk_settings_icon_database_icon_object_get(const char* url, Evas* canvas) { EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0); WebCore::KURL kurl(WebCore::KURL(), WTF::String::fromUTF8(url)); WebCore::Image* icon = WebCore::iconDatabase().synchronousIconForPageURL(kurl.string(), WebCore::IntSize(16, 16)); if (!icon) { ERR("no icon for url %s", url); return 0; } WebCore::NativeImageCairo* nativeImage = icon->nativeImageForCurrentFrame(); return nativeImage ? ewk_util_image_from_cairo_surface_add(canvas, nativeImage->surface()) : 0; }
/** * Create Evas_Object of type image representing the given URL. * * This is an utility function that creates an Evas_Object of type * image set to have fill always match object size * (evas_object_image_filled_add()), saving some code to use it from Evas. * * @note in order to have this working, one must open icon database * with ewk_settings_icon_database_path_set(). * * @param url which url to query icon. * @param canvas evas instance where to add resulting object. * * @return newly allocated Evas_Object instance or @c NULL on * errors. Delete the object with evas_object_del(). */ Evas_Object* ewk_settings_icon_database_icon_object_add(const char* url, Evas* canvas) { EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0); WebCore::KURL kurl(WebCore::KURL(), WebCore::String::fromUTF8(url)); WebCore::Image* icon = WebCore::iconDatabase()->iconForPageURL(kurl.string(), WebCore::IntSize(16, 16)); cairo_surface_t* surface; if (!icon) { ERR("no icon for url %s", url); return 0; } surface = icon->nativeImageForCurrentFrame(); return ewk_util_image_from_cairo_surface_add(canvas, surface); }