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