From 67892ba18f738224e8c5a6e4336b4fe9011c40dd Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 31 Aug 2019 23:53:51 +0100 Subject: make web search icon setting work properly --- desktop/searchweb.c | 35 +++++++++++++++++++++++++++++++++-- desktop/searchweb.h | 11 +++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) (limited to 'desktop') diff --git a/desktop/searchweb.c b/desktop/searchweb.c index 91a8118ca..2c0873de5 100644 --- a/desktop/searchweb.c +++ b/desktop/searchweb.c @@ -365,6 +365,33 @@ search_web_omni(const char *term, return NSERROR_OK; } +/* exported interface documented in desktop/searchweb.h */ +nserror search_web_get_provider_bitmap(struct bitmap **bitmap_out) +{ + struct search_provider *provider; + struct bitmap *ico_bitmap = NULL; + + /* must be initialised */ + if (search_web_ctx.providers == NULL) { + return NSERROR_INIT_FAILED; + } + + provider = &search_web_ctx.providers[search_web_ctx.current]; + + /* set the icon now (if we can) at least to the default */ + if (provider->ico_handle != NULL) { + ico_bitmap = content_get_bitmap(provider->ico_handle); + } + if ((ico_bitmap == NULL) && + (search_web_ctx.default_ico_handle != NULL)) { + ico_bitmap = content_get_bitmap(search_web_ctx.default_ico_handle); + } + + *bitmap_out = ico_bitmap; + return NSERROR_OK; +} + + /* exported interface documented in desktop/searchweb.h */ nserror search_web_select_provider(int selection) { @@ -520,10 +547,14 @@ nserror search_web_init(const char *provider_fname) } /* get default search icon */ - ret = hlcache_handle_retrieve(icon_nsurl, 0, NULL, NULL, + ret = hlcache_handle_retrieve(icon_nsurl, + 0, + NULL, + NULL, default_ico_callback, &search_web_ctx, - NULL, CONTENT_IMAGE, + NULL, + CONTENT_IMAGE, &search_web_ctx.default_ico_handle); nsurl_unref(icon_nsurl); if (ret != NSERROR_OK) { diff --git a/desktop/searchweb.h b/desktop/searchweb.h index a96e7787b..69748b6d6 100644 --- a/desktop/searchweb.h +++ b/desktop/searchweb.h @@ -72,6 +72,17 @@ enum search_web_omni_flags { */ nserror search_web_omni(const char *term, enum search_web_omni_flags flags, struct nsurl **url_out); + +/** + * obtain the current providers bitmap + * + * obtain the icon representing the current web search provider + * + * \param bitmap_out recives the resulting bitmap which may be NULL + * \return NSERROR_OK on success or NSERROR_INIT_FAILED if not initialised + */ +nserror search_web_get_provider_bitmap(struct bitmap **bitmap_out); + /** * Change the currently selected web search provider. * -- cgit v1.2.3