Re-enable toolbar editing and button selection in RO treeview windows.

svn path=/trunk/netsurf/; revision=10907
This commit is contained in:
Steve Fryatt 2010-10-24 21:52:16 +00:00
parent ba197f29c7
commit a1194cd03f
11 changed files with 123 additions and 67 deletions

View File

@ -160,6 +160,12 @@ void ro_gui_cookies_open(void)
bool ro_gui_cookies_toolbar_click(wimp_pointer *pointer)
{
if (cookies_window.toolbar->editor != NULL) {
ro_gui_theme_toolbar_editor_click(cookies_window.toolbar,
pointer);
return true;
}
switch (pointer->i) {
case ICON_TOOLBAR_DELETE:
if (pointer->buttons == wimp_CLICK_SELECT) {
@ -286,6 +292,14 @@ bool ro_gui_cookies_menu_select(wimp_w window, wimp_menu *menu,
case TREE_CLEAR_SELECTION:
cookies_clear_selection();
return true;
case TOOLBAR_BUTTONS:
cookies_window.toolbar->display_buttons =
!cookies_window.toolbar->display_buttons;
ro_gui_theme_refresh_toolbar(cookies_window.toolbar);
return true;
case TOOLBAR_EDIT:
ro_gui_theme_toggle_edit(cookies_window.toolbar);
return true;
default:
return false;
}
@ -295,11 +309,17 @@ bool ro_gui_cookies_menu_select(wimp_w window, wimp_menu *menu,
/**
* Update the theme details of the cookies window.
*
* \param full_update true to force a full theme change; false to
* refresh the toolbar size.
*/
void ro_gui_cookies_update_theme(void)
void ro_gui_cookies_update_theme(bool full_update)
{
ro_treeview_update_theme(cookies_window.tv);
if (full_update)
ro_treeview_update_theme(cookies_window.tv);
else
ro_treeview_update_toolbar(cookies_window.tv);
}
/**
@ -311,9 +331,9 @@ void ro_gui_cookies_update_theme(void)
bool ro_gui_cookies_check_window(wimp_w window)
{
/* SF if (cookies_window.w == window)
if (cookies_window.window == window)
return true;
else*/
else
return false;
}

View File

@ -31,7 +31,7 @@ bool ro_gui_cookies_check_menu(wimp_menu *menu);
bool ro_gui_cookies_toolbar_click(wimp_pointer *pointer);
void ro_gui_cookies_open(void);
void ro_gui_cookies_update_theme(void);
void ro_gui_cookies_update_theme(bool full_update);
#endif

View File

@ -167,6 +167,12 @@ void ro_gui_global_history_open(void)
bool ro_gui_global_history_toolbar_click(wimp_pointer *pointer)
{
if (global_history_window.toolbar->editor != NULL) {
ro_gui_theme_toolbar_editor_click(global_history_window.toolbar,
pointer);
return true;
}
switch (pointer->i) {
case ICON_TOOLBAR_DELETE:
if (pointer->buttons == wimp_CLICK_SELECT) {
@ -311,6 +317,14 @@ bool ro_gui_global_history_menu_select(wimp_w window, wimp_menu *menu,
case TREE_CLEAR_SELECTION:
history_global_clear_selection();
return true;
case TOOLBAR_BUTTONS:
global_history_window.toolbar->display_buttons =
!global_history_window.toolbar->display_buttons;
ro_gui_theme_refresh_toolbar(global_history_window.toolbar);
return true;
case TOOLBAR_EDIT:
ro_gui_theme_toggle_edit(global_history_window.toolbar);
return true;
default:
return false;
}
@ -320,11 +334,17 @@ bool ro_gui_global_history_menu_select(wimp_w window, wimp_menu *menu,
/**
* Update the theme details of the global history window.
*
* \param full_update true to force a full theme change; false to
* refresh the toolbar size.
*/
void ro_gui_global_history_update_theme(void)
void ro_gui_global_history_update_theme(bool full_update)
{
ro_treeview_update_theme(global_history_window.tv);
if (full_update)
ro_treeview_update_theme(global_history_window.tv);
else
ro_treeview_update_toolbar(global_history_window.tv);
}
/**
@ -336,9 +356,9 @@ void ro_gui_global_history_update_theme(void)
bool ro_gui_global_history_check_window(wimp_w window)
{
/* if (global_history_window.w == window)
if (global_history_window.window == window)
return true;
else*/
else
return false;
}

View File

@ -28,7 +28,7 @@ void ro_gui_global_history_preinitialise(void);
void ro_gui_global_history_postinitialise(void);
void ro_gui_global_history_open(void);
void ro_gui_global_history_save(void);
void ro_gui_global_history_update_theme(void);
void ro_gui_global_history_update_theme(bool full_update);
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);

View File

@ -181,7 +181,11 @@ void ro_gui_hotlist_open(void)
bool ro_gui_hotlist_toolbar_click(wimp_pointer *pointer)
{
LOG(("Entering hotlist toolbar handler: b=%d, i=%d", pointer->buttons, pointer->i));
if (hotlist_window.toolbar->editor != NULL) {
ro_gui_theme_toolbar_editor_click(hotlist_window.toolbar,
pointer);
return true;
}
switch (pointer->i) {
case ICON_TOOLBAR_DELETE:
@ -254,17 +258,17 @@ void ro_gui_hotlist_menu_prepare(wimp_w window, wimp_menu *menu)
ro_gui_menu_set_entry_shaded(hotlist_window.menu, TOOLBAR_BUTTONS,
(hotlist_window.toolbar == NULL ||
hotlist_window.toolbar->editor));
hotlist_window.toolbar->editor != NULL));
ro_gui_menu_set_entry_ticked(hotlist_window.menu, TOOLBAR_BUTTONS,
(hotlist_window.toolbar != NULL &&
(hotlist_window.toolbar->display_buttons ||
hotlist_window.toolbar->editor)));
(hotlist_window.toolbar->editor != NULL))));
ro_gui_menu_set_entry_shaded(hotlist_window.menu, TOOLBAR_EDIT,
hotlist_window.toolbar == NULL);
ro_gui_menu_set_entry_ticked(hotlist_window.menu, TOOLBAR_EDIT,
(hotlist_window.toolbar != NULL &&
hotlist_window.toolbar->editor));
hotlist_window.toolbar->editor != NULL));
ro_gui_save_prepare(GUI_SAVE_HOTLIST_EXPORT_HTML,
NULL, NULL, NULL, NULL);
@ -341,6 +345,14 @@ bool ro_gui_hotlist_menu_select(wimp_w window, wimp_menu *menu,
case TREE_CLEAR_SELECTION:
hotlist_clear_selection();
return true;
case TOOLBAR_BUTTONS:
hotlist_window.toolbar->display_buttons =
!hotlist_window.toolbar->display_buttons;
ro_gui_theme_refresh_toolbar(hotlist_window.toolbar);
return true;
case TOOLBAR_EDIT:
ro_gui_theme_toggle_edit(hotlist_window.toolbar);
return true;
default:
return false;
}
@ -350,11 +362,17 @@ bool ro_gui_hotlist_menu_select(wimp_w window, wimp_menu *menu,
/**
* Update the theme details of the hotlist window.
*
* \param full_update true to force a full theme change; false to
* refresh the toolbar size.
*/
void ro_gui_hotlist_update_theme(void)
void ro_gui_hotlist_update_theme(bool full_update)
{
ro_treeview_update_theme(hotlist_window.tv);
if (full_update)
ro_treeview_update_theme(hotlist_window.tv);
else
ro_treeview_update_toolbar(hotlist_window.tv);
}
/**

View File

@ -28,7 +28,7 @@ void ro_gui_hotlist_preinitialise(void);
void ro_gui_hotlist_postinitialise(void);
void ro_gui_hotlist_open(void);
void ro_gui_hotlist_save(void);
void ro_gui_hotlist_update_theme(void);
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);

View File

@ -101,7 +101,6 @@ static int ro_gui_menu_get_checksum(void);
static void ro_gui_menu_prepare_pageinfo(struct gui_window *g);
static void ro_gui_menu_prepare_objectinfo(hlcache_handle *object,
const char *href);
static void ro_gui_menu_refresh_toolbar(struct toolbar *toolbar);
static bool ro_gui_menu_translate(struct menu_definition *menu);
@ -755,44 +754,6 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning)
}
/**
* Refresh a toolbar after it has been updated
*
* \param toolbar the toolbar to update
*/
void ro_gui_menu_refresh_toolbar(struct toolbar *toolbar)
{
// struct treeview_window *treeview_window;
assert(toolbar);
toolbar->reformat_buttons = true;
ro_gui_theme_process_toolbar(toolbar, -1);
if (toolbar->type == THEME_BROWSER_TOOLBAR) {
gui_window_update_extent(ro_gui_window_lookup(
current_menu_window));
// } else if (toolbar->type == THEME_HOTLIST_TOOLBAR) {
// treeview_window = ro_gui_hotlist_get();
// /* TODO: FIX THIS */
// /* tree_resized(treeview_window->tree); */
// xwimp_force_redraw(treeview_window->window,
// 0,-16384, 16384, 16384);
// } else if (toolbar->type == THEME_HISTORY_TOOLBAR) {
// treeview_window = ro_gui_global_history_get();
// /* TODO: FIX THIS */
// /* tree_resized(treeview_window->tree); */
// xwimp_force_redraw(treeview_window->window,
// 0,-16384, 16384, 16384);
// } else if (toolbar->type == THEME_COOKIES_TOOLBAR) {
// treeview_window = ro_gui_cookies_get();
// /* TODO: FIX THIS */
// /* tree_resized(treeview_window->tree); */
// xwimp_force_redraw(treeview_window->window,
// 0,-16384, 16384, 16384);
}
}
/**
* Update navigate menu status and toolbar icons.
*
@ -896,7 +857,7 @@ void ro_gui_menu_prepare_objectinfo(hlcache_handle *object, const char *href)
mime = content_get_mime_type(object);
if (mime == NULL)
mime = "-";
if (href)
target = href;
@ -1688,19 +1649,19 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
case TOOLBAR_BUTTONS:
assert(t);
t->display_buttons = !t->display_buttons;
ro_gui_menu_refresh_toolbar(t);
ro_gui_theme_refresh_toolbar(t);
return true;
case TOOLBAR_ADDRESS_BAR:
assert(t);
t->display_url = !t->display_url;
ro_gui_menu_refresh_toolbar(t);
ro_gui_theme_refresh_toolbar(t);
if (t->display_url)
ro_gui_set_caret_first(t->toolbar_handle);
return true;
case TOOLBAR_THROBBER:
assert(t);
t->display_throbber = !t->display_throbber;
ro_gui_menu_refresh_toolbar(t);
ro_gui_theme_refresh_toolbar(t);
return true;
case TOOLBAR_EDIT:
assert(t);

View File

@ -588,9 +588,9 @@ bool ro_gui_theme_apply(struct theme_descriptor *descriptor)
/* apply the theme to all the current windows */
ro_gui_window_update_theme();
ro_gui_cookies_update_theme();
ro_gui_global_history_update_theme();
ro_gui_hotlist_update_theme();
ro_gui_cookies_update_theme(true);
ro_gui_global_history_update_theme(true);
ro_gui_hotlist_update_theme(true);
ro_gui_theme_close(theme_previous, false);
return true;
}
@ -1599,6 +1599,30 @@ void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar)
}
/**
* Refresh a toolbar after it has been updated
*
* \param toolbar the toolbar to update
*/
void ro_gui_theme_refresh_toolbar(struct toolbar *toolbar)
{
assert(toolbar);
toolbar->reformat_buttons = true;
ro_gui_theme_process_toolbar(toolbar, -1);
if (toolbar->type == THEME_BROWSER_TOOLBAR) {
gui_window_update_extent(ro_gui_window_lookup(
current_menu_window));
} else if (toolbar->type == THEME_HOTLIST_TOOLBAR) {
ro_gui_hotlist_update_theme(false);
} else if (toolbar->type == THEME_HISTORY_TOOLBAR) {
ro_gui_global_history_update_theme(false);
} else if (toolbar->type == THEME_COOKIES_TOOLBAR) {
ro_gui_cookies_update_theme(false);
}
}
/**
* Toggles the toolbar editing mode
*

View File

@ -163,6 +163,7 @@ bool ro_gui_theme_update_toolbar(struct theme_descriptor *descriptor, struct too
bool ro_gui_theme_attach_toolbar(struct toolbar *toolbar, wimp_w parent);
bool ro_gui_theme_process_toolbar(struct toolbar *toolbar, int width);
void ro_gui_theme_destroy_toolbar(struct toolbar *toolbar);
void ro_gui_theme_refresh_toolbar(struct toolbar *toolbar);
void ro_gui_theme_toggle_edit(struct toolbar *toolbar);
void ro_gui_theme_toolbar_editor_sync(struct toolbar *toolbar);

View File

@ -933,14 +933,25 @@ void ro_treeview_update_theme(ro_treeview *tv)
/* \todo -- Check for toolbar editing here. */
ro_gui_theme_attach_toolbar(tv->tb, tv->w);
ro_treeview_set_origin(tv, 0,
-(ro_gui_theme_toolbar_height(tv->tb)));
xwimp_force_redraw(tv->w, 0, tv->extent.y, tv->extent.x, 0);
ro_treeview_update_toolbar(tv);
}
}
/**
* Change the size of a treeview's toolbar and redraw the window.
*
* \param *tv The treeview to update.
*/
void ro_treeview_update_toolbar(ro_treeview *tv)
{
ro_treeview_set_origin(tv, 0,
-(ro_gui_theme_toolbar_height(tv->tb)));
xwimp_force_redraw(tv->w, 0, tv->extent.y, tv->extent.x, 0);
}
#if 0
if ((tree) && (tree->toolbar)) {

View File

@ -47,6 +47,7 @@ bool ro_treeview_has_selection(ro_treeview *tv);
void ro_treeview_set_origin(ro_treeview *tv, int x, int y);
void ro_treeview_mouse_at(wimp_w w, wimp_pointer *pointer);
void ro_treeview_update_theme(ro_treeview *tv);
void ro_treeview_update_toolbar(ro_treeview *tv);
int ro_treeview_get_help(help_full_message_request *message_data);
#endif