Mercurial > pidgin.yaz
annotate src/dialogs.c @ 349:b402a23f35df
[gaim-migrate @ 359]
Let's see if *this* doesn't break everything
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 07 Jun 2000 17:14:32 +0000 |
parents | 9d258a0aa560 |
children | fd3cc0a28d5d |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
23 #include "../config.h" |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
24 #endif |
1 | 25 #include <string.h> |
26 #include <stdio.h> | |
27 #include <stdlib.h> | |
28 #include <time.h> | |
29 #include <sys/types.h> | |
30 #include <sys/stat.h> | |
31 #include <fcntl.h> | |
32 #include <sys/socket.h> | |
33 #include <netdb.h> | |
34 #include <netinet/in.h> | |
35 #include <unistd.h> | |
36 #include <netinet/in.h> | |
37 #include <arpa/inet.h> | |
38 | |
39 #include <gtk/gtk.h> | |
40 #include "gaim.h" | |
41 #include "gtkhtml.h" | |
42 | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
43 #define DEFAULT_FONT_NAME "-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1" |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
44 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
45 char *fontface; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
46 char *fontname; |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
47 |
1 | 48 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ |
49 static GList *dialogwindows = NULL; | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
50 static GtkWidget *linkdialog, *exportdialog, *importdialog, *logdialog; |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
51 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
52 static void accept_callback(GtkWidget *widget, struct file_transfer *t); |
1 | 53 |
54 struct create_away { | |
55 GtkWidget *window; | |
56 GtkWidget *entry; | |
57 GtkWidget *text; | |
58 GtkWidget *checkbx; | |
59 }; | |
60 | |
61 | |
62 struct warning { | |
63 GtkWidget *window; | |
64 GtkWidget *anon; | |
65 char *who; | |
66 }; | |
67 | |
68 struct addbuddy { | |
69 GtkWidget *window; | |
70 GtkWidget *combo; | |
71 GtkWidget *entry; | |
72 }; | |
73 | |
74 struct addperm { | |
75 GtkWidget *window; | |
76 GSList *buttons; | |
77 GtkWidget *entry; | |
78 }; | |
79 | |
80 struct addbp { | |
81 GtkWidget *window; | |
82 GtkWidget *nameentry; | |
83 GtkWidget *messentry; | |
84 GtkWidget *sendim; | |
85 GtkWidget *openwindow; | |
86 }; | |
87 | |
88 struct findbyemail { | |
89 GtkWidget *window; | |
90 GtkWidget *emailentry; | |
91 }; | |
92 | |
93 struct findbyinfo { | |
94 GtkWidget *window; | |
95 GtkWidget *firstentry; | |
96 GtkWidget *middleentry; | |
97 GtkWidget *lastentry; | |
98 GtkWidget *maidenentry; | |
99 GtkWidget *cityentry; | |
100 GtkWidget *stateentry; | |
101 GtkWidget *countryentry; | |
102 }; | |
103 | |
104 struct registerdlg { | |
105 GtkWidget *window; | |
106 GtkWidget *name; | |
107 GtkWidget *email; | |
108 GtkWidget *uname; | |
109 GtkWidget *sname; | |
110 GtkWidget *country; | |
111 }; | |
112 | |
113 struct info_dlg { | |
114 GtkWidget *window; | |
115 GtkWidget *text; | |
116 GtkWidget *close; | |
117 }; | |
118 | |
119 | |
120 struct set_info_dlg { | |
121 GtkWidget *window; | |
122 GtkWidget *text; | |
123 GtkWidget *save; | |
124 GtkWidget *cancel; | |
125 }; | |
126 | |
127 struct set_dir_dlg { | |
128 GtkWidget *window; | |
129 GtkWidget *first; | |
130 GtkWidget *middle; | |
131 GtkWidget *last; | |
132 GtkWidget *maiden; | |
133 GtkWidget *city; | |
134 GtkWidget *state; | |
135 GtkWidget *country; | |
136 GtkWidget *web; | |
137 GtkWidget *cancel; | |
138 GtkWidget *save; | |
139 }; | |
140 | |
141 struct linkdlg { | |
142 GtkWidget *ok; | |
143 GtkWidget *cancel; | |
144 GtkWidget *window; | |
145 GtkWidget *url; | |
146 GtkWidget *text; | |
147 GtkWidget *toggle; | |
148 GtkWidget *entry; | |
149 }; | |
150 | |
146 | 151 struct passwddlg { |
152 GtkWidget *window; | |
153 GtkWidget *ok; | |
154 GtkWidget *cancel; | |
155 GtkWidget *original; | |
156 GtkWidget *new1; | |
157 GtkWidget *new2; | |
158 }; | |
1 | 159 |
160 /*------------------------------------------------------------------------*/ | |
161 /* Function to Send an Email */ | |
162 /*------------------------------------------------------------------------*/ | |
163 | |
164 static int g_sendemail(char *name, char *email, int uname, int sname, char *country) | |
165 { | |
166 static char email_data[2000]; | |
167 int sock; | |
253
5b28ef2b550e
[gaim-migrate @ 263]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
168 struct in_addr *host; |
1 | 169 /* char data[3]; */ |
170 FILE *sockfile; | |
171 char uname_output; | |
172 FILE *tmpfile; | |
173 char filename[128]; | |
174 char buf[256]; | |
175 int i=0, tmpfd=-1; | |
176 | |
177 while (i<10000 && tmpfd < 0) { | |
178 g_snprintf(filename, 128, "/tmp/gaim_%s%d.tmp", current_user->username, i++); | |
179 | |
180 tmpfd = open(filename, O_RDWR|O_CREAT|O_EXCL, 0600); | |
181 } | |
182 | |
183 if(tmpfd < 0) { | |
184 return -1; | |
185 } | |
186 | |
187 | |
188 if (uname) | |
189 { | |
190 g_snprintf(buf, sizeof(buf), "uname -a > %s", filename); | |
191 system(buf); | |
192 } | |
193 | |
253
5b28ef2b550e
[gaim-migrate @ 263]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
194 host = (struct in_addr *)get_address(REG_SRVR); |
1 | 195 if (!host) |
196 { | |
197 printf("Error Resolving Mail Server.\n"); | |
198 return -1; | |
199 } | |
200 | |
253
5b28ef2b550e
[gaim-migrate @ 263]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
201 if ((sock = connect_address(host->s_addr, REG_PORT)) < 0) |
1 | 202 { |
203 printf("Error Connecting to Socket.\n"); | |
204 return -1; | |
205 } | |
206 | |
207 sockfile = fdopen(sock, "r+"); | |
208 | |
209 g_snprintf(email_data, sizeof(email_data), "mail from: %s\n", REG_EMAIL_ADDR); | |
210 fputs(email_data, sockfile); | |
211 | |
212 g_snprintf(email_data, sizeof(email_data), "rcpt to: %s\n", REG_EMAIL_ADDR); | |
213 fputs(email_data, sockfile); | |
214 | |
215 g_snprintf(email_data, sizeof(email_data), "data\n"); | |
216 fputs(email_data, sockfile); | |
217 g_snprintf(email_data, sizeof(email_data), "Subject: Registration Information\n\nBelow is the submitted Registration Information\n----------------------------------\nName: %s\nEmail: %s\nCountry: %s\nSName: %s\nGAIM: v%s\nUname: ", name, email, country, sname ? current_user->username : "N/A", VERSION); | |
218 fputs(email_data, sockfile); | |
219 | |
220 if (uname) | |
221 { | |
222 tmpfile = fopen(filename, "r"); | |
223 while (!feof(tmpfile)) | |
224 { | |
225 uname_output = fgetc(tmpfile); | |
226 if (!feof(tmpfile)) | |
227 fputc(uname_output, sockfile); | |
228 } | |
229 fclose(tmpfile); | |
230 } | |
231 | |
232 unlink(filename); | |
233 | |
234 g_snprintf(email_data, sizeof(email_data), "\n.\nquit\n\n"); | |
235 fputs(email_data, sockfile); | |
236 | |
237 /* while (fgets(data, 2, sockfile)) { | |
238 } | |
239 */ | |
240 /* I don't think the above is necessary... */ | |
241 | |
242 close(sock); | |
243 | |
244 return 1; | |
245 } | |
246 | |
247 /*------------------------------------------------------------------------*/ | |
248 /* Destroys */ | |
249 /*------------------------------------------------------------------------*/ | |
250 | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
251 static gint delete_event_dialog(GtkWidget *w, GdkEventAny *e, struct conversation *c) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
252 { |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
253 dialogwindows = g_list_remove(dialogwindows, w); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
254 gtk_widget_destroy(w); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
255 |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
256 if (GTK_IS_COLOR_SELECTION_DIALOG(w)) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
257 c->color_dialog = NULL; |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
258 if (GTK_IS_FONT_SELECTION_DIALOG(w)) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
259 c->font_dialog = NULL; |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
260 |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
261 return FALSE; |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
262 } |
1 | 263 |
264 static void destroy_dialog(GtkWidget *w, GtkWidget *w2) | |
265 { | |
266 GtkWidget *dest; | |
267 | |
268 if (!GTK_IS_WIDGET(w2)) | |
269 dest = w; | |
270 else | |
271 dest = w2; | |
272 | |
273 if (dest == imdialog) | |
274 imdialog = NULL; | |
275 | |
276 if (dest == exportdialog) | |
277 exportdialog = NULL; | |
278 | |
279 if (dest == importdialog) | |
280 importdialog = NULL; | |
281 | |
282 if (dest == logdialog) | |
283 logdialog = NULL; | |
284 | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
285 /* if (GTK_COLOR_SELECTION_DIALOG(dest)) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
286 color_dialog = NULL;*/ |
1 | 287 |
288 if (dest == linkdialog) | |
289 linkdialog = NULL; | |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
290 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
291 /* if (dest == fontdialog) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
292 fontdialog = NULL;*/ |
1 | 293 |
294 dialogwindows = g_list_remove(dialogwindows, dest); | |
295 gtk_widget_destroy(dest); | |
296 | |
297 } | |
298 | |
299 | |
300 void destroy_all_dialogs() | |
301 { | |
302 GList *d = dialogwindows; | |
303 | |
304 while(d) { | |
305 destroy_dialog(NULL, d->data); | |
306 d = d->next; | |
307 } | |
308 | |
309 g_list_free(dialogwindows); | |
310 dialogwindows = NULL; | |
311 | |
84 | 312 do_im_back(NULL, NULL); |
313 | |
1 | 314 if (imdialog) { |
315 destroy_dialog(NULL, imdialog); | |
316 imdialog = NULL; | |
317 } | |
318 | |
319 if (linkdialog) { | |
320 destroy_dialog(NULL, linkdialog); | |
321 linkdialog = NULL; | |
322 } | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
323 /* is this needed? */ |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
324 /* if (colordialog) { |
1 | 325 destroy_dialog(NULL, colordialog); |
326 colordialog = NULL; | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
327 }*/ |
1 | 328 |
329 if (exportdialog) { | |
330 destroy_dialog(NULL, exportdialog); | |
331 exportdialog = NULL; | |
332 } | |
333 | |
334 if (importdialog) { | |
335 destroy_dialog(NULL, exportdialog); | |
336 importdialog = NULL; | |
337 } | |
338 | |
339 if (logdialog) { | |
340 destroy_dialog(NULL, logdialog); | |
341 logdialog = NULL; | |
342 } | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
343 /* is this needed? */ |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
344 /* if (fontdialog) { |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
345 destroy_dialog(NULL, fontdialog); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
346 fontdialog = NULL; |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
347 }*/ |
1 | 348 } |
349 | |
350 static void do_warn(GtkWidget *widget, struct warning *w) | |
351 { | |
352 serv_warn(w->who, (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))) ? | |
353 1 : 0); | |
354 | |
355 destroy_dialog(NULL, w->window); | |
356 } | |
357 | |
358 | |
359 void show_warn_dialog(char *who) | |
360 { | |
361 GtkWidget *cancel; | |
362 GtkWidget *warn; | |
363 GtkWidget *label; | |
364 GtkWidget *vbox; | |
365 GtkWidget *bbox; | |
366 struct warning *w = g_new0(struct warning, 1); | |
367 | |
368 char *buf = g_malloc(128); | |
369 w->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
370 dialogwindows = g_list_prepend(dialogwindows, w->window); | |
371 cancel = gtk_button_new_with_label("Cancel"); | |
372 warn = gtk_button_new_with_label("Warn"); | |
373 bbox = gtk_hbox_new(TRUE, 10); | |
374 vbox = gtk_vbox_new(FALSE, 5); | |
375 | |
376 /* Put the buttons in the box */ | |
377 gtk_box_pack_start(GTK_BOX(bbox), warn, TRUE, TRUE, 10); | |
378 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
379 | |
380 g_snprintf(buf, 127, "Do you really want to warn %s?", who); | |
381 label = gtk_label_new(buf); | |
382 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | |
383 gtk_widget_show(label); | |
384 w->anon = gtk_check_button_new_with_label("Warn anonymously?"); | |
385 gtk_box_pack_start(GTK_BOX(vbox), w->anon, TRUE, TRUE, 0); | |
386 | |
387 label = gtk_label_new("Anonymous warnings are less harsh."); | |
388 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | |
389 gtk_widget_show(label); | |
390 | |
391 w->who = who; | |
392 | |
393 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
394 | |
395 /* Handle closes right */ | |
396 gtk_signal_connect(GTK_OBJECT(w->window), "delete_event", | |
397 GTK_SIGNAL_FUNC(destroy_dialog), w->window); | |
398 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
399 GTK_SIGNAL_FUNC(destroy_dialog), w->window); | |
400 gtk_signal_connect(GTK_OBJECT(warn), "clicked", | |
401 GTK_SIGNAL_FUNC(do_warn), w); | |
402 /* Finish up */ | |
403 gtk_widget_show(warn); | |
404 gtk_widget_show(cancel); | |
405 gtk_widget_show(w->anon); | |
406 gtk_widget_show(bbox); | |
407 gtk_widget_show(vbox); | |
408 gtk_window_set_title(GTK_WINDOW(w->window), "Gaim - Warn user?"); | |
409 gtk_container_add(GTK_CONTAINER(w->window), vbox); | |
410 gtk_widget_realize(w->window); | |
411 aol_icon(w->window->window); | |
412 | |
413 gtk_widget_show(w->window); | |
25 | 414 g_free(buf); |
1 | 415 } |
416 | |
417 | |
418 /*------------------------------------------------------------------------*/ | |
419 /* The dialog for getting an error */ | |
420 /*------------------------------------------------------------------------*/ | |
421 | |
422 void | |
423 do_error_dialog(char *message, char *title) | |
424 { | |
425 GtkWidget *d; | |
426 GtkWidget *label; | |
427 GtkWidget *close; | |
428 | |
429 | |
430 d = gtk_dialog_new(); | |
431 | |
432 label = gtk_label_new(message); | |
433 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
434 gtk_widget_show(label); | |
435 close = gtk_button_new_with_label("Close"); | |
436 gtk_widget_show(close); | |
437 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), | |
438 label, FALSE, FALSE, 5); | |
439 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | |
440 close, FALSE, FALSE, 5); | |
441 | |
442 | |
443 gtk_window_set_title(GTK_WINDOW(d), title); | |
444 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), d); | |
445 gtk_widget_realize(d); | |
446 aol_icon(d->window); | |
447 | |
448 gtk_widget_show(d); | |
449 } | |
450 | |
451 | |
452 | |
453 void show_error_dialog(char *c) | |
454 { | |
455 | |
456 int no = atoi(c); | |
457 char *w = strtok(NULL, ":"); | |
458 char buf[256]; | |
459 char buf2[32]; | |
460 | |
461 | |
462 switch(no) { | |
463 case 69: | |
464 g_snprintf(buf, sizeof(buf), "Unable to write file %s.", w); | |
465 break; | |
466 case 169: | |
467 g_snprintf(buf, sizeof(buf), "Unable to read file %s.", w); | |
468 break; | |
469 case 269: | |
470 g_snprintf(buf, sizeof(buf), "Message too long, last %s bytes truncated.", w); | |
471 break; | |
472 case 901: | |
473 g_snprintf(buf, sizeof(buf), "%s not currently logged in.", w); | |
474 break; | |
475 case 902: | |
476 g_snprintf(buf, sizeof(buf), "Warning of %s not allowed.", w); | |
477 break; | |
478 case 903: | |
479 g_snprintf(buf, sizeof(buf), "A message has been dropped, you are exceeding the server speed limit."); | |
480 break; | |
481 case 950: | |
482 g_snprintf(buf, sizeof(buf), "Chat in %s is not available.", w); | |
483 break; | |
484 case 960: | |
485 g_snprintf(buf, sizeof(buf), "You are sending messages too fast to %s.", w); | |
486 break; | |
487 case 961: | |
488 g_snprintf(buf, sizeof(buf), "You missed an IM from %s because it was too big.", w); | |
489 break; | |
490 case 962: | |
491 g_snprintf(buf, sizeof(buf), "You missed an IM from %s because it was sent too fast.", w); | |
492 break; | |
493 case 970: | |
494 g_snprintf(buf, sizeof(buf), "Failure."); | |
495 break; | |
496 case 971: | |
497 g_snprintf(buf, sizeof(buf), "Too many matches."); | |
498 break; | |
499 case 972: | |
500 g_snprintf(buf, sizeof(buf), "Need more qualifiers."); | |
501 break; | |
502 case 973: | |
503 g_snprintf(buf, sizeof(buf), "Dir service temporarily unavailable."); | |
504 break; | |
505 case 974: | |
506 g_snprintf(buf, sizeof(buf), "Email lookup restricted."); | |
507 break; | |
508 case 975: | |
509 g_snprintf(buf, sizeof(buf), "Keyword ignored."); | |
510 break; | |
511 case 976: | |
512 g_snprintf(buf, sizeof(buf), "No keywords."); | |
513 break; | |
514 case 977: | |
515 g_snprintf(buf, sizeof(buf), "User has no directory information."); | |
516 /* g_snprintf(buf, sizeof(buf), "Language not supported."); */ | |
517 break; | |
518 case 978: | |
519 g_snprintf(buf, sizeof(buf), "Country not supported."); | |
520 break; | |
521 case 979: | |
522 g_snprintf(buf, sizeof(buf), "Failure unknown: %s.", w); | |
523 break; | |
524 case 980: | |
525 g_snprintf(buf, sizeof(buf), "Incorrect nickname or password."); | |
526 break; | |
527 case 981: | |
528 g_snprintf(buf, sizeof(buf), "The service is temporarily unavailable."); | |
529 break; | |
530 case 982: | |
531 g_snprintf(buf, sizeof(buf), "Your warning level is currently too high to log in."); | |
532 break; | |
533 case 983: | |
534 g_snprintf(buf, sizeof(buf), "You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."); | |
535 break; | |
536 case 989: | |
537 g_snprintf(buf, sizeof(buf), "An unknown signon error has occurred: %s.", w); | |
538 break; | |
539 default: | |
540 g_snprintf(buf, sizeof(buf), "An unknown error, %d, has occured. Info: %s", no, w); | |
541 } | |
542 | |
543 g_snprintf(buf2, sizeof(buf2), "Gaim - Error %d", no); | |
544 | |
545 | |
546 do_error_dialog(buf, buf2); | |
547 return; | |
548 } | |
549 | |
550 static void do_im(GtkWidget *widget, GtkWidget *imentry) | |
551 { | |
552 char *who; | |
553 struct conversation *c; | |
554 | |
555 who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(imentry)))); | |
556 | |
557 destroy_dialog(NULL, imdialog); | |
558 imdialog = NULL; | |
559 | |
560 if (!strcasecmp(who, "")) { | |
561 g_free(who); | |
562 return; | |
563 } | |
564 | |
565 c = find_conversation(who); | |
566 | |
567 if (c == NULL) { | |
568 c = new_conversation(who); | |
569 } else { | |
570 gdk_window_raise(c->window->window); | |
571 } | |
572 g_free(who); | |
573 } | |
574 | |
575 void show_ee_dialog(int ee) | |
576 { | |
577 GtkWidget *ok; | |
578 GtkWidget *label; | |
579 GtkWidget *box; | |
580 GtkWidget *eedialog; | |
581 | |
582 eedialog = gtk_window_new(GTK_WINDOW_DIALOG); | |
583 ok = gtk_button_new_with_label("OK"); | |
584 box = gtk_vbox_new(FALSE, 10); | |
585 | |
586 if (ee == 0) | |
587 label = gtk_label_new("Amazing! Simply Amazing!"); | |
588 else if (ee == 1) | |
589 label = gtk_label_new("Pimpin\' Penguin Style! *Waddle Waddle*"); | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
590 else if (ee == 2) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
591 label = gtk_label_new("You should be me. I'm so cute!"); |
1 | 592 else |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
337
diff
changeset
|
593 label = gtk_label_new("Now that's what I like!"); |
1 | 594 |
595 gtk_widget_show(label); | |
596 gtk_widget_show(ok); | |
597 | |
598 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 10); | |
599 gtk_box_pack_start(GTK_BOX(box), ok, FALSE, FALSE, 10); | |
600 | |
601 gtk_widget_show(box); | |
602 | |
603 gtk_container_add(GTK_CONTAINER(eedialog), box); | |
604 gtk_window_set_title(GTK_WINDOW(eedialog), "Gaim - SUPRISE!"); | |
605 | |
606 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
607 GTK_SIGNAL_FUNC(destroy_dialog), eedialog); | |
608 gtk_widget_realize(eedialog); | |
609 aol_icon(eedialog->window); | |
610 | |
611 gtk_widget_show(eedialog); | |
612 } | |
613 | |
614 void show_im_dialog(GtkWidget *w, GtkWidget *w2) | |
615 { | |
616 GtkWidget *cancel; | |
617 GtkWidget *ok; | |
618 GtkWidget *imentry; | |
619 GtkWidget *vbox; | |
620 GtkWidget *ebox; | |
621 GtkWidget *bbox; | |
622 GtkWidget *label; | |
623 | |
624 if (!imdialog) { | |
625 | |
626 imdialog = gtk_window_new(GTK_WINDOW_DIALOG); | |
627 cancel = gtk_button_new_with_label("Cancel"); | |
628 ok = gtk_button_new_with_label("OK"); | |
629 bbox = gtk_hbox_new(TRUE, 10); | |
630 vbox = gtk_vbox_new(FALSE, 5); | |
631 ebox = gtk_hbox_new(FALSE, 2); | |
632 | |
633 /* Put the buttons in the box */ | |
634 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 10); | |
635 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
636 | |
637 label = gtk_label_new("IM who: "); | |
638 gtk_box_pack_start(GTK_BOX(ebox), label, TRUE, TRUE, 10); | |
639 gtk_widget_show(label); | |
640 | |
641 imentry = gtk_entry_new(); | |
642 gtk_box_pack_start(GTK_BOX(ebox), imentry, TRUE, TRUE, 10); | |
643 | |
644 gtk_box_pack_start(GTK_BOX(vbox), ebox, FALSE, FALSE, 5); | |
645 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
646 | |
647 /* Handle closes right */ | |
648 gtk_signal_connect(GTK_OBJECT(imentry), "activate", | |
649 GTK_SIGNAL_FUNC(do_im), imentry); | |
650 gtk_signal_connect(GTK_OBJECT(imdialog), "destroy", | |
651 GTK_SIGNAL_FUNC(destroy_dialog), imdialog); | |
652 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
653 GTK_SIGNAL_FUNC(destroy_dialog), imdialog); | |
654 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
655 GTK_SIGNAL_FUNC(do_im), imentry); | |
656 /* Finish up */ | |
657 gtk_widget_show(ok); | |
658 gtk_widget_show(cancel); | |
659 gtk_widget_show(ebox); | |
660 gtk_widget_show(imentry); | |
661 gtk_widget_show(bbox); | |
662 gtk_widget_show(vbox); | |
663 gtk_window_set_title(GTK_WINDOW(imdialog), "Gaim - IM user"); | |
664 gtk_container_add(GTK_CONTAINER(imdialog), vbox); | |
665 gtk_widget_grab_focus(imentry); | |
666 gtk_widget_realize(imdialog); | |
667 aol_icon(imdialog->window); | |
668 | |
669 } | |
670 gtk_widget_show(imdialog); | |
671 } | |
672 | |
673 | |
674 /*------------------------------------------------------------------------*/ | |
675 /* The dialog for adding buddies */ | |
676 /*------------------------------------------------------------------------*/ | |
677 | |
678 void do_add_buddy(GtkWidget *w, struct addbuddy *a) | |
679 { | |
680 char *grp, *who; | |
681 struct conversation *c; | |
682 | |
683 who = gtk_entry_get_text(GTK_ENTRY(a->entry)); | |
684 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(a->combo)->entry)); | |
685 | |
686 c = find_conversation(who); | |
687 | |
688 add_buddy(grp, who); | |
689 | |
690 if (c != NULL) | |
691 gtk_label_set_text(GTK_LABEL(GTK_BIN(c->add_button)->child), "Remove"); | |
692 | |
693 build_edit_tree(); | |
694 | |
695 serv_save_config(); | |
696 | |
697 serv_add_buddy(who); | |
698 | |
228 | 699 do_export( (GtkWidget *) NULL, 0 ); |
700 | |
1 | 701 update_num_groups(); |
702 | |
703 destroy_dialog(NULL, a->window); | |
704 } | |
705 | |
706 | |
707 static GList *groups_tree() | |
708 { | |
709 GList *tmp=NULL; | |
710 char *tmp2; | |
711 struct group *g; | |
712 GList *grp = groups; | |
713 | |
714 if (!grp) { | |
715 tmp2 = g_strdup("Buddies"); | |
716 tmp = g_list_append(tmp, tmp2); | |
717 } else { | |
718 while(grp) { | |
719 g = (struct group *)grp->data; | |
720 tmp2 = g->name; | |
721 tmp=g_list_append(tmp, tmp2); | |
722 grp = grp->next; | |
723 } | |
724 } | |
725 return tmp; | |
726 } | |
727 | |
728 | |
729 void show_add_buddy(char *buddy, char *group) | |
730 { | |
731 GtkWidget *cancel; | |
732 GtkWidget *add; | |
733 GtkWidget *label; | |
734 GtkWidget *bbox; | |
735 GtkWidget *vbox; | |
736 GtkWidget *topbox; | |
236 | 737 GtkWidget *frame; |
738 | |
1 | 739 struct addbuddy *a = g_new0(struct addbuddy, 1); |
740 | |
741 a->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
742 dialogwindows = g_list_prepend(dialogwindows, a->window); | |
743 cancel = gtk_button_new_with_label("Cancel"); | |
744 add = gtk_button_new_with_label("Add"); | |
745 bbox = gtk_hbox_new(TRUE, 10); | |
746 topbox = gtk_hbox_new(FALSE, 5); | |
747 vbox = gtk_vbox_new(FALSE, 5); | |
244 | 748 |
1 | 749 a->entry = gtk_entry_new(); |
750 a->combo = gtk_combo_new(); | |
751 /* Fix the combo box */ | |
752 gtk_combo_set_popdown_strings(GTK_COMBO(a->combo), groups_tree()); | |
753 /* Put the buttons in the box */ | |
236 | 754 |
1 | 755 gtk_box_pack_start(GTK_BOX(bbox), add, TRUE, TRUE, 10); |
756 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
757 | |
236 | 758 frame = gtk_frame_new(NULL); |
759 gtk_frame_set_label(GTK_FRAME(frame), "Add Buddy"); | |
760 | |
238 | 761 label = gtk_label_new("Buddy"); |
1 | 762 gtk_widget_show(label); |
763 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
764 gtk_box_pack_start(GTK_BOX(topbox), a->entry, FALSE, FALSE, 5); | |
765 if (buddy != NULL) | |
766 gtk_entry_set_text(GTK_ENTRY(a->entry), buddy); | |
767 | |
238 | 768 label = gtk_label_new("Group"); |
1 | 769 gtk_widget_show(label); |
770 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
771 gtk_box_pack_start(GTK_BOX(topbox), a->combo, FALSE, FALSE, 5); | |
772 | |
773 if (group != NULL) | |
774 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(a->combo)->entry), group); | |
775 | |
776 /* And the boxes in the box */ | |
777 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
778 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
779 | |
780 /* Handle closes right */ | |
781 gtk_signal_connect(GTK_OBJECT(a->window), "destroy", | |
782 GTK_SIGNAL_FUNC(destroy_dialog), a->window); | |
783 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
784 GTK_SIGNAL_FUNC(destroy_dialog), a->window); | |
785 gtk_signal_connect(GTK_OBJECT(add), "clicked", | |
786 GTK_SIGNAL_FUNC(do_add_buddy), a); | |
787 gtk_signal_connect(GTK_OBJECT(a->entry), "activate", | |
788 GTK_SIGNAL_FUNC(do_add_buddy), a); | |
789 /* Finish up */ | |
790 gtk_widget_show(add); | |
791 gtk_widget_show(cancel); | |
792 gtk_widget_show(a->combo); | |
793 gtk_widget_show(a->entry); | |
794 gtk_widget_show(topbox); | |
795 gtk_widget_show(bbox); | |
796 gtk_widget_show(vbox); | |
236 | 797 gtk_widget_show(frame); |
1 | 798 gtk_window_set_title(GTK_WINDOW(a->window), "Gaim - Add Buddy"); |
799 gtk_window_set_focus(GTK_WINDOW(a->window), a->entry); | |
245 | 800 gtk_container_add(GTK_CONTAINER(frame), vbox); |
236 | 801 gtk_container_add(GTK_CONTAINER(a->window), frame); |
802 gtk_container_set_border_width(GTK_CONTAINER(a->window), 5); | |
1 | 803 gtk_widget_realize(a->window); |
804 aol_icon(a->window->window); | |
805 | |
806 gtk_widget_show(a->window); | |
807 } | |
808 | |
809 | |
810 /*------------------------------------------------------------------------*/ | |
811 /* The dialog for new buddy pounces */ | |
812 /*------------------------------------------------------------------------*/ | |
813 | |
814 | |
815 void do_new_bp(GtkWidget *w, struct addbp *b) | |
816 { | |
817 struct buddy_pounce *bp = g_new0(struct buddy_pounce, 1); | |
818 | |
26 | 819 g_snprintf(bp->name, 80, "%s", gtk_entry_get_text(GTK_ENTRY(b->nameentry))); |
820 g_snprintf(bp->message, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->messentry))); | |
821 | |
1 | 822 if (GTK_TOGGLE_BUTTON(b->openwindow)->active) |
823 bp->popup = 1; | |
824 else | |
825 bp->popup = 0; | |
826 | |
827 if (GTK_TOGGLE_BUTTON(b->sendim)->active) | |
828 bp->sendim = 1; | |
829 else | |
830 bp->sendim = 0; | |
26 | 831 |
1 | 832 buddy_pounces = g_list_append(buddy_pounces, bp); |
833 | |
834 do_bp_menu(); | |
835 | |
836 destroy_dialog(NULL, b->window); | |
837 g_free(b); | |
838 } | |
839 | |
840 | |
841 void show_new_bp(char *name) | |
842 { | |
843 GtkWidget *cancel; | |
844 GtkWidget *ok; | |
845 GtkWidget *label; | |
846 GtkWidget *bbox; | |
847 GtkWidget *vbox; | |
848 | |
849 struct addbp *b = g_new0(struct addbp, 1); | |
850 | |
851 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
852 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
853 cancel = gtk_button_new_with_label("Cancel"); | |
854 ok = gtk_button_new_with_label("OK"); | |
855 bbox = gtk_hbox_new(TRUE, 10); | |
856 vbox = gtk_vbox_new(FALSE, 5); | |
857 b->nameentry = gtk_entry_new(); | |
858 b->messentry = gtk_entry_new(); | |
859 | |
860 /* Put the buttons in the box */ | |
861 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 10); | |
862 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
863 | |
864 label = gtk_label_new("Buddy To Pounce:"); | |
865 gtk_widget_show(label); | |
866 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
867 gtk_box_pack_start(GTK_BOX(vbox), b->nameentry, FALSE, FALSE, 0); | |
868 | |
869 b->openwindow = gtk_check_button_new_with_label("Open IM Window on Buddy Logon"); | |
870 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->openwindow), FALSE); | |
871 | |
872 b->sendim = gtk_check_button_new_with_label("Send IM on Buddy Logon"); | |
873 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sendim), TRUE); | |
874 | |
875 gtk_widget_show(b->openwindow); | |
876 gtk_widget_show(b->sendim); | |
877 gtk_box_pack_start(GTK_BOX(vbox), b->openwindow, FALSE, FALSE, 0); | |
878 gtk_box_pack_start(GTK_BOX(vbox), b->sendim, FALSE, FALSE, 0); | |
879 | |
880 label = gtk_label_new("Message to send:"); | |
881 gtk_widget_show(label); | |
882 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
883 gtk_box_pack_start(GTK_BOX(vbox), b->messentry, FALSE, FALSE, 0); | |
884 | |
885 | |
886 /* And the boxes in the box */ | |
887 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
888 | |
889 /* Handle closes right */ | |
890 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
891 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
892 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
893 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
894 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
895 GTK_SIGNAL_FUNC(do_new_bp), b); | |
896 gtk_signal_connect(GTK_OBJECT(b->messentry), "activate", | |
897 GTK_SIGNAL_FUNC(do_new_bp), b); | |
898 | |
899 | |
900 /* Finish up */ | |
901 gtk_widget_show(ok); | |
902 gtk_widget_show(cancel); | |
903 gtk_widget_show(b->nameentry); | |
904 gtk_widget_show(b->messentry); | |
905 gtk_widget_show(bbox); | |
906 gtk_widget_show(vbox); | |
907 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - New Buddy Pounce"); | |
908 if (name != NULL) { | |
909 gtk_entry_set_text(GTK_ENTRY(b->nameentry), name); | |
910 gtk_window_set_focus(GTK_WINDOW(b->window), b->messentry); | |
911 } else | |
912 gtk_window_set_focus(GTK_WINDOW(b->window), b->nameentry); | |
913 gtk_container_add(GTK_CONTAINER(b->window), vbox); | |
914 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
915 gtk_widget_realize(b->window); | |
916 aol_icon(b->window->window); | |
917 | |
918 gtk_widget_show(b->window); | |
919 } | |
920 | |
921 | |
922 | |
923 /*------------------------------------------------------------------------*/ | |
924 /* The dialog for SET INFO / SET DIR INFO */ | |
925 /*------------------------------------------------------------------------*/ | |
926 | |
927 void do_save_info(GtkWidget *widget, struct set_info_dlg *b) | |
928 { | |
929 gchar *junk; | |
930 char *buf; | |
931 | |
932 junk = gtk_editable_get_chars(GTK_EDITABLE(b->text), 0, -1); | |
933 | |
934 g_snprintf(current_user->user_info, sizeof(current_user->user_info), "%s", junk); | |
25 | 935 |
1 | 936 save_prefs(); |
937 | |
79 | 938 buf = g_malloc(strlen(current_user->user_info) * 4); |
122
521db4bf5f28
[gaim-migrate @ 132]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
939 if (!buf) { |
521db4bf5f28
[gaim-migrate @ 132]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
940 buf = g_malloc(1); |
521db4bf5f28
[gaim-migrate @ 132]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
941 buf[0] = 0; |
521db4bf5f28
[gaim-migrate @ 132]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
942 } |
1 | 943 g_snprintf(buf, strlen(current_user->user_info) * 2, "%s", current_user->user_info); |
944 escape_text(buf); | |
945 serv_set_info(buf); | |
946 g_free(buf); | |
25 | 947 g_free(junk); |
1 | 948 destroy_dialog(NULL, b->window); |
949 g_free(b); | |
950 } | |
951 | |
952 void do_set_dir(GtkWidget *widget, struct set_dir_dlg *b) | |
953 { | |
954 char *first = gtk_entry_get_text(GTK_ENTRY(b->first)); | |
955 int web = GTK_TOGGLE_BUTTON(b->web)->active; | |
956 char *middle = gtk_entry_get_text(GTK_ENTRY(b->middle)); | |
957 char *last = gtk_entry_get_text(GTK_ENTRY(b->last)); | |
958 char *maiden = gtk_entry_get_text(GTK_ENTRY(b->maiden)); | |
959 char *city = gtk_entry_get_text(GTK_ENTRY(b->city)); | |
960 char *state = gtk_entry_get_text(GTK_ENTRY(b->state)); | |
961 char *country = gtk_entry_get_text(GTK_ENTRY(b->country)); | |
962 | |
963 | |
964 serv_set_dir(first, middle, last, maiden, city, state, country, web); | |
965 | |
966 destroy_dialog(NULL, b->window); | |
967 g_free(b); | |
968 } | |
969 | |
970 void show_set_dir() | |
971 { | |
972 GtkWidget *label; | |
973 GtkWidget *bot; | |
974 GtkWidget *top; | |
975 GtkWidget *table; | |
976 | |
977 struct set_dir_dlg *b = g_new0(struct set_dir_dlg, 1); | |
978 | |
979 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
980 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
981 | |
982 b->cancel = gtk_button_new_with_label("Cancel"); | |
983 b->save = gtk_button_new_with_label("Save"); | |
984 | |
985 bot = gtk_hbox_new(TRUE, 10); | |
986 top = gtk_vbox_new(FALSE, 10); | |
987 | |
988 gtk_widget_show(b->save); | |
989 gtk_widget_show(b->cancel); | |
990 | |
991 gtk_box_pack_start(GTK_BOX(bot), b->save, FALSE, FALSE, 5); | |
992 gtk_box_pack_start(GTK_BOX(bot), b->cancel, FALSE, FALSE, 5); | |
993 | |
994 gtk_widget_show(bot); | |
995 | |
996 table = gtk_table_new(10, 2, FALSE); | |
997 | |
998 b->first = gtk_entry_new(); | |
999 b->middle = gtk_entry_new(); | |
1000 b->last = gtk_entry_new(); | |
1001 b->maiden = gtk_entry_new(); | |
1002 b->city = gtk_entry_new(); | |
1003 b->state = gtk_entry_new(); | |
1004 b->country = gtk_entry_new(); | |
1005 b->web = gtk_check_button_new_with_label("Allow Web Searches To Find Your Info"); | |
1006 | |
1007 label = gtk_label_new("First Name"); | |
1008 gtk_widget_show(label); | |
1009 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
1010 gtk_table_attach_defaults(GTK_TABLE(table), b->first, 1, 2, 0, 1); | |
1011 | |
1012 label = gtk_label_new("Middle Name"); | |
1013 gtk_widget_show(label); | |
1014 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
1015 gtk_table_attach_defaults(GTK_TABLE(table), b->middle, 1, 2, 1, 2); | |
1016 | |
1017 label = gtk_label_new("Last Name"); | |
1018 gtk_widget_show(label); | |
1019 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | |
1020 gtk_table_attach_defaults(GTK_TABLE(table), b->last, 1, 2, 2, 3); | |
1021 | |
1022 label = gtk_label_new("Maiden Name"); | |
1023 gtk_widget_show(label); | |
1024 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); | |
1025 gtk_table_attach_defaults(GTK_TABLE(table), b->maiden, 1, 2, 3, 4); | |
1026 | |
1027 label = gtk_label_new("City"); | |
1028 gtk_widget_show(label); | |
1029 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 4, 5); | |
1030 gtk_table_attach_defaults(GTK_TABLE(table), b->city, 1, 2, 4, 5); | |
1031 | |
1032 label = gtk_label_new("State"); | |
1033 gtk_widget_show(label); | |
1034 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 5, 6); | |
1035 gtk_table_attach_defaults(GTK_TABLE(table), b->state, 1, 2, 5, 6); | |
1036 | |
1037 label = gtk_label_new("Country"); | |
1038 gtk_widget_show(label); | |
1039 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 6, 7); | |
1040 gtk_table_attach_defaults(GTK_TABLE(table), b->country, 1, 2, 6, 7); | |
1041 | |
1042 gtk_table_attach_defaults(GTK_TABLE(table), b->web, 0, 2, 8, 9); | |
1043 | |
1044 gtk_widget_show(table); | |
1045 gtk_box_pack_start(GTK_BOX(top), table, FALSE, FALSE, 5); | |
1046 gtk_box_pack_start(GTK_BOX(top), bot, FALSE, FALSE, 5); | |
1047 | |
1048 gtk_widget_show(b->first); | |
1049 gtk_widget_show(b->middle); | |
1050 gtk_widget_show(b->last); | |
1051 gtk_widget_show(b->maiden); | |
1052 gtk_widget_show(b->city); | |
1053 gtk_widget_show(b->state); | |
1054 gtk_widget_show(b->country); | |
1055 gtk_widget_show(b->web); | |
1056 | |
1057 gtk_widget_show(top); | |
1058 | |
1059 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1060 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1061 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", | |
1062 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1063 gtk_signal_connect(GTK_OBJECT(b->save), "clicked", GTK_SIGNAL_FUNC(do_set_dir), b); | |
1064 | |
1065 gtk_container_add(GTK_CONTAINER(b->window), top); | |
1066 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1067 gtk_widget_set_usize(b->window, 530, 280); | |
1068 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Set Dir Info"); | |
1069 gtk_window_set_focus(GTK_WINDOW(b->window), b->first); | |
1070 gtk_widget_realize(b->window); | |
1071 aol_icon(b->window->window); | |
1072 | |
1073 gtk_widget_show(b->window); | |
1074 } | |
1075 | |
149 | 1076 void do_change_password(GtkWidget *widget, struct passwddlg *b) |
1077 { | |
1078 gchar *orig, *new1, *new2; | |
1079 gchar *buf; | |
1080 | |
1081 orig = gtk_entry_get_text(GTK_ENTRY(b->original)); | |
1082 new1 = gtk_entry_get_text(GTK_ENTRY(b->new1)); | |
1083 new2 = gtk_entry_get_text(GTK_ENTRY(b->new2)); | |
1084 | |
1085 if (strcasecmp(new1, new2)) { | |
1086 do_error_dialog("New Passwords Do Not Match", "Gaim - Change Password Error"); | |
1087 return ; | |
1088 } | |
1089 | |
1090 if ((strlen(orig) < 1) || (strlen(new1) < 1) || (strlen(new2) < 1)) { | |
1091 do_error_dialog("Fill out all fields completely", "Gaim - Change Password Error"); | |
1092 return; | |
1093 } | |
1094 | |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
236
diff
changeset
|
1095 serv_change_passwd(orig, new1); |
149 | 1096 |
1097 destroy_dialog(NULL, b->window); | |
1098 g_free(b); | |
1099 } | |
1100 | |
146 | 1101 void show_change_passwd() |
1102 { | |
1103 GtkWidget *hbox; | |
1104 GtkWidget *label; | |
1105 GtkWidget *vbox; | |
149 | 1106 GtkWidget *table; |
146 | 1107 struct passwddlg *b = g_new0(struct passwddlg, 1); |
1108 | |
1109 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1110 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
149 | 1111 |
146 | 1112 b->ok = gtk_button_new_with_label("Ok"); |
149 | 1113 b->cancel = gtk_button_new_with_label("Cancel"); |
1114 | |
1115 gtk_widget_show(b->ok); | |
1116 gtk_widget_show(b->cancel); | |
1117 | |
1118 table = gtk_table_new(3, 2, TRUE); | |
1119 | |
1120 | |
1121 | |
146 | 1122 label = gtk_label_new("Original Password"); |
1123 gtk_widget_show(label); | |
149 | 1124 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); |
146 | 1125 b->original = gtk_entry_new(); |
160
aaa8f0a2140e
[gaim-migrate @ 170]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
149
diff
changeset
|
1126 gtk_entry_set_visibility(GTK_ENTRY(b->original), FALSE); |
149 | 1127 gtk_widget_show(b->original); |
1128 gtk_table_attach_defaults(GTK_TABLE(table), b->original, 1, 2, 0, 1); | |
1129 | |
1130 label = gtk_label_new("New Password"); | |
1131 gtk_widget_show(label); | |
1132 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
1133 b->new1 = gtk_entry_new(); | |
160
aaa8f0a2140e
[gaim-migrate @ 170]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
149
diff
changeset
|
1134 gtk_entry_set_visibility(GTK_ENTRY(b->new1), FALSE); |
149 | 1135 gtk_widget_show(b->new1); |
1136 gtk_table_attach_defaults(GTK_TABLE(table), b->new1, 1, 2, 1, 2); | |
1137 | |
1138 label = gtk_label_new("New Password (again)"); | |
1139 gtk_widget_show(label); | |
1140 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | |
1141 b->new2 = gtk_entry_new(); | |
160
aaa8f0a2140e
[gaim-migrate @ 170]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
149
diff
changeset
|
1142 gtk_entry_set_visibility(GTK_ENTRY(b->new2), FALSE); |
149 | 1143 gtk_widget_show(b->new2); |
1144 gtk_table_attach_defaults(GTK_TABLE(table), b->new2, 1, 2, 2, 3); | |
1145 | |
1146 gtk_widget_show(table); | |
1147 | |
1148 vbox = gtk_vbox_new(TRUE, TRUE); | |
1149 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 5); | |
1150 | |
1151 hbox = gtk_hbox_new(TRUE, TRUE); | |
1152 gtk_box_pack_start(GTK_BOX(hbox), b->ok, FALSE, FALSE, 5); | |
1153 gtk_box_pack_start(GTK_BOX(hbox), b->cancel, FALSE, FALSE, 5); | |
1154 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
146 | 1155 gtk_widget_show(hbox); |
1156 | |
1157 gtk_container_add(GTK_CONTAINER(b->window), vbox); | |
1158 gtk_widget_show(vbox); | |
149 | 1159 |
1160 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1161 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Password Change"); | |
146 | 1162 gtk_widget_show(b->window); |
149 | 1163 |
1164 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1165 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1166 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", | |
1167 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1168 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", | |
1169 GTK_SIGNAL_FUNC(do_change_password), b); | |
1170 | |
1171 | |
146 | 1172 } |
1173 | |
1 | 1174 void show_set_info() |
1175 { | |
1176 GtkWidget *bot; | |
1177 GtkWidget *top; | |
1178 | |
1179 struct set_info_dlg *b = g_new0(struct set_info_dlg, 1); | |
1180 | |
1181 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1182 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
1183 | |
1184 b->cancel = gtk_button_new_with_label("Cancel"); | |
1185 b->save = gtk_button_new_with_label("Save"); | |
1186 | |
1187 bot = gtk_hbox_new(TRUE, 10); | |
1188 top = gtk_vbox_new(FALSE, 10); | |
1189 | |
1190 gtk_widget_show(b->save); | |
1191 gtk_widget_show(b->cancel); | |
1192 | |
1193 gtk_box_pack_start(GTK_BOX(bot), b->save, FALSE, FALSE, 10); | |
1194 gtk_box_pack_start(GTK_BOX(bot), b->cancel, FALSE, FALSE, 10); | |
1195 | |
1196 | |
1197 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1198 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1199 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", | |
1200 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1201 gtk_signal_connect(GTK_OBJECT(b->save), "clicked", | |
1202 GTK_SIGNAL_FUNC(do_save_info), b); | |
1203 | |
1204 gtk_widget_show(bot); | |
1205 | |
1206 | |
1207 b->text = gtk_text_new(NULL, NULL); | |
1208 gtk_text_set_word_wrap(GTK_TEXT(b->text), TRUE); | |
1209 gtk_text_set_editable(GTK_TEXT(b->text), TRUE); | |
1210 gtk_widget_set_usize(b->text, 350, 100); | |
1211 gtk_text_insert(GTK_TEXT(b->text), NULL, NULL, NULL, current_user->user_info, -1); | |
1212 | |
1213 gtk_widget_show(b->text); | |
1214 | |
1215 gtk_box_pack_start(GTK_BOX(top), b->text, TRUE, TRUE, 10); | |
1216 gtk_widget_show(top); | |
1217 | |
1218 gtk_box_pack_start(GTK_BOX(top), bot, FALSE, FALSE, 10); | |
1219 gtk_container_add(GTK_CONTAINER(b->window), top); | |
1220 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1221 gtk_widget_realize(b->window); | |
1222 aol_icon(b->window->window); | |
1223 | |
1224 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Set User Info"); | |
1225 gtk_widget_show(b->window); | |
1226 | |
1227 } | |
1228 | |
1229 /*------------------------------------------------------------------------*/ | |
1230 /* The dialog for registration information */ | |
1231 /*------------------------------------------------------------------------*/ | |
1232 | |
1233 void do_register_dialog(GtkWidget *widget, struct registerdlg *b) | |
1234 { | |
1235 char *email = gtk_entry_get_text(GTK_ENTRY(b->email)); | |
1236 char *name = gtk_entry_get_text(GTK_ENTRY(b->name)); | |
1237 int uname = GTK_TOGGLE_BUTTON(b->uname)->active; | |
1238 int sname = GTK_TOGGLE_BUTTON(b->sname)->active; | |
1239 char *country = gtk_entry_get_text(GTK_ENTRY(b->country)); | |
1240 | |
1241 general_options |= OPT_GEN_REGISTERED; | |
1242 save_prefs(); | |
1243 | |
1244 destroy_dialog(NULL, b->window); | |
1245 | |
1246 g_free(b); | |
1247 | |
1248 g_sendemail(name, email, uname, sname, country); | |
1249 } | |
1250 | |
1251 void set_reg_flag(GtkWidget *widget, struct registerdlg *b) | |
1252 { | |
1253 general_options |= OPT_GEN_REGISTERED; | |
1254 save_prefs(); | |
1255 destroy_dialog(NULL, b->window); | |
1256 g_free(b); | |
1257 } | |
1258 | |
1259 void show_register_dialog() | |
1260 { | |
1261 GtkWidget *ok; | |
1262 GtkWidget *cancel; | |
1263 GtkWidget *label; | |
1264 GtkWidget *table; | |
1265 GtkWidget *vbox; | |
1266 GtkWidget *bbox; | |
1267 | |
1268 struct registerdlg *b = g_new0(struct registerdlg, 1); | |
1269 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1270 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
1271 | |
1272 cancel = gtk_button_new_with_label("Cancel"); | |
1273 ok = gtk_button_new_with_label("Send"); | |
1274 | |
1275 bbox = gtk_hbox_new(TRUE, 10); | |
1276 table = gtk_table_new(6, 2, TRUE); | |
1277 vbox = gtk_vbox_new(FALSE, 5); | |
1278 | |
1279 b->name = gtk_entry_new(); | |
1280 b->email = gtk_entry_new(); | |
1281 b->uname = gtk_check_button_new_with_label("Send the output of uname -a with registration"); | |
1282 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->uname), TRUE); | |
1283 b->sname = gtk_check_button_new_with_label("Send my screenname with registration"); | |
1284 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sname), TRUE); | |
1285 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 10); | |
1286 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
1287 | |
1288 label = gtk_label_new("This list will not, in any way, be distributed and\nwill be used for internal census purposes only.\nAll fields are completely optional."); | |
1289 gtk_widget_show(label); | |
1290 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 2, 0, 1); | |
1291 | |
1292 label = gtk_label_new("Name"); | |
1293 gtk_widget_show(label); | |
1294 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
1295 gtk_table_attach_defaults(GTK_TABLE(table), b->name, 1, 2, 1, 2); | |
1296 | |
1297 label = gtk_label_new("Email"); | |
1298 gtk_widget_show(label); | |
1299 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | |
1300 gtk_table_attach_defaults(GTK_TABLE(table), b->email, 1, 2, 2, 3); | |
1301 | |
1302 label = gtk_label_new("Country"); | |
1303 b->country = gtk_entry_new(); | |
1304 gtk_widget_show(label); | |
1305 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); | |
1306 gtk_table_attach_defaults(GTK_TABLE(table), b->country, 1, 2, 3, 4); | |
1307 | |
1308 gtk_table_attach_defaults(GTK_TABLE(table), b->sname, 0, 2, 4, 5); | |
1309 gtk_table_attach_defaults(GTK_TABLE(table), b->uname, 0, 2, 5, 6); | |
1310 | |
1311 gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 5); | |
1312 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
1313 | |
1314 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1315 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1316 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
1317 GTK_SIGNAL_FUNC(set_reg_flag), b); | |
1318 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
1319 GTK_SIGNAL_FUNC(do_register_dialog), b); | |
1320 | |
1321 gtk_widget_show(ok); | |
1322 gtk_widget_show(cancel); | |
1323 gtk_widget_show(b->name); | |
1324 gtk_widget_show(b->email); | |
1325 gtk_widget_show(b->uname); | |
1326 gtk_widget_show(b->sname); | |
1327 gtk_widget_show(b->country); | |
1328 gtk_widget_show(table); | |
1329 gtk_widget_show(bbox); | |
1330 gtk_widget_show(vbox); | |
1331 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Registration"); | |
1332 gtk_window_set_focus(GTK_WINDOW(b->window), b->name); | |
1333 gtk_container_add(GTK_CONTAINER(b->window), vbox); | |
1334 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1335 gtk_widget_realize(b->window); | |
1336 aol_icon(b->window->window); | |
1337 | |
1338 gtk_widget_show(b->window); | |
1339 } | |
1340 | |
1341 | |
1342 /*------------------------------------------------------------------------*/ | |
1343 /* The dialog for the info requests */ | |
1344 /*------------------------------------------------------------------------*/ | |
1345 | |
247
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
245
diff
changeset
|
1346 void g_show_info_text(char *info) |
1 | 1347 { |
1348 GtkWidget *ok; | |
1349 GtkWidget *label; | |
1350 GtkWidget *text; | |
1351 GtkWidget *bbox; | |
1352 GtkWidget *sw; | |
337 | 1353 GdkBitmap *mask; |
1354 GdkPixmap *face; | |
1355 GtkWidget *face_p; | |
1 | 1356 |
1357 struct info_dlg *b = g_new0(struct info_dlg, 1); | |
1358 | |
1359 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1360 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
1361 gtk_container_border_width(GTK_CONTAINER(b->window), 5); | |
1362 bbox = gtk_vbox_new(FALSE, 5); | |
1363 gtk_container_add(GTK_CONTAINER(b->window), bbox); | |
1364 | |
1365 ok = gtk_button_new_with_label("OK"); | |
1366 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1367 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1368 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
1369 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1370 | |
1371 label = gtk_label_new("Below are the results of your search: "); | |
1372 | |
1373 sw = gtk_scrolled_window_new (NULL, NULL); | |
1374 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), | |
1375 GTK_POLICY_NEVER, | |
1376 GTK_POLICY_ALWAYS); | |
1377 text = gtk_html_new(NULL, NULL); | |
1378 b->text = text; | |
1379 gtk_container_add(GTK_CONTAINER(sw), text); | |
1380 | |
1381 GTK_HTML (text)->hadj->step_increment = 10.0; | |
1382 GTK_HTML (text)->vadj->step_increment = 10.0; | |
1383 gtk_widget_set_usize(sw, 300, 250); | |
1384 | |
1385 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0); | |
1386 gtk_box_pack_start(GTK_BOX(bbox), sw, TRUE, TRUE, 0); | |
1387 gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0); | |
1388 | |
1389 gtk_widget_realize(b->window); | |
1390 aol_icon(b->window->window); | |
1391 gtk_widget_show_all(b->window); | |
1392 | |
247
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
245
diff
changeset
|
1393 gtk_html_append_text(GTK_HTML(b->text), info, 0); |
337 | 1394 |
247
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
245
diff
changeset
|
1395 } |
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
245
diff
changeset
|
1396 |
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
245
diff
changeset
|
1397 void g_show_info(char *url) { |
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
245
diff
changeset
|
1398 char *url_text = grab_url(url); |
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
245
diff
changeset
|
1399 g_show_info_text(url_text); |
1 | 1400 g_free(url_text); |
1401 } | |
1402 | |
1403 /*------------------------------------------------------------------------*/ | |
1404 /* The dialog for adding to permit/deny */ | |
1405 /*------------------------------------------------------------------------*/ | |
1406 | |
1407 | |
1408 static void do_add_perm(GtkWidget *w, struct addperm *p) | |
1409 { | |
1410 | |
1411 char *who; | |
1412 char *name; | |
1413 int d = 0; | |
1414 GSList *buttons = p->buttons; | |
1415 | |
1416 | |
1417 who = gtk_entry_get_text(GTK_ENTRY(p->entry)); | |
1418 | |
1419 name = g_malloc(strlen(who) + 2); | |
1420 g_snprintf(name, strlen(who) + 2, "%s", who); | |
1421 | |
1422 while(buttons) { | |
1423 if((int)gtk_object_get_user_data(GTK_OBJECT(buttons->data)) == 1) { | |
1424 if (GTK_TOGGLE_BUTTON(buttons->data)->active) | |
1425 d = 1; | |
1426 } | |
1427 buttons = buttons->next; | |
1428 } | |
1429 | |
1430 if (d) { | |
1431 deny = g_list_append(deny, name); | |
1432 serv_add_deny(name); | |
1433 } else { | |
1434 permit = g_list_append(permit, name); | |
1435 serv_add_permit(name); | |
1436 } | |
1437 | |
1438 | |
1439 | |
1440 build_permit_tree(); | |
1441 | |
1442 serv_save_config(); | |
300
b32c83750104
[gaim-migrate @ 310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
1443 do_export(0, 0); |
1 | 1444 |
1445 destroy_dialog(NULL, p->window); | |
1446 } | |
1447 | |
1448 | |
1449 | |
1450 void show_add_perm(char *who) | |
1451 { | |
1452 GtkWidget *cancel; | |
1453 GtkWidget *add; | |
1454 GtkWidget *label; | |
1455 GtkWidget *bbox; | |
1456 GtkWidget *vbox; | |
1457 GtkWidget *rbox; | |
1458 GtkWidget *topbox; | |
1459 GtkWidget *which; | |
1460 struct addperm *p = g_new0(struct addperm, 1); | |
1461 | |
1462 p->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1463 dialogwindows = g_list_prepend(dialogwindows, p->window); | |
1464 cancel = gtk_button_new_with_label("Cancel"); | |
1465 add = gtk_button_new_with_label("Add"); | |
1466 bbox = gtk_hbox_new(TRUE, 10); | |
1467 topbox = gtk_hbox_new(FALSE, 5); | |
1468 vbox = gtk_vbox_new(FALSE, 5); | |
1469 rbox = gtk_vbox_new(FALSE, 5); | |
1470 p->entry = gtk_entry_new(); | |
1471 | |
1472 if (who != NULL) | |
1473 gtk_entry_set_text(GTK_ENTRY(p->entry), who); | |
1474 | |
1475 which = gtk_radio_button_new_with_label(NULL, "Deny"); | |
1476 gtk_box_pack_start(GTK_BOX(rbox), which, FALSE, FALSE, 0); | |
1477 gtk_object_set_user_data(GTK_OBJECT(which), (int *)1); | |
1478 gtk_widget_show(which); | |
1479 | |
1480 which = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(which)), "Permit"); | |
1481 gtk_box_pack_start(GTK_BOX(rbox), which, FALSE, FALSE, 0); | |
1482 gtk_object_set_user_data(GTK_OBJECT(which), (int *)2); | |
1483 gtk_widget_show(which); | |
1484 | |
1485 /* Put the buttons in the box */ | |
1486 gtk_box_pack_start(GTK_BOX(bbox), add, TRUE, TRUE, 10); | |
1487 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
1488 | |
1489 label = gtk_label_new("Add"); | |
1490 gtk_widget_show(label); | |
1491 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
1492 gtk_box_pack_start(GTK_BOX(topbox), p->entry, FALSE, FALSE, 5); | |
1493 gtk_box_pack_start(GTK_BOX(topbox), rbox, FALSE, FALSE, 5); | |
1494 /* And the boxes in the box */ | |
1495 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
1496 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
1497 | |
1498 | |
1499 p->buttons = gtk_radio_button_group(GTK_RADIO_BUTTON(which)); | |
1500 /* Handle closes right */ | |
1501 gtk_signal_connect(GTK_OBJECT(p->window), "destroy", | |
1502 GTK_SIGNAL_FUNC(destroy_dialog), p->window); | |
1503 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
1504 GTK_SIGNAL_FUNC(destroy_dialog), p->window); | |
1505 gtk_signal_connect(GTK_OBJECT(add), "clicked", | |
1506 GTK_SIGNAL_FUNC(do_add_perm), p); | |
1507 gtk_signal_connect(GTK_OBJECT(p->entry), "activate", | |
1508 GTK_SIGNAL_FUNC(do_add_perm), p); | |
1509 | |
1510 /* Finish up */ | |
1511 gtk_widget_show(add); | |
1512 gtk_widget_show(cancel); | |
1513 gtk_widget_show(p->entry); | |
1514 gtk_widget_show(topbox); | |
1515 gtk_widget_show(bbox); | |
1516 gtk_widget_show(vbox); | |
1517 gtk_widget_show(rbox); | |
1518 gtk_window_set_title(GTK_WINDOW(p->window), "Gaim - Add Permit/Deny"); | |
1519 gtk_window_set_focus(GTK_WINDOW(p->window), p->entry); | |
1520 gtk_container_add(GTK_CONTAINER(p->window), vbox); | |
1521 gtk_widget_realize(p->window); | |
1522 aol_icon(p->window->window); | |
1523 | |
1524 gtk_widget_show(p->window); | |
1525 } | |
1526 | |
1527 | |
1528 /*------------------------------------------------------------------------*/ | |
1529 /* Function Called To Add A Log */ | |
1530 /*------------------------------------------------------------------------*/ | |
1531 | |
1532 void do_log(GtkWidget *w, char *name) | |
1533 { | |
1534 struct log_conversation *l; | |
1535 struct conversation *c; | |
1536 char buf[128]; | |
1537 | |
1538 c = find_conversation(name); | |
1539 if (!find_log_info(name)) { | |
1540 l = (struct log_conversation *)g_new0(struct log_conversation, 1); | |
1541 strcpy(l->name, name); | |
1542 strcpy(l->filename, gtk_file_selection_get_filename(GTK_FILE_SELECTION(logdialog))); | |
1543 log_conversations = g_list_append(log_conversations, l); | |
1544 | |
1545 if (c != NULL) | |
1546 { | |
1547 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, c->name); | |
1548 gtk_window_set_title(GTK_WINDOW(c->window), buf); | |
1549 } | |
1550 } | |
1551 | |
1552 save_prefs(); | |
1553 | |
1554 destroy_dialog(NULL, logdialog); | |
1555 logdialog = NULL; | |
1556 } | |
1557 | |
1558 static void cancel_log(GtkWidget *w, char *name) | |
1559 { | |
1560 | |
1561 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(logdialog)); | |
1562 | |
1563 if (c != NULL) | |
1564 { | |
1565 set_state_lock(1); | |
1566 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->log_button), FALSE); | |
1567 set_state_lock(0); | |
1568 } | |
1569 destroy_dialog(NULL, logdialog); | |
1570 } | |
1571 | |
1572 void show_log_dialog(char *bname) | |
1573 { | |
1574 char *buf = g_malloc(BUF_LEN); | |
1575 struct conversation *c = find_conversation(bname); | |
1576 | |
1577 | |
1578 if (!logdialog) { | |
1579 logdialog = gtk_file_selection_new("Gaim - Log Conversation"); | |
1580 | |
1581 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(logdialog)); | |
1582 | |
1583 gtk_object_set_user_data(GTK_OBJECT(logdialog), c); | |
1584 | |
1585 g_snprintf(buf, BUF_LEN - 1, "%s/%s.log", getenv("HOME"), bname); | |
1586 | |
1587 gtk_file_selection_set_filename(GTK_FILE_SELECTION(logdialog), buf); | |
1588 gtk_signal_connect(GTK_OBJECT(logdialog), "delete_event", GTK_SIGNAL_FUNC(cancel_log), c); | |
1589 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(logdialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_log), bname); | |
1590 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(logdialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_log), bname); | |
1591 } | |
1592 | |
25 | 1593 g_free(buf); |
1594 | |
1 | 1595 gtk_widget_show(logdialog); |
1596 gdk_window_raise(logdialog->window); | |
1597 } | |
1598 | |
1599 /*------------------------------------------------------*/ | |
1600 /* Find Buddy By Email */ | |
1601 /*------------------------------------------------------*/ | |
1602 | |
1603 void do_find_info(GtkWidget *w, struct findbyinfo *b) | |
1604 { | |
1605 char *first; | |
1606 char *middle; | |
1607 char *last; | |
1608 char *maiden; | |
1609 char *city; | |
1610 char *state; | |
1611 char *country; | |
1612 | |
1613 first = gtk_entry_get_text(GTK_ENTRY(b->firstentry)); | |
1614 middle = gtk_entry_get_text(GTK_ENTRY(b->middleentry)); | |
1615 last = gtk_entry_get_text(GTK_ENTRY(b->lastentry)); | |
1616 maiden = gtk_entry_get_text(GTK_ENTRY(b->maidenentry)); | |
1617 city = gtk_entry_get_text(GTK_ENTRY(b->cityentry)); | |
1618 state = gtk_entry_get_text(GTK_ENTRY(b->stateentry)); | |
1619 country = gtk_entry_get_text(GTK_ENTRY(b->countryentry)); | |
1620 | |
1621 serv_dir_search(first, middle, last, maiden, city, state, country, ""); | |
1622 destroy_dialog(NULL, b->window); | |
1623 } | |
1624 | |
1625 void do_find_email(GtkWidget *w, struct findbyemail *b) | |
1626 { | |
1627 char *email; | |
1628 | |
1629 email = gtk_entry_get_text(GTK_ENTRY(b->emailentry)); | |
1630 | |
1631 serv_dir_search("","","","","","","", email); | |
1632 | |
1633 destroy_dialog(NULL, b->window); | |
1634 } | |
1635 | |
1636 void show_find_info() | |
1637 { | |
1638 GtkWidget *cancel; | |
1639 GtkWidget *ok; | |
1640 GtkWidget *label; | |
1641 GtkWidget *bbox; | |
1642 GtkWidget *vbox; | |
1643 GtkWidget *topbox; | |
1644 | |
1645 struct findbyinfo *b = g_new0(struct findbyinfo, 1); | |
1646 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1647 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
1648 | |
1649 cancel = gtk_button_new_with_label("Cancel"); | |
1650 ok = gtk_button_new_with_label("OK"); | |
1651 | |
1652 bbox = gtk_hbox_new(TRUE, 10); | |
1653 topbox = gtk_table_new(7, 2, TRUE); | |
1654 vbox = gtk_vbox_new(FALSE, 5); | |
1655 | |
1656 b->firstentry = gtk_entry_new(); | |
1657 b->middleentry = gtk_entry_new(); | |
1658 b->lastentry = gtk_entry_new(); | |
1659 b->maidenentry = gtk_entry_new(); | |
1660 b->cityentry = gtk_entry_new(); | |
1661 b->stateentry = gtk_entry_new(); | |
1662 b->countryentry = gtk_entry_new(); | |
1663 | |
1664 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 10); | |
1665 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
1666 | |
1667 label = gtk_label_new("First Name"); | |
1668 gtk_widget_show(label); | |
1669 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 0, 1); | |
1670 gtk_table_attach_defaults(GTK_TABLE(topbox), b->firstentry, 1, 2, 0, 1); | |
1671 | |
1672 label = gtk_label_new("Middle Name"); | |
1673 gtk_widget_show(label); | |
1674 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 1, 2); | |
1675 gtk_table_attach_defaults(GTK_TABLE(topbox), b->middleentry, 1, 2, 1, 2); | |
1676 | |
1677 label = gtk_label_new("Last Name"); | |
1678 gtk_widget_show(label); | |
1679 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 2, 3); | |
1680 gtk_table_attach_defaults(GTK_TABLE(topbox), b->lastentry, 1, 2, 2, 3); | |
1681 | |
1682 label = gtk_label_new("Maiden Name"); | |
1683 gtk_widget_show(label); | |
1684 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 3, 4); | |
1685 gtk_table_attach_defaults(GTK_TABLE(topbox), b->maidenentry, 1, 2, 3, 4); | |
1686 | |
1687 label = gtk_label_new("City"); | |
1688 gtk_widget_show(label); | |
1689 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 4, 5); | |
1690 gtk_table_attach_defaults(GTK_TABLE(topbox), b->cityentry, 1, 2, 4, 5); | |
1691 | |
1692 label = gtk_label_new("State"); | |
1693 gtk_widget_show(label); | |
1694 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 5, 6); | |
1695 gtk_table_attach_defaults(GTK_TABLE(topbox), b->stateentry, 1, 2, 5, 6); | |
1696 | |
1697 label = gtk_label_new("Country"); | |
1698 gtk_widget_show(label); | |
1699 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 6, 7); | |
1700 gtk_table_attach_defaults(GTK_TABLE(topbox), b->countryentry, 1, 2, 6, 7); | |
1701 | |
1702 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
1703 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
1704 | |
1705 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1706 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1707 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
1708 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1709 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
1710 GTK_SIGNAL_FUNC(do_find_info), b); | |
1711 | |
1712 gtk_widget_show(ok); | |
1713 gtk_widget_show(cancel); | |
1714 gtk_widget_show(b->firstentry); | |
1715 gtk_widget_show(b->middleentry); | |
1716 gtk_widget_show(b->lastentry); | |
1717 gtk_widget_show(b->maidenentry); | |
1718 gtk_widget_show(b->cityentry); | |
1719 gtk_widget_show(b->stateentry); | |
1720 gtk_widget_show(b->countryentry); | |
1721 gtk_widget_show(topbox); | |
1722 gtk_widget_show(bbox); | |
1723 gtk_widget_show(vbox); | |
1724 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Find Buddy By Info"); | |
1725 gtk_window_set_focus(GTK_WINDOW(b->window), b->firstentry); | |
1726 gtk_container_add(GTK_CONTAINER(b->window), vbox); | |
1727 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1728 gtk_widget_realize(b->window); | |
1729 aol_icon(b->window->window); | |
1730 | |
1731 gtk_widget_show(b->window); | |
1732 } | |
1733 | |
1734 void show_find_email() | |
1735 { | |
1736 GtkWidget *cancel; | |
1737 GtkWidget *ok; | |
1738 GtkWidget *label; | |
1739 GtkWidget *bbox; | |
1740 GtkWidget *vbox; | |
1741 GtkWidget *topbox; | |
1742 | |
1743 struct findbyemail *b = g_new0(struct findbyemail, 1); | |
1744 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1745 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
1746 | |
1747 cancel = gtk_button_new_with_label("Cancel"); | |
1748 ok = gtk_button_new_with_label("OK"); | |
1749 | |
1750 bbox = gtk_hbox_new(TRUE, 10); | |
1751 topbox = gtk_hbox_new(FALSE, 5); | |
1752 vbox = gtk_vbox_new(FALSE, 5); | |
1753 | |
1754 b->emailentry = gtk_entry_new(); | |
1755 | |
1756 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 10); | |
1757 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
1758 | |
1759 label = gtk_label_new("Email"); | |
1760 gtk_widget_show(label); | |
1761 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
1762 gtk_box_pack_start(GTK_BOX(topbox), b->emailentry, FALSE, FALSE, 5); | |
1763 | |
1764 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
1765 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
1766 | |
1767 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1768 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1769 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
1770 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1771 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
1772 GTK_SIGNAL_FUNC(do_find_email), b); | |
1773 gtk_signal_connect(GTK_OBJECT(b->emailentry), "activate", | |
1774 GTK_SIGNAL_FUNC(do_find_email), b); | |
1775 | |
1776 gtk_widget_show(ok); | |
1777 gtk_widget_show(cancel); | |
1778 gtk_widget_show(b->emailentry); | |
1779 gtk_widget_show(topbox); | |
1780 gtk_widget_show(bbox); | |
1781 gtk_widget_show(vbox); | |
1782 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Find Buddy By Email"); | |
1783 gtk_window_set_focus(GTK_WINDOW(b->window), b->emailentry); | |
1784 gtk_container_add(GTK_CONTAINER(b->window), vbox); | |
1785 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1786 gtk_widget_realize(b->window); | |
1787 aol_icon(b->window->window); | |
1788 | |
1789 gtk_widget_show(b->window); | |
1790 } | |
1791 | |
1792 /*------------------------------------------------------*/ | |
1793 /* Link Dialog */ | |
1794 /*------------------------------------------------------*/ | |
1795 | |
1796 void cancel_link(GtkWidget *widget, struct linkdlg *b) | |
1797 { | |
62 | 1798 if (b->toggle) { |
1799 set_state_lock(1); | |
1 | 1800 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->toggle), FALSE); |
62 | 1801 set_state_lock(0); |
1802 } | |
1 | 1803 destroy_dialog(NULL, b->window); |
1804 } | |
1805 | |
1806 void do_add_link(GtkWidget *widget, struct linkdlg *b) | |
1807 { | |
1808 char *open_tag; | |
1809 char *urltext, *showtext; | |
1810 open_tag = g_malloc(2048); | |
1811 | |
1812 | |
1813 urltext = gtk_entry_get_text(GTK_ENTRY(b->url)); | |
1814 showtext = gtk_entry_get_text(GTK_ENTRY(b->text)); | |
1815 | |
1816 g_snprintf(open_tag, 2048, "<A HREF=\"%s\">%s", urltext, showtext); | |
1817 surround(b->entry, open_tag, "</A>"); | |
1818 | |
1819 g_free(open_tag); | |
1820 destroy_dialog(NULL, b->window); | |
1821 } | |
1822 | |
1823 | |
1824 void show_add_link(GtkWidget *entry, GtkWidget *link) | |
1825 { | |
1826 GtkWidget *vbox; | |
1827 GtkWidget *bbox; | |
1828 GtkWidget *table; | |
1829 GtkWidget *label; | |
1830 | |
1831 if (!linkdialog) { | |
1832 struct linkdlg *b = g_new0(struct linkdlg, 1); | |
1833 linkdialog = gtk_window_new(GTK_WINDOW_DIALOG); | |
1834 dialogwindows = g_list_prepend(dialogwindows, linkdialog); | |
1835 | |
1836 b->cancel = gtk_button_new_with_label("Cancel"); | |
1837 b->ok = gtk_button_new_with_label("Ok"); | |
1838 | |
1839 vbox = gtk_vbox_new(FALSE, 10); | |
1840 bbox = gtk_hbox_new(TRUE, 10); | |
1841 | |
1842 gtk_widget_show(b->ok); | |
1843 gtk_widget_show(b->cancel); | |
1844 | |
1845 gtk_box_pack_start(GTK_BOX(bbox), b->ok, FALSE, FALSE, 10); | |
1846 gtk_box_pack_start(GTK_BOX(bbox), b->cancel, FALSE, FALSE, 10); | |
1847 gtk_widget_show(bbox); | |
1848 | |
1849 table = gtk_table_new(2, 2, FALSE); | |
1850 b->url = gtk_entry_new(); | |
1851 b->text = gtk_entry_new(); | |
1852 | |
1853 label = gtk_label_new("URL"); | |
1854 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
1855 gtk_table_attach_defaults(GTK_TABLE(table), b->url, 1, 2, 0, 1); | |
1856 gtk_widget_show(label); | |
1857 | |
1858 label = gtk_label_new("Description"); | |
1859 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
1860 gtk_table_attach_defaults(GTK_TABLE(table), b->text, 1, 2, 1, 2); | |
1861 gtk_widget_show(label); | |
1862 | |
1863 gtk_widget_show(b->url); | |
1864 gtk_widget_show(b->text); | |
1865 gtk_widget_show(table); | |
1866 | |
1867 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 10); | |
1868 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 10); | |
1869 gtk_widget_show(vbox); | |
1870 | |
1871 gtk_signal_connect(GTK_OBJECT(linkdialog), "destroy", | |
1872 GTK_SIGNAL_FUNC(cancel_link), b); | |
1873 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", | |
1874 GTK_SIGNAL_FUNC(cancel_link), b); | |
1875 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", | |
1876 GTK_SIGNAL_FUNC(do_add_link), b); | |
1877 | |
1878 gtk_container_add(GTK_CONTAINER(linkdialog ), vbox); | |
1879 gtk_container_border_width(GTK_CONTAINER(linkdialog ), 10); | |
1880 gtk_window_set_title(GTK_WINDOW(linkdialog ), "GAIM - Add URL"); | |
1881 gtk_window_set_focus(GTK_WINDOW(linkdialog ), b->url); | |
1882 b->window = linkdialog; | |
1883 b->toggle = link; | |
1884 b->entry = entry; | |
1885 gtk_widget_realize(linkdialog); | |
1886 aol_icon(linkdialog->window); | |
1887 | |
1888 } | |
1889 | |
1890 gtk_widget_show(linkdialog); | |
1891 gdk_window_raise(linkdialog->window); | |
1892 } | |
1893 | |
1894 | |
1895 /*------------------------------------------------------*/ | |
1896 /* Color Selection Dialog */ | |
1897 /*------------------------------------------------------*/ | |
1898 | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1899 void cancel_color(GtkWidget *widget, struct conversation *c) |
1 | 1900 { |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1901 if (c->palette && widget) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1902 { |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1903 set_state_lock(1); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1904 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->palette), FALSE); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1905 set_state_lock(0); |
61 | 1906 } |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1907 dialogwindows = g_list_remove(dialogwindows, c->color_dialog); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1908 gtk_widget_destroy(c->color_dialog); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1909 c->color_dialog = NULL; |
1 | 1910 } |
1911 | |
1912 void do_color(GtkWidget *widget, GtkColorSelection *colorsel) | |
1913 { | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1914 gdouble color[3]; |
1 | 1915 GdkColor text_color; |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1916 struct conversation *c; |
1 | 1917 char *open_tag; |
1918 | |
1919 open_tag = g_malloc(30); | |
1920 | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1921 gtk_color_selection_get_color (colorsel, color); |
1 | 1922 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1923 c = gtk_object_get_user_data(GTK_OBJECT(colorsel)); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1924 GTK_IS_EDITABLE(c->entry); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1925 |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1926 text_color.red = ((guint16)(color[0]*65535))>>8; |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1927 text_color.green = ((guint16)(color[1]*65535))>>8; |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1928 text_color.blue = ((guint16)(color[2]*65535))>>8; |
1 | 1929 |
1930 g_snprintf(open_tag, 23, "<FONT COLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green, text_color.blue); | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1931 surround(c->entry, open_tag, "</FONT>"); |
1 | 1932 sprintf(debug_buff,"#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue); |
1933 debug_print(debug_buff); | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1934 g_free(open_tag); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1935 cancel_color(NULL, c); |
1 | 1936 } |
1937 | |
1938 | |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1939 void show_color_dialog(struct conversation *c, GtkWidget *color) |
1 | 1940 { |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1941 GtkWidget *colorsel; |
1 | 1942 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1943 if (!c->color_dialog) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1944 { |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1945 c->color_dialog = gtk_color_selection_dialog_new("Select Text Color"); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1946 colorsel = GTK_COLOR_SELECTION_DIALOG(c->color_dialog)->colorsel; |
1 | 1947 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1948 gtk_object_set_user_data(GTK_OBJECT(colorsel), c); |
1 | 1949 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1950 gtk_signal_connect(GTK_OBJECT(c->color_dialog), "delete_event", GTK_SIGNAL_FUNC(delete_event_dialog), c); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1951 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->color_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_color), colorsel); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1952 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->color_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_color), c); |
1 | 1953 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1954 gtk_widget_realize(c->color_dialog); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1955 aol_icon(c->color_dialog->window); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1956 } |
1 | 1957 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1958 gtk_widget_show(c->color_dialog); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1959 gdk_window_raise(c->color_dialog->window); |
1 | 1960 } |
1961 | |
1962 /*------------------------------------------------------------------------*/ | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1963 /* Font Selection Dialog */ |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1964 /*------------------------------------------------------------------------*/ |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1965 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1966 void cancel_font(GtkWidget *widget, struct conversation *c) |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1967 { |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1968 if (c->font && widget) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1969 { |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1970 set_state_lock(1); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1971 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->font), FALSE); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1972 set_state_lock(0); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1973 } |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1974 dialogwindows = g_list_remove(dialogwindows, c->font_dialog); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1975 gtk_widget_destroy(c->font_dialog); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
1976 c->font_dialog = NULL; |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1977 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1978 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1979 void apply_font(GtkWidget *widget, GtkFontSelection *fontsel) |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1980 { |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1981 /* this could be expanded to include font size, weight, etc. |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1982 but for now only works with font face */ |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1983 int i, j = 0, k = 0; |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1984 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(fontsel)); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1985 |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1986 if (c) |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1987 { |
334
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
1988 char *tmp = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); |
308
e5fa88351dc8
[gaim-migrate @ 318]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
300
diff
changeset
|
1989 strncpy(c->current_fontname, tmp, sizeof(c->current_fontname)); |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1990 |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1991 for (i = 0; i < strlen(c->current_fontname); i++) |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
1992 { |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1993 if (c->current_fontname[i] == '-') |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1994 { |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1995 if (++j > 2) |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1996 break; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1997 } |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1998 else if (j == 2) |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
1999 c->current_fontface[k++] = c->current_fontname[i]; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2000 } |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2001 c->current_fontface[k] = '\0'; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2002 |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2003 set_font_face(NULL, c); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2004 } |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2005 else |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2006 { |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2007 if (fontface) |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2008 g_free(fontface); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2009 |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2010 fontface = g_malloc(64); |
334
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2011 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2012 |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2013 for (i = 0; i < strlen(fontname); i++) |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2014 { |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2015 if (fontname[i] == '-') |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2016 { |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2017 if (++j > 2) |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2018 break; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2019 } |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2020 else if (j == 2) |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2021 fontface[k++] = fontname[i]; |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2022 } |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2023 fontface[k] = '\0'; |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2024 |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2025 save_prefs(); |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2026 } |
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2027 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2028 cancel_font(NULL, c); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2029 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2030 |
334
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2031 static GtkWidget *fontseld; |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2032 |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2033 void destroy_fontsel(GtkWidget *w, gpointer d) { |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2034 gtk_widget_destroy(fontseld); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2035 fontseld = NULL; |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2036 } |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2037 |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2038 void apply_font_dlg(GtkWidget *w, GtkWidget *f) { |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2039 int i, j = 0, k = 0; |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2040 if (fontface) |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2041 g_free(fontface); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2042 |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2043 fontface = g_malloc(64); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2044 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontseld)); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2045 destroy_fontsel(0, 0); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2046 for (i = 0; i < strlen(fontname); i++) { |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2047 if (fontname[i] == '-') { |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2048 if (++j > 2) break; |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2049 } else if (j == 2) |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2050 fontface[k++] = fontname[i]; |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2051 } |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2052 fontface[k] = '\0'; |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2053 save_prefs(); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2054 } |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2055 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2056 void show_font_dialog(struct conversation *c, GtkWidget *font) |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2057 { |
334
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2058 |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2059 if (!font) { /* we came from the prefs dialog */ |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2060 if (fontseld) return; |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2061 fontseld = gtk_font_selection_dialog_new("Select Font"); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2062 if (fontname) |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2063 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), fontname); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2064 else |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2065 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), DEFAULT_FONT_NAME); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2066 |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2067 gtk_object_set_user_data(GTK_OBJECT(fontseld), NULL); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2068 gtk_signal_connect(GTK_OBJECT(fontseld), "delete_event", GTK_SIGNAL_FUNC(destroy_fontsel), NULL); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2069 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->cancel_button), "clicked", GTK_SIGNAL_FUNC(destroy_fontsel), NULL); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2070 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->ok_button), "clicked", GTK_SIGNAL_FUNC(apply_font_dlg), NULL); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2071 gtk_widget_realize(fontseld); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2072 aol_icon(fontseld->window); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2073 gtk_widget_show(fontseld); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2074 gdk_window_raise(fontseld->window); |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2075 return; |
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2076 } |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2077 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2078 if (!c->font_dialog) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2079 { |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2080 c->font_dialog = gtk_font_selection_dialog_new("Select Font"); |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2081 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2082 if (font) |
334
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2083 gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), c); |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2084 else |
334
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2085 gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), NULL); |
234
985635758c33
[gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
231
diff
changeset
|
2086 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2087 gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)c->font_dialog, DEFAULT_FONT_NAME); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2088 |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2089 gtk_signal_connect(GTK_OBJECT(c->font_dialog), "delete_event", GTK_SIGNAL_FUNC(delete_event_dialog), c); |
334
0fa651368776
[gaim-migrate @ 344]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
311
diff
changeset
|
2090 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(apply_font), c->font_dialog); |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2091 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_font), c); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2092 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2093 if (fontname) |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2094 gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)c->font_dialog, fontname); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2095 else |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2096 gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)c->font_dialog, DEFAULT_FONT_NAME); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2097 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2098 gtk_widget_realize(c->font_dialog); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2099 |
311
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2100 aol_icon(c->font_dialog->window); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2101 } |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2102 gtk_widget_show(c->font_dialog); |
0a8b4edc4732
[gaim-migrate @ 321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
308
diff
changeset
|
2103 gdk_window_raise(c->font_dialog->window); |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2104 } |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2105 |
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2106 /*------------------------------------------------------------------------*/ |
1 | 2107 /* The dialog for import/export */ |
2108 /*------------------------------------------------------------------------*/ | |
2109 | |
228 | 2110 #define PATHSIZE 1024 |
2111 | |
229 | 2112 /* see if a buddy list cache file for this user exists */ |
2113 | |
2114 gboolean | |
2115 bud_list_cache_exists( void ) | |
2116 { | |
2117 gboolean ret = FALSE; | |
2118 char path[PATHSIZE]; | |
2119 char *file; | |
2120 struct stat sbuf; | |
2121 extern char g_screenname[]; | |
2122 | |
2123 file = getenv( "HOME" ); | |
2124 if ( file != (char *) NULL ) { | |
262
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2125 sprintf( path, "%s/.gaim/%s.blist", file, g_screenname ); |
229 | 2126 if ( !stat(path, &sbuf) ) |
2127 ret = TRUE; | |
2128 } | |
2129 return ret; | |
2130 } | |
2131 | |
262
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2132 /* if dummy is 0, save to ~/.gaim/screenname.blist. Else, let user choose */ |
228 | 2133 |
1 | 2134 void do_export(GtkWidget *w, void *dummy) |
2135 { | |
2136 FILE *f; | |
228 | 2137 gint show_dialog = (int) dummy; |
1 | 2138 char *buf = g_malloc(BUF_LONG); |
228 | 2139 char *file; |
2140 char path[PATHSIZE]; | |
2141 extern char g_screenname[]; | |
1 | 2142 |
228 | 2143 if ( show_dialog == 1 ) { |
2144 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(exportdialog)); | |
2145 strncpy( path, file, PATHSIZE - 1 ); | |
2146 } | |
2147 else { | |
2148 file = getenv( "HOME" ); | |
262
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2149 if ( file != (char *) NULL ) { |
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2150 FILE *dir; |
266
3b5b469d07f7
[gaim-migrate @ 276]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
262
diff
changeset
|
2151 sprintf(buf, "%s/.gaim/", file); |
262
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2152 dir = fopen(buf, "r"); |
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2153 if (!dir) |
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2154 mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR); |
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2155 else |
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2156 fclose(dir); |
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2157 sprintf( path, "%s/.gaim/%s.blist", file, g_screenname ); |
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2158 } else |
228 | 2159 return; |
2160 } | |
2161 if ((f = fopen(path,"w"))) { | |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
236
diff
changeset
|
2162 serv_build_config(buf, 8192 - 1); |
1 | 2163 fprintf(f, "%s\n", buf); |
2164 fclose(f); | |
2165 chmod(buf, S_IRUSR | S_IWUSR); | |
228 | 2166 } else if ( show_dialog == 1 ) { |
1 | 2167 g_snprintf(buf, BUF_LONG / 2, "Error writing file %s", file); |
2168 do_error_dialog(buf, "Error"); | |
2169 } | |
228 | 2170 if ( show_dialog == 1 ) { |
2171 destroy_dialog(NULL, exportdialog); | |
2172 exportdialog = NULL; | |
2173 } | |
1 | 2174 |
2175 g_free(buf); | |
2176 | |
2177 } | |
2178 | |
2179 | |
2180 void show_export_dialog() | |
2181 { | |
2182 char *buf = g_malloc(BUF_LEN); | |
2183 if (!exportdialog) { | |
2184 exportdialog = gtk_file_selection_new("Gaim - Export Buddy List"); | |
2185 | |
2186 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(exportdialog)); | |
2187 | |
2188 g_snprintf(buf, BUF_LEN - 1, "%s/gaim.buddy", getenv("HOME")); | |
2189 | |
2190 gtk_file_selection_set_filename(GTK_FILE_SELECTION(exportdialog), buf); | |
2191 gtk_signal_connect(GTK_OBJECT(exportdialog), "destroy", | |
2192 GTK_SIGNAL_FUNC(destroy_dialog), exportdialog); | |
2193 | |
2194 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(exportdialog)->ok_button), | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2195 "clicked", GTK_SIGNAL_FUNC(do_export), (void*)1); |
1 | 2196 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(exportdialog)->cancel_button), |
2197 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), exportdialog); | |
2198 | |
2199 | |
2200 } | |
2201 | |
2202 g_free(buf); | |
2203 | |
2204 gtk_widget_show(exportdialog); | |
2205 gdk_window_raise(exportdialog->window); | |
2206 | |
2207 } | |
2208 | |
262
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2209 /* if dummy is 0, then import from ~/.gaim/screenname.blist, else let user |
229 | 2210 choose */ |
228 | 2211 |
1 | 2212 void do_import(GtkWidget *w, void *dummy) |
2213 { | |
228 | 2214 gint show_dialog = (int) dummy; |
1 | 2215 GList *grp, *grp2; |
2216 char *buf = g_malloc(BUF_LONG); | |
2217 char *buf2; | |
2218 char *first = g_malloc(64); | |
228 | 2219 char *file; |
2220 char path[PATHSIZE]; | |
1 | 2221 FILE *f; |
228 | 2222 extern char g_screenname[]; |
2223 | |
2224 if ( show_dialog == 1 ) { | |
2225 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(importdialog)); | |
2226 strncpy( path, file, PATHSIZE - 1 ); | |
2227 } | |
2228 else { | |
2229 file = getenv( "HOME" ); | |
2230 if ( file != (char *) NULL ) | |
262
07abf2ed6665
[gaim-migrate @ 272]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
255
diff
changeset
|
2231 sprintf( path, "%s/.gaim/%s.blist", file, g_screenname ); |
228 | 2232 else |
2233 return; | |
2234 } | |
2235 | |
2236 if (!(f = fopen(path,"r"))) { | |
2237 if ( show_dialog == 1 ) { | |
2238 g_snprintf(buf, BUF_LONG / 2, "Error reading file %s", file); | |
2239 do_error_dialog(buf, "Error"); | |
2240 destroy_dialog(NULL, importdialog); | |
2241 importdialog = NULL; | |
2242 } | |
1 | 2243 g_free(buf); |
37 | 2244 g_free(first); |
1 | 2245 return; |
2246 } | |
2247 | |
2248 fgets(first, 64, f); | |
2249 | |
2250 if (!strcasecmp(first, "Config {\n")) { | |
228 | 2251 if ( show_dialog == 1 ) { |
2252 destroy_dialog(NULL, importdialog); | |
2253 importdialog = NULL; | |
2254 } | |
25 | 2255 g_free(buf); |
37 | 2256 g_free(first); |
228 | 2257 fclose( f ); |
1 | 2258 return; |
2259 } else if (buf[0] == 'm') { | |
2260 buf2 = buf; | |
231 | 2261 buf = g_malloc(8193); |
2262 g_snprintf(buf, 8192, "toc_set_config {%s}\n", buf2); | |
1 | 2263 g_free(buf2); |
2264 } | |
2265 | |
2266 | |
2267 fseek(f, 0, SEEK_SET); | |
2268 | |
2269 fread(buf, BUF_LONG, 1, f); | |
2270 | |
2271 grp = groups; | |
2272 | |
2273 while(grp) { | |
2274 grp2 = grp->next; | |
2275 remove_group((struct group *)grp->data); | |
2276 grp = grp2; | |
2277 } | |
2278 | |
296
a88b889b692b
[gaim-migrate @ 306]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
266
diff
changeset
|
2279 parse_toc_buddy_list(buf, 1); |
1 | 2280 |
2281 serv_save_config(); | |
2282 | |
2283 build_edit_tree(); | |
2284 build_permit_tree(); | |
2285 | |
228 | 2286 fclose( f ); |
2287 | |
2288 if ( show_dialog == 1 ) { | |
2289 /* save what we just did to cache */ | |
2290 | |
2291 do_export( (GtkWidget *) NULL, 0 ); | |
2292 destroy_dialog(NULL, importdialog); | |
2293 importdialog = NULL; | |
2294 } | |
1 | 2295 |
2296 g_free(buf); | |
37 | 2297 g_free(first); |
1 | 2298 } |
2299 | |
2300 void show_import_dialog() | |
2301 { | |
2302 char *buf = g_malloc(BUF_LEN); | |
2303 if (!importdialog) { | |
2304 importdialog = gtk_file_selection_new("Gaim - Import Buddy List"); | |
2305 | |
2306 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(importdialog)); | |
2307 | |
2308 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("HOME")); | |
2309 | |
2310 gtk_file_selection_set_filename(GTK_FILE_SELECTION(importdialog), buf); | |
2311 gtk_signal_connect(GTK_OBJECT(importdialog), "destroy", | |
2312 GTK_SIGNAL_FUNC(destroy_dialog), importdialog); | |
2313 | |
2314 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(importdialog)->ok_button), | |
230
83dd297aa363
[gaim-migrate @ 240]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
229
diff
changeset
|
2315 "clicked", GTK_SIGNAL_FUNC(do_import), (void*)1); |
1 | 2316 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(importdialog)->cancel_button), |
2317 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), importdialog); | |
2318 | |
2319 | |
2320 } | |
2321 | |
24 | 2322 g_free(buf); |
1 | 2323 gtk_widget_show(importdialog); |
2324 gdk_window_raise(importdialog->window); | |
2325 } | |
2326 | |
2327 | |
2328 /*------------------------------------------------------------------------*/ | |
2329 /* The dialog for new away messages */ | |
2330 /*------------------------------------------------------------------------*/ | |
2331 | |
2332 void create_mess(GtkWidget *widget, struct create_away *ca) | |
2333 { | |
2334 struct away_message *b; | |
2335 gchar *away_message; | |
2336 guint text_len; | |
2337 int is_checked; | |
2338 | |
2339 /* Grab the appropriate data */ | |
2340 b = g_new0(struct away_message, 1); | |
2341 g_snprintf(b->name, sizeof(b->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); | |
2342 | |
2343 /* Get proper Length */ | |
2344 text_len = gtk_text_get_length(GTK_TEXT(ca->text)); | |
2345 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len); | |
2346 | |
2347 g_snprintf(b->message, sizeof(b->message), "%s", away_message); | |
38 | 2348 g_free(away_message); |
1 | 2349 is_checked = GTK_TOGGLE_BUTTON(ca->checkbx)->active; |
2350 | |
2351 if (is_checked) do_away_message(NULL, b); | |
2352 | |
2353 /* stick it on the away list */ | |
2354 if (strlen(b->name)) { | |
2355 away_messages = g_list_append(away_messages, b); | |
2356 save_prefs(); | |
2357 do_away_menu(); | |
2358 if (pd != NULL) | |
2359 gtk_list_select_item(GTK_LIST(pd->away_list), g_list_index(away_messages, b)); | |
2360 } | |
2361 | |
2362 destroy_dialog(NULL, ca->window); | |
2363 } | |
2364 | |
2365 void create_away_mess(GtkWidget *widget, void *dummy) | |
2366 { | |
2367 GtkWidget *bbox; | |
2368 GtkWidget *titlebox; | |
2369 GtkWidget *tbox; | |
2370 GtkWidget *create; | |
2371 GtkWidget *sw; | |
2372 GtkWidget *label; | |
2373 | |
2374 struct create_away *ca = g_new0(struct create_away, 1); | |
2375 | |
2376 /* Set up window */ | |
2377 ca->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
2378 gtk_container_border_width(GTK_CONTAINER(ca->window), 10); | |
2379 gtk_window_set_title(GTK_WINDOW(ca->window), "Gaim - New away message"); | |
2380 gtk_signal_connect(GTK_OBJECT(ca->window),"delete_event", | |
2381 GTK_SIGNAL_FUNC(destroy_dialog), ca->window); | |
2382 | |
2383 /* set up container boxes */ | |
2384 bbox = gtk_vbox_new(FALSE, 0); | |
2385 titlebox = gtk_hbox_new(FALSE, 0); | |
2386 tbox = gtk_vbox_new(FALSE, 0); | |
2387 | |
2388 /* Make a label for away entry */ | |
2389 label = gtk_label_new("Away title: "); | |
2390 gtk_box_pack_start(GTK_BOX(titlebox), label, TRUE, TRUE, 0); | |
2391 | |
2392 /* make away title entry */ | |
2393 ca->entry = gtk_entry_new(); | |
2394 gtk_box_pack_start(GTK_BOX(titlebox), ca->entry, TRUE, TRUE, 0); | |
2395 | |
2396 sw = gtk_scrolled_window_new(NULL, NULL); | |
2397 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
2398 GTK_POLICY_AUTOMATIC, | |
2399 GTK_POLICY_AUTOMATIC); | |
2400 gtk_widget_show(sw); | |
2401 | |
2402 /* create and format text box */ | |
2403 ca->text = gtk_text_new(NULL, NULL); | |
2404 gtk_text_set_word_wrap(GTK_TEXT(ca->text), TRUE); | |
2405 gtk_text_set_editable(GTK_TEXT(ca->text), TRUE ); | |
2406 gtk_container_add(GTK_CONTAINER(sw), ca->text); | |
2407 gtk_widget_show(ca->text); | |
2408 gtk_box_pack_start(GTK_BOX(bbox), sw, TRUE, TRUE, 10); | |
2409 | |
2410 /* make create button */ | |
2411 create = gtk_button_new_with_label ("Create new message"); | |
255
be4ac6d5c1b4
[gaim-migrate @ 265]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
2412 gtk_box_pack_start(GTK_BOX(bbox), create, FALSE, FALSE, 0); |
1 | 2413 gtk_signal_connect(GTK_OBJECT(create), "clicked", GTK_SIGNAL_FUNC(create_mess), ca); |
2414 | |
2415 /* Checkbox for showing away msg */ | |
2416 ca->checkbx = gtk_check_button_new_with_label("Make away now"); | |
2417 | |
2418 /* pack boxes where they belong */ | |
255
be4ac6d5c1b4
[gaim-migrate @ 265]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
2419 gtk_box_pack_start(GTK_BOX(tbox), titlebox, FALSE, FALSE, 0); |
be4ac6d5c1b4
[gaim-migrate @ 265]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
2420 gtk_box_pack_start(GTK_BOX(tbox), bbox, TRUE, TRUE, 0); |
1 | 2421 gtk_box_pack_start(GTK_BOX(tbox), ca->checkbx, FALSE, FALSE, 0); |
2422 gtk_container_add(GTK_CONTAINER(ca->window), tbox); | |
2423 | |
2424 /* let the world see what we have done. */ | |
2425 gtk_widget_show(label); | |
2426 gtk_widget_show(create); | |
2427 gtk_widget_show(ca->checkbx); | |
2428 gtk_widget_show(ca->entry); | |
2429 gtk_widget_show(titlebox); | |
2430 gtk_widget_show(tbox); | |
2431 gtk_widget_show(bbox); | |
2432 | |
2433 | |
2434 gtk_widget_realize(ca->window); | |
2435 aol_icon(ca->window->window); | |
2436 | |
2437 gtk_widget_show(ca->window); | |
2438 | |
2439 | |
2440 } |