diff options
author | George Hazan <ghazan@miranda.im> | 2022-03-09 16:01:24 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-03-09 16:01:32 +0300 |
commit | d387ed11456e40f36f359cb3aa9f74a54b8f369b (patch) | |
tree | 58b3c950a6f00ee6664e794ec4a385cc3b10cb34 /plugins/NewEventNotify/src | |
parent | b5c43418ddb50192686929bac0a6b3190aa6b600 (diff) |
popup control moved from main menu to Options - Popups - Enabled items
Diffstat (limited to 'plugins/NewEventNotify/src')
-rw-r--r-- | plugins/NewEventNotify/src/main.cpp | 16 | ||||
-rw-r--r-- | plugins/NewEventNotify/src/menuitem.cpp | 67 | ||||
-rw-r--r-- | plugins/NewEventNotify/src/options.cpp | 18 | ||||
-rw-r--r-- | plugins/NewEventNotify/src/stdafx.h | 10 |
4 files changed, 14 insertions, 97 deletions
diff --git a/plugins/NewEventNotify/src/main.cpp b/plugins/NewEventNotify/src/main.cpp index 8039f7bd4b..051177106e 100644 --- a/plugins/NewEventNotify/src/main.cpp +++ b/plugins/NewEventNotify/src/main.cpp @@ -46,7 +46,8 @@ PLUGININFOEX pluginInfoEx = };
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+ bPopups(MODULENAME, "Popups", true)
{}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -59,7 +60,7 @@ CMPlugin::CMPlugin() : int HookedNewEvent(WPARAM hContact, LPARAM hDbEvent)
{
//are popups currently enabled?
- if (g_plugin.bDisable)
+ if (!g_plugin.bPopups)
return 0;
//get DBEVENTINFO without pBlob
@@ -113,8 +114,6 @@ int HookedInit(WPARAM, LPARAM) if (ServiceExists("PluginSweeper/Add"))
CallService("PluginSweeper/Add", (WPARAM)MODULENAME, (LPARAM)MODULENAME);
- if (g_plugin.bMenuitem)
- MenuitemInit(!g_plugin.bDisable);
return 0;
}
@@ -122,10 +121,17 @@ int HookedInit(WPARAM, LPARAM) int CMPlugin::Load()
{
+ if (getBool(OPT_DISABLE)) {
+ bPopups = false;
+ delSetting(OPT_DISABLE);
+ }
+
HookEvent(ME_SYSTEM_MODULESLOADED, HookedInit);
HookEvent(ME_OPT_INITIALISE, OptionsAdd);
- g_plugin.OptionsRead();
+ addPopupOption(LPGEN("New event notifications"), bPopups);
+
+ OptionsRead();
return 0;
}
diff --git a/plugins/NewEventNotify/src/menuitem.cpp b/plugins/NewEventNotify/src/menuitem.cpp deleted file mode 100644 index 42cb38e813..0000000000 --- a/plugins/NewEventNotify/src/menuitem.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/*
- Name: NewEventNotify - Plugin for Miranda IM
- File: mi.c - Manages item(s) in the Miranda Menu
- Version: 0.0.4
- Description: Notifies you about some events
- Author: icebreaker, <icebreaker@newmail.net>
- Date: 22.07.02 19:56 / Update: 24.07.02 01:39
- Copyright: (C) 2002 Starzinger Michael
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#include "stdafx.h"
-
-HGENMENU hMenuitemNotify;
-BOOL bNotify;
-
-static INT_PTR MenuitemNotifyCmd(WPARAM, LPARAM)
-{
- bNotify = !bNotify;
- MenuitemUpdate(bNotify);
-
- // write changes to options->bDisable and into database
- Opt_DisableNEN(!bNotify);
- return 0;
-}
-
-int MenuitemUpdate(BOOL bStatus)
-{
- if (bStatus)
- Menu_ModifyItem(hMenuitemNotify, MENUITEM_DISABLE, Skin_GetIconHandle(SKINICON_OTHER_POPUP));
- else
- Menu_ModifyItem(hMenuitemNotify, MENUITEM_ENABLE, Skin_GetIconHandle(SKINICON_OTHER_NOPOPUP));
- return 0;
-}
-
-int MenuitemInit(BOOL bStatus)
-{
- HGENMENU hRoot = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0);
-
- CMenuItem mi(&g_plugin);
- SET_UID(mi, 0x7aed93f7, 0x835, 0x4ff6, 0xb1, 0x34, 0xae, 0x0, 0x21, 0x2a, 0xd7, 0x81);
- mi.root = hRoot;
- mi.position = 1;
- mi.hIcolibItem = Skin_LoadIcon(SKINICON_OTHER_POPUP);
- mi.pszService = "NewEventNotify/MenuitemNotifyCommand";
- mi.flags = 0;
- hMenuitemNotify = Menu_AddMainMenuItem(&mi);
-
- CreateServiceFunction(mi.pszService, MenuitemNotifyCmd);
-
- bNotify = bStatus;
- MenuitemUpdate(bNotify);
- return 0;
-}
diff --git a/plugins/NewEventNotify/src/options.cpp b/plugins/NewEventNotify/src/options.cpp index c035cd93f1..c9f5354ea3 100644 --- a/plugins/NewEventNotify/src/options.cpp +++ b/plugins/NewEventNotify/src/options.cpp @@ -26,11 +26,9 @@ void CMPlugin::OptionsRead(void)
{
- bDisable = getBool(OPT_DISABLE, false);
bMUCDisable = getBool(OPT_MUCDISABLE, false);
bPreview = getBool(OPT_PREVIEW, true);
- bMenuitem = getBool(OPT_MENUITEM, false);
bMergePopup = getBool(OPT_MERGEPOPUP, true);
bMsgWindowCheck = getBool(OPT_MSGWINDOWCHECK, true);
bMsgReplyWindow = getBool(OPT_MSGREPLYWINDOW, false);
@@ -74,11 +72,9 @@ void CMPlugin::OptionsRead(void) void CMPlugin::OptionsWrite(void)
{
- setByte(OPT_DISABLE, bDisable);
setByte(OPT_MUCDISABLE, bMUCDisable);
setByte(OPT_PREVIEW, bPreview);
- setByte(OPT_MENUITEM, bMenuitem);
setByte(OPT_MERGEPOPUP, bMergePopup);
setByte(OPT_MSGWINDOWCHECK, bMsgWindowCheck);
setByte(OPT_MSGREPLYWINDOW, bMsgReplyWindow);
@@ -132,7 +128,6 @@ class COptionsBaseDlg : public CDlgBase void OnFinish(CDlgBase *)
{
g_plugin.OptionsWrite();
- MenuitemUpdate(!g_plugin.bDisable);
}
public:
@@ -145,9 +140,6 @@ public: void OnReset() override
{
g_plugin.OptionsRead();
-
- // maybe something changed with the mi
- MenuitemUpdate(!g_plugin.bDisable);
}
};
@@ -214,9 +206,8 @@ public: spinMessage(this, IDC_SPIN_MESSAGE, 1000, -1)
{
auto *pwszSection = TranslateT("General options");
- m_opts.AddOption(pwszSection, TranslateT("Show entry in the Popups menu"), g_plugin.bMenuitem);
m_opts.AddOption(pwszSection, TranslateT("Show preview of event in popup"), g_plugin.bPreview);
- m_opts.AddOption(pwszSection, TranslateT("Disable event notifications for instant messages"), g_plugin.bDisable);
+ m_opts.AddOption(pwszSection, TranslateT("Enable event notifications for instant messages"), g_plugin.bPopups);
m_opts.AddOption(pwszSection, TranslateT("Disable event notifications for group chats"), g_plugin.bMUCDisable);
pwszSection = TranslateT("Notify me of...");
@@ -419,10 +410,3 @@ int OptionsAdd(WPARAM addInfo, LPARAM) g_plugin.addOptions(addInfo, &odp);
return 0;
}
-
-int Opt_DisableNEN(BOOL Status)
-{
- g_plugin.bDisable = Status;
- g_plugin.OptionsWrite(); // JK: really necessary to write everything here ????
- return 0;
-}
diff --git a/plugins/NewEventNotify/src/stdafx.h b/plugins/NewEventNotify/src/stdafx.h index 1e0f5d515a..a83ef4c160 100644 --- a/plugins/NewEventNotify/src/stdafx.h +++ b/plugins/NewEventNotify/src/stdafx.h @@ -136,9 +136,6 @@ #define MENUITEM_NAME LPGEN("Notify of new events")
-#define MENUITEM_ENABLE LPGENW("Enable new event notification")
-#define MENUITEM_DISABLE LPGENW("Disable new event notification")
-
//---------------------------
//---Structures
@@ -151,10 +148,10 @@ struct CMPlugin : public PLUGIN<CMPlugin> void OptionsRead(void);
void OptionsWrite(void);
- bool bDisable;
+ CMOption<bool> bPopups;
+
bool bMUCDisable;
bool bPreview;
- bool bMenuitem;
bool bDisableNonMessage;
bool bMsgWindowCheck;
bool bMsgReplyWindow;
@@ -204,9 +201,6 @@ int PopupShow(MCONTACT hContact, MEVENT hEvent, UINT eventType); int PopupUpdate(PLUGIN_DATA &pdata, MEVENT hEvent);
int PopupAct(HWND hWnd, UINT mask, PLUGIN_DATA *pdata);
int OptionsAdd(WPARAM addInfo, LPARAM);
-int Opt_DisableNEN(BOOL Status);
-int MenuitemInit(BOOL bStatus);
-int MenuitemUpdate(BOOL bStatus);
int CheckMsgWnd(MCONTACT hContact);
PLUGIN_DATA* PU_GetByContact(MCONTACT hContact, UINT eventType);
|