summaryrefslogtreecommitdiff
path: root/amiga/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'amiga/menu.c')
-rw-r--r--amiga/menu.c73
1 files changed, 8 insertions, 65 deletions
diff --git a/amiga/menu.c b/amiga/menu.c
index 50f48a919..6c67b0424 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -73,14 +73,6 @@ enum {
NSA_GLYPH_MAX
};
-struct ami_hotlist_ctx {
- struct gui_window_2 *gw;
- int level;
- int item;
- bool in_menu;
-};
-
-
BOOL menualreadyinit;
const char * const netsurf_version;
const char * const verdate;
@@ -543,15 +535,14 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
gwin->menu[item].nm_Label = NULL;
}
-static nserror ami_menu_hotlist_add(void *ctx, const char *title, nsurl *url, bool is_folder)
+static bool ami_menu_hotlist_add(struct gui_window_2 *gw, int level, int item, const char *title, nsurl *url, bool is_folder)
{
- struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
UBYTE type;
char *icon;
- if(menu_ctx->item >= AMI_MENU_HOTLIST_MAX) return NSERROR_OK;
+ if(item >= AMI_MENU_HOTLIST_MAX) return false;
- switch(menu_ctx->level) {
+ switch(level) {
case 1:
type = NM_ITEM;
break;
@@ -560,7 +551,7 @@ static nserror ami_menu_hotlist_add(void *ctx, const char *title, nsurl *url, bo
break;
default:
/* entries not at level 1 or 2 are not able to be added */
- return NSERROR_OK;
+ return false;
break;
}
@@ -570,65 +561,17 @@ static nserror ami_menu_hotlist_add(void *ctx, const char *title, nsurl *url, bo
icon = "icons/content.png";
}
- ami_menu_alloc_item(menu_ctx->gw, menu_ctx->item, type, title,
+ ami_menu_alloc_item(gw, item, type, title,
0, icon, ami_menu_item_hotlist_entries, (void *)url);
if((is_folder == true) && (type == NM_SUB))
- menu_ctx->gw->menu[menu_ctx->item].nm_Flags = NM_ITEMDISABLED;
-
- menu_ctx->item++;
-
- return NSERROR_OK;
-}
+ gw->menu[item].nm_Flags = NM_ITEMDISABLED;
-static nserror ami_menu_hotlist_folder_enter_cb(void *ctx, const char *title)
-{
- struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
-
- if(menu_ctx->in_menu == true) {
- ami_menu_hotlist_add(menu_ctx, title, NULL, true);
- } else {
- if((menu_ctx->level == 0) && (strcmp(title, messages_get("HotlistMenu")) == 0))
- menu_ctx->in_menu = true;
- }
- menu_ctx->level++;
- return NSERROR_OK;
-}
-
-static nserror ami_menu_hotlist_address_cb(void *ctx, nsurl *url, const char *title)
-{
- struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
-
- if(menu_ctx->in_menu == true)
- ami_menu_hotlist_add(menu_ctx, title, url, false);
-
- return NSERROR_OK;
-}
-
-static nserror ami_menu_hotlist_folder_leave_cb(void *ctx)
-{
- struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
-
- menu_ctx->level--;
-
- if((menu_ctx->in_menu == true) && (menu_ctx->level == 0))
- menu_ctx->in_menu = false;
-
- return NSERROR_OK;
+ return true;
}
static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
{
- struct ami_hotlist_ctx ctx;
-
- ctx.level = 0;
- ctx.item = AMI_MENU_HOTLIST;
- ctx.in_menu = false;
- ctx.gw = gwin;
-
- return hotlist_iterate(&ctx,
- ami_menu_hotlist_folder_enter_cb,
- ami_menu_hotlist_address_cb,
- ami_menu_hotlist_folder_leave_cb);
+ return ami_hotlist_scan(gwin, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}
void ami_menu_update_checked(struct gui_window_2 *gwin)