/* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #include #include #include #include #include "hexchat-plugin.h" #include "utility.h" #include "hextray.h" #include "callbacks.h" #include "resource.h" struct HOTKEY g_hHotKey; /* we need to convert ALT and SHIFT modifiers // from #define MOD_ALT 0x0001 #define MOD_CONTROL 0x0002 #define MOD_SHIFT 0x0004 // from #define HOTKEYF_SHIFT 0x01 #define HOTKEYF_CONTROL 0x02 #define HOTKEYF_ALT 0x04 */ WORD HotkeyfToMod(WORD modifiers) { WORD newmods = 0; if (modifiers & HOTKEYF_SHIFT) newmods |= MOD_SHIFT; if (modifiers & HOTKEYF_CONTROL) newmods |= MOD_CONTROL; if (modifiers & HOTKEYF_ALT) newmods |= MOD_ALT; return newmods; } WORD ModToHotkeyf(WORD modifiers) { WORD newmods = 0; if (modifiers & MOD_SHIFT) newmods |= HOTKEYF_SHIFT; if (modifiers & MOD_CONTROL) newmods |= HOTKEYF_CONTROL; if (modifiers & MOD_ALT) newmods |= HOTKEYF_ALT; return newmods; } void SavePrefs(int iDlg) { hexchat_pluginpref_set_int (ph, "settings", g_dwPrefs); hexchat_pluginpref_set_int (ph, "aot", g_iTime); hexchat_pluginpref_set_int (ph, "key", g_hHotKey.key); hexchat_pluginpref_set_int (ph, "mod", g_hHotKey.mod); hexchat_pluginpref_set_str (ph, "away", (const char*) g_szAway); } void LoadPrefs() { /**************************************************************************************************/ /*********************** Our Settings Section *****************************************************/ /**************************************************************************************************/ /**************************************************************************************************/ /*************************** Get the value for each of our preferances ****************************/ /**************************************************************************************************/ g_dwPrefs = hexchat_pluginpref_get_int (ph, "settings"); g_iTime = hexchat_pluginpref_get_int (ph, "aot"); g_hHotKey.key = hexchat_pluginpref_get_int (ph, "key"); g_hHotKey.mod = hexchat_pluginpref_get_int (ph, "mod"); hexchat_pluginpref_get_str (ph, "away", (char *) g_szAway); /**************************************************************************************************/ /******************************** Register our hotkey with windows ********************************/ /**************************************************************************************************/ if(g_dwPrefs & (1<