Author: stevef
Date: Sun Feb 28 16:08:29 2010
New Revision: 10090
URL:
http://source.netsurf-browser.org?rev=10090&view=rev
Log:
RISC OS treeview menu code mostly completed (except toolbar interactions).
Modified:
branches/paulblokus/treeview/riscos/global_history.c
branches/paulblokus/treeview/riscos/hotlist.c
branches/paulblokus/treeview/riscos/menus.c
branches/paulblokus/treeview/riscos/treeview.c
branches/paulblokus/treeview/riscos/wimp_event.c
branches/paulblokus/treeview/riscos/wimp_event.h
Modified: branches/paulblokus/treeview/riscos/global_history.c
URL:
http://source.netsurf-browser.org/branches/paulblokus/treeview/riscos/glo...
==============================================================================
--- branches/paulblokus/treeview/riscos/global_history.c (original)
+++ branches/paulblokus/treeview/riscos/global_history.c Sun Feb 28 16:08:29 2010
@@ -37,6 +37,7 @@
#include "riscos/gui.h"
#include "riscos/menus.h"
#include "riscos/options.h"
+#include "riscos/save.h"
#include "riscos/theme.h"
#include "riscos/treeview.h"
#include "riscos/wimp.h"
@@ -162,6 +163,9 @@
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);
}
/**
@@ -178,6 +182,9 @@
wimp_selection *selection, menu_action action)
{
switch (action) {
+ case HISTORY_EXPORT:
+ ro_gui_dialog_open_persistent(window, dialog_saveas, true);
+ return true;
case TREE_EXPAND_ALL:
history_global_expand_all();
return true;
Modified: branches/paulblokus/treeview/riscos/hotlist.c
URL:
http://source.netsurf-browser.org/branches/paulblokus/treeview/riscos/hot...
==============================================================================
--- branches/paulblokus/treeview/riscos/hotlist.c (original)
+++ branches/paulblokus/treeview/riscos/hotlist.c Sun Feb 28 16:08:29 2010
@@ -37,6 +37,7 @@
#include "riscos/hotlist.h"
#include "riscos/menus.h"
#include "riscos/options.h"
+#include "riscos/save.h"
#include "riscos/theme.h"
#include "riscos/treeview.h"
#include "riscos/wimp.h"
@@ -49,9 +50,6 @@
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(void);
-static void ro_gui_hotlist_menu_close(void);
-
/* The RISC OS hotlist window, toolbar and treeview data. */
@@ -99,13 +97,12 @@
/* Build the hotlist window menu. */
- static wimp_w one = (wimp_w) 1;
static const struct ns_menu hotlist_definition = {
"Hotlist", {
{ "Hotlist", NO_ACTION, 0 },
{ "Hotlist.New", NO_ACTION, 0 },
-// { "Hotlist.New.Folder", TREE_NEW_FOLDER, &dialog_folder },
-// { "Hotlist.New.Link", TREE_NEW_LINK, &dialog_entry },
+ { "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 },
@@ -119,13 +116,7 @@
{ "_Hotlist.Toolbars.ToolButtons", TOOLBAR_BUTTONS, 0 },
{ "Hotlist.Toolbars.EditToolbar", TOOLBAR_EDIT, 0 },
{ "Selection", TREE_SELECTION, 0 },
- /* We want a window, but it changes depending upon
- * context. Therefore, ensure that the structure is
- * created so that we can dynamically modify the
- * actual item presented. We do this by creating a
- * fake wimp_w with the value 1, which indicates a
- * window handle as opposed to a submenu. */
- { "Selection.Edit", TREE_SELECTION_EDIT, &one },
+ { "Selection.Edit", TREE_SELECTION_EDIT, 0 },
{ "Selection.Launch", TREE_SELECTION_LAUNCH, 0 },
{ "Selection.Delete", TREE_SELECTION_DELETE, 0 },
{ "SelectAll", TREE_SELECT_ALL, 0 },
@@ -186,6 +177,10 @@
!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);
+
}
/**
@@ -202,6 +197,9 @@
wimp_selection *selection, menu_action action)
{
switch (action) {
+ case HOTLIST_EXPORT:
+ ro_gui_dialog_open_persistent(window, dialog_saveas, true);
+ return true;
case TREE_NEW_FOLDER:
hotlist_add_folder();
return true;
@@ -227,6 +225,7 @@
hotlist_collapse_addresses();
return true;
case TREE_SELECTION_EDIT:
+ hotlist_edit_selected();
return true;
case TREE_SELECTION_LAUNCH:
hotlist_launch_selected();
@@ -245,22 +244,6 @@
}
return false;
-}
-
-/**
- * Handle Message_SubmenuWarning for the hotlist menu
- */
-
-void ro_gui_hotlist_menu_warning(void)
-{
-}
-
-/**
- * Handle the closure of the hotlist menu
- */
-
-void ro_gui_hotlist_menu_close(void)
-{
}
/**
Modified: branches/paulblokus/treeview/riscos/menus.c
URL:
http://source.netsurf-browser.org/branches/paulblokus/treeview/riscos/men...
==============================================================================
--- branches/paulblokus/treeview/riscos/menus.c (original)
+++ branches/paulblokus/treeview/riscos/menus.c Sun Feb 28 16:08:29 2010
@@ -521,11 +521,13 @@
&g, &bw, &c, &t,
&is_cookies, &is_hotlist,
&is_global_history);
+
+ if (cleanup) {
+ ro_gui_wimp_event_menus_closed(current_menu_window,
+ current_menu_icon, current_menu);
+ }
+
current_menu = NULL;
-
- if (cleanup) {
- ro_gui_wimp_event_menus_closed();
- }
}
current_menu_window = NULL;
@@ -685,28 +687,42 @@
for (i = 1; warning->selection.items[i] != -1; i++)
menu_entry = &menu_entry->sub_menu->
entries[warning->selection.items[i]];
-
- if (IS_MENU(menu_entry->sub_menu)) {
- ro_gui_wimp_event_register_submenu((wimp_w)0);
- sub_menu = menu_entry->sub_menu;
- i = 0;
- do {
- action = ro_gui_menu_find_action(current_menu,
- &sub_menu->entries[i]);
+ action = ro_gui_menu_find_action(current_menu, menu_entry);
+
+ /* We only process the menu in the old way if the wimp_event module
+ * hasn't processed it for us.
+ */
+
+ if (!ro_gui_wimp_event_submenu_warning(current_menu_window,
+ current_menu_icon, current_menu, &(warning->selection),
+ action)) {
+ if (IS_MENU(menu_entry->sub_menu)) {
+ ro_gui_wimp_event_register_submenu((wimp_w)0);
+ sub_menu = menu_entry->sub_menu;
+ i = 0;
+ do {
+ action = ro_gui_menu_find_action(current_menu,
+ &sub_menu->entries[i]);
+ if (action != NO_ACTION)
+ ro_gui_menu_prepare_action(current_menu_window,
+ action, false);
+ } while (!(sub_menu->entries[i++].menu_flags &
+ wimp_MENU_LAST));
+ } else {
+ ro_gui_wimp_event_register_submenu((wimp_w)menu_entry->sub_menu);
+ action = ro_gui_menu_find_action(current_menu, menu_entry);
if (action != NO_ACTION)
ro_gui_menu_prepare_action(current_menu_window,
- action, false);
- } while (!(sub_menu->entries[i++].menu_flags & wimp_MENU_LAST));
- } else {
- ro_gui_wimp_event_register_submenu((wimp_w)menu_entry->sub_menu);
- action = ro_gui_menu_find_action(current_menu, menu_entry);
- if (action != NO_ACTION)
- ro_gui_menu_prepare_action(current_menu_window,
- action, true);
- /* remove the close icon */
+ action, true);
+ }
+ }
+
+ /* If this is a dialogue box, remove the close and back icons. */
+
+ if (!(IS_MENU(menu_entry->sub_menu)))
ro_gui_wimp_update_window_furniture((wimp_w)menu_entry->sub_menu,
wimp_WINDOW_CLOSE_ICON | wimp_WINDOW_BACK_ICON, 0);
- }
+
/* open the sub-menu */
error = xwimp_create_sub_menu(menu_entry->sub_menu,
@@ -1519,8 +1535,6 @@
if (!c)
return false;
/* Fall through */
- case HOTLIST_EXPORT:
- case HISTORY_EXPORT:
ro_gui_menu_prepare_action(owner, action, true);
ro_gui_dialog_open_persistent(owner, dialog_saveas,
windows_at_pointer);
@@ -2026,16 +2040,6 @@
ro_gui_save_prepare(GUI_SAVE_LINK_TEXT, NULL, NULL,
c->url, c->title);
break;
- case HOTLIST_EXPORT:
- if (windows)
- ro_gui_save_prepare(GUI_SAVE_HOTLIST_EXPORT_HTML,
- NULL, NULL, NULL, NULL);
- break;
- case HISTORY_EXPORT:
- if (windows)
- ro_gui_save_prepare(GUI_SAVE_HISTORY_EXPORT_HTML,
- NULL, NULL, NULL, NULL);
- break;
/* navigation actions */
case BROWSER_NAVIGATE_BACK:
Modified: branches/paulblokus/treeview/riscos/treeview.c
URL:
http://source.netsurf-browser.org/branches/paulblokus/treeview/riscos/tre...
==============================================================================
--- branches/paulblokus/treeview/riscos/treeview.c (original)
+++ branches/paulblokus/treeview/riscos/treeview.c Sun Feb 28 16:08:29 2010
@@ -61,7 +61,7 @@
#endif
/** \todo Ugh! */
-const char tree_directory_icon_name[] = "directory.png";
+const char tree_directory_icon_name[] =
"file:///NetSurf:/Resources/Icons/directory.png";
const char tree_content_icon_name[] = "content.png";
struct ro_treeview
Modified: branches/paulblokus/treeview/riscos/wimp_event.c
URL:
http://source.netsurf-browser.org/branches/paulblokus/treeview/riscos/wim...
==============================================================================
--- branches/paulblokus/treeview/riscos/wimp_event.c (original)
+++ branches/paulblokus/treeview/riscos/wimp_event.c Sun Feb 28 16:08:29 2010
@@ -102,7 +102,8 @@
bool (*window_menu_selection)(wimp_w w, wimp_menu *m,
wimp_selection *s, menu_action action);
void (*window_menu_close)(wimp_w w, wimp_menu *m);
- void (*window_menu_warning)(wimp_w w, wimp_menu *m, wimp_selection *s);
+ void (*window_menu_warning)(wimp_w w, wimp_menu *m,
+ wimp_selection *s, menu_action action);
const char *help_prefix;
void *user_data;
struct icon_event *first;
@@ -397,7 +398,8 @@
if ((event->type == EVENT_MENU_GRIGHT) && (event->i == i))
break;
if (!event) {
- if ((window->window_menu) && (window->window_menu_selection)) {
+ if ((window->window_menu) && (window->window_menu == menu)
+ && (window->window_menu_selection)) {
window->window_menu_selection(w, menu,
selection, action);
@@ -1251,7 +1253,7 @@
wimp_selection *s, menu_action action),
void (*callback_close)(wimp_w w, wimp_menu *m),
void (*callback_warning)(wimp_w w, wimp_menu *m,
- wimp_selection *s),
+ wimp_selection *s, menu_action action),
bool menu_auto)
{
struct event_window *window;
@@ -1374,12 +1376,88 @@
return event;
}
-/**
- * Handle menus being closed
- */
-void ro_gui_wimp_event_menus_closed(void)
-{
- ro_gui_wimp_event_register_submenu(0);
+/* Handle sumbenu warnings. This is called from ro_gui_menu_warning(), and
+ * returns to that function to have the submenu opened correctly.
+ *
+ * \param w the window to owning the menu
+ * \param i the icon owning the menu
+ * \param menu the menu that has been selected
+ * \param selection the selection information
+ * \param action the menu action info from menus.c
+ * \return true if the event was handled, false otherwise
+ */
+
+bool ro_gui_wimp_event_submenu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
+ wimp_selection *selection, menu_action action)
+{
+ struct event_window *window;
+ struct icon_event *event;
+
+ ro_gui_wimp_event_register_submenu(0);
+
+ /* Process the event for any window menus. Find the window data, then
+ * try and match to an icon event. If we can, then there isn't anything
+ * to do.
+ */
+
+ window = ro_gui_wimp_event_find_window(w);
+ if (!window)
+ return false;
+
+ for (event = window->first; event; event = event->next)
+ if ((event->type == EVENT_MENU_GRIGHT) && (event->i == i))
+ break;
+ if (event)
+ return false;
+
+ /* If the warning is for a window menu, then pass the event on to it. */
+
+ if ((window->window_menu) && (window->window_menu == menu)) {
+ if (window->window_menu_warning) {
+ window->window_menu_warning(w, menu, selection, action);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Handle menus being closed. This is called from ro_gui_menu_closed(), in
+ * every scenario when one of our own menus is open.
+ *
+ * \param w the window to owning the menu
+ * \param i the icon owning the menu
+ * \param menu the menu that has been selected
+ */
+
+void ro_gui_wimp_event_menus_closed(wimp_w w, wimp_i i, wimp_menu *menu)
+{
+ struct event_window *window;
+ struct icon_event *event;
+
+ ro_gui_wimp_event_register_submenu(0);
+
+ /* Process the event for any window menus. Find the window data, then
+ * try and match to an icon event. If we can, then there isn't anything
+ * to do.
+ */
+
+ window = ro_gui_wimp_event_find_window(w);
+ if (!window)
+ return;
+
+ for (event = window->first; event; event = event->next)
+ if ((event->type == EVENT_MENU_GRIGHT) && (event->i == i))
+ break;
+ if (event)
+ return;
+
+ /* If the close is for a window menu, then pass the event on to it. */
+
+ if ((window->window_menu) && (window->window_menu == menu) &&
+ (window->window_menu_close))
+ window->window_menu_close(w, menu);
}
/**
Modified: branches/paulblokus/treeview/riscos/wimp_event.h
URL:
http://source.netsurf-browser.org/branches/paulblokus/treeview/riscos/wim...
==============================================================================
--- branches/paulblokus/treeview/riscos/wimp_event.h (original)
+++ branches/paulblokus/treeview/riscos/wimp_event.h Sun Feb 28 16:08:29 2010
@@ -88,10 +88,12 @@
wimp_selection *s, menu_action action),
void (*callback_close)(wimp_w w, wimp_menu *m),
void (*callback_warning)(wimp_w w, wimp_menu *m,
- wimp_selection *s),
+ wimp_selection *s, menu_action action),
bool menu_auto);
-void ro_gui_wimp_event_menus_closed(void);
+bool ro_gui_wimp_event_submenu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
+ wimp_selection *selection, menu_action action);
+void ro_gui_wimp_event_menus_closed(wimp_w w, wimp_i i, wimp_menu *menu);
void ro_gui_wimp_event_register_submenu(wimp_w w);
#endif