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