Mercurial > pidgin.yaz
comparison src/browser.c @ 3466:7a3f16a375a5
[gaim-migrate @ 3516]
some patches from some people.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 29 Aug 2002 01:47:15 +0000 |
parents | 8de4f34a1bd7 |
children | d33ec392a5e1 |
comparison
equal
deleted
inserted
replaced
3465:ec437d73b2ee | 3466:7a3f16a375a5 |
---|---|
58 #define MOZILLA_VERSION_PROP "_MOZILLA_VERSION" | 58 #define MOZILLA_VERSION_PROP "_MOZILLA_VERSION" |
59 #define MOZILLA_LOCK_PROP "_MOZILLA_LOCK" | 59 #define MOZILLA_LOCK_PROP "_MOZILLA_LOCK" |
60 #define MOZILLA_COMMAND_PROP "_MOZILLA_COMMAND" | 60 #define MOZILLA_COMMAND_PROP "_MOZILLA_COMMAND" |
61 #define MOZILLA_RESPONSE_PROP "_MOZILLA_RESPONSE" | 61 #define MOZILLA_RESPONSE_PROP "_MOZILLA_RESPONSE" |
62 | 62 |
63 static GdkAtom XA_MOZILLA_VERSION = 0; | 63 static GdkAtom GDKA_MOZILLA_VERSION = 0; |
64 static GdkAtom XA_MOZILLA_LOCK = 0; | 64 static GdkAtom GDKA_MOZILLA_LOCK = 0; |
65 static GdkAtom XA_MOZILLA_COMMAND = 0; | 65 static GdkAtom GDKA_MOZILLA_COMMAND = 0; |
66 static GdkAtom XA_MOZILLA_RESPONSE = 0; | 66 static GdkAtom GDKA_MOZILLA_RESPONSE = 0; |
67 | 67 |
68 | 68 |
69 static int netscape_lock; | 69 static int netscape_lock; |
70 | 70 |
71 | 71 |
186 | 186 |
187 | 187 |
188 | 188 |
189 static void mozilla_remote_init_atoms() | 189 static void mozilla_remote_init_atoms() |
190 { | 190 { |
191 if (!XA_MOZILLA_VERSION) | 191 if (!GDKA_MOZILLA_VERSION) |
192 XA_MOZILLA_VERSION = gdk_atom_intern(MOZILLA_VERSION_PROP, 0); | 192 GDKA_MOZILLA_VERSION = gdk_atom_intern(MOZILLA_VERSION_PROP, 0); |
193 if (!XA_MOZILLA_LOCK) | 193 if (!GDKA_MOZILLA_LOCK) |
194 XA_MOZILLA_LOCK = gdk_atom_intern(MOZILLA_LOCK_PROP, 0); | 194 GDKA_MOZILLA_LOCK = gdk_atom_intern(MOZILLA_LOCK_PROP, 0); |
195 if (!XA_MOZILLA_COMMAND) | 195 if (!GDKA_MOZILLA_COMMAND) |
196 XA_MOZILLA_COMMAND = gdk_atom_intern(MOZILLA_COMMAND_PROP, 0); | 196 GDKA_MOZILLA_COMMAND = gdk_atom_intern(MOZILLA_COMMAND_PROP, 0); |
197 if (!XA_MOZILLA_RESPONSE) | 197 if (!GDKA_MOZILLA_RESPONSE) |
198 XA_MOZILLA_RESPONSE = gdk_atom_intern(MOZILLA_RESPONSE_PROP, 0); | 198 GDKA_MOZILLA_RESPONSE = gdk_atom_intern(MOZILLA_RESPONSE_PROP, 0); |
199 } | 199 } |
200 | 200 |
201 static GdkWindow *mozilla_remote_find_window() | 201 static GdkWindow *mozilla_remote_find_window() |
202 { | 202 { |
203 int i; | 203 int i; |
226 Atom type; | 226 Atom type; |
227 int format; | 227 int format; |
228 unsigned long nitems, bytesafter; | 228 unsigned long nitems, bytesafter; |
229 unsigned char *version = 0; | 229 unsigned char *version = 0; |
230 Window w = GClientWindow(gdk_display, kids[i]); | 230 Window w = GClientWindow(gdk_display, kids[i]); |
231 int status = XGetWindowProperty(gdk_display, w, XA_MOZILLA_VERSION, | 231 int status = XGetWindowProperty(gdk_display, w, |
232 gdk_x11_atom_to_xatom(GDKA_MOZILLA_VERSION), | |
232 0, (65536 / sizeof(long)), | 233 0, (65536 / sizeof(long)), |
233 False, XA_STRING, | 234 False, XA_STRING, |
234 &type, &format, &nitems, &bytesafter, | 235 &type, &format, &nitems, &bytesafter, |
235 &version); | 236 &version); |
236 | 237 |
293 GdkAtom actual_type; | 294 GdkAtom actual_type; |
294 gint actual_format; | 295 gint actual_format; |
295 gint nitems; | 296 gint nitems; |
296 unsigned char *data = 0; | 297 unsigned char *data = 0; |
297 | 298 |
298 result = gdk_property_get(window, XA_MOZILLA_LOCK, | 299 result = gdk_property_get(window, GDKA_MOZILLA_LOCK, |
299 XA_STRING, 0, | 300 gdk_x11_xatom_to_atom (XA_STRING), 0, |
300 (65536 / sizeof(long)), 0, | 301 (65536 / sizeof(long)), 0, |
301 &actual_type, &actual_format, &nitems, &data); | 302 &actual_type, &actual_format, &nitems, &data); |
302 if (result != Success || actual_type == None) { | 303 if (result != Success || actual_type == None) { |
303 /* It's not now locked - lock it. */ | 304 /* It's not now locked - lock it. */ |
304 debug_printf("%s: (writing " MOZILLA_LOCK_PROP | 305 debug_printf("%s: (writing " MOZILLA_LOCK_PROP |
305 " \"%s\" to 0x%x)\n", progname, lock_data, (unsigned int)window); | 306 " \"%s\" to 0x%x)\n", progname, lock_data, (unsigned int)window); |
306 | 307 |
307 gdk_property_change(window, XA_MOZILLA_LOCK, XA_STRING, | 308 gdk_property_change(window, GDKA_MOZILLA_LOCK, |
309 gdk_x11_xatom_to_atom (XA_STRING), | |
308 8, PropModeReplace, | 310 8, PropModeReplace, |
309 (unsigned char *)lock_data, strlen(lock_data)); | 311 (unsigned char *)lock_data, strlen(lock_data)); |
310 locked = True; | 312 locked = True; |
311 } | 313 } |
312 | 314 |
331 unsigned char *data = 0; | 333 unsigned char *data = 0; |
332 | 334 |
333 debug_printf("%s: (deleting " MOZILLA_LOCK_PROP | 335 debug_printf("%s: (deleting " MOZILLA_LOCK_PROP |
334 " \"%s\" from 0x%x)\n", progname, lock_data, (unsigned int)window); | 336 " \"%s\" from 0x%x)\n", progname, lock_data, (unsigned int)window); |
335 | 337 |
336 result = gdk_property_get(window, XA_MOZILLA_LOCK, XA_STRING, | 338 result = gdk_property_get(window, GDKA_MOZILLA_LOCK, |
339 gdk_x11_xatom_to_atom (XA_STRING), | |
337 0, (65536 / sizeof(long)), | 340 0, (65536 / sizeof(long)), |
338 1, &actual_type, &actual_format, &nitems, &data); | 341 1, &actual_type, &actual_format, &nitems, &data); |
339 if (result != Success) { | 342 if (result != Success) { |
340 debug_printf("%s: unable to read and delete " MOZILLA_LOCK_PROP " property\n", progname); | 343 debug_printf("%s: unable to read and delete " MOZILLA_LOCK_PROP " property\n", progname); |
341 return; | 344 return; |
376 } | 379 } |
377 | 380 |
378 debug_printf("%s: (writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x)\n", | 381 debug_printf("%s: (writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x)\n", |
379 progname, command, (unsigned int)window); | 382 progname, command, (unsigned int)window); |
380 | 383 |
381 gdk_property_change(window, XA_MOZILLA_COMMAND, XA_STRING, 8, | 384 gdk_property_change(window, GDKA_MOZILLA_COMMAND, |
382 GDK_PROP_MODE_REPLACE, (unsigned char *)command, strlen(command)); | 385 gdk_x11_xatom_to_atom (XA_STRING), |
386 8, GDK_PROP_MODE_REPLACE, (unsigned char *)command, strlen(command)); | |
383 | 387 |
384 while (!done) { | 388 while (!done) { |
385 GdkEvent *event; | 389 GdkEvent *event; |
386 | 390 |
387 event = gdk_event_get(); | 391 event = gdk_event_get(); |
401 result = 6; | 405 result = 6; |
402 done = True; | 406 done = True; |
403 } else if (event->type == GDK_PROPERTY_NOTIFY && | 407 } else if (event->type == GDK_PROPERTY_NOTIFY && |
404 event->property.state == GDK_PROPERTY_NEW_VALUE && | 408 event->property.state == GDK_PROPERTY_NEW_VALUE && |
405 event->property.window == window && | 409 event->property.window == window && |
406 event->property.atom == XA_MOZILLA_RESPONSE) { | 410 event->property.atom == GDKA_MOZILLA_RESPONSE) { |
407 GdkAtom actual_type; | 411 GdkAtom actual_type; |
408 gint actual_format, nitems; | 412 gint actual_format, nitems; |
409 unsigned char *data = 0; | 413 unsigned char *data = 0; |
410 | 414 |
411 result = gdk_property_get(window, XA_MOZILLA_RESPONSE, | 415 result = gdk_property_get(window, GDKA_MOZILLA_RESPONSE, |
412 XA_STRING, 0, | 416 gdk_x11_xatom_to_atom (XA_STRING), 0, |
413 (65536 / sizeof(long)), | 417 (65536 / sizeof(long)), |
414 1, &actual_type, &actual_format, &nitems, &data); | 418 1, &actual_type, &actual_format, &nitems, &data); |
415 | 419 |
416 | 420 |
417 if (result == Success && data && *data) { | 421 if (result == Success && data && *data) { |
462 if (data) | 466 if (data) |
463 g_free(data); | 467 g_free(data); |
464 } else if (event->type == GDK_PROPERTY_NOTIFY && | 468 } else if (event->type == GDK_PROPERTY_NOTIFY && |
465 event->property.window == window && | 469 event->property.window == window && |
466 event->property.state == GDK_PROPERTY_DELETE && | 470 event->property.state == GDK_PROPERTY_DELETE && |
467 event->property.atom == XA_MOZILLA_COMMAND) { | 471 event->property.atom == GDKA_MOZILLA_COMMAND) { |
468 debug_printf("%s: (server 0x%x has accepted " | 472 debug_printf("%s: (server 0x%x has accepted " |
469 MOZILLA_COMMAND_PROP ".)\n", progname, (unsigned int)window); | 473 MOZILLA_COMMAND_PROP ".)\n", progname, (unsigned int)window); |
470 } | 474 } |
471 gdk_event_free(event); | 475 gdk_event_free(event); |
472 } | 476 } |
583 | 587 |
584 if (pid == 0) { | 588 if (pid == 0) { |
585 /* args will be allocated below but we don't bother | 589 /* args will be allocated below but we don't bother |
586 * freeing it since we're just going to exec and | 590 * freeing it since we're just going to exec and |
587 * exit */ | 591 * exit */ |
588 char **args; | 592 char **args=NULL; |
589 char command[1024]; | 593 char command[1024]; |
590 | 594 |
591 if (web_browser == BROWSER_OPERA) { | 595 if (web_browser == BROWSER_OPERA) { |
592 args = g_new(char *, 4); | 596 args = g_new(char *, 4); |
593 args[0] = "opera"; | 597 args[0] = "opera"; |