2005-02-07 17:28:43 +03:00
|
|
|
/*
|
2010-10-05 23:14:46 +04:00
|
|
|
* Copyright 2010 Stephen Fryatt <stevef@netsurf-browser.org>
|
2016-12-27 14:45:18 +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/>.
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
|
|
|
|
2016-06-10 13:53:28 +03:00
|
|
|
/**
|
|
|
|
* \file
|
2016-12-27 14:45:18 +03:00
|
|
|
* Implementation of RISC OS global history.
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
#include <stdint.h>
|
2005-02-07 17:28:43 +03:00
|
|
|
#include <stdlib.h>
|
2016-12-27 14:45:18 +03:00
|
|
|
#include <oslib/wimp.h>
|
2014-10-16 12:50:55 +04:00
|
|
|
|
|
|
|
#include "utils/nsoption.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/log.h"
|
2016-06-30 17:40:10 +03:00
|
|
|
#include "netsurf/window.h"
|
2016-12-27 14:45:18 +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/global_history.h"
|
2014-10-16 12:50:55 +04:00
|
|
|
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/dialog.h"
|
|
|
|
#include "riscos/gui.h"
|
|
|
|
#include "riscos/menus.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"
|
2016-12-27 14:45:18 +03:00
|
|
|
#include "riscos/corewindow.h"
|
|
|
|
#include "riscos/global_history.h"
|
2005-02-07 17:28:43 +03:00
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
struct ro_global_history_window {
|
|
|
|
struct ro_corewindow core;
|
|
|
|
wimp_menu *menu;
|
2011-02-21 02:16:33 +03:00
|
|
|
};
|
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
/** global_history window is a singleton */
|
|
|
|
static struct ro_global_history_window *global_history_window = NULL;
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
/** riscos template for global_history window */
|
|
|
|
static wimp_window *dialog_global_history_template;
|
2005-02-07 17:28:43 +03:00
|
|
|
|
|
|
|
|
2005-02-09 02:37:41 +03:00
|
|
|
/**
|
2016-12-27 14:45:18 +03:00
|
|
|
* callback to draw on drawable area of ro global_history 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
|
2005-02-09 02:37:41 +03:00
|
|
|
*/
|
2016-12-27 14:45:18 +03:00
|
|
|
static nserror
|
|
|
|
global_history_draw(struct ro_corewindow *ro_cw,
|
|
|
|
int originx,
|
|
|
|
int originy,
|
|
|
|
struct rect *r)
|
2010-10-05 23:14:46 +04:00
|
|
|
{
|
2016-12-27 14:45:18 +03:00
|
|
|
struct redraw_context ctx = {
|
|
|
|
.interactive = true,
|
|
|
|
.background_images = true,
|
|
|
|
.plot = &ro_plotters
|
|
|
|
};
|
2011-02-21 02:16:33 +03:00
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
ro_plot_origin_x = originx;
|
|
|
|
ro_plot_origin_y = originy;
|
|
|
|
no_font_blending = true;
|
|
|
|
global_history_redraw(0, 0, r, &ctx);
|
|
|
|
no_font_blending = false;
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
return NSERROR_OK;
|
2005-02-09 02:37:41 +03:00
|
|
|
}
|
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2013-09-08 22:04:45 +04:00
|
|
|
/**
|
2016-12-27 14:45:18 +03:00
|
|
|
* callback for keypress on ro coookie 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-27 14:45:18 +03:00
|
|
|
static nserror global_history_key(struct ro_corewindow *ro_cw, uint32_t nskey)
|
2013-09-08 22:04:45 +04:00
|
|
|
{
|
2016-12-27 14:45:18 +03:00
|
|
|
if (global_history_keypress(nskey)) {
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
return NSERROR_NOT_IMPLEMENTED;
|
2013-09-08 22:04:45 +04:00
|
|
|
}
|
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
/**
|
2016-12-27 14:45:18 +03:00
|
|
|
* callback for mouse event on ro global_history window
|
|
|
|
*
|
|
|
|
* \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.
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
2016-12-27 14:45:18 +03:00
|
|
|
static nserror
|
|
|
|
global_history_mouse(struct ro_corewindow *ro_cw,
|
|
|
|
browser_mouse_state mouse_state,
|
|
|
|
int x, int y)
|
2006-04-10 03:21:13 +04:00
|
|
|
{
|
2016-12-27 14:45:18 +03:00
|
|
|
global_history_mouse_action(mouse_state, x, y);
|
2011-02-21 02:16:33 +03:00
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
return NSERROR_OK;
|
2005-03-13 01:32:43 +03:00
|
|
|
}
|
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-25 00:00:45 +04:00
|
|
|
/**
|
2016-12-27 14:45:18 +03:00
|
|
|
* handle clicks in ro core window toolbar.
|
2010-10-25 00:00:45 +04:00
|
|
|
*
|
2016-12-27 14:45:18 +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-27 14:45:18 +03:00
|
|
|
static nserror
|
|
|
|
global_history_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
|
|
|
global_history_keypress(NS_KEY_DELETE_LEFT);
|
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
|
|
|
global_history_expand(false);
|
2011-02-21 02:16:33 +03:00
|
|
|
break;
|
2010-10-25 01:52:16 +04:00
|
|
|
|
2011-02-21 02:16:33 +03:00
|
|
|
case TOOLBAR_BUTTON_COLLAPSE:
|
2013-09-03 15:36:55 +04:00
|
|
|
global_history_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
|
|
|
global_history_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
|
|
|
global_history_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
|
|
|
global_history_keypress(NS_KEY_CR);
|
2011-02-21 02:16:33 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-10-25 00:00:45 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-12-27 14:45:18 +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-27 14:45:18 +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-27 14:45:18 +03:00
|
|
|
static nserror global_history_toolbar_update(struct ro_corewindow *ro_cw)
|
2011-02-21 02:16:33 +03:00
|
|
|
{
|
2016-12-27 14:45:18 +03:00
|
|
|
ro_toolbar_set_button_shaded_state(ro_cw->toolbar,
|
2011-02-21 02:16:33 +03:00
|
|
|
TOOLBAR_BUTTON_DELETE,
|
2013-09-02 19:19:16 +04:00
|
|
|
!global_history_has_selection());
|
2011-02-21 02:16:33 +03:00
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
ro_toolbar_set_button_shaded_state(ro_cw->toolbar,
|
2011-02-21 02:16:33 +03:00
|
|
|
TOOLBAR_BUTTON_LAUNCH,
|
2013-09-02 19:19:16 +04:00
|
|
|
!global_history_has_selection());
|
2016-12-27 14:45:18 +03:00
|
|
|
return NSERROR_OK;
|
2011-02-21 02:16:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-12-27 14:45:18 +03:00
|
|
|
* callback for saving of toolbar state in ro global history window
|
2011-02-21 02:16:33 +03:00
|
|
|
*
|
2016-12-27 14:45:18 +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-27 14:45:18 +03:00
|
|
|
static nserror
|
|
|
|
global_history_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_history, config);
|
2011-02-21 02:16:33 +03:00
|
|
|
ro_gui_save_options();
|
2016-12-27 14:45:18 +03:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
2010-10-25 00:00:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
/**
|
2016-12-27 14:45:18 +03:00
|
|
|
* Prepare the global_history menu for display
|
2005-02-07 17:28:43 +03:00
|
|
|
*
|
2016-12-27 14:45:18 +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.
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
2016-12-27 14:45:18 +03:00
|
|
|
static bool
|
|
|
|
global_history_menu_prepare(wimp_w w,
|
|
|
|
wimp_i i,
|
|
|
|
wimp_menu *menu,
|
|
|
|
wimp_pointer *pointer)
|
2006-04-10 03:21:13 +04:00
|
|
|
{
|
2010-10-05 23:14:46 +04:00
|
|
|
bool selection;
|
2016-12-27 14:45:18 +03:00
|
|
|
struct ro_global_history_window *global_historyw;
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
global_historyw = (struct ro_global_history_window *)ro_gui_wimp_event_get_user_data(w);
|
|
|
|
|
|
|
|
if ((global_historyw == NULL) ||
|
|
|
|
(menu != global_historyw->menu)) {
|
2011-02-21 02:16:33 +03:00
|
|
|
return false;
|
2016-12-27 14:45:18 +03:00
|
|
|
}
|
2010-10-25 03:17:21 +04:00
|
|
|
|
2013-09-02 19:19:16 +04:00
|
|
|
selection = global_history_has_selection();
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2016-12-27 14:45:18 +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_HISTORY_EXPORT_HTML,
|
2016-12-27 14:45:18 +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-27 14:45:18 +03:00
|
|
|
ro_toolbar_menu_option_shade(global_historyw->core.toolbar));
|
2010-10-25 03:17:21 +04:00
|
|
|
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_BUTTONS,
|
2016-12-27 14:45:18 +03:00
|
|
|
ro_toolbar_menu_buttons_tick(global_historyw->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-27 14:45:18 +03:00
|
|
|
ro_toolbar_menu_edit_shade(global_historyw->core.toolbar));
|
2010-10-25 03:17:21 +04:00
|
|
|
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_EDIT,
|
2016-12-27 14:45:18 +03:00
|
|
|
ro_toolbar_menu_edit_tick(global_historyw->core.toolbar));
|
2011-02-21 02:16:33 +03:00
|
|
|
|
|
|
|
return true;
|
2005-02-07 17:28:43 +03:00
|
|
|
}
|
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
/**
|
2016-12-27 14:45:18 +03:00
|
|
|
* Handle submenu warnings for the global_history menu
|
2006-04-10 03:21:13 +04:00
|
|
|
*
|
2016-12-27 14:45:18 +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.
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
2016-12-27 14:45:18 +03:00
|
|
|
static void
|
|
|
|
global_history_menu_warning(wimp_w w,
|
|
|
|
wimp_i i,
|
|
|
|
wimp_menu *menu,
|
|
|
|
wimp_selection *selection,
|
|
|
|
menu_action action)
|
2010-10-05 23:14:46 +04:00
|
|
|
{
|
|
|
|
/* Do nothing */
|
2006-04-11 06:39:55 +04:00
|
|
|
}
|
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2006-04-11 06:39:55 +04:00
|
|
|
/**
|
2016-12-27 14:45:18 +03:00
|
|
|
* Handle selections from the global_history menu
|
2006-04-11 06:39:55 +04:00
|
|
|
*
|
2016-12-27 14:45:18 +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.
|
2006-04-11 06:39:55 +04:00
|
|
|
*/
|
2016-12-27 14:45:18 +03:00
|
|
|
static bool
|
|
|
|
global_history_menu_select(wimp_w w,
|
|
|
|
wimp_i i,
|
|
|
|
wimp_menu *menu,
|
|
|
|
wimp_selection *selection,
|
|
|
|
menu_action action)
|
2010-10-05 23:14:46 +04:00
|
|
|
{
|
2016-12-27 14:45:18 +03:00
|
|
|
struct ro_global_history_window *global_historyw;
|
|
|
|
|
|
|
|
global_historyw = (struct ro_global_history_window *)ro_gui_wimp_event_get_user_data(w);
|
|
|
|
|
|
|
|
if ((global_historyw == NULL) ||
|
|
|
|
(menu != global_historyw->menu)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
switch (action) {
|
|
|
|
case HISTORY_EXPORT:
|
2011-02-21 02:16:33 +03:00
|
|
|
ro_gui_dialog_open_persistent(w, dialog_saveas, true);
|
2006-04-11 06:39:55 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_EXPAND_ALL:
|
2013-09-03 15:36:55 +04:00
|
|
|
global_history_expand(false);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_EXPAND_FOLDERS:
|
2013-09-03 15:36:55 +04:00
|
|
|
global_history_expand(true);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_EXPAND_LINKS:
|
2013-09-03 15:36:55 +04:00
|
|
|
global_history_expand(false);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_COLLAPSE_ALL:
|
2013-09-03 15:36:55 +04:00
|
|
|
global_history_contract(true);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_COLLAPSE_FOLDERS:
|
2013-09-03 15:36:55 +04:00
|
|
|
global_history_contract(true);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_COLLAPSE_LINKS:
|
2013-09-03 15:36:55 +04:00
|
|
|
global_history_contract(false);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_SELECTION_LAUNCH:
|
2015-03-27 12:36:19 +03:00
|
|
|
global_history_keypress(NS_KEY_CR);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_SELECTION_DELETE:
|
2015-03-27 12:36:19 +03:00
|
|
|
global_history_keypress(NS_KEY_DELETE_LEFT);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_SELECT_ALL:
|
2015-03-27 12:36:19 +03:00
|
|
|
global_history_keypress(NS_KEY_SELECT_ALL);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
case TREE_CLEAR_SELECTION:
|
2015-03-27 12:36:19 +03:00
|
|
|
global_history_keypress(NS_KEY_CLEAR_SELECTION);
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-25 01:52:16 +04:00
|
|
|
case TOOLBAR_BUTTONS:
|
2016-12-27 14:45:18 +03:00
|
|
|
ro_toolbar_set_display_buttons(global_historyw->core.toolbar,
|
|
|
|
!ro_toolbar_get_display_buttons(global_historyw->core.toolbar));
|
2010-10-25 01:52:16 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-25 01:52:16 +04:00
|
|
|
case TOOLBAR_EDIT:
|
2016-12-27 14:45:18 +03:00
|
|
|
ro_toolbar_toggle_edit(global_historyw->core.toolbar);
|
2010-10-25 01:52:16 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
default:
|
|
|
|
return false;
|
2005-12-31 07:36:24 +03:00
|
|
|
}
|
2006-04-11 06:39:55 +04:00
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
return false;
|
2005-12-31 07:36:24 +03:00
|
|
|
}
|
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
/**
|
2016-12-27 14:45:18 +03:00
|
|
|
* Creates the window for the global_history tree.
|
2005-02-07 17:28:43 +03:00
|
|
|
*
|
2016-12-27 14:45:18 +03:00
|
|
|
* \return NSERROR_OK on success else appropriate error code on faliure.
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
2016-12-27 14:45:18 +03:00
|
|
|
static nserror ro_global_history_init(void)
|
|
|
|
{
|
|
|
|
struct ro_global_history_window *ncwin;
|
|
|
|
nserror res;
|
|
|
|
static const struct ns_menu global_history_menu_def = {
|
|
|
|
"History", {
|
|
|
|
{ "History", NO_ACTION, 0 },
|
|
|
|
{ "_History.Export", HISTORY_EXPORT, &dialog_saveas },
|
|
|
|
{ "History.Expand", TREE_EXPAND_ALL, 0 },
|
|
|
|
{ "History.Expand.All", TREE_EXPAND_ALL, 0 },
|
|
|
|
{ "History.Expand.Folders", TREE_EXPAND_FOLDERS, 0 },
|
|
|
|
{ "History.Expand.Links", TREE_EXPAND_LINKS, 0 },
|
|
|
|
{ "History.Collapse", TREE_COLLAPSE_ALL, 0 },
|
|
|
|
{ "History.Collapse.All", TREE_COLLAPSE_ALL, 0 },
|
|
|
|
{ "History.Collapse.Folders", TREE_COLLAPSE_FOLDERS, 0 },
|
|
|
|
{ "History.Collapse.Links", TREE_COLLAPSE_LINKS, 0 },
|
|
|
|
{ "History.Toolbars", NO_ACTION, 0 },
|
|
|
|
{ "_History.Toolbars.ToolButtons", TOOLBAR_BUTTONS, 0 },
|
|
|
|
{ "History.Toolbars.EditToolbar",TOOLBAR_EDIT, 0 },
|
|
|
|
{ "Selection", TREE_SELECTION, 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 global_history_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"},
|
|
|
|
{ NULL, TOOLBAR_BUTTON_NONE, TOOLBAR_BUTTON_NONE, '\0', ""}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (global_history_window != NULL) {
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2017-06-11 12:10:25 +03:00
|
|
|
ncwin = calloc(1, sizeof(*ncwin));
|
2016-12-27 14:45:18 +03:00
|
|
|
if (ncwin == NULL) {
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create window from template */
|
|
|
|
ncwin->core.wh = wimp_create_window(dialog_global_history_template);
|
|
|
|
|
|
|
|
ro_gui_set_window_title(ncwin->core.wh, messages_get("GlobalHistory"));
|
|
|
|
|
|
|
|
/* initialise callbacks */
|
|
|
|
ncwin->core.draw = global_history_draw;
|
|
|
|
ncwin->core.key = global_history_key;
|
|
|
|
ncwin->core.mouse = global_history_mouse;
|
|
|
|
ncwin->core.toolbar_click = global_history_toolbar_click;
|
|
|
|
ncwin->core.toolbar_save = global_history_toolbar_save;
|
|
|
|
/* update is not valid untill global history is initialised */
|
|
|
|
ncwin->core.toolbar_update = NULL;
|
|
|
|
|
|
|
|
/* initialise core window */
|
|
|
|
res = ro_corewindow_init(&ncwin->core,
|
|
|
|
global_history_toolbar_buttons,
|
|
|
|
nsoption_charp(toolbar_history),
|
|
|
|
THEME_STYLE_GLOBAL_HISTORY_TOOLBAR,
|
|
|
|
"HelpGHistoryToolbar");
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
free(ncwin);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = global_history_init(ncwin->core.cb_table,
|
|
|
|
(struct core_window *)ncwin);
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
free(ncwin);
|
|
|
|
return res;
|
|
|
|
}
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
/* setup toolbar update post global_history manager initialisation */
|
|
|
|
ncwin->core.toolbar_update = global_history_toolbar_update;
|
|
|
|
global_history_toolbar_update(&ncwin->core);
|
|
|
|
|
|
|
|
/* Build the global_history window menu. */
|
|
|
|
ncwin->menu = ro_gui_menu_define_menu(&global_history_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,
|
|
|
|
global_history_menu_prepare);
|
|
|
|
ro_gui_wimp_event_register_menu_selection(ncwin->core.wh,
|
|
|
|
global_history_menu_select);
|
|
|
|
ro_gui_wimp_event_register_menu_warning(ncwin->core.wh,
|
|
|
|
global_history_menu_warning);
|
|
|
|
|
|
|
|
/* memoise window so it can be represented when necessary
|
|
|
|
* instead of recreating every time.
|
|
|
|
*/
|
|
|
|
global_history_window = ncwin;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in riscos/global_history.h */
|
|
|
|
nserror ro_gui_global_history_present(void)
|
2010-10-05 23:14:46 +04:00
|
|
|
{
|
2016-12-27 14:45:18 +03:00
|
|
|
nserror res;
|
|
|
|
|
|
|
|
res = ro_global_history_init();
|
|
|
|
if (res == NSERROR_OK) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Presenting");
|
2016-12-27 14:45:18 +03:00
|
|
|
ro_gui_dialog_open_top(global_history_window->core.wh,
|
|
|
|
global_history_window->core.toolbar,
|
|
|
|
600, 800);
|
|
|
|
} else {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Failed presenting code %d", res);
|
2016-12-27 14:45:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in riscos/global_history.h */
|
|
|
|
void ro_gui_global_history_initialise(void)
|
|
|
|
{
|
|
|
|
dialog_global_history_template = ro_gui_dialog_load_template("tree");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in riscos/global_history.h */
|
|
|
|
nserror ro_gui_global_history_finalise(void)
|
|
|
|
{
|
|
|
|
nserror res;
|
|
|
|
|
|
|
|
if (global_history_window == NULL) {
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = global_history_fini();
|
|
|
|
if (res == NSERROR_OK) {
|
|
|
|
res = ro_corewindow_fini(&global_history_window->core);
|
|
|
|
|
|
|
|
free(global_history_window);
|
|
|
|
global_history_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* exported interface documented in riscos/global_history.h */
|
|
|
|
bool ro_gui_global_history_check_window(wimp_w wh)
|
|
|
|
{
|
|
|
|
if ((global_history_window != NULL) &&
|
|
|
|
(global_history_window->core.wh == wh)) {
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
}
|
|
|
|
return false;
|
2005-02-07 17:28:43 +03:00
|
|
|
}
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2016-12-27 14:45:18 +03:00
|
|
|
/* exported interface documented in riscos/global_history.h */
|
2010-10-05 23:14:46 +04:00
|
|
|
bool ro_gui_global_history_check_menu(wimp_menu *menu)
|
2006-04-10 03:21:13 +04:00
|
|
|
{
|
2016-12-27 14:45:18 +03:00
|
|
|
if ((global_history_window != NULL) &&
|
|
|
|
(global_history_window->menu == menu)) {
|
2010-10-05 23:14:46 +04:00
|
|
|
return true;
|
2016-12-27 14:45:18 +03:00
|
|
|
}
|
|
|
|
return false;
|
2005-02-07 17:28:43 +03:00
|
|
|
}
|