From 44d565bb91b211f80c6f21fb92804084af37d4db Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sun, 13 Jan 2013 15:24:40 +0000 Subject: added toptoolbar support fixed autoupdate saving setting cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@3095 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Weather/src/version.h | 6 ------ plugins/Weather/src/weather.cpp | 21 ++++++++++++++++++++- plugins/Weather/src/weather.h | 26 +++++++------------------- plugins/Weather/src/weather_svcs.cpp | 6 +++++- 4 files changed, 32 insertions(+), 27 deletions(-) (limited to 'plugins/Weather/src') diff --git a/plugins/Weather/src/version.h b/plugins/Weather/src/version.h index f36385ce1a..8cc0354dce 100644 --- a/plugins/Weather/src/version.h +++ b/plugins/Weather/src/version.h @@ -4,14 +4,8 @@ #define __BUILD_NUM 1 #define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM - -#define __STRINGIFY_IMPL(x) #x -#define __STRINGIFY(x) __STRINGIFY_IMPL(x) -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) #define __PLUGIN_NAME "Weather" -#define __INTERNAL_NAME "Weather" #define __FILENAME "Weather.dll" #define __DESCRIPTION "Retrieves weather information and displays it in your contact list." #define __AUTHOR "Miranda NG Team" diff --git a/plugins/Weather/src/weather.cpp b/plugins/Weather/src/weather.cpp index 4d7abb15f7..d4f1f8547e 100644 --- a/plugins/Weather/src/weather.cpp +++ b/plugins/Weather/src/weather.cpp @@ -56,6 +56,8 @@ BOOL ThreadRunning; // variable to determine if module loaded BOOL ModuleLoaded; +HANDLE hTBButton = NULL; + // plugin info static const PLUGININFOEX pluginInfoEx = { @@ -69,7 +71,7 @@ static const PLUGININFOEX pluginInfoEx = __AUTHORWEB, UNICODE_AWARE, // {6B612A34-DCF2-4e32-85CF-B6FD006B745E} - {0x6b612a34, 0xdcf2, 0x4e32, { 0x85, 0xcf, 0xb6, 0xfd, 0x0, 0x6b, 0x74, 0x5e}} + {0x6b612a34, 0xdcf2, 0x4e32, {0x85, 0xcf, 0xb6, 0xfd, 0x0, 0x6b, 0x74, 0x5e}} }; extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) @@ -102,6 +104,21 @@ int WeatherShutdown(WPARAM wParam,LPARAM lParam) return 0; } +int OnToolbarLoaded(WPARAM wParam, LPARAM lParam) +{ + TTBButton tbb = {0}; + tbb.cbSize = sizeof(TTBButton); + tbb.name = LPGEN("Enable/disable auto update"); + tbb.pszService = MS_WEATHER_ENABLED; + tbb.pszTooltipUp = LPGEN("Auto Update Enabled"); + tbb.pszTooltipDn = LPGEN("Auto Update Disabled"); + tbb.hIconHandleUp = GetIconHandle("main"); + tbb.hIconHandleDn = GetIconHandle("disabled"); + tbb.dwFlags = (db_get_b(NULL, WEATHERPROTONAME, "AutoUpdate", 1) ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON | TTBBF_VISIBLE; + hTBButton = TopToolbar_AddButton(&tbb); + return 0; +} + // weather protocol initialization function // run after the event ME_SYSTEM_MODULESLOADED occurs int WeatherInit(WPARAM wParam,LPARAM lParam) @@ -121,6 +138,8 @@ int WeatherInit(WPARAM wParam,LPARAM lParam) // weather user detail HookEvent(ME_USERINFO_INITIALISE, UserInfoInit); + HookEvent(ME_TTB_MODULELOADED, OnToolbarLoaded); + hDataWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0); hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0); diff --git a/plugins/Weather/src/weather.h b/plugins/Weather/src/weather.h index e4acc35e04..694a475549 100644 --- a/plugins/Weather/src/weather.h +++ b/plugins/Weather/src/weather.h @@ -1,6 +1,6 @@ /* -Weather Protocol plugin for Miranda IM -Copyright (c) 2012 Miranda NG Team +Weather Protocol plugin for Miranda NG +Copyright (c) 2012-2013 Miranda NG Team Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved Copyright (c) 2002-2005 Calvin Che @@ -26,35 +26,21 @@ along with this program. If not, see . #define _CRT_SECURE_NO_WARNINGS #include - -#include -#include #include -#include -#include #include - #include #include #include -#include - -#define MIRANDA_VER 0x0A00 - #include -#include #include #include -#include -#include #include #include #include #include #include #include -#include #include #include #include @@ -66,10 +52,12 @@ along with this program. If not, see . #include #include #include - #include +#include + +#include +#include -#include "m_weather.h" #include "resource.h" #include "version.h" @@ -373,7 +361,7 @@ extern HANDLE hHookWeatherUpdated; extern HANDLE hHookWeatherError; extern HANDLE hWindowList; extern HANDLE hMwinMenu; - +extern HANDLE hTBButton; extern UINT_PTR timerId; // check if weather is currently updating diff --git a/plugins/Weather/src/weather_svcs.cpp b/plugins/Weather/src/weather_svcs.cpp index ee0948bf4c..d61bdc2a8b 100644 --- a/plugins/Weather/src/weather_svcs.cpp +++ b/plugins/Weather/src/weather_svcs.cpp @@ -225,21 +225,25 @@ void UpdateMenu(BOOL State) { // update option setting opt.CAutoUpdate = State; - db_set_b(NULL, WEATHERPROTONAME, "AutoUpdate", (BYTE)opt.AutoUpdate); + db_set_b(NULL, WEATHERPROTONAME, "AutoUpdate", (BYTE)State); CLISTMENUITEM mi = { sizeof(mi) }; if (State) { // to enable auto-update mi.pszName = LPGEN("Auto Update Enabled"); mi.icolibItem = GetIconHandle("main"); + opt.AutoUpdate = 1; } else { // to disable auto-update mi.pszName = LPGEN("Auto Update Disabled"); mi.icolibItem = GetIconHandle("disabled"); + opt.AutoUpdate = 0; } mi.flags = CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB; CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hEnableDisableMenu, (LPARAM)&mi); + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTBButton, !State ? TTBST_PUSHED : TTBST_RELEASED); + } void UpdatePopupMenu(BOOL State) -- cgit v1.2.3