summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2017-01-15 17:51:55 (GMT)
committer Chris Young <chris@unsatisfactorysoftware.co.uk>2017-01-15 17:51:55 (GMT)
commitb78d6f458e5d5cb9c78d7430aacf10abd227eb32 (patch)
tree9cd1ad8616923aa47b297deec72a2bc7c701a296
parentb8640956d48af03f2f7f6c07e66958fa825a4972 (diff)
downloadnetsurf-b78d6f458e5d5cb9c78d7430aacf10abd227eb32.tar.gz
netsurf-b78d6f458e5d5cb9c78d7430aacf10abd227eb32.tar.bz2
Attempt hotlist menu refresh
-rw-r--r--frontends/amiga/gui.c3
-rw-r--r--frontends/amiga/gui.h2
-rw-r--r--frontends/amiga/gui_menu.c44
-rw-r--r--frontends/amiga/gui_menu.h4
-rw-r--r--frontends/amiga/menu.c37
-rw-r--r--frontends/amiga/menu.h5
6 files changed, 79 insertions, 16 deletions
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index d660e93..c6ca886 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -3327,6 +3327,8 @@ void ami_gui_hotlist_update_all(void)
if(IsMinListEmpty(window_list)) return;
+ ami_gui_menu_refresh_hotlist();
+
node = (struct nsObject *)GetHead((struct List *)window_list);
do {
@@ -3336,7 +3338,6 @@ void ami_gui_hotlist_update_all(void)
if(node->Type == AMINS_WINDOW)
{
ami_gui_hotlist_toolbar_update(gwin);
- //ami_gui_menu_refresh_hotlist(gwin);
}
} while((node = nnode));
}
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index 77f6839..07ff922 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -134,7 +134,7 @@ struct gui_window_2 {
int temp;
bool redraw_scroll;
bool new_content;
- struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1];
+ struct ami_menu_data *menu_data[AMI_MENU_AREXX_MAX + 1]; /* only for GadTools menus */
ULONG hotlist_items;
Object *restrict hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX];
struct List hotlist_toolbar_list;
diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c
index 6b33194..c453c64 100644
--- a/frontends/amiga/gui_menu.c
+++ b/frontends/amiga/gui_menu.c
@@ -80,8 +80,11 @@
#include "amiga/utf8.h"
#include "amiga/schedule.h"
+#ifdef __amigaos4__
static struct Menu *restrict gui_menu = NULL;
static int gui_menu_count = 0;
+struct ami_menu_data *gui_menu_data[AMI_MENU_AREXX_MAX + 1];
+#endif
static bool ami_menu_check_toggled = false;
static bool menu_quit = false;
@@ -900,6 +903,12 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
static nserror ami_menu_scan(struct ami_menu_data **md)
{
+ ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
+ ami_menu_item_hotlist_add, NULL, 0);
+ ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
+ ami_menu_item_hotlist_show, NULL, 0);
+ ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+
return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
}
@@ -1002,11 +1011,7 @@ static void ami_init_menulabs(struct ami_menu_data **md)
ami_menu_item_browser_redraw, NULL, 0);
ami_menu_alloc_item(md, M_HOTLIST, NM_TITLE, "Hotlist", NULL, NULL, NULL, NULL, 0);
- ami_menu_alloc_item(md, M_HLADD, NM_ITEM, "HotlistAdd", "B", "TBImages:list_favouriteadd",
- ami_menu_item_hotlist_add, NULL, 0);
- ami_menu_alloc_item(md, M_HLSHOW, NM_ITEM,"HotlistShowNS", "H", "TBImages:list_favourite",
- ami_menu_item_hotlist_show, NULL, 0);
- ami_menu_alloc_item(md, M_BAR_H1, NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL, 0);
+ /* see ami_menu_scan for the rest of this menu */
ami_menu_alloc_item(md, M_PREFS, NM_TITLE, "Settings", NULL, NULL, NULL, NULL, 0);
ami_menu_alloc_item(md, M_PREDIT, NM_ITEM, "SettingsEdit", NULL, "TBImages:list_prefs",
@@ -1027,21 +1032,25 @@ static void ami_init_menulabs(struct ami_menu_data **md)
struct Menu *ami_gui_menu_create(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
if(gui_menu != NULL) {
gwin->imenu = gui_menu;
gui_menu_count++;
return gwin->imenu;
}
- }
+ ami_init_menulabs(gui_menu_data);
+ ami_menu_scan(gui_menu_data);
+ ami_menu_arexx_scan(gui_menu_data);
+ gwin->imenu = ami_menu_layout(gui_menu_data, AMI_MENU_AREXX_MAX);
- ami_init_menulabs(gwin->menu_data);
- ami_menu_scan(gwin->menu_data);
- ami_menu_arexx_scan(gwin->menu_data);
- gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
-
- if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
gui_menu = gwin->imenu;
gui_menu_count++;
+#endif
+ } else {
+ ami_init_menulabs(gwin->menu_data);
+ ami_menu_scan(gwin->menu_data);
+ ami_menu_arexx_scan(gwin->menu_data);
+ gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
}
return gwin->imenu;
@@ -1081,14 +1090,16 @@ static void ami_free_menulabs(struct ami_menu_data **md)
void ami_gui_menu_free(struct gui_window_2 *gwin)
{
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+#ifdef __amigaos4__
gui_menu_count--;
if(gui_menu_count == 0) {
- ami_free_menulabs(gwin->menu_data);
+ ami_free_menulabs(gui_menu_data);
// if we detach our menu from the window we need to do this manually
DisposeObject((Object *)gui_menu);
gui_menu = NULL;
}
+#endif
} else {
ami_free_menulabs(gwin->menu_data);
FreeMenus(gwin->imenu);
@@ -1100,3 +1111,10 @@ bool ami_gui_menu_quit_selected(void)
return menu_quit;
}
+void ami_gui_menu_refresh_hotlist(void)
+{
+#ifdef __amigaos4__
+ ami_menu_refresh(gui_menu, gui_menu_data, M_HOTLIST, AMI_MENU_HOTLIST_MAX, ami_menu_scan);
+#endif
+}
+
diff --git a/frontends/amiga/gui_menu.h b/frontends/amiga/gui_menu.h
index a9de69a..16fc720 100644
--- a/frontends/amiga/gui_menu.h
+++ b/frontends/amiga/gui_menu.h
@@ -142,6 +142,10 @@ void ami_gui_menu_set_checked(struct Menu *menu, int item, bool check);
*/
void ami_gui_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
+/**
+ * Refresh the Hotlist menu
+ */
+void ami_gui_menu_refresh_hotlist(void);
/**
* Gets if NetSurf has been quit from the menu
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 04c6eb0..cfbbd8d 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -80,7 +80,7 @@ bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg)
}
/* menu creation code */
-static void ami_menu_free_lab_item(struct ami_menu_data **md, int i)
+void ami_menu_free_lab_item(struct ami_menu_data **md, int i)
{
if(md[i] == NULL) return;
if(md[i]->menulab &&
@@ -435,3 +435,38 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
}
}
+void ami_menu_refresh(struct Menu *menu, struct ami_menu_data **md, int menu_item, int max,
+ nserror (*cb)(struct ami_menu_data **md))
+{
+#ifdef __amigaos4__
+ Object *restrict obj;
+ Object *restrict menu_item_obj;
+ int i;
+
+ if(menu == NULL) return;
+
+ if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 54, 6)) {
+ /* find the address of the menu */
+ menu_item_obj = (Object *)IDoMethod((Object *)menu, MM_FINDID, 0, menu_item);
+
+ /* remove all children */
+ while((obj = (Object *)IDoMethod(menu_item_obj, MM_NEXTCHILD, 0, NULL)) != NULL) {
+ IDoMethod(menu_item_obj, OM_REMMEMBER, obj);
+ /* do we need to disposeobject? */
+ }
+
+ /* free associated data */
+ for(i = (menu_item + 1); i <= max; i++) {
+ if(md[i] == NULL) continue;
+ ami_menu_free_lab_item(md, i);
+ }
+
+ /* get current data */
+ cb(md);
+
+ /* re-add items to menu */
+ ami_menu_layout_mc_recursive(menu_item_obj, md, NM_ITEM, (menu_item + 1), max);
+ }
+#endif
+}
+
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index f8a3f17..358faa4 100644
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -45,6 +45,11 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
void *restrict func, void *restrict hookdata, UWORD flags);
struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
+void ami_menu_free_lab_item(struct ami_menu_data **md, int i);
+
+/* refresh a menu's children */
+void ami_menu_refresh(struct Menu *menu, struct ami_menu_data **md, int menu_item, int max,
+ nserror (*cb)(struct ami_menu_data **md));
/**
* Get the selected state of a menu item