summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2017-01-06 23:56:52 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2017-01-06 23:56:52 +0000
commit917a602dce32286260a34d61b7c0db4bee502ec0 (patch)
tree17186d3dac2e8a18310c628270c377974d21ad58
parenta86f2c8dd35c0cd8ba2f87097a68ad32373c28b5 (diff)
downloadnetsurf-917a602dce32286260a34d61b7c0db4bee502ec0.tar.gz
netsurf-917a602dce32286260a34d61b7c0db4bee502ec0.tar.bz2
Conversion of Amiga hotlist manager to corewindow
-rw-r--r--frontends/amiga/arexx.c4
-rw-r--r--frontends/amiga/gui.c16
-rw-r--r--[-rwxr-xr-x]frontends/amiga/hotlist.c457
-rw-r--r--[-rwxr-xr-x]frontends/amiga/hotlist.h22
-rw-r--r--frontends/amiga/menu.c9
5 files changed, 464 insertions, 44 deletions
diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c
index b9702287b..63e418a69 100644
--- a/frontends/amiga/arexx.c
+++ b/frontends/amiga/arexx.c
@@ -665,9 +665,9 @@ RXHOOKF(rx_hotlist)
cmd->ac_RC = 0;
if(strcasecmp((char *)cmd->ac_ArgList[0], "OPEN") == 0) {
- ami_tree_open(hotlist_window, AMI_TREE_HOTLIST);
+ ami_hotlist_present();
} else if(strcasecmp((char *)cmd->ac_ArgList[0], "CLOSE") == 0) {
- ami_tree_close(hotlist_window);
+ ami_hotlist_close();
}
}
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 7c92a40d7..4e88a0e47 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -552,6 +552,12 @@ static void ami_set_screen_defaults(struct Screen *screen)
nsoption_default_set_int(history_window_xsize, width);
nsoption_default_set_int(history_window_ysize, height);
+ nsoption_default_set_int(hotlist_window_ypos, top);
+ nsoption_default_set_int(hotlist_window_xpos, left);
+ nsoption_default_set_int(hotlist_window_xsize, width);
+ nsoption_default_set_int(hotlist_window_ysize, height);
+
+
nsoption_default_set_int(window_x, 0);
nsoption_default_set_int(window_y, screen->BarHeight + 1);
nsoption_default_set_int(window_width, screen->Width);
@@ -1018,7 +1024,7 @@ static void gui_init2(int argc, char** argv)
}
/**/
- ami_hotlist_initialise(nsoption_charp(hotlist_file));
+ hotlist_init(nsoption_charp(hotlist_file));
search_web_select_provider(nsoption_int(search_provider));
if (notalreadyrunning &&
@@ -3041,7 +3047,7 @@ static void gui_quit(void)
urldb_save(nsoption_charp(url_file));
urldb_save_cookies(nsoption_charp(cookie_file));
- ami_hotlist_free(nsoption_charp(hotlist_file));
+ hotlist_fini(nsoption_charp(hotlist_file));
#ifdef __amigaos4__
if(IApplication && ami_appid)
UnregisterApplication(ami_appid, NULL);
@@ -3185,7 +3191,7 @@ static bool ami_gui_hotlist_add(void *userdata, int level, int item,
return true;
}
-static int ami_gui_hotlist_scan(struct tree *tree, struct List *speed_button_list, struct gui_window_2 *gwin)
+static int ami_gui_hotlist_scan(struct List *speed_button_list, struct gui_window_2 *gwin)
{
struct ami_gui_tb_userdata userdata;
userdata.gw = gwin;
@@ -3207,7 +3213,7 @@ static void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
NewList(&gwin->hotlist_toolbar_list);
- if(ami_gui_hotlist_scan(ami_tree_get_tree(hotlist_window), &gwin->hotlist_toolbar_list, gwin) > 0) {
+ if(ami_gui_hotlist_scan(&gwin->hotlist_toolbar_list, gwin) > 0) {
gwin->objects[GID_HOTLIST] =
SpeedBarObj,
GA_ID, GID_HOTLIST,
@@ -3306,7 +3312,7 @@ static void ami_gui_hotlist_toolbar_update(struct gui_window_2 *gwin)
ami_gui_hotlist_toolbar_free(gwin, &gwin->hotlist_toolbar_list);
- if(ami_gui_hotlist_scan(ami_tree_get_tree(hotlist_window), &gwin->hotlist_toolbar_list, gwin) > 0) {
+ if(ami_gui_hotlist_scan(&gwin->hotlist_toolbar_list, gwin) > 0) {
SetGadgetAttrs((struct Gadget *)gwin->objects[GID_HOTLIST],
gwin->win, NULL,
SPEEDBAR_Buttons, &gwin->hotlist_toolbar_list,
diff --git a/frontends/amiga/hotlist.c b/frontends/amiga/hotlist.c
index fc2342d73..de8b6ac6a 100755..100644
--- a/frontends/amiga/hotlist.c
+++ b/frontends/amiga/hotlist.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008, 2009, 2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -16,16 +16,82 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Implementation of Amiga hotlist viewer using core windows.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
-#include <proto/exec.h>
-#include "utils/nsurl.h"
+#include <proto/asl.h>
+#include <proto/dos.h>
+#include <proto/intuition.h>
+
+#include <classes/window.h>
+#include <gadgets/layout.h>
+#include <gadgets/space.h>
+
+#include <reaction/reaction_macros.h>
+
#include "desktop/hotlist.h"
-#include "netsurf/mouse.h"
-#include "netsurf/window.h"
+#include "netsurf/keypress.h"
+#include "netsurf/plotters.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/nsoption.h"
+#include "amiga/corewindow.h"
+#include "amiga/file.h"
#include "amiga/hotlist.h"
-#include "amiga/tree.h"
+#include "amiga/libs.h"
+#include "amiga/theme.h"
+#include "amiga/utf8.h"
+
+enum {
+ /* Project menu */
+ AMI_HOTLIST_M_PROJECT = 0,
+ AMI_HOTLIST_M_EXPORT,
+ AMI_HOTLIST_M_BAR_P1,
+ AMI_HOTLIST_M_EXPAND,
+ AMI_HOTLIST_M_EXPAND_ALL,
+ AMI_HOTLIST_M_EXPAND_FOLDERS,
+ AMI_HOTLIST_M_EXPAND_LINKS,
+ AMI_HOTLIST_M_COLLAPSE,
+ AMI_HOTLIST_M_COLLAPSE_ALL,
+ AMI_HOTLIST_M_COLLAPSE_FOLDERS,
+ AMI_HOTLIST_M_COLLAPSE_LINKS,
+ AMI_HOTLIST_M_BAR_P2,
+ AMI_HOTLIST_M_SNAPSHOT,
+ AMI_HOTLIST_M_BAR_P3,
+ AMI_HOTLIST_M_CLOSE,
+ /* Edit menu */
+ AMI_HOTLIST_M_EDIT,
+ AMI_HOTLIST_M_NEWFOLDER,
+ AMI_HOTLIST_M_NEWLINK,
+ AMI_HOTLIST_M_EDIT_EDIT,
+ AMI_HOTLIST_M_BAR_E1,
+ AMI_HOTLIST_M_SELECTALL,
+ AMI_HOTLIST_M_CLEAR,
+ AMI_HOTLIST_M_BAR_E2,
+ AMI_HOTLIST_M_DELETE,
+ AMI_HOTLIST_M_LAST
+};
+
+/**
+ * Amiga hotlist viewer window context
+ */
+struct ami_hotlist_window {
+ /** Amiga core window context */
+ struct ami_corewindow core;
+
+ struct ami_menu_data *menu_data[AMI_HOTLIST_M_LAST + 1];
+ struct Menu *imenu; /* Intuition menu */
+};
+
+static struct ami_hotlist_window *hotlist_window = NULL;
struct ami_hotlist_ctx {
void *userdata;
@@ -37,22 +103,7 @@ struct ami_hotlist_ctx {
bool (*cb)(void *userdata, int level, int item, const char *title, nsurl *url, bool folder);
};
-struct treeview_window *hotlist_window = NULL;
-
-void ami_hotlist_initialise(const char *hotlist_file)
-{
- tree_hotlist_path = hotlist_file;
- hotlist_window = ami_tree_create(TREE_HOTLIST, NULL);
- if(!hotlist_window) return;
-}
-
-void ami_hotlist_free(const char *hotlist_file)
-{
- ami_tree_destroy(hotlist_window);
- hotlist_window = NULL;
-}
-
-
+/** hotlist scanner */
static nserror ami_hotlist_folder_enter_cb(void *ctx, const char *title)
{
struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
@@ -118,3 +169,365 @@ nserror ami_hotlist_scan(void *userdata, int first_item, const char *folder,
return error;
}
+
+
+/**
+ * callback for mouse action for hotlist viewer on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param mouse_state netsurf mouse state on event
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_hotlist_mouse(struct ami_corewindow *ami_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
+{
+ hotlist_mouse_action(mouse_state, x, y);
+
+ return NSERROR_OK;
+}
+
+/**
+ * callback for keypress for hotlist viewer on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param nskey The netsurf key code
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_hotlist_key(struct ami_corewindow *ami_cw, uint32_t nskey)
+{
+ if (hotlist_keypress(nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
+}
+
+/**
+ * callback on draw event for hotlist viewer on core window
+ *
+ * \param ami_cw The Amiga core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \param ctx The drawing context
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+ami_hotlist_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
+{
+ hotlist_redraw(x, y, r, ctx);
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * menu stuff
+ */
+
+static void
+ami_hotlist_menu_free(struct ami_hotlist_window *hotlist_win)
+{
+ SetAttrs(hotlist_win->core.objects[GID_CW_WIN],
+ WINDOW_MenuStrip, NULL,
+ TAG_DONE);
+
+ ami_menu_free_menu(hotlist_win->menu_data, AMI_HOTLIST_M_LAST, hotlist_win->imenu);
+}
+
+ /* menu hook functions */
+HOOKF(void, ami_hotlist_menu_item_project_export, APTR, window, struct IntuiMessage *)
+{
+ char fname[1024];
+ struct ami_corewindow *ami_cw;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+
+ if(AslRequestTags(savereq,
+ ASLFR_Window, ami_cw->win,
+ ASLFR_SleepWindow, TRUE,
+ ASLFR_TitleText, messages_get("NetSurf"),
+ ASLFR_Screen, scrn,
+ ASLFR_InitialFile, "hotlist.html",
+ TAG_DONE)) {
+ strlcpy(fname, savereq->fr_Drawer, 1024);
+ AddPart(fname, savereq->fr_File, 1024);
+ ami_update_pointer(ami_cw->win, GUI_POINTER_WAIT);
+ hotlist_export(fname, NULL);
+ ami_update_pointer(ami_cw->win, GUI_POINTER_DEFAULT);
+ }
+}
+
+HOOKF(void, ami_hotlist_menu_item_project_expand_all, APTR, window, struct IntuiMessage *)
+{
+ hotlist_expand(false);
+}
+
+HOOKF(void, ami_hotlist_menu_item_project_expand_folders, APTR, window, struct IntuiMessage *)
+{
+ hotlist_expand(true);
+}
+
+HOOKF(void, ami_hotlist_menu_item_project_expand_links, APTR, window, struct IntuiMessage *)
+{
+ hotlist_expand(false);
+}
+
+HOOKF(void, ami_hotlist_menu_item_project_collapse_all, APTR, window, struct IntuiMessage *)
+{
+ hotlist_contract(true);
+}
+
+HOOKF(void, ami_hotlist_menu_item_project_collapse_folders, APTR, window, struct IntuiMessage *)
+{
+ hotlist_contract(true);
+}
+
+HOOKF(void, ami_hotlist_menu_item_project_collapse_links, APTR, window, struct IntuiMessage *)
+{
+ hotlist_contract(false);
+}
+
+HOOKF(void, ami_hotlist_menu_item_project_snapshot, APTR, window, struct IntuiMessage *)
+{
+ struct ami_corewindow *ami_cw;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+
+ nsoption_set_int(hotlist_window_ypos, ami_cw->win->TopEdge);
+ nsoption_set_int(hotlist_window_xpos, ami_cw->win->LeftEdge);
+ nsoption_set_int(hotlist_window_xsize, ami_cw->win->Width);
+ nsoption_set_int(hotlist_window_ysize, ami_cw->win->Height);
+}
+
+HOOKF(void, ami_hotlist_menu_item_project_close, APTR, window, struct IntuiMessage *)
+{
+ struct ami_corewindow *ami_cw;
+ GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
+
+ ami_cw->close_window = true;
+}
+
+HOOKF(void, ami_hotlist_menu_item_edit_newfolder, APTR, window, struct IntuiMessage *)
+{
+ hotlist_add_folder(NULL, false, 0);
+}
+
+HOOKF(void, ami_hotlist_menu_item_edit_newlink, APTR, window, struct IntuiMessage *)
+{
+ hotlist_add_entry(NULL, NULL, false, 0);
+}
+
+HOOKF(void, ami_hotlist_menu_item_edit_edit, APTR, window, struct IntuiMessage *)
+{
+ hotlist_edit_selection();
+}
+
+HOOKF(void, ami_hotlist_menu_item_edit_select_all, APTR, window, struct IntuiMessage *)
+{
+ hotlist_keypress(NS_KEY_SELECT_ALL);
+}
+
+HOOKF(void, ami_hotlist_menu_item_edit_clear, APTR, window, struct IntuiMessage *)
+{
+ hotlist_keypress(NS_KEY_CLEAR_SELECTION);
+}
+
+HOOKF(void, ami_hotlist_menu_item_edit_delete, APTR, window, struct IntuiMessage *)
+{
+ hotlist_keypress(NS_KEY_DELETE_LEFT);
+}
+
+
+/* menu setup */
+
+static void ami_hotlist_menulabs(struct ami_menu_data **md)
+{
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_PROJECT, NM_TITLE, "Tree", 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPORT, NM_ITEM, "TreeExport", 'S', "TBImages:list_save",
+ ami_hotlist_menu_item_project_export, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND, NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_ALL, NM_SUB, "All", '+', NULL,
+ ami_hotlist_menu_item_project_expand_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_FOLDERS, NM_SUB, "Folders", 0, NULL,
+ ami_hotlist_menu_item_project_expand_folders, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_LINKS, NM_SUB, "Links", 0, NULL,
+ ami_hotlist_menu_item_project_expand_links, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE, NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_ALL, NM_SUB, "All", '-', NULL,
+ ami_hotlist_menu_item_project_collapse_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", 0, NULL,
+ ami_hotlist_menu_item_project_collapse_folders, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_LINKS, NM_SUB, "Links", 0, NULL,
+ ami_hotlist_menu_item_project_collapse_links, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
+ ami_hotlist_menu_item_project_snapshot, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_CLOSE, NM_ITEM, "CloseWindow", 'K', "TBImages:list_cancel",
+ ami_hotlist_menu_item_project_close, NULL, 0);
+
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
+
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWFOLDER, NM_ITEM, "TreeNewFolder", 'N', "TBImages:list_drawer",
+ ami_hotlist_menu_item_edit_newfolder, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWLINK, NM_ITEM, "TreeNewLink", 0, "TBImages:list_favouriteadd",
+ ami_hotlist_menu_item_edit_newlink, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT_EDIT, NM_ITEM, "TreeEdit", 'E', "TBImages:list_edit",
+ ami_hotlist_menu_item_edit_edit, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_SELECTALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
+ ami_hotlist_menu_item_edit_select_all, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
+ ami_hotlist_menu_item_edit_clear, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_DELETE, NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
+ ami_hotlist_menu_item_edit_delete, NULL, 0);
+
+ ami_menu_alloc_item(md, AMI_HOTLIST_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
+}
+
+static struct Menu *
+ami_hotlist_menu_create(struct ami_hotlist_window *hotlist_win)
+{
+ ami_hotlist_menulabs(hotlist_win->menu_data);
+ hotlist_win->imenu = ami_menu_layout(hotlist_win->menu_data, AMI_HOTLIST_M_LAST);
+ if(hotlist_win->imenu == NULL) return NULL;
+
+ return hotlist_win->imenu;
+}
+
+
+static nserror
+ami_hotlist_create_window(struct ami_hotlist_window *hotlist_win)
+{
+ struct ami_corewindow *ami_cw = (struct ami_corewindow *)&hotlist_win->core;
+
+ ami_cw->objects[GID_CW_WIN] = WindowObj,
+ WA_ScreenTitle, ami_gui_get_screen_title(),
+ WA_Title, ami_cw->wintitle,
+ WA_Activate, TRUE,
+ WA_DepthGadget, TRUE,
+ WA_DragBar, TRUE,
+ WA_CloseGadget, TRUE,
+ WA_SizeGadget, TRUE,
+ WA_SizeBRight, TRUE,
+ WA_Top, nsoption_int(hotlist_window_ypos),
+ WA_Left, nsoption_int(hotlist_window_xpos),
+ WA_Width, nsoption_int(hotlist_window_xsize),
+ WA_Height, nsoption_int(hotlist_window_ysize),
+ WA_PubScreen, scrn,
+ WA_ReportMouse, TRUE,
+ WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
+ IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
+ IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
+ WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
+ WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
+ WINDOW_SharedPort, sport,
+ WINDOW_HorizProp, 1,
+ WINDOW_VertProp, 1,
+ WINDOW_UserData, hotlist_win,
+ WINDOW_MenuStrip, ami_hotlist_menu_create(hotlist_win),
+ WINDOW_MenuUserData, WGUD_HOOK,
+ WINDOW_IconifyGadget, FALSE,
+ WINDOW_Position, WPOS_CENTERSCREEN,
+ WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
+ LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
+ GA_ID, GID_CW_DRAW,
+ SPACE_Transparent, TRUE,
+ SPACE_BevelStyle, BVS_DISPLAY,
+ GA_RelVerify, TRUE,
+ SpaceEnd,
+ EndGroup,
+ EndWindow;
+
+ if(ami_cw->objects[GID_CW_WIN] == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ return NSERROR_OK;
+}
+
+/**
+ * destroy a previously created hotlist view
+ */
+static void
+ami_hotlist_destroy(struct ami_corewindow *ami_cw)
+{
+ nserror res;
+
+ if(hotlist_window == NULL)
+ return;
+
+ res = hotlist_manager_fini();
+ if (res == NSERROR_OK) {
+ ami_hotlist_menu_free(hotlist_window);
+ res = ami_corewindow_fini(&hotlist_window->core); /* closes the window for us, frees hotlist_win */
+ hotlist_window = NULL;
+ }
+
+ ami_gui_hotlist_update_all();
+}
+
+
+/* exported interface documented in amiga/hotlist.h */
+nserror ami_hotlist_present(void)
+{
+ struct ami_hotlist_window *ncwin;
+ nserror res;
+
+ if(hotlist_window != NULL) {
+ //windowtofront()
+ return NSERROR_OK;
+ }
+
+ ncwin = calloc(1, sizeof(struct ami_hotlist_window));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("Cookies"));
+
+ res = ami_hotlist_create_window(ncwin);
+ if (res != NSERROR_OK) {
+ LOG("SSL UI builder init failed");
+ ami_utf8_free(ncwin->core.wintitle);
+ free(ncwin);
+ return res;
+ }
+
+ /* initialise Amiga core window */
+ ncwin->core.draw = ami_hotlist_draw;
+ ncwin->core.key = ami_hotlist_key;
+ ncwin->core.mouse = ami_hotlist_mouse;
+ ncwin->core.close = ami_hotlist_destroy;
+ ncwin->core.event = NULL;
+
+ res = ami_corewindow_init(&ncwin->core);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ res = hotlist_manager_init(ncwin->core.cb_table, (struct core_window *)ncwin);
+ if (res != NSERROR_OK) {
+ ami_utf8_free(ncwin->core.wintitle);
+ DisposeObject(ncwin->core.objects[GID_CW_WIN]);
+ free(ncwin);
+ return res;
+ }
+
+ hotlist_window = ncwin;
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in amiga/hotlist.h */
+void ami_hotlist_close(void)
+{
+ ami_hotlist_destroy((struct ami_corewindow *)hotlist_window);
+}
+
diff --git a/frontends/amiga/hotlist.h b/frontends/amiga/hotlist.h
index 113a2d1c0..588a72de8 100755..100644
--- a/frontends/amiga/hotlist.h
+++ b/frontends/amiga/hotlist.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -19,16 +19,18 @@
#ifndef AMIGA_HOTLIST_H
#define AMIGA_HOTLIST_H
-struct nsurl;
-struct treeview_window;
+#include "utils/nsurl.h"
-extern struct treeview_window *hotlist_window;
-
-void ami_hotlist_initialise(const char *hotlist_file);
-
-void ami_hotlist_free(const char *hotlist_file);
-
-nserror ami_hotlist_scan(void *userdata, int first_item, const char *folder, bool (*cb_add_item)(void *userdata, int level, int item, const char *title, struct nsurl *url, bool folder));
+/** Open the hotlist viewer */
+nserror ami_hotlist_present(void);
+/** Close the hotlist viewer
+ * normally this shouldn't be used; only exists for ARexx use
+ */
+void ami_hotlist_close(void);
+/** Scan the hotlist */
+nserror ami_hotlist_scan(void *userdata, int first_item, const char *folder,
+ bool (*cb_add_item)(void *userdata, int level, int item, const char *title, nsurl *url, bool folder));
#endif
+
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 83cfaa7df..d8159323e 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -73,7 +73,6 @@
#include "amiga/print.h"
#include "amiga/search.h"
#include "amiga/theme.h"
-#include "amiga/tree.h"
#include "amiga/utf8.h"
#include "amiga/schedule.h"
@@ -106,7 +105,7 @@ static bool menu_glyphs_loaded = false;
const char * const netsurf_version;
const char * const verdate;
-static nserror ami_menu_scan(struct tree *tree, struct ami_menu_data **md);
+static nserror ami_menu_scan(struct ami_menu_data **md);
void ami_menu_arexx_scan(struct ami_menu_data **md);
void ami_menu_set_check_toggled(void)
@@ -456,7 +455,7 @@ HOOKF(void, ami_menu_item_hotlist_add, APTR, window, struct IntuiMessage *)
HOOKF(void, ami_menu_item_hotlist_show, APTR, window, struct IntuiMessage *)
{
- ami_tree_open(hotlist_window, AMI_TREE_HOTLIST);
+ ami_hotlist_present();
}
HOOKF(void, ami_menu_item_hotlist_entries, APTR, window, struct IntuiMessage *)
@@ -992,7 +991,7 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
ami_init_menulabs(gwin->menu_data);
- ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin->menu_data); //\todo this needs to be MenuClass created
+ ami_menu_scan(gwin->menu_data); //\todo this needs to be MenuClass created
ami_menu_arexx_scan(gwin->menu_data);
gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
@@ -1092,7 +1091,7 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
return true;
}
-static nserror ami_menu_scan(struct tree *tree, struct ami_menu_data **md)
+static nserror ami_menu_scan(struct ami_menu_data **md)
{
return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}