diff options
author | Steve Fryatt <stevef@netsurf-browser.org> | 2013-12-31 16:45:32 +0000 |
---|---|---|
committer | Steve Fryatt <stevef@netsurf-browser.org> | 2013-12-31 16:45:32 +0000 |
commit | 604108916923146c888e6659bd5df24fab460e41 (patch) | |
tree | dd274b9e3c9bb35bc8488e42dcf2bda7e22a4813 | |
parent | 56b0465e88f9941bd05fe7492a4d6b4e9bb7f9f0 (diff) | |
download | netsurf-604108916923146c888e6659bd5df24fab460e41.tar.gz netsurf-604108916923146c888e6659bd5df24fab460e41.tar.bz2 |
Implement user confirmation before removing hotlist entries from the URL bar.
-rw-r--r-- | resources/FatMessages | 15 | ||||
-rw-r--r-- | riscos/hotlist.c | 73 | ||||
-rw-r--r-- | riscos/window.c | 1 |
3 files changed, 86 insertions, 3 deletions
diff --git a/resources/FatMessages b/resources/FatMessages index 777bbc664..2d74f3d6d 100644 --- a/resources/FatMessages +++ b/resources/FatMessages @@ -3051,6 +3051,11 @@ de.all.OverwriteFile:Eine Datei mit diesem Namen existiert bereits und würde ü fr.all.OverwriteFile:Un fichier portant ce nom existe déjà et serait perdu. it.all.OverwriteFile:Un file con questo nome è già esistente, continuare comporterà la sovrascrittura del file originale. nl.all.OverwriteFile:Een bestand met deze naam bestaat al en zal verloren gaan. +en.all.RemoveHotlist:Are you sure you wish to remove this address from the hotlist? +de.all.RemoveHotlist:Are you sure you wish to remove this address from the hotlist? +fr.all.RemoveHotlist:Are you sure you wish to remove this address from the hotlist? +it.all.RemoveHotlist:Are you sure you wish to remove this address from the hotlist? +nl.all.RemoveHotlist:Are you sure you wish to remove this address from the hotlist? # Page fetching # ============= @@ -3590,6 +3595,16 @@ de.all.DontReplace:Abbrechen fr.all.DontReplace:Ne pas remplacer le fichier it.all.DontReplace:Non sostituire nl.all.DontReplace:Bestand niet vervangen +en.all.Remove:Remove address +de.all.Remove:Remove address +rf.all.Remove:Remove address +it.all.Remove:Remove address +nl.all.Remove:Remove address +en.all.DontRemove:Don't remove +de.all.DontRemove:Don't remove +rf.all.DontRemove:Don't remove +it.all.DontRemove:Don't remove +nl.all.DontRemove:Don't remove en.all.obj:object de.all.obj:Objekt fr.all.obj:objet diff --git a/riscos/hotlist.c b/riscos/hotlist.c index 9fcd81e08..b29ba7e19 100644 --- a/riscos/hotlist.c +++ b/riscos/hotlist.c @@ -62,6 +62,15 @@ static bool ro_gui_hotlist_menu_select(wimp_w w, wimp_i i, wimp_menu *menu, static void ro_gui_hotlist_toolbar_click(button_bar_action action); static void ro_gui_hotlist_addurl_bounce(wimp_message *message); static void ro_gui_hotlist_scheduled_callback(void *p); +static void ro_gui_hotlist_remove_confirmed(query_id id, + enum query_response res, void *p); +static void ro_gui_hotlist_remove_cancelled(query_id id, + enum query_response res, void *p); + +static const query_callback remove_funcs = { + ro_gui_hotlist_remove_confirmed, + ro_gui_hotlist_remove_cancelled +}; struct ro_treeview_callbacks ro_hotlist_treeview_callbacks = { ro_gui_hotlist_toolbar_click, @@ -85,6 +94,11 @@ struct ro_hotlist_message_hotlist_changed { static char *hotlist_url = NULL; /**< URL area claimed from RMA. */ static char *hotlist_title = NULL; /**< Title area claimed from RMA. */ +/** Hotlist Query Handler. */ + +static query_id hotlist_query = QUERY_INVALID; +static nsurl *hotlist_delete_url = NULL; + /* The RISC OS hotlist window, toolbar and treeview data. */ static struct ro_hotlist { @@ -599,10 +613,65 @@ void ro_gui_hotlist_add_cleanup(void) void ro_gui_hotlist_remove_page(nsurl *url) { - if (url == NULL || nsoption_bool(external_hotlists)) + if (url == NULL || nsoption_bool(external_hotlists) || + !hotlist_has_url(url)) return; - hotlist_remove_url(url); + /* Clean up any existing delete attempts before continuing. */ + + if (hotlist_query != QUERY_INVALID) { + query_close(hotlist_query); + hotlist_query = QUERY_INVALID; + } + + if (hotlist_delete_url != NULL) { + nsurl_unref(hotlist_delete_url); + hotlist_delete_url = NULL; + } + + hotlist_query = query_user("RemoveHotlist", NULL, &remove_funcs, NULL, + messages_get("Remove"), messages_get("DontRemove")); + + hotlist_delete_url = nsurl_ref(url); + + // hotlist_remove_url(url); +} + + +/** + * Callback confirming a URL delete query. + * + * \param id The ID of the query calling us. + * \param res The user's response to the query. + * \param *p Callback data (always NULL). + */ + +static void ro_gui_hotlist_remove_confirmed(query_id id, + enum query_response res, void *p) +{ + hotlist_remove_url(hotlist_delete_url); + ro_toolbar_update_all_hotlists(); + + nsurl_unref(hotlist_delete_url); + hotlist_delete_url = NULL; + hotlist_query = QUERY_INVALID; +} + + +/** + * Callback cancelling a URL delete query. + * + * \param id The ID of the query calling us. + * \param res The user's response to the query. + * \param *p Callback data (always NULL). + */ + +static void ro_gui_hotlist_remove_cancelled(query_id id, + enum query_response res, void *p) +{ + nsurl_unref(hotlist_delete_url); + hotlist_delete_url = NULL; + hotlist_query = QUERY_INVALID; } diff --git a/riscos/window.c b/riscos/window.c index d169a70be..f6b274a20 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -4300,7 +4300,6 @@ static void ro_gui_window_action_remove_bookmark(struct gui_window *g) url = hlcache_handle_get_url(g->bw->current_content); ro_gui_hotlist_remove_page(url); - ro_toolbar_update_hotlist(g->toolbar); } |