mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-20 16:34:14 +03:00
Add an option to close inactive tabs to the tab bar context menu
This commit is contained in:
parent
cc0abb66b0
commit
cd0bcc421a
@ -614,7 +614,7 @@ STATIC VOID rx_close(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((un
|
||||
gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
||||
else if(cmd->ac_ArgList[0])
|
||||
{
|
||||
ami_close_all_tabs(gw->shared);
|
||||
ami_gui_close_window(gw->shared);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ enum {
|
||||
|
||||
/* Tabs */
|
||||
AMI_CTX_ID_TABNEW,
|
||||
AMI_CTX_ID_TABCLOSE_OTHER,
|
||||
|
||||
AMI_CTX_ID_MAX
|
||||
};
|
||||
@ -251,6 +252,14 @@ HOOKF(void, ami_ctxmenu_item_tabnew, APTR, window, struct IntuiMessage *)
|
||||
ami_gui_new_blank_tab(gwin);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_ctxmenu_item_tabclose_other, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
struct gui_window_2 *gwin;
|
||||
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
||||
ami_gui_close_inactive_tabs(gwin);
|
||||
}
|
||||
|
||||
/** Hook for history context menu entries **/
|
||||
HOOKF(void, ami_ctxmenu_item_history, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
@ -471,8 +480,10 @@ void ami_ctxmenu_init(void)
|
||||
ami_ctxmenu_alloc_item(AMI_CTX_ID_FRAMESHOW, "FrameOnly", NULL, "TBImages:list_preview",
|
||||
ami_ctxmenu_item_frameshow);
|
||||
|
||||
ami_ctxmenu_alloc_item(AMI_CTX_ID_TABNEW, "NewTab", "T", "TBImages:list_add",
|
||||
ami_ctxmenu_alloc_item(AMI_CTX_ID_TABNEW, "NewTab", "T", "TBImages:list_tab",
|
||||
ami_ctxmenu_item_tabnew);
|
||||
ami_ctxmenu_alloc_item(AMI_CTX_ID_TABCLOSE_OTHER, "CloseInactive", "K", "TBImages:list_cancel",
|
||||
ami_ctxmenu_item_tabclose_other);
|
||||
}
|
||||
|
||||
/********************************
|
||||
@ -582,6 +593,7 @@ struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin)
|
||||
MEnd;
|
||||
|
||||
ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_TABNEW, gwin);
|
||||
ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_TABCLOSE_OTHER, gwin);
|
||||
|
||||
return (struct Menu *)gwin->clicktab_ctxmenu;
|
||||
}
|
||||
|
44
amiga/gui.c
44
amiga/gui.c
@ -2455,7 +2455,7 @@ static void ami_handle_msg(void)
|
||||
break;
|
||||
|
||||
case WMHI_CLOSEWINDOW:
|
||||
ami_close_all_tabs(gwin);
|
||||
ami_gui_close_window(gwin);
|
||||
break;
|
||||
#ifdef __amigaos4__
|
||||
case WMHI_ICONIFY:
|
||||
@ -2524,7 +2524,7 @@ static void ami_handle_msg(void)
|
||||
if(ami_menu_window_close == (void *)AMI_MENU_WINDOW_CLOSE_ALL)
|
||||
ami_quit_netsurf();
|
||||
else
|
||||
ami_close_all_tabs(ami_menu_window_close);
|
||||
ami_gui_close_window(ami_menu_window_close);
|
||||
|
||||
ami_menu_window_close = NULL;
|
||||
}
|
||||
@ -2914,7 +2914,7 @@ void ami_quit_netsurf(void)
|
||||
/* This also closes windows that are attached to the
|
||||
* gui_window, such as local history and find. */
|
||||
ShowWindow(gwin->win, WINDOW_BACKMOST);
|
||||
ami_close_all_tabs(gwin);
|
||||
ami_gui_close_window(gwin);
|
||||
break;
|
||||
|
||||
case AMINS_GUIOPTSWINDOW:
|
||||
@ -4386,36 +4386,46 @@ gui_window_create(struct browser_window *bw,
|
||||
return g;
|
||||
}
|
||||
|
||||
void ami_close_all_tabs(struct gui_window_2 *gwin)
|
||||
static void ami_gui_close_tabs(struct gui_window_2 *gwin, bool other_tabs)
|
||||
{
|
||||
struct Node *tab;
|
||||
struct Node *ntab;
|
||||
|
||||
struct gui_window *gw;
|
||||
|
||||
if((gwin->tabs > 1) && (nsoption_bool(tab_close_warn) == true)) {
|
||||
char *req_body = ami_utf8_easy(messages_get("MultiTabClose"));
|
||||
int32 res = ami_warn_user_multi(req_body, "Yes", "No", gwin->win);
|
||||
free(req_body);
|
||||
|
||||
|
||||
if(res == 0) return;
|
||||
}
|
||||
|
||||
if(gwin->tabs)
|
||||
{
|
||||
|
||||
if(gwin->tabs) {
|
||||
tab = GetHead(&gwin->tab_list);
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
ntab=GetSucc(tab);
|
||||
GetClickTabNodeAttrs(tab,
|
||||
TNA_UserData,&gwin->gw,
|
||||
TNA_UserData,&gw,
|
||||
TAG_DONE);
|
||||
browser_window_destroy(gwin->gw->bw);
|
||||
|
||||
if((other_tabs == false) || (gwin->gw != gw)) {
|
||||
browser_window_destroy(gw->bw);
|
||||
}
|
||||
} while((tab=ntab));
|
||||
} else {
|
||||
if(other_tabs == false) browser_window_destroy(gwin->gw->bw);
|
||||
}
|
||||
else
|
||||
{
|
||||
browser_window_destroy(gwin->gw->bw);
|
||||
}
|
||||
}
|
||||
|
||||
void ami_gui_close_window(struct gui_window_2 *gwin)
|
||||
{
|
||||
ami_gui_close_tabs(gwin, false);
|
||||
}
|
||||
|
||||
void ami_gui_close_inactive_tabs(struct gui_window_2 *gwin)
|
||||
{
|
||||
ami_gui_close_tabs(gwin, true);
|
||||
}
|
||||
|
||||
static void gui_window_destroy(struct gui_window *g)
|
||||
|
16
amiga/gui.h
16
amiga/gui.h
@ -169,7 +169,6 @@ struct gui_window
|
||||
};
|
||||
|
||||
void ami_get_msg(void);
|
||||
void ami_close_all_tabs(struct gui_window_2 *gwin);
|
||||
void ami_try_quit(void);
|
||||
void ami_quit_netsurf(void);
|
||||
void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw);
|
||||
@ -189,6 +188,21 @@ char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail);
|
||||
int ami_gui_count_windows(int window, int *tabs);
|
||||
void ami_gui_set_scale(struct gui_window *gw, float scale);
|
||||
|
||||
|
||||
/**
|
||||
* Close a window and all tabs attached to it.
|
||||
*
|
||||
* @param gwin gui_window_2 to act upon.
|
||||
*/
|
||||
void ami_gui_close_window(struct gui_window_2 *gwin);
|
||||
|
||||
/**
|
||||
* Close all tabs in a window except the active one.
|
||||
*
|
||||
* @param gwin gui_window_2 to act upon.
|
||||
*/
|
||||
void ami_gui_close_inactive_tabs(struct gui_window_2 *gwin);
|
||||
|
||||
/**
|
||||
* Compatibility function to get space.gadget render area.
|
||||
*
|
||||
|
@ -600,7 +600,7 @@ static void ami_init_menulabs(struct gui_window_2 *gwin)
|
||||
ami_menu_alloc_item(gwin, M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL);
|
||||
ami_menu_alloc_item(gwin, M_NEWWIN, NM_ITEM, "NewWindowNS", 'N', "TBImages:list_app",
|
||||
ami_menu_item_project_newwin, NULL);
|
||||
ami_menu_alloc_item(gwin, M_NEWTAB, NM_ITEM, "NewTab", 'T', "TBImages:list_add",
|
||||
ami_menu_alloc_item(gwin, M_NEWTAB, NM_ITEM, "NewTab", 'T', "TBImages:list_tab",
|
||||
ami_menu_item_project_newtab, NULL);
|
||||
ami_menu_alloc_item(gwin, M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
||||
ami_menu_alloc_item(gwin, M_OPEN, NM_ITEM, "OpenFile", 'O', "TBImages:list_folder_misc",
|
||||
|
@ -967,6 +967,11 @@ de.all.Close:Schließen
|
||||
fr.all.Close:Fermer
|
||||
it.all.Close:Chiudi
|
||||
nl.all.Close:Sluit
|
||||
en.ami.CloseInactive:Close inactive tabs
|
||||
de.ami.CloseInactive:Close inactive tabs
|
||||
fr.ami.CloseInactive:Close inactive tabs
|
||||
it.ami.CloseInactive:Close inactive tabs
|
||||
nl.ami.CloseInactive:Close inactive tabs
|
||||
en.all.ObjShow:Show object
|
||||
de.all.ObjShow:Zeige Objekt
|
||||
fr.all.ObjShow:Afficher l'objet
|
||||
|
Loading…
x
Reference in New Issue
Block a user