From d03d6e606b40157d910ddf99ab018156abeb8ef0 Mon Sep 17 00:00:00 2001 From: "berkeviktor@aol.com" Date: Mon, 28 Feb 2011 18:59:32 +0100 Subject: add wdk changes to named branch --- plugins/xtray/callbacks.cpp | 734 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 734 insertions(+) create mode 100644 plugins/xtray/callbacks.cpp (limited to 'plugins/xtray/callbacks.cpp') diff --git a/plugins/xtray/callbacks.cpp b/plugins/xtray/callbacks.cpp new file mode 100644 index 00000000..636c114e --- /dev/null +++ b/plugins/xtray/callbacks.cpp @@ -0,0 +1,734 @@ +/* X-Tray + * Copyright (C) 2005 Michael Hotaling + * + * X-Tray 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. + * + * X-Tray 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 X-Tray; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define _WIN32_IE 0x0601 + +#include +#include +#include +#include +#include "utility.h" +#include "plugin.h" +#include "xtray.h" +#include "xchat.h" +#include "callbacks.h" +#include "resource.h" +#include "sdTray.h" +#include "sdAlerts.h" + +HWND g_hPrefTabEvents; +HWND g_hPrefTabSettings; +HWND g_hPrefTabAlerts; +HWND g_hPrefTabAbout; +bool g_bCanQuit; +int g_iIsActive = 1; + + +BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) +{ + TCHAR szTitle[10]; + GetWindowText(hWnd, szTitle, 9); + + if(_tcsstr(szTitle, _T("XChat ["))) + { + g_hXchatWnd = hWnd; + return false; + } + + return true; +} + +/***********************************************************************************************/ +/******* our xchat event call back, get the name and info for each event and save it ***********/ +/******* for our alerts later ***********/ +/***********************************************************************************************/ +int event_cb(char *word[], void *userdata) +{ + int iEvent = (int)userdata; + + if(iEvent > 10 && iEvent != 21) + return XCHAT_EAT_NONE; + + /***************************************************************************************/ + /***** if the window is minimized or if we're allowed to show alerts when its not **/ + /***** and if the option to show the specified alert is true and if we're even **/ + /***** allowed to show alerts at all then we show them (a bit confusing but it works) **/ + /***************************************************************************************/ + if(((g_iIsActive == 0) || !(g_dwPrefs & (1< 0) + { + xchat_set_context(ph, xchat_find_server(msg-1)); + + if(!xchat_get_info(ph, "away")) + { + xchat_away(g_szAway); + } + else + { + xchat_back(); + } + } + } + break; + } + + return 1; +} + +int CALLBACK PrefProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + TCITEM tci1; + TCITEM tci2; + TCITEM tci3; + TCITEM tci4; + + tci1.mask = TCIF_TEXT; + tci1.pszText = _T("Settings"); + tci1.cchTextMax = strlen("Settings"); + SendDlgItemMessage(hWnd, IDC_TAB_CONTROL, TCM_INSERTITEM, 0, (LPARAM)&tci1); + + tci2.mask = TCIF_TEXT; + tci2.pszText = _T("Alerts"); + tci2.cchTextMax = strlen("Alerts"); + SendDlgItemMessage(hWnd, IDC_TAB_CONTROL, TCM_INSERTITEM, 1, (LPARAM)&tci2); + + tci3.mask = TCIF_TEXT; + tci3.pszText = _T("Events"); + tci3.cchTextMax = strlen("Events"); + SendDlgItemMessage(hWnd, IDC_TAB_CONTROL, TCM_INSERTITEM, 2, (LPARAM)&tci3); + + tci4.mask = TCIF_TEXT; + tci4.pszText = _T("About"); + tci4.cchTextMax = strlen("About"); + SendDlgItemMessage(hWnd, IDC_TAB_CONTROL, TCM_INSERTITEM, 3, (LPARAM)&tci4); + + + /***********************************************************************************/ + /***********************************************************************************/ + /***********************************************************************************/ + + g_hPrefTabSettings = CreateDialog((HINSTANCE)g_hInstance, + MAKEINTRESOURCE(IDD_SETTINGS), + hWnd, + (DLGPROC)SettingsProc); + SetDialog(g_hPrefTabSettings, IDD_SETTINGS); + + g_hPrefTabAlerts = CreateDialog((HINSTANCE)g_hInstance, + MAKEINTRESOURCE(IDD_ALERTS), + hWnd, + (DLGPROC)AlertsProc); + SetDialog(g_hPrefTabAlerts, IDD_ALERTS); + + g_hPrefTabEvents = CreateDialog((HINSTANCE)g_hInstance, + MAKEINTRESOURCE(IDD_EVENTS), + hWnd, + (DLGPROC)EventsProc); + SetDialog(g_hPrefTabEvents, IDD_EVENTS); + + g_hPrefTabAbout = CreateDialog((HINSTANCE)g_hInstance, + MAKEINTRESOURCE(IDD_ABOUT), + hWnd, + (DLGPROC)AboutProc); + } + break; + case WM_SHOWWINDOW: + { + if(wparam) + { + SendDlgItemMessage(hWnd, IDC_TAB_CONTROL, TCM_SETCURSEL, 0, 0); + ShowWindow(g_hPrefTabSettings, SW_SHOW); + ShowWindow(g_hPrefTabAlerts, SW_HIDE); + ShowWindow(g_hPrefTabEvents, SW_HIDE); + ShowWindow(g_hPrefTabAbout, SW_HIDE); + } + } + break; + case WM_NOTIFY: + { + NMHDR *pData = (NMHDR *)lparam; + + switch(pData->code) + { + case TCN_SELCHANGE: + { + switch(SendDlgItemMessage(hWnd, IDC_TAB_CONTROL, TCM_GETCURSEL, 0, 0)) + { + case 0: + { + ShowWindow(g_hPrefTabSettings, SW_SHOW); + ShowWindow(g_hPrefTabAlerts, SW_HIDE); + ShowWindow(g_hPrefTabEvents, SW_HIDE); + ShowWindow(g_hPrefTabAbout, SW_HIDE); + } + break; + case 1: + { + ShowWindow(g_hPrefTabSettings, SW_HIDE); + ShowWindow(g_hPrefTabAlerts, SW_SHOW); + ShowWindow(g_hPrefTabEvents, SW_HIDE); + ShowWindow(g_hPrefTabAbout, SW_HIDE); + } + break; + case 2: + { + ShowWindow(g_hPrefTabSettings, SW_HIDE); + ShowWindow(g_hPrefTabAlerts, SW_HIDE); + ShowWindow(g_hPrefTabEvents, SW_SHOW); + ShowWindow(g_hPrefTabAbout, SW_HIDE); + } + break; + case 3: + { + ShowWindow(g_hPrefTabSettings, SW_HIDE); + ShowWindow(g_hPrefTabAlerts, SW_HIDE); + ShowWindow(g_hPrefTabEvents, SW_HIDE); + ShowWindow(g_hPrefTabAbout, SW_SHOW); + } + break; + } + } + break; + } + } + break; + case WM_CLOSE: + { + ShowWindow(g_hPrefTabEvents, SW_HIDE); + ShowWindow(g_hPrefTabSettings, SW_HIDE); + ShowWindow(g_hPrefTabAlerts, SW_HIDE); + ShowWindow(g_hPrefTabAbout, SW_HIDE); + ShowWindow(hWnd, SW_HIDE); + return TRUE; + } + break; + case WM_COMMAND: + { + switch(wparam) + { + case IDC_PREF_OK: + { + CheckPrefs(g_hPrefTabEvents, IDD_EVENTS); + CheckPrefs(g_hPrefTabSettings, IDD_SETTINGS); + CheckPrefs(g_hPrefTabAlerts, IDD_ALERTS); + + SavePrefs(0); + + ShowWindow(g_hPrefTabEvents, SW_HIDE); + ShowWindow(g_hPrefTabSettings, SW_HIDE); + ShowWindow(g_hPrefTabAlerts, SW_HIDE); + ShowWindow(g_hPrefTabAbout, SW_HIDE); + ShowWindow(hWnd, SW_HIDE); + return TRUE; + } + break; + case IDC_PREF_CANCEL: + { + ShowWindow(g_hPrefTabEvents, SW_HIDE); + ShowWindow(g_hPrefTabSettings, SW_HIDE); + ShowWindow(g_hPrefTabAlerts, SW_HIDE); + ShowWindow(g_hPrefTabAbout, SW_HIDE); + ShowWindow(hWnd, SW_HIDE); + return TRUE; + } + break; + case IDC_PREF_APPLY: + { + CheckPrefs(g_hPrefTabEvents, IDD_EVENTS); + CheckPrefs(g_hPrefTabSettings, IDD_SETTINGS); + CheckPrefs(g_hPrefTabAlerts, IDD_ALERTS); + + SavePrefs(0); + return FALSE; + } + break; + } + } + break; + case WM_DESTROY: + { + SendMessage(g_hPrefTabEvents, WM_CLOSE, 0, 0); + SendMessage(g_hPrefTabSettings, WM_CLOSE, 0, 0); + SendMessage(g_hPrefTabAbout, WM_CLOSE, 0, 0); + SendMessage(g_hPrefTabAlerts, WM_CLOSE, 0, 0); + } + break; + } + + return FALSE; +} + +/****************************************************/ +/****************************************************/ +/****************************************************/ +LRESULT CALLBACK AlertsProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch(msg) + { + case WM_CLOSE: + { + DestroyWindow(hWnd); + return TRUE; + break; + } + break; + case WM_COMMAND: + { + switch(LOWORD(wparam)) + { + case PREF_AMAE: + { + SetToggle(hWnd, PREF_OSBWM, PREF_AMAE, TRUE); + SetToggle(hWnd, PREF_UWIOB, PREF_AMAE, TRUE); + SetToggle(hWnd, PREF_KAOI, PREF_AMAE, TRUE); + + if(IsDlgButtonChecked(hWnd, PREF_AMAE)) + { + SetToggle(hWnd, IDC_ALERT_HOTKEY, PREF_UWIOB, TRUE); + SetToggle(hWnd, IDC_ALERT_HOTKEY_TEXT, PREF_UWIOB, TRUE); + SetToggle(hWnd, IDC_ALERT_TIME, PREF_KAOI, FALSE); + SetToggle(hWnd, IDC_ALERT_TIME_TEXT, PREF_KAOI, FALSE); + } + else + { + SetToggle(hWnd, IDC_ALERT_HOTKEY, PREF_AMAE, TRUE); + SetToggle(hWnd, IDC_ALERT_HOTKEY_TEXT, PREF_AMAE, TRUE); + SetToggle(hWnd, IDC_ALERT_TIME, PREF_AMAE, TRUE); + SetToggle(hWnd, IDC_ALERT_TIME_TEXT, PREF_AMAE, TRUE); + } + } + break; + case PREF_UWIOB: + { + SetToggle(hWnd, IDC_ALERT_HOTKEY, PREF_UWIOB, TRUE); + SetToggle(hWnd, IDC_ALERT_HOTKEY_TEXT, PREF_UWIOB, TRUE); + } + break; + case PREF_KAOI: + { + SetToggle(hWnd, IDC_ALERT_TIME, PREF_KAOI, FALSE); + SetToggle(hWnd, IDC_ALERT_TIME_TEXT, PREF_KAOI, FALSE); + } + break; + } + break; + } + } + + return FALSE; +} + +/****************************************************/ +/****************************************************/ +/****************************************************/ +LRESULT CALLBACK AboutProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + if(msg == WM_CLOSE) + { + DestroyWindow(hWnd); + return true; + } + + return FALSE; +} + +/*****************************************************/ +/** Process the events for our event dialog **********/ +/*****************************************************/ +LRESULT CALLBACK EventsProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + if(msg == WM_CLOSE) + { + DestroyWindow(hWnd); + return true; + } + + return FALSE; +} + +/*****************************************************/ +/** Process the events for our settings dialog this **/ +/** is alot more complicated because options are **/ +/** enabled/disabled based on the state of others **/ +/*****************************************************/ +LRESULT CALLBACK SettingsProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + if(msg == WM_CLOSE) + { + DestroyWindow(hWnd); + return true; + } + + return FALSE; +} + +/*****************************************************/ +/** this is the hotkey message processing function **/ +/** this window is always open and ready to be told **/ +/** if someone has hit the hotkey, if they did, we **/ +/** need to close out all of the tray alerts, for **/ +/** this I wrote sdCloseAlerts, more info there **/ +/*****************************************************/ +LRESULT CALLBACK HotKeyProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + if(msg == WM_CLOSE) + { + DestroyWindow(hWnd); + return true; + } + else if(msg == WM_HOTKEY) + { + sdCloseAlerts(); + } + + return FALSE; +} + -- cgit 1.4.1 From 34144faca5e0bb09ccc4cee4e298cb80dff740dd Mon Sep 17 00:00:00 2001 From: "berkeviktor@aol.com" Date: Wed, 27 Jul 2011 08:06:02 +0200 Subject: fix xtray blinking on unselected events --- plugins/xtray/callbacks.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins/xtray/callbacks.cpp') diff --git a/plugins/xtray/callbacks.cpp b/plugins/xtray/callbacks.cpp index 636c114e..18547ab3 100644 --- a/plugins/xtray/callbacks.cpp +++ b/plugins/xtray/callbacks.cpp @@ -167,10 +167,9 @@ int event_cb(char *word[], void *userdata) free(szTemp); } - if(g_dwPrefs & (1<