Handle closing windows and quitting from the menu differently

This commit is contained in:
Chris Young 2016-07-03 17:09:11 +01:00
parent 65bf58e4a1
commit ea9932dd00
4 changed files with 22 additions and 17 deletions

View File

@ -2544,16 +2544,14 @@ static void ami_handle_msg(void)
// ReplyMsg((struct Message *)message);
}
if(gwin->closed == true) {
ami_gui_close_window(gwin);
}
} while((node = nnode));
if(ami_menu_window_close)
{
if(ami_menu_window_close == (void *)AMI_MENU_WINDOW_CLOSE_ALL)
if(ami_menu_quit_selected() == true){
ami_quit_netsurf();
else
ami_gui_close_window(ami_menu_window_close);
ami_menu_window_close = NULL;
}
if(ami_menu_get_check_toggled() == true) {

View File

@ -144,6 +144,7 @@ struct gui_window_2 {
gui_pointer_shape mouse_pointer;
struct Menu *imenu; /* Intuition menu */
struct VisualInfo *vi; /* For GadTools menu */
bool closed; /* Window has been closed (via menu) */
};
struct gui_window

View File

@ -87,8 +87,7 @@ enum {
NSA_GLYPH_MAX
};
struct gui_window_2 *ami_menu_window_close = NULL;
static bool menu_quit = false;
static bool ami_menu_check_toggled = false;
static BOOL menualreadyinit;
static Object *menu_glyph[NSA_GLYPH_MAX];
@ -113,6 +112,11 @@ bool ami_menu_get_check_toggled(void)
return check_toggled;
}
bool ami_menu_quit_selected(void)
{
return menu_quit;
}
/*
* The below functions are called automatically by window.class when menu items are selected.
*/
@ -175,7 +179,7 @@ HOOKF(void, ami_menu_item_project_closewin, APTR, window, struct IntuiMessage *)
struct gui_window_2 *gwin;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
ami_menu_window_close = gwin;
gwin->closed = true;
}
HOOKF(void, ami_menu_item_project_print, APTR, window, struct IntuiMessage *)
@ -253,7 +257,7 @@ HOOKF(void, ami_menu_item_project_about, APTR, window, struct IntuiMessage *)
HOOKF(void, ami_menu_item_project_quit, APTR, window, struct IntuiMessage *)
{
ami_menu_window_close = AMI_MENU_WINDOW_CLOSE_ALL;
menu_quit = true;
}
HOOKF(void, ami_menu_item_edit_cut, APTR, window, struct IntuiMessage *)

View File

@ -129,14 +129,9 @@ enum {
#define AMI_MENU_BACKIMG FULLMENUNUM(2,8,1)
#define AMI_MENU_JS FULLMENUNUM(2,9,0)
/** A special value for ami_menu_window_close */
#define AMI_MENU_WINDOW_CLOSE_ALL (void *)1
struct gui_window;
struct gui_window_2;
extern struct gui_window_2 *ami_menu_window_close;
void ami_free_menulabs(struct gui_window_2 *gwin);
struct Menu *ami_menu_create(struct gui_window_2 *gwin);
void ami_menu_refresh(struct gui_window_2 *gwin);
@ -158,5 +153,12 @@ void ami_menu_set_check_toggled(void);
* \return true if the menus need refreshing
*/
bool ami_menu_get_check_toggled(void);
/**
* Gets if NetSurf has been quit from the menu
*
* \return true if NetSurf has been quit
*/
bool ami_menu_quit_selected(void);
#endif