comparison src/win32/systray.c @ 5365:fa63b4c784b9

[gaim-migrate @ 5741] Localization fixed for systray menu items committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Tue, 13 May 2003 15:51:44 +0000
parents d635e8fe2fba
children a93c92572106
comparison
equal deleted inserted replaced
5364:379beab3d157 5365:fa63b4c784b9
55 static HICON sysicon_away=0; 55 static HICON sysicon_away=0;
56 static NOTIFYICONDATA wgaim_nid; 56 static NOTIFYICONDATA wgaim_nid;
57 static SYSTRAY_STATE st_state=SYSTRAY_STATE_OFFLINE; 57 static SYSTRAY_STATE st_state=SYSTRAY_STATE_OFFLINE;
58 static HMENU systray_menu=0; 58 static HMENU systray_menu=0;
59 static HMENU systray_away_menu=0; 59 static HMENU systray_away_menu=0;
60 /* UTF-8 to locale conversion */
61 gchar *locenc=NULL;
62 static gsize bread=0;
63 static gsize bwrite=0;
60 64
61 /* 65 /*
62 * GLOBALS 66 * GLOBALS
63 */ 67 */
64 extern GtkWidget *imaway; 68 extern GtkWidget *imaway;
94 systray_away_menu = 0; 98 systray_away_menu = 0;
95 } 99 }
96 systray_away_menu = CreatePopupMenu(); 100 systray_away_menu = CreatePopupMenu();
97 while (awy && (item_count <= SYSTRAY_CMND_SET_AWY+MAX_AWY_MESSAGES)) { 101 while (awy && (item_count <= SYSTRAY_CMND_SET_AWY+MAX_AWY_MESSAGES)) {
98 a = (struct away_message *)awy->data; 102 a = (struct away_message *)awy->data;
99 AppendMenu(systray_away_menu, MF_STRING, item_count, a->name); 103 locenc = g_locale_from_utf8(a->name, -1, &bread, &bwrite, NULL);
104 AppendMenu(systray_away_menu, MF_STRING, item_count, locenc);
105 g_free(locenc);
100 awy = g_slist_next(awy); 106 awy = g_slist_next(awy);
101 item_count+=1; 107 item_count+=1;
102 } 108 }
103 AppendMenu(systray_away_menu, MF_SEPARATOR, 0, 0); 109 AppendMenu(systray_away_menu, MF_SEPARATOR, 0, 0);
104 AppendMenu(systray_away_menu, MF_STRING, SYSTRAY_CMND_SET_AWY_NEW, _("New")); 110 locenc = g_locale_from_utf8(_("New"), -1, &bread, &bwrite, NULL);
111 AppendMenu(systray_away_menu, MF_STRING, SYSTRAY_CMND_SET_AWY_NEW, locenc);
112 g_free(locenc);
105 return systray_away_menu; 113 return systray_away_menu;
106 } 114 }
107 115
108 static void systray_show_menu(int x, int y, BOOL connected) { 116 static void systray_show_menu(int x, int y, BOOL connected) {
109 /* need to call this so that the menu disappears if clicking outside 117 /* need to call this so that the menu disappears if clicking outside
113 /* Different menus depending on signed on/off state */ 121 /* Different menus depending on signed on/off state */
114 if(connected) { 122 if(connected) {
115 /* If signoff item dosn't exist.. create it */ 123 /* If signoff item dosn't exist.. create it */
116 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_SIGNOFF)) { 124 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_SIGNOFF)) {
117 DeleteMenu(systray_menu, SYSTRAY_CMND_SIGNON, MF_BYCOMMAND); 125 DeleteMenu(systray_menu, SYSTRAY_CMND_SIGNON, MF_BYCOMMAND);
126 locenc = g_locale_from_utf8(_("Signoff"), -1, &bread, &bwrite, NULL);
118 InsertMenu(systray_menu, SYSTRAY_CMND_MENU_EXIT, 127 InsertMenu(systray_menu, SYSTRAY_CMND_MENU_EXIT,
119 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_SIGNOFF, _("Signoff")); 128 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_SIGNOFF, locenc);
129 g_free(locenc);
120 } 130 }
121 /* if away menu exists, remove and rebuild it */ 131 /* if away menu exists, remove and rebuild it */
122 if(systray_away_menu) { 132 if(systray_away_menu) {
123 if(!DeleteMenu(systray_menu, (UINT)systray_away_menu, MF_BYCOMMAND)) 133 if(!DeleteMenu(systray_menu, (UINT)systray_away_menu, MF_BYCOMMAND))
124 debug_printf("Error using DeleteMenu\n"); 134 debug_printf("Error using DeleteMenu\n");
125 } 135 }
136 locenc = g_locale_from_utf8(_("Set Away Message"), -1, &bread, &bwrite, NULL);
126 InsertMenu(systray_menu, SYSTRAY_CMND_PREFS, 137 InsertMenu(systray_menu, SYSTRAY_CMND_PREFS,
127 MF_BYCOMMAND | MF_POPUP | MF_STRING, (UINT)systray_create_awy_menu(), 138 MF_BYCOMMAND | MF_POPUP | MF_STRING, (UINT)systray_create_awy_menu(),
128 _("Set Away Message")); 139 locenc);
140 g_free(locenc);
129 EnableMenuItem(systray_menu, SYSTRAY_CMND_AUTOLOGIN, MF_GRAYED); 141 EnableMenuItem(systray_menu, SYSTRAY_CMND_AUTOLOGIN, MF_GRAYED);
130 /* If away, put "I'm Back" option in menu */ 142 /* If away, put "I'm Back" option in menu */
131 if(st_state == SYSTRAY_STATE_AWAY) { 143 if(st_state == SYSTRAY_STATE_AWAY) {
132 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_BACK)) { 144 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_BACK)) {
145 locenc = g_locale_from_utf8(_("I'm Back"), -1, &bread, &bwrite, NULL);
133 InsertMenu(systray_menu, (UINT)systray_away_menu, 146 InsertMenu(systray_menu, (UINT)systray_away_menu,
134 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_BACK, 147 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_BACK,
135 _("I'm Back")); 148 locenc);
149 g_free(locenc);
136 } 150 }
137 } else { 151 } else {
138 /* Delete I'm Back item if it exists */ 152 /* Delete I'm Back item if it exists */
139 DeleteMenu(systray_menu, SYSTRAY_CMND_BACK, MF_BYCOMMAND); 153 DeleteMenu(systray_menu, SYSTRAY_CMND_BACK, MF_BYCOMMAND);
140 } 154 }
141 } else { 155 } else {
142 /* If signon item dosn't exist.. create it */ 156 /* If signon item dosn't exist.. create it */
143 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_SIGNON)) { 157 if(!IsMenuItem(systray_menu, SYSTRAY_CMND_SIGNON)) {
144 DeleteMenu(systray_menu, SYSTRAY_CMND_SIGNOFF, MF_BYCOMMAND); 158 DeleteMenu(systray_menu, SYSTRAY_CMND_SIGNOFF, MF_BYCOMMAND);
159 locenc = g_locale_from_utf8(_("Sign On"), -1, &bread, &bwrite, NULL);
145 InsertMenu(systray_menu, SYSTRAY_CMND_MENU_EXIT, 160 InsertMenu(systray_menu, SYSTRAY_CMND_MENU_EXIT,
146 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_SIGNON, _("Sign On")); 161 MF_BYCOMMAND | MF_STRING, SYSTRAY_CMND_SIGNON, locenc);
162 g_free(locenc);
147 } 163 }
148 EnableMenuItem(systray_menu, SYSTRAY_CMND_AUTOLOGIN, MF_ENABLED); 164 EnableMenuItem(systray_menu, SYSTRAY_CMND_AUTOLOGIN, MF_ENABLED);
149 EnableMenuItem(systray_menu, (UINT)systray_away_menu, MF_GRAYED); 165 EnableMenuItem(systray_menu, (UINT)systray_away_menu, MF_GRAYED);
150 /* Delete I'm Back item if it exists */ 166 /* Delete I'm Back item if it exists */
151 DeleteMenu(systray_menu, SYSTRAY_CMND_BACK, MF_BYCOMMAND); 167 DeleteMenu(systray_menu, SYSTRAY_CMND_BACK, MF_BYCOMMAND);
289 } 305 }
290 306
291 static void systray_create_menu(void) { 307 static void systray_create_menu(void) {
292 /* create popup menu */ 308 /* create popup menu */
293 if((systray_menu = CreatePopupMenu())) { 309 if((systray_menu = CreatePopupMenu())) {
294 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_PREFS, _("Preferences"))) 310 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_PREFS,
311 (locenc=g_locale_from_utf8(_("Preferences"), -1, &bread, &bwrite, NULL))))
295 debug_printf("AppendMenu error: %ld\n", GetLastError()); 312 debug_printf("AppendMenu error: %ld\n", GetLastError());
296 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_AUTOLOGIN, _("Auto-login"))) 313 g_free(locenc);
314 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_AUTOLOGIN,
315 (locenc=g_locale_from_utf8(_("Auto-login"), -1, &bread, &bwrite, NULL))))
297 debug_printf("AppendMenu error: %ld\n", GetLastError()); 316 debug_printf("AppendMenu error: %ld\n", GetLastError());
317 g_free(locenc);
298 if(!AppendMenu(systray_menu, MF_SEPARATOR, 0, 0)) 318 if(!AppendMenu(systray_menu, MF_SEPARATOR, 0, 0))
299 debug_printf("AppendMenu error: %ld\n", GetLastError()); 319 debug_printf("AppendMenu error: %ld\n", GetLastError());
300 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_MENU_EXIT, _("Exit"))) 320 g_free(locenc);
321 if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_MENU_EXIT,
322 (locenc=g_locale_from_utf8(_("Exit"), -1, &bread, &bwrite, NULL))))
301 debug_printf("AppendMenu error: %ld\n", GetLastError()); 323 debug_printf("AppendMenu error: %ld\n", GetLastError());
324 g_free(locenc);
302 } else 325 } else
303 debug_printf("CreatePopupMenu error: %ld\n", GetLastError()); 326 debug_printf("CreatePopupMenu error: %ld\n", GetLastError());
304 } 327 }
305 328
306 static void systray_init_icon(HWND hWnd, HICON icon) { 329 static void systray_init_icon(HWND hWnd, HICON icon) {
309 wgaim_nid.hWnd=hWnd; 332 wgaim_nid.hWnd=hWnd;
310 wgaim_nid.uID=0; 333 wgaim_nid.uID=0;
311 wgaim_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP; 334 wgaim_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
312 wgaim_nid.uCallbackMessage=WM_TRAYMESSAGE; 335 wgaim_nid.uCallbackMessage=WM_TRAYMESSAGE;
313 wgaim_nid.hIcon=icon; 336 wgaim_nid.hIcon=icon;
314 strcpy(wgaim_nid.szTip,GAIM_SYSTRAY_DISCONN_HINT); 337 locenc=g_locale_from_utf8(GAIM_SYSTRAY_DISCONN_HINT, -1, &bread, &bwrite, NULL);
315 338 strcpy(wgaim_nid.szTip, locenc);
339 g_free(locenc);
316 Shell_NotifyIcon(NIM_ADD,&wgaim_nid); 340 Shell_NotifyIcon(NIM_ADD,&wgaim_nid);
317 } 341 }
318 342
319 static void systray_change_icon(HICON icon, char* text) { 343 static void systray_change_icon(HICON icon, char* text) {
320 wgaim_nid.hIcon = icon; 344 wgaim_nid.hIcon = icon;
321 lstrcpy(wgaim_nid.szTip, text); 345 locenc = g_locale_from_utf8(text, -1, &bread, &bwrite, NULL);
346 lstrcpy(wgaim_nid.szTip, locenc);
347 g_free(locenc);
322 Shell_NotifyIcon(NIM_MODIFY,&wgaim_nid); 348 Shell_NotifyIcon(NIM_MODIFY,&wgaim_nid);
323 } 349 }
324 350
325 static void systray_remove_nid(void) { 351 static void systray_remove_nid(void) {
326 Shell_NotifyIcon(NIM_DELETE,&wgaim_nid); 352 Shell_NotifyIcon(NIM_DELETE,&wgaim_nid);