diff options
author | George Hazan <george.hazan@gmail.com> | 2012-12-02 18:19:49 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-12-02 18:19:49 +0000 |
commit | c4582dd65b444e5dae29ada7cc3f6c9a9c20edf3 (patch) | |
tree | 17a8627550b202d62df8e1df76d2585d3d0cdeaa /plugins/AvatarHistory/src | |
parent | 5ea5feb7e052ca45af7bc9ed76e4a252bd71950d (diff) |
new easy standard way of registering icons: Icon_Register
git-svn-id: http://svn.miranda-ng.org/main/trunk@2601 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AvatarHistory/src')
-rw-r--r-- | plugins/AvatarHistory/src/AvatarDlg.cpp | 4 | ||||
-rw-r--r-- | plugins/AvatarHistory/src/AvatarHistory.cpp | 33 | ||||
-rw-r--r-- | plugins/AvatarHistory/src/icolib.cpp | 52 |
3 files changed, 18 insertions, 71 deletions
diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp index de344a5929..f06469adef 100644 --- a/plugins/AvatarHistory/src/AvatarDlg.cpp +++ b/plugins/AvatarHistory/src/AvatarDlg.cpp @@ -36,8 +36,6 @@ TCHAR * GetContactFolder(TCHAR *fn, HANDLE hContact); BOOL ResolveShortcut(TCHAR *shortcut, TCHAR *file);
static INT_PTR ShowDialogSvc(WPARAM wParam, LPARAM lParam);
-extern HANDLE hServices[];
-extern HANDLE hHooks[];
struct AvatarDialogData
{
@@ -540,7 +538,7 @@ int PreBuildContactMenu(WPARAM wParam,LPARAM lParam) void InitMenuItem()
{
- hServices[2] = CreateServiceFunction(MS_AVATARHISTORY_SHOWDIALOG, ShowDialogSvc);
+ CreateServiceFunction(MS_AVATARHISTORY_SHOWDIALOG, ShowDialogSvc);
CLISTMENUITEM mi = { sizeof(mi) };
mi.ptszName = LPGENT("View Avatar History");
diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp index 68fed732d0..fe493bddd5 100644 --- a/plugins/AvatarHistory/src/AvatarHistory.cpp +++ b/plugins/AvatarHistory/src/AvatarHistory.cpp @@ -27,9 +27,6 @@ HINSTANCE hInst; DWORD mirVer;
-HANDLE hHooks[6] = {0};
-HANDLE hServices[3] = {0};
-
HANDLE hFolder = NULL;
char *metacontacts_proto = NULL;
@@ -172,14 +169,14 @@ extern "C" __declspec(dllexport) int Load(void) LoadOptions();
- hHooks[0] = HookEvent(ME_SYSTEM_MODULESLOADED,ModulesLoaded);
- hHooks[1] = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
- hHooks[3] = HookEvent(ME_OPT_INITIALISE, OptInit);
- hHooks[4] = HookEvent(ME_SKIN2_ICONSCHANGED, IcoLibIconsChanged);
- hHooks[5] = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu);
+ HookEvent(ME_SYSTEM_MODULESLOADED,ModulesLoaded);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
+ HookEvent(ME_OPT_INITIALISE, OptInit);
+ HookEvent(ME_SKIN2_ICONSCHANGED, IcoLibIconsChanged);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu);
- hServices[0] = CreateServiceFunction(MS_AVATARHISTORY_ENABLED, IsEnabled);
- hServices[1] = CreateServiceFunction(MS_AVATARHISTORY_GET_CACHED_AVATAR, GetCachedAvatar);
+ CreateServiceFunction(MS_AVATARHISTORY_ENABLED, IsEnabled);
+ CreateServiceFunction(MS_AVATARHISTORY_GET_CACHED_AVATAR, GetCachedAvatar);
if(CallService(MS_DB_GETPROFILEPATHT, MAX_PATH, (LPARAM)profilePath) != 0)
_tcscpy(profilePath, _T(".")); // Failed, use current dir
@@ -206,10 +203,9 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam) if (ServiceExists(MS_MC_GETPROTOCOLNAME))
metacontacts_proto = (char *) CallService(MS_MC_GETPROTOCOLNAME, 0, 0);
- if (DBGetContactSettingByte(NULL, MODULE_NAME, "LogToHistory", AVH_DEF_LOGTOHISTORY))
+ if (DBGetContactSettingByte(NULL, MODULE_NAME, "LogToHistory", AVH_DEF_LOGTOHISTORY))
{
- char *templates[] = { "Avatar change\nchanged his/her avatar",
- "Avatar removal\nremoved his/her avatar" };
+ char *templates[] = { "Avatar change\nchanged his/her avatar", "Avatar removal\nremoved his/her avatar" };
HICON hIcon = createDefaultOverlayedIcon(FALSE);
HistoryEvents_RegisterWithTemplates(MODULE_NAME, "avatarchange", "Avatar change", EVENTTYPE_AVATAR_CHANGE, hIcon,
HISTORYEVENTS_FORMAT_CHAR | HISTORYEVENTS_FORMAT_WCHAR | HISTORYEVENTS_FORMAT_RICH_TEXT,
@@ -218,23 +214,14 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam) DestroyIcon(hIcon);
}
- hHooks[2] = HookEvent(ME_AV_CONTACTAVATARCHANGED, AvatarChanged);
+ HookEvent(ME_AV_CONTACTAVATARCHANGED, AvatarChanged);
return 0;
}
static int PreShutdown(WPARAM wParam, LPARAM lParam)
{
- int i;
-
- for (i = 0; i < MAX_REGS(hHooks); i++)
- UnhookEvent(hHooks[i]);
-
- for (i = 0; i < MAX_REGS(hServices); i++)
- DestroyServiceFunction(hServices[i]);
-
WindowList_Broadcast(hAvatarWindowsList,WM_CLOSE,0,0);
-
return 0;
}
diff --git a/plugins/AvatarHistory/src/icolib.cpp b/plugins/AvatarHistory/src/icolib.cpp index 28a88494bb..12497d1009 100644 --- a/plugins/AvatarHistory/src/icolib.cpp +++ b/plugins/AvatarHistory/src/icolib.cpp @@ -6,42 +6,20 @@ enum IconIndex I_OVERLAY
};
-typedef struct
+static IconItem iconList[] =
{
- TCHAR* szDescr;
- char* szName;
- int defIconID;
- BOOL core;
-} IconStruct;
-
-static IconStruct iconList[] =
-{
- { LPGENT("History"), "core_main_10", IDI_AVATARHIST, TRUE },
- { LPGENT("Avatar Overlay"), "avh_overlay", IDI_AVATAROVERLAY, FALSE }
+ { LPGEN("History"), "core_main_10", IDI_AVATARHIST },
+ { LPGEN("Avatar Overlay"), "avh_overlay", IDI_AVATAROVERLAY }
};
-extern HANDLE hHooks[];
-
static HICON LoadIconEx(IconIndex i)
{
- HICON hIcon;
-
- if (hHooks[4])
- hIcon = Skin_GetIcon(iconList[(int)i].szName);
- else
- hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(iconList[(int)i].defIconID),
- IMAGE_ICON, 0, 0, 0);
-
- return hIcon;
+ return Skin_GetIcon(iconList[(int)i].szName);
}
-
static void ReleaseIconEx(HICON hIcon)
{
- if (hHooks[4])
- Skin_ReleaseIcon(hIcon);
- else
- DestroyIcon(hIcon);
+ Skin_ReleaseIcon(hIcon);
}
static void IcoLibUpdateMenus()
@@ -61,24 +39,8 @@ int IcoLibIconsChanged(WPARAM wParam, LPARAM lParam) void SetupIcoLib()
{
- if (hHooks[4]) {
- TCHAR path[MAX_PATH];
- GetModuleFileName(hInst, path, sizeof(path));
-
- SKINICONDESC sid = { sizeof(sid) };
- sid.ptszSection = LPGENT("Avatar History");
- sid.ptszDefaultFile = path;
- sid.flags = SIDF_ALL_TCHAR;
-
- for (unsigned i = 0; i < MAX_REGS(iconList); i++) {
- if (!iconList[i].core) {
- sid.ptszDescription = iconList[i].szDescr;
- sid.pszName = iconList[i].szName;
- sid.iDefaultIndex = -iconList[i].defIconID;
- Skin_AddIcon(&sid);
- }
- }
- }
+ iconList[0].hIcolib = LoadSkinnedIconHandle(SKINICON_OTHER_HISTORY);
+ Icon_Register(hInst, LPGEN("Avatar History"), iconList+1, SIZEOF(iconList)-1);
IcoLibUpdateMenus();
}
|