annotate src/win32/systray.c @ 3959:9c2d8579ff3e

[gaim-migrate @ 4141] Gaim systray icon now has a right clickable menu committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Wed, 13 Nov 2002 23:53:13 +0000
parents 8ef1360becfe
children f9e961773058
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
1 /*
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
2 * systray.c
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
3 *
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
4 * Author: Herman Bloggs <hermanator12002@yahoo.com>
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
5 * Date: November, 2002
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
6 * Description: Gaim systray functionality
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
7 */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
8 #include <windows.h>
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
9 #include <gdk/gdkwin32.h>
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
10 #include "resource.h"
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
11 #include "gaim.h"
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
12 #include "win32dep.h"
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
13 #include "MinimizeToTray.h"
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
14 #include "ui.h"
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
15
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
16 /*
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
17 * DEFINES, MACROS & DATA TYPES
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
18 */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
19 #define GAIM_SYSTRAY_HINT _("Gaim Instant Messenger")
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
20 #define GAIM_SYSTRAY_DISCONN_HINT _("Gaim Instant Messenger - Signed off")
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
21 #define GAIM_SYSTRAY_AWAY_HINT _("Gaim Instant Messenger - Away")
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
22 #define WM_TRAYMESSAGE WM_USER /* User defined WM Message */
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
23 #define MAX_AWY_MESSAGES 50
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
24
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
25 enum _GAIM_WIN {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
26 GAIM_LOGIN_WIN,
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
27 GAIM_BUDDY_WIN,
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
28 GAIM_BACK_WIN,
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
29 GAIM_WIN_COUNT
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
30 };
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
31 typedef enum _GAIM_WIN GAIM_WIN;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
32
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
33 enum _SYSTRAY_STATE {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
34 SYSTRAY_STATE_CONN,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
35 SYSTRAY_STATE_CONNECTING,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
36 SYSTRAY_STATE_DISCONN,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
37 SYSTRAY_STATE_AWAY,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
38 SYSTRAY_STATE_COUNT
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
39 };
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
40 typedef enum _SYSTRAY_STATE SYSTRAY_STATE;
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
41
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
42 enum _SYSTRAY_CMND {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
43 SYSTRAY_CMND_MENU_EXIT,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
44 SYSTRAY_CMND_SIGNON,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
45 SYSTRAY_CMND_SIGNOFF,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
46 SYSTRAY_CMND_AUTOLOGIN,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
47 SYSTRAY_CMND_PREFS,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
48 SYSTRAY_CMND_BACK,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
49 SYSTRAY_CMND_SET_AWY_NEW,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
50 SYSTRAY_CMND_SET_AWY,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
51 SYSTRAY_CMND_SET_AWY_LAST=SYSTRAY_CMND_SET_AWY+MAX_AWY_MESSAGES
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
52 };
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
53 typedef enum _SYSTRAY_CMND SYSTRAY_CMND;
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
54
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
55 /*
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
56 * LOCALS
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
57 */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
58 static HWND systray_hwnd=0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
59 static HICON sysicon_disconn=0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
60 static HICON sysicon_conn=0;
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
61 static HICON sysicon_away=0;
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
62 static NOTIFYICONDATA wgaim_nid;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
63 static HWND gaim_windows[GAIM_WIN_COUNT];
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
64 static SYSTRAY_STATE st_state=SYSTRAY_STATE_DISCONN;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
65 static HMENU systray_menu=0;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
66 static HMENU systray_away_menu=0;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
67
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
68 /*
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
69 * GLOBALS
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
70 */
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
71
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
72 /*
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
73 * PRIVATE CODE
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
74 */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
75
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
76 /*
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
77 * SYSTRAY HELPERS
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
78 ********************/
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
79
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
80 /* Returns 1 if menu item exists, 0 if not */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
81 static int IsMenuItem( HMENU hMenu, UINT id ) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
82 if(0xFFFFFFFF == GetMenuState(hMenu, id, MF_BYCOMMAND))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
83 return 0;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
84 else
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
85 return 1;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
86 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
87
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
88 /*
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
89 * WGAIM SYSTRAY GUI
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
90 ********************/
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
91
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
92 static HMENU systray_create_awy_menu(void) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
93 int item_count = SYSTRAY_CMND_SET_AWY;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
94 struct away_message *a = NULL;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
95 GSList *awy = away_messages;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
96
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
97 /* Delete previous away submenu */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
98 if(systray_away_menu) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
99 DestroyMenu(systray_away_menu);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
100 systray_away_menu = 0;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
101 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
102 systray_away_menu = CreatePopupMenu();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
103 while (awy && (item_count <= SYSTRAY_CMND_SET_AWY+MAX_AWY_MESSAGES)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
104 a = (struct away_message *)awy->data;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
105 AppendMenu(systray_away_menu, MF_STRING, item_count, a->name);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
106 awy = g_slist_next(awy);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
107 item_count+=1;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
108 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
109 AppendMenu(systray_away_menu, MF_SEPARATOR, 0, 0);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
110 AppendMenu(systray_away_menu, MF_STRING, SYSTRAY_CMND_SET_AWY_NEW, _("New"));
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
111 return systray_away_menu;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
112 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
113
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
114 static void systray_show_menu(int x, int y, BOOL connected) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
115 /* need to call this so that the menu disappears if clicking outside
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
116 of the menu scope */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
117 SetForegroundWindow(systray_hwnd);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
118
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
119 /* Different menus depending on signed on/off state */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
120 if(connected) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
121 /* If signoff item dosn't exist.. create it */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
122 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_SIGNOFF)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
123 DeleteMenu(systray_menu, SYSTRAY_CMND_SIGNON, MF_BYCOMMAND);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
124 InsertMenu(systray_menu, SYSTRAY_CMND_MENU_EXIT,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
125 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_SIGNOFF, _("Signoff"));
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
126 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
127 /* if away menu exists, remove and rebuild it */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
128 if(systray_away_menu) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
129 if(!DeleteMenu(systray_menu, (UINT)systray_away_menu, MF_BYCOMMAND))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
130 debug_printf("Error using DeleteMenu\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
131 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
132 InsertMenu(systray_menu, SYSTRAY_CMND_PREFS,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
133 MF_BYCOMMAND | MF_POPUP | MF_STRING, (UINT)systray_create_awy_menu(),
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
134 _("Set Away Message"));
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
135 EnableMenuItem(systray_menu, SYSTRAY_CMND_AUTOLOGIN, MF_GRAYED);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
136 /* If away, put "I'm Back" option in menu */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
137 if(st_state == SYSTRAY_STATE_AWAY) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
138 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_BACK)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
139 InsertMenu(systray_menu, (UINT)systray_away_menu,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
140 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_BACK,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
141 _("I'm Back"));
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
142 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
143 } else {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
144 /* Delete I'm Back item if it exists */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
145 DeleteMenu(systray_menu, SYSTRAY_CMND_BACK, MF_BYCOMMAND);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
146 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
147 } else {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
148 /* If signon item dosn't exist.. create it */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
149 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_SIGNON)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
150 DeleteMenu(systray_menu, SYSTRAY_CMND_SIGNOFF, MF_BYCOMMAND);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
151 InsertMenu(systray_menu, SYSTRAY_CMND_MENU_EXIT,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
152 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_SIGNON, _("Sign On"));
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
153 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
154 EnableMenuItem(systray_menu, SYSTRAY_CMND_AUTOLOGIN, MF_ENABLED);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
155 EnableMenuItem(systray_menu, (UINT)systray_away_menu, MF_GRAYED);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
156 /* Delete I'm Back item if it exists */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
157 DeleteMenu(systray_menu, SYSTRAY_CMND_BACK, MF_BYCOMMAND);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
158 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
159
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
160 TrackPopupMenu(systray_menu, // handle to shortcut menu
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
161 TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
162 x, // horizontal position, in screen coordinates
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
163 y, // vertical position, in screen coordinates
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
164 0, // reserved, must be zero
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
165 systray_hwnd, // handle to owner window
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
166 NULL // ignored
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
167 );
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
168 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
169
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
170 /* Set nth away message from away_messages list */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
171 static void systray_set_away(int nth) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
172 int item_count = 0;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
173 GSList *awy = away_messages;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
174 struct away_message *a = NULL;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
175
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
176 while (awy && (item_count != nth)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
177 awy = g_slist_next(awy);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
178 item_count+=1;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
179 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
180 if(awy) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
181 a = (struct away_message *)awy->data;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
182 do_away_message(NULL, a);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
183 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
184 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
185
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
186 static LRESULT CALLBACK systray_mainmsg_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
187
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
188 switch(msg) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
189 case WM_CREATE:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
190 debug_printf("WM_CREATE\n");
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
191 break;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
192
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
193 case WM_TIMER:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
194 debug_printf("WM_TIMER\n");
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
195 break;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
196
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
197 case WM_DESTROY:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
198 debug_printf("WM_DESTROY\n");
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
199 break;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
200
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
201 case WM_COMMAND:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
202 debug_printf("WM_COMMAND\n");
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
203 switch(LOWORD(wparam)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
204 case SYSTRAY_CMND_MENU_EXIT:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
205 do_quit();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
206 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
207 case SYSTRAY_CMND_SIGNON:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
208 debug_printf("signon\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
209 show_login();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
210 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
211 case SYSTRAY_CMND_SIGNOFF:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
212 debug_printf("signoff\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
213 signoff_all();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
214 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
215 case SYSTRAY_CMND_AUTOLOGIN:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
216 debug_printf("autologin\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
217 auto_login();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
218 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
219 case SYSTRAY_CMND_PREFS:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
220 debug_printf("Prefs\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
221 show_prefs();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
222 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
223 case SYSTRAY_CMND_BACK:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
224 debug_printf("I'm back\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
225 do_im_back(NULL, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
226 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
227 case SYSTRAY_CMND_SET_AWY_NEW:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
228 debug_printf("New away item\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
229 create_away_mess(NULL, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
230 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
231 default:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
232 /* SYSTRAY_CMND_SET_AWY */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
233 if((LOWORD(wparam) >= SYSTRAY_CMND_SET_AWY) &&
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
234 (LOWORD(wparam) <= (SYSTRAY_CMND_SET_AWY + MAX_AWY_MESSAGES))) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
235 debug_printf("Set away message\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
236 systray_set_away(LOWORD(wparam)-SYSTRAY_CMND_SET_AWY);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
237 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
238 }
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
239 break;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
240 case WM_TRAYMESSAGE:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
241 {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
242 if( lparam == WM_LBUTTONDBLCLK ) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
243 /* If Gaim main win is hidden.. restore it */
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
244 if( st_state == SYSTRAY_STATE_DISCONN ) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
245 RestoreWndFromTray(gaim_windows[GAIM_LOGIN_WIN]);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
246 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
247 else if( st_state == SYSTRAY_STATE_AWAY ) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
248 RestoreWndFromTray(gaim_windows[GAIM_BACK_WIN]);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
249 RestoreWndFromTray(gaim_windows[GAIM_BUDDY_WIN]);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
250 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
251 else if( st_state == SYSTRAY_STATE_CONN ) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
252 RestoreWndFromTray(gaim_windows[GAIM_BUDDY_WIN]);
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
253 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
254 debug_printf("Systray got double click\n");
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
255 }
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
256 if( lparam == WM_RBUTTONUP ) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
257 POINT mpoint;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
258 GetCursorPos(&mpoint);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
259 /* Are we connected ? */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
260 if(st_state == SYSTRAY_STATE_CONNECTING)
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
261 break; /* no menu when connecting */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
262 if(st_state == SYSTRAY_STATE_DISCONN)
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
263 systray_show_menu(mpoint.x, mpoint.y, 0);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
264 else
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
265 systray_show_menu(mpoint.x, mpoint.y, 1);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
266 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
267 break;
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
268 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
269 default:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
270 }/* end switch */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
271
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
272 return DefWindowProc(hwnd, msg, wparam, lparam);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
273 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
274
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
275 /* Create hidden window to process systray messages */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
276 static HWND systray_create_hiddenwin() {
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
277 WNDCLASSEX wcex;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
278 TCHAR wname[32];
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
279
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
280 strcpy(wname, "GaimWin");
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
281
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
282 wcex.cbSize = sizeof(WNDCLASSEX);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
283
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
284 wcex.style = 0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
285 wcex.lpfnWndProc = (WNDPROC)systray_mainmsg_handler;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
286 wcex.cbClsExtra = 0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
287 wcex.cbWndExtra = 0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
288 wcex.hInstance = wgaim_hinstance();
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
289 wcex.hIcon = NULL;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
290 wcex.hCursor = NULL,
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
291 wcex.hbrBackground = NULL;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
292 wcex.lpszMenuName = NULL;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
293 wcex.lpszClassName = wname;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
294 wcex.hIconSm = NULL;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
295
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
296 RegisterClassEx(&wcex);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
297
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
298 // Create the window
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
299 return (CreateWindow(wname, "", 0, 0, 0, 0, 0, GetDesktopWindow(), NULL, wgaim_hinstance(), 0));
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
300 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
301
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
302 static void systray_create_menu(void) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
303 /* create popup menu */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
304 if((systray_menu = CreatePopupMenu())) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
305 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_PREFS, _("Preferences")))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
306 debug_printf("AppendMenu error: %d\n", GetLastError());
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
307 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_AUTOLOGIN, _("Auto-login")))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
308 debug_printf("AppendMenu error: %d\n", GetLastError());
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
309 if(!AppendMenu(systray_menu, MF_SEPARATOR, 0, 0))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
310 debug_printf("AppendMenu error: %d\n", GetLastError());
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
311 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_MENU_EXIT, _("Exit")))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
312 debug_printf("AppendMenu error: %d\n", GetLastError());
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
313 } else
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
314 debug_printf("CreatePopupMenu error: %d\n", GetLastError());
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
315 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
316
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
317 static void systray_init_icon(HWND hWnd, HICON icon) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
318 ZeroMemory(&wgaim_nid,sizeof(wgaim_nid));
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
319 wgaim_nid.cbSize=sizeof(NOTIFYICONDATA);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
320 wgaim_nid.hWnd=hWnd;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
321 wgaim_nid.uID=0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
322 wgaim_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
323 wgaim_nid.uCallbackMessage=WM_TRAYMESSAGE;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
324 wgaim_nid.hIcon=icon;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
325 strcpy(wgaim_nid.szTip,GAIM_SYSTRAY_DISCONN_HINT);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
326
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
327 Shell_NotifyIcon(NIM_ADD,&wgaim_nid);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
328 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
329
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
330 static void systray_change_icon(HICON icon, char* text) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
331 wgaim_nid.hIcon = icon;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
332 lstrcpy(wgaim_nid.szTip, text);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
333 Shell_NotifyIcon(NIM_MODIFY,&wgaim_nid);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
334 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
335
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
336 static void systray_remove_nid(void) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
337 Shell_NotifyIcon(NIM_DELETE,&wgaim_nid);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
338 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
339
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
340 static void systray_minimize_win(HWND hWnd) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
341 MinimizeWndToTray(hWnd);
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
342 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
343
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
344 static void systray_update_icon() {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
345 switch(st_state) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
346 case SYSTRAY_STATE_CONN:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
347 systray_change_icon(sysicon_conn, GAIM_SYSTRAY_HINT);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
348 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
349 case SYSTRAY_STATE_CONNECTING:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
350 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
351 case SYSTRAY_STATE_DISCONN:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
352 systray_change_icon(sysicon_disconn, GAIM_SYSTRAY_DISCONN_HINT);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
353 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
354 case SYSTRAY_STATE_AWAY:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
355 systray_change_icon(sysicon_away, GAIM_SYSTRAY_AWAY_HINT);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
356 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
357 }
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
358 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
359
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
360 static void systray_update_status() {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
361 SYSTRAY_STATE old_state = st_state;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
362
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
363 if(connections) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
364 if(awaymessage) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
365 st_state = SYSTRAY_STATE_AWAY;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
366 } else if(connecting_count) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
367 st_state = SYSTRAY_STATE_CONNECTING;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
368 } else {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
369 st_state = SYSTRAY_STATE_CONN;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
370 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
371 } else {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
372 if(connecting_count) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
373 st_state = SYSTRAY_STATE_CONNECTING;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
374 } else {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
375 st_state = SYSTRAY_STATE_DISCONN;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
376 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
377 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
378 if(st_state != old_state) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
379 systray_update_icon();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
380 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
381 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
382
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
383 /*
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
384 * GAIM WINDOW FILTERS
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
385 **********************/
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
386
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
387 static GdkFilterReturn st_buddywin_filter( GdkXEvent *xevent, GdkEvent *event, gpointer data) {
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
388
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
389 MSG *msg = (MSG*)xevent;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
390
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
391 switch( msg->message ) {
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
392 case WM_SYSCOMMAND:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
393 if( msg->wParam == SC_MINIMIZE ) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
394 systray_minimize_win(msg->hwnd);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
395 /* Also minimize I'm back window */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
396 if(st_state == SYSTRAY_STATE_AWAY)
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
397 systray_minimize_win(gaim_windows[GAIM_BACK_WIN]);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
398 return GDK_FILTER_REMOVE;
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
399 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
400 break;
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
401 case WM_CLOSE:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
402 systray_minimize_win(msg->hwnd);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
403 /* Also minimize I'm back window */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
404 if(st_state == SYSTRAY_STATE_AWAY)
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
405 systray_minimize_win(gaim_windows[GAIM_BACK_WIN]);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
406 return GDK_FILTER_REMOVE;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
407 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
408
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
409 return GDK_FILTER_CONTINUE;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
410 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
411
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
412 static GdkFilterReturn st_loginwin_filter( GdkXEvent *xevent, GdkEvent *event, gpointer data) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
413 MSG *msg = (MSG*)xevent;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
414
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
415 switch( msg->message ) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
416 case WM_CLOSE:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
417 systray_minimize_win(msg->hwnd);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
418 return GDK_FILTER_REMOVE;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
419 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
420
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
421 return GDK_FILTER_CONTINUE;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
422 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
423
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
424 static GdkFilterReturn st_backwin_filter( GdkXEvent *xevent, GdkEvent *event, gpointer data) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
425 MSG *msg = (MSG*)xevent;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
426
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
427 switch( msg->message ) {
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
428 case WM_SYSCOMMAND:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
429 if( msg->wParam == SC_MINIMIZE ) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
430 systray_minimize_win(msg->hwnd);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
431 return GDK_FILTER_REMOVE;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
432 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
433 break;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
434 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
435 return GDK_FILTER_CONTINUE;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
436 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
437
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
438 /*
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
439 * GAIM EVENT CALLBACKS
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
440 ***********************/
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
441
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
442 static void st_signon(struct gaim_connection *gc, void *data) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
443 systray_update_status();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
444 }
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
445
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
446 static void st_signoff(struct gaim_connection *gc, void *data) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
447 systray_update_status();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
448 }
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
449
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
450 static void st_away(struct gaim_connection *gc, void *data) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
451 systray_update_status();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
452 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
453
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
454 static void st_back(struct gaim_connection *gc, void *data) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
455 systray_update_status();
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
456 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
457
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
458 /*
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
459 * PUBLIC CODE
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
460 */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
461
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
462 /* Create a hidden window and associate it with the systray icon.
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
463 We use this hidden window to proccess WM_TRAYMESSAGE msgs. */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
464 void wgaim_systray_init(void) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
465 /* dummy window to process systray messages */
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
466 systray_hwnd = systray_create_hiddenwin();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
467
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
468 systray_create_menu();
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
469
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
470 /* Load icons, and init systray notify icon */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
471 sysicon_disconn = LoadIcon(wgaim_hinstance(),MAKEINTRESOURCE(IDI_ICON2));
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
472 sysicon_conn = LoadIcon(wgaim_hinstance(),MAKEINTRESOURCE(IDI_ICON3));
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
473 sysicon_away = LoadIcon(wgaim_hinstance(),MAKEINTRESOURCE(IDI_ICON4));
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
474
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
475 /* Create icon in systray */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
476 systray_init_icon(systray_hwnd, sysicon_disconn);
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
477
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
478 /* Register Gaim event callbacks */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
479 gaim_signal_connect(NULL, event_signon, st_signon, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
480 gaim_signal_connect(NULL, event_signoff, st_signoff, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
481 gaim_signal_connect(NULL, event_away, st_away, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
482 gaim_signal_connect(NULL, event_back, st_back, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
483 /*gaim_signal_connect(NULL, event_connecting, wgaim_st_connecting, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
484 gaim_signal_connect(NULL, event_im_displayed_rcvd, wgaim_st_im_displayed_recv, NULL);*/
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
485 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
486
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
487 void wgaim_systray_cleanup(void) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
488 systray_remove_nid();
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
489 DestroyMenu(systray_menu);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
490 DestroyWindow(systray_hwnd);
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
491 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
492
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
493 /* This function is called after the buddy list has been created */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
494 void wgaim_created_blistwin( GtkWidget *blist ) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
495 gdk_window_add_filter (GTK_WIDGET(blist)->window,
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
496 st_buddywin_filter,
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
497 NULL);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
498 gaim_windows[GAIM_BUDDY_WIN] = GDK_WINDOW_HWND(GTK_WIDGET(blist)->window);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
499 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
500
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
501 /* This function is called after the login window has been created */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
502 void wgaim_created_loginwin( GtkWidget *loginwin ) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
503 gdk_window_add_filter (GTK_WIDGET(loginwin)->window,
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
504 st_loginwin_filter,
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
505 NULL);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
506 gaim_windows[GAIM_LOGIN_WIN] = GDK_WINDOW_HWND(GTK_WIDGET(loginwin)->window);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
507 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
508
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
509 void wgaim_created_backwin( GtkWidget *backwin ) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
510 gdk_window_add_filter (GTK_WIDGET(backwin)->window,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
511 st_backwin_filter,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
512 NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
513 gaim_windows[GAIM_BACK_WIN] = GDK_WINDOW_HWND(GTK_WIDGET(backwin)->window);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
514 }