summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-10-04 19:53:25 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-10-04 19:53:25 +0300
commitb35fc72bfb45a527d4c8b181019ab38cd3d813aa (patch)
treeea3ed5345e60aba4766047796a01d235c979cadd /src
parentfb8111c474a8e393e885707eb9796195a2e5a1c6 (diff)
duplicate code removed
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/chat.h3
-rw-r--r--src/mir_app/src/srmm_base.cpp10
-rw-r--r--src/mir_app/src/srmm_toolbar.cpp5
3 files changed, 11 insertions, 7 deletions
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h
index 9b2564bad0..84e9be92d9 100644
--- a/src/mir_app/src/chat.h
+++ b/src/mir_app/src/chat.h
@@ -30,6 +30,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define STREAMSTAGE_TAIL 2
#define STREAMSTAGE_STOP 3
+#define N_CUSTOM_BBCODES 3
+extern wchar_t *wszBbcodes[N_CUSTOM_BBCODES];
+
#define DM_OPTIONSAPPLIED (WM_USER+14)
void Srmm_CreateToolbarIcons(CSrmmBaseDialog *pDlg, int flags);
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 9495a98690..57b03ca48a 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -581,6 +581,8 @@ static void doMarkEventRead(MCONTACT hContact, MEVENT hEvent)
Clist_RemoveEvent(-1, hEvent);
}
+wchar_t *wszBbcodes[N_CUSTOM_BBCODES] = { L"[img]", L"[code]", L"[quote]" };
+
INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
@@ -608,12 +610,10 @@ INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
}
if (wParam == IDC_CODE) {
- switch (lParam) {
- case 1: InsertBbcodeString(L"[code]"); break;
- case 2: InsertBbcodeString(L"[quote]"); break;
- default:
+ if (lParam > 0 && lParam < _countof(wszBbcodes))
+ InsertBbcodeString(wszBbcodes[lParam-1]);
+ else
Srmm_ClickToolbarIcon(m_hContact, wParam, m_hwnd, 0);
- }
}
break;
diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp
index b0ddabd7bd..1f7f2e0e9b 100644
--- a/src/mir_app/src/srmm_toolbar.cpp
+++ b/src/mir_app/src/srmm_toolbar.cpp
@@ -885,8 +885,9 @@ static int OnToolbarClicked(WPARAM, LPARAM lParam)
return 0;
HMENU hMenu = CreatePopupMenu();
- AppendMenuW(hMenu, MF_STRING, 1, TranslateT("[code]"));
- AppendMenuW(hMenu, MF_STRING, 2, TranslateT("[quote]"));
+ for (int i = 0; i < N_CUSTOM_BBCODES; i++)
+ AppendMenuW(hMenu, MF_STRING, i + 1, wszBbcodes[i]);
+
int ret = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, nullptr);
if (ret != 0)
PostMessage(cbcd->hwndFrom, WM_COMMAND, IDC_CODE, ret);