From de0c4e2c32c1ecbef75293653adff4e4ceffeffe Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Mon, 3 Jul 2006 21:07:02 +0000 Subject: Implement up toolbar icon and menu option. svn path=/trunk/netsurf/; revision=2705 --- riscos/gui.c | 4 +++- riscos/menus.c | 42 +++++++++++++++++++++++++++++++++++++++++- riscos/menus.h | 1 + riscos/theme.c | 4 ++-- riscos/theme.h | 13 +++++++------ riscos/window.c | 4 ++++ 6 files changed, 58 insertions(+), 10 deletions(-) (limited to 'riscos') diff --git a/riscos/gui.c b/riscos/gui.c index 9ffa05c0b..5abddac3d 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -1103,7 +1103,9 @@ void ro_gui_close_window_request(wimp_close *close) } free(filename); } else { - /* todo: go 'up' */ + /* this is pointless if we are about to close the window */ + if (ro_gui_shift_pressed()) + ro_gui_menu_handle_action(close->w, BROWSER_NAVIGATE_UP, true); } } if (ro_gui_shift_pressed()) diff --git a/riscos/menus.c b/riscos/menus.c index 83fc09e3b..4e5cfc98a 100644 --- a/riscos/menus.c +++ b/riscos/menus.c @@ -194,7 +194,8 @@ void ro_gui_menu_init(void) { "Navigate", NO_ACTION, 0 }, { "Navigate.Home", BROWSER_NAVIGATE_HOME, 0 }, { "Navigate.Back", BROWSER_NAVIGATE_BACK, 0 }, - { "_Navigate.Forward", BROWSER_NAVIGATE_FORWARD, 0 }, + { "Navigate.Forward", BROWSER_NAVIGATE_FORWARD, 0 }, + { "_Navigate.UpLevel", BROWSER_NAVIGATE_UP, 0 }, { "Navigate.Reload", BROWSER_NAVIGATE_RELOAD_ALL, 0 }, { "Navigate.Stop", BROWSER_NAVIGATE_STOP, 0 }, { "View", NO_ACTION, 0 }, @@ -809,6 +810,7 @@ void ro_gui_prepare_navigate(struct gui_window *gui) { ro_gui_menu_prepare_action(gui->window, BROWSER_NAVIGATE_BACK, false); ro_gui_menu_prepare_action(gui->window, BROWSER_NAVIGATE_FORWARD, false); + ro_gui_menu_prepare_action(gui->window, BROWSER_NAVIGATE_UP, false); ro_gui_menu_prepare_action(gui->window, HOTLIST_SHOW, false); ro_gui_menu_prepare_action(gui->window, BROWSER_SAVE, false); ro_gui_menu_prepare_action(gui->window, BROWSER_PRINT, false); @@ -1370,6 +1372,9 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action, os_error *error; char url[80]; const struct url_data *data; + char *parent; + url_func_result res; + bool compare; ro_gui_menu_get_window_details(owner, &g, &bw, &c, &t, &tree); @@ -1518,6 +1523,17 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action, return false; history_forward(bw, bw->history); return true; + case BROWSER_NAVIGATE_UP: + if ((!bw) || (!c)) + return false; + res = url_parent(c->url, &parent); + if (res == URL_FUNC_OK) { + res = url_compare(c->url, parent, &compare); + if (!compare && (res == URL_FUNC_OK)) + browser_window_go(g->bw, parent, 0, true); + free(parent); + } + return true; case BROWSER_NAVIGATE_RELOAD: case BROWSER_NAVIGATE_RELOAD_ALL: if (!bw) @@ -1734,6 +1750,9 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action, bool result = false; int checksum = 0; os_error *error; + char *parent; + url_func_result res; + bool compare; ro_gui_menu_get_window_details(owner, &g, &bw, &c, &t, &tree); if (current_menu_open) @@ -1930,6 +1949,27 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action, t->toolbar_handle, ICON_TOOLBAR_FORWARD, result); break; + case BROWSER_NAVIGATE_UP: + result = (bw && c); + if (result) { + res = url_parent(c->url, &parent); + if (res == URL_FUNC_OK) { + res = url_compare(c->url, parent, &compare); + result = !compare; + free(parent); + } else { + result = false; + } + } + ro_gui_menu_set_entry_shaded(current_menu, + action, !result); + if ((t) && (!t->editor) && + (t->type == THEME_BROWSER_TOOLBAR)) + ro_gui_set_icon_shaded_state( + t->toolbar_handle, + ICON_TOOLBAR_UP, !result); + result = true; + break; case BROWSER_NAVIGATE_RELOAD: case BROWSER_NAVIGATE_RELOAD_ALL: result = (bw->current_content && !bw->loading_content); diff --git a/riscos/menus.h b/riscos/menus.h index 12a4a234f..9ac7fcaf4 100644 --- a/riscos/menus.h +++ b/riscos/menus.h @@ -72,6 +72,7 @@ typedef enum { BROWSER_NAVIGATE_HOME, BROWSER_NAVIGATE_BACK, BROWSER_NAVIGATE_FORWARD, + BROWSER_NAVIGATE_UP, BROWSER_NAVIGATE_RELOAD, BROWSER_NAVIGATE_RELOAD_ALL, BROWSER_NAVIGATE_STOP, diff --git a/riscos/theme.c b/riscos/theme.c index eebdb8b2b..5016e7e75 100644 --- a/riscos/theme.c +++ b/riscos/theme.c @@ -49,7 +49,7 @@ static bool theme_toolbar_editor_drag = false; /* these order of the icons must match the numbers defined in riscos/gui.h */ static const char * theme_browser_icons[] = {"back", "forward", "stop", "reload", "home", "history", "save", "print", "hotlist", - "scale", "search", NULL}; + "scale", "search", "up", NULL}; static const char * theme_hotlist_icons[] = {"delete", "expand", "open", "launch", "create", NULL}; static const char * theme_history_icons[] = {"delete", "expand", "open", @@ -782,7 +782,7 @@ struct toolbar *ro_gui_theme_create_toolbar(struct theme_descriptor *descriptor, case THEME_BROWSER_EDIT_TOOLBAR: ro_gui_theme_add_toolbar_icons(toolbar, theme_browser_icons, - "0123456789a|"); + "0123456789ab|"); break; case THEME_HOTLIST_EDIT_TOOLBAR: ro_gui_theme_add_toolbar_icons(toolbar, diff --git a/riscos/theme.h b/riscos/theme.h index bd6a4783c..d5ba81956 100644 --- a/riscos/theme.h +++ b/riscos/theme.h @@ -26,12 +26,13 @@ #define ICON_TOOLBAR_BOOKMARK 8 #define ICON_TOOLBAR_SCALE 9 #define ICON_TOOLBAR_SEARCH 10 -#define ICON_TOOLBAR_LAST 11 -#define ICON_TOOLBAR_SURROUND 11 // Must be after highest toolbar icon -#define ICON_TOOLBAR_FAVICON 12 -#define ICON_TOOLBAR_URL 13 -#define ICON_TOOLBAR_SUGGEST 14 -#define ICON_TOOLBAR_THROBBER 15 +#define ICON_TOOLBAR_UP 11 +#define ICON_TOOLBAR_LAST 12 +#define ICON_TOOLBAR_SURROUND 12 // Must be after highest toolbar icon +#define ICON_TOOLBAR_FAVICON 13 +#define ICON_TOOLBAR_URL 14 +#define ICON_TOOLBAR_SUGGEST 15 +#define ICON_TOOLBAR_THROBBER 16 /* icon numbers for hotlist/history toolbars */ #define ICON_TOOLBAR_DELETE 0 diff --git a/riscos/window.c b/riscos/window.c index 8029a8b79..ffdd4bc49 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -1441,6 +1441,10 @@ bool ro_gui_toolbar_click(wimp_pointer *pointer) ro_gui_menu_handle_action(g->window, BROWSER_PRINT, true); break; + case ICON_TOOLBAR_UP: + ro_gui_menu_handle_action(g->window, + BROWSER_NAVIGATE_UP, true); + break; case ICON_TOOLBAR_URL: if (pointer->buttons & (wimp_DRAG_SELECT | wimp_DRAG_ADJUST)) { if (g->bw->current_content) { -- cgit v1.2.3