annotate src/win32/systray.c @ 4365:6e96ced6fb78

[gaim-migrate @ 4631] Hope this fixes the problems people are having. I have to leave for awhile. Pain Day. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 20 Jan 2003 18:12:14 +0000
parents a843ce9d77ea
children f5e7949668a5
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
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
25 enum _SYSTRAY_STATE {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
26 SYSTRAY_STATE_CONN,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
27 SYSTRAY_STATE_CONNECTING,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
28 SYSTRAY_STATE_DISCONN,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
29 SYSTRAY_STATE_AWAY,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
30 SYSTRAY_STATE_COUNT
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
31 };
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
32 typedef enum _SYSTRAY_STATE SYSTRAY_STATE;
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
33
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
34 enum _SYSTRAY_CMND {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
35 SYSTRAY_CMND_MENU_EXIT,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
36 SYSTRAY_CMND_SIGNON,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
37 SYSTRAY_CMND_SIGNOFF,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
38 SYSTRAY_CMND_AUTOLOGIN,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
39 SYSTRAY_CMND_PREFS,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
40 SYSTRAY_CMND_BACK,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
41 SYSTRAY_CMND_SET_AWY_NEW,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
42 SYSTRAY_CMND_SET_AWY,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
43 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
44 };
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
45 typedef enum _SYSTRAY_CMND SYSTRAY_CMND;
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
46
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
47 /*
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
48 * LOCALS
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
49 */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
50 static HWND systray_hwnd=0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
51 static HICON sysicon_disconn=0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
52 static HICON sysicon_conn=0;
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
53 static HICON sysicon_away=0;
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
54 static NOTIFYICONDATA wgaim_nid;
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
55 static SYSTRAY_STATE st_state=SYSTRAY_STATE_DISCONN;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
56 static HMENU systray_menu=0;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
57 static HMENU systray_away_menu=0;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
58
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
59 /*
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
60 * GLOBALS
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
61 */
3972
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
62 extern GtkWidget *imaway;
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
63
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
64 /*
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
65 * PRIVATE CODE
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
66 */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
67
3959
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 * SYSTRAY HELPERS
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
70 ********************/
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
71
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
72 /* Returns 1 if menu item exists, 0 if not */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
73 static int IsMenuItem( HMENU hMenu, UINT id ) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
74 if(0xFFFFFFFF == GetMenuState(hMenu, id, MF_BYCOMMAND))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
75 return 0;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
76 else
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
77 return 1;
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 /*
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
81 * WGAIM SYSTRAY GUI
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
82 ********************/
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
83
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
84 static HMENU systray_create_awy_menu(void) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
85 int item_count = SYSTRAY_CMND_SET_AWY;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
86 struct away_message *a = NULL;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
87 GSList *awy = away_messages;
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 /* Delete previous away submenu */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
90 if(systray_away_menu) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
91 DestroyMenu(systray_away_menu);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
92 systray_away_menu = 0;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
93 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
94 systray_away_menu = CreatePopupMenu();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
95 while (awy && (item_count <= SYSTRAY_CMND_SET_AWY+MAX_AWY_MESSAGES)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
96 a = (struct away_message *)awy->data;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
97 AppendMenu(systray_away_menu, MF_STRING, item_count, a->name);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
98 awy = g_slist_next(awy);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
99 item_count+=1;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
100 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
101 AppendMenu(systray_away_menu, MF_SEPARATOR, 0, 0);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
102 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
103 return systray_away_menu;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
104 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
105
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
106 static void systray_show_menu(int x, int y, BOOL connected) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
107 /* 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
108 of the menu scope */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
109 SetForegroundWindow(systray_hwnd);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
110
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
111 /* Different menus depending on signed on/off state */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
112 if(connected) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
113 /* If signoff item dosn't exist.. create it */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
114 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_SIGNOFF)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
115 DeleteMenu(systray_menu, SYSTRAY_CMND_SIGNON, MF_BYCOMMAND);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
116 InsertMenu(systray_menu, SYSTRAY_CMND_MENU_EXIT,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
117 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_SIGNOFF, _("Signoff"));
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 /* if away menu exists, remove and rebuild it */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
120 if(systray_away_menu) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
121 if(!DeleteMenu(systray_menu, (UINT)systray_away_menu, MF_BYCOMMAND))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
122 debug_printf("Error using DeleteMenu\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
123 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
124 InsertMenu(systray_menu, SYSTRAY_CMND_PREFS,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
125 MF_BYCOMMAND | MF_POPUP | MF_STRING, (UINT)systray_create_awy_menu(),
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
126 _("Set Away Message"));
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
127 EnableMenuItem(systray_menu, SYSTRAY_CMND_AUTOLOGIN, MF_GRAYED);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
128 /* If away, put "I'm Back" option in menu */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
129 if(st_state == SYSTRAY_STATE_AWAY) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
130 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_BACK)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
131 InsertMenu(systray_menu, (UINT)systray_away_menu,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
132 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_BACK,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
133 _("I'm Back"));
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
134 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
135 } else {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
136 /* Delete I'm Back item if it exists */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
137 DeleteMenu(systray_menu, SYSTRAY_CMND_BACK, MF_BYCOMMAND);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
138 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
139 } else {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
140 /* If signon item dosn't exist.. create it */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
141 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_SIGNON)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
142 DeleteMenu(systray_menu, SYSTRAY_CMND_SIGNOFF, MF_BYCOMMAND);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
143 InsertMenu(systray_menu, SYSTRAY_CMND_MENU_EXIT,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
144 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_SIGNON, _("Sign On"));
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
145 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
146 EnableMenuItem(systray_menu, SYSTRAY_CMND_AUTOLOGIN, MF_ENABLED);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
147 EnableMenuItem(systray_menu, (UINT)systray_away_menu, MF_GRAYED);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
148 /* Delete I'm Back item if it exists */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
149 DeleteMenu(systray_menu, SYSTRAY_CMND_BACK, MF_BYCOMMAND);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
150 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
151
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
152 TrackPopupMenu(systray_menu, // handle to shortcut menu
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
153 TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON,
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
154 x, // horizontal position, in screen coordinates
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
155 y, // vertical position, in screen coordinates
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
156 0, // reserved, must be zero
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
157 systray_hwnd, // handle to owner window
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
158 NULL // ignored
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 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
161
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
162 /* Set nth away message from away_messages list */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
163 static void systray_set_away(int nth) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
164 int item_count = 0;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
165 GSList *awy = away_messages;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
166 struct away_message *a = NULL;
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 while (awy && (item_count != nth)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
169 awy = g_slist_next(awy);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
170 item_count+=1;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
171 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
172 if(awy) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
173 a = (struct away_message *)awy->data;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
174 do_away_message(NULL, a);
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 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
177
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
178 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
179
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
180 switch(msg) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
181 case WM_CREATE:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
182 debug_printf("WM_CREATE\n");
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
183 break;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
184
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
185 case WM_TIMER:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
186 debug_printf("WM_TIMER\n");
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
187 break;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
188
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
189 case WM_DESTROY:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
190 debug_printf("WM_DESTROY\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_COMMAND:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
194 debug_printf("WM_COMMAND\n");
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
195 switch(LOWORD(wparam)) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
196 case SYSTRAY_CMND_MENU_EXIT:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
197 do_quit();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
198 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
199 case SYSTRAY_CMND_SIGNON:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
200 debug_printf("signon\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
201 show_login();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
202 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
203 case SYSTRAY_CMND_SIGNOFF:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
204 debug_printf("signoff\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
205 signoff_all();
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_AUTOLOGIN:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
208 debug_printf("autologin\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
209 auto_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_PREFS:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
212 debug_printf("Prefs\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
213 show_prefs();
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_BACK:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
216 debug_printf("I'm back\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
217 do_im_back(NULL, NULL);
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_SET_AWY_NEW:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
220 debug_printf("New away item\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
221 create_away_mess(NULL, NULL);
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 default:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
224 /* SYSTRAY_CMND_SET_AWY */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
225 if((LOWORD(wparam) >= SYSTRAY_CMND_SET_AWY) &&
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
226 (LOWORD(wparam) <= (SYSTRAY_CMND_SET_AWY + MAX_AWY_MESSAGES))) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
227 debug_printf("Set away message\n");
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
228 systray_set_away(LOWORD(wparam)-SYSTRAY_CMND_SET_AWY);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
229 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
230 }
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
231 break;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
232 case WM_TRAYMESSAGE:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
233 {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
234 if( lparam == WM_LBUTTONDBLCLK ) {
3972
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
235 /* Either hide or show current window (login or buddy) */
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
236 docklet_toggle();
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
237 /* if away.. hide/show I'm back win too */
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
238 if(st_state == SYSTRAY_STATE_AWAY) {
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
239 if(GTK_WIDGET_VISIBLE(blist) && !GTK_WIDGET_VISIBLE(imaway)) {
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
240 RestoreWndFromTray(GDK_WINDOW_HWND(GTK_WIDGET(imaway)->window));
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
241 gtk_window_present(GTK_WINDOW(imaway));
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
242 } else if(!GTK_WIDGET_VISIBLE(blist) && GTK_WIDGET_VISIBLE(imaway)) {
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
243 wgaim_systray_minimize(imaway);
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
244 gtk_widget_hide(imaway);
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
245 }
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
246 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
247 debug_printf("Systray got double click\n");
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
248 }
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
249 if( lparam == WM_RBUTTONUP ) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
250 POINT mpoint;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
251 GetCursorPos(&mpoint);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
252 /* Are we connected ? */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
253 if(st_state == SYSTRAY_STATE_CONNECTING)
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
254 break; /* no menu when connecting */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
255 if(st_state == SYSTRAY_STATE_DISCONN)
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
256 systray_show_menu(mpoint.x, mpoint.y, 0);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
257 else
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
258 systray_show_menu(mpoint.x, mpoint.y, 1);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
259 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
260 break;
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
261 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
262 default:
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
263 }/* end switch */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
264
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
265 return DefWindowProc(hwnd, msg, wparam, lparam);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
266 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
267
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
268 /* Create hidden window to process systray messages */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
269 static HWND systray_create_hiddenwin() {
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
270 WNDCLASSEX wcex;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
271 TCHAR wname[32];
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
272
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
273 strcpy(wname, "GaimWin");
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
274
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
275 wcex.cbSize = sizeof(WNDCLASSEX);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
276
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
277 wcex.style = 0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
278 wcex.lpfnWndProc = (WNDPROC)systray_mainmsg_handler;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
279 wcex.cbClsExtra = 0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
280 wcex.cbWndExtra = 0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
281 wcex.hInstance = wgaim_hinstance();
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
282 wcex.hIcon = NULL;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
283 wcex.hCursor = NULL,
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
284 wcex.hbrBackground = NULL;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
285 wcex.lpszMenuName = NULL;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
286 wcex.lpszClassName = wname;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
287 wcex.hIconSm = NULL;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
288
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
289 RegisterClassEx(&wcex);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
290
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
291 // Create the window
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
292 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
293 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
294
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
295 static void systray_create_menu(void) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
296 /* create popup menu */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
297 if((systray_menu = CreatePopupMenu())) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
298 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_PREFS, _("Preferences")))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
299 debug_printf("AppendMenu error: %d\n", GetLastError());
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
300 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_AUTOLOGIN, _("Auto-login")))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
301 debug_printf("AppendMenu error: %d\n", GetLastError());
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
302 if(!AppendMenu(systray_menu, MF_SEPARATOR, 0, 0))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
303 debug_printf("AppendMenu error: %d\n", GetLastError());
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
304 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_MENU_EXIT, _("Exit")))
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
305 debug_printf("AppendMenu error: %d\n", GetLastError());
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
306 } else
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
307 debug_printf("CreatePopupMenu error: %d\n", GetLastError());
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
308 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
309
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
310 static void systray_init_icon(HWND hWnd, HICON icon) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
311 ZeroMemory(&wgaim_nid,sizeof(wgaim_nid));
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
312 wgaim_nid.cbSize=sizeof(NOTIFYICONDATA);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
313 wgaim_nid.hWnd=hWnd;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
314 wgaim_nid.uID=0;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
315 wgaim_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
316 wgaim_nid.uCallbackMessage=WM_TRAYMESSAGE;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
317 wgaim_nid.hIcon=icon;
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
318 strcpy(wgaim_nid.szTip,GAIM_SYSTRAY_DISCONN_HINT);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
319
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
320 Shell_NotifyIcon(NIM_ADD,&wgaim_nid);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
321 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
322
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
323 static void systray_change_icon(HICON icon, char* text) {
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 lstrcpy(wgaim_nid.szTip, text);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
326 Shell_NotifyIcon(NIM_MODIFY,&wgaim_nid);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
327 }
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 static void systray_remove_nid(void) {
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
330 Shell_NotifyIcon(NIM_DELETE,&wgaim_nid);
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
331 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
332
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
333 static void systray_update_icon() {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
334 switch(st_state) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
335 case SYSTRAY_STATE_CONN:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
336 systray_change_icon(sysicon_conn, GAIM_SYSTRAY_HINT);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
337 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
338 case SYSTRAY_STATE_CONNECTING:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
339 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
340 case SYSTRAY_STATE_DISCONN:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
341 systray_change_icon(sysicon_disconn, GAIM_SYSTRAY_DISCONN_HINT);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
342 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
343 case SYSTRAY_STATE_AWAY:
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
344 systray_change_icon(sysicon_away, GAIM_SYSTRAY_AWAY_HINT);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
345 break;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
346 }
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
347 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
348
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
349 static void systray_update_status() {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
350 SYSTRAY_STATE old_state = st_state;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
351
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
352 if(connections) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
353 if(awaymessage) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
354 st_state = SYSTRAY_STATE_AWAY;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
355 } else if(connecting_count) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
356 st_state = SYSTRAY_STATE_CONNECTING;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
357 } else {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
358 st_state = SYSTRAY_STATE_CONN;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
359 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
360 } else {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
361 if(connecting_count) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
362 st_state = SYSTRAY_STATE_CONNECTING;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
363 } else {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
364 st_state = SYSTRAY_STATE_DISCONN;
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
365 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
366 }
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
367 if(st_state != old_state) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
368 systray_update_icon();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
369 }
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
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
372 /*
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
373 * GAIM EVENT CALLBACKS
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
374 ***********************/
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
375
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
376 static void st_signon(struct gaim_connection *gc, void *data) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
377 systray_update_status();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
378 }
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
379
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
380 static void st_signoff(struct gaim_connection *gc, void *data) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
381 systray_update_status();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
382 }
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
383
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
384 static void st_away(struct gaim_connection *gc, void *data) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
385 systray_update_status();
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
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
388 static void st_back(struct gaim_connection *gc, void *data) {
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
389 systray_update_status();
3946
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
3972
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
392 static void st_im_recieve(struct gaim_connection *gc, void *data) {
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
393
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
394 }
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
395
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
396 /*
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
397 * PUBLIC CODE
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
398 */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
399
4106
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
400 /*
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
401 * GAIM WINDOW FILTERS
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
402 **********************/
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
403
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
404 GdkFilterReturn st_buddywin_filter( GdkXEvent *xevent, GdkEvent *event, gpointer data) {
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
405
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
406 MSG *msg = (MSG*)xevent;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
407
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
408 switch( msg->message ) {
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
409 case WM_SYSCOMMAND:
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
410 if( msg->wParam == SC_MINIMIZE ) {
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
411 hide_buddy_list();
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
412 return GDK_FILTER_REMOVE;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
413 }
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
414 break;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
415 case WM_CLOSE:
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
416 hide_buddy_list();
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
417 return GDK_FILTER_REMOVE;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
418 }
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
419
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
420 return GDK_FILTER_CONTINUE;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
421 }
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
422
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
423 GdkFilterReturn st_loginwin_filter( GdkXEvent *xevent, GdkEvent *event, gpointer data) {
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
424 MSG *msg = (MSG*)xevent;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
425
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
426 switch( msg->message ) {
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
427 case WM_CLOSE:
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
428 wgaim_systray_minimize(mainwindow);
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
429 gtk_widget_hide(mainwindow);
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
430 return GDK_FILTER_REMOVE;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
431 }
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
432
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
433 return GDK_FILTER_CONTINUE;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
434 }
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
435
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
436 GdkFilterReturn st_backwin_filter( GdkXEvent *xevent, GdkEvent *event, gpointer data) {
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
437 MSG *msg = (MSG*)xevent;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
438
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
439 switch( msg->message ) {
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
440 case WM_SYSCOMMAND:
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
441 if( msg->wParam == SC_MINIMIZE ) {
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
442 if(imaway) {
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
443 wgaim_systray_minimize(imaway);
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
444 gtk_widget_hide(imaway);
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
445 }
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
446 return GDK_FILTER_REMOVE;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
447 }
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
448 break;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
449 }
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
450 return GDK_FILTER_CONTINUE;
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
451 }
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
452
a843ce9d77ea [gaim-migrate @ 4321]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4101
diff changeset
453
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
454 /* Create a hidden window and associate it with the systray icon.
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
455 We use this hidden window to proccess WM_TRAYMESSAGE msgs. */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
456 void wgaim_systray_init(void) {
3972
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
457 docklet_add();
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
458
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
459 /* dummy window to process systray messages */
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
460 systray_hwnd = systray_create_hiddenwin();
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
461
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
462 systray_create_menu();
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
463
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
464 /* Load icons, and init systray notify icon */
4101
003e0a02d6b9 [gaim-migrate @ 4316]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4087
diff changeset
465 sysicon_disconn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
003e0a02d6b9 [gaim-migrate @ 4316]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4087
diff changeset
466 sysicon_conn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
003e0a02d6b9 [gaim-migrate @ 4316]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4087
diff changeset
467 sysicon_away = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
468
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
469 /* Create icon in systray */
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
470 systray_init_icon(systray_hwnd, sysicon_disconn);
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
471
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
472 /* Register Gaim event callbacks */
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
473 gaim_signal_connect(NULL, event_signon, st_signon, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
474 gaim_signal_connect(NULL, event_signoff, st_signoff, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
475 gaim_signal_connect(NULL, event_away, st_away, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
476 gaim_signal_connect(NULL, event_back, st_back, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
477 /*gaim_signal_connect(NULL, event_connecting, wgaim_st_connecting, NULL);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
478 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
479 }
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
480
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
481 void wgaim_systray_cleanup(void) {
3972
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
482 docklet_remove();
3946
8ef1360becfe [gaim-migrate @ 4125]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
483 systray_remove_nid();
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
484 DestroyMenu(systray_menu);
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
485 DestroyWindow(systray_hwnd);
3946
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
3972
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
488 void wgaim_systray_minimize( GtkWidget *window ) {
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
489 MinimizeWndToTray(GDK_WINDOW_HWND(window->window));
3959
9c2d8579ff3e [gaim-migrate @ 4141]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3946
diff changeset
490 }
3972
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
491
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
492 void wgaim_systray_maximize( GtkWidget *window ) {
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
493 RestoreWndFromTray(GDK_WINDOW_HWND(window->window));
f9e961773058 [gaim-migrate @ 4156]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3959
diff changeset
494 }