diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-02-05 17:37:59 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-02-05 17:37:59 +0000 |
commit | 3478926e3d060e227b08381925ee9bd307fd63e3 (patch) | |
tree | d557dd8604037320dbc9da54483e689aa7ce3b95 | |
parent | 0233716a1aeab439b0195408a76285fd2ecbbe93 (diff) |
added close other tabs menu item (thx $ergi0)
git-svn-id: http://svn.miranda-ng.org/main/trunk@3440 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/TabSRMM/res/resource.rc | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/container.cpp | 54 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/src/globals.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/hotkeyhandler.cpp | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/src/include/functions.h | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/include/msgs.h | 1 | ||||
-rw-r--r-- | plugins/TabSRMM/src/include/resource.h | 2 |
8 files changed, 67 insertions, 2 deletions
diff --git a/plugins/TabSRMM/res/resource.rc b/plugins/TabSRMM/res/resource.rc index 9e90a70fec..12cd9ef81b 100644 --- a/plugins/TabSRMM/res/resource.rc +++ b/plugins/TabSRMM/res/resource.rc @@ -664,6 +664,8 @@ BEGIN POPUP "Tabmenu"
BEGIN
MENUITEM "Close Tab", ID_TABMENU_CLOSETAB
+ MENUITEM "Close Other Tabs", ID_TABMENU_CLOSEOTHERTABS
+ MENUITEM SEPARATOR
MENUITEM "Leave Chat Room", ID_TABMENU_LEAVECHATROOM
MENUITEM SEPARATOR
MENUITEM "Save Tab Position", ID_TABMENU_SAVETABPOSITION
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index 176999fad7..1f78880826 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -1016,6 +1016,9 @@ panel_found: else
SendMessage(hwndDlg, DM_CLOSETABATMOUSE, 0, (LPARAM)&pt1);
break;
+ case ID_TABMENU_CLOSEOTHERTABS:
+ CloseOtherTabs(hwndTab, *dat);
+ break;
case ID_TABMENU_SAVETABPOSITION:
M->WriteDword(dat->hContact, SRMSGMOD_T, "tabindex", dat->iTabID * 100);
break;
@@ -2225,6 +2228,41 @@ int TSAPI GetTabIndexFromHWND(HWND hwndTab, HWND hwnd) return -1;
}
+
+/*
+ * search the list of tabs and return the tab (by index) which "belongs" to the given
+ * hwnd. The hwnd is the handle of a message dialog childwindow. At creation,
+ * the dialog handle is stored in the TCITEM.lParam field, because we need
+ * to know the owner of the tab.
+ *
+ * hwndTab: handle of the tab control itself.
+ * hwnd: handle of a message dialog.
+ *
+ * returns the tab index (zero based), -1 if no tab is found (which SHOULD not
+ * really happen, but who knows... ;))
+ */
+
+HWND TSAPI GetHWNDFromTabIndex(HWND hwndTab, int idx)
+{
+ TCITEM item;
+ int i = 0;
+ int iItems;
+
+ iItems = TabCtrl_GetItemCount(hwndTab);
+
+ ZeroMemory((void*)&item, sizeof(item));
+ item.mask = TCIF_PARAM;
+
+ for (i=0; i < iItems; i++)
+ {
+ TabCtrl_GetItem(hwndTab, i, &item);
+ if (i == idx)
+ return (HWND)item.lParam;
+ }
+ return NULL;
+}
+
+
/*
* activates the tab belonging to the given client HWND (handle of the actual
* message window.
@@ -2261,6 +2299,22 @@ int TSAPI GetTabItemFromMouse(HWND hwndTab, POINT *pt) return TabCtrl_HitTest(hwndTab, &tch);
}
+
+/*enumerates tabs and closes all of them, but the one in dat */
+void TSAPI CloseOtherTabs(HWND hwndTab, TWindowData &dat)
+{
+ for (int idxt = 0; idxt < dat.pContainer->iChilds; )
+ {
+ HWND otherTab = GetHWNDFromTabIndex(hwndTab, idxt);
+ if (otherTab != NULL && otherTab != dat.hwnd)
+ {
+ SendMessage(otherTab, WM_CLOSE, 1, 0);
+ }
+ else
+ ++idxt;
+ }
+}
+
/*
* cut off contact name to the option value set via Options->Tabbed messaging
* some people were requesting this, because really long contact list names
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 53e3374061..eadc6e55b4 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -200,6 +200,9 @@ LRESULT TSAPI DM_GenericHotkeysCheck(MSG *message, TWindowData *dat) if (dat->pContainer->SideBar->isActive())
SendMessage(hwndDlg, WM_COMMAND, IDC_TOGGLESIDEBAR, 0);
return 1;
+ case TABSRMM_HK_CLOSE_OTHER:
+ CloseOtherTabs(GetDlgItem(dat->pContainer->hwnd, IDC_MSGTABS), *dat);
+ return 1;
default:
break;
}
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index f05f0f9ff3..6fc0edb842 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -746,7 +746,7 @@ void CGlobals::logStatusChange(WPARAM wParam, const CContactCache *c) DWORD dwMask = M->GetDword(hContact, SRMSGMOD_T, "mwmask", 0);
DWORD dwFlags = M->GetDword(hContact, SRMSGMOD_T, "mwflags", 0);
- bool fLocal = M->GetByte(hContact, "logstatuschanges", 0);
+ BYTE fLocal = M->GetByte(hContact, "logstatuschanges", 0);
if (fGlobal || fLocal) {
/*
diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index fc75cb1fe4..a66951c93e 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -74,7 +74,8 @@ static HOTKEYDESC _hotkeydescs[] = { { 0, "tabsrmm_muc_cmgr", LPGEN("Channel manager"), TABSRMM_HK_SECTION_GC, 0, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, 'C'), TABSRMM_HK_CHANNELMGR },
{ 0, "tabsrmm_muc_filter", LPGEN("Toggle filter"), TABSRMM_HK_SECTION_GC, 0, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, 'F'), TABSRMM_HK_FILTERTOGGLE },
{ 0, "tabsrmm_muc_nick", LPGEN("Toggle nick list"), TABSRMM_HK_SECTION_GC, 0, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, 'N'), TABSRMM_HK_LISTTOGGLE },
- { 0, "tabsrmm_muc_server_show", LPGEN("Show server window"), TABSRMM_HK_SECTION_GC, 0, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, '1'), TABSRMM_HK_MUC_SHOWSERVER }
+ { 0, "tabsrmm_muc_server_show", LPGEN("Show server window"), TABSRMM_HK_SECTION_GC, 0, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, '1'), TABSRMM_HK_MUC_SHOWSERVER },
+ { 0, "tabsrmm_close_other", LPGEN("Close Other Tabs"), TABSRMM_HK_SECTION_GENERIC, 0, HOTKEYCODE(HOTKEYF_ALT|HOTKEYF_CONTROL, 'W'), TABSRMM_HK_CLOSE_OTHER },
};
static SendLaterJobIterator g_jobs;
diff --git a/plugins/TabSRMM/src/include/functions.h b/plugins/TabSRMM/src/include/functions.h index 4efdc9662e..8d3dabb7ba 100644 --- a/plugins/TabSRMM/src/include/functions.h +++ b/plugins/TabSRMM/src/include/functions.h @@ -88,7 +88,9 @@ TContainerData* TSAPI CreateContainer(const TCHAR *name, int iTemp, HANDLE hCont TContainerData* TSAPI FindContainerByName(const TCHAR *name);
int TSAPI GetTabIndexFromHWND(HWND hwndTab, HWND hwnd);
+HWND TSAPI GetHWNDFromTabIndex(HWND hwndTab, int idx);
int TSAPI GetTabItemFromMouse(HWND hwndTab, POINT *pt);
+void TSAPI CloseOtherTabs(HWND hwndTab, TWindowData &dat);
int TSAPI ActivateTabFromHWND(HWND hwndTab, HWND hwnd);
void TSAPI AdjustTabClientRect(TContainerData *pContainer, RECT *rc);
void TSAPI ReflashContainer(TContainerData *pContainer);
diff --git a/plugins/TabSRMM/src/include/msgs.h b/plugins/TabSRMM/src/include/msgs.h index fe24199adb..3e95b494c0 100644 --- a/plugins/TabSRMM/src/include/msgs.h +++ b/plugins/TabSRMM/src/include/msgs.h @@ -1016,6 +1016,7 @@ typedef struct { #define TABSRMM_HK_FILTERTOGGLE 29
#define TABSRMM_HK_LISTTOGGLE 30
#define TABSRMM_HK_MUC_SHOWSERVER 31
+#define TABSRMM_HK_CLOSE_OTHER 32
#define TABSRMM_HK_SECTION_IM LPGEN("Message windows - IM")
#define TABSRMM_HK_SECTION_GENERIC LPGEN("Message windows - all")
diff --git a/plugins/TabSRMM/src/include/resource.h b/plugins/TabSRMM/src/include/resource.h index 25f9547d0f..d92c793c35 100644 --- a/plugins/TabSRMM/src/include/resource.h +++ b/plugins/TabSRMM/src/include/resource.h @@ -628,6 +628,7 @@ #define ID_TABCONTEXT_PREVTAB 40029
#define ID_CLOSETAB 40030
#define ID_TABMENU_CLOSETAB 40031
+#define ID_TABMENU_CLOSEOTHERTABS 40032
#define ID_TABMENU_SAVELOCALESETTINGFORTHISCONTACT 40034
#define ID_TABMENU_OPENWINDOWSERVICE 40035
#define ID_TABMENU_ATTACHTOCONTAINER 40036
@@ -658,6 +659,7 @@ #define ID_FILE_CLOSEMESSAGESESSION 40086
#define ID_VIEW_SHOWMULTISENDCONTACTLIST 40087
#define ID_VIEW_TITLEBAR 40088
+#define ID_FILE_CLOSEOTHERMSGSESSIONS 40090
#define ID_VIEW_TABSATBOTTOM 40093
#define ID_VIEW_STAYONTOP 40095
#define ID_HELP 40096
|