2004-06-30 21:44:11 +04:00
|
|
|
/*
|
2014-01-03 02:25:23 +04:00
|
|
|
* Copyright 2010, 2013 Stephen Fryatt <stevef@netsurf-browser.org>
|
2016-12-26 16:22:42 +03:00
|
|
|
* Copyright 2016 Vincent Sanders <vince@netsurf-browser.org>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-06-30 21:44:11 +04:00
|
|
|
*/
|
|
|
|
|
2016-06-10 13:53:28 +03:00
|
|
|
/**
|
|
|
|
* \file
|
2016-12-26 16:22:42 +03:00
|
|
|
* Implementation of RISC OS hotlist manager.
|
2004-06-30 21:44:11 +04:00
|
|
|
*/
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
#include <stdint.h>
|
2004-06-30 21:44:11 +04:00
|
|
|
#include <stdlib.h>
|
2016-06-10 13:53:28 +03:00
|
|
|
#include <oslib/osmodule.h>
|
|
|
|
#include <oslib/wimp.h>
|
2014-03-08 18:13:27 +04:00
|
|
|
|
2014-10-16 12:50:55 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/nsoption.h"
|
2016-06-14 01:34:45 +03:00
|
|
|
#include "utils/nsurl.h"
|
|
|
|
#include "netsurf/url_db.h"
|
|
|
|
#include "netsurf/window.h"
|
2016-12-26 16:22:42 +03:00
|
|
|
#include "netsurf/plotters.h"
|
2016-07-01 16:27:04 +03:00
|
|
|
#include "netsurf/keypress.h"
|
2013-09-02 19:19:16 +04:00
|
|
|
#include "desktop/hotlist.h"
|
2014-03-08 18:13:27 +04:00
|
|
|
|
|
|
|
#include "riscos/gui.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/dialog.h"
|
2011-10-09 17:32:43 +04:00
|
|
|
#include "riscos/message.h"
|
2010-10-05 23:14:46 +04:00
|
|
|
#include "riscos/save.h"
|
2011-02-21 02:16:33 +03:00
|
|
|
#include "riscos/toolbar.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/wimp.h"
|
|
|
|
#include "riscos/wimp_event.h"
|
2014-01-16 18:28:25 +04:00
|
|
|
#include "riscos/query.h"
|
2016-12-26 16:22:42 +03:00
|
|
|
#include "riscos/menus.h"
|
|
|
|
#include "riscos/corewindow.h"
|
|
|
|
#include "riscos/hotlist.h"
|
2004-06-30 21:44:11 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
/**
|
|
|
|
* Hotlist window container for RISC OS.
|
|
|
|
*/
|
|
|
|
struct ro_hotlist_window {
|
|
|
|
struct ro_corewindow core;
|
|
|
|
wimp_menu *menu;
|
2011-10-09 17:32:43 +04:00
|
|
|
};
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
/** hotlist window singleton */
|
|
|
|
static struct ro_hotlist_window *hotlist_window = NULL;
|
2011-10-09 17:32:43 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
/** riscos template for hotlist window */
|
|
|
|
static wimp_window *dialog_hotlist_template;
|
2011-10-09 17:32:43 +04:00
|
|
|
|
2013-12-31 20:45:32 +04:00
|
|
|
/** Hotlist Query Handler. */
|
|
|
|
static query_id hotlist_query = QUERY_INVALID;
|
2016-12-26 16:22:42 +03:00
|
|
|
static nsurl *hotlist_delete_url = NULL;
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
/**
|
|
|
|
* URL adding hotlist protocol message block.
|
|
|
|
*
|
|
|
|
* Message block is not currently in OSLib.
|
|
|
|
*/
|
|
|
|
struct ro_hotlist_message_hotlist_addurl {
|
|
|
|
wimp_MESSAGE_HEADER_MEMBERS /**< The standard message header. */
|
|
|
|
char *url; /**< Pointer to the URL in RMA. */
|
|
|
|
char *title; /**< Pointer to the title in RMA. */
|
|
|
|
char appname[32]; /**< The application name. */
|
|
|
|
};
|
2010-10-05 23:14:46 +04:00
|
|
|
|
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* change hotlist protocol message block.
|
|
|
|
*
|
|
|
|
* Message block is not currently in OSLib.
|
2010-10-05 23:14:46 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
struct ro_hotlist_message_hotlist_changed {
|
|
|
|
wimp_MESSAGE_HEADER_MEMBERS /**< The standard message header. */
|
|
|
|
};
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
/** URL area claimed from RMA. */
|
|
|
|
static char *hotlist_url = NULL;
|
|
|
|
/** Title area claimed from RMA. */
|
|
|
|
static char *hotlist_title = NULL;
|
2004-07-04 23:27:42 +04:00
|
|
|
|
2004-06-30 21:44:11 +04:00
|
|
|
|
2004-07-09 02:05:35 +04:00
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* callback to draw on drawable area of ro hotlist window
|
|
|
|
*
|
|
|
|
* \param ro_cw The riscos core window structure.
|
|
|
|
* \param r The rectangle of the window that needs updating.
|
|
|
|
* \param originx The risc os plotter x origin.
|
|
|
|
* \param originy The risc os plotter y origin.
|
|
|
|
* \return NSERROR_OK on success otherwise apropriate error code
|
2004-07-09 02:05:35 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static nserror
|
|
|
|
hotlist_draw(struct ro_corewindow *ro_cw,
|
|
|
|
int originx,
|
|
|
|
int originy,
|
|
|
|
struct rect *r)
|
2008-07-27 02:29:15 +04:00
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
struct redraw_context ctx = {
|
|
|
|
.interactive = true,
|
|
|
|
.background_images = true,
|
|
|
|
.plot = &ro_plotters
|
2010-10-05 23:14:46 +04:00
|
|
|
};
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_plot_origin_x = originx;
|
|
|
|
ro_plot_origin_y = originy;
|
|
|
|
no_font_blending = true;
|
|
|
|
hotlist_redraw(0, 0, r, &ctx);
|
|
|
|
no_font_blending = false;
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
return NSERROR_OK;
|
2004-07-09 02:05:35 +04:00
|
|
|
}
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2013-09-08 22:04:45 +04:00
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* callback for keypress on ro hotlist window
|
|
|
|
*
|
|
|
|
* \param ro_cw The ro core window structure.
|
|
|
|
* \param nskey The netsurf key code.
|
|
|
|
* \return NSERROR_OK if key processed,
|
|
|
|
* NSERROR_NOT_IMPLEMENTED if key not processed
|
|
|
|
* otherwise apropriate error code
|
2013-09-08 22:04:45 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static nserror hotlist_key(struct ro_corewindow *ro_cw, uint32_t nskey)
|
2013-09-08 22:04:45 +04:00
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
if (hotlist_keypress(nskey)) {
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
return NSERROR_NOT_IMPLEMENTED;
|
2013-09-08 22:04:45 +04:00
|
|
|
}
|
|
|
|
|
2004-06-30 21:44:11 +04:00
|
|
|
|
2004-12-09 13:30:44 +03:00
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* callback for mouse event on ro hotlist window
|
2004-12-09 13:30:44 +03:00
|
|
|
*
|
2016-12-26 16:22:42 +03:00
|
|
|
* \param ro_cw The ro core window structure.
|
|
|
|
* \param mouse_state mouse state
|
|
|
|
* \param x location of event
|
|
|
|
* \param y location of event
|
|
|
|
* \return NSERROR_OK on sucess otherwise apropriate error code.
|
2004-12-09 13:30:44 +03:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static nserror
|
|
|
|
hotlist_mouse(struct ro_corewindow *ro_cw,
|
|
|
|
browser_mouse_state mouse_state,
|
|
|
|
int x, int y)
|
2008-07-27 02:29:15 +04:00
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
hotlist_mouse_action(mouse_state, x, y);
|
2011-02-21 02:16:33 +03:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
return NSERROR_OK;
|
2004-07-29 15:40:48 +04:00
|
|
|
}
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-25 00:00:45 +04:00
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* handle clicks in ro hotlist window toolbar.
|
2010-10-25 00:00:45 +04:00
|
|
|
*
|
2016-12-26 16:22:42 +03:00
|
|
|
* \param ro_cw The ro core window structure.
|
|
|
|
* \param action The button bar action.
|
|
|
|
* \return NSERROR_OK if config saved, otherwise apropriate error code
|
2010-10-25 00:00:45 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static nserror
|
|
|
|
hotlist_toolbar_click(struct ro_corewindow *ro_cw, button_bar_action action)
|
2010-10-25 00:00:45 +04:00
|
|
|
{
|
2011-02-21 02:16:33 +03:00
|
|
|
switch (action) {
|
|
|
|
case TOOLBAR_BUTTON_DELETE:
|
2015-03-27 12:36:19 +03:00
|
|
|
hotlist_keypress(NS_KEY_DELETE_LEFT);
|
2013-12-30 20:20:37 +04:00
|
|
|
ro_toolbar_update_all_hotlists();
|
2011-02-21 02:16:33 +03:00
|
|
|
break;
|
2010-10-25 03:17:21 +04:00
|
|
|
|
2011-02-21 02:16:33 +03:00
|
|
|
case TOOLBAR_BUTTON_EXPAND:
|
2013-09-03 15:36:55 +04:00
|
|
|
hotlist_expand(false);
|
2011-02-21 02:16:33 +03:00
|
|
|
break;
|
2010-10-25 00:00:45 +04:00
|
|
|
|
2011-02-21 02:16:33 +03:00
|
|
|
case TOOLBAR_BUTTON_COLLAPSE:
|
2013-09-03 15:36:55 +04:00
|
|
|
hotlist_contract(false);
|
2010-10-25 00:00:45 +04:00
|
|
|
break;
|
2011-02-21 02:16:33 +03:00
|
|
|
|
|
|
|
case TOOLBAR_BUTTON_OPEN:
|
2013-09-03 15:36:55 +04:00
|
|
|
hotlist_expand(true);
|
2010-10-25 00:00:45 +04:00
|
|
|
break;
|
2011-02-21 02:16:33 +03:00
|
|
|
|
|
|
|
case TOOLBAR_BUTTON_CLOSE:
|
2013-09-03 15:36:55 +04:00
|
|
|
hotlist_contract(true);
|
2010-10-25 00:00:45 +04:00
|
|
|
break;
|
2011-02-21 02:16:33 +03:00
|
|
|
|
|
|
|
case TOOLBAR_BUTTON_LAUNCH:
|
2015-03-27 12:36:19 +03:00
|
|
|
hotlist_keypress(NS_KEY_CR);
|
2010-10-25 00:00:45 +04:00
|
|
|
break;
|
2011-02-21 02:16:33 +03:00
|
|
|
|
|
|
|
case TOOLBAR_BUTTON_CREATE:
|
2013-09-03 01:41:04 +04:00
|
|
|
hotlist_add_folder(NULL, false, 0);
|
2011-02-21 02:16:33 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-10-25 00:00:45 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-12-26 16:22:42 +03:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
2011-02-21 02:16:33 +03:00
|
|
|
}
|
2010-10-25 00:00:45 +04:00
|
|
|
|
2011-02-21 02:16:33 +03:00
|
|
|
|
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* Handle updating state of buttons in ro core window toolbar.
|
|
|
|
*
|
|
|
|
* \param ro_cw The ro core window structure.
|
|
|
|
* \return NSERROR_OK if config saved, otherwise apropriate error code
|
2011-02-21 02:16:33 +03:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static nserror hotlist_toolbar_update(struct ro_corewindow *ro_cw)
|
2011-02-21 02:16:33 +03:00
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
bool has_selection;
|
|
|
|
|
|
|
|
has_selection = hotlist_has_selection();
|
|
|
|
|
|
|
|
ro_toolbar_set_button_shaded_state(ro_cw->toolbar,
|
|
|
|
TOOLBAR_BUTTON_DELETE,
|
|
|
|
!has_selection);
|
2011-02-21 02:16:33 +03:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_toolbar_set_button_shaded_state(ro_cw->toolbar,
|
|
|
|
TOOLBAR_BUTTON_LAUNCH,
|
|
|
|
!has_selection);
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
2011-02-21 02:16:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* callback for saving of toolbar state in ro hotlist window
|
2011-02-21 02:16:33 +03:00
|
|
|
*
|
2016-12-26 16:22:42 +03:00
|
|
|
* \param ro_cw The ro core window structure.
|
|
|
|
* \param config The new toolbar configuration.
|
|
|
|
* \return NSERROR_OK if config saved, otherwise apropriate error code
|
2011-02-21 02:16:33 +03:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static nserror hotlist_toolbar_save(struct ro_corewindow *ro_cw, char *config)
|
2011-02-21 02:16:33 +03:00
|
|
|
{
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_charp(toolbar_hotlist, config);
|
2011-02-21 02:16:33 +03:00
|
|
|
ro_gui_save_options();
|
2016-12-26 16:22:42 +03:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
2010-10-25 00:00:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-29 15:40:48 +04:00
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* Prepare the hotlist menu for display
|
2004-07-29 15:40:48 +04:00
|
|
|
*
|
2016-12-26 16:22:42 +03:00
|
|
|
* \param w The window owning the menu.
|
|
|
|
* \param i The icon owning the menu.
|
|
|
|
* \param menu The menu from which the selection was made.
|
|
|
|
* \param pointer The pointer shape
|
|
|
|
* \return true if action accepted; else false.
|
2004-07-29 15:40:48 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static bool
|
|
|
|
hotlist_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu, wimp_pointer *pointer)
|
2008-07-27 02:29:15 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
bool selection;
|
2016-12-26 16:22:42 +03:00
|
|
|
struct ro_hotlist_window *hotlistw;
|
|
|
|
|
|
|
|
hotlistw = (struct ro_hotlist_window *)ro_gui_wimp_event_get_user_data(w);
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
if ((hotlistw == NULL) ||
|
|
|
|
(menu != hotlistw->menu)) {
|
2011-02-21 02:16:33 +03:00
|
|
|
return false;
|
2016-12-26 16:22:42 +03:00
|
|
|
}
|
2010-10-25 03:17:21 +04:00
|
|
|
|
2013-09-02 19:19:16 +04:00
|
|
|
selection = hotlist_has_selection();
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_gui_menu_set_entry_shaded(menu, TREE_SELECTION, !selection);
|
|
|
|
ro_gui_menu_set_entry_shaded(menu, TREE_CLEAR_SELECTION, !selection);
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2011-02-21 02:16:33 +03:00
|
|
|
ro_gui_save_prepare(GUI_SAVE_HOTLIST_EXPORT_HTML,
|
2016-12-26 16:22:42 +03:00
|
|
|
NULL, NULL, NULL, NULL);
|
2010-10-25 03:17:21 +04:00
|
|
|
|
|
|
|
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_BUTTONS,
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_toolbar_menu_option_shade(hotlistw->core.toolbar));
|
2010-10-25 03:17:21 +04:00
|
|
|
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_BUTTONS,
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_toolbar_menu_buttons_tick(hotlistw->core.toolbar));
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2010-10-25 03:17:21 +04:00
|
|
|
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_EDIT,
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_toolbar_menu_edit_shade(hotlistw->core.toolbar));
|
2010-10-25 03:17:21 +04:00
|
|
|
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_EDIT,
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_toolbar_menu_edit_tick(hotlistw->core.toolbar));
|
2011-02-21 02:16:33 +03:00
|
|
|
|
|
|
|
return true;
|
2004-12-09 13:30:44 +03:00
|
|
|
}
|
2004-07-29 15:40:48 +04:00
|
|
|
|
2010-10-25 03:17:21 +04:00
|
|
|
|
2004-12-09 13:30:44 +03:00
|
|
|
/**
|
2010-10-05 23:14:46 +04:00
|
|
|
* Handle submenu warnings for the hotlist menu
|
2004-12-09 13:30:44 +03:00
|
|
|
*
|
2016-12-26 16:22:42 +03:00
|
|
|
* \param w The window owning the menu.
|
|
|
|
* \param i The icon owning the menu.
|
|
|
|
* \param menu The menu to which the warning applies.
|
|
|
|
* \param selection The wimp menu selection data.
|
|
|
|
* \param action The selected menu action.
|
2004-12-09 13:30:44 +03:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static void
|
|
|
|
hotlist_menu_warning(wimp_w w,
|
|
|
|
wimp_i i,
|
|
|
|
wimp_menu *menu,
|
|
|
|
wimp_selection *selection,
|
|
|
|
menu_action action)
|
2008-07-27 02:29:15 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
/* Do nothing */
|
2004-07-29 15:40:48 +04:00
|
|
|
}
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2004-07-29 15:40:48 +04:00
|
|
|
/**
|
2010-10-05 23:14:46 +04:00
|
|
|
* Handle selections from the hotlist menu
|
2004-07-29 15:40:48 +04:00
|
|
|
*
|
2016-12-26 16:22:42 +03:00
|
|
|
* \param w The window owning the menu.
|
|
|
|
* \param i The icon owning the menu.
|
|
|
|
* \param menu The menu from which the selection was made.
|
|
|
|
* \param selection The wimp menu selection data.
|
|
|
|
* \param action The selected menu action.
|
|
|
|
* \return true if action accepted; else false.
|
2004-07-29 15:40:48 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static bool
|
|
|
|
hotlist_menu_select(wimp_w w,
|
|
|
|
wimp_i i,
|
|
|
|
wimp_menu *menu,
|
|
|
|
wimp_selection *selection,
|
|
|
|
menu_action action)
|
2008-07-27 02:29:15 +04:00
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
struct ro_hotlist_window *hotlistw;
|
|
|
|
|
|
|
|
hotlistw = (struct ro_hotlist_window *)ro_gui_wimp_event_get_user_data(w);
|
|
|
|
|
|
|
|
if ((hotlistw == NULL) ||
|
|
|
|
(menu != hotlistw->menu)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
switch (action) {
|
|
|
|
case HOTLIST_EXPORT:
|
2011-02-21 02:16:33 +03:00
|
|
|
ro_gui_dialog_open_persistent(w, dialog_saveas, true);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_NEW_FOLDER:
|
2013-09-03 01:41:04 +04:00
|
|
|
hotlist_add_folder(NULL, false, 0);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_NEW_LINK:
|
2013-09-03 01:41:04 +04:00
|
|
|
hotlist_add_entry(NULL, NULL, false, 0);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_EXPAND_ALL:
|
2013-09-03 15:36:55 +04:00
|
|
|
hotlist_expand(false);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_EXPAND_FOLDERS:
|
2013-09-03 15:36:55 +04:00
|
|
|
hotlist_expand(true);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_EXPAND_LINKS:
|
2013-09-03 15:36:55 +04:00
|
|
|
hotlist_expand(false);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_COLLAPSE_ALL:
|
2013-09-03 15:36:55 +04:00
|
|
|
hotlist_contract(true);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_COLLAPSE_FOLDERS:
|
2013-09-03 15:36:55 +04:00
|
|
|
hotlist_contract(true);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_COLLAPSE_LINKS:
|
2013-09-03 15:36:55 +04:00
|
|
|
hotlist_contract(false);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_SELECTION_EDIT:
|
2013-09-03 01:41:04 +04:00
|
|
|
hotlist_edit_selection();
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_SELECTION_LAUNCH:
|
2015-03-27 12:36:19 +03:00
|
|
|
hotlist_keypress(NS_KEY_CR);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_SELECTION_DELETE:
|
2015-03-27 12:36:19 +03:00
|
|
|
hotlist_keypress(NS_KEY_DELETE_LEFT);
|
2013-12-30 20:20:37 +04:00
|
|
|
ro_toolbar_update_all_hotlists();
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_SELECT_ALL:
|
2015-03-27 12:36:19 +03:00
|
|
|
hotlist_keypress(NS_KEY_SELECT_ALL);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_CLEAR_SELECTION:
|
2015-03-27 12:36:19 +03:00
|
|
|
hotlist_keypress(NS_KEY_CLEAR_SELECTION);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-25 01:52:16 +04:00
|
|
|
case TOOLBAR_BUTTONS:
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_toolbar_set_display_buttons(hotlistw->core.toolbar,
|
|
|
|
!ro_toolbar_get_display_buttons(hotlistw->core.toolbar));
|
2010-10-25 01:52:16 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-25 01:52:16 +04:00
|
|
|
case TOOLBAR_EDIT:
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_toolbar_toggle_edit(hotlistw->core.toolbar);
|
2010-10-25 01:52:16 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
default:
|
|
|
|
return false;
|
2006-01-08 04:51:33 +03:00
|
|
|
}
|
2004-07-16 03:58:08 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
return false;
|
|
|
|
}
|
2004-07-16 03:58:08 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2004-07-06 02:17:59 +04:00
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* Creates the window for the hotlist tree.
|
2004-07-06 02:17:59 +04:00
|
|
|
*
|
2016-12-26 16:22:42 +03:00
|
|
|
* \return NSERROR_OK on success else appropriate error code on faliure.
|
2004-07-06 02:17:59 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static nserror ro_hotlist_init(void)
|
|
|
|
{
|
|
|
|
struct ro_hotlist_window *ncwin;
|
|
|
|
nserror res;
|
|
|
|
static const struct ns_menu hotlist_menu_def = {
|
|
|
|
"Hotlist", {
|
|
|
|
{ "Hotlist", NO_ACTION, 0 },
|
|
|
|
{ "Hotlist.New", NO_ACTION, 0 },
|
|
|
|
{ "Hotlist.New.Folder", TREE_NEW_FOLDER, 0 },
|
|
|
|
{ "Hotlist.New.Link", TREE_NEW_LINK, 0 },
|
|
|
|
{ "_Hotlist.Export", HOTLIST_EXPORT, &dialog_saveas },
|
|
|
|
{ "Hotlist.Expand", TREE_EXPAND_ALL, 0 },
|
|
|
|
{ "Hotlist.Expand.All", TREE_EXPAND_ALL, 0 },
|
|
|
|
{ "Hotlist.Expand.Folders", TREE_EXPAND_FOLDERS, 0 },
|
|
|
|
{ "Hotlist.Expand.Links", TREE_EXPAND_LINKS, 0 },
|
|
|
|
{ "Hotlist.Collapse", TREE_COLLAPSE_ALL, 0 },
|
|
|
|
{ "Hotlist.Collapse.All", TREE_COLLAPSE_ALL, 0 },
|
|
|
|
{ "Hotlist.Collapse.Folders", TREE_COLLAPSE_FOLDERS, 0 },
|
|
|
|
{ "Hotlist.Collapse.Links", TREE_COLLAPSE_LINKS, 0 },
|
|
|
|
{ "Hotlist.Toolbars", NO_ACTION, 0 },
|
|
|
|
{ "_Hotlist.Toolbars.ToolButtons", TOOLBAR_BUTTONS, 0 },
|
|
|
|
{ "Hotlist.Toolbars.EditToolbar", TOOLBAR_EDIT, 0 },
|
|
|
|
{ "Selection", TREE_SELECTION, 0 },
|
|
|
|
{ "Selection.Edit", TREE_SELECTION_EDIT, 0 },
|
|
|
|
{ "Selection.Launch", TREE_SELECTION_LAUNCH, 0 },
|
|
|
|
{ "Selection.Delete", TREE_SELECTION_DELETE, 0 },
|
|
|
|
{ "SelectAll", TREE_SELECT_ALL, 0 },
|
|
|
|
{ "Clear", TREE_CLEAR_SELECTION, 0 },
|
|
|
|
{ NULL, 0, 0}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct button_bar_buttons hotlist_toolbar_buttons[] = {
|
|
|
|
{ "delete", TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_NONE, '0', "0" },
|
|
|
|
{ "expand", TOOLBAR_BUTTON_EXPAND, TOOLBAR_BUTTON_COLLAPSE, '1', "1" },
|
|
|
|
{ "open", TOOLBAR_BUTTON_OPEN, TOOLBAR_BUTTON_CLOSE, '2', "2" },
|
|
|
|
{ "launch", TOOLBAR_BUTTON_LAUNCH, TOOLBAR_BUTTON_NONE, '3', "3" },
|
|
|
|
{ "create", TOOLBAR_BUTTON_CREATE, TOOLBAR_BUTTON_NONE, '4', "4" },
|
|
|
|
{ NULL, TOOLBAR_BUTTON_NONE, TOOLBAR_BUTTON_NONE, '\0', "" }
|
|
|
|
};
|
|
|
|
|
|
|
|
if (hotlist_window != NULL) {
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2017-06-11 12:10:25 +03:00
|
|
|
ncwin = calloc(1, sizeof(*ncwin));
|
2016-12-26 16:22:42 +03:00
|
|
|
if (ncwin == NULL) {
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create window from template */
|
|
|
|
ncwin->core.wh = wimp_create_window(dialog_hotlist_template);
|
|
|
|
|
|
|
|
ro_gui_set_window_title(ncwin->core.wh, messages_get("Hotlist"));
|
|
|
|
|
|
|
|
/* Set up callback handlers */
|
|
|
|
ncwin->core.draw = hotlist_draw;
|
|
|
|
ncwin->core.key = hotlist_key;
|
|
|
|
ncwin->core.mouse = hotlist_mouse;
|
|
|
|
ncwin->core.toolbar_click = hotlist_toolbar_click;
|
|
|
|
ncwin->core.toolbar_save = hotlist_toolbar_save;
|
|
|
|
/* update is not valid untill hotlist manager is initialised */
|
|
|
|
ncwin->core.toolbar_update = NULL;
|
|
|
|
|
|
|
|
/* initialise core window */
|
|
|
|
res = ro_corewindow_init(&ncwin->core,
|
|
|
|
hotlist_toolbar_buttons,
|
|
|
|
nsoption_charp(toolbar_hotlist),
|
|
|
|
THEME_STYLE_HOTLIST_TOOLBAR,
|
|
|
|
"HelpHotToolbar");
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
free(ncwin);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2016-12-29 17:51:43 +03:00
|
|
|
res = hotlist_manager_init(ncwin->core.cb_table,
|
|
|
|
(struct core_window *)ncwin);
|
2016-12-26 16:22:42 +03:00
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
free(ncwin);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup toolbar update post hotlist manager initialisation */
|
|
|
|
ncwin->core.toolbar_update = hotlist_toolbar_update;
|
|
|
|
hotlist_toolbar_update(&ncwin->core);
|
|
|
|
|
|
|
|
/* Build the hotlist window menu. */
|
|
|
|
ncwin->menu = ro_gui_menu_define_menu(&hotlist_menu_def);
|
|
|
|
|
|
|
|
ro_gui_wimp_event_register_menu(ncwin->core.wh,
|
|
|
|
ncwin->menu, false, false);
|
|
|
|
ro_gui_wimp_event_register_menu_prepare(ncwin->core.wh,
|
|
|
|
hotlist_menu_prepare);
|
|
|
|
ro_gui_wimp_event_register_menu_selection(ncwin->core.wh,
|
|
|
|
hotlist_menu_select);
|
|
|
|
ro_gui_wimp_event_register_menu_warning(ncwin->core.wh,
|
|
|
|
hotlist_menu_warning);
|
|
|
|
|
|
|
|
/* memoise window so it can be re-presented when necessary
|
|
|
|
* instead of recreating every time.
|
|
|
|
*/
|
|
|
|
hotlist_window = ncwin;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in riscos/hotlist.h */
|
|
|
|
nserror ro_gui_hotlist_present(void)
|
2008-07-27 02:29:15 +04:00
|
|
|
{
|
2016-12-29 15:56:38 +03:00
|
|
|
nserror res;
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
/* deal with external hotlist handler */
|
|
|
|
if (nsoption_bool(external_hotlists) &&
|
|
|
|
(nsoption_charp(external_hotlist_app) != NULL) &&
|
|
|
|
(*nsoption_charp(external_hotlist_app) != '\0')) {
|
|
|
|
char command[2048];
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
snprintf(command, sizeof(command), "Filer_Run %s",
|
|
|
|
nsoption_charp(external_hotlist_app));
|
|
|
|
error = xos_cli(command);
|
|
|
|
|
|
|
|
if (error == NULL) {
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess);
|
|
|
|
ro_warn_user("Failed to launch external hotlist: %s",
|
|
|
|
error->errmess);
|
|
|
|
}
|
|
|
|
|
2016-12-29 15:21:03 +03:00
|
|
|
res = ro_hotlist_init();
|
|
|
|
if (res == NSERROR_OK) {
|
|
|
|
LOG("Presenting");
|
|
|
|
ro_gui_dialog_open_top(hotlist_window->core.wh,
|
|
|
|
hotlist_window->core.toolbar,
|
|
|
|
600, 800);
|
|
|
|
} else {
|
|
|
|
LOG("Failed presenting code %d", res);
|
|
|
|
}
|
2016-12-26 16:22:42 +03:00
|
|
|
|
2016-12-29 15:21:03 +03:00
|
|
|
return res;
|
2016-12-26 16:22:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in riscos/hotlist.h */
|
|
|
|
void ro_gui_hotlist_initialise(void)
|
|
|
|
{
|
|
|
|
dialog_hotlist_template = ro_gui_dialog_load_template("tree");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in riscos/hotlist.h */
|
|
|
|
nserror ro_gui_hotlist_finalise(void)
|
|
|
|
{
|
|
|
|
nserror res;
|
|
|
|
|
|
|
|
if (hotlist_window == NULL) {
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2017-04-25 14:13:07 +03:00
|
|
|
res = hotlist_fini();
|
2016-12-26 16:22:42 +03:00
|
|
|
if (res == NSERROR_OK) {
|
|
|
|
res = ro_corewindow_fini(&hotlist_window->core);
|
|
|
|
|
|
|
|
free(hotlist_window);
|
|
|
|
hotlist_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in riscos/hotlist.h */
|
|
|
|
bool ro_gui_hotlist_check_window(wimp_w wh)
|
|
|
|
{
|
|
|
|
if ((hotlist_window != NULL) &&
|
|
|
|
(hotlist_window->core.wh == wh)) {
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
}
|
|
|
|
return false;
|
2010-10-05 23:14:46 +04:00
|
|
|
}
|
2009-03-28 22:59:46 +03:00
|
|
|
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
/* exported interface documented in riscos/hotlist.h */
|
2010-10-05 23:14:46 +04:00
|
|
|
bool ro_gui_hotlist_check_menu(wimp_menu *menu)
|
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
if ((hotlist_window != NULL) &&
|
|
|
|
(hotlist_window->menu == menu)) {
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-26 16:22:42 +03:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to schedule for the next available Null poll, by which point
|
|
|
|
* a hotlist client will have claimed the Message_HotlistAddURL and any
|
|
|
|
* details in RMA can safely be discarded.
|
|
|
|
*
|
|
|
|
* \param p Unused data pointer.
|
|
|
|
*/
|
|
|
|
static void ro_gui_hotlist_scheduled_callback(void *p)
|
|
|
|
{
|
|
|
|
ro_gui_hotlist_add_cleanup();
|
2010-10-05 23:14:46 +04:00
|
|
|
}
|
2009-03-28 22:59:46 +03:00
|
|
|
|
2011-10-09 17:32:43 +04:00
|
|
|
|
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* Handle bounced Message_HotlistAddURL, so that RMA storage can be freed.
|
2011-10-09 17:32:43 +04:00
|
|
|
*
|
2016-12-26 16:22:42 +03:00
|
|
|
* \param message The bounced message content.
|
2011-10-09 17:32:43 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static void ro_gui_hotlist_addurl_bounce(wimp_message *message)
|
|
|
|
{
|
|
|
|
if (hotlist_url != NULL) {
|
|
|
|
nsurl *nsurl;
|
|
|
|
|
|
|
|
if (nsurl_create(hotlist_url, &nsurl) != NSERROR_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hotlist_add_url(nsurl);
|
|
|
|
nsurl_unref(nsurl);
|
|
|
|
}
|
2011-10-09 17:32:43 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_gui_hotlist_add_cleanup();
|
|
|
|
|
|
|
|
/* There's no longer any need to listen for the next Null poll. */
|
|
|
|
|
|
|
|
riscos_schedule(-1, ro_gui_hotlist_scheduled_callback, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in riscos/hotlist.h */
|
2013-11-22 22:19:20 +04:00
|
|
|
void ro_gui_hotlist_add_page(nsurl *url)
|
2011-10-09 17:32:43 +04:00
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
const struct url_data *data;
|
|
|
|
wimp_message message;
|
|
|
|
struct ro_hotlist_message_hotlist_addurl *add_url =
|
|
|
|
(struct ro_hotlist_message_hotlist_addurl *) &message;
|
2011-10-09 17:32:43 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
if (url == NULL) {
|
2011-10-09 17:32:43 +04:00
|
|
|
return;
|
2016-12-26 16:22:42 +03:00
|
|
|
}
|
2011-10-09 17:32:43 +04:00
|
|
|
|
2011-10-14 00:40:52 +04:00
|
|
|
/* If we're not using external hotlists, add the page to NetSurf's
|
|
|
|
* own hotlist and return...
|
|
|
|
*/
|
2012-03-22 13:34:34 +04:00
|
|
|
if (!nsoption_bool(external_hotlists)) {
|
2013-11-22 22:19:20 +04:00
|
|
|
hotlist_add_url(url);
|
2011-10-14 00:40:52 +04:00
|
|
|
return;
|
|
|
|
}
|
2011-10-09 17:32:43 +04:00
|
|
|
|
2011-10-14 00:40:52 +04:00
|
|
|
/* ...otherwise try broadcasting the details to any other
|
|
|
|
* interested parties. If no-one answers, we'll fall back to
|
|
|
|
* NetSurf's hotlist anyway when the message bounces.
|
2011-10-09 17:32:43 +04:00
|
|
|
*/
|
|
|
|
|
2011-10-14 00:40:52 +04:00
|
|
|
ro_gui_hotlist_add_cleanup();
|
2011-10-09 17:32:43 +04:00
|
|
|
|
2013-11-22 22:19:20 +04:00
|
|
|
data = urldb_get_url_data(url);
|
2011-10-09 17:32:43 +04:00
|
|
|
if (data == NULL)
|
|
|
|
return;
|
|
|
|
|
2013-11-22 22:19:20 +04:00
|
|
|
hotlist_url = osmodule_alloc(nsurl_length(url) + 1);
|
2011-10-09 17:32:43 +04:00
|
|
|
hotlist_title = osmodule_alloc(strlen(data->title) + 1);
|
|
|
|
|
|
|
|
if (hotlist_url == NULL || hotlist_title == NULL) {
|
|
|
|
ro_gui_hotlist_add_cleanup();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-22 22:19:20 +04:00
|
|
|
strcpy(hotlist_url, nsurl_access(url));
|
2011-10-09 17:32:43 +04:00
|
|
|
strcpy(hotlist_title, data->title);
|
|
|
|
|
|
|
|
add_url->size = 60;
|
|
|
|
add_url->your_ref = 0;
|
|
|
|
add_url->action = message_HOTLIST_ADD_URL;
|
|
|
|
add_url->url = hotlist_url;
|
|
|
|
add_url->title = hotlist_title;
|
|
|
|
strcpy(add_url->appname, "NetSurf");
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
if (!ro_message_send_message(wimp_USER_MESSAGE_RECORDED,
|
|
|
|
&message,
|
|
|
|
0,
|
|
|
|
ro_gui_hotlist_addurl_bounce)) {
|
2011-10-09 17:32:43 +04:00
|
|
|
ro_gui_hotlist_add_cleanup();
|
2016-12-26 16:22:42 +03:00
|
|
|
}
|
2011-10-14 00:40:52 +04:00
|
|
|
|
|
|
|
/* Listen for the next Null poll, as an indication that the
|
|
|
|
* message didn't bounce.
|
|
|
|
*/
|
2014-03-08 18:13:27 +04:00
|
|
|
riscos_schedule(0, ro_gui_hotlist_scheduled_callback, NULL);
|
2011-10-09 17:32:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
/* exported interface documented in riscos/hotlist.h */
|
|
|
|
void ro_gui_hotlist_add_cleanup(void)
|
2011-10-09 17:32:43 +04:00
|
|
|
{
|
2013-09-03 01:41:04 +04:00
|
|
|
if (hotlist_url != NULL) {
|
2016-12-26 16:22:42 +03:00
|
|
|
osmodule_free(hotlist_url);
|
|
|
|
hotlist_url = NULL;
|
2013-09-03 01:41:04 +04:00
|
|
|
}
|
2011-10-14 00:40:52 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
if (hotlist_title != NULL) {
|
|
|
|
osmodule_free(hotlist_title);
|
|
|
|
hotlist_title = NULL;
|
|
|
|
}
|
2011-10-14 00:40:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* Callback confirming a URL delete query.
|
2011-10-14 00:40:52 +04:00
|
|
|
*
|
2016-12-26 16:22:42 +03:00
|
|
|
* \param id The ID of the query calling us.
|
|
|
|
* \param res The user's response to the query.
|
|
|
|
* \param p Callback data (always NULL).
|
2011-10-14 00:40:52 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static void
|
|
|
|
ro_gui_hotlist_remove_confirmed(query_id id, enum query_response res, void *p)
|
2011-10-14 00:40:52 +04:00
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
hotlist_remove_url(hotlist_delete_url);
|
|
|
|
ro_toolbar_update_all_hotlists();
|
|
|
|
|
|
|
|
nsurl_unref(hotlist_delete_url);
|
|
|
|
hotlist_delete_url = NULL;
|
|
|
|
hotlist_query = QUERY_INVALID;
|
2011-10-09 17:32:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* 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).
|
2011-10-09 17:32:43 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static void
|
|
|
|
ro_gui_hotlist_remove_cancelled(query_id id, enum query_response res, void *p)
|
2011-10-09 17:32:43 +04:00
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
nsurl_unref(hotlist_delete_url);
|
|
|
|
hotlist_delete_url = NULL;
|
|
|
|
hotlist_query = QUERY_INVALID;
|
2011-10-09 17:32:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-30 16:36:24 +04:00
|
|
|
/**
|
2016-12-26 16:22:42 +03:00
|
|
|
* removal query dialog callbacks.
|
2013-12-30 16:36:24 +04:00
|
|
|
*/
|
2016-12-26 16:22:42 +03:00
|
|
|
static const query_callback remove_funcs = {
|
|
|
|
ro_gui_hotlist_remove_confirmed,
|
|
|
|
ro_gui_hotlist_remove_cancelled
|
|
|
|
};
|
|
|
|
|
2013-12-30 16:36:24 +04:00
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
/* exported interface documented in riscos/hotlist.h */
|
2013-12-30 16:36:24 +04:00
|
|
|
void ro_gui_hotlist_remove_page(nsurl *url)
|
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
if ((url == NULL) ||
|
|
|
|
nsoption_bool(external_hotlists) ||
|
|
|
|
!hotlist_has_url(url)) {
|
2013-12-30 16:36:24 +04:00
|
|
|
return;
|
2016-12-26 16:22:42 +03:00
|
|
|
}
|
2013-12-30 16:36:24 +04:00
|
|
|
|
2013-12-31 20:45:32 +04:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2013-12-31 20:57:47 +04:00
|
|
|
/* Check with the user before removing the URL, unless they don't
|
|
|
|
* want us to be careful in which case just do it.
|
|
|
|
*/
|
|
|
|
if (nsoption_bool(confirm_hotlist_remove)) {
|
|
|
|
hotlist_query = query_user("RemoveHotlist", NULL,
|
2016-12-26 16:22:42 +03:00
|
|
|
&remove_funcs, NULL,
|
|
|
|
messages_get("Remove"),
|
|
|
|
messages_get("DontRemove"));
|
2013-12-31 20:45:32 +04:00
|
|
|
|
2013-12-31 20:57:47 +04:00
|
|
|
hotlist_delete_url = nsurl_ref(url);
|
|
|
|
} else {
|
|
|
|
hotlist_remove_url(url);
|
|
|
|
ro_toolbar_update_all_hotlists();
|
|
|
|
}
|
2013-12-31 20:45:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-26 16:22:42 +03:00
|
|
|
/* exported interface documented in riscos/hotlist.h */
|
2013-12-30 19:41:38 +04:00
|
|
|
bool ro_gui_hotlist_has_page(nsurl *url)
|
|
|
|
{
|
2016-12-26 16:22:42 +03:00
|
|
|
if ((url == NULL) ||
|
|
|
|
nsoption_bool(external_hotlists)) {
|
2013-12-30 19:41:38 +04:00
|
|
|
return false;
|
2016-12-26 16:22:42 +03:00
|
|
|
}
|
2013-12-30 19:41:38 +04:00
|
|
|
|
|
|
|
return hotlist_has_url(url);
|
|
|
|
}
|