summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Fryatt <stevef@netsurf-browser.org>2013-12-30 12:36:24 +0000
committerSteve Fryatt <stevef@netsurf-browser.org>2013-12-30 12:36:24 +0000
commitb8dd4f282b521f881f33841a9e3bb101f933c349 (patch)
tree867771af6bafdac145f3dfe77f2e00221bdd5612
parentf825521072ed7e459e7fa465cf66efd24f5feb76 (diff)
downloadnetsurf-b8dd4f282b521f881f33841a9e3bb101f933c349.tar.gz
netsurf-b8dd4f282b521f881f33841a9e3bb101f933c349.tar.bz2
Bring hotlist icon event handling in line with other toolbar actions.
- Make hotlist icon return click events to clients. - Move URL add and remove code into browser window toolbar event handler. - Pass hotlist icon URL add/remove via RISC OS hotlist interface.
-rw-r--r--riscos/gui/url_bar.c40
-rw-r--r--riscos/gui/url_bar.h2
-rw-r--r--riscos/hotlist.c16
-rw-r--r--riscos/hotlist.h1
-rw-r--r--riscos/window.c43
5 files changed, 69 insertions, 33 deletions
diff --git a/riscos/gui/url_bar.c b/riscos/gui/url_bar.c
index 1bc426166..e51795734 100644
--- a/riscos/gui/url_bar.c
+++ b/riscos/gui/url_bar.c
@@ -760,40 +760,22 @@ bool ro_gui_url_bar_click(struct url_bar *url_bar,
pos.y > url_bar->extent.y1)
return false;
- /* If we have a click over the hotlist icon, hotlist add/remove. */
+ /* If we have a Select or Adjust click, check if it originated on the
+ * hotlist icon; if it did, return an event.
+ */
- if (pointer->buttons == wimp_SINGLE_SELECT &&
- url_bar->text_buffer != NULL) {
+ if (pointer->buttons == wimp_SINGLE_SELECT ||
+ pointer->buttons == wimp_SINGLE_ADJUST) {
if (pos.x >= url_bar->hotlist.extent.x0 &&
pos.x <= url_bar->hotlist.extent.x1 &&
pos.y >= url_bar->hotlist.extent.y0 &&
pos.y <= url_bar->hotlist.extent.y1) {
- nsurl *n;
- bool redraw = false;
- if (nsurl_create((const char *)url_bar->text_buffer,
- &n) == NSERROR_OK) {
- if (url_bar->hotlist.add) {
- if (hotlist_add_url(n) == NSERROR_OK) {
- redraw = true;
- url_bar->hotlist.add = false;
- }
- } else {
- /* TODO: Open "Remove page from
- * Hotlist?" query dialogue box,
- * rather than silent removal. */
- hotlist_remove_url(n);
- redraw = true;
- url_bar->hotlist.add = true;
- }
- nsurl_unref(n);
-
- if (redraw && !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);
- }
+ if (pointer->buttons == wimp_SINGLE_SELECT &&
+ action != NULL)
+ *action = TOOLBAR_URL_SELECT_HOTLIST;
+ else if (pointer->buttons == wimp_SINGLE_ADJUST &&
+ action != NULL)
+ *action = TOOLBAR_URL_ADJUST_HOTLIST;
return true;
}
}
diff --git a/riscos/gui/url_bar.h b/riscos/gui/url_bar.h
index 04a8468ba..c20dbf943 100644
--- a/riscos/gui/url_bar.h
+++ b/riscos/gui/url_bar.h
@@ -34,6 +34,8 @@ typedef enum {
TOOLBAR_URL_NONE = 0, /* Special case: no action */
TOOLBAR_URL_DRAG_URL,
TOOLBAR_URL_DRAG_FAVICON,
+ TOOLBAR_URL_SELECT_HOTLIST,
+ TOOLBAR_URL_ADJUST_HOTLIST
} url_bar_action;
struct url_bar;
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 7b5762fad..cb014b572 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -596,6 +596,22 @@ void ro_gui_hotlist_add_cleanup(void)
}
+/**
+ * Remove a URL from the hotlist. This will be passed on to the core hotlist,
+ * unless we're configured to use external hotlists in which case we ignore it.
+ *
+ * \param *url The URL to be removed.
+ */
+
+void ro_gui_hotlist_remove_page(nsurl *url)
+{
+ if (url == NULL || nsoption_bool(external_hotlists))
+ return;
+
+ hotlist_remove_url(url);
+}
+
+
#if 0
/**
* Handle URL dropped on hotlist
diff --git a/riscos/hotlist.h b/riscos/hotlist.h
index 25e4794a7..4993092c9 100644
--- a/riscos/hotlist.h
+++ b/riscos/hotlist.h
@@ -47,6 +47,7 @@ bool ro_gui_hotlist_check_window(wimp_w window);
bool ro_gui_hotlist_check_menu(wimp_menu *menu);
void ro_gui_hotlist_add_page(nsurl *url);
void ro_gui_hotlist_add_cleanup(void);
+void ro_gui_hotlist_remove_page(nsurl *url);
#endif
diff --git a/riscos/window.c b/riscos/window.c
index a7c42ac12..39ae5f658 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -138,6 +138,7 @@ static void ro_gui_window_action_save(struct gui_window *g,
static void ro_gui_window_action_search(struct gui_window *g);
static void ro_gui_window_action_zoom(struct gui_window *g);
static void ro_gui_window_action_add_bookmark(struct gui_window *g);
+static void ro_gui_window_action_remove_bookmark(struct gui_window *g);
static void ro_gui_window_action_print(struct gui_window *g);
static void ro_gui_window_action_page_info(struct gui_window *g);
@@ -3611,9 +3612,12 @@ void ro_gui_window_toolbar_click(void *data,
return;
- if (action_type == TOOLBAR_ACTION_URL &&
- action.url == TOOLBAR_URL_DRAG_URL) {
- if (g->bw->current_content) {
+ if (action_type == TOOLBAR_ACTION_URL) {
+ switch (action.url) {
+ case TOOLBAR_URL_DRAG_URL:
+ if (g->bw->current_content == NULL)
+ break;
+
hlcache_handle *h = g->bw->current_content;
if (ro_gui_shift_pressed())
@@ -3624,6 +3628,15 @@ void ro_gui_window_toolbar_click(void *data,
ro_gui_drag_save_link(save_type,
nsurl_access(hlcache_handle_get_url(h)),
content_get_title(h), g);
+ break;
+
+ case TOOLBAR_URL_SELECT_HOTLIST:
+ ro_gui_window_action_add_bookmark(g);
+ break;
+
+ case TOOLBAR_URL_ADJUST_HOTLIST:
+ ro_gui_window_action_remove_bookmark(g);
+ break;
}
return;
@@ -4250,7 +4263,7 @@ void ro_gui_window_action_zoom(struct gui_window *g)
* \param *g The browser window to act on.
*/
-void ro_gui_window_action_add_bookmark(struct gui_window *g)
+static void ro_gui_window_action_add_bookmark(struct gui_window *g)
{
nsurl *url;
@@ -4267,6 +4280,28 @@ void ro_gui_window_action_add_bookmark(struct gui_window *g)
/**
+ * Remove a hotlist entry for a browser window.
+ *
+ * \param *g The browser window to act on.
+ */
+
+static void ro_gui_window_action_remove_bookmark(struct gui_window *g)
+{
+ 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;
+
+ url = hlcache_handle_get_url(g->bw->current_content);
+
+ ro_gui_hotlist_remove_page(url);
+ ro_toolbar_hotlist_modifed(g->toolbar, url);
+}
+
+
+/**
* Open a print dialogue for a browser window.
*
* \param *g The browser window to act on.