Restore toolbar menus in RO treeview windows.

svn path=/trunk/netsurf/; revision=10908
This commit is contained in:
Steve Fryatt 2010-10-24 23:17:21 +00:00
parent a1194cd03f
commit 3529ead319
12 changed files with 123 additions and 92 deletions

View File

@ -45,12 +45,6 @@
#include "utils/url.h"
#include "utils/utils.h"
static void ro_gui_cookies_menu_prepare(wimp_w window, wimp_menu *menu);
static bool ro_gui_cookies_menu_select(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
static void ro_gui_cookies_menu_warning(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
/* The RISC OS cookie window, toolbar and treeview data. */
static struct ro_cookies_window {
@ -160,6 +154,9 @@ void ro_gui_cookies_open(void)
bool ro_gui_cookies_toolbar_click(wimp_pointer *pointer)
{
if (pointer->buttons == wimp_CLICK_MENU)
return ro_gui_wimp_event_process_window_menu_click(pointer);
if (cookies_window.toolbar->editor != NULL) {
ro_gui_theme_toolbar_editor_click(cookies_window.toolbar,
pointer);
@ -193,13 +190,6 @@ bool ro_gui_cookies_toolbar_click(wimp_pointer *pointer)
break;
}
/* \todo -- We assume that the owning module will have attached a window menu
* to our parent window. If it hasn't, this call will quietly fail.
*/
if (pointer->buttons == wimp_CLICK_MENU)
return ro_gui_wimp_event_process_window_menu_click(pointer);
return false;
}
@ -214,24 +204,29 @@ void ro_gui_cookies_menu_prepare(wimp_w window, wimp_menu *menu)
{
bool selection;
selection = ro_treeview_has_selection(cookies_window.tv);
if (menu != cookies_window.menu && menu != tree_toolbar_menu)
return;
ro_gui_menu_set_entry_shaded(cookies_window.menu, TREE_SELECTION,
!selection);
ro_gui_menu_set_entry_shaded(cookies_window.menu, TREE_CLEAR_SELECTION,
!selection);
if (menu == cookies_window.menu) {
selection = ro_treeview_has_selection(cookies_window.tv);
ro_gui_menu_set_entry_shaded(cookies_window.menu, TOOLBAR_BUTTONS,
ro_gui_menu_set_entry_shaded(cookies_window.menu, TREE_SELECTION,
!selection);
ro_gui_menu_set_entry_shaded(cookies_window.menu, TREE_CLEAR_SELECTION,
!selection);
}
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_BUTTONS,
(cookies_window.toolbar == NULL ||
cookies_window.toolbar->editor));
ro_gui_menu_set_entry_ticked(cookies_window.menu, TOOLBAR_BUTTONS,
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_BUTTONS,
(cookies_window.toolbar != NULL &&
(cookies_window.toolbar->display_buttons ||
(cookies_window.toolbar->editor))));
ro_gui_menu_set_entry_shaded(cookies_window.menu, TOOLBAR_EDIT,
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_EDIT,
cookies_window.toolbar == NULL);
ro_gui_menu_set_entry_ticked(cookies_window.menu, TOOLBAR_EDIT,
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_EDIT,
(cookies_window.toolbar != NULL &&
cookies_window.toolbar->editor));
}

View File

@ -24,12 +24,20 @@
#ifndef _NETSURF_RISCOS_COOKIES_H_
#define _NETSURF_RISCOS_COOKIES_H_
#include "riscos/menus.h"
void ro_gui_cookies_preinitialise(void);
void ro_gui_cookies_postinitialise(void);
bool ro_gui_cookies_check_window(wimp_w window);
bool ro_gui_cookies_check_menu(wimp_menu *menu);
bool ro_gui_cookies_toolbar_click(wimp_pointer *pointer);
void ro_gui_cookies_menu_prepare(wimp_w window, wimp_menu *menu);
bool ro_gui_cookies_menu_select(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
void ro_gui_cookies_menu_warning(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
void ro_gui_cookies_open(void);
void ro_gui_cookies_update_theme(bool full_update);

View File

@ -47,12 +47,6 @@
#include "utils/url.h"
#include "utils/utils.h"
static void ro_gui_global_history_menu_prepare(wimp_w window, wimp_menu *menu);
static bool ro_gui_global_history_menu_select(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
static void ro_gui_global_history_menu_warning(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
/* The RISC OS global history window, toolbar and treeview data */
static struct ro_global_history_window {
@ -167,6 +161,9 @@ void ro_gui_global_history_open(void)
bool ro_gui_global_history_toolbar_click(wimp_pointer *pointer)
{
if (pointer->buttons == wimp_CLICK_MENU)
return ro_gui_wimp_event_process_window_menu_click(pointer);
if (global_history_window.toolbar->editor != NULL) {
ro_gui_theme_toolbar_editor_click(global_history_window.toolbar,
pointer);
@ -206,13 +203,6 @@ bool ro_gui_global_history_toolbar_click(wimp_pointer *pointer)
break;
}
/* \todo -- We assume that the owning module will have attached a window menu
* to our parent window. If it hasn't, this call will quietly fail.
*/
if (pointer->buttons == wimp_CLICK_MENU)
return ro_gui_wimp_event_process_window_menu_click(pointer);
return true;
}
@ -228,31 +218,34 @@ void ro_gui_global_history_menu_prepare(wimp_w window, wimp_menu *menu)
{
bool selection;
selection = ro_treeview_has_selection(global_history_window.tv);
if (menu != global_history_window.menu && menu != tree_toolbar_menu)
return;
ro_gui_menu_set_entry_shaded(global_history_window.menu,
TREE_SELECTION, !selection);
ro_gui_menu_set_entry_shaded(global_history_window.menu,
TREE_CLEAR_SELECTION, !selection);
if (menu == global_history_window.menu) {
selection = ro_treeview_has_selection(global_history_window.tv);
ro_gui_menu_set_entry_shaded(global_history_window.menu,
TOOLBAR_BUTTONS,
ro_gui_menu_set_entry_shaded(global_history_window.menu,
TREE_SELECTION, !selection);
ro_gui_menu_set_entry_shaded(global_history_window.menu,
TREE_CLEAR_SELECTION, !selection);
ro_gui_save_prepare(GUI_SAVE_HISTORY_EXPORT_HTML,
NULL, NULL, NULL, NULL);
}
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_BUTTONS,
(global_history_window.toolbar == NULL ||
global_history_window.toolbar->editor));
ro_gui_menu_set_entry_ticked(global_history_window.menu,
TOOLBAR_BUTTONS,
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_BUTTONS,
(global_history_window.toolbar != NULL &&
(global_history_window.toolbar->display_buttons ||
(global_history_window.toolbar->editor))));
ro_gui_menu_set_entry_shaded(global_history_window.menu, TOOLBAR_EDIT,
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_EDIT,
global_history_window.toolbar == NULL);
ro_gui_menu_set_entry_ticked(global_history_window.menu, TOOLBAR_EDIT,
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_EDIT,
(global_history_window.toolbar != NULL &&
global_history_window.toolbar->editor));
ro_gui_save_prepare(GUI_SAVE_HISTORY_EXPORT_HTML,
NULL, NULL, NULL, NULL);
}
/**

View File

@ -24,6 +24,8 @@
#ifndef _NETSURF_RISCOS_GLOBALHISTORY_H_
#define _NETSURF_RISCOS_GLOBALHISTORY_H_
#include "riscos/menus.h"
void ro_gui_global_history_preinitialise(void);
void ro_gui_global_history_postinitialise(void);
void ro_gui_global_history_open(void);
@ -33,5 +35,11 @@ bool ro_gui_global_history_check_window(wimp_w window);
bool ro_gui_global_history_check_menu(wimp_menu *menu);
bool ro_gui_global_history_toolbar_click(wimp_pointer *pointer);
void ro_gui_global_history_menu_prepare(wimp_w window, wimp_menu *menu);
bool ro_gui_global_history_menu_select(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
void ro_gui_global_history_menu_warning(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
#endif

View File

@ -987,9 +987,9 @@ void gui_poll(bool active)
gui_last_poll = clock();
ro_gui_handle_event(event, &block);
/* Only run scheduled callbacks on a null poll
* We cannot do this in the null event handler, as that may be called
* from gui_multitask(). Scheduled callbacks must only be run from the
/* Only run scheduled callbacks on a null poll
* We cannot do this in the null event handler, as that may be called
* from gui_multitask(). Scheduled callbacks must only be run from the
* top-level.
*/
if (event == wimp_NULL_REASON_CODE)
@ -1248,7 +1248,8 @@ bool ro_gui_icon_bar_click(wimp_pointer *pointer)
if (pointer->buttons == wimp_CLICK_MENU) {
ro_gui_menu_create(iconbar_menu, pointer->pos.x,
96 + iconbar_menu_height, wimp_ICON_BAR);
96 + iconbar_menu_height, wimp_ICON_BAR,
true);
} else if (pointer->buttons == wimp_CLICK_SELECT) {
if (option_homepage_url && option_homepage_url[0]) {
@ -2070,7 +2071,7 @@ char *path_to_url(const char *path)
/* create a unix path from teh cananocal risc os one */
unix_path = __unixify(canonical_path, __RISCOSIFY_NO_REVERSE_SUFFIX, NULL, 0, 0);
if (unix_path == NULL) {
LOG(("__unixify failed: %s", canonical_path));
free(canonical_path);
@ -2092,7 +2093,7 @@ char *path_to_url(const char *path)
} else {
snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, unix_path);
}
free(unix_path);
free(unix_path);
/* We don't want '/' to be escaped. */
url_err = url_escape(url, FILE_SCHEME_PREFIX_LEN, false, "/", &escurl);

View File

@ -48,12 +48,6 @@
#include "utils/utils.h"
#include "utils/url.h"
static void ro_gui_hotlist_menu_prepare(wimp_w window, wimp_menu *menu);
static bool ro_gui_hotlist_menu_select(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
static void ro_gui_hotlist_menu_warning(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
/* The RISC OS hotlist window, toolbar and treeview data. */
static struct ro_hotlist {
@ -181,6 +175,9 @@ void ro_gui_hotlist_open(void)
bool ro_gui_hotlist_toolbar_click(wimp_pointer *pointer)
{
if (pointer->buttons == wimp_CLICK_MENU)
return ro_gui_wimp_event_process_window_menu_click(pointer);
if (hotlist_window.toolbar->editor != NULL) {
ro_gui_theme_toolbar_editor_click(hotlist_window.toolbar,
pointer);
@ -226,14 +223,6 @@ bool ro_gui_hotlist_toolbar_click(wimp_pointer *pointer)
break;
}
/* \todo -- We assume that the owning module will have attached a window menu
* to our parent window. If it hasn't, this call will quietly fail.
*/
if (pointer->buttons == wimp_CLICK_MENU)
return ro_gui_wimp_event_process_window_menu_click(pointer);
return true;
}
@ -249,31 +238,37 @@ void ro_gui_hotlist_menu_prepare(wimp_w window, wimp_menu *menu)
{
bool selection;
selection = ro_treeview_has_selection(hotlist_window.tv);
if (menu != hotlist_window.menu && menu != tree_toolbar_menu)
return;
ro_gui_menu_set_entry_shaded(hotlist_window.menu, TREE_SELECTION,
!selection);
ro_gui_menu_set_entry_shaded(hotlist_window.menu, TREE_CLEAR_SELECTION,
!selection);
if (menu == hotlist_window.menu) {
selection = ro_treeview_has_selection(hotlist_window.tv);
ro_gui_menu_set_entry_shaded(hotlist_window.menu, TOOLBAR_BUTTONS,
ro_gui_menu_set_entry_shaded(hotlist_window.menu,
TREE_SELECTION, !selection);
ro_gui_menu_set_entry_shaded(hotlist_window.menu,
TREE_CLEAR_SELECTION, !selection);
ro_gui_save_prepare(GUI_SAVE_HOTLIST_EXPORT_HTML,
NULL, NULL, NULL, NULL);
}
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_BUTTONS,
(hotlist_window.toolbar == NULL ||
hotlist_window.toolbar->editor != NULL));
ro_gui_menu_set_entry_ticked(hotlist_window.menu, TOOLBAR_BUTTONS,
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_BUTTONS,
(hotlist_window.toolbar != NULL &&
(hotlist_window.toolbar->display_buttons ||
(hotlist_window.toolbar->editor != NULL))));
ro_gui_menu_set_entry_shaded(hotlist_window.menu, TOOLBAR_EDIT,
ro_gui_menu_set_entry_shaded(menu, TOOLBAR_EDIT,
hotlist_window.toolbar == NULL);
ro_gui_menu_set_entry_ticked(hotlist_window.menu, TOOLBAR_EDIT,
ro_gui_menu_set_entry_ticked(menu, TOOLBAR_EDIT,
(hotlist_window.toolbar != NULL &&
hotlist_window.toolbar->editor != NULL));
ro_gui_save_prepare(GUI_SAVE_HOTLIST_EXPORT_HTML,
NULL, NULL, NULL, NULL);
}
/**
* Handle submenu warnings for the hotlist menu
*

View File

@ -24,6 +24,8 @@
#ifndef _NETSURF_RISCOS_HOTLIST_H_
#define _NETSURF_RISCOS_HOTLIST_H_
#include "riscos/menus.h"
void ro_gui_hotlist_preinitialise(void);
void ro_gui_hotlist_postinitialise(void);
void ro_gui_hotlist_open(void);
@ -32,6 +34,11 @@ void ro_gui_hotlist_update_theme(bool full_update);
bool ro_gui_hotlist_check_window(wimp_w window);
bool ro_gui_hotlist_check_menu(wimp_menu *menu);
bool ro_gui_hotlist_toolbar_click(wimp_pointer *pointer);
void ro_gui_hotlist_menu_prepare(wimp_w window, wimp_menu *menu);
bool ro_gui_hotlist_menu_select(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
void ro_gui_hotlist_menu_warning(wimp_w window, wimp_menu *menu,
wimp_selection *selection, menu_action action);
#endif

View File

@ -301,6 +301,7 @@ void ro_gui_menu_init(void)
};
tree_toolbar_menu = ro_gui_menu_define_menu(&tree_toolbar_definition);
/* proxy menu */
static const struct ns_menu proxy_type_definition = {
"ProxyType", {
@ -375,8 +376,15 @@ void ro_gui_menu_init(void)
/**
* Display a menu.
*
* \param *menu Pointer to the menu to be displayed.
* \param x The x position.
* \param y The y position.
* \param w The window that the menu belongs to.
* \param prepare true if the menu is to be prepared; otherwise
* false (mainly for use by wimp_event module).
*/
void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w)
void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w, bool prepare)
{
struct gui_window *g;
os_error *error;
@ -442,7 +450,7 @@ void ro_gui_menu_create(wimp_menu *menu, int x, int y, wimp_w w)
} else if (menu == recent_search_menu) {
if (!ro_gui_search_prepare_menu())
return;
} else {
} else if (prepare) {
i = 0;
do {
action = ro_gui_menu_find_action(menu,
@ -499,7 +507,7 @@ void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i)
ro_gui_menu_create(menu,
state.visible.x0 + icon_state.icon.extent.x1 + 64,
state.visible.y1 + icon_state.icon.extent.y1 -
state.yscroll, w);
state.yscroll, w, true);
current_menu_icon = i;
}
@ -679,7 +687,7 @@ void ro_gui_menu_selection(wimp_selection *selection)
assert(g); /* Keep scan-build happy */
gui_create_form_select_menu(g->bw, gui_form_select_control);
} else
ro_gui_menu_create(current_menu, 0, 0, current_menu_window);
ro_gui_menu_create(current_menu, 0, 0, current_menu_window, true);
current_menu_icon = previous_menu_icon;
}
@ -989,7 +997,7 @@ void gui_create_form_select_menu(struct browser_window *bw,
gui_form_select_control = control;
ro_gui_menu_create(gui_form_select_menu,
pointer.pos.x, pointer.pos.y, bw->window->window);
pointer.pos.x, pointer.pos.y, bw->window->window, true);
}

View File

@ -170,7 +170,7 @@ struct ns_menu {
void ro_gui_menu_init(void);
void ro_gui_menu_create(wimp_menu* menu, int x, int y, wimp_w w);
void ro_gui_menu_create(wimp_menu* menu, int x, int y, wimp_w w, bool prepare);
bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
bool windows_at_pointer);
void ro_gui_menu_prepare_action(wimp_w owner, menu_action action,

View File

@ -951,16 +951,31 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor,
case THEME_HOTLIST_EDIT_TOOLBAR:
ro_gui_wimp_event_register_mouse_click(toolbar->toolbar_handle,
ro_gui_hotlist_toolbar_click);
ro_gui_wimp_event_register_window_menu(toolbar->toolbar_handle,
tree_toolbar_menu,
ro_gui_hotlist_menu_prepare,
ro_gui_hotlist_menu_select, NULL,
ro_gui_hotlist_menu_warning, false);
break;
case THEME_HISTORY_TOOLBAR:
case THEME_HISTORY_EDIT_TOOLBAR:
ro_gui_wimp_event_register_mouse_click(toolbar->toolbar_handle,
ro_gui_global_history_toolbar_click);
ro_gui_wimp_event_register_window_menu(toolbar->toolbar_handle,
tree_toolbar_menu,
ro_gui_global_history_menu_prepare,
ro_gui_global_history_menu_select, NULL,
ro_gui_global_history_menu_warning, false);
break;
case THEME_COOKIES_TOOLBAR:
case THEME_COOKIES_EDIT_TOOLBAR:
ro_gui_wimp_event_register_mouse_click(toolbar->toolbar_handle,
ro_gui_cookies_toolbar_click);
ro_gui_wimp_event_register_window_menu(toolbar->toolbar_handle,
tree_toolbar_menu,
ro_gui_cookies_menu_prepare,
ro_gui_cookies_menu_select, NULL,
ro_gui_cookies_menu_warning, false);
break;
default:
break;

View File

@ -985,7 +985,8 @@ bool ro_gui_wimp_event_process_window_menu_click(wimp_pointer *pointer)
window->window_menu);
ro_gui_menu_create(window->window_menu,
pointer->pos.x, pointer->pos.y, window->w);
pointer->pos.x, pointer->pos.y,
window->w, false);
return true;
}
return false;

View File

@ -593,7 +593,7 @@ void gui_window_update_box(struct gui_window *g,
y0 = -ceilf((data->redraw.y + data->redraw.height) * 2 * g->bw->scale);
x1 = ceilf((data->redraw.x + data->redraw.width) * 2 * g->bw->scale) + 1;
y1 = -floorf(data->redraw.y * 2 * g->bw->scale) + 1;
use_buffer =
use_buffer =
(g->option.buffer_everything || g->option.buffer_animations);
/* try to optimise buffered redraws */
@ -1398,7 +1398,7 @@ bool gui_window_frame_resize_start(struct gui_window *g)
* \param g gui_window containing the content
* \param c the content to save
*/
void gui_window_save_link(struct gui_window *g, const char *url,
void gui_window_save_link(struct gui_window *g, const char *url,
const char *title)
{
ro_gui_save_prepare(GUI_SAVE_LINK_URL, NULL, NULL, url, title);
@ -2148,7 +2148,7 @@ bool ro_gui_toolbar_click(wimp_pointer *pointer)
/* Handle Menu clicks */
if (pointer->buttons == wimp_CLICK_MENU) {
ro_gui_menu_create(browser_toolbar_menu, pointer->pos.x,
pointer->pos.y, g->window);
pointer->pos.y, g->window, true);
return true;
}
@ -2317,7 +2317,7 @@ bool ro_gui_window_click(wimp_pointer *pointer)
gui_window_place_caret(g, -100, -100, 0);
if (pointer->buttons == wimp_CLICK_MENU) {
ro_gui_menu_create(browser_menu, pointer->pos.x, pointer->pos.y, pointer->w);
ro_gui_menu_create(browser_menu, pointer->pos.x, pointer->pos.y, pointer->w, true);
} else {
if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos))
browser_window_mouse_click(g->bw,