Thu, 17 Jul 2003 10:35:43 +0000
[gaim-migrate @ 6664]
Core/UI split the core initialization and shutdown. I think I got all the
bugs worked out. It's looking nice and stable here, but if it causes CVS to
go to hell for everyone.. er, try to fix it or let me know :) I don't have
this in patch form.
| 1 | 1 | /* |
| 2 | * gaim | |
| 3 | * | |
| 4 | * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
| 5 | * | |
| 6 | * some code: (most in this file) | |
| 7 | * Copyright (C) 1996 Netscape Communications Corporation, all rights reserved. | |
| 8 | * Created: Jamie Zawinski <jwz@netscape.com>, 24-Dec-94. | |
| 9 | * | |
| 10 | * This program is free software; you can redistribute it and/or modify | |
| 11 | * it under the terms of the GNU General Public License as published by | |
| 12 | * the Free Software Foundation; either version 2 of the License, or | |
| 13 | * (at your option) any later version. | |
| 14 | * | |
| 15 | * This program is distributed in the hope that it will be useful, | |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | * GNU General Public License for more details. | |
| 19 | * | |
| 20 | * You should have received a copy of the GNU General Public License | |
| 21 | * along with this program; if not, write to the Free Software | |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 23 | * | |
| 24 | * This code is mainly taken from Netscape's sample implementation of | |
| 25 | * their protocol. Nifty. | |
| 26 | * | |
| 27 | */ | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
28 | #include "internal.h" |
| 1 | 29 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
30 | #include <gdk/gdkprivate.h> |
| 1 | 31 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
32 | #include "debug.h" |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
33 | #include "notify.h" |
|
5545
a8b1a1262402
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5515
diff
changeset
|
34 | #include "prefs.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
35 | #include "util.h" |
| 1 | 36 | |
| 37 | #ifndef _WIN32 | |
| 38 | #include <X11/Xlib.h> | |
| 39 | #include <X11/Xatom.h> | |
| 40 | ||
| 41 | static const char *progname = "gaim"; | |
| 42 | static const char *expected_mozilla_version = "1.1"; | |
| 43 | ||
| 44 | #define MOZILLA_VERSION_PROP "_MOZILLA_VERSION" | |
| 45 | #define MOZILLA_LOCK_PROP "_MOZILLA_LOCK" | |
| 46 | #define MOZILLA_COMMAND_PROP "_MOZILLA_COMMAND" | |
| 47 | #define MOZILLA_RESPONSE_PROP "_MOZILLA_RESPONSE" | |
| 48 | ||
| 3466 | 49 | static GdkAtom GDKA_MOZILLA_VERSION = 0; |
| 50 | static GdkAtom GDKA_MOZILLA_LOCK = 0; | |
| 51 | static GdkAtom GDKA_MOZILLA_COMMAND = 0; | |
| 52 | static GdkAtom GDKA_MOZILLA_RESPONSE = 0; | |
| 1 | 53 | |
| 4428 | 54 | static char *window_check_mozilla_version(Window); |
| 55 | static const char *get_lock_data(); | |
| 56 | static GdkFilterReturn netscape_response_cb(XEvent *, GdkEvent *, GdkWindow *); | |
| 57 | static gboolean netscape_command(const char *); | |
| 1 | 58 | |
| 59 | static int netscape_lock; | |
| 60 | ||
| 61 | ||
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
62 | static Window VirtualRootWindowOfScreen(screen) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
63 | Screen *screen; |
| 1 | 64 | { |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
65 | static Screen *save_screen = (Screen *) 0; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
66 | static Window root = (Window) 0; |
| 1 | 67 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
68 | if (screen != save_screen) { |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
69 | Display *dpy = DisplayOfScreen(screen); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
70 | Atom __SWM_VROOT = None; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
71 | unsigned int i; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
72 | Window rootReturn, parentReturn, *children; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
73 | unsigned int numChildren; |
| 1 | 74 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
75 | root = RootWindowOfScreen(screen); |
| 1 | 76 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
77 | /* go look for a virtual root */ |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
78 | __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
79 | if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
80 | for (i = 0; i < numChildren; i++) { |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
81 | Atom actual_type; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
82 | int actual_format; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
83 | unsigned long nitems, bytesafter; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
84 | Window *newRoot = (Window *) 0; |
| 1 | 85 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
86 | if (XGetWindowProperty(dpy, children[i], |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
87 | __SWM_VROOT, 0, 1, False, XA_WINDOW, |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
88 | &actual_type, &actual_format, |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
89 | &nitems, &bytesafter, |
|
2372
c24942700dfd
[gaim-migrate @ 2385]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2099
diff
changeset
|
90 | (unsigned char **)&newRoot) == Success |
|
c24942700dfd
[gaim-migrate @ 2385]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2099
diff
changeset
|
91 | && newRoot) { |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
92 | root = *newRoot; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
93 | break; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
94 | } |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
95 | } |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
96 | if (children) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
97 | XFree((char *)children); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
98 | } |
| 1 | 99 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
100 | save_screen = screen; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
101 | } |
| 1 | 102 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
103 | return root; |
| 1 | 104 | } |
| 105 | ||
| 106 | /* The following code is Copyright (C) 1989 X Consortium */ | |
| 107 | ||
| 108 | static Window TryChildren(); | |
| 109 | ||
| 110 | /* Find a window with WM_STATE, else return win itself, as per ICCCM */ | |
| 111 | ||
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
112 | static Window GClientWindow(dpy, win) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
113 | Display *dpy; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
114 | Window win; |
| 1 | 115 | { |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
116 | Atom WM_STATE; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
117 | Atom type = None; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
118 | int format; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
119 | unsigned long nitems, after; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
120 | unsigned char *data; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
121 | Window inf; |
| 1 | 122 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
123 | WM_STATE = XInternAtom(dpy, "WM_STATE", True); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
124 | if (!WM_STATE) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
125 | return win; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
126 | XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType, |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
127 | &type, &format, &nitems, &after, &data); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
128 | if (type) { |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
129 | XFree(data); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
130 | return win; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
131 | } |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
132 | |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
133 | inf = TryChildren(dpy, win, WM_STATE); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
134 | if (!inf) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
135 | inf = win; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
136 | |
| 26 | 137 | XFree(data); |
| 138 | ||
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
139 | return inf; |
| 1 | 140 | } |
| 141 | ||
| 142 | static | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
143 | Window TryChildren(dpy, win, WM_STATE) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
144 | Display *dpy; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
145 | Window win; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
146 | Atom WM_STATE; |
| 1 | 147 | { |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
148 | Window root, parent; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
149 | Window *children; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
150 | unsigned int nchildren; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
151 | unsigned int i; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
152 | Atom type = None; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
153 | int format; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
154 | unsigned long nitems, after; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
155 | unsigned char *data; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
156 | Window inf = 0; |
| 1 | 157 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
158 | if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren)) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
159 | return 0; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
160 | for (i = 0; !inf && (i < nchildren); i++) { |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
161 | XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False, |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
162 | AnyPropertyType, &type, &format, &nitems, &after, &data); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
163 | if (type) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
164 | inf = children[i]; |
| 26 | 165 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
166 | XFree(data); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
167 | } |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
168 | for (i = 0; !inf && (i < nchildren); i++) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
169 | inf = TryChildren(dpy, children[i], WM_STATE); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
170 | if (children) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
171 | XFree((char *)children); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
172 | return inf; |
| 1 | 173 | } |
| 174 | ||
| 175 | /* END X Consortium code */ | |
| 176 | ||
| 177 | ||
| 178 | ||
| 179 | static void mozilla_remote_init_atoms() | |
| 180 | { | |
| 3466 | 181 | if (!GDKA_MOZILLA_VERSION) |
| 182 | GDKA_MOZILLA_VERSION = gdk_atom_intern(MOZILLA_VERSION_PROP, 0); | |
| 183 | if (!GDKA_MOZILLA_LOCK) | |
| 184 | GDKA_MOZILLA_LOCK = gdk_atom_intern(MOZILLA_LOCK_PROP, 0); | |
| 185 | if (!GDKA_MOZILLA_COMMAND) | |
| 186 | GDKA_MOZILLA_COMMAND = gdk_atom_intern(MOZILLA_COMMAND_PROP, 0); | |
| 187 | if (!GDKA_MOZILLA_RESPONSE) | |
| 188 | GDKA_MOZILLA_RESPONSE = gdk_atom_intern(MOZILLA_RESPONSE_PROP, 0); | |
| 1 | 189 | } |
| 190 | ||
| 4428 | 191 | static char *window_check_mozilla_version(Window window) { |
| 192 | ||
| 193 | Atom type; | |
| 194 | int format; | |
| 195 | unsigned long nitems, bytesafter; | |
| 196 | unsigned char *version = 0; | |
| 197 | gchar *retval = NULL; | |
| 198 | ||
| 199 | if (XGetWindowProperty(gdk_display, window, | |
| 200 | gdk_x11_atom_to_xatom(GDKA_MOZILLA_VERSION), | |
| 201 | 0, (65536 / sizeof(long)), | |
| 202 | False, XA_STRING, | |
| 203 | &type, &format, &nitems, &bytesafter, | |
| 204 | &version) != Success) { | |
| 205 | return NULL; | |
| 206 | } | |
| 207 | ||
| 208 | if (!version) { | |
| 209 | return NULL; | |
| 210 | } | |
| 211 | ||
| 212 | retval = g_strdup(version); | |
| 213 | XFree(version); | |
| 214 | ||
| 215 | return retval; | |
| 216 | } | |
| 217 | ||
| 1 | 218 | static GdkWindow *mozilla_remote_find_window() |
| 219 | { | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
220 | int i; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
221 | Window root = VirtualRootWindowOfScreen(DefaultScreenOfDisplay(gdk_display)); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
222 | Window root2, parent, *kids; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
223 | unsigned int nkids; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
224 | Window result = 0; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
225 | Window tenative = 0; |
| 4428 | 226 | unsigned char *tenative_version = 0, *version = 0; |
| 227 | static GdkWindow *remote_window = NULL; | |
| 228 | ||
| 229 | if (remote_window != NULL) { | |
| 230 | version = window_check_mozilla_version(GDK_WINDOW_XID(remote_window)); | |
| 231 | ||
| 232 | if (version != NULL) { | |
| 233 | g_free(version); | |
| 234 | return remote_window; | |
| 235 | } | |
| 236 | g_free(version); | |
| 237 | ||
| 238 | gdk_window_destroy(remote_window); | |
| 239 | remote_window = NULL; | |
| 240 | } | |
| 1 | 241 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
242 | if (!XQueryTree(gdk_display, root, &root2, &parent, &kids, &nkids)) { |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
243 | gaim_debug(GAIM_DEBUG_ERROR, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
244 | "%s: XQueryTree failed on display %s\n", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
245 | progname, DisplayString(gdk_display)); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
246 | return NULL; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
247 | } |
| 1 | 248 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
249 | /* root != root2 is possible with virtual root WMs. */ |
| 1 | 250 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
251 | if (!(kids && nkids)) { |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
252 | gaim_debug(GAIM_DEBUG_ERROR, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
253 | "%s: root window has no children on display %s\n", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
254 | progname, DisplayString(gdk_display)); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
255 | return NULL; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
256 | } |
| 1 | 257 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
258 | for (i = nkids - 1; i >= 0; i--) { |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
259 | Window w = GClientWindow(gdk_display, kids[i]); |
| 4428 | 260 | |
| 261 | version = window_check_mozilla_version(w); | |
| 26 | 262 | |
| 4428 | 263 | if (version == NULL) { |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
264 | continue; |
| 4428 | 265 | } |
| 26 | 266 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
267 | if (strcmp((char *)version, expected_mozilla_version) && !tenative) { |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
268 | tenative = w; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
269 | tenative_version = version; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
270 | continue; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
271 | } |
| 4428 | 272 | |
| 273 | g_free(version); | |
| 274 | ||
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
275 | result = w; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
276 | break; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
277 | } |
| 1 | 278 | |
| 26 | 279 | XFree(kids); |
| 280 | ||
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
281 | if (result && tenative) { |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
282 | gaim_debug(GAIM_DEBUG_WARNING, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
283 | "%s: both version %s (0x%x) and version %s (%0x%x) " |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
284 | "are running. Using version %s.\n", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
285 | progname, tenative_version, (unsigned int)tenative, |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
286 | expected_mozilla_version, (unsigned int)result, |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
287 | expected_mozilla_version); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
288 | XFree(tenative_version); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
289 | return gdk_window_foreign_new(result); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
290 | } else if (tenative) { |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
291 | gaim_debug(GAIM_DEBUG_WARNING, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
292 | "%s: expected version %s but found version %s (0x%x) " |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
293 | "instead.\n", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
294 | progname, expected_mozilla_version, |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
295 | tenative_version, (unsigned int)tenative); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
296 | XFree(tenative_version); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
297 | return gdk_window_foreign_new(tenative); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
298 | } else if (result) { |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
299 | return gdk_window_foreign_new(result); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
300 | } else { |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
301 | gaim_debug(GAIM_DEBUG_ERROR, "%s: not running on display %s\n", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
302 | progname, DisplayString(gdk_display)); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
303 | return NULL; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
304 | } |
| 1 | 305 | } |
| 306 | ||
| 307 | ||
| 4428 | 308 | static const char *get_lock_data() { |
| 309 | static char *lock_data = NULL; | |
| 1 | 310 | |
| 4428 | 311 | if (lock_data == NULL) { |
| 312 | char hostname[HOST_NAME_MAX + 1] = {0}; | |
| 313 | ||
| 314 | if (gethostname(hostname, HOST_NAME_MAX + 1) == 0) { | |
| 315 | lock_data = g_strdup_printf("pid%d@%s", getpid(), hostname); | |
| 316 | } else { | |
| 317 | lock_data = g_strdup_printf("pid%d", getpid()); | |
| 1 | 318 | } |
| 319 | } | |
| 320 | ||
| 4428 | 321 | return lock_data; |
| 322 | } | |
| 323 | ||
|
5435
990c340ecb6d
[gaim-migrate @ 5817]
Mark Doliner <markdoliner@pidgin.im>
parents:
5213
diff
changeset
|
324 | #if 0 |
| 4551 | 325 | static void mozilla_remote_obtain_lock(GdkWindow * window) |
| 4428 | 326 | { |
| 327 | gboolean locked = False; | |
| 328 | const char *lock_data = get_lock_data(); | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
329 | GdkAtom actual_type; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
330 | gint actual_format; |
| 1 | 331 | gint nitems; |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
332 | unsigned char *data = 0; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
333 | |
| 4428 | 334 | gdk_x11_grab_server(); |
| 335 | if (!gdk_property_get(window, GDKA_MOZILLA_LOCK, | |
| 3466 | 336 | gdk_x11_xatom_to_atom (XA_STRING), 0, |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
337 | (65536 / sizeof(long)), 0, |
| 4428 | 338 | &actual_type, &actual_format, &nitems, &data)) { |
| 339 | ||
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
340 | /* It's not now locked - lock it. */ |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
341 | gaim_debug(GAIM_DEBUG_MISC, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
342 | "%s: writing " MOZILLA_LOCK_PROP " \"%s\" to 0x%x\n", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
343 | progname, lock_data, (unsigned int)window); |
| 1 | 344 | |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
345 | gdk_property_change(window, GDKA_MOZILLA_LOCK, |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
346 | gdk_x11_xatom_to_atom (XA_STRING), |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
347 | 8, PropModeReplace, |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
348 | (unsigned char *)lock_data, strlen(lock_data)); |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
349 | locked = True; |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
350 | } |
| 1 | 351 | |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
352 | if (data) |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
353 | g_free(data); |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
354 | |
| 4428 | 355 | gdk_x11_ungrab_server(); |
| 1 | 356 | } |
|
5435
990c340ecb6d
[gaim-migrate @ 5817]
Mark Doliner <markdoliner@pidgin.im>
parents:
5213
diff
changeset
|
357 | #endif |
| 1 | 358 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
359 | static void mozilla_remote_free_lock(GdkWindow * window) |
| 1 | 360 | { |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
361 | int result = 0; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
362 | GdkAtom actual_type; |
| 4428 | 363 | gint actual_format; |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
364 | gint nitems; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
365 | unsigned char *data = 0; |
| 4428 | 366 | const char *lock_data = get_lock_data(); |
| 1 | 367 | |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
368 | gaim_debug(GAIM_DEBUG_MISC, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
369 | "%s: deleting " MOZILLA_LOCK_PROP " \"%s\" from 0x%x\n", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
370 | progname, lock_data, (unsigned int)window); |
| 1 | 371 | |
| 3466 | 372 | result = gdk_property_get(window, GDKA_MOZILLA_LOCK, |
| 373 | gdk_x11_xatom_to_atom (XA_STRING), | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
374 | 0, (65536 / sizeof(long)), |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
375 | 1, &actual_type, &actual_format, &nitems, &data); |
| 4428 | 376 | |
| 377 | if (result != TRUE) { | |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
378 | gaim_debug(GAIM_DEBUG_ERROR, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
379 | "%s: Unable to read and delete " MOZILLA_LOCK_PROP |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
380 | " property\n", progname); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
381 | return; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
382 | } else if (!data || !*data) { |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
383 | gaim_debug(GAIM_DEBUG_ERROR, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
384 | "%s: Invalid data on " MOZILLA_LOCK_PROP |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
385 | " of wnidow 0x%x\n", progname, (unsigned int)window); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
386 | return; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
387 | } else if (strcmp((char *)data, lock_data)) { |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
388 | gaim_debug(GAIM_DEBUG_ERROR, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
389 | "%s: " MOZILLA_LOCK_PROP " was stolen! Expected \"%s\", " |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
390 | "saw \"%s\"!\n", progname, lock_data, data); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
391 | return; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
392 | } |
| 1 | 393 | |
| 4428 | 394 | XFree(data); |
| 1 | 395 | } |
| 396 | ||
| 4428 | 397 | static GdkFilterReturn netscape_response_cb(XEvent *event, GdkEvent *translated, GdkWindow *window) |
| 398 | { | |
| 399 | Atom actual_type, mozilla_response; | |
| 400 | Window xid; | |
| 401 | int actual_format; | |
| 402 | unsigned long nitems, bytes_after; | |
| 403 | unsigned char *data = 0; | |
| 1 | 404 | |
| 4428 | 405 | if (window == NULL || GDK_WINDOW_OBJECT(window)->destroyed) { |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
406 | gaim_notify_error(NULL, NULL, |
|
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
407 | _("Communication with the browser failed. " |
|
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
408 | "Please close all windows and try again."), NULL); |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
409 | gaim_debug(GAIM_DEBUG_WARNING, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
410 | "netscape_response_cb called with NULL window.\n"); |
| 4428 | 411 | return GDK_FILTER_CONTINUE; |
| 412 | } | |
| 413 | ||
| 414 | mozilla_response = gdk_x11_atom_to_xatom(GDKA_MOZILLA_RESPONSE); | |
| 415 | xid = GDK_WINDOW_XID(window); | |
| 416 | ||
| 417 | /* If the event isn't what we want then let gtk handle it */ | |
| 418 | if (event->xany.type != PropertyNotify || | |
| 419 | event->xproperty.state != PropertyNewValue || | |
| 420 | event->xproperty.window != xid || | |
| 421 | event->xproperty.atom != mozilla_response) { | |
| 422 | return GDK_FILTER_CONTINUE; | |
| 423 | } | |
| 424 | ||
| 425 | if (XGetWindowProperty (gdk_display, xid, mozilla_response, | |
| 426 | 0, (65536 / sizeof (long)), | |
| 427 | True, | |
| 428 | XA_STRING, | |
| 429 | &actual_type, &actual_format, | |
| 430 | &nitems, &bytes_after, | |
| 431 | &data) != Success | |
| 432 | || data == NULL || (data[0] != '1' && data[0] != '2')) { | |
| 433 | ||
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
434 | gaim_notify_error(NULL, NULL, |
|
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
435 | _("Communication with the browser failed. " |
|
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
436 | "Please close all windows and try again."), NULL); |
| 4428 | 437 | } |
| 438 | ||
| 439 | if (data[0] == '1') { | |
| 440 | /* Netscape isn't ready yet */ | |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
441 | gaim_debug(GAIM_DEBUG_ERROR, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
442 | "Remote Netscape window isn't ready yet.\n"); |
| 4428 | 443 | return GDK_FILTER_REMOVE; |
| 444 | } | |
| 445 | ||
| 446 | if (data[0] == '2') { | |
| 447 | /* Yay! It worked */ | |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
448 | gaim_debug(GAIM_DEBUG_INFO, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
449 | "Successfully sent command to remote Netscape window.\n"); |
| 4428 | 450 | } |
| 451 | ||
| 452 | gdk_window_remove_filter(window, (GdkFilterFunc) netscape_response_cb, window); | |
| 453 | mozilla_remote_free_lock(window); | |
| 454 | netscape_lock = 0; | |
| 455 | return GDK_FILTER_REMOVE; | |
| 456 | } | |
| 457 | ||
| 458 | static void mozilla_remote_command(GdkWindow * window, const char *command, Bool raise_p) | |
| 1 | 459 | { |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
460 | char *new_command = 0; |
| 1 | 461 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
462 | /* The -noraise option is implemented by passing a "noraise" argument |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
463 | to each command to which it should apply. |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
464 | */ |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
465 | if (!raise_p) { |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
466 | char *close; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
467 | new_command = g_malloc(strlen(command) + 20); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
468 | strcpy(new_command, command); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
469 | close = strrchr(new_command, ')'); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
470 | if (close) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
471 | strcpy(close, ", noraise)"); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
472 | else |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
473 | strcat(new_command, "(noraise)"); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
474 | command = new_command; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
475 | } |
| 1 | 476 | |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
477 | gaim_debug(GAIM_DEBUG_MISC, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
478 | "%s: Writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x\n", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
479 | progname, command, (unsigned int)window); |
| 1 | 480 | |
| 3466 | 481 | gdk_property_change(window, GDKA_MOZILLA_COMMAND, |
| 482 | gdk_x11_xatom_to_atom (XA_STRING), | |
| 483 | 8, GDK_PROP_MODE_REPLACE, (unsigned char *)command, strlen(command)); | |
| 1 | 484 | |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
485 | gdk_window_add_filter(window, (GdkFilterFunc) netscape_response_cb, window); |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
486 | } |
|
4430
95df701e8cdf
[gaim-migrate @ 4705]
Robert McQueen <robot101@debian.org>
parents:
4429
diff
changeset
|
487 | |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
488 | static gboolean netscape_command(const char *command) |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
489 | { |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
490 | GdkWindow *window = NULL; |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
491 | |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
492 | if (netscape_lock) { |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
493 | gaim_debug(GAIM_DEBUG_WARNING, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
494 | "netscape_command() is currently in use.\n"); |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
495 | return FALSE; |
|
4430
95df701e8cdf
[gaim-migrate @ 4705]
Robert McQueen <robot101@debian.org>
parents:
4429
diff
changeset
|
496 | } |
|
95df701e8cdf
[gaim-migrate @ 4705]
Robert McQueen <robot101@debian.org>
parents:
4429
diff
changeset
|
497 | |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
498 | netscape_lock = 1; |
| 1 | 499 | |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
500 | mozilla_remote_init_atoms(); |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
501 | window = mozilla_remote_find_window(); |
| 1 | 502 | |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
503 | if (window == NULL || (GDK_WINDOW_OBJECT(window)->destroyed == TRUE)) { |
|
5213
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
504 | gaim_debug(GAIM_DEBUG_ERROR, "browser", |
|
d56ea526b80c
[gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents:
4885
diff
changeset
|
505 | "Remote window absent or unsuitable.\n"); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
506 | netscape_lock = 0; |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
507 | return FALSE; |
| 1 | 508 | } |
| 509 | ||
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
510 | mozilla_remote_command(window, command, False); |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
511 | |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
512 | netscape_lock = 0; |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
513 | return TRUE; |
| 1 | 514 | } |
| 515 | ||
|
5998
e833f6baf102
[gaim-migrate @ 6446]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
516 | void open_url(GtkWidget *w, const char *url) |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
517 | { |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
518 | char *command = NULL; |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
519 | GError *error = NULL; |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
520 | const char *web_browser; |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
521 | |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
522 | web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser"); |
| 4551 | 523 | |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
524 | if (!strcmp(web_browser, "netscape")) { |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
525 | char *args = NULL; |
| 4551 | 526 | |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
527 | if (gaim_prefs_get_bool("/gaim/gtk/browsers/new_window")) |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
528 | args = g_strdup_printf("OpenURL(%s, new-window)", url); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
529 | else |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
530 | args = g_strdup_printf("OpenURL(%s)", url); |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
531 | |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
532 | if (netscape_command(args)) { |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
533 | g_free(args); |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
534 | return; |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
535 | } |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
536 | |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
537 | /* if netscape is running ... |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
538 | command = g_strdup_printf("netscape -remote %s", args); */ |
| 4551 | 539 | |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
540 | command = g_strdup_printf("netscape \"%s\"", url); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
541 | g_free(args); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
542 | } |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
543 | else if (!strcmp(web_browser, "opera")) { |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
544 | if (gaim_prefs_get_bool("/gaim/gtk/browsers/new_window")) |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
545 | command = g_strdup_printf("opera -newwindow \"%s\"", url); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
546 | else |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
547 | command = g_strdup_printf("opera \"%s\"", url); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
548 | } |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
549 | else if (!strcmp(web_browser, "kfmclient")) { |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
550 | command = g_strdup_printf("kfmclient openURL \"%s\"", url); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
551 | } |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
552 | else if (!strcmp(web_browser, "galeon")) { |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
553 | if (gaim_prefs_get_bool("/gaim/gtk/browsers/new_window")) |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
554 | command = g_strdup_printf("galeon -w \"%s\"", url); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
555 | else |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
556 | command = g_strdup_printf("galeon \"%s\"", url); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
557 | } |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
558 | else if (!strcmp(web_browser, "mozilla")) { |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
559 | command = g_strdup_printf("mozilla \"%s\"", url); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
560 | } |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
561 | else if (!strcmp(web_browser, "custom")) { |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
562 | const char *web_command; |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
563 | |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
564 | |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
565 | web_command = gaim_prefs_get_string("/gaim/gtk/browsers/command"); |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
566 | |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
567 | if (web_command == NULL || *web_command == '\0') { |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
568 | gaim_notify_error(NULL, NULL, |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
569 | _("Unable to launch your browser because " |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
570 | "the 'Manual' browser command has been " |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
571 | "chosen, but no command has been set."), |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
572 | NULL); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
573 | return; |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
574 | } |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
575 | |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
576 | if (strstr(web_command, "%s")) |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
577 | command = gaim_strreplace(web_command, "%s", url); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
578 | else { |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
579 | /* There is no "%s" in the browser command. Assume the user |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
580 | * wanted the URL tacked on to the end of the command. */ |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
581 | command = g_strdup_printf("%s %s", web_command, url); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
582 | } |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
583 | } |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
584 | |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
585 | if (g_spawn_command_line_async(command, &error) == FALSE) { |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
586 | char *tmp = g_strdup_printf(_("There was an error launching your chosen browser: %s"), error->message); |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
587 | gaim_notify_error(NULL, NULL, tmp, NULL); |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
588 | g_free(tmp); |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
589 | g_error_free(error); |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
590 | } |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
591 | |
|
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
592 | g_free(command); |
| 1 | 593 | } |
| 594 | ||
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
595 | void add_bookmark(GtkWidget *w, char *url) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
596 | { |
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
597 | const char *web_browser; |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
598 | |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
599 | web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser"); |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
600 | |
|
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
601 | if (!strcmp(web_browser, "netscape")) { |
|
4431
c0a9b9f3924f
[gaim-migrate @ 4706]
Robert McQueen <robot101@debian.org>
parents:
4430
diff
changeset
|
602 | char *command = g_strdup_printf("AddBookmark(%s)", url); |
| 1 | 603 | |
| 604 | netscape_command(command); | |
| 605 | g_free(command); | |
| 606 | } | |
| 607 | } | |
| 608 | ||
|
5560
7cd6678f838b
[gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents:
5545
diff
changeset
|
609 | #else /* _WIN32 */ |
| 1 | 610 | |
| 611 | /* Sooner or later, I shall support Windows clicking! */ | |
| 612 | ||
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
613 | void add_bookmark(GtkWidget *w, char *url) |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
614 | { |
|
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
615 | } |
| 3630 | 616 | void open_url(GtkWidget *w, char *url) |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
617 | { |
| 3630 | 618 | ShellExecute(NULL, NULL, url, NULL, ".\\", 0); |
|
1250
46ac03911ab0
[gaim-migrate @ 1260]
Decklin Foster <decklin@red-bean.com>
parents:
1181
diff
changeset
|
619 | } |
| 1 | 620 | |
|
2372
c24942700dfd
[gaim-migrate @ 2385]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2099
diff
changeset
|
621 | #endif /* _WIN32 */ |