Create menu on OS3 and 3 the same way (old GadTools method)

This makes it easier to switch to menuclass.
It also fixes a crash-on-exit bug on OS3.
This commit is contained in:
Chris Young 2015-09-06 09:12:26 +01:00
commit d1ccd3e53d
4 changed files with 27 additions and 53 deletions

View File

@ -3781,10 +3781,9 @@ gui_window_create(struct browser_window *bw,
(locked_screen == TRUE) && (locked_screen == TRUE) &&
(strcmp(nsoption_charp(pubscreen_name), "Workbench") == 0)) (strcmp(nsoption_charp(pubscreen_name), "Workbench") == 0))
iconifygadget = TRUE; iconifygadget = TRUE;
ami_create_menu(g->shared);
#ifndef __amigaos4__ struct Menu *menu = ami_menu_create(g->shared);
struct Menu *menu = ami_menu_create_os3(g->shared, g->shared->menu);
#endif
NewList(&g->shared->tab_list); NewList(&g->shared->tab_list);
g->tab_node = AllocClickTabNode(TNA_Text,messages_get("NetSurf"), g->tab_node = AllocClickTabNode(TNA_Text,messages_get("NetSurf"),
TNA_Number, 0, TNA_Number, 0,
@ -3933,11 +3932,7 @@ gui_window_create(struct browser_window *bw,
IDCMP_REFRESHWINDOW | IDCMP_REFRESHWINDOW |
IDCMP_ACTIVEWINDOW | IDCMP_EXTENDEDMOUSE, IDCMP_ACTIVEWINDOW | IDCMP_EXTENDEDMOUSE,
WINDOW_IconifyGadget, iconifygadget, WINDOW_IconifyGadget, iconifygadget,
#ifdef __amigaos4__
WINDOW_NewMenu, g->shared->menu,
#else
WINDOW_MenuStrip, menu, WINDOW_MenuStrip, menu,
#endif
WINDOW_MenuUserData, WGUD_HOOK, WINDOW_MenuUserData, WGUD_HOOK,
WINDOW_NewPrefsHook, &newprefs_hook, WINDOW_NewPrefsHook, &newprefs_hook,
WINDOW_IDCMPHook, &g->shared->scrollerhook, WINDOW_IDCMPHook, &g->shared->scrollerhook,
@ -4389,9 +4384,8 @@ static void gui_window_destroy(struct gui_window *g)
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_FORWARD]); DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_FORWARD]);
ami_ctxmenu_release_hook(g->shared->ctxmenu_hook); ami_ctxmenu_release_hook(g->shared->ctxmenu_hook);
ami_free_menulabs(g->shared); ami_free_menulabs(g->shared);
#ifndef __amigaos4__ ami_menu_free(g->shared);
ami_menu_free_os3(g->shared);
#endif
free(g->shared->wintitle); free(g->shared->wintitle);
ami_utf8_free(g->shared->status); ami_utf8_free(g->shared->status);
FreeVec(g->shared->svbuffer); FreeVec(g->shared->svbuffer);

View File

@ -140,10 +140,8 @@ struct gui_window_2 {
struct AppWindow *appwin; struct AppWindow *appwin;
struct MinList shared_pens; struct MinList shared_pens;
gui_pointer_shape mouse_pointer; gui_pointer_shape mouse_pointer;
#ifndef __amigaos4__ struct Menu *imenu; /* Intuition menu */
struct NewMenu *menu_os3; struct VisualInfo *vi; /* For GadTools menu */
struct VisualInfo *vi;
#endif
}; };
struct gui_window struct gui_window

View File

@ -704,29 +704,19 @@ static void ami_init_menulabs(struct gui_window_2 *gwin)
/* Menu refresh for hotlist */ /* Menu refresh for hotlist */
void ami_menu_refresh(struct gui_window_2 *gwin) void ami_menu_refresh(struct gui_window_2 *gwin)
{ {
struct Menu *menu;
SetAttrs(gwin->objects[OID_MAIN], SetAttrs(gwin->objects[OID_MAIN],
#ifdef __amigaos4__
WINDOW_NewMenu, NULL,
#else
WINDOW_MenuStrip, NULL, WINDOW_MenuStrip, NULL,
#endif
TAG_DONE); TAG_DONE);
#ifndef __amigaos4__ ami_menu_free(gwin);
ami_menu_free_os3(gwin->menu_os3);
#endif
ami_free_menulabs(gwin); ami_free_menulabs(gwin);
ami_create_menu(gwin);
#ifndef __amigaos4__ menu = ami_menu_create(gwin);
gwin->menu_os3 = ami_menu_create_os3(gwin, gwin->menu);
#endif
SetAttrs(gwin->objects[OID_MAIN], SetAttrs(gwin->objects[OID_MAIN],
#ifdef __amigaos4__ WINDOW_MenuStrip, menu,
WINDOW_NewMenu, gwin->menu,
#else
WINDOW_MenuStrip, gwin->menu_os3,
#endif
TAG_DONE); TAG_DONE);
} }
@ -905,25 +895,13 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
return gwin; return gwin;
} }
#ifndef __amigaos4__ void ami_menu_free(struct gui_window_2 *gwin)
void ami_menu_free_os3(struct gui_window_2 *gwin)
{ {
FreeMenus(gwin->menu_os3); FreeMenus(gwin->imenu);
FreeVisualInfo(gwin->vi); FreeVisualInfo(gwin->vi);
} }
struct Menu *ami_menu_create_os3(struct gui_window_2 *gwin, struct NewMenu *newmenu) struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
gwin->vi = GetVisualInfo(scrn, TAG_DONE);
gwin->menu_os3 = CreateMenus(newmenu, TAG_DONE);
LayoutMenus(gwin->menu_os3, gwin->vi,
GTMN_NewLookMenus, TRUE, TAG_DONE);
return gwin->menu_os3;
}
#endif
struct NewMenu *ami_create_menu(struct gui_window_2 *gwin)
{ {
gwin->menu = ami_misc_allocvec_clear(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1), 0); gwin->menu = ami_misc_allocvec_clear(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1), 0);
ami_init_menulabs(gwin); ami_init_menulabs(gwin);
@ -944,7 +922,14 @@ struct NewMenu *ami_create_menu(struct gui_window_2 *gwin)
if(nsoption_bool(background_images) == true) if(nsoption_bool(background_images) == true)
gwin->menu[M_IMGBACK].nm_Flags |= CHECKED; gwin->menu[M_IMGBACK].nm_Flags |= CHECKED;
return(gwin->menu); gwin->vi = GetVisualInfo(scrn, TAG_DONE);
gwin->imenu = CreateMenus(gwin->menu, TAG_DONE);
LayoutMenus(gwin->imenu, gwin->vi,
GTMN_NewLookMenus, TRUE, TAG_DONE);
/**\todo do we even need to store/keep gwin->menu? **/
return gwin->imenu;
} }
void ami_menu_arexx_scan(struct gui_window_2 *gwin) void ami_menu_arexx_scan(struct gui_window_2 *gwin)

View File

@ -137,15 +137,12 @@ struct gui_window_2 *ami_menu_window_close;
bool ami_menu_check_toggled; bool ami_menu_check_toggled;
void ami_free_menulabs(struct gui_window_2 *gwin); void ami_free_menulabs(struct gui_window_2 *gwin);
struct NewMenu *ami_create_menu(struct gui_window_2 *gwin); struct Menu *ami_menu_create(struct gui_window_2 *gwin);
void ami_menu_refresh(struct gui_window_2 *gwin); void ami_menu_refresh(struct gui_window_2 *gwin);
void ami_menu_update_checked(struct gui_window_2 *gwin); void ami_menu_update_checked(struct gui_window_2 *gwin);
void ami_menu_update_disabled(struct gui_window *g, hlcache_handle *c); void ami_menu_update_disabled(struct gui_window *g, hlcache_handle *c);
void ami_menu_free_glyphs(void); void ami_menu_free_glyphs(void);
void ami_menu_free(struct gui_window_2 *gwin);
#ifndef __amigaos4__
void ami_menu_free_os3(struct gui_window_2 *gwin);
struct Menu *ami_menu_create_os3(struct gui_window_2 *gwin, struct NewMenu *newmenu);
#endif
#endif #endif