summaryrefslogtreecommitdiff
path: root/plugins/NewEventNotify/src/menuitem.cpp
blob: 99e35c47402dbe613f920a4588339c501cf2dade (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
  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 "neweventnotify.h"

HANDLE hMenuitemNotify;
BOOL bNotify;

static INT_PTR MenuitemNotifyCmd(WPARAM wParam,LPARAM lParam)
{
	bNotify = !bNotify;
	MenuitemUpdate(bNotify);

	//write changes to options->bDisable and into database
	Opt_DisableNEN(!bNotify);
	return 0;
}

int MenuitemUpdate(BOOL bStatus)
{
	CLISTMENUITEM mi = { sizeof(mi) };
	mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(bStatus ? IDI_ENABLED : IDI_DISABLED));
	if (bStatus)
		mi.ptszName = TranslateT(MENUITEM_DISABLE);
	else
		mi.ptszName = TranslateT(MENUITEM_ENABLE);
	mi.flags = CMIM_ICON | CMIM_NAME | CMIF_KEEPUNTRANSLATED | CMIF_TCHAR;
	CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuitemNotify, (LPARAM)&mi);

	return 0;
}

int MenuitemInit(BOOL bStatus)
{
	CreateServiceFunction(MS_NEN_MENUNOTIFY, MenuitemNotifyCmd);

	CLISTMENUITEM mi = { sizeof(mi) };
	mi.position = 1;
	mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ENABLED));
	mi.ptszPopupName = TranslateT("PopUps");
	mi.pszService = MS_NEN_MENUNOTIFY;
	mi.flags = CMIF_KEEPUNTRANSLATED | CMIF_TCHAR;
	hMenuitemNotify = Menu_AddMainMenuItem(&mi);

	bNotify = bStatus;
	MenuitemUpdate(bNotify);

	return 0;
}