Mercurial > pidgin.yaz
changeset 14683:a8c2af13b96d
[gaim-migrate @ 17435]
Fix the docklet on wingaim.
What is the plan for the docklet prefs?
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 06 Oct 2006 05:03:28 +0000 |
parents | 9b4268984921 |
children | e6ea3ea8efe9 |
files | gaim-installer.nsi gtk/Makefile.am gtk/Makefile.mingw gtk/gtkdocklet-win32.c gtk/gtkdocklet.c gtk/gtkdocklet.h gtk/plugins/Makefile.mingw gtk/plugins/docklet/MinimizeToTray.c gtk/plugins/docklet/MinimizeToTray.h gtk/win32/gtkdocklet-win32.c |
diffstat | 10 files changed, 289 insertions(+), 431 deletions(-) [+] |
line wrap: on
line diff
--- a/gaim-installer.nsi Fri Oct 06 00:10:34 2006 +0000 +++ b/gaim-installer.nsi Fri Oct 06 05:03:28 2006 +0000 @@ -698,7 +698,6 @@ RMDir /r "$INSTDIR\locale" RMDir /r "$INSTDIR\pixmaps" RMDir /r "$INSTDIR\perlmod" - Delete "$INSTDIR\plugins\docklet.dll" Delete "$INSTDIR\plugins\extplacement.dll" Delete "$INSTDIR\plugins\gaimrc.dll" Delete "$INSTDIR\plugins\history.dll"
--- a/gtk/Makefile.am Fri Oct 06 00:10:34 2006 +0000 +++ b/gtk/Makefile.am Fri Oct 06 05:03:28 2006 +0000 @@ -6,7 +6,10 @@ win32/IdleTracker/Makefile.mingw \ win32/IdleTracker/idletrack.c \ win32/IdleTracker/idletrack.h \ + win32/MinimizeToTray.h \ + win32/MinimizeToTray.c \ win32/gaimrc.rc.in \ + win32/gtkdocklet-win32.c \ win32/gtkgaimrc.rc.in \ win32/gtkwin32dep.c \ win32/gtkwin32dep.h \
--- a/gtk/Makefile.mingw Fri Oct 06 00:10:34 2006 +0000 +++ b/gtk/Makefile.mingw Fri Oct 06 05:03:28 2006 +0000 @@ -65,6 +65,7 @@ gtkdebug.c \ gtkdialogs.c \ gtkdnd-hints.c \ + gtkdocklet.c \ gtkeventloop.c \ gtkexpander.c \ gtkft.c \ @@ -89,6 +90,8 @@ gtkthemes.c \ gtkutils.c \ gtkwhiteboard.c \ + win32/MinimizeToTray.c \ + win32/gtkdocklet-win32.c \ win32/gtkwin32dep.c \ win32/untar.c \ win32/wspell.c @@ -129,7 +132,7 @@ ## ## TARGET DEFINITIONS ## -.PHONY: all install clean clean_exe +.PHONY: all install install_shallow clean clean_exe all: $(EXE_TARGET).exe $(GTKGAIM_TARGET).dll $(MAKE) -C $(GAIM_GTK_PLUGINS_TOP) -f $(GAIM_WIN32_MAKEFILE) @@ -139,13 +142,15 @@ -e 's/@ORIGINAL_FILENAME@/$(EXE_NAME)/' \ $@.in > $@ -install: all $(GAIM_INSTALL_DIR) +install_shallow: $(GAIM_INSTALL_DIR) $(EXE_TARGET).exe $(GTKGAIM_TARGET).dll + cp $(EXE_TARGET).exe $(GTKGAIM_TARGET).dll $(GAIM_INSTALL_DIR) + cp $(NEEDED_DLLS) $(GAIM_INSTALL_DIR) + +install: install_shallow all $(MAKE) -C $(GAIM_GTK_PLUGINS_TOP) -f $(GAIM_WIN32_MAKEFILE) install $(MAKE) -C $(GAIM_GTK_PIXMAPS_TOP) -f $(GAIM_WIN32_MAKEFILE) install $(MAKE) -C $(GAIM_GTK_SOUNDS_TOP) -f $(GAIM_WIN32_MAKEFILE) install $(MAKE) -C $(GAIM_GTK_IDLETRACK_TOP) -f $(GAIM_WIN32_MAKEFILE) install - cp $(EXE_TARGET).exe $(GTKGAIM_TARGET).dll $(GAIM_INSTALL_DIR) - cp $(NEEDED_DLLS) $(GAIM_INSTALL_DIR) ./win32/gtkgaimrc.rc: ./win32/gtkgaimrc.rc.in $(GAIM_TOP)/VERSION sed -e 's/@GAIM_VERSION@/$(GAIM_VERSION)/g' \
--- a/gtk/gtkdocklet-win32.c Fri Oct 06 00:10:34 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,263 +0,0 @@ -/* - * System tray icon (aka docklet) plugin for Gaim - * - * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org> - * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com> - * Inspired by a similar plugin by: - * John (J5) Palmieri <johnp@martianrock.com> - * - * 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 <windows.h> -#include <gdk/gdkwin32.h> -#include <gdk/gdk.h> - -#include "internal.h" -#include "gtkblist.h" -#include "gtkprefs.h" -#include "debug.h" - -#include "gaim.h" -#include "gtkdialogs.h" - -#include "resource.h" -#include "MinimizeToTray.h" -#include "gtkwin32dep.h" -#include "docklet.h" - -/* - * DEFINES, MACROS & DATA TYPES - */ -#define WM_TRAYMESSAGE WM_USER /* User defined WM Message */ - -/* - * LOCALS - */ -static HWND systray_hwnd=0; -static HICON sysicon_disconn=0; -static HICON sysicon_conn=0; -static HICON sysicon_away=0; -static HICON sysicon_pend=0; -static HICON sysicon_awypend=0; -static HICON sysicon_blank=0; -static NOTIFYICONDATA wgaim_nid; - - -static LRESULT CALLBACK systray_mainmsg_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { - static UINT taskbarRestartMsg; /* static here means value is kept across multiple calls to this func */ - - switch(msg) { - case WM_CREATE: - gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_CREATE\n"); - taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated"); - break; - - case WM_TIMER: - gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_TIMER\n"); - break; - - case WM_DESTROY: - gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_DESTROY\n"); - break; - - case WM_TRAYMESSAGE: - { - int type = 0; - - /* We'll use Double Click - Single click over on linux */ - if( lparam == WM_LBUTTONDBLCLK ) - type = 1; - else if( lparam == WM_MBUTTONUP ) - type = 2; - else if( lparam == WM_RBUTTONUP ) - type = 3; - else - break; - - docklet_clicked(type); - break; - } - default: - if (msg == taskbarRestartMsg) { - /* explorer crashed and left us hanging... - This will put the systray icon back in it's place, when it restarts */ - Shell_NotifyIcon(NIM_ADD,&wgaim_nid); - } - break; - }/* end switch */ - - return DefWindowProc(hwnd, msg, wparam, lparam); -} - -/* Create hidden window to process systray messages */ -static HWND systray_create_hiddenwin() { - WNDCLASSEX wcex; - TCHAR wname[32]; - - strcpy(wname, "GaimWin"); - - wcex.cbSize = sizeof(WNDCLASSEX); - - wcex.style = 0; - wcex.lpfnWndProc = (WNDPROC)systray_mainmsg_handler; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = gtkwgaim_hinstance(); - wcex.hIcon = NULL; - wcex.hCursor = NULL, - wcex.hbrBackground = NULL; - wcex.lpszMenuName = NULL; - wcex.lpszClassName = wname; - wcex.hIconSm = NULL; - - RegisterClassEx(&wcex); - - /* Create the window */ - return (CreateWindow(wname, "", 0, 0, 0, 0, 0, GetDesktopWindow(), NULL, gtkwgaim_hinstance(), 0)); -} - -static void systray_init_icon(HWND hWnd, HICON icon) { - ZeroMemory(&wgaim_nid,sizeof(wgaim_nid)); - wgaim_nid.cbSize=sizeof(NOTIFYICONDATA); - wgaim_nid.hWnd=hWnd; - wgaim_nid.uID=0; - wgaim_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP; - wgaim_nid.uCallbackMessage=WM_TRAYMESSAGE; - wgaim_nid.hIcon=icon; - lstrcpy(wgaim_nid.szTip, "Gaim"); - Shell_NotifyIcon(NIM_ADD,&wgaim_nid); - docklet_embedded(); -} - -static void systray_change_icon(HICON icon) { - wgaim_nid.hIcon = icon; - Shell_NotifyIcon(NIM_MODIFY,&wgaim_nid); -} - -static void systray_remove_nid(void) { - Shell_NotifyIcon(NIM_DELETE,&wgaim_nid); -} - -static void wgaim_tray_update_icon(DockletStatus icon) { - switch (icon) { - case DOCKLET_STATUS_OFFLINE: - systray_change_icon(sysicon_disconn); - break; - case DOCKLET_STATUS_CONNECTING: - break; - case DOCKLET_STATUS_ONLINE: - systray_change_icon(sysicon_conn); - break; - case DOCKLET_STATUS_ONLINE_PENDING: - systray_change_icon(sysicon_pend); - break; - case DOCKLET_STATUS_AWAY: - systray_change_icon(sysicon_away); - break; - case DOCKLET_STATUS_AWAY_PENDING: - systray_change_icon(sysicon_awypend); - break; - } -} - -static void wgaim_tray_blank_icon() { - systray_change_icon(sysicon_blank); -} - -static void wgaim_tray_set_tooltip(gchar *tooltip) { - if (tooltip) { - char *locenc = NULL; - locenc = g_locale_from_utf8(tooltip, -1, NULL, NULL, NULL); - lstrcpyn(wgaim_nid.szTip, locenc, sizeof(wgaim_nid.szTip)/sizeof(TCHAR)); - g_free(locenc); - } else { - lstrcpy(wgaim_nid.szTip, "Gaim"); - } - Shell_NotifyIcon(NIM_MODIFY, &wgaim_nid); -} - -void wgaim_tray_minimize(GaimGtkBuddyList *gtkblist) { - MinimizeWndToTray(GDK_WINDOW_HWND(gtkblist->window->window)); -} - -void wgaim_tray_maximize(GaimGtkBuddyList *gtkblist) { - RestoreWndFromTray(GDK_WINDOW_HWND(gtkblist->window->window)); -} - - -static void wgaim_tray_create() { - OSVERSIONINFO osinfo; - /* dummy window to process systray messages */ - systray_hwnd = systray_create_hiddenwin(); - - osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&osinfo); - - /* Load icons, and init systray notify icon - * NOTE: Windows < XP only supports displaying 4-bit images in the Systray, - * 2K and ME will use the highest color depth that the desktop will support, - * but will scale it back to 4-bits for display. - * That is why we use custom 4-bit icons for pre XP Windowses */ - if ((osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion > 0) || - (osinfo.dwMajorVersion >= 6)) - { - sysicon_disconn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON), IMAGE_ICON, 16, 16, 0); - sysicon_conn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON), IMAGE_ICON, 16, 16, 0); - sysicon_away = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON), IMAGE_ICON, 16, 16, 0); - sysicon_pend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0); - sysicon_awypend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0); - } else { - sysicon_disconn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); - sysicon_conn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); - sysicon_away = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); - sysicon_pend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); - sysicon_awypend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); - } - sysicon_blank = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_BLANK_TRAY_ICON), IMAGE_ICON, 16, 16, 0); - - /* Create icon in systray */ - systray_init_icon(systray_hwnd, sysicon_disconn); - - gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-hiding", - &handle, GAIM_CALLBACK(wgaim_tray_minimize), NULL); - gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-unhiding", - &handle, GAIM_CALLBACK(wgaim_tray_maximize), NULL); - - gaim_debug(GAIM_DEBUG_INFO, "tray icon", "created\n"); -} - -static void wgaim_tray_destroy() { - gaim_signals_disconnect_by_handle(&handle); - systray_remove_nid(); - DestroyWindow(systray_hwnd); - docklet_remove(); -} - -static struct docklet_ui_ops wgaim_tray_ops = -{ - wgaim_tray_create, - wgaim_tray_destroy, - wgaim_tray_update_icon, - wgaim_tray_blank_icon, - wgaim_tray_set_tooltip, - NULL -}; - -/* Used by docklet's plugin load func */ -void docklet_ui_init() { - docklet_set_ui_ops(&wgaim_tray_ops); -}
--- a/gtk/gtkdocklet.c Fri Oct 06 00:10:34 2006 +0000 +++ b/gtk/gtkdocklet.c Fri Oct 06 05:03:28 2006 +0000 @@ -30,12 +30,10 @@ #include "prefs.h" #include "signals.h" #include "sound.h" -#include "version.h" #include "gtkaccount.h" #include "gtkblist.h" #include "gtkconv.h" -#include "gtkft.h" #include "gtkplugin.h" #include "gtkprefs.h" #include "gtksavedstatuses.h" @@ -43,8 +41,6 @@ #include "gtkutils.h" #include "gaimstock.h" #include "gtkdocklet.h" - -#include "gaim.h" #include "gtkdialogs.h" #ifndef DOCKLET_TOOLTIP_LINE_LIMIT @@ -256,11 +252,13 @@ /************************************************************************** * callbacks and signal handlers **************************************************************************/ +#if 0 static void gaim_quit_cb() { /* TODO: confirm quit while pending */ } +#endif static void docklet_update_status_cb(void *data) @@ -269,13 +267,6 @@ } static void -docklet_prefs_cb(const char *name, GaimPrefType type, - gconstpointer val, gpointer data) -{ - docklet_update_status(); -} - -static void docklet_conv_updated_cb(GaimConversation *conv, GaimConvUpdateType type) { if (type == GAIM_CONV_UPDATE_UNSEEN) @@ -602,26 +593,23 @@ return &i; } -void +void gaim_gtk_docklet_init() { void *conn_handle = gaim_connections_get_handle(); void *conv_handle = gaim_conversations_get_handle(); void *accounts_handle = gaim_accounts_get_handle(); - void *core_handle = gaim_get_core(); void *docklet_handle = gaim_gtk_docklet_get_handle(); - - gaim_debug(GAIM_DEBUG_INFO, "docklet", "plugin loaded\n"); - gaim_prefs_add_none("/plugins/gtk/docklet"); - gaim_prefs_add_string("/plugins/gtk/docklet/blink_im", "hidden"); - gaim_prefs_add_string("/plugins/gtk/docklet/blink_chat", "never"); - + gaim_prefs_add_none("/plugins/gtk/docklet"); + gaim_prefs_add_string("/plugins/gtk/docklet/blink_im", "hidden"); + gaim_prefs_add_string("/plugins/gtk/docklet/blink_chat", "never"); + docklet_ui_init(); if (ui_ops && ui_ops->create) ui_ops->create(); gaim_signal_connect(conn_handle, "signed-on", - docklet_handle, GAIM_CALLBACK(docklet_signed_on_cb), NULL); + docklet_handle, GAIM_CALLBACK(docklet_signed_on_cb), NULL); gaim_signal_connect(conn_handle, "signed-off", docklet_handle, GAIM_CALLBACK(docklet_signed_off_cb), NULL); gaim_signal_connect(accounts_handle, "account-status-changed", @@ -634,9 +622,10 @@ docklet_handle, GAIM_CALLBACK(docklet_update_status_cb), NULL); gaim_signal_connect(conv_handle, "conversation-updated", docklet_handle, GAIM_CALLBACK(docklet_conv_updated_cb), NULL); - - gaim_signal_connect(core_handle, "quitting", - NULL, GAIM_CALLBACK(gaim_quit_cb), NULL); +#if 0 + gaim_signal_connect(gaim_get_core(), "quitting", + docklet_handle, GAIM_CALLBACK(gaim_quit_cb), NULL); +#endif /* gaim_prefs_connect_callback(plugin, "/plugins/gtk/docklet/blink_im", docklet_prefs_cb, NULL); @@ -653,6 +642,7 @@ ui_ops->destroy(); } +#if 0 static GtkWidget * plugin_config_frame(GaimPlugin *plugin) { @@ -686,9 +676,5 @@ gtk_widget_show_all(frame); return frame; } +#endif -static GaimGtkPluginUiInfo ui_info = -{ - plugin_config_frame, - 0 /* page_num (Reserved) */ -};
--- a/gtk/gtkdocklet.h Fri Oct 06 00:10:34 2006 +0000 +++ b/gtk/gtkdocklet.h Fri Oct 06 05:03:28 2006 +0000 @@ -46,17 +46,17 @@ }; -/* functions in docklet.c */ +/* functions in gtkdocklet.c */ void gaim_gtk_docklet_clicked(int); void gaim_gtk_docklet_embedded(void); void gaim_gtk_docklet_remove(void); void gaim_gtk_docklet_set_ui_ops(struct docklet_ui_ops *); void gaim_gtk_docklet_unload(void); -void gaim_gtk_docklet_init(); -void gaim_gtk_docklet_uninit(); -void*gaim_gtk_docklet_get_handle(); +void gaim_gtk_docklet_init(void); +void gaim_gtk_docklet_uninit(void); +void*gaim_gtk_docklet_get_handle(void); -/* function in docklet-{x11,win32}.c */ +/* function in gtkdocklet-{x11,win32}.c */ void docklet_ui_init(void); #endif /* _GTKDOCKLET_H_ */
--- a/gtk/plugins/Makefile.mingw Fri Oct 06 00:10:34 2006 +0000 +++ b/gtk/plugins/Makefile.mingw Fri Oct 06 05:03:28 2006 +0000 @@ -7,7 +7,6 @@ GAIM_TOP := ../.. include $(GAIM_TOP)/libgaim/win32/global.mak -DOCKLET_PLUGIN := ./docklet GTKPERL_PLUGIN := ./perl TICKER_PLUGIN := ./ticker TRANSPARENCY_PLUGIN := ./win32/transparency @@ -58,14 +57,12 @@ .PHONY: all clean plugins install all: plugins - $(MAKE) -C $(DOCKLET_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) $(MAKE) -C $(GTKPERL_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) $(MAKE) -C $(TICKER_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) $(MAKE) -C $(TRANSPARENCY_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) $(MAKE) -C $(WINPREFS_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) install: all $(GAIM_INSTALL_PLUGINS_DIR) - $(MAKE) -C $(DOCKLET_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) install $(MAKE) -C $(GTKPERL_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) install $(MAKE) -C $(TICKER_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) install $(MAKE) -C $(TRANSPARENCY_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) install @@ -92,7 +89,6 @@ ## clean: rm -f *.o *.dll - $(MAKE) -C $(DOCKLET_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) clean $(MAKE) -C $(GTKPERL_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) clean $(MAKE) -C $(TICKER_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) clean $(MAKE) -C $(TRANSPARENCY_PLUGIN) -f $(GAIM_WIN32_MAKEFILE) clean
--- a/gtk/plugins/docklet/MinimizeToTray.c Fri Oct 06 00:10:34 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -/* MinimizeToTray - * - * A couple of routines to show how to make it produce a custom caption - * animation to make it look like we are minimizing to and maximizing - * from the system tray - * - * These routines are public domain, but it would be nice if you dropped - * me a line if you use them! - * - * 1.0 29.06.2000 Initial version - * 1.1 01.07.2000 The window retains it's place in the Z-order of windows - * when minimized/hidden. This means that when restored/shown, it doesn't - * always appear as the foreground window unless we call SetForegroundWindow - * - * Copyright 2000 Matthew Ellis <m.t.ellis@bigfoot.com> - */ -#define _WIN32_WINNT 0x0500 -#include <windows.h> -#include "MinimizeToTray.h" - -#define DEFAULT_RECT_WIDTH 150 -#define DEFAULT_RECT_HEIGHT 30 - -static void GetTrayWndRect(LPRECT lpTrayRect) { - APPBARDATA appBarData; - HWND hShellTrayWnd = FindWindowEx(NULL, NULL, TEXT("Shell_TrayWnd"), - NULL); - - if(hShellTrayWnd) { - HWND hTrayNotifyWnd = FindWindowEx(hShellTrayWnd, NULL, - TEXT("TrayNotifyWnd"), NULL); - - if(hTrayNotifyWnd) { - GetWindowRect(hTrayNotifyWnd,lpTrayRect); - return; - } - } - - appBarData.cbSize = sizeof(appBarData); - if(SHAppBarMessage(ABM_GETTASKBARPOS, &appBarData)) { - switch(appBarData.uEdge) { - case ABE_LEFT: - case ABE_RIGHT: - lpTrayRect->top = appBarData.rc.bottom - 100; - lpTrayRect->bottom = appBarData.rc.bottom - 16; - lpTrayRect->left = appBarData.rc.left; - lpTrayRect->right = appBarData.rc.right; - break; - case ABE_TOP: - case ABE_BOTTOM: - lpTrayRect->top = appBarData.rc.top; - lpTrayRect->bottom = appBarData.rc.bottom; - lpTrayRect->left = appBarData.rc.right - 100; - lpTrayRect->right = appBarData.rc.right - 16; - break; - } - return; - } - - hShellTrayWnd = FindWindowEx(NULL, NULL, TEXT("Shell_TrayWnd"), NULL); - if(hShellTrayWnd) { - GetWindowRect(hShellTrayWnd, lpTrayRect); - if(lpTrayRect->right-lpTrayRect->left > DEFAULT_RECT_WIDTH) - lpTrayRect->left = lpTrayRect->right - DEFAULT_RECT_WIDTH; - if(lpTrayRect->bottom-lpTrayRect->top > DEFAULT_RECT_HEIGHT) - lpTrayRect->top=lpTrayRect->bottom - DEFAULT_RECT_HEIGHT; - - return; - } - - SystemParametersInfo(SPI_GETWORKAREA, 0, lpTrayRect, 0); - lpTrayRect->left = lpTrayRect->right - DEFAULT_RECT_WIDTH; - lpTrayRect->top = lpTrayRect->bottom - DEFAULT_RECT_HEIGHT; -} - -static BOOL GetDoAnimateMinimize(void) { - ANIMATIONINFO ai; - - ai.cbSize = sizeof(ai); - SystemParametersInfo(SPI_GETANIMATION, sizeof(ai), &ai, 0); - - return ai.iMinAnimate ? TRUE : FALSE; -} - -void MinimizeWndToTray(HWND hWnd) { - - if(!IsWindowVisible(hWnd)) - return; - - if(GetDoAnimateMinimize()) { - RECT rcFrom, rcTo; - - GetWindowRect(hWnd, &rcFrom); - GetTrayWndRect(&rcTo); - - DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo); - } - - ShowWindow(hWnd, SW_HIDE); -} - -void RestoreWndFromTray(HWND hWnd) { - - if(IsWindowVisible(hWnd)) - return; - - if(GetDoAnimateMinimize()) { - RECT rcFrom, rcTo; - GetTrayWndRect(&rcFrom); - GetWindowRect(hWnd, &rcTo); - - DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo); - } - - ShowWindow(hWnd, SW_SHOW); - SetActiveWindow(hWnd); - SetForegroundWindow(hWnd); -} -
--- a/gtk/plugins/docklet/MinimizeToTray.h Fri Oct 06 00:10:34 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -#ifndef _MINIMIZE_TO_TRAY_H_ -#define _MINIMIZE_TO_TRAY_H_ - -void MinimizeWndToTray(HWND hWnd); -void RestoreWndFromTray(HWND hWnd); - -#endif /* _MINIMIZE_TO_TRAY_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk/win32/gtkdocklet-win32.c Fri Oct 06 05:03:28 2006 +0000 @@ -0,0 +1,258 @@ +/* + * System tray icon (aka docklet) plugin for Gaim + * + * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org> + * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com> + * Inspired by a similar plugin by: + * John (J5) Palmieri <johnp@martianrock.com> + * + * 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 <windows.h> +#include <gdk/gdkwin32.h> +#include <gdk/gdk.h> + +#include "internal.h" +#include "gtkblist.h" +#include "debug.h" + +#include "resource.h" +#include "MinimizeToTray.h" +#include "gtkwin32dep.h" +#include "gtkdocklet.h" + +/* + * DEFINES, MACROS & DATA TYPES + */ +#define WM_TRAYMESSAGE WM_USER /* User defined WM Message */ + +/* + * LOCALS + */ +static HWND systray_hwnd = 0; +static HICON sysicon_disconn = 0; +static HICON sysicon_conn = 0; +static HICON sysicon_away = 0; +static HICON sysicon_pend = 0; +static HICON sysicon_awypend = 0; +static HICON sysicon_blank = 0; +static NOTIFYICONDATA wgaim_nid; + + +static LRESULT CALLBACK systray_mainmsg_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { + static UINT taskbarRestartMsg; /* static here means value is kept across multiple calls to this func */ + + switch(msg) { + case WM_CREATE: + gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_CREATE\n"); + taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated"); + break; + + case WM_TIMER: + gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_TIMER\n"); + break; + + case WM_DESTROY: + gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_DESTROY\n"); + break; + + case WM_TRAYMESSAGE: + { + int type = 0; + + /* We'll use Double Click - Single click over on linux */ + if(lparam == WM_LBUTTONDBLCLK) + type = 1; + else if(lparam == WM_MBUTTONUP) + type = 2; + else if(lparam == WM_RBUTTONUP) + type = 3; + else + break; + + gaim_gtk_docklet_clicked(type); + break; + } + default: + if (msg == taskbarRestartMsg) { + /* explorer crashed and left us hanging... + This will put the systray icon back in it's place, when it restarts */ + Shell_NotifyIcon(NIM_ADD, &wgaim_nid); + } + break; + }/* end switch */ + + return DefWindowProc(hwnd, msg, wparam, lparam); +} + +/* Create hidden window to process systray messages */ +static HWND systray_create_hiddenwin() { + WNDCLASSEX wcex; + LPCTSTR wname; + + wname = TEXT("WingaimSystrayWinCls"); + + + wcex.cbSize = sizeof(wcex); + wcex.style = 0; + wcex.lpfnWndProc = systray_mainmsg_handler; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = gtkwgaim_hinstance(); + wcex.hIcon = NULL; + wcex.hCursor = NULL, + wcex.hbrBackground = NULL; + wcex.lpszMenuName = NULL; + wcex.lpszClassName = wname; + wcex.hIconSm = NULL; + + RegisterClassEx(&wcex); + + /* Create the window */ + return (CreateWindow(wname, "", 0, 0, 0, 0, 0, GetDesktopWindow(), NULL, gtkwgaim_hinstance(), 0)); +} + +static void systray_init_icon(HWND hWnd, HICON icon) { + ZeroMemory(&wgaim_nid, sizeof(wgaim_nid)); + wgaim_nid.cbSize = sizeof(NOTIFYICONDATA); + wgaim_nid.hWnd = hWnd; + wgaim_nid.uID = 0; + wgaim_nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; + wgaim_nid.uCallbackMessage = WM_TRAYMESSAGE; + wgaim_nid.hIcon = icon; + lstrcpy(wgaim_nid.szTip, "Gaim"); + Shell_NotifyIcon(NIM_ADD, &wgaim_nid); + gaim_gtk_docklet_embedded(); +} + +static void systray_change_icon(HICON icon) { + wgaim_nid.hIcon = icon; + Shell_NotifyIcon(NIM_MODIFY, &wgaim_nid); +} + +static void systray_remove_nid(void) { + Shell_NotifyIcon(NIM_DELETE, &wgaim_nid); +} + +static void wgaim_tray_update_icon(DockletStatus icon) { + switch (icon) { + case DOCKLET_STATUS_OFFLINE: + systray_change_icon(sysicon_disconn); + break; + case DOCKLET_STATUS_CONNECTING: + break; + case DOCKLET_STATUS_ONLINE: + systray_change_icon(sysicon_conn); + break; + case DOCKLET_STATUS_ONLINE_PENDING: + systray_change_icon(sysicon_pend); + break; + case DOCKLET_STATUS_AWAY: + systray_change_icon(sysicon_away); + break; + case DOCKLET_STATUS_AWAY_PENDING: + systray_change_icon(sysicon_awypend); + break; + } +} + +static void wgaim_tray_blank_icon() { + systray_change_icon(sysicon_blank); +} + +static void wgaim_tray_set_tooltip(gchar *tooltip) { + if (tooltip) { + char *locenc = NULL; + locenc = g_locale_from_utf8(tooltip, -1, NULL, NULL, NULL); + lstrcpyn(wgaim_nid.szTip, locenc, sizeof(wgaim_nid.szTip) / sizeof(TCHAR)); + g_free(locenc); + } else { + lstrcpy(wgaim_nid.szTip, "Gaim"); + } + Shell_NotifyIcon(NIM_MODIFY, &wgaim_nid); +} + +static void wgaim_tray_minimize(GaimGtkBuddyList *gtkblist) { + MinimizeWndToTray(GDK_WINDOW_HWND(gtkblist->window->window)); +} + +static void wgaim_tray_maximize(GaimGtkBuddyList *gtkblist) { + RestoreWndFromTray(GDK_WINDOW_HWND(gtkblist->window->window)); +} + + +static void wgaim_tray_create() { + OSVERSIONINFO osinfo; + /* dummy window to process systray messages */ + systray_hwnd = systray_create_hiddenwin(); + + osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osinfo); + + /* Load icons, and init systray notify icon + * NOTE: Windows < XP only supports displaying 4-bit images in the Systray, + * 2K and ME will use the highest color depth that the desktop will support, + * but will scale it back to 4-bits for display. + * That is why we use custom 4-bit icons for pre XP Windowses */ + if ((osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion > 0) || + (osinfo.dwMajorVersion >= 6)) + { + sysicon_disconn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + sysicon_conn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + sysicon_away = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + sysicon_pend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + sysicon_awypend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + } else { + sysicon_disconn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); + sysicon_conn = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); + sysicon_away = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); + sysicon_pend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); + sysicon_awypend = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0); + } + sysicon_blank = (HICON)LoadImage(gtkwgaim_hinstance(), MAKEINTRESOURCE(GAIM_BLANK_TRAY_ICON), IMAGE_ICON, 16, 16, 0); + + /* Create icon in systray */ + systray_init_icon(systray_hwnd, sysicon_disconn); + + gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-hiding", + gaim_gtk_docklet_get_handle(), GAIM_CALLBACK(wgaim_tray_minimize), NULL); + gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-unhiding", + gaim_gtk_docklet_get_handle(), GAIM_CALLBACK(wgaim_tray_maximize), NULL); + + gaim_debug(GAIM_DEBUG_INFO, "tray icon", "created\n"); +} + +static void wgaim_tray_destroy() { + systray_remove_nid(); + DestroyWindow(systray_hwnd); + gaim_gtk_docklet_remove(); +} + +static struct docklet_ui_ops wgaim_tray_ops = +{ + wgaim_tray_create, + wgaim_tray_destroy, + wgaim_tray_update_icon, + wgaim_tray_blank_icon, + wgaim_tray_set_tooltip, + NULL +}; + +/* Used by docklet's plugin load func */ +void docklet_ui_init() { + gaim_gtk_docklet_set_ui_ops(&wgaim_tray_ops); +}