summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2016-01-31 17:58:27 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2016-01-31 17:58:27 +0000
commitcd0bcc421a2ae5a4bf64f4e21c92a0004ef7ece8 (patch)
tree95c40cb2c6907de7eae5b3507e77c69d1c9c104d
parentcc0abb66b092f2198e1931ee6921fe79da4ed94d (diff)
downloadnetsurf-cd0bcc421a2ae5a4bf64f4e21c92a0004ef7ece8.tar.gz
netsurf-cd0bcc421a2ae5a4bf64f4e21c92a0004ef7ece8.tar.bz2
Add an option to close inactive tabs to the tab bar context menu
-rw-r--r--amiga/arexx.c2
-rw-r--r--amiga/ctxmenu.c14
-rw-r--r--amiga/gui.c44
-rw-r--r--amiga/gui.h16
-rw-r--r--amiga/menu.c2
-rw-r--r--resources/FatMessages5
6 files changed, 62 insertions, 21 deletions
diff --git a/amiga/arexx.c b/amiga/arexx.c
index 1960af0c1..412fc4056 100644
--- a/amiga/arexx.c
+++ b/amiga/arexx.c
@@ -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;
}
diff --git a/amiga/ctxmenu.c b/amiga/ctxmenu.c
index e9de27092..8d49d4f15 100644
--- a/amiga/ctxmenu.c
+++ b/amiga/ctxmenu.c
@@ -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;
}
diff --git a/amiga/gui.c b/amiga/gui.c
index e4cdd1831..15a5e9d64 100644
--- a/amiga/gui.c
+++ b/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)
diff --git a/amiga/gui.h b/amiga/gui.h
index 38eee52bf..92ede2a45 100644
--- a/amiga/gui.h
+++ b/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.
*
diff --git a/amiga/menu.c b/amiga/menu.c
index 145774480..558475828 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -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",
diff --git a/resources/FatMessages b/resources/FatMessages
index 67de72a62..6b66685c0 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -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