summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorRichard Wilson <rjw@netsurf-browser.org>2004-07-05 22:17:59 +0000
committerRichard Wilson <rjw@netsurf-browser.org>2004-07-05 22:17:59 +0000
commitb9c4038e5f92075a2c59d393f3e7abc0671489f4 (patch)
tree34d3a4f1bdf82a4c61d04992aba4af237a8f1fe6 /riscos
parentf8a1933c153966e82abfb909fe571f44d495a83c (diff)
downloadnetsurf-b9c4038e5f92075a2c59d393f3e7abc0671489f4.tar.gz
netsurf-b9c4038e5f92075a2c59d393f3e7abc0671489f4.tar.bz2
[project @ 2004-07-05 22:17:59 by rjw]
Minor hotlist GUI fixes. Further hotlist menu development. svn path=/import/netsurf/; revision=1052
Diffstat (limited to 'riscos')
-rw-r--r--riscos/gui.h8
-rw-r--r--riscos/hotlist.c112
-rw-r--r--riscos/menus.c215
-rw-r--r--riscos/save.c5
4 files changed, 292 insertions, 48 deletions
diff --git a/riscos/gui.h b/riscos/gui.h
index 3980ba2eb..b61fdb675 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -43,7 +43,8 @@ typedef enum { GUI_SAVE_SOURCE, GUI_SAVE_DRAW, GUI_SAVE_TEXT,
GUI_SAVE_COMPLETE,
GUI_SAVE_OBJECT_ORIG, GUI_SAVE_OBJECT_NATIVE,
GUI_SAVE_LINK_URI, GUI_SAVE_LINK_URL,
- GUI_SAVE_LINK_TEXT } gui_save_type;
+ GUI_SAVE_LINK_TEXT,
+ GUI_HOTLIST_EXPORT_HTML} gui_save_type;
extern gui_save_type gui_current_save_type;
typedef enum { GUI_DRAG_SELECTION, GUI_DRAG_DOWNLOAD_SAVE,
GUI_DRAG_SAVE, GUI_DRAG_STATUS_RESIZE,
@@ -187,6 +188,11 @@ void ro_gui_hotlist_move_drag_end(wimp_dragged *drag);
bool ro_gui_hotlist_keypress(int key);
void ro_gui_hotlist_menu_closed(void);
+int ro_gui_hotlist_get_selected(bool folders);
+void ro_gui_hotlist_set_selected(bool selected);
+void ro_gui_hotlist_set_expanded(bool expand, bool folders, bool links);
+void ro_gui_hotlist_save_as(const char *file);
+
/* in save.c */
void ro_gui_save_click(wimp_pointer *pointer);
void ro_gui_drag_icon(wimp_pointer *pointer);
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 87c0d2041..ed4bc6e1b 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -175,6 +175,7 @@ wimp_mouse_state drag_buttons;
/* Whether the current selection was from a menu click
*/
bool menu_selection = false;
+bool menu_open = false;
/* Hotlist loading buffer
*/
@@ -195,7 +196,7 @@ static int ro_gui_hotlist_selection_state(struct hotlist_entry *entry, bool sele
static void ro_gui_hotlist_selection_drag(struct hotlist_entry *entry,
int x0, int y0, int x1, int y1,
bool toggle, bool redraw);
-static int ro_gui_hotlist_selection_count(struct hotlist_entry *entry);
+static int ro_gui_hotlist_selection_count(struct hotlist_entry *entry, bool folders);
static void ro_gui_hotlist_update_expansion(struct hotlist_entry *entry, bool only_selected,
bool folders, bool links, bool expand, bool contract);
static void ro_gui_hotlist_launch_selection(struct hotlist_entry *entry);
@@ -410,8 +411,11 @@ bool ro_gui_hotlist_load(void) {
}
}
+
+/**
+ * Perform a save to the default file
+ */
void ro_gui_hotlist_save(void) {
- FILE *fp;
/* Don't save if we didn't load
*/
@@ -422,9 +426,23 @@ void ro_gui_hotlist_save(void) {
xosfile_create_dir("<Choices$Write>.WWW", 0);
xosfile_create_dir("<Choices$Write>.WWW.NetSurf", 0);
+ /* Save to our file
+ */
+ ro_gui_hotlist_save_as("<Choices$Write>.WWW.NetSurf.Hotlist");
+}
+
+
+/**
+ * Perform a save to a specified file
+ *
+ * /param file the file to save to
+ */
+void ro_gui_hotlist_save_as(const char *file) {
+ FILE *fp;
+
/* Open our file
*/
- fp = fopen("<Choices$Write>.WWW.NetSurf.Hotlist", "w");
+ fp = fopen(file, "w");
if (!fp) {
warn_user("HotlistSaveError", 0);
return;
@@ -450,7 +468,7 @@ void ro_gui_hotlist_save(void) {
/* Set the filetype to HTML
*/
- xosfile_set_type("<Choices$Write>.WWW.NetSurf.Hotlist", 0xfaf);
+ xosfile_set_type(file, 0xfaf);
}
bool ro_gui_hotlist_save_entry(FILE *fp, struct hotlist_entry *entry) {
@@ -1305,7 +1323,8 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) {
*/
x_offset = x - entry->x0;
y_offset = y - (entry->y0 + entry->height);
- if (((x_offset < HOTLIST_LEAF_INSET) && (y_offset > -HOTLIST_LINE_HEIGHT)) ||
+ if (((x_offset < HOTLIST_LEAF_INSET) && (y_offset > -HOTLIST_LINE_HEIGHT) &&
+ ((buttons == wimp_CLICK_SELECT << 8) || (buttons == wimp_CLICK_ADJUST << 8))) ||
((entry->children != -1) &&
((buttons == wimp_DOUBLE_SELECT) || (buttons == wimp_DOUBLE_ADJUST)))) {
ro_gui_hotlist_update_expansion(entry->child_entry, false, true, true, false, true);
@@ -1322,7 +1341,7 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) {
/* We treat a menu click as a Select click if we have no selections
*/
if (buttons == wimp_CLICK_MENU) {
- if (ro_gui_hotlist_selection_count(root.child_entry) == 0) {
+ if (ro_gui_hotlist_selection_count(root.child_entry, true) == 0) {
menu_selection = true;
buttons = (wimp_CLICK_SELECT << 8);
}
@@ -1363,7 +1382,9 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) {
}
}
} else {
- no_entry = true;
+ if (!((x_offset < HOTLIST_LEAF_INSET) && (y_offset > -HOTLIST_LINE_HEIGHT))) {
+ no_entry = true;
+ }
}
} else {
no_entry = true;
@@ -1376,9 +1397,10 @@ void ro_gui_hotlist_click(wimp_pointer *pointer) {
/* Create a menu if we should
*/
if (buttons == wimp_CLICK_MENU) {
-/* ro_gui_create_menu(hotlist_menu, pointer->pos.x - 64,
+ ro_gui_create_menu(hotlist_menu, pointer->pos.x - 64,
pointer->pos.y, NULL);
-*/ return;
+ menu_open = true;
+ return;
}
/* Handle a click without an entry
@@ -1517,7 +1539,7 @@ int ro_gui_hotlist_selection_state(struct hotlist_entry *entry, bool selected, b
/* Continue onwards
*/
- if (entry->child_entry) {
+ if ((entry->child_entry) && ((!selected) || (entry->expanded))) {
changes += ro_gui_hotlist_selection_state(entry->child_entry,
selected, redraw & (entry->expanded));
}
@@ -1526,7 +1548,13 @@ int ro_gui_hotlist_selection_state(struct hotlist_entry *entry, bool selected, b
return changes;
}
-int ro_gui_hotlist_selection_count(struct hotlist_entry *entry) {
+
+/**
+ * Return the current number of selected items (internal interface)
+ *
+ * \param entry the entry to count siblings and children of
+ */
+int ro_gui_hotlist_selection_count(struct hotlist_entry *entry, bool folders) {
int count = 0;
/* Check we have an entry (only applies if we have an empty hotlist)
@@ -1538,12 +1566,12 @@ int ro_gui_hotlist_selection_count(struct hotlist_entry *entry) {
while (entry) {
/* Check this entry
*/
- if (entry->selected) count++;
+ if ((entry->selected) && (folders || (entry->children == -1))) count++;
/* Continue onwards
*/
if (entry->child_entry) {
- count += ro_gui_hotlist_selection_count(entry->child_entry);
+ count += ro_gui_hotlist_selection_count(entry->child_entry, folders);
}
entry = entry->next_entry;
}
@@ -1589,6 +1617,11 @@ void ro_gui_hotlist_launch_selection(struct hotlist_entry *entry) {
void ro_gui_hotlist_update_expansion(struct hotlist_entry *entry, bool only_selected,
bool folders, bool links, bool expand, bool contract) {
bool current;
+
+ /* Set a reformat to be pending
+ */
+ reformat_pending = true;
+
/* Check we have an entry (only applies if we have an empty hotlist)
*/
if (!entry) return;
@@ -1603,7 +1636,7 @@ void ro_gui_hotlist_update_expansion(struct hotlist_entry *entry, bool only_sele
/* Only update what we should
*/
- if (((links) && (entry->children != -1)) || ((folders) && (entry->children > 0))) {
+ if (((links) && (entry->children == -1)) || ((folders) && (entry->children > 0))) {
/* Update the expansion state
*/
if (expand) {
@@ -1793,6 +1826,7 @@ void ro_gui_hotlist_move_drag_end(wimp_dragged *drag) {
* Handle a menu being closed
*/
void ro_gui_hotlist_menu_closed(void) {
+ menu_open = false;
if (menu_selection) {
ro_gui_hotlist_selection_state(root.child_entry, false, true);
menu_selection = false;
@@ -1814,16 +1848,22 @@ bool ro_gui_hotlist_keypress(int key) {
switch (key) {
case 1: /* CTRL+A */
ro_gui_hotlist_selection_state(root.child_entry, true, true);
+ if (menu_open) ro_gui_create_menu(hotlist_menu, 0, 0, NULL);
return true;
case 26: /* CTRL+Z */
ro_gui_hotlist_selection_state(root.child_entry, false, true);
+ if (menu_open) ro_gui_create_menu(hotlist_menu, 0, 0, NULL);
return true;
case 32: /* SPACE */
ro_gui_hotlist_update_expansion(root.child_entry, true, true, true, false, false);
+ if (menu_open) ro_gui_create_menu(hotlist_menu, 0, 0, NULL);
return true;
case wimp_KEY_RETURN:
ro_gui_hotlist_launch_selection(root.child_entry);
return true;
+ case wimp_KEY_F3:
+ ro_gui_hotlist_save();
+ return true;
case wimp_KEY_UP:
case wimp_KEY_DOWN:
case wimp_KEY_PAGE_UP:
@@ -1867,6 +1907,50 @@ bool ro_gui_hotlist_keypress(int key) {
+
+
+
+
+/**
+ * Set all items to either selected or deselected
+ *
+ * \param selected the state to set all items to
+ */
+void ro_gui_hotlist_set_selected(bool selected) {
+ ro_gui_hotlist_selection_state(root.child_entry, selected, true);
+ menu_selection = false;
+}
+
+
+/**
+ * Return the current number of selected items
+ *
+ * \param folders include folders in the selection count
+ * \return the number of selected items
+ */
+int ro_gui_hotlist_get_selected(bool folders) {
+ return ro_gui_hotlist_selection_count(root.child_entry, folders);
+}
+
+
+/**
+ * Set all items to either selected or deselected
+ *
+ * \param expand whether to expand (collapse otherwise)
+ * \param folders whether to update folders
+ * \param links whether to update links
+ */
+void ro_gui_hotlist_set_expanded(bool expand, bool folders, bool links) {
+ ro_gui_hotlist_update_expansion(root.child_entry, false, folders, links, expand, !expand);
+}
+
+
+
+
+
+
+
+
/**
* Convert the time of the last visit into a human friendly string
*
diff --git a/riscos/menus.c b/riscos/menus.c
index bc4c7ef37..3bc41472d 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -49,6 +49,7 @@ static void ro_gui_menu_pageinfo(wimp_message_menu_warning *warning);
static void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning);
static struct box *ro_gui_menu_find_object_box(void);
static void ro_gui_menu_object_reload(void);
+static void ro_gui_menu_hotlist_warning(wimp_message_menu_warning *warning);
wimp_menu *current_menu;
static int current_menu_x, current_menu_y;
@@ -274,40 +275,87 @@ wimp_menu *browser_menu = (wimp_menu *) &menu;
+/* Hotlist new submenu
+*/
+static wimp_MENU(2) hotlist_new = {
+ { "New" }, 7,2,7,0, 300, 44, 0,
+ {
+ { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Folder" } },
+ { wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Link" } },
+ }
+};
+
+
+/* Hotlist expand submenu
+*/
+static wimp_MENU(3) hotlist_expand = {
+ { "Expand" }, 7,2,7,0, 300, 44, 0,
+ {
+ { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "All" } },
+ { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Folders" } },
+ { wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Links" } },
+ }
+};
+
+/* Hotlist collapse submenu
+*/
+static wimp_MENU(3) hotlist_collapse = {
+ { "Collapse" }, 7,2,7,0, 300, 44, 0,
+ {
+ { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "All" } },
+ { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Folders" } },
+ { wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Links" } },
+ }
+};
+
+
+static wimp_MENU(4) hotlist_save = {
+ { "SaveHotlist" }, 7,2,7,0, 200, 44, 0,
+ {
+ { wimp_MENU_GIVE_WARNING, (wimp_menu*)1, DEFAULT_FLAGS, { "URI" } },
+ { wimp_MENU_GIVE_WARNING, (wimp_menu*)1, DEFAULT_FLAGS, { "URL" } },
+ { wimp_MENU_GIVE_WARNING, (wimp_menu*)1, DEFAULT_FLAGS, { "HTML" } },
+ { wimp_MENU_LAST | wimp_MENU_GIVE_WARNING, (wimp_menu*)1, DEFAULT_FLAGS, { "LinkText" } }
+ }
+};
+
/* Hotlist file submenu
*/
-static wimp_MENU(6) hotlist_file = {
+static wimp_MENU(5) hotlist_file = {
{ "Hotlist" }, 7,2,7,0, 300, 44, 0,
{
- { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Save" } },
- { wimp_MENU_SEPARATE, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Export" } },
- { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "OpenDir" } },
- { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "CloseDir" } },
- { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "OpenLinks" } },
- { wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "CloseLinks" } }
+ { wimp_MENU_GIVE_WARNING, (wimp_menu *)&hotlist_new, DEFAULT_FLAGS, { "New" } },
+ { wimp_MENU_GIVE_WARNING, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Save" } },
+ { wimp_MENU_GIVE_WARNING | wimp_MENU_SEPARATE, (wimp_menu *)1, DEFAULT_FLAGS, { "Export" } },
+ { 0, (wimp_menu *)&hotlist_expand, DEFAULT_FLAGS, { "Expand" } },
+ { wimp_MENU_LAST, (wimp_menu *)&hotlist_collapse, DEFAULT_FLAGS, { "Collapse" } },
}
};
/* Hotlist file submenu
*/
-static wimp_MENU(3) hotlist_select = {
+static wimp_MENU(5) hotlist_select = {
{ "Selection" }, 7,2,7,0, 300, 44, 0,
{
- { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Save" } },
- { wimp_MENU_SEPARATE, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Launch" } },
- { wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Delete" } },
+ { wimp_MENU_GIVE_WARNING, (wimp_menu *)&hotlist_save, DEFAULT_FLAGS, { "Save" } },
+ { wimp_MENU_SEPARATE, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Launch" } },
+ { wimp_MENU_GIVE_WARNING, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "EditTitle" } },
+ { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Delete" } },
+ { wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "ResetUsage" } },
}
};
/* Hotlist menu
*/
-static wimp_MENU(2) hotlist_root = {
+static wimp_MENU(4) hotlist_root = {
{ "Hotlist" }, 7,2,7,0, 200, 44, 0,
{
- { 0, (wimp_menu *)&hotlist_file, DEFAULT_FLAGS, { "Hotlist" } },
- { wimp_MENU_LAST, (wimp_menu *)&hotlist_select, DEFAULT_FLAGS, { "Selection" } },
+ { 0, (wimp_menu *)&hotlist_file, DEFAULT_FLAGS, { "Hotlist" } },
+ { wimp_MENU_GIVE_WARNING, (wimp_menu *)&hotlist_select, DEFAULT_FLAGS, { "Selection" } },
+ { 0, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "SelectAll" } },
+ { wimp_MENU_LAST, wimp_NO_SUB_MENU, DEFAULT_FLAGS, { "Clear" } },
}
};
wimp_menu *hotlist_menu = (wimp_menu *)&hotlist_root;
@@ -328,7 +376,12 @@ static wimp_menu *browser_window_menu = (wimp_menu *)&window_menu;
static wimp_menu *browser_utilities_menu = (wimp_menu *)&utilities_menu;
static wimp_menu *browser_hotlist_menu = (wimp_menu *)&hotlist_util_menu;
static wimp_menu *browser_help_menu = (wimp_menu *)&help_menu;
+
+static wimp_menu *hotlist_new_menu = (wimp_menu *)&hotlist_new;
+static wimp_menu *hotlist_expand_menu = (wimp_menu *)&hotlist_expand;
+static wimp_menu *hotlist_collapse_menu = (wimp_menu *)&hotlist_collapse;
static wimp_menu *hotlist_file_menu = (wimp_menu *)&hotlist_file;
+static wimp_menu *hotlist_save_menu = (wimp_menu *)&hotlist_save;
static wimp_menu *hotlist_select_menu = (wimp_menu *)&hotlist_select;
@@ -339,8 +392,8 @@ static wimp_menu *hotlist_select_menu = (wimp_menu *)&hotlist_select;
void ro_gui_menus_init(void)
{
translate_menu(iconbar_menu);
+
translate_menu(browser_menu);
- translate_menu(hotlist_menu);
translate_menu(browser_page_menu);
translate_menu(browser_export_menu);
translate_menu(browser_object_menu);
@@ -355,7 +408,13 @@ void ro_gui_menus_init(void)
translate_menu(browser_utilities_menu);
translate_menu(browser_hotlist_menu);
translate_menu(browser_help_menu);
+
+ translate_menu(hotlist_menu);
+ translate_menu(hotlist_new_menu);
+ translate_menu(hotlist_expand_menu);
+ translate_menu(hotlist_collapse_menu);
translate_menu(hotlist_file_menu);
+ translate_menu(hotlist_save_menu);
translate_menu(hotlist_select_menu);
iconbar_menu->entries[0].sub_menu = (wimp_menu *) dialog_info;
@@ -410,6 +469,8 @@ void translate_menu(wimp_menu *menu)
void ro_gui_create_menu(wimp_menu *menu, int x, int y, gui_window *g)
{
+ int selection;
+
current_menu = menu;
current_menu_x = x;
current_menu_y = y;
@@ -420,6 +481,16 @@ void ro_gui_create_menu(wimp_menu *menu, int x, int y, gui_window *g)
else
menu->entries[1].icon_flags |= wimp_ICON_SHADED;
}
+ if (menu == hotlist_menu) {
+ selection = ro_gui_hotlist_get_selected(true);
+ if (selection == 0) {
+ hotlist_menu->entries[1].icon_flags |= wimp_ICON_SHADED;
+ hotlist_menu->entries[3].icon_flags |= wimp_ICON_SHADED;
+ } else {
+ hotlist_menu->entries[1].icon_flags &= ~wimp_ICON_SHADED;
+ hotlist_menu->entries[3].icon_flags &= ~wimp_ICON_SHADED;
+ }
+ }
wimp_create_menu(menu, x, y);
}
@@ -478,6 +549,38 @@ void ro_gui_menu_selection(wimp_selection *selection)
break;
}
+ } else if (current_menu == hotlist_menu) {
+ switch (selection->items[0]) {
+ case 0: /* Hotlist-> */
+ switch (selection->items[1]) {
+ case 0: /* New */
+ break;
+ case 1: /* Save */
+ ro_gui_hotlist_save();
+ break;
+ case 2: /* Export */
+ break;
+ case 3: /* Expand */
+ ro_gui_hotlist_set_expanded(true,
+ (selection->items[2] != 2),
+ (selection->items[2] != 1));
+ break;
+ case 4: /* Collapse */
+ ro_gui_hotlist_set_expanded(false,
+ (selection->items[2] != 2),
+ (selection->items[2] != 1));
+ break;
+ }
+ break;
+ case 1: /* Selection-> */
+ break;
+ case 2: /* Select all */
+ ro_gui_hotlist_set_selected(true);
+ break;
+ case 3: /* Clear */
+ ro_gui_hotlist_set_selected(false);
+ break;
+ }
} else if (current_menu == browser_menu) {
struct content *c = current_gui->data.browser.bw->current_content;
switch (selection->items[0]) {
@@ -653,17 +756,17 @@ void ro_gui_menu_selection(wimp_selection *selection)
break;
case MENU_UTILITIES:
switch (selection->items[1]) {
- case 0: /* Hotlist -> */
- switch (selection->items[2]) {
- case 0: /* Add to hotlist */
- ro_gui_hotlist_add(current_gui->title,
- current_gui->data.browser.bw->current_content);
- break;
- case 1: /* Show hotlist */
- ro_gui_hotlist_show();
- break;
- }
- break;
+ case 0: /* Hotlist -> */
+ switch (selection->items[2]) {
+ case 0: /* Add to hotlist */
+ ro_gui_hotlist_add(current_gui->title,
+ current_gui->data.browser.bw->current_content);
+ break;
+ case 1: /* Show hotlist */
+ ro_gui_hotlist_show();
+ break;
+ }
+ break;
}
break;
case MENU_HELP:
@@ -706,14 +809,21 @@ void ro_gui_menu_selection(wimp_selection *selection)
/**
- * Handle Message_MenuWarning by opening the save dialog.
+ * Handle Message_MenuWarning.
*/
-
void ro_gui_menu_warning(wimp_message_menu_warning *warning)
{
- struct content *c = current_gui->data.browser.bw->current_content;
+ struct content *c;
os_error *error = NULL; // No warnings
+ if (current_menu == hotlist_menu) {
+ ro_gui_menu_hotlist_warning(warning);
+ return;
+ } else if (current_menu != browser_menu) {
+ return;
+ }
+
+ c = current_gui->data.browser.bw->current_content;
switch (warning->selection.items[0]) {
case MENU_PAGE: /* Page -> */
switch (warning->selection.items[1]) {
@@ -846,6 +956,37 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning)
/**
+ * Handle Message_MenuWarning for the hotlist menu.
+ */
+void ro_gui_menu_hotlist_warning(wimp_message_menu_warning *warning) {
+ os_error *error = NULL; // No warnings
+
+
+ switch (warning->selection.items[0]) {
+ case 0: /* Hotlist-> */
+ switch (warning->selection.items[1]) {
+ case 0: /* New */
+ break;
+ case 2: /* Export */
+ gui_current_save_type = GUI_HOTLIST_EXPORT_HTML;
+ ro_gui_menu_prepare_save(NULL);
+ error = xwimp_create_sub_menu((wimp_menu *) dialog_saveas,
+ warning->pos.x, warning->pos.y);
+ break;
+ }
+ break;
+ case 1: /* Selection-> */
+ break;
+ }
+
+ if (error) {
+ LOG(("0x%x: %s\n", error->errnum, error->errmess));
+ warn_user("MenuError", error->errmess);
+ }
+}
+
+
+/**
* Prepares the save box to reflect gui_current_save_type and a content.
*
* \param c content to save
@@ -858,7 +999,12 @@ void ro_gui_menu_prepare_save(struct content *c)
const char *name = "";
const char *nice;
- assert(c);
+/* We can't assert globally any more as hotlists have no content
+*/
+ if (gui_current_save_type != GUI_HOTLIST_EXPORT_HTML) {
+ assert(c);
+ }
+
switch (gui_current_save_type) {
case GUI_SAVE_SOURCE:
@@ -902,11 +1048,16 @@ void ro_gui_menu_prepare_save(struct content *c)
icon = "file_fff";
name = messages_get("SaveLink");
break;
+ case GUI_HOTLIST_EXPORT_HTML:
+ icon = "file_faf";
+ name = "Hotlist";
+ break;
}
save_content = c;
- if ((nice = url_nice(c->url)))
- name = nice;
+ if (c) {
+ if ((nice = url_nice(c->url))) name = nice;
+ }
/* Ensure the correct icon exists
*/
diff --git a/riscos/save.c b/riscos/save.c
index ba636435d..0d4f290a7 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -144,7 +144,7 @@ void ro_gui_save_datasave_ack(wimp_message *message)
struct content *c = save_content;
os_error *error;
- if (!save_content) {
+ if (!save_content && gui_current_save_type != GUI_HOTLIST_EXPORT_HTML) {
LOG(("unexpected DataSaveAck: save_content not set"));
return;
}
@@ -211,6 +211,9 @@ void ro_gui_save_datasave_ack(wimp_message *message)
if (!ro_gui_save_link(c, LINK_TEXT, path))
return;
break;
+ case GUI_HOTLIST_EXPORT_HTML:
+ ro_gui_hotlist_save_as(path);
+ break;
}
/* Ack successful save with message_DATA_LOAD */