From eea34922668e8dd5830d6633766aefc3f6e8b5a4 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 23 Nov 2013 15:30:26 +0000 Subject: Update hotlist indicator when current page is added to hotlist. --- riscos/gui/url_bar.c | 23 +++++++++++++++++++++++ riscos/gui/url_bar.h | 10 ++++++++++ riscos/toolbar.c | 9 +++++++++ riscos/toolbar.h | 10 ++++++++++ riscos/window.c | 10 ++++++++-- 5 files changed, 60 insertions(+), 2 deletions(-) (limited to 'riscos') diff --git a/riscos/gui/url_bar.c b/riscos/gui/url_bar.c index 90fe5ed86..eede2ac88 100644 --- a/riscos/gui/url_bar.c +++ b/riscos/gui/url_bar.c @@ -997,6 +997,29 @@ void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url, } +/* This is an exported interface documented in url_bar.h */ + +void ro_gui_url_bar_hotlist_modifed(struct url_bar *url_bar, nsurl *url) +{ + nsurl *n; + + if (nsurl_create((const char *)url_bar->text_buffer, + &n) == NSERROR_OK) { + bool prev = url_bar->hotlist.add; + url_bar->hotlist.add = !hotlist_has_url(n); + nsurl_unref(n); + + if (prev != url_bar->hotlist.add && !url_bar->hidden) { + xwimp_force_redraw(url_bar->window, + url_bar->hotlist.extent.x0, + url_bar->hotlist.extent.y0, + url_bar->hotlist.extent.x1, + url_bar->hotlist.extent.y1); + } + } +} + + /* This is an exported interface documented in url_bar.h */ const char *ro_gui_url_bar_get_url(struct url_bar *url_bar) diff --git a/riscos/gui/url_bar.h b/riscos/gui/url_bar.h index edc77640b..04a8468ba 100644 --- a/riscos/gui/url_bar.h +++ b/riscos/gui/url_bar.h @@ -231,6 +231,16 @@ void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url, bool is_utf8, bool set_caret); +/** + * Update urlbar's hotlist icon, if necessary. + * + * \param *url_bar The URL Bar to update. + * \param *url URL with updated hotlist presence, or NULL if unknown. + */ + +void ro_gui_url_bar_hotlist_modifed(struct url_bar *url_bar, nsurl *url); + + /** * Return a pointer to the URL contained in a URL bar. * diff --git a/riscos/toolbar.c b/riscos/toolbar.c index d56c6fad2..4da4db478 100644 --- a/riscos/toolbar.c +++ b/riscos/toolbar.c @@ -1618,6 +1618,15 @@ const char *ro_toolbar_get_url(struct toolbar *toolbar) } +/* This is an exported interface documented in toolbar.h */ + +void ro_toolbar_hotlist_modifed(struct toolbar *toolbar, nsurl *url) +{ + if (toolbar != NULL && toolbar->url != NULL) + ro_gui_url_bar_hotlist_modifed(toolbar->url, url); +} + + /* This is an exported interface documented in toolbar.h */ bool ro_toolbar_get_url_field_extent(struct toolbar *toolbar, os_box *extent) diff --git a/riscos/toolbar.h b/riscos/toolbar.h index 583a5e765..284eee22d 100644 --- a/riscos/toolbar.h +++ b/riscos/toolbar.h @@ -385,6 +385,16 @@ void ro_toolbar_set_url(struct toolbar *toolbar, const char *url, const char *ro_toolbar_get_url(struct toolbar *toolbar); +/** + * Update toolbar's urlbar hotlist icon, if necessary. + * + * \param *toolbar The toolbar to update. + * \param *url URL with updated hotlist presence, or NULL if unknown. + */ + +void ro_toolbar_hotlist_modifed(struct toolbar *toolbar, nsurl *url); + + /** * Return the current work area coordinates of the URL and favicon field's * bounding box. diff --git a/riscos/window.c b/riscos/window.c index 866b3dfdf..35f9b201e 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -4245,11 +4245,17 @@ void ro_gui_window_action_zoom(struct gui_window *g) void ro_gui_window_action_add_bookmark(struct gui_window *g) { - if (g == NULL || g->bw == NULL || g->bw->current_content == NULL || + nsurl *url; + + if (g == NULL || g->bw == NULL || g->toolbar == NULL || + g->bw->current_content == NULL || hlcache_handle_get_url(g->bw->current_content) == NULL) return; - ro_gui_hotlist_add_page(hlcache_handle_get_url(g->bw->current_content)); + url = hlcache_handle_get_url(g->bw->current_content); + + ro_gui_hotlist_add_page(url); + ro_toolbar_hotlist_modifed(g->toolbar, url); } -- cgit v1.2.3