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