[gaim-migrate @ 3006]
[pidgin-git.git] / src / dialogs.c
blob470d4155db6f0b8313582565c99baf443b04ede6
1 /*
2 * gaim
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.
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.
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
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25 #include <string.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <time.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <fcntl.h>
32 #include <ctype.h>
33 #include <sys/socket.h>
34 #include <netdb.h>
35 #include <netinet/in.h>
36 #include <unistd.h>
37 #include <netinet/in.h>
38 #include <arpa/inet.h>
39 #include <errno.h>
41 #include <gtk/gtk.h>
42 #include "gaim.h"
43 #include "gtkimhtml.h"
44 #include "prpl.h"
45 #ifdef USE_APPLET
46 #include "applet.h"
47 #endif
49 #include "pixmaps/gnome_preferences.xpm"
50 #include "pixmaps/cancel.xpm"
51 #include "pixmaps/save.xpm"
52 #include "pixmaps/ok.xpm"
53 #include "pixmaps/add.xpm"
54 #include "pixmaps/warn.xpm"
55 #include "pixmaps/close.xpm"
57 #include "pixmaps/angel.xpm"
58 #include "pixmaps/bigsmile.xpm"
59 #include "pixmaps/burp.xpm"
60 #include "pixmaps/crossedlips.xpm"
61 #include "pixmaps/cry.xpm"
62 #include "pixmaps/embarrassed.xpm"
63 #include "pixmaps/kiss.xpm"
64 #include "pixmaps/moneymouth.xpm"
65 #include "pixmaps/sad.xpm"
66 #include "pixmaps/scream.xpm"
67 #include "pixmaps/smile.xpm"
68 #include "pixmaps/smile8.xpm"
69 #include "pixmaps/think.xpm"
70 #include "pixmaps/tongue.xpm"
71 #include "pixmaps/wink.xpm"
72 #include "pixmaps/yell.xpm"
74 #include "pixmaps/aimicon.xpm"
76 #include "pixmaps/aol_icon.xpm"
77 #include "pixmaps/free_icon.xpm"
78 #include "pixmaps/dt_icon.xpm"
79 #include "pixmaps/admin_icon.xpm"
80 #include "pixmaps/ab.xpm"
82 #define PATHSIZE 1024
84 int smiley_array[FACE_TOTAL];
85 GdkColor bgcolor;
86 GdkColor fgcolor;
88 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */
89 static GtkWidget *infodialog = NULL;
90 static GList *dialogwindows = NULL;
91 static GtkWidget *importdialog;
92 static struct gaim_connection *importgc;
93 static GtkWidget *icondlg;
94 static GtkWidget *aliasdlg = NULL;
95 static GtkWidget *aliasentry = NULL;
96 static GtkWidget *aliasname = NULL;
97 static GtkWidget *rename_dialog = NULL;
98 static GtkWidget *rename_bud_dialog = NULL;
100 struct confirm_del {
101 GtkWidget *window;
102 GtkWidget *label;
103 GtkWidget *ok;
104 GtkWidget *cancel;
105 char name[1024];
106 struct gaim_connection *gc;
109 struct create_away {
110 GtkWidget *window;
111 GtkWidget *entry;
112 GtkWidget *text;
113 struct away_message *mess;
116 struct warning {
117 GtkWidget *window;
118 GtkWidget *anon;
119 char *who;
120 struct gaim_connection *gc;
123 struct addbuddy {
124 GtkWidget *window;
125 GtkWidget *combo;
126 GtkWidget *entry;
127 GtkWidget *entry_for_alias;
128 GtkWidget *account;
129 struct gaim_connection *gc;
132 struct addperm {
133 GtkWidget *window;
134 GtkWidget *entry;
135 struct gaim_connection *gc;
136 gboolean permit;
139 struct addbp {
140 GtkWidget *window;
141 GtkWidget *nameentry;
142 GtkWidget *messentry;
143 GtkWidget *commentry;
144 GtkWidget *command;
145 GtkWidget *sendim;
146 GtkWidget *openwindow;
147 GtkWidget *popupnotify;
148 GtkWidget *p_signon;
149 GtkWidget *p_unaway;
150 GtkWidget *p_unidle;
151 GtkWidget *p_typing;
152 GtkWidget *save;
153 GtkWidget *menu;
154 GtkWidget *sound;
155 GtkWidget *soundentry;
157 struct aim_user *user;
158 struct buddy_pounce *buddy_pounce;
161 struct findbyemail {
162 GtkWidget *window;
163 GtkWidget *emailentry;
164 struct gaim_connection *gc;
167 struct findbyinfo {
168 struct gaim_connection *gc;
169 GtkWidget *window;
170 GtkWidget *firstentry;
171 GtkWidget *middleentry;
172 GtkWidget *lastentry;
173 GtkWidget *maidenentry;
174 GtkWidget *cityentry;
175 GtkWidget *stateentry;
176 GtkWidget *countryentry;
179 struct info_dlg {
180 struct gaim_connection *gc;
181 char *who;
182 GtkWidget *window;
183 GtkWidget *text;
185 static GSList *info_dlgs = NULL;
187 static struct info_dlg *find_info_dlg(struct gaim_connection *gc, char *who)
189 GSList *i = info_dlgs;
190 while (i) {
191 struct info_dlg *d = i->data;
192 i = i->next;
193 if (d->gc != gc)
194 continue;
195 if (d->who == NULL)
196 continue;
197 if (!who)
198 continue;
199 if (!g_strcasecmp(normalize(who), d->who))
200 return d;
202 return NULL;
205 struct set_info_dlg {
206 GtkWidget *window;
207 GtkWidget *menu;
208 struct aim_user *user;
209 GtkWidget *text;
210 GtkWidget *save;
211 GtkWidget *cancel;
214 struct set_icon_dlg {
215 GtkWidget *window;
216 struct aim_user *user;
217 GtkWidget *ok;
218 GtkWidget *cancel;
219 GtkWidget *entry;
222 struct set_dir_dlg {
223 struct gaim_connection *gc;
224 GtkWidget *window;
225 GtkWidget *first;
226 GtkWidget *middle;
227 GtkWidget *last;
228 GtkWidget *maiden;
229 GtkWidget *city;
230 GtkWidget *state;
231 GtkWidget *country;
232 GtkWidget *web;
233 GtkWidget *cancel;
234 GtkWidget *save;
237 struct linkdlg {
238 GtkWidget *ok;
239 GtkWidget *cancel;
240 GtkWidget *window;
241 GtkWidget *url;
242 GtkWidget *text;
243 GtkWidget *toggle;
244 GtkWidget *entry;
247 struct passwddlg {
248 GtkWidget *window;
249 GtkWidget *ok;
250 GtkWidget *cancel;
251 GtkWidget *original;
252 GtkWidget *new1;
253 GtkWidget *new2;
254 struct gaim_connection *gc;
257 struct view_log {
258 long offset;
259 int options;
260 char *name;
261 GtkWidget *bbox;
262 GtkWidget *window;
263 GtkWidget *layout;
266 /*------------------------------------------------------------------------*/
267 /* Destroys */
268 /*------------------------------------------------------------------------*/
270 static gint delete_event_dialog(GtkWidget *w, GdkEventAny *e, struct conversation *c)
272 gchar *object_data;
273 object_data = gtk_object_get_user_data(GTK_OBJECT(w));
275 if (GTK_IS_COLOR_SELECTION_DIALOG(w)) {
276 set_state_lock(1);
277 if (w == c->fg_color_dialog) {
278 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->fgcolorbtn), FALSE);
279 c->fg_color_dialog = NULL;
280 } else {
281 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->bgcolorbtn), FALSE);
282 c->bg_color_dialog = NULL;
284 set_state_lock(0);
285 } else if (GTK_IS_FONT_SELECTION_DIALOG(w)) {
286 set_state_lock(1);
287 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->font), FALSE);
288 set_state_lock(0);
289 c->font_dialog = NULL;
290 } else if (!g_strcasecmp(object_data, "smiley dialog")) {
291 set_state_lock(1);
292 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->smiley), FALSE);
293 set_state_lock(0);
294 c->smiley_dialog = NULL;
295 } else if (!g_strcasecmp(object_data, "log dialog")) {
296 set_state_lock(1);
297 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->wood), FALSE);
298 set_state_lock(0);
299 c->log_dialog = NULL;
302 dialogwindows = g_list_remove(dialogwindows, w);
303 gtk_widget_destroy(w);
305 return FALSE;
308 static void destroy_dialog(GtkWidget *w, GtkWidget *w2)
310 GtkWidget *dest;
312 if (!GTK_IS_WIDGET(w2))
313 dest = w;
314 else
315 dest = w2;
317 if (dest == imdialog)
318 imdialog = NULL;
320 if (dest == infodialog)
321 infodialog = NULL;
323 if (dest == importdialog) {
324 importdialog = NULL;
325 importgc = NULL;
328 if (dest == icondlg)
329 icondlg = NULL;
331 if (dest == aliasdlg) {
332 aliasdlg = NULL;
333 aliasentry = NULL;
334 aliasname = NULL;
337 if (dest == rename_dialog)
338 rename_dialog = NULL;
340 if (dest == rename_bud_dialog)
341 rename_bud_dialog = NULL;
343 dialogwindows = g_list_remove(dialogwindows, dest);
344 gtk_widget_destroy(dest);
349 void destroy_all_dialogs()
351 while (dialogwindows)
352 destroy_dialog(NULL, dialogwindows->data);
354 if (awaymessage)
355 do_im_back(NULL, NULL);
357 if (imdialog) {
358 destroy_dialog(NULL, imdialog);
359 imdialog = NULL;
362 if (infodialog) {
363 destroy_dialog(NULL, infodialog);
364 infodialog = NULL;
367 if (importdialog) {
368 destroy_dialog(NULL, importdialog);
369 importdialog = NULL;
372 if (icondlg) {
373 destroy_dialog(NULL, icondlg);
374 icondlg = NULL;
378 static void do_warn(GtkWidget *widget, struct warning *w)
380 serv_warn(w->gc, w->who, (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))) ? 1 : 0);
382 destroy_dialog(NULL, w->window);
385 static void free_warn_data(GtkObject *obj, struct warning *w)
387 g_free(w);
390 void show_warn_dialog(struct gaim_connection *gc, char *who)
392 GtkWidget *cancel;
393 GtkWidget *warn;
394 GtkWidget *label;
395 GtkWidget *vbox;
396 GtkWidget *bbox;
397 GtkWidget *frame;
398 GtkWidget *fbox;
399 char buf[128];
401 struct warning *w = g_new0(struct warning, 1);
402 w->who = who;
403 w->gc = gc;
405 GAIM_DIALOG(w->window);
406 dialogwindows = g_list_prepend(dialogwindows, w->window);
407 gtk_window_set_wmclass(GTK_WINDOW(w->window), "warning", "Gaim");
408 gtk_window_set_policy(GTK_WINDOW(w->window), FALSE, FALSE, TRUE);
409 gtk_window_set_title(GTK_WINDOW(w->window), _("Gaim - Warn user?"));
410 gtk_container_set_border_width(GTK_CONTAINER(w->window), 5);
411 gtk_signal_connect(GTK_OBJECT(w->window), "delete_event",
412 GTK_SIGNAL_FUNC(destroy_dialog), w->window);
413 gtk_signal_connect(GTK_OBJECT(w->window), "delete_event", GTK_SIGNAL_FUNC(free_warn_data), w);
414 gtk_widget_realize(w->window);
415 aol_icon(w->window->window);
417 fbox = gtk_vbox_new(FALSE, 5);
418 gtk_container_add(GTK_CONTAINER(w->window), fbox);
419 gtk_widget_show(fbox);
421 frame = gtk_frame_new(_("Warn"));
422 gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 5);
423 gtk_widget_show(frame);
425 vbox = gtk_vbox_new(FALSE, 5);
426 gtk_container_add(GTK_CONTAINER(frame), vbox);
427 gtk_widget_show(vbox);
429 g_snprintf(buf, 127, _("Do you really want to warn %s?"), who);
430 label = gtk_label_new(buf);
431 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
432 gtk_widget_show(label);
434 w->anon = gtk_check_button_new_with_label(_("Warn anonymously?"));
435 gtk_box_pack_start(GTK_BOX(vbox), w->anon, TRUE, TRUE, 5);
436 gtk_widget_show(w->anon);
438 label = gtk_label_new(_("Anonymous warnings are less harsh."));
439 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
440 gtk_widget_show(label);
442 bbox = gtk_hbox_new(TRUE, 10);
443 gtk_box_pack_start(GTK_BOX(fbox), bbox, FALSE, FALSE, 5);
444 gtk_widget_show(bbox);
446 cancel = picture_button(w->window, _("Cancel"), cancel_xpm);
447 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
448 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), w->window);
450 warn = picture_button(w->window, _("Warn"), warn_xpm);
451 gtk_box_pack_end(GTK_BOX(bbox), warn, FALSE, FALSE, 5);
452 gtk_signal_connect(GTK_OBJECT(warn), "clicked", GTK_SIGNAL_FUNC(do_warn), w);
454 gtk_widget_show(w->window);
457 void do_remove_buddy(GtkWidget *w, struct buddy *b)
459 struct group *g = find_group_by_buddy(b->gc, b->name);
460 struct gaim_connection *gc = b->gc;
461 struct conversation *cv;
463 if (!b)
464 return;
466 debug_printf(_("Removing '%s' from buddylist.\n"), b->name);
467 serv_remove_buddy(b->gc, b->name, g->name);
468 remove_buddy(gc, g, b);
469 do_export(gc);
470 build_edit_tree();
472 cv = find_conversation(b->name);
474 if (cv)
475 update_convo_add_button(cv);
479 void show_confirm_del(struct gaim_connection *gc, gchar *name)
481 struct confirm_del *b = g_new0(struct confirm_del, 1);
482 struct buddy *bd;
483 GtkWidget *hbox;
484 GtkWidget *vbox;
485 GtkWidget *fbox;
486 GtkWidget *frame;
487 gchar tmp[2048];
489 GAIM_DIALOG(b->window);
490 dialogwindows = g_list_prepend(dialogwindows, b->window);
492 g_snprintf(tmp, sizeof(tmp), _("Gaim - Remove %s?"), name);
493 gtk_window_set_title(GTK_WINDOW(b->window), tmp);
494 gtk_window_set_wmclass(GTK_WINDOW(b->window), "confirm_del", "Gaim");
495 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, FALSE, TRUE);
496 gtk_signal_connect(GTK_OBJECT(b->window), "delete_event",
497 GTK_SIGNAL_FUNC(destroy_dialog), b->window);
499 gtk_widget_realize(b->window);
501 vbox = gtk_vbox_new(FALSE, 0);
502 gtk_container_add(GTK_CONTAINER(b->window), vbox);
503 gtk_widget_show(vbox);
505 frame = gtk_frame_new(_("Remove Buddy"));
506 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
507 gtk_container_set_border_width(GTK_CONTAINER(frame), 5);
508 gtk_widget_show(frame);
510 fbox = gtk_vbox_new(FALSE, 5);
511 gtk_container_add(GTK_CONTAINER(frame), fbox);
512 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
513 gtk_widget_show(fbox);
515 g_snprintf(tmp, sizeof(tmp), _("You are about to remove '%s' from\nyour buddylist. Do you want to continue?"), name);
516 b->label = gtk_label_new(tmp);
517 gtk_misc_set_alignment(GTK_MISC(b->label), 0, 0.5);
518 gtk_label_set_justify(GTK_LABEL(b->label), GTK_JUSTIFY_LEFT);
519 gtk_box_pack_start(GTK_BOX(fbox), b->label, FALSE, FALSE, 0);
520 gtk_widget_show(b->label);
522 hbox = gtk_hbox_new(FALSE, 5);
523 gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
524 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, FALSE, 0);
525 gtk_widget_show(hbox);
527 b->ok = picture_button(b->window, _("Accept"), ok_xpm);
528 gtk_box_pack_start(GTK_BOX(hbox), b->ok, FALSE, FALSE, 5);
530 bd = find_buddy(gc, name);
532 if (bd)
533 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(do_remove_buddy), bd);
535 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
537 b->cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
538 gtk_box_pack_start(GTK_BOX(hbox), b->cancel, FALSE, FALSE, 5);
539 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
541 gtk_widget_show(b->window);
546 /*------------------------------------------------------------------------*/
547 /* The dialog for getting an error */
548 /*------------------------------------------------------------------------*/
550 GtkWidget *do_error_dialog(char *message, char *title)
552 GtkWidget *d;
553 GtkWidget *label;
554 GtkWidget *close;
557 d = gtk_dialog_new();
558 gtk_window_set_policy(GTK_WINDOW(d), FALSE, FALSE, TRUE);
559 gtk_widget_realize(d);
560 label = gtk_label_new(message);
561 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
562 gtk_widget_show(label);
563 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), label, FALSE, FALSE, 5);
565 close = picture_button(d, _("Close"), cancel_xpm);
567 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), close, FALSE, FALSE, 5);
569 gtk_container_set_border_width(GTK_CONTAINER(d), 5);
570 gtk_window_set_title(GTK_WINDOW(d), title);
571 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), d);
572 aol_icon(d->window);
574 gtk_widget_show(d);
575 gtk_widget_grab_focus(close);
576 return d;
581 static void do_im(GtkWidget *widget, GtkWidget *imentry)
583 char *who;
584 struct conversation *c;
586 who = g_strdup(gtk_entry_get_text(GTK_ENTRY(imentry)));
587 destroy_dialog(NULL, imdialog);
588 imdialog = NULL;
590 if (!g_strcasecmp(who, "")) {
591 g_free(who);
592 return;
595 c = find_conversation(who);
597 if (c == NULL) {
598 c = new_conversation(who);
599 } else {
600 gdk_window_raise(c->window->window);
602 g_free(who);
605 static void do_info(GtkWidget *widget, GtkWidget *infoentry)
607 char *who;
609 who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(infoentry))));
610 destroy_dialog(NULL, infodialog);
611 infodialog = NULL;
613 if (!g_strcasecmp(who, "")) {
614 g_free(who);
615 return;
618 /* what do we want to do about this case? */
619 if (connections)
620 serv_get_info(connections->data, who);
622 g_free(who);
625 void show_ee_dialog(int ee)
627 GtkWidget *ok;
628 GtkWidget *label;
629 GtkWidget *box;
630 GtkWidget *eedialog;
632 GAIM_DIALOG(eedialog);
633 gtk_widget_realize(eedialog);
634 ok = picture_button(eedialog, _("OK"), ok_xpm);
635 box = gtk_vbox_new(FALSE, 10);
637 if (ee == 0)
638 label = gtk_label_new("Amazing! Simply Amazing!");
639 else if (ee == 1)
640 label = gtk_label_new("Pimpin\' Penguin Style! *Waddle Waddle*");
641 else if (ee == 2)
642 label = gtk_label_new("You should be me. I'm so cute!");
643 else if (ee == 3)
644 label = gtk_label_new("Now that's what I like!");
645 else if (ee == 4)
646 label = gtk_label_new("Ahh, and excellent choice!");
647 else
648 label = gtk_label_new("Everytime you click my name, an angel gets its wings.");
649 gtk_widget_show(label);
650 gtk_widget_show(ok);
652 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 10);
653 gtk_box_pack_start(GTK_BOX(box), ok, FALSE, FALSE, 10);
655 gtk_widget_show(box);
657 gtk_container_add(GTK_CONTAINER(eedialog), box);
658 gtk_window_set_title(GTK_WINDOW(eedialog), "Gaim - SUPRISE!");
660 gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), eedialog);
661 gtk_widget_realize(eedialog);
662 aol_icon(eedialog->window);
664 gtk_widget_show(eedialog);
667 void show_im_dialog()
669 GtkWidget *mainbox;
670 GtkWidget *frame;
671 GtkWidget *fbox;
672 GtkWidget *bbox;
673 GtkWidget *button;
674 GtkWidget *imentry;
675 GtkWidget *label;
677 if (!imdialog) {
678 GAIM_DIALOG(imdialog);
679 gtk_window_set_wmclass(GTK_WINDOW(imdialog), "imdialog", "Gaim");
680 gtk_window_set_policy(GTK_WINDOW(imdialog), FALSE, TRUE, TRUE);
681 gtk_window_set_title(GTK_WINDOW(imdialog), _("Gaim - IM user"));
682 gtk_signal_connect(GTK_OBJECT(imdialog), "destroy",
683 GTK_SIGNAL_FUNC(destroy_dialog), imdialog);
684 gtk_widget_realize(imdialog);
685 aol_icon(imdialog->window);
687 mainbox = gtk_vbox_new(FALSE, 5);
688 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
689 gtk_container_add(GTK_CONTAINER(imdialog), mainbox);
691 frame = gtk_frame_new(_("Send Instant Message"));
692 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
694 fbox = gtk_hbox_new(FALSE, 5);
695 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
696 gtk_container_add(GTK_CONTAINER(frame), fbox);
698 label = gtk_label_new(_("IM who:"));
699 gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0);
701 imentry = gtk_entry_new();
702 gtk_box_pack_start(GTK_BOX(fbox), imentry, TRUE, TRUE, 0);
703 gtk_signal_connect(GTK_OBJECT(imentry), "activate", GTK_SIGNAL_FUNC(do_im), imentry);
704 gtk_widget_grab_focus(imentry);
706 bbox = gtk_hbox_new(FALSE, 5);
707 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
709 button = picture_button(imdialog, _("Cancel"), cancel_xpm);
710 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
711 gtk_signal_connect(GTK_OBJECT(button), "clicked",
712 GTK_SIGNAL_FUNC(destroy_dialog), imdialog);
714 button = picture_button(imdialog, _("OK"), ok_xpm);
715 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
716 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_im), imentry);
719 gtk_widget_show_all(imdialog);
722 void show_info_dialog()
724 GtkWidget *mainbox;
725 GtkWidget *frame;
726 GtkWidget *fbox;
727 GtkWidget *bbox;
728 GtkWidget *button;
729 GtkWidget *infoentry;
730 GtkWidget *label;
732 if (!infodialog) {
734 GAIM_DIALOG(infodialog);
735 gtk_window_set_wmclass(GTK_WINDOW(infodialog), "infodialog", "Gaim");
736 gtk_window_set_policy(GTK_WINDOW(infodialog), FALSE, TRUE, TRUE);
737 gtk_widget_realize(infodialog);
739 mainbox = gtk_vbox_new(FALSE, 5);
740 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
741 gtk_container_add(GTK_CONTAINER(infodialog), mainbox);
743 frame = gtk_frame_new(_("Get User Info"));
744 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
746 fbox = gtk_hbox_new(FALSE, 5);
747 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
748 gtk_container_add(GTK_CONTAINER(frame), fbox);
750 label = gtk_label_new(_("User:"));
751 gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0);
752 gtk_widget_show(label);
754 infoentry = gtk_entry_new();
755 gtk_box_pack_start(GTK_BOX(fbox), infoentry, TRUE, TRUE, 0);
757 /* Handle closes right */
758 gtk_signal_connect(GTK_OBJECT(infoentry), "activate",
759 GTK_SIGNAL_FUNC(do_info), infoentry);
760 gtk_signal_connect(GTK_OBJECT(infodialog), "destroy",
761 GTK_SIGNAL_FUNC(destroy_dialog), infodialog);
763 /* Buttons */
764 bbox = gtk_hbox_new(FALSE, 5);
765 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
767 button = picture_button(infodialog, _("Cancel"), cancel_xpm);
768 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
769 gtk_signal_connect(GTK_OBJECT(button), "clicked",
770 GTK_SIGNAL_FUNC(destroy_dialog), infodialog);
772 button = picture_button(infodialog, _("OK"), ok_xpm);
773 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
774 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_info), infoentry);
776 /* Finish up */
777 gtk_window_set_title(GTK_WINDOW(infodialog), _("Gaim - Get User Info"));
778 gtk_widget_grab_focus(infoentry);
780 aol_icon(infodialog->window);
782 gtk_widget_show_all(infodialog);
786 /*------------------------------------------------------------------------*/
787 /* The dialog for adding buddies */
788 /*------------------------------------------------------------------------*/
790 extern void add_callback(GtkWidget *, struct conversation *);
792 void do_add_buddy(GtkWidget *w, struct addbuddy *a)
794 char *grp, *who, *whoalias;
795 struct conversation *c;
797 who = gtk_entry_get_text(GTK_ENTRY(a->entry));
798 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(a->combo)->entry));
799 whoalias = gtk_entry_get_text(GTK_ENTRY(a->entry_for_alias));
801 c = find_conversation(who);
803 add_buddy(a->gc, grp, who, whoalias);
804 serv_add_buddy(a->gc, who);
806 if (c != NULL) {
807 update_buttons_by_protocol(c);
810 do_export(a->gc);
812 destroy_dialog(NULL, a->window);
815 void do_add_group(GtkWidget *w, struct addbuddy *a)
817 char *grp;
819 grp = gtk_entry_get_text(GTK_ENTRY(a->entry));
821 if (!a->gc)
822 a->gc = connections->data;
824 add_group(a->gc, grp);
825 do_export(a->gc);
827 destroy_dialog(NULL, a->window);
831 static GList *groups_tree(struct gaim_connection *gc)
833 GList *tmp = NULL;
834 char *tmp2;
835 struct group *g;
836 GSList *grp = gc->groups;
838 if (!grp) {
839 tmp2 = g_strdup(_("Buddies"));
840 tmp = g_list_append(tmp, tmp2);
841 } else {
842 while (grp) {
843 g = (struct group *)grp->data;
844 tmp2 = g->name;
845 tmp = g_list_append(tmp, tmp2);
846 grp = g_slist_next(grp);
849 return tmp;
852 static void free_dialog(GtkWidget *w, struct addbuddy *a)
854 g_free(a);
858 void show_add_group(struct gaim_connection *gc)
860 GtkWidget *cancel;
861 GtkWidget *add;
862 GtkWidget *label;
863 GtkWidget *bbox;
864 GtkWidget *vbox;
865 GtkWidget *topbox;
866 GtkWidget *frame;
868 struct addbuddy *a = g_new0(struct addbuddy, 1);
869 a->gc = gc;
871 GAIM_DIALOG(a->window);
872 gtk_window_set_wmclass(GTK_WINDOW(a->window), "add_group", "Gaim");
873 gtk_window_set_policy(GTK_WINDOW(a->window), FALSE, FALSE, TRUE);
874 gtk_widget_realize(a->window);
875 dialogwindows = g_list_prepend(dialogwindows, a->window);
877 bbox = gtk_hbox_new(TRUE, 10);
878 topbox = gtk_hbox_new(FALSE, 5);
879 vbox = gtk_vbox_new(FALSE, 5);
881 a->entry = gtk_entry_new();
882 /* Put the buttons in the box */
884 add = picture_button(a->window, _("Add"), add_xpm);
886 cancel = picture_button(a->window, _("Cancel"), cancel_xpm);
888 gtk_box_pack_start(GTK_BOX(bbox), add, FALSE, FALSE, 5);
889 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
891 frame = gtk_frame_new(NULL);
892 gtk_frame_set_label(GTK_FRAME(frame), _("Add Group"));
894 label = gtk_label_new(_("Group"));
895 gtk_widget_show(label);
896 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
897 gtk_box_pack_start(GTK_BOX(topbox), a->entry, FALSE, FALSE, 5);
899 /* And the boxes in the box */
900 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5);
901 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5);
903 /* Handle closes right */
904 gtk_signal_connect(GTK_OBJECT(a->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), a->window);
905 gtk_signal_connect(GTK_OBJECT(a->window), "destroy", GTK_SIGNAL_FUNC(free_dialog), a);
906 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), a->window);
907 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(do_add_group), a);
908 gtk_signal_connect(GTK_OBJECT(a->entry), "activate", GTK_SIGNAL_FUNC(do_add_group), a);
909 /* Finish up */
910 gtk_widget_show(add);
911 gtk_widget_show(cancel);
912 gtk_widget_show(a->entry);
913 gtk_widget_show(topbox);
914 gtk_widget_show(bbox);
915 gtk_widget_show(vbox);
916 gtk_widget_show(frame);
917 gtk_window_set_title(GTK_WINDOW(a->window), _("Gaim - Add Group"));
918 gtk_window_set_focus(GTK_WINDOW(a->window), a->entry);
919 gtk_container_add(GTK_CONTAINER(frame), vbox);
920 gtk_container_add(GTK_CONTAINER(a->window), frame);
921 gtk_container_set_border_width(GTK_CONTAINER(a->window), 5);
922 gtk_widget_realize(a->window);
923 aol_icon(a->window->window);
925 gtk_widget_show(a->window);
928 static void addbuddy_select_account(GtkObject *w, struct gaim_connection *gc)
930 struct addbuddy *b = gtk_object_get_user_data(w);
932 /* Save our account */
933 b->gc = gc;
935 /* We also want to update our group list */
936 gtk_combo_set_popdown_strings(GTK_COMBO(b->combo), groups_tree(gc));
939 static void create_online_user_names(struct addbuddy *b)
941 char buf[2048]; /* Never hurts to be safe ;-) */
942 GSList *g = connections;
943 struct gaim_connection *c;
944 GtkWidget *menu, *opt;
945 int count = 0;
946 int place = 0;
948 menu = gtk_menu_new();
950 while (g) {
951 c = (struct gaim_connection *)g->data;
952 g_snprintf(buf, sizeof(buf), "%s (%s)",
953 c->username, c->prpl->name());
954 opt = gtk_menu_item_new_with_label(buf);
955 gtk_object_set_user_data(GTK_OBJECT(opt), b);
956 gtk_signal_connect(GTK_OBJECT(opt), "activate",
957 GTK_SIGNAL_FUNC(addbuddy_select_account),
959 gtk_widget_show(opt);
960 gtk_menu_append(GTK_MENU(menu), opt);
962 /* Now check to see if it's our current menu */
963 if (c == b->gc) {
964 place = count;
965 gtk_menu_item_activate(GTK_MENU_ITEM(opt));
966 gtk_option_menu_set_history(GTK_OPTION_MENU(b->account), count);
968 /* Do the cha cha cha */
971 count++;
973 g = g->next;
976 gtk_option_menu_remove_menu(GTK_OPTION_MENU(b->account));
977 gtk_option_menu_set_menu(GTK_OPTION_MENU(b->account), menu);
978 gtk_option_menu_set_history(GTK_OPTION_MENU(b->account), place);
980 gtk_widget_show(b->account);
981 gtk_widget_show(b->account->parent);
985 void show_add_buddy(struct gaim_connection *gc, char *buddy, char *group, char *alias)
987 GtkWidget *mainbox;
988 GtkWidget *frame;
989 GtkWidget *table;
990 GtkWidget *bbox;
991 GtkWidget *cancel;
992 GtkWidget *add;
993 GtkWidget *label;
995 struct addbuddy *a = g_new0(struct addbuddy, 1);
996 a->gc = gc ? gc : connections->data;
998 GAIM_DIALOG(a->window);
999 gtk_window_set_wmclass(GTK_WINDOW(a->window), "add_buddy", "Gaim");
1000 gtk_window_set_policy(GTK_WINDOW(a->window), FALSE, FALSE, TRUE);
1001 gtk_window_set_title(GTK_WINDOW(a->window), _("Gaim - Add Buddy"));
1003 gtk_widget_realize(a->window);
1004 aol_icon(a->window->window);
1005 gtk_signal_connect(GTK_OBJECT(a->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), a->window);
1006 gtk_signal_connect(GTK_OBJECT(a->window), "destroy", GTK_SIGNAL_FUNC(free_dialog), a);
1007 dialogwindows = g_list_prepend(dialogwindows, a->window);
1009 mainbox = gtk_vbox_new(FALSE, 5);
1010 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
1011 gtk_container_add(GTK_CONTAINER(a->window), mainbox);
1013 frame = gtk_frame_new(_("Add Buddy"));
1014 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
1015 gtk_widget_show(frame);
1017 table = gtk_table_new(4, 2, FALSE);
1018 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
1019 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1020 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
1021 gtk_container_add(GTK_CONTAINER(frame), table);
1023 label = gtk_label_new(_("Contact"));
1024 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
1026 a->entry = gtk_entry_new();
1027 gtk_table_attach_defaults(GTK_TABLE(table), a->entry, 1, 2, 0, 1);
1028 gtk_window_set_focus(GTK_WINDOW(a->window), a->entry);
1029 if (buddy != NULL)
1030 gtk_entry_set_text(GTK_ENTRY(a->entry), buddy);
1031 gtk_signal_connect(GTK_OBJECT(a->entry), "activate", GTK_SIGNAL_FUNC(do_add_buddy), a);
1033 label = gtk_label_new(_("Alias"));
1034 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
1036 a->entry_for_alias = gtk_entry_new();
1037 gtk_table_attach_defaults(GTK_TABLE(table), a->entry_for_alias, 1, 2, 1, 2);
1038 if (alias != NULL)
1039 gtk_entry_set_text(GTK_ENTRY(a->entry_for_alias), alias);
1041 label = gtk_label_new(_("Group"));
1042 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
1044 a->combo = gtk_combo_new();
1045 gtk_combo_set_popdown_strings(GTK_COMBO(a->combo), groups_tree(a->gc));
1046 if (group != NULL)
1047 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(a->combo)->entry), group);
1048 gtk_table_attach_defaults(GTK_TABLE(table), a->combo, 1, 2, 2, 3);
1050 /* Set up stuff for the account box */
1051 label = gtk_label_new(_("Add To"));
1052 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
1054 a->account = gtk_option_menu_new();
1055 gtk_table_attach_defaults(GTK_TABLE(table), a->account, 1, 2, 3, 4);
1057 create_online_user_names(a);
1059 /* End of account box */
1061 bbox = gtk_hbox_new(FALSE, 5);
1062 gtk_box_pack_start(GTK_BOX(mainbox), bbox, TRUE, TRUE, 0);
1064 cancel = picture_button(a->window, _("Cancel"), cancel_xpm);
1065 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 0);
1066 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), a->window);
1068 add = picture_button(a->window, _("Add"), add_xpm);
1069 gtk_box_pack_end(GTK_BOX(bbox), add, FALSE, FALSE, 0);
1070 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(do_add_buddy), a);
1072 gtk_widget_show_all(a->window);
1076 /*------------------------------------------------------------------------*/
1077 /* The dialog for new buddy pounces */
1078 /*------------------------------------------------------------------------*/
1081 void do_new_bp(GtkWidget *w, struct addbp *b)
1083 struct buddy_pounce *bp;
1085 if (strlen(gtk_entry_get_text(GTK_ENTRY(b->nameentry))) == 0) {
1086 do_error_dialog(_("Please enter a buddy to pounce."), _("Buddy Pounce Error"));
1087 return;
1090 if(!b->buddy_pounce)
1091 bp = g_new0(struct buddy_pounce, 1);
1092 else
1093 bp = b->buddy_pounce;
1096 g_snprintf(bp->name, 80, "%s", gtk_entry_get_text(GTK_ENTRY(b->nameentry)));
1097 g_snprintf(bp->message, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->messentry)));
1098 g_snprintf(bp->command, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->commentry)));
1099 g_snprintf(bp->sound, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->soundentry)));
1100 g_snprintf(bp->pouncer, 80, "%s", b->user->username);
1102 bp->protocol = b->user->protocol;
1104 bp->options = 0;
1106 if (GTK_TOGGLE_BUTTON(b->popupnotify)->active)
1107 bp->options |= OPT_POUNCE_NOTIFY;
1109 if (GTK_TOGGLE_BUTTON(b->openwindow)->active)
1110 bp->options |= OPT_POUNCE_POPUP;
1112 if (GTK_TOGGLE_BUTTON(b->sendim)->active)
1113 bp->options |= OPT_POUNCE_SEND_IM;
1115 if (GTK_TOGGLE_BUTTON(b->command)->active)
1116 bp->options |= OPT_POUNCE_COMMAND;
1118 if (GTK_TOGGLE_BUTTON(b->sound)->active)
1119 bp->options |= OPT_POUNCE_SOUND;
1121 if (GTK_TOGGLE_BUTTON(b->p_signon)->active)
1122 bp->options |= OPT_POUNCE_SIGNON;
1124 if (GTK_TOGGLE_BUTTON(b->p_unaway)->active)
1125 bp->options |= OPT_POUNCE_UNAWAY;
1127 if (GTK_TOGGLE_BUTTON(b->p_unidle)->active)
1128 bp->options |= OPT_POUNCE_UNIDLE;
1130 if (GTK_TOGGLE_BUTTON(b->p_typing)->active)
1131 bp->options |= OPT_POUNCE_TYPING;
1133 if (GTK_TOGGLE_BUTTON(b->save)->active)
1134 bp->options |= OPT_POUNCE_SAVE;
1136 if(!b->buddy_pounce)
1137 buddy_pounces = g_list_append(buddy_pounces, bp);
1139 do_bp_menu();
1141 destroy_dialog(NULL, b->window);
1143 save_prefs();
1144 g_free(b);
1147 static void pounce_choose(GtkWidget *opt, struct addbp *b)
1149 struct aim_user *u = gtk_object_get_user_data(GTK_OBJECT(opt));
1150 b->user = u;
1153 static GtkWidget *pounce_user_menu(struct addbp *b, struct gaim_connection *gc)
1155 GtkWidget *optmenu;
1156 GtkWidget *menu;
1157 GtkWidget *opt;
1158 GSList *u = aim_users;
1159 struct aim_user *a;
1160 int count = 0;
1161 int place = 0;
1163 optmenu = gtk_option_menu_new();
1165 menu = gtk_menu_new();
1167 while (u) {
1168 a = (struct aim_user *)u->data;
1169 opt = gtk_menu_item_new_with_label(a->username);
1170 gtk_object_set_user_data(GTK_OBJECT(opt), a);
1171 gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(pounce_choose), b);
1172 gtk_menu_append(GTK_MENU(menu), opt);
1173 gtk_widget_show(opt);
1175 if (b->user == a) {
1176 gtk_menu_item_activate(GTK_MENU_ITEM(opt));
1177 place = count;
1180 count++;
1182 u = u->next;
1185 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
1186 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), place);
1188 b->menu = optmenu;
1190 return optmenu;
1194 void show_new_bp(char *name, struct gaim_connection *gc, int idle, int away, struct buddy_pounce *edit_bp)
1196 GtkWidget *label;
1197 GtkWidget *bbox;
1198 GtkWidget *vbox;
1199 GtkWidget *button;
1200 GtkWidget *frame;
1201 GtkWidget *table;
1202 GtkWidget *optmenu;
1204 struct addbp *b = g_new0(struct addbp, 1);
1206 if(edit_bp) {
1207 b->buddy_pounce = edit_bp;
1208 b->user = find_user(edit_bp->pouncer, edit_bp->protocol);
1209 } else {
1210 b->user = gc ? gc->user : aim_users->data;
1211 b->buddy_pounce = NULL;
1214 GAIM_DIALOG(b->window);
1215 dialogwindows = g_list_prepend(dialogwindows, b->window);
1216 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
1217 gtk_window_set_wmclass(GTK_WINDOW(b->window), "new_bp", "Gaim");
1218 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - New Buddy Pounce"));
1219 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1220 gtk_widget_realize(b->window);
1221 aol_icon(b->window->window);
1223 vbox = gtk_vbox_new(FALSE, 5);
1224 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1225 gtk_container_add(GTK_CONTAINER(b->window), vbox);
1226 gtk_widget_show(vbox);
1228 /* <pounce type="who"> */
1229 frame = gtk_frame_new(_("Pounce Who"));
1230 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
1231 gtk_widget_show(GTK_WIDGET(frame));
1233 table = gtk_table_new(2, 2, FALSE);
1234 gtk_container_add(GTK_CONTAINER(frame), table);
1235 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
1236 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1237 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
1238 gtk_widget_show(table);
1240 label = gtk_label_new(_("Account"));
1241 gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
1242 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
1243 gtk_widget_show(label);
1245 optmenu = pounce_user_menu(b, gc);
1246 gtk_table_attach(GTK_TABLE(table), optmenu, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1247 gtk_widget_show(optmenu);
1249 label = gtk_label_new(_("Buddy"));
1250 gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
1251 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1252 gtk_widget_show(label);
1254 b->nameentry = gtk_entry_new();
1255 gtk_table_attach(GTK_TABLE(table), b->nameentry, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1256 if (name !=NULL)
1257 gtk_entry_set_text(GTK_ENTRY(b->nameentry), name);
1258 else if(edit_bp)
1259 gtk_entry_set_text(GTK_ENTRY(b->nameentry), edit_bp->name);
1260 gtk_window_set_focus(GTK_WINDOW(b->window), b->nameentry);
1261 gtk_widget_show(b->nameentry);
1262 /* </pounce type="who"> */
1265 /* <pounce type="when"> */
1266 frame = gtk_frame_new(_("Pounce When"));
1267 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
1268 gtk_widget_show(GTK_WIDGET(frame));
1270 table = gtk_table_new(2, 2, FALSE);
1271 gtk_container_add(GTK_CONTAINER(frame), table);
1272 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
1273 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1274 gtk_widget_show(table);
1276 b->p_signon = gtk_check_button_new_with_label(_("Pounce on sign on"));
1277 if(edit_bp)
1278 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_signon),
1279 (edit_bp->options & OPT_POUNCE_SIGNON) ? TRUE : FALSE);
1280 else
1281 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_signon), TRUE);
1282 gtk_table_attach(GTK_TABLE(table), b->p_signon, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
1283 gtk_widget_show(b->p_signon);
1285 b->p_unaway = gtk_check_button_new_with_label(_("Pounce on return from away"));
1286 if (away)
1287 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unaway), TRUE);
1288 else if(edit_bp)
1289 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unaway),
1290 (edit_bp->options & OPT_POUNCE_UNAWAY) ? TRUE : FALSE);
1291 gtk_table_attach(GTK_TABLE(table), b->p_unaway, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1292 gtk_widget_show(b->p_unaway);
1294 b->p_unidle = gtk_check_button_new_with_label(_("Pounce on return from idle"));
1295 if (idle)
1296 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unidle), TRUE);
1297 else if(edit_bp)
1298 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unidle),
1299 (edit_bp->options & OPT_POUNCE_UNIDLE) ? TRUE : FALSE);
1300 gtk_table_attach(GTK_TABLE(table), b->p_unidle, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1301 gtk_widget_show(b->p_unidle);
1303 b->p_typing = gtk_check_button_new_with_label(_("Pounce when buddy is typing to you"));
1304 gtk_table_attach(GTK_TABLE(table), b->p_typing,1,2,1,2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1305 gtk_widget_show(b->p_typing);
1307 /* </pounce type="when"> */
1309 /* <pounce type="action"> */
1310 frame = gtk_frame_new(_("Pounce Action"));
1311 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
1312 gtk_widget_show(GTK_WIDGET(frame));
1314 table = gtk_table_new(4, 2, FALSE);
1315 gtk_container_add(GTK_CONTAINER(frame), table);
1316 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
1317 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1318 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
1319 gtk_widget_show(table);
1321 b->openwindow = gtk_check_button_new_with_label(_("Open IM Window"));
1322 if(edit_bp)
1323 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->openwindow),
1324 (edit_bp->options & OPT_POUNCE_POPUP) ? TRUE : FALSE);
1325 else
1326 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->openwindow), FALSE);
1327 gtk_table_attach(GTK_TABLE(table), b->openwindow, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
1328 gtk_widget_show(b->openwindow);
1330 b->popupnotify = gtk_check_button_new_with_label(_("Popup Notification"));
1331 if(edit_bp)
1332 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->popupnotify),
1333 (edit_bp->options & OPT_POUNCE_NOTIFY) ? TRUE : FALSE);
1334 else
1335 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->popupnotify), FALSE);
1336 gtk_table_attach(GTK_TABLE(table), b->popupnotify, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
1337 gtk_widget_show(b->popupnotify);
1339 b->sendim = gtk_check_button_new_with_label(_("Send Message"));
1340 if(edit_bp)
1341 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sendim),
1342 (edit_bp->options & OPT_POUNCE_SEND_IM) ? TRUE : FALSE);
1343 else
1344 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sendim), TRUE);
1345 gtk_table_attach(GTK_TABLE(table), b->sendim, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1346 gtk_widget_show(b->sendim);
1348 b->messentry = gtk_entry_new();
1349 gtk_table_attach(GTK_TABLE(table), b->messentry, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1350 gtk_signal_connect(GTK_OBJECT(b->messentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b);
1351 if(edit_bp) {
1352 gtk_widget_set_sensitive(GTK_WIDGET(b->messentry),
1353 (edit_bp->options & OPT_POUNCE_SEND_IM) ? TRUE : FALSE);
1354 gtk_entry_set_text(GTK_ENTRY(b->messentry), edit_bp->message);
1356 gtk_widget_show(b->messentry);
1358 gtk_signal_connect(GTK_OBJECT(b->sendim), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->messentry);
1360 b->command = gtk_check_button_new_with_label(_("Execute command on pounce"));
1361 gtk_table_attach(GTK_TABLE(table), b->command, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1362 if(edit_bp)
1363 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->command),
1364 (edit_bp->options & OPT_POUNCE_COMMAND) ? TRUE : FALSE);
1365 else
1366 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->command), FALSE);
1367 gtk_widget_show(b->command);
1369 b->commentry = gtk_entry_new();
1370 gtk_table_attach(GTK_TABLE(table), b->commentry, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1371 gtk_signal_connect(GTK_OBJECT(b->commentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b);
1372 if(edit_bp) {
1373 gtk_widget_set_sensitive(GTK_WIDGET(b->commentry),
1374 (edit_bp->options & OPT_POUNCE_COMMAND) ? TRUE : FALSE);
1375 gtk_entry_set_text(GTK_ENTRY(b->commentry), edit_bp->command);
1377 else
1378 gtk_widget_set_sensitive(GTK_WIDGET(b->commentry), FALSE);
1379 gtk_widget_show(b->commentry);
1380 gtk_signal_connect(GTK_OBJECT(b->command), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->commentry);
1382 b->sound = gtk_check_button_new_with_label(_("Play sound on pounce"));
1383 if(edit_bp)
1384 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sound),
1385 (edit_bp->options & OPT_POUNCE_SOUND) ? TRUE : FALSE);
1386 else
1387 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sound), FALSE);
1388 gtk_table_attach(GTK_TABLE(table), b->sound, 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
1389 gtk_widget_show(b->sound);
1391 b->soundentry = gtk_entry_new();
1392 gtk_table_attach(GTK_TABLE(table), b->soundentry, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1393 gtk_signal_connect(GTK_OBJECT(b->soundentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b);
1394 if(edit_bp) {
1395 gtk_widget_set_sensitive(GTK_WIDGET(b->soundentry),
1396 (edit_bp->options & OPT_POUNCE_SOUND) ? TRUE : FALSE);
1397 gtk_entry_set_text(GTK_ENTRY(b->soundentry), edit_bp->sound);
1398 } else
1399 gtk_widget_set_sensitive(GTK_WIDGET(b->soundentry), FALSE);
1400 gtk_widget_show(b->soundentry);
1401 gtk_signal_connect(GTK_OBJECT(b->sound), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->soundentry);
1402 /* </pounce type="action"> */
1404 b->save = gtk_check_button_new_with_label(_("Save this pounce after activation"));
1405 gtk_container_set_border_width(GTK_CONTAINER(b->save), 7);
1406 if(edit_bp)
1407 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->save),
1408 (edit_bp->options & OPT_POUNCE_SAVE) ? TRUE : FALSE);
1409 else
1410 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->save), FALSE);
1411 gtk_box_pack_start(GTK_BOX(vbox), b->save, FALSE, FALSE, 0);
1412 gtk_widget_show(b->save);
1414 bbox = gtk_hbox_new(FALSE, 5);
1415 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
1416 gtk_widget_show(bbox);
1418 button = picture_button(b->window, _("Cancel"), cancel_xpm);
1419 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1420 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
1422 button = picture_button(b->window, _("OK"), ok_xpm);
1423 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_new_bp), b);
1424 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
1426 gtk_widget_show(b->window);
1431 /*------------------------------------------------------------------------*/
1432 /* The dialog for SET INFO / SET DIR INFO */
1433 /*------------------------------------------------------------------------*/
1435 void do_save_info(GtkWidget *widget, struct set_info_dlg *b)
1437 gchar *junk;
1438 struct gaim_connection *gc;
1440 junk = gtk_editable_get_chars(GTK_EDITABLE(b->text), 0, -1);
1442 if (b->user) {
1443 strncpy_withhtml(b->user->user_info, junk, sizeof b->user->user_info);
1444 gc = b->user->gc;
1446 save_prefs();
1448 if (gc)
1449 serv_set_info(gc, b->user->user_info);
1451 g_free(junk);
1452 destroy_dialog(NULL, b->window);
1453 g_free(b);
1456 void do_set_dir(GtkWidget *widget, struct set_dir_dlg *b)
1458 char *first = gtk_entry_get_text(GTK_ENTRY(b->first));
1459 int web = GTK_TOGGLE_BUTTON(b->web)->active;
1460 char *middle = gtk_entry_get_text(GTK_ENTRY(b->middle));
1461 char *last = gtk_entry_get_text(GTK_ENTRY(b->last));
1462 char *maiden = gtk_entry_get_text(GTK_ENTRY(b->maiden));
1463 char *city = gtk_entry_get_text(GTK_ENTRY(b->city));
1464 char *state = gtk_entry_get_text(GTK_ENTRY(b->state));
1465 char *country = gtk_entry_get_text(GTK_ENTRY(b->country));
1467 serv_set_dir(b->gc, first, middle, last, maiden, city, state, country, web);
1469 destroy_dialog(NULL, b->window);
1470 g_free(b);
1473 void show_set_dir(struct gaim_connection *gc)
1475 GtkWidget *label;
1476 GtkWidget *bot;
1477 GtkWidget *vbox;
1478 GtkWidget *hbox;
1479 GtkWidget *frame;
1480 GtkWidget *fbox;
1481 char buf[256];
1483 struct set_dir_dlg *b = g_new0(struct set_dir_dlg, 1);
1484 b->gc = gc;
1486 GAIM_DIALOG(b->window);
1487 dialogwindows = g_list_prepend(dialogwindows, b->window);
1488 gtk_window_set_wmclass(GTK_WINDOW(b->window), "set_dir", "Gaim");
1489 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
1490 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Set Dir Info"));
1491 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1492 gtk_widget_realize(b->window);
1493 aol_icon(b->window->window);
1495 fbox = gtk_vbox_new(FALSE, 5);
1496 gtk_container_add(GTK_CONTAINER(b->window), fbox);
1497 gtk_widget_show(fbox);
1499 frame = gtk_frame_new(_("Directory Info"));
1500 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
1501 gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 0);
1502 gtk_widget_show(frame);
1504 vbox = gtk_vbox_new(FALSE, 5);
1505 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1506 gtk_container_add(GTK_CONTAINER(frame), vbox);
1507 gtk_widget_show(vbox);
1509 g_snprintf(buf, sizeof(buf), "Setting Dir Info for %s:", gc->username);
1510 label = gtk_label_new(buf);
1511 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5);
1512 gtk_widget_show(label);
1514 b->first = gtk_entry_new();
1515 b->middle = gtk_entry_new();
1516 b->last = gtk_entry_new();
1517 b->maiden = gtk_entry_new();
1518 b->city = gtk_entry_new();
1519 b->state = gtk_entry_new();
1520 b->country = gtk_entry_new();
1521 b->web = gtk_check_button_new_with_label(_("Allow Web Searches To Find Your Info"));
1523 /* Line 1 */
1524 label = gtk_label_new(_("First Name"));
1525 gtk_widget_show(label);
1527 hbox = gtk_hbox_new(FALSE, 5);
1528 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1529 gtk_box_pack_end(GTK_BOX(hbox), b->first, FALSE, FALSE, 0);
1531 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1532 gtk_widget_show(hbox);
1534 /* Line 2 */
1535 label = gtk_label_new(_("Middle Name"));
1536 gtk_widget_show(label);
1538 hbox = gtk_hbox_new(FALSE, 5);
1539 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1540 gtk_box_pack_end(GTK_BOX(hbox), b->middle, FALSE, FALSE, 0);
1542 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1543 gtk_widget_show(hbox);
1546 /* Line 3 */
1547 label = gtk_label_new(_("Last Name"));
1548 gtk_widget_show(label);
1550 hbox = gtk_hbox_new(FALSE, 5);
1551 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1552 gtk_box_pack_end(GTK_BOX(hbox), b->last, FALSE, FALSE, 0);
1554 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1555 gtk_widget_show(hbox);
1557 /* Line 4 */
1558 label = gtk_label_new(_("Maiden Name"));
1559 gtk_widget_show(label);
1561 hbox = gtk_hbox_new(FALSE, 5);
1562 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1563 gtk_box_pack_end(GTK_BOX(hbox), b->maiden, FALSE, FALSE, 0);
1565 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1566 gtk_widget_show(hbox);
1568 /* Line 5 */
1569 label = gtk_label_new(_("City"));
1570 gtk_widget_show(label);
1572 hbox = gtk_hbox_new(FALSE, 5);
1573 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1574 gtk_box_pack_end(GTK_BOX(hbox), b->city, FALSE, FALSE, 0);
1576 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1577 gtk_widget_show(hbox);
1579 /* Line 6 */
1580 label = gtk_label_new(_("State"));
1581 gtk_widget_show(label);
1583 hbox = gtk_hbox_new(FALSE, 5);
1584 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1585 gtk_box_pack_end(GTK_BOX(hbox), b->state, FALSE, FALSE, 0);
1587 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1588 gtk_widget_show(hbox);
1590 /* Line 7 */
1591 label = gtk_label_new(_("Country"));
1592 gtk_widget_show(label);
1594 hbox = gtk_hbox_new(FALSE, 5);
1595 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1596 gtk_box_pack_end(GTK_BOX(hbox), b->country, FALSE, FALSE, 0);
1598 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1599 gtk_widget_show(hbox);
1601 /* Line 8 */
1603 hbox = gtk_hbox_new(FALSE, 5);
1604 gtk_box_pack_start(GTK_BOX(hbox), b->web, TRUE, TRUE, 0);
1605 gtk_widget_show(hbox);
1606 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1608 gtk_widget_show(b->first);
1609 gtk_widget_show(b->middle);
1610 gtk_widget_show(b->last);
1611 gtk_widget_show(b->maiden);
1612 gtk_widget_show(b->city);
1613 gtk_widget_show(b->state);
1614 gtk_widget_show(b->country);
1615 gtk_widget_show(b->web);
1617 /* And add the buttons */
1619 bot = gtk_hbox_new(FALSE, 5);
1620 gtk_box_pack_start(GTK_BOX(fbox), bot, FALSE, FALSE, 0);
1621 gtk_widget_show(bot);
1623 b->cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
1624 gtk_box_pack_end(GTK_BOX(bot), b->cancel, FALSE, FALSE, 0);
1625 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1627 b->save = picture_button(b->window, _("Save"), save_xpm);
1628 gtk_box_pack_end(GTK_BOX(bot), b->save, FALSE, FALSE, 0);
1629 gtk_signal_connect(GTK_OBJECT(b->save), "clicked", GTK_SIGNAL_FUNC(do_set_dir), b);
1631 gtk_window_set_focus(GTK_WINDOW(b->window), b->first);
1633 gtk_widget_show(b->window);
1636 void do_change_password(GtkWidget *widget, struct passwddlg *b)
1638 gchar *orig, *new1, *new2;
1640 orig = gtk_entry_get_text(GTK_ENTRY(b->original));
1641 new1 = gtk_entry_get_text(GTK_ENTRY(b->new1));
1642 new2 = gtk_entry_get_text(GTK_ENTRY(b->new2));
1644 if (g_strcasecmp(new1, new2)) {
1645 do_error_dialog(_("New Passwords Do Not Match"), _("Gaim - Change Password Error"));
1646 return;
1649 if ((strlen(orig) < 1) || (strlen(new1) < 1) || (strlen(new2) < 1)) {
1650 do_error_dialog(_("Fill out all fields completely"), _("Gaim - Change Password Error"));
1651 return;
1654 serv_change_passwd(b->gc, orig, new1);
1656 destroy_dialog(NULL, b->window);
1657 g_free(b);
1660 void show_change_passwd(struct gaim_connection *gc)
1662 GtkWidget *hbox;
1663 GtkWidget *label;
1664 GtkWidget *vbox;
1665 GtkWidget *fbox;
1666 GtkWidget *frame;
1667 char buf[256];
1669 struct passwddlg *b = g_new0(struct passwddlg, 1);
1670 b->gc = gc;
1672 GAIM_DIALOG(b->window);
1673 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
1674 gtk_window_set_wmclass(GTK_WINDOW(b->window), "change_passwd", "Gaim");
1675 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Password Change"));
1676 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1677 gtk_widget_realize(b->window);
1678 aol_icon(b->window->window);
1679 dialogwindows = g_list_prepend(dialogwindows, b->window);
1681 fbox = gtk_vbox_new(FALSE, 5);
1682 gtk_container_border_width(GTK_CONTAINER(fbox), 5);
1683 gtk_container_add(GTK_CONTAINER(b->window), fbox);
1684 gtk_widget_show(fbox);
1686 frame = gtk_frame_new(_("Change Password"));
1687 gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 0);
1688 gtk_widget_show(frame);
1690 vbox = gtk_vbox_new(FALSE, 5);
1691 gtk_container_border_width(GTK_CONTAINER(vbox), 5);
1692 gtk_container_add(GTK_CONTAINER(frame), vbox);
1693 gtk_widget_show(vbox);
1695 g_snprintf(buf, sizeof(buf), "Changing password for %s:", gc->username);
1696 label = gtk_label_new(buf);
1697 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5);
1698 gtk_widget_show(label);
1700 /* First Line */
1701 hbox = gtk_hbox_new(FALSE, 5);
1702 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1703 gtk_widget_show(hbox);
1705 label = gtk_label_new(_("Original Password"));
1706 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1707 gtk_widget_show(label);
1709 b->original = gtk_entry_new();
1710 gtk_entry_set_visibility(GTK_ENTRY(b->original), FALSE);
1711 gtk_box_pack_end(GTK_BOX(hbox), b->original, FALSE, FALSE, 0);
1712 gtk_widget_show(b->original);
1714 /* Next Line */
1715 hbox = gtk_hbox_new(FALSE, 5);
1716 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1717 gtk_widget_show(hbox);
1719 label = gtk_label_new(_("New Password"));
1720 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1721 gtk_widget_show(label);
1723 b->new1 = gtk_entry_new();
1724 gtk_entry_set_visibility(GTK_ENTRY(b->new1), FALSE);
1725 gtk_box_pack_end(GTK_BOX(hbox), b->new1, FALSE, FALSE, 0);
1726 gtk_widget_show(b->new1);
1728 /* Next Line */
1729 hbox = gtk_hbox_new(FALSE, 5);
1730 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1731 gtk_widget_show(hbox);
1733 label = gtk_label_new(_("New Password (again)"));
1734 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1735 gtk_widget_show(label);
1737 b->new2 = gtk_entry_new();
1738 gtk_entry_set_visibility(GTK_ENTRY(b->new2), FALSE);
1739 gtk_box_pack_end(GTK_BOX(hbox), b->new2, FALSE, FALSE, 0);
1740 gtk_widget_show(b->new2);
1742 /* Now do our row of buttons */
1743 hbox = gtk_hbox_new(FALSE, 5);
1744 gtk_box_pack_start(GTK_BOX(fbox), hbox, FALSE, FALSE, 0);
1745 gtk_widget_show(hbox);
1747 b->cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
1748 gtk_box_pack_end(GTK_BOX(hbox), b->cancel, FALSE, FALSE, 0);
1749 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1751 b->ok = picture_button(b->window, _("OK"), ok_xpm);
1752 gtk_box_pack_end(GTK_BOX(hbox), b->ok, FALSE, FALSE, 0);
1753 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(do_change_password), b);
1756 gtk_widget_show(b->window);
1759 void show_set_info(struct gaim_connection *gc)
1761 GtkWidget *buttons;
1762 GtkWidget *label;
1763 GtkWidget *vbox;
1764 gchar *buf;
1765 struct aim_user *tmp;
1767 struct set_info_dlg *b = g_new0(struct set_info_dlg, 1);
1768 tmp = gc->user;
1769 b->user = tmp;
1771 GAIM_DIALOG(b->window);
1772 gtk_window_set_wmclass(GTK_WINDOW(b->window), "set_info", "Gaim");
1773 dialogwindows = g_list_prepend(dialogwindows, b->window);
1774 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Set User Info"));
1775 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1776 gtk_widget_realize(b->window);
1777 aol_icon(b->window->window);
1779 vbox = gtk_vbox_new(FALSE, 5);
1780 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1781 gtk_container_add(GTK_CONTAINER(b->window), vbox);
1782 gtk_widget_show(vbox);
1784 buf = g_malloc(256);
1785 g_snprintf(buf, 256, "Changing info for %s:", tmp->username);
1786 label = gtk_label_new(buf);
1787 g_free(buf);
1788 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5);
1789 gtk_widget_show(label);
1791 b->text = gtk_text_new(NULL, NULL);
1792 gtk_text_set_word_wrap(GTK_TEXT(b->text), TRUE);
1793 gtk_text_set_editable(GTK_TEXT(b->text), TRUE);
1794 gtk_widget_set_usize(b->text, 300, 200);
1795 buf = g_malloc(strlen(tmp->user_info) + 1);
1796 strncpy_nohtml(buf, tmp->user_info, strlen(tmp->user_info) + 1);
1797 gtk_text_insert(GTK_TEXT(b->text), NULL, NULL, NULL, buf, -1);
1798 g_free(buf);
1799 gtk_box_pack_start(GTK_BOX(vbox), b->text, TRUE, TRUE, 0);
1800 gtk_widget_show(b->text);
1801 gtk_window_set_focus(GTK_WINDOW(b->window), b->text);
1803 buttons = gtk_hbox_new(FALSE, 5);
1804 gtk_box_pack_start(GTK_BOX(vbox), buttons, FALSE, FALSE, 0);
1805 gtk_widget_show(buttons);
1807 b->cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
1808 gtk_box_pack_end(GTK_BOX(buttons), b->cancel, FALSE, FALSE, 0);
1809 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1811 b->save = picture_button(b->window, _("Save"), save_xpm);
1812 gtk_box_pack_end(GTK_BOX(buttons), b->save, FALSE, FALSE, 0);
1813 gtk_signal_connect(GTK_OBJECT(b->save), "clicked", GTK_SIGNAL_FUNC(do_save_info), b);
1815 gtk_widget_show(b->window);
1819 /*------------------------------------------------------------------------*/
1820 /* The dialog for the info requests */
1821 /*------------------------------------------------------------------------*/
1823 static void info_dlg_free(GtkWidget *b, struct info_dlg *d)
1825 if (g_slist_find(info_dlgs, d))
1826 info_dlgs = g_slist_remove(info_dlgs, d);
1827 g_free(d->who);
1828 g_free(d);
1831 gchar **info_img_handler(gchar *url)
1833 if (!g_strcasecmp(url, "free_icon.gif"))
1834 return free_icon_xpm;
1835 if (!g_strcasecmp(url, "aol_icon.gif"))
1836 return aol_icon_xpm;
1837 if (!g_strcasecmp(url, "dt_icon.gif"))
1838 return dt_icon_xpm;
1839 if (!g_strcasecmp(url, "admin_icon.gif"))
1840 return admin_icon_xpm;
1841 if (!g_strcasecmp(url, "ab_icon.gif"))
1842 return ab_xpm;
1843 return NULL;
1846 /* if away is 0, show regardless and try to get away message
1847 * 1, don't show if regular info isn't shown
1848 * 2, show regardless but don't try to get away message
1850 * i wish this were my client. if i were i wouldn't have to deal with this shit.
1852 void g_show_info_text(struct gaim_connection *gc, char *who, int away, char *info, ...)
1854 GtkWidget *ok;
1855 GtkWidget *label;
1856 GtkWidget *text;
1857 GtkWidget *bbox;
1858 GtkWidget *sw;
1859 gint options = 0;
1860 char *more_info;
1861 va_list ap;
1863 struct info_dlg *b = find_info_dlg(gc, who);
1864 if (!b && (away == 1))
1865 return;
1866 if (!b) {
1867 b = g_new0(struct info_dlg, 1);
1868 b->gc = gc;
1869 b->who = who ? g_strdup(normalize(who)) : NULL;
1870 info_dlgs = g_slist_append(info_dlgs, b);
1872 GAIM_DIALOG(b->window);
1873 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim");
1874 gtk_container_border_width(GTK_CONTAINER(b->window), 5);
1875 gtk_widget_realize(GTK_WIDGET(b->window));
1876 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(info_dlg_free), b);
1877 aol_icon(b->window->window);
1879 bbox = gtk_vbox_new(FALSE, 5);
1880 gtk_container_add(GTK_CONTAINER(b->window), bbox);
1882 label = gtk_label_new(_("Below are the results of your search: "));
1883 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
1885 sw = gtk_scrolled_window_new(NULL, NULL);
1886 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1887 gtk_box_pack_start(GTK_BOX(bbox), sw, TRUE, TRUE, 0);
1889 text = gtk_imhtml_new(NULL, NULL);
1890 b->text = text;
1891 gtk_container_add(GTK_CONTAINER(sw), text);
1892 GTK_LAYOUT(text)->hadjustment->step_increment = 10.0;
1893 GTK_LAYOUT(text)->vadjustment->step_increment = 10.0;
1894 gtk_widget_set_usize(sw, 300, 250);
1895 gtk_imhtml_set_img_handler(GTK_IMHTML(text), info_img_handler);
1896 gaim_setup_imhtml(text);
1898 ok = picture_button(b->window, _("OK"), ok_xpm);
1899 gtk_signal_connect_object(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
1900 GTK_OBJECT(b->window));
1901 gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0);
1903 gtk_widget_show_all(b->window);
1906 if (convo_options & OPT_CONVO_IGNORE_COLOUR)
1907 options ^= GTK_IMHTML_NO_COLOURS;
1908 if (convo_options & OPT_CONVO_IGNORE_FONTS)
1909 options ^= GTK_IMHTML_NO_FONTS;
1910 if (convo_options & OPT_CONVO_IGNORE_SIZES)
1911 options ^= GTK_IMHTML_NO_SIZES;
1912 options ^= GTK_IMHTML_NO_COMMENTS;
1913 options ^= GTK_IMHTML_NO_TITLE;
1914 options ^= GTK_IMHTML_NO_NEWLINE;
1915 options ^= GTK_IMHTML_NO_SCROLL;
1917 gtk_imhtml_append_text(GTK_IMHTML(b->text), info, -1, options);
1919 va_start(ap, info);
1920 while ((more_info = va_arg(ap, char *)) != NULL)
1921 gtk_imhtml_append_text(GTK_IMHTML(b->text), more_info, -1, options);
1922 va_end(ap);
1924 if (away)
1925 info_dlgs = g_slist_remove(info_dlgs, b);
1926 else
1927 serv_get_away(gc, who);
1930 /*------------------------------------------------------------------------*/
1931 /* The dialog for adding to permit/deny */
1932 /*------------------------------------------------------------------------*/
1935 static void do_add_perm(GtkWidget *w, struct addperm *p)
1938 char *who;
1939 char *name;
1942 who = gtk_entry_get_text(GTK_ENTRY(p->entry));
1944 name = g_malloc(strlen(who) + 2);
1945 g_snprintf(name, strlen(who) + 2, "%s", who);
1947 if (!p->permit) {
1948 GSList *d = p->gc->deny;
1949 char *n;
1950 n = g_strdup(normalize(name));
1951 while (d) {
1952 if (!g_strcasecmp(n, normalize(d->data)))
1953 break;
1954 d = d->next;
1956 g_free(n);
1957 if (!d) {
1958 p->gc->deny = g_slist_append(p->gc->deny, name);
1959 serv_add_deny(p->gc, name);
1960 build_block_list();
1961 do_export(p->gc);
1962 } else
1963 g_free(name);
1964 } else {
1965 GSList *d = p->gc->permit;
1966 char *n;
1967 n = g_strdup(normalize(name));
1968 while (d) {
1969 if (!g_strcasecmp(n, normalize(d->data)))
1970 break;
1971 d = d->next;
1973 g_free(n);
1974 if (!d) {
1975 p->gc->permit = g_slist_append(p->gc->permit, name);
1976 serv_add_permit(p->gc, name);
1977 build_allow_list();
1978 do_export(p->gc);
1979 } else
1980 g_free(name);
1983 destroy_dialog(NULL, p->window);
1988 void show_add_perm(struct gaim_connection *gc, char *who, gboolean permit)
1990 GtkWidget *cancel;
1991 GtkWidget *add;
1992 GtkWidget *label;
1993 GtkWidget *bbox;
1994 GtkWidget *vbox;
1995 GtkWidget *topbox;
1996 GtkWidget *frame;
1998 struct addperm *p = g_new0(struct addperm, 1);
1999 p->gc = gc;
2000 p->permit = permit;
2002 GAIM_DIALOG(p->window);
2003 gtk_container_set_border_width(GTK_CONTAINER(p->window), 5);
2004 gtk_window_set_policy(GTK_WINDOW(p->window), FALSE, FALSE, TRUE);
2005 gtk_widget_realize(p->window);
2007 dialogwindows = g_list_prepend(dialogwindows, p->window);
2009 bbox = gtk_hbox_new(TRUE, 10);
2010 topbox = gtk_hbox_new(FALSE, 5);
2011 vbox = gtk_vbox_new(FALSE, 5);
2012 p->entry = gtk_entry_new();
2014 if (permit)
2015 frame = gtk_frame_new(_("Permit"));
2016 else
2017 frame = gtk_frame_new(_("Deny"));
2019 /* Build Add Button */
2021 if (permit)
2022 add = picture_button(p->window, _("Permit"), add_xpm);
2023 else
2024 add = picture_button(p->window, _("Deny"), add_xpm);
2025 cancel = picture_button(p->window, _("Cancel"), cancel_xpm);
2027 /* End of Cancel Button */
2028 if (who != NULL)
2029 gtk_entry_set_text(GTK_ENTRY(p->entry), who);
2031 /* Put the buttons in the box */
2033 gtk_box_pack_start(GTK_BOX(bbox), add, FALSE, FALSE, 5);
2034 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
2036 label = gtk_label_new(_("Add"));
2037 gtk_widget_show(label);
2038 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
2039 gtk_box_pack_start(GTK_BOX(topbox), p->entry, FALSE, FALSE, 5);
2040 /* And the boxes in the box */
2041 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5);
2042 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5);
2043 gtk_container_add(GTK_CONTAINER(frame), vbox);
2046 /* Handle closes right */
2047 gtk_signal_connect(GTK_OBJECT(p->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), p->window);
2048 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), p->window);
2049 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(do_add_perm), p);
2050 gtk_signal_connect(GTK_OBJECT(p->entry), "activate", GTK_SIGNAL_FUNC(do_add_perm), p);
2052 /* Finish up */
2053 gtk_widget_show(add);
2054 gtk_widget_show(cancel);
2055 gtk_widget_show(p->entry);
2056 gtk_widget_show(topbox);
2057 gtk_widget_show(bbox);
2058 gtk_widget_show(vbox);
2059 gtk_widget_show(frame);
2060 if (permit)
2061 gtk_window_set_title(GTK_WINDOW(p->window), _("Gaim - Add Permit"));
2062 else
2063 gtk_window_set_title(GTK_WINDOW(p->window), _("Gaim - Add Deny"));
2064 gtk_window_set_focus(GTK_WINDOW(p->window), p->entry);
2065 gtk_container_add(GTK_CONTAINER(p->window), frame);
2066 gtk_widget_realize(p->window);
2067 aol_icon(p->window->window);
2069 gtk_widget_show(p->window);
2073 /*------------------------------------------------------------------------*/
2074 /* Functions Called To Add A Log */
2075 /*------------------------------------------------------------------------*/
2077 void cancel_log(GtkWidget *widget, struct conversation *c)
2079 if (c->wood) {
2080 set_state_lock(1);
2081 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->wood), FALSE);
2082 set_state_lock(0);
2084 dialogwindows = g_list_remove(dialogwindows, c->log_dialog);
2085 gtk_widget_destroy(c->log_dialog);
2086 c->log_dialog = NULL;
2089 void do_log(GtkWidget *w, struct conversation *c)
2091 struct log_conversation *l;
2092 char buf[128];
2093 char *file;
2094 char path[PATHSIZE];
2096 if (!find_log_info(c->name)) {
2097 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(c->log_dialog));
2098 strncpy(path, file, PATHSIZE - 1);
2099 if (file_is_dir(path, c->log_dialog)) {
2100 return;
2103 l = (struct log_conversation *)g_new0(struct log_conversation, 1);
2104 strcpy(l->name, c->name);
2105 strcpy(l->filename, file);
2106 log_conversations = g_list_append(log_conversations, l);
2108 if (c != NULL) {
2109 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, c->name);
2110 gtk_window_set_title(GTK_WINDOW(c->window), buf);
2114 save_prefs();
2115 cancel_log(NULL, c);
2118 void show_log_dialog(struct conversation *c)
2120 char *buf = g_malloc(BUF_LEN);
2122 if (!c->log_dialog) {
2123 c->log_dialog = gtk_file_selection_new(_("Gaim - Log Conversation"));
2125 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(c->log_dialog));
2127 g_snprintf(buf, BUF_LEN - 1, "%s/%s.log", getenv("HOME"), normalize(c->name));
2128 gtk_object_set_user_data(GTK_OBJECT(c->log_dialog), "log dialog");
2129 gtk_file_selection_set_filename(GTK_FILE_SELECTION(c->log_dialog), buf);
2130 gtk_signal_connect(GTK_OBJECT(c->log_dialog), "delete_event",
2131 GTK_SIGNAL_FUNC(delete_event_dialog), c);
2132 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(c->log_dialog)->ok_button), "clicked",
2133 GTK_SIGNAL_FUNC(do_log), c);
2134 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(c->log_dialog)->cancel_button),
2135 "clicked", GTK_SIGNAL_FUNC(cancel_log), c);
2138 g_free(buf);
2140 gtk_widget_show(c->log_dialog);
2141 gdk_window_raise(c->log_dialog->window);
2144 /*------------------------------------------------------*/
2145 /* Find Buddy By Email */
2146 /*------------------------------------------------------*/
2148 void do_find_info(GtkWidget *w, struct findbyinfo *b)
2150 char *first;
2151 char *middle;
2152 char *last;
2153 char *maiden;
2154 char *city;
2155 char *state;
2156 char *country;
2158 first = gtk_entry_get_text(GTK_ENTRY(b->firstentry));
2159 middle = gtk_entry_get_text(GTK_ENTRY(b->middleentry));
2160 last = gtk_entry_get_text(GTK_ENTRY(b->lastentry));
2161 maiden = gtk_entry_get_text(GTK_ENTRY(b->maidenentry));
2162 city = gtk_entry_get_text(GTK_ENTRY(b->cityentry));
2163 state = gtk_entry_get_text(GTK_ENTRY(b->stateentry));
2164 country = gtk_entry_get_text(GTK_ENTRY(b->countryentry));
2166 serv_dir_search(b->gc, first, middle, last, maiden, city, state, country, "");
2167 destroy_dialog(NULL, b->window);
2170 void do_find_email(GtkWidget *w, struct findbyemail *b)
2172 char *email;
2174 email = gtk_entry_get_text(GTK_ENTRY(b->emailentry));
2176 serv_dir_search(b->gc, "", "", "", "", "", "", "", email);
2178 destroy_dialog(NULL, b->window);
2181 void show_find_info(struct gaim_connection *gc)
2183 GtkWidget *cancel;
2184 GtkWidget *ok;
2185 GtkWidget *label;
2186 GtkWidget *bbox;
2187 GtkWidget *vbox;
2188 GtkWidget *hbox;
2189 GtkWidget *fbox;
2190 GtkWidget *frame;
2192 struct findbyinfo *b = g_new0(struct findbyinfo, 1);
2193 b->gc = gc;
2194 GAIM_DIALOG(b->window);
2195 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
2196 gtk_window_set_wmclass(GTK_WINDOW(b->window), "find_info", "Gaim");
2197 gtk_widget_show(b->window);
2199 dialogwindows = g_list_prepend(dialogwindows, b->window);
2201 frame = gtk_frame_new(_("Search for Buddy"));
2202 fbox = gtk_vbox_new(FALSE, 5);
2204 /* Build OK Button */
2206 ok = picture_button(b->window, _("OK"), ok_xpm);
2207 cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
2209 bbox = gtk_hbox_new(FALSE, 5);
2210 vbox = gtk_vbox_new(FALSE, 5);
2211 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2213 b->firstentry = gtk_entry_new();
2214 b->middleentry = gtk_entry_new();
2215 b->lastentry = gtk_entry_new();
2216 b->maidenentry = gtk_entry_new();
2217 b->cityentry = gtk_entry_new();
2218 b->stateentry = gtk_entry_new();
2219 b->countryentry = gtk_entry_new();
2221 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 0);
2222 gtk_box_pack_end(GTK_BOX(bbox), ok, FALSE, FALSE, 0);
2224 /* Line 1 */
2225 label = gtk_label_new(_("First Name"));
2226 gtk_widget_show(label);
2228 hbox = gtk_hbox_new(FALSE, 5);
2229 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2230 gtk_box_pack_end(GTK_BOX(hbox), b->firstentry, FALSE, FALSE, 0);
2232 gtk_widget_show(hbox);
2233 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2235 /* Line 2 */
2237 label = gtk_label_new(_("Middle Name"));
2238 gtk_widget_show(label);
2240 hbox = gtk_hbox_new(FALSE, 5);
2241 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2242 gtk_box_pack_end(GTK_BOX(hbox), b->middleentry, FALSE, FALSE, 0);
2244 gtk_widget_show(hbox);
2245 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2247 /* Line 3 */
2249 label = gtk_label_new(_("Last Name"));
2250 gtk_widget_show(label);
2252 hbox = gtk_hbox_new(FALSE, 5);
2253 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2254 gtk_box_pack_end(GTK_BOX(hbox), b->lastentry, FALSE, FALSE, 0);
2256 gtk_widget_show(hbox);
2257 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2259 /* Line 4 */
2261 label = gtk_label_new(_("Maiden Name"));
2262 gtk_widget_show(label);
2264 hbox = gtk_hbox_new(FALSE, 5);
2265 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2266 gtk_box_pack_end(GTK_BOX(hbox), b->maidenentry, FALSE, FALSE, 0);
2268 gtk_widget_show(hbox);
2269 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2271 /* Line 5 */
2273 label = gtk_label_new(_("City"));
2274 gtk_widget_show(label);
2276 hbox = gtk_hbox_new(FALSE, 5);
2277 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2278 gtk_box_pack_end(GTK_BOX(hbox), b->cityentry, FALSE, FALSE, 0);
2280 gtk_widget_show(hbox);
2281 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2283 /* Line 6 */
2284 label = gtk_label_new(_("State"));
2285 gtk_widget_show(label);
2287 hbox = gtk_hbox_new(FALSE, 5);
2288 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2289 gtk_box_pack_end(GTK_BOX(hbox), b->stateentry, FALSE, FALSE, 0);
2291 gtk_widget_show(hbox);
2292 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2294 /* Line 7 */
2295 label = gtk_label_new(_("Country"));
2296 gtk_widget_show(label);
2298 hbox = gtk_hbox_new(FALSE, 5);
2299 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2300 gtk_box_pack_end(GTK_BOX(hbox), b->countryentry, FALSE, FALSE, 0);
2302 gtk_widget_show(hbox);
2303 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2305 /* Merge The Boxes */
2307 gtk_container_add(GTK_CONTAINER(frame), vbox);
2308 gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 0);
2309 gtk_box_pack_start(GTK_BOX(fbox), bbox, FALSE, FALSE, 0);
2311 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
2312 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
2313 gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(do_find_info), b);
2315 gtk_widget_show(ok);
2316 gtk_widget_show(cancel);
2317 gtk_widget_show(b->firstentry);
2318 gtk_widget_show(b->middleentry);
2319 gtk_widget_show(b->lastentry);
2320 gtk_widget_show(b->maidenentry);
2321 gtk_widget_show(b->cityentry);
2322 gtk_widget_show(b->stateentry);
2323 gtk_widget_show(b->countryentry);
2324 gtk_widget_show(bbox);
2325 gtk_widget_show(vbox);
2326 gtk_widget_show(frame);
2327 gtk_widget_show(fbox);
2329 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Find Buddy By Info"));
2330 gtk_window_set_focus(GTK_WINDOW(b->window), b->firstentry);
2331 gtk_container_add(GTK_CONTAINER(b->window), fbox);
2332 gtk_container_border_width(GTK_CONTAINER(b->window), 5);
2333 gtk_widget_realize(b->window);
2334 aol_icon(b->window->window);
2336 gtk_widget_show(b->window);
2339 void show_find_email(struct gaim_connection *gc)
2341 GtkWidget *label;
2342 GtkWidget *bbox;
2343 GtkWidget *vbox;
2344 GtkWidget *frame;
2345 GtkWidget *topbox;
2346 GtkWidget *button;
2348 struct findbyemail *b = g_new0(struct findbyemail, 1);
2349 if (g_slist_find(connections, gc))
2350 b->gc = gc;
2351 GAIM_DIALOG(b->window);
2352 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
2353 gtk_window_set_wmclass(GTK_WINDOW(b->window), "find_email", "Gaim");
2354 gtk_widget_realize(b->window);
2355 aol_icon(b->window->window);
2356 dialogwindows = g_list_prepend(dialogwindows, b->window);
2357 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
2358 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Find Buddy By Email"));
2360 vbox = gtk_vbox_new(FALSE, 5);
2361 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2362 gtk_container_add(GTK_CONTAINER(b->window), vbox);
2364 frame = gtk_frame_new(_("Search for Buddy"));
2365 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
2367 topbox = gtk_hbox_new(FALSE, 5);
2368 gtk_container_add(GTK_CONTAINER(frame), topbox);
2369 gtk_container_set_border_width(GTK_CONTAINER(topbox), 5);
2371 label = gtk_label_new(_("Email"));
2372 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 0);
2374 b->emailentry = gtk_entry_new();
2375 gtk_box_pack_start(GTK_BOX(topbox), b->emailentry, TRUE, TRUE, 0);
2376 gtk_signal_connect(GTK_OBJECT(b->emailentry), "activate", GTK_SIGNAL_FUNC(do_find_email), b);
2377 gtk_window_set_focus(GTK_WINDOW(b->window), b->emailentry);
2379 bbox = gtk_hbox_new(FALSE, 5);
2380 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
2382 button = picture_button(b->window, _("Cancel"), cancel_xpm);
2383 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
2384 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
2386 button = picture_button(b->window, _("OK"), ok_xpm);
2387 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_find_email), b);
2388 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
2390 gtk_widget_show_all(b->window);
2393 /*------------------------------------------------------*/
2394 /* Link Dialog */
2395 /*------------------------------------------------------*/
2397 void cancel_link(GtkWidget *widget, struct conversation *c)
2399 if (c->link) {
2400 set_state_lock(1);
2401 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->link), FALSE);
2402 set_state_lock(0);
2404 destroy_dialog(NULL, c->link_dialog);
2405 c->link_dialog = NULL;
2408 void do_add_link(GtkWidget *widget, struct linkdlg *b)
2410 char *open_tag;
2411 char *urltext, *showtext;
2412 open_tag = g_malloc(2048);
2415 urltext = gtk_entry_get_text(GTK_ENTRY(b->url));
2416 showtext = gtk_entry_get_text(GTK_ENTRY(b->text));
2418 g_snprintf(open_tag, 2048, "<A HREF=\"%s\">%s", urltext, showtext);
2419 surround(b->entry, open_tag, "</A>");
2421 g_free(open_tag);
2422 destroy_dialog(NULL, b->window);
2426 void show_add_link(GtkWidget *linky, struct conversation *c)
2428 GtkWidget *vbox;
2429 GtkWidget *bbox;
2430 GtkWidget *hbox;
2431 GtkWidget *label;
2432 GtkWidget *frame;
2433 GtkWidget *fbox;
2435 if (!c->link_dialog) {
2436 struct linkdlg *b = g_new0(struct linkdlg, 1);
2437 GAIM_DIALOG(c->link_dialog);
2438 gtk_window_set_wmclass(GTK_WINDOW(c->link_dialog), "add_link", "Gaim");
2439 dialogwindows = g_list_prepend(dialogwindows, c->link_dialog);
2441 gtk_widget_set_usize(c->link_dialog, 270, 165);
2442 gtk_window_set_policy(GTK_WINDOW(c->link_dialog), FALSE, FALSE, TRUE);
2443 gtk_widget_show(c->link_dialog);
2445 vbox = gtk_vbox_new(FALSE, 10);
2446 bbox = gtk_hbox_new(TRUE, 10);
2447 frame = gtk_frame_new(_("Insert Link"));
2448 fbox = gtk_vbox_new(FALSE, 5);
2450 /* Build OK Button */
2452 b->ok = picture_button(c->link_dialog, _("OK"), ok_xpm);
2453 b->cancel = picture_button(c->link_dialog, _("Cancel"), cancel_xpm);
2455 gtk_widget_set_usize(b->ok, 75, 30);
2456 gtk_widget_set_usize(b->cancel, 75, 30);
2458 gtk_box_pack_start(GTK_BOX(bbox), b->ok, FALSE, FALSE, 10);
2459 gtk_box_pack_end(GTK_BOX(bbox), b->cancel, FALSE, FALSE, 10);
2460 gtk_widget_show(bbox);
2462 b->url = gtk_entry_new();
2463 b->text = gtk_entry_new();
2465 hbox = gtk_hbox_new(FALSE, 5);
2466 label = gtk_label_new(_("URL"));
2467 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2468 gtk_box_pack_end(GTK_BOX(hbox), b->url, FALSE, FALSE, 5);
2469 gtk_widget_show(label);
2470 gtk_widget_show(hbox);
2471 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
2473 hbox = gtk_hbox_new(FALSE, 5);
2474 label = gtk_label_new(_("Description"));
2475 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2476 gtk_box_pack_end(GTK_BOX(hbox), b->text, FALSE, FALSE, 5);
2477 gtk_widget_show(label);
2478 gtk_widget_show(hbox);
2479 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
2481 gtk_widget_show(b->url);
2482 gtk_widget_show(b->text);
2483 gtk_widget_show(frame);
2484 gtk_widget_show(fbox);
2486 gtk_container_add(GTK_CONTAINER(frame), vbox);
2487 gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 5);
2488 gtk_box_pack_start(GTK_BOX(fbox), bbox, TRUE, TRUE, 5);
2489 gtk_widget_show(vbox);
2491 gtk_signal_connect(GTK_OBJECT(c->link_dialog), "destroy",
2492 GTK_SIGNAL_FUNC(cancel_link), c);
2493 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(cancel_link), c);
2494 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(do_add_link), b);
2496 gtk_container_add(GTK_CONTAINER(c->link_dialog), fbox);
2497 gtk_container_border_width(GTK_CONTAINER(c->link_dialog), 10);
2498 gtk_window_set_title(GTK_WINDOW(c->link_dialog), _("Gaim - Add URL"));
2499 gtk_window_set_focus(GTK_WINDOW(c->link_dialog), b->url);
2500 b->window = c->link_dialog;
2501 b->toggle = linky;
2502 b->entry = c->entry;
2503 gtk_widget_realize(c->link_dialog);
2504 aol_icon(c->link_dialog->window);
2508 gtk_widget_show(c->link_dialog);
2509 gdk_window_raise(c->link_dialog->window);
2513 /*------------------------------------------------------*/
2514 /* Color Selection Dialog */
2515 /*------------------------------------------------------*/
2517 static GtkWidget *fgcseld = NULL;
2518 static GtkWidget *bgcseld = NULL;
2520 void cancel_fgcolor(GtkWidget *widget, struct conversation *c)
2522 if (c->fgcolorbtn && widget) {
2523 set_state_lock(1);
2524 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->fgcolorbtn), FALSE);
2525 set_state_lock(0);
2527 dialogwindows = g_list_remove(dialogwindows, c->fg_color_dialog);
2528 gtk_widget_destroy(c->fg_color_dialog);
2529 c->fg_color_dialog = NULL;
2532 void cancel_bgcolor(GtkWidget *widget, struct conversation *c)
2534 if (c->bgcolorbtn && widget) {
2535 set_state_lock(1);
2536 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->bgcolorbtn), FALSE);
2537 set_state_lock(0);
2539 dialogwindows = g_list_remove(dialogwindows, c->bg_color_dialog);
2540 gtk_widget_destroy(c->bg_color_dialog);
2541 c->bg_color_dialog = NULL;
2544 void do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
2546 gdouble color[3];
2547 GdkColor text_color;
2548 struct conversation *c;
2549 char *open_tag;
2551 open_tag = g_malloc(30);
2553 gtk_color_selection_get_color(colorsel, color);
2555 c = gtk_object_get_user_data(GTK_OBJECT(colorsel));
2556 /* GTK_IS_EDITABLE(c->entry); huh? */
2558 text_color.red = ((guint16)(color[0] * 65535)) >> 8;
2559 text_color.green = ((guint16)(color[1] * 65535)) >> 8;
2560 text_color.blue = ((guint16)(color[2] * 65535)) >> 8;
2562 c->fgcol = text_color;
2563 c->hasfg = 1;
2564 g_snprintf(open_tag, 23, "<FONT COLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green,
2565 text_color.blue);
2566 surround(c->entry, open_tag, "</FONT>");
2567 debug_printf("#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue);
2568 g_free(open_tag);
2569 cancel_fgcolor(NULL, c);
2572 void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
2574 gdouble color[3];
2575 GdkColor text_color;
2576 struct conversation *c;
2577 char *open_tag;
2579 open_tag = g_malloc(30);
2581 gtk_color_selection_get_color(colorsel, color);
2583 c = gtk_object_get_user_data(GTK_OBJECT(colorsel));
2584 /* GTK_IS_EDITABLE(c->entry); huh? */
2586 text_color.red = ((guint16)(color[0] * 65535)) >> 8;
2587 text_color.green = ((guint16)(color[1] * 65535)) >> 8;
2588 text_color.blue = ((guint16)(color[2] * 65535)) >> 8;
2590 c->bgcol = text_color;
2591 c->hasbg = 1;
2592 g_snprintf(open_tag, 25, "<BODY BGCOLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green,
2593 text_color.blue);
2594 surround(c->entry, open_tag, "</BODY>");
2595 debug_printf("#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue);
2596 g_free(open_tag);
2597 cancel_bgcolor(NULL, c);
2600 static void destroy_colorsel(GtkWidget *w, gpointer d)
2602 if (d) {
2603 gtk_widget_destroy(fgcseld);
2604 fgcseld = NULL;
2605 } else {
2606 gtk_widget_destroy(bgcseld);
2607 bgcseld = NULL;
2611 static void apply_color_dlg(GtkWidget *w, gpointer d)
2613 gdouble color[3];
2614 if ((int)d == 1) {
2615 gtk_color_selection_get_color(GTK_COLOR_SELECTION
2616 (GTK_COLOR_SELECTION_DIALOG(fgcseld)->colorsel), color);
2617 destroy_colorsel(NULL, (void *)1);
2619 fgcolor.red = ((guint16)(color[0] * 65535)) >> 8;
2620 fgcolor.green = ((guint16)(color[1] * 65535)) >> 8;
2621 fgcolor.blue = ((guint16)(color[2] * 65535)) >> 8;
2622 update_color(NULL, pref_fg_picture);
2623 update_convo_color(TRUE);
2624 } else {
2625 gtk_color_selection_get_color(GTK_COLOR_SELECTION
2626 (GTK_COLOR_SELECTION_DIALOG(bgcseld)->colorsel), color);
2627 destroy_colorsel(NULL, (void *)0);
2629 bgcolor.red = ((guint16)(color[0] * 65535)) >> 8;
2630 bgcolor.green = ((guint16)(color[1] * 65535)) >> 8;
2631 bgcolor.blue = ((guint16)(color[2] * 65535)) >> 8;
2632 update_color(NULL, pref_bg_picture);
2633 update_convo_color(FALSE);
2637 void show_fgcolor_dialog(struct conversation *c, GtkWidget *color)
2639 GtkWidget *colorsel;
2640 gdouble fgclr[3];
2642 if (color == NULL) { /* we came from the prefs */
2643 if (fgcseld)
2644 return;
2645 fgclr[0] = (gdouble)(fgcolor.red) / 255;
2646 fgclr[1] = (gdouble)(fgcolor.green) / 255;
2647 fgclr[2] = (gdouble)(fgcolor.blue) / 255;
2649 fgcseld = gtk_color_selection_dialog_new(_("Select Text Color"));
2650 gtk_color_selection_set_color(GTK_COLOR_SELECTION
2651 (GTK_COLOR_SELECTION_DIALOG(fgcseld)->colorsel), fgclr);
2652 gtk_signal_connect(GTK_OBJECT(fgcseld), "delete_event",
2653 GTK_SIGNAL_FUNC(destroy_colorsel), (void *)1);
2654 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(fgcseld)->cancel_button),
2655 "clicked", GTK_SIGNAL_FUNC(destroy_colorsel), (void *)1);
2656 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(fgcseld)->ok_button), "clicked",
2657 GTK_SIGNAL_FUNC(apply_color_dlg), (void *)1);
2658 gtk_widget_realize(fgcseld);
2659 aol_icon(fgcseld->window);
2660 gtk_widget_show(fgcseld);
2661 gdk_window_raise(fgcseld->window);
2662 return;
2665 if (!c->fg_color_dialog) {
2666 fgclr[0] = (gdouble)(c->fgcol.red) / 255;
2667 fgclr[1] = (gdouble)(c->fgcol.green) / 255;
2668 fgclr[2] = (gdouble)(c->fgcol.blue) / 255;
2670 c->fg_color_dialog = gtk_color_selection_dialog_new(_("Select Text Color"));
2671 colorsel = GTK_COLOR_SELECTION_DIALOG(c->fg_color_dialog)->colorsel;
2672 gtk_color_selection_set_color(GTK_COLOR_SELECTION(colorsel), fgclr);
2673 gtk_object_set_user_data(GTK_OBJECT(colorsel), c);
2675 gtk_signal_connect(GTK_OBJECT(c->fg_color_dialog), "delete_event",
2676 GTK_SIGNAL_FUNC(delete_event_dialog), c);
2677 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->fg_color_dialog)->ok_button),
2678 "clicked", GTK_SIGNAL_FUNC(do_fgcolor), colorsel);
2679 gtk_signal_connect(GTK_OBJECT
2680 (GTK_COLOR_SELECTION_DIALOG(c->fg_color_dialog)->cancel_button),
2681 "clicked", GTK_SIGNAL_FUNC(cancel_fgcolor), c);
2683 gtk_widget_realize(c->fg_color_dialog);
2684 aol_icon(c->fg_color_dialog->window);
2687 gtk_widget_show(c->fg_color_dialog);
2688 gdk_window_raise(c->fg_color_dialog->window);
2691 void show_bgcolor_dialog(struct conversation *c, GtkWidget *color)
2693 GtkWidget *colorsel;
2694 gdouble bgclr[3];
2696 if (color == NULL) { /* we came from the prefs */
2697 if (bgcseld)
2698 return;
2699 bgclr[0] = (gdouble)(bgcolor.red) / 255;
2700 bgclr[1] = (gdouble)(bgcolor.green) / 255;
2701 bgclr[2] = (gdouble)(bgcolor.blue) / 255;
2703 bgcseld = gtk_color_selection_dialog_new(_("Select Background Color"));
2704 gtk_color_selection_set_color(GTK_COLOR_SELECTION
2705 (GTK_COLOR_SELECTION_DIALOG(bgcseld)->colorsel), bgclr);
2706 gtk_signal_connect(GTK_OBJECT(bgcseld), "delete_event",
2707 GTK_SIGNAL_FUNC(destroy_colorsel), NULL);
2708 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(bgcseld)->cancel_button),
2709 "clicked", GTK_SIGNAL_FUNC(destroy_colorsel), NULL);
2710 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(bgcseld)->ok_button), "clicked",
2711 GTK_SIGNAL_FUNC(apply_color_dlg), (void *)2);
2712 gtk_widget_realize(bgcseld);
2713 aol_icon(bgcseld->window);
2714 gtk_widget_show(bgcseld);
2715 gdk_window_raise(bgcseld->window);
2716 return;
2719 if (!c->bg_color_dialog) {
2720 bgclr[0] = (gdouble)(c->bgcol.red) / 255;
2721 bgclr[1] = (gdouble)(c->bgcol.green) / 255;
2722 bgclr[2] = (gdouble)(c->bgcol.blue) / 255;
2724 c->bg_color_dialog = gtk_color_selection_dialog_new(_("Select Text Color"));
2725 colorsel = GTK_COLOR_SELECTION_DIALOG(c->bg_color_dialog)->colorsel;
2726 gtk_color_selection_set_color(GTK_COLOR_SELECTION(colorsel), bgclr);
2727 gtk_object_set_user_data(GTK_OBJECT(colorsel), c);
2729 gtk_signal_connect(GTK_OBJECT(c->bg_color_dialog), "delete_event",
2730 GTK_SIGNAL_FUNC(delete_event_dialog), c);
2731 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->bg_color_dialog)->ok_button),
2732 "clicked", GTK_SIGNAL_FUNC(do_bgcolor), colorsel);
2733 gtk_signal_connect(GTK_OBJECT
2734 (GTK_COLOR_SELECTION_DIALOG(c->bg_color_dialog)->cancel_button),
2735 "clicked", GTK_SIGNAL_FUNC(cancel_bgcolor), c);
2737 gtk_widget_realize(c->bg_color_dialog);
2738 aol_icon(c->bg_color_dialog->window);
2741 gtk_widget_show(c->bg_color_dialog);
2742 gdk_window_raise(c->bg_color_dialog->window);
2745 /*------------------------------------------------------------------------*/
2746 /* Font Selection Dialog */
2747 /*------------------------------------------------------------------------*/
2749 void cancel_font(GtkWidget *widget, struct conversation *c)
2751 if (c->font && widget) {
2752 set_state_lock(1);
2753 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->font), FALSE);
2754 set_state_lock(0);
2756 dialogwindows = g_list_remove(dialogwindows, c->font_dialog);
2757 gtk_widget_destroy(c->font_dialog);
2758 c->font_dialog = NULL;
2761 void apply_font(GtkWidget *widget, GtkFontSelection *fontsel)
2763 /* this could be expanded to include font size, weight, etc.
2764 but for now only works with font face */
2765 int i, j = 0, k = 0;
2766 char *fontname;
2767 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(fontsel));
2769 if (c) {
2770 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel));
2772 set_font_face(fontname, c);
2773 } else {
2774 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel));
2776 for (i = 0; i < strlen(fontname); i++) {
2777 if (fontname[i] == '-') {
2778 if (++j > 2)
2779 break;
2780 } else if (j == 2)
2781 fontface[k++] = fontname[i];
2783 fontface[k] = '\0';
2785 g_snprintf(fontxfld, sizeof(fontxfld), "%s", fontname);
2788 cancel_font(NULL, c);
2791 static GtkWidget *fontseld;
2793 void destroy_fontsel(GtkWidget *w, gpointer d)
2795 gtk_widget_destroy(fontseld);
2796 fontseld = NULL;
2799 void apply_font_dlg(GtkWidget *w, GtkWidget *f)
2801 int i, j = 0, k = 0;
2802 char *fontname;
2804 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontseld));
2805 destroy_fontsel(0, 0);
2806 for (i = 0; i < strlen(fontname); i++) {
2807 if (fontname[i] == '-') {
2808 if (++j > 2)
2809 break;
2810 } else if (j == 2)
2811 fontface[k++] = fontname[i];
2813 fontface[k] = '\0';
2814 g_snprintf(fontxfld, sizeof(fontxfld), "%s", fontname);
2815 update_convo_font();
2818 void show_font_dialog(struct conversation *c, GtkWidget *font)
2821 if (!font) { /* we came from the prefs dialog */
2822 if (fontseld)
2823 return;
2824 fontseld = gtk_font_selection_dialog_new(_("Select Font"));
2825 if (fontxfld[0]) {
2826 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
2827 fontxfld);
2828 } else {
2829 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
2830 DEFAULT_FONT_XFLD);
2833 gtk_object_set_user_data(GTK_OBJECT(fontseld), NULL);
2834 gtk_signal_connect(GTK_OBJECT(fontseld), "delete_event",
2835 GTK_SIGNAL_FUNC(destroy_fontsel), NULL);
2836 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->cancel_button),
2837 "clicked", GTK_SIGNAL_FUNC(destroy_fontsel), NULL);
2838 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->ok_button), "clicked",
2839 GTK_SIGNAL_FUNC(apply_font_dlg), NULL);
2840 gtk_widget_realize(fontseld);
2841 aol_icon(fontseld->window);
2842 gtk_widget_show(fontseld);
2843 gdk_window_raise(fontseld->window);
2844 return;
2847 if (!c->font_dialog) {
2848 c->font_dialog = gtk_font_selection_dialog_new(_("Select Font"));
2850 if (font)
2851 gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), c);
2852 else
2853 gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), NULL);
2855 if (c->fontxfld[0]) {
2856 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(c->font_dialog),
2857 c->fontxfld);
2858 } else {
2859 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(c->font_dialog),
2860 DEFAULT_FONT_XFLD);
2863 gtk_signal_connect(GTK_OBJECT(c->font_dialog), "delete_event",
2864 GTK_SIGNAL_FUNC(delete_event_dialog), c);
2865 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->ok_button),
2866 "clicked", GTK_SIGNAL_FUNC(apply_font), c->font_dialog);
2867 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->cancel_button),
2868 "clicked", GTK_SIGNAL_FUNC(cancel_font), c);
2870 gtk_widget_realize(c->font_dialog);
2872 aol_icon(c->font_dialog->window);
2874 gtk_widget_show(c->font_dialog);
2875 gdk_window_raise(c->font_dialog->window);
2878 /*------------------------------------------------------------------------*/
2879 /* The dialog for import/export */
2880 /*------------------------------------------------------------------------*/
2882 static void do_import_dialog(GtkWidget *w, struct gaim_connection *gc)
2884 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(importdialog));
2885 if (file_is_dir(file, importdialog)) {
2886 return;
2888 if (g_slist_find(connections, importgc)) {
2889 do_import(importgc, file);
2890 do_export(importgc);
2892 destroy_dialog(NULL, importdialog);
2895 static void set_import_gc(gpointer data, struct gaim_connection *gc)
2897 importgc = gc;
2900 static void create_import_dropdown(GtkFileSelection *fs)
2902 GtkWidget *hbox;
2903 GtkWidget *label;
2904 GSList *g = connections;
2905 struct gaim_connection *c;
2906 GtkWidget *optmenu;
2907 GtkWidget *menu;
2908 char buf[256];
2909 GtkWidget *opt;
2911 if (!connections)
2912 return;
2913 importgc = connections->data;
2914 if (!connections->next)
2915 return;
2917 hbox = gtk_hbox_new(FALSE, 0);
2918 gtk_box_pack_end(GTK_BOX(fs->action_area), hbox, FALSE, FALSE, 0);
2919 gtk_widget_show(hbox);
2921 optmenu = gtk_option_menu_new();
2922 gtk_box_pack_end(GTK_BOX(hbox), optmenu, FALSE, FALSE, 5);
2923 gtk_widget_show(optmenu);
2925 label = gtk_label_new(_("Import to:"));
2926 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2927 gtk_widget_show(label);
2929 menu = gtk_menu_new();
2931 while (g) {
2932 c = (struct gaim_connection *)g->data;
2933 g_snprintf(buf, sizeof buf, "%s (%s)", c->username, c->prpl->name());
2934 opt = gtk_menu_item_new_with_label(buf);
2935 gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(set_import_gc), c);
2936 gtk_widget_show(opt);
2937 gtk_menu_append(GTK_MENU(menu), opt);
2938 g = g->next;
2941 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
2942 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0);
2945 void show_import_dialog()
2947 char *buf = g_malloc(BUF_LEN);
2948 if (!importdialog) {
2949 importdialog = gtk_file_selection_new(_("Gaim - Import Buddy List"));
2951 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(importdialog));
2953 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("HOME"));
2955 gtk_file_selection_set_filename(GTK_FILE_SELECTION(importdialog), buf);
2956 gtk_signal_connect(GTK_OBJECT(importdialog), "destroy",
2957 GTK_SIGNAL_FUNC(destroy_dialog), importdialog);
2959 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(importdialog)->ok_button),
2960 "clicked", GTK_SIGNAL_FUNC(do_import_dialog), NULL);
2961 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(importdialog)->cancel_button),
2962 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), importdialog);
2964 create_import_dropdown(GTK_FILE_SELECTION(importdialog));
2967 g_free(buf);
2968 gtk_widget_show(importdialog);
2969 gdk_window_raise(importdialog->window);
2972 /*------------------------------------------------------------------------*/
2973 /* The dialog for new away messages */
2974 /*------------------------------------------------------------------------*/
2976 static struct away_message *save_away_message(struct create_away *ca)
2978 struct away_message *am;
2979 guint text_len;
2980 gchar *away_message;
2982 if (!ca->mess)
2983 am = g_new0(struct away_message, 1);
2984 else {
2985 #ifdef USE_APPLET
2986 char *awayname = g_strdup_printf("away/%s", ca->mess->name);
2987 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname);
2988 g_free(awayname);
2989 #endif
2990 am = ca->mess;
2993 g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry)));
2994 text_len = gtk_text_get_length(GTK_TEXT(ca->text));
2995 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len);
2997 g_snprintf(am->message, sizeof(am->message), "%s", away_message);
2998 g_free(away_message);
3000 if (!ca->mess) {
3001 away_messages = g_slist_insert_sorted(away_messages, am, sort_awaymsg_list);
3004 save_prefs();
3005 do_away_menu();
3006 if (prefs_away_list != NULL)
3007 gtk_list_select_item(GTK_LIST(prefs_away_list), g_slist_index(away_messages, am));
3009 return am;
3012 int check_away_mess(struct create_away *ca, int type)
3014 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) {
3015 /* We shouldn't allow a blank title */
3016 do_error_dialog(_("You cannot create an away message with a blank title"),
3017 _("Gaim - Error"));
3018 return 0;
3021 if ((gtk_text_get_length(GTK_TEXT(ca->text)) == 0) && (type <= 1)) {
3022 /* We shouldn't allow a blank message */
3023 do_error_dialog(_("You cannot create an empty away message"), _("Gaim - Error"));
3024 return 0;
3027 return 1;
3030 void save_away_mess(GtkWidget *widget, struct create_away *ca)
3032 if (!check_away_mess(ca, 1))
3033 return;
3035 save_away_message(ca);
3036 destroy_dialog(NULL, ca->window);
3037 g_free(ca);
3040 void use_away_mess(GtkWidget *widget, struct create_away *ca)
3042 static struct away_message am;
3043 guint text_len;
3044 gchar *away_message;
3046 if (!check_away_mess(ca, 0))
3047 return;
3049 g_snprintf(am.name, sizeof(am.name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry)));
3050 text_len = gtk_text_get_length(GTK_TEXT(ca->text));
3051 if (text_len < 0)
3052 return;
3053 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len);
3055 g_snprintf(am.message, sizeof(am.message), "%s", away_message);
3056 g_free(away_message);
3058 do_away_message(NULL, &am);
3060 destroy_dialog(NULL, ca->window);
3061 g_free(ca);
3064 void su_away_mess(GtkWidget *widget, struct create_away *ca)
3066 if (!check_away_mess(ca, 1))
3067 return;
3068 do_away_message(NULL, save_away_message(ca));
3069 destroy_dialog(NULL, ca->window);
3070 g_free(ca);
3073 void create_away_mess(GtkWidget *widget, void *dummy)
3075 GtkWidget *hbox;
3076 GtkWidget *titlebox;
3077 GtkWidget *tbox;
3078 GtkWidget *sw;
3079 GtkWidget *label;
3080 GtkWidget *frame;
3081 GtkWidget *fbox;
3082 GtkWidget *button;
3084 struct create_away *ca = g_new0(struct create_away, 1);
3086 /* Set up window */
3087 GAIM_DIALOG(ca->window);
3088 gtk_widget_set_usize(ca->window, -1, 250);
3089 gtk_container_border_width(GTK_CONTAINER(ca->window), 5);
3090 gtk_window_set_wmclass(GTK_WINDOW(ca->window), "away_mess", "Gaim");
3091 gtk_window_set_title(GTK_WINDOW(ca->window), _("Gaim - New away message"));
3092 gtk_signal_connect(GTK_OBJECT(ca->window), "delete_event",
3093 GTK_SIGNAL_FUNC(destroy_dialog), ca->window);
3094 gtk_widget_realize(ca->window);
3095 aol_icon(ca->window->window);
3097 tbox = gtk_vbox_new(FALSE, 5);
3098 gtk_container_add(GTK_CONTAINER(ca->window), tbox);
3099 gtk_widget_show(tbox);
3101 frame = gtk_frame_new(_("New away message"));
3102 gtk_box_pack_start(GTK_BOX(tbox), frame, TRUE, TRUE, 0);
3103 gtk_widget_show(frame);
3105 fbox = gtk_vbox_new(FALSE, 5);
3106 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
3107 gtk_container_add(GTK_CONTAINER(frame), fbox);
3108 gtk_widget_show(fbox);
3110 titlebox = gtk_hbox_new(FALSE, 5);
3111 gtk_box_pack_start(GTK_BOX(fbox), titlebox, FALSE, FALSE, 0);
3112 gtk_widget_show(titlebox);
3114 label = gtk_label_new(_("Away title: "));
3115 gtk_box_pack_start(GTK_BOX(titlebox), label, FALSE, FALSE, 0);
3116 gtk_widget_show(label);
3118 ca->entry = gtk_entry_new();
3119 gtk_box_pack_start(GTK_BOX(titlebox), ca->entry, TRUE, TRUE, 0);
3120 gtk_widget_grab_focus(ca->entry);
3121 gtk_widget_show(ca->entry);
3123 sw = gtk_scrolled_window_new(NULL, NULL);
3124 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
3125 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
3126 gtk_box_pack_start(GTK_BOX(fbox), sw, TRUE, TRUE, 0);
3127 gtk_widget_show(sw);
3129 ca->text = gtk_text_new(NULL, NULL);
3130 gtk_text_set_word_wrap(GTK_TEXT(ca->text), TRUE);
3131 gtk_text_set_editable(GTK_TEXT(ca->text), TRUE);
3132 gtk_container_add(GTK_CONTAINER(sw), ca->text);
3133 gtk_widget_show(ca->text);
3135 if (dummy && GTK_LIST(prefs_away_list)->selection) {
3136 GtkWidget *item = GTK_LIST(prefs_away_list)->selection->data;
3137 struct away_message *amt = gtk_object_get_user_data(GTK_OBJECT(item));
3138 int pos = 0;
3139 gtk_entry_set_text(GTK_ENTRY(ca->entry), amt->name);
3140 gtk_editable_insert_text(GTK_EDITABLE(ca->text), amt->message,
3141 strlen(amt->message), &pos);
3142 ca->mess = amt;
3145 hbox = gtk_hbox_new(FALSE, 5);
3146 gtk_box_pack_start(GTK_BOX(tbox), hbox, FALSE, FALSE, 0);
3147 gtk_widget_show(hbox);
3149 button = picture_button(ca->window, _("Cancel"), cancel_xpm);
3150 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), ca->window);
3151 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
3153 button = picture_button(ca->window, _("Use"), gnome_preferences_xpm);
3154 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(use_away_mess), ca);
3155 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
3157 button = picture_button(ca->window, _("Save & Use"), add_xpm);
3158 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(su_away_mess), ca);
3159 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
3161 button = picture_button(ca->window, _("Save"), ok_xpm);
3162 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(save_away_mess), ca);
3163 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
3165 gtk_widget_show(ca->window);
3168 /* smiley dialog */
3170 void close_smiley_dialog(GtkWidget *widget, struct conversation *c)
3172 if (c->smiley) {
3173 set_state_lock(1);
3174 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->smiley), FALSE);
3175 set_state_lock(0);
3177 dialogwindows = g_list_remove(dialogwindows, c->smiley_dialog);
3178 gtk_widget_destroy(c->smiley_dialog);
3179 c->smiley_dialog = NULL;
3182 void set_smiley_array(GtkWidget *widget, int smiley_type)
3184 int i;
3186 for (i = 0; i < FACE_TOTAL; i++)
3187 smiley_array[i] = 0;
3189 smiley_array[smiley_type] = 1;
3191 return;
3194 void insert_smiley_text(GtkWidget *widget, struct conversation *c)
3196 char *smiley_text;
3197 int i;
3199 for (i = 0; i < FACE_TOTAL; i++)
3200 if (smiley_array[i] == 1)
3201 break;
3203 switch (i) {
3204 case (FACE_ANGEL):
3205 smiley_text = g_strndup("O:-)", strlen("O:-)"));
3206 break;
3207 case (FACE_BIGSMILE):
3208 smiley_text = g_strndup(":-D", strlen(":-D"));
3209 break;
3210 case (FACE_BURP):
3211 smiley_text = g_strndup(":-!", strlen(":-!"));
3212 break;
3213 case (FACE_CROSSEDLIPS):
3214 smiley_text = g_strndup(":-X", strlen(":-X"));
3215 break;
3216 case (FACE_CRY):
3217 smiley_text = g_strndup(":'(", strlen(":'("));
3218 break;
3219 case (FACE_EMBARRASSED):
3220 smiley_text = g_strndup(":-[", strlen(":-["));
3221 break;
3222 case (FACE_KISS):
3223 smiley_text = g_strndup(":-*", strlen(":-*"));
3224 break;
3225 case (FACE_MONEYMOUTH):
3226 smiley_text = g_strndup(":-$", strlen(":-$"));
3227 break;
3228 case (FACE_SAD):
3229 smiley_text = g_strndup(":-(", strlen(":-("));
3230 break;
3231 case (FACE_SCREAM):
3232 smiley_text = g_strndup("=-O", strlen("=-O"));
3233 break;
3234 case (FACE_SMILE):
3235 smiley_text = g_strndup(":-)", strlen(":-)"));
3236 break;
3237 case (FACE_SMILE8):
3238 smiley_text = g_strndup("8-)", strlen("8-)"));
3239 break;
3240 case (FACE_THINK):
3241 smiley_text = g_strndup(":-/", strlen(":-/"));
3242 break;
3243 case (FACE_TONGUE):
3244 smiley_text = g_strndup(":-P", strlen(":-p"));
3245 break;
3246 case (FACE_WINK):
3247 smiley_text = g_strndup(";-)", strlen(";-)"));
3248 break;
3249 case (FACE_YELL):
3250 smiley_text = g_strndup(">:o", strlen(">:o"));
3251 break;
3252 default:
3253 smiley_text = g_strndup(":-)", strlen(":-)"));
3254 break;
3257 /* surround(c->entry, smiley_text, ""); */
3259 if (GTK_OLD_EDITABLE(c->entry)->has_selection) {
3260 int finish = GTK_OLD_EDITABLE(c->entry)->selection_end_pos;
3261 gtk_editable_insert_text(GTK_EDITABLE(c->entry),
3262 smiley_text, strlen(smiley_text), &finish);
3263 } else {
3264 int pos = GTK_OLD_EDITABLE(c->entry)->current_pos;
3265 gtk_editable_insert_text(GTK_EDITABLE(c->entry), smiley_text, strlen(smiley_text), &pos);
3268 g_free(smiley_text);
3270 close_smiley_dialog(NULL, c);
3272 return;
3275 static void toolbar_add_smiley(struct conversation *c, GtkWidget *bar, char **xpm, GtkWidget *win,
3276 int face)
3278 GtkWidget *tpm;
3279 GdkBitmap *mask;
3280 GdkPixmap *dpm;
3281 GtkWidget *button;
3283 dpm = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, xpm);
3284 tpm = gtk_pixmap_new(dpm, mask);
3285 gtk_widget_show(tpm);
3286 gdk_pixmap_unref(dpm);
3287 gdk_bitmap_unref(mask);
3288 button =
3289 gtk_toolbar_append_element(GTK_TOOLBAR(bar), GTK_TOOLBAR_CHILD_BUTTON, NULL, NULL, NULL,
3290 NULL, tpm, GTK_SIGNAL_FUNC(set_smiley_array), (int *)face);
3291 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(insert_smiley_text), c);
3293 /* these look really weird with borders */
3294 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
3297 void show_smiley_dialog(struct conversation *c, GtkWidget *widget)
3299 GtkWidget *dialog;
3300 GtkWidget *vbox, *smiley_box_1, *smiley_box_2, *smiley_box_3, *smiley_box_4;
3301 GtkWidget *win;
3302 GtkWidget *bbox;
3304 if (c->smiley_dialog)
3305 return;
3307 win = c->window;
3309 GAIM_DIALOG(dialog);
3310 gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, TRUE);
3311 gtk_window_set_wmclass(GTK_WINDOW(dialog), "smiley_dialog", "Gaim");
3312 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
3314 /* setup boxes */
3315 vbox = gtk_vbox_new(TRUE, 5);
3316 bbox = gtk_hbox_new(FALSE, 5);
3318 smiley_box_1 = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
3319 smiley_box_2 = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
3320 smiley_box_3 = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
3321 smiley_box_4 = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
3323 /* setup buttons */
3325 /* pack buttons */
3326 toolbar_add_smiley(c, smiley_box_1, angel_xpm, win, FACE_ANGEL);
3327 toolbar_add_smiley(c, smiley_box_1, bigsmile_xpm, win, FACE_BIGSMILE);
3328 toolbar_add_smiley(c, smiley_box_1, burp_xpm, win, FACE_BURP);
3329 toolbar_add_smiley(c, smiley_box_1, crossedlips_xpm, win, FACE_CROSSEDLIPS);
3331 toolbar_add_smiley(c, smiley_box_2, cry_xpm, win, FACE_CRY);
3332 toolbar_add_smiley(c, smiley_box_2, embarrassed_xpm, win, FACE_EMBARRASSED);
3333 toolbar_add_smiley(c, smiley_box_2, kiss_xpm, win, FACE_KISS);
3334 toolbar_add_smiley(c, smiley_box_2, moneymouth_xpm, win, FACE_MONEYMOUTH);
3336 toolbar_add_smiley(c, smiley_box_3, sad_xpm, win, FACE_SAD);
3337 toolbar_add_smiley(c, smiley_box_3, scream_xpm, win, FACE_SCREAM);
3338 toolbar_add_smiley(c, smiley_box_3, smile_xpm, win, FACE_SMILE);
3339 toolbar_add_smiley(c, smiley_box_3, smile8_xpm, win, FACE_SMILE8);
3341 toolbar_add_smiley(c, smiley_box_4, think_xpm, win, FACE_THINK);
3342 toolbar_add_smiley(c, smiley_box_4, tongue_xpm, win, FACE_TONGUE);
3343 toolbar_add_smiley(c, smiley_box_4, wink_xpm, win, FACE_WINK);
3344 toolbar_add_smiley(c, smiley_box_4, yell_xpm, win, FACE_YELL);
3346 /* pack containers */
3347 gtk_box_pack_start(GTK_BOX(vbox), smiley_box_1, TRUE, TRUE, 0);
3348 gtk_box_pack_start(GTK_BOX(vbox), smiley_box_2, TRUE, TRUE, 0);
3349 gtk_box_pack_start(GTK_BOX(vbox), smiley_box_3, TRUE, TRUE, 0);
3350 gtk_box_pack_start(GTK_BOX(vbox), smiley_box_4, TRUE, TRUE, 0);
3352 gtk_container_add(GTK_CONTAINER(dialog), vbox);
3353 gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
3355 /* connect signals */
3356 gtk_object_set_user_data(GTK_OBJECT(dialog), "smiley dialog");
3357 gtk_signal_connect(GTK_OBJECT(dialog), "delete_event", GTK_SIGNAL_FUNC(delete_event_dialog), c);
3359 /* show everything */
3360 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!"));
3361 gtk_widget_show_all(dialog);
3363 c->smiley_dialog = dialog;
3365 return;
3368 static void do_alias_bud(GtkWidget *w, struct buddy *b)
3370 char *al = gtk_entry_get_text(GTK_ENTRY(aliasname));
3371 g_snprintf(b->show, sizeof(b->show), "%s", (al && strlen(al)) ? al : b->name);
3372 handle_buddy_rename(b, b->name);
3373 destroy_dialog(aliasdlg, aliasdlg);
3376 void alias_dialog_bud(struct buddy *b)
3378 GtkWidget *frame;
3379 GtkWidget *vbox;
3380 GtkWidget *bbox;
3381 GtkWidget *cancel;
3382 static GtkWidget *add = NULL;
3383 GtkWidget *label;
3384 GtkWidget *topbox;
3385 static int a, c;
3387 if (aliasdlg)
3388 gtk_widget_destroy(aliasdlg);
3390 GAIM_DIALOG(aliasdlg);
3391 gtk_window_set_policy(GTK_WINDOW(aliasdlg), FALSE, FALSE, TRUE);
3392 gtk_window_set_wmclass(GTK_WINDOW(aliasdlg), "alias_dialog", "Gaim");
3393 gtk_widget_realize(aliasdlg);
3394 dialogwindows = g_list_prepend(dialogwindows, aliasdlg);
3396 bbox = gtk_hbox_new(TRUE, 10);
3397 topbox = gtk_hbox_new(FALSE, 5);
3398 vbox = gtk_vbox_new(FALSE, 5);
3400 aliasentry = gtk_entry_new();
3401 aliasname = gtk_entry_new();
3402 /* Put the buttons in the box */
3404 add = picture_button(aliasdlg, _("Alias"), add_xpm);
3406 cancel = picture_button(aliasdlg, _("Cancel"), cancel_xpm);
3408 gtk_box_pack_start(GTK_BOX(bbox), add, FALSE, FALSE, 5);
3409 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
3411 frame = gtk_frame_new(NULL);
3412 gtk_frame_set_label(GTK_FRAME(frame), _("Alias Buddy"));
3414 label = gtk_label_new(_("Buddy"));
3415 gtk_widget_show(label);
3416 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
3417 gtk_box_pack_start(GTK_BOX(topbox), aliasentry, FALSE, FALSE, 5);
3418 gtk_entry_set_editable(GTK_ENTRY(aliasentry), FALSE);
3419 label = gtk_label_new(_("Alias"));
3420 gtk_widget_show(label);
3421 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
3422 gtk_box_pack_start(GTK_BOX(topbox), aliasname, FALSE, FALSE, 5);
3424 gtk_entry_set_text(GTK_ENTRY(aliasentry), b->name);
3425 gtk_entry_set_text(GTK_ENTRY(aliasname), b->show);
3427 /* And the boxes in the box */
3428 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5);
3429 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5);
3431 /* Handle closes right */
3432 gtk_signal_connect(GTK_OBJECT(aliasdlg), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), aliasdlg);
3433 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), aliasdlg);
3434 a = gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(do_alias_bud), b);
3435 c = gtk_signal_connect(GTK_OBJECT(aliasname), "activate", GTK_SIGNAL_FUNC(do_alias_bud), b);
3436 /* Finish up */
3437 gtk_widget_show(add);
3438 gtk_widget_show(cancel);
3439 gtk_widget_show(aliasentry);
3440 gtk_widget_show(aliasname);
3441 gtk_widget_show(topbox);
3442 gtk_widget_show(bbox);
3443 gtk_widget_show(vbox);
3444 gtk_widget_show(frame);
3445 gtk_window_set_title(GTK_WINDOW(aliasdlg), _("Gaim - Alias Buddy"));
3446 gtk_window_set_focus(GTK_WINDOW(aliasdlg), aliasentry);
3447 gtk_container_add(GTK_CONTAINER(frame), vbox);
3448 gtk_container_add(GTK_CONTAINER(aliasdlg), frame);
3449 gtk_container_set_border_width(GTK_CONTAINER(aliasdlg), 5);
3450 gtk_widget_realize(aliasdlg);
3451 aol_icon(aliasdlg->window);
3453 gtk_widget_show(aliasdlg);
3457 static gboolean dont_destroy(gpointer a, gpointer b, gpointer c)
3459 return TRUE;
3462 static void do_save_log(GtkWidget *w, GtkWidget *filesel)
3464 char *file;
3465 char path[PATHSIZE];
3466 char buf[BUF_LONG];
3467 char error[BUF_LEN];
3468 FILE *fp_old, *fp_new;
3469 char filename[PATHSIZE];
3470 char *name;
3471 char *tmp;
3473 name = gtk_object_get_user_data(GTK_OBJECT(filesel));
3474 tmp = gaim_user_dir();
3475 g_snprintf(filename, PATHSIZE, "%s/logs/%s%s", tmp,
3476 name ? normalize(name) : "system", name ? ".log" : "");
3477 g_free(tmp);
3479 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel));
3480 strncpy(path, file, PATHSIZE - 1);
3481 if (file_is_dir(path, filesel))
3482 return;
3484 if ((fp_new = fopen(path, "w")) == NULL) {
3485 g_snprintf(error, BUF_LONG,
3486 "Can't open file %s for writing - %s", path, strerror(errno));
3487 do_error_dialog(error, "Error");
3488 return;
3491 if ((fp_old = fopen(filename, "r")) == NULL) {
3492 g_snprintf(error, BUF_LONG,
3493 "Can't open file %s for reading - %s", filename, strerror(errno));
3494 do_error_dialog(error, "Error");
3495 fclose(fp_new);
3496 return;
3499 while (fgets(buf, BUF_LONG, fp_old))
3500 fputs(buf, fp_new);
3501 fclose(fp_old);
3502 fclose(fp_new);
3504 gtk_widget_destroy(filesel);
3506 return;
3509 static void show_save_log(GtkWidget *w, gchar *name)
3511 GtkWidget *filesel;
3512 gchar buf[BUF_LEN];
3514 g_snprintf(buf, BUF_LEN - 1, "%s/%s%s", getenv("HOME"),
3515 name ? normalize(name) : "system", name ? ".log" : "");
3517 filesel = gtk_file_selection_new(_("Gaim - Save Log File"));
3518 gtk_signal_connect(GTK_OBJECT(filesel), "delete_event",
3519 GTK_SIGNAL_FUNC(destroy_dialog), filesel);
3521 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(filesel));
3522 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), buf);
3523 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button),
3524 "clicked", GTK_SIGNAL_FUNC(do_save_log), filesel);
3525 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button),
3526 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), filesel);
3527 gtk_object_set_user_data(GTK_OBJECT(filesel), name);
3529 gtk_widget_realize(filesel);
3530 aol_icon(filesel->window);
3531 gtk_widget_show(filesel);
3533 return;
3536 static void do_clear_log_file(GtkWidget *w, gchar *name)
3538 gchar buf[256];
3539 gchar filename[256];
3540 GtkWidget *window;
3541 char *tmp;
3543 tmp = gaim_user_dir();
3544 g_snprintf(filename, 256, "%s/logs/%s%s", tmp,
3545 name ? normalize(name) : "system", name ? ".log" : "");
3546 g_free(tmp);
3548 if ((remove(filename)) == -1) {
3549 g_snprintf(buf, 256, _("Unable to remove file %s - %s"), filename, strerror(errno));
3550 do_error_dialog(buf, _("Error"));
3553 window = gtk_object_get_user_data(GTK_OBJECT(w));
3554 destroy_dialog(NULL, window);
3557 static void show_clear_log(GtkWidget *w, gchar *name)
3559 GtkWidget *window;
3560 GtkWidget *box;
3561 GtkWidget *hbox;
3562 GtkWidget *button;
3563 GtkWidget *label;
3564 GtkWidget *hsep;
3566 GAIM_DIALOG(window);
3567 gtk_window_set_wmclass(GTK_WINDOW(window), "dialog", "Gaim");
3568 gtk_container_set_border_width(GTK_CONTAINER(window), 10);
3569 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, TRUE);
3570 gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(destroy_dialog), window);
3571 gtk_widget_realize(window);
3572 aol_icon(window->window);
3574 box = gtk_vbox_new(FALSE, 5);
3575 gtk_container_add(GTK_CONTAINER(window), box);
3577 label = gtk_label_new(_("Really clear log?"));
3578 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 15);
3580 hsep = gtk_hseparator_new();
3581 gtk_box_pack_start(GTK_BOX(box), hsep, FALSE, FALSE, 0);
3583 hbox = gtk_hbox_new(FALSE, 0);
3584 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
3585 gtk_widget_show(hbox);
3587 button = picture_button(window, _("Cancel"), cancel_xpm);
3588 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), window);
3589 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5);
3590 gtk_widget_show(button);
3592 button = picture_button(window, _("Okay"), ok_xpm);
3593 gtk_object_set_user_data(GTK_OBJECT(button), gtk_object_get_user_data(GTK_OBJECT(w)));
3594 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_clear_log_file), name);
3595 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), window);
3596 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5);
3597 gtk_widget_show(button);
3599 gtk_widget_show_all(window);
3601 return;
3604 static void log_show_convo(GtkWidget *w, struct view_log *view)
3606 gchar buf[BUF_LONG];
3607 FILE *fp;
3608 char filename[256];
3609 int i=0;
3610 GString *string;
3611 guint block;
3613 string = g_string_new("");
3615 if (view->name) {
3616 char *tmp = gaim_user_dir();
3617 g_snprintf(filename, 256, "%s/logs/%s.log", tmp, normalize(view->name));
3618 g_free(tmp);
3619 } else {
3620 char *tmp = gaim_user_dir();
3621 g_snprintf(filename, 256, "%s/logs/system", tmp);
3622 g_free(tmp);
3624 if ((fp = fopen(filename, "r")) == NULL) {
3625 g_snprintf(buf, BUF_LONG, "Unable to open log file %s", filename);
3626 do_error_dialog(buf, "Error!");
3627 return;
3630 gtk_widget_set_sensitive(view->bbox, FALSE);
3631 gtk_signal_disconnect_by_func(GTK_OBJECT(view->window),
3632 GTK_SIGNAL_FUNC(destroy_dialog), view->window);
3633 block = gtk_signal_connect(GTK_OBJECT(view->window), "delete_event",
3634 GTK_SIGNAL_FUNC(dont_destroy), view->window);
3636 fseek(fp, view->offset, SEEK_SET);
3637 gtk_imhtml_clear(GTK_IMHTML(view->layout));
3639 while (gtk_events_pending())
3640 gtk_main_iteration();
3643 while (fgets(buf, BUF_LONG, fp) && !strstr(buf, "---- New C")) {
3644 i++;
3645 if (strlen(buf) >= 5 && (!strncmp(buf + strlen(buf) - 5, "<BR>\n", 5)))
3646 /* take off the \n */
3647 buf[strlen(buf) - 1] = '\0';
3649 /* don't lose the thirtieth line of conversation. thanks FeRD */
3650 g_string_append(string, buf);
3652 if (i == 30) {
3653 gtk_imhtml_append_text(GTK_IMHTML(view->layout), string->str, -1, view->options);
3654 g_string_free(string, TRUE);
3655 string = g_string_new("");
3656 /* you can't have these anymore. if someone clicks on another item while one is
3657 * drawing, it will try to move to that item, and that causes problems here.
3658 while (gtk_events_pending())
3659 gtk_main_iteration();
3661 i = 0;
3665 gtk_imhtml_append_text(GTK_IMHTML(view->layout), string->str, -1, view->options);
3666 gtk_imhtml_append_text(GTK_IMHTML(view->layout), "<BR>", -1, view->options);
3668 gtk_widget_set_sensitive(view->bbox, TRUE);
3669 gtk_signal_disconnect(GTK_OBJECT(view->window), block);
3670 gtk_signal_connect(GTK_OBJECT(view->window), "delete_event",
3671 GTK_SIGNAL_FUNC(destroy_dialog), view->window);
3672 g_string_free(string, TRUE);
3673 fclose(fp);
3676 static void des_view_item(GtkObject *obj, struct view_log *view)
3678 if (view->name)
3679 g_free(view->name);
3680 g_free(view);
3683 static void des_log_win(GtkObject *win, gpointer data)
3685 char *x = gtk_object_get_user_data(win);
3686 if (x)
3687 g_free(x);
3690 void show_log(char *nm)
3692 gchar filename[256];
3693 gchar buf[BUF_LONG];
3694 FILE *fp;
3695 GtkWidget *window;
3696 GtkWidget *box;
3697 GtkWidget *hbox;
3698 GtkWidget *bbox;
3699 GtkWidget *sw;
3700 GtkWidget *layout;
3701 GtkWidget *close_button;
3702 GtkWidget *clear_button;
3703 GtkWidget *save_button;
3704 GtkWidget *list = NULL;
3705 GList *item_list = NULL;
3706 GtkWidget *item = NULL;
3707 GtkWidget *last = NULL;
3708 GtkWidget *frame;
3709 struct view_log *view;
3710 char *name = nm ? g_strdup(nm) : NULL;
3712 int options;
3713 guint block;
3714 char convo_start[32];
3715 long offset = 0;
3716 unsigned int i = 0;
3718 options = GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL;
3719 if (convo_options & OPT_CONVO_IGNORE_COLOUR)
3720 options ^= GTK_IMHTML_NO_COLOURS;
3721 if (convo_options & OPT_CONVO_IGNORE_FONTS)
3722 options ^= GTK_IMHTML_NO_FONTS;
3723 if (convo_options & OPT_CONVO_IGNORE_SIZES)
3724 options ^= GTK_IMHTML_NO_SIZES;
3726 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3727 gtk_object_set_user_data(GTK_OBJECT(window), name);
3728 gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(des_log_win), NULL);
3729 gtk_window_set_wmclass(GTK_WINDOW(window), "log", "Gaim");
3730 if (name)
3731 g_snprintf(buf, BUF_LONG, "Gaim - Conversations with %s", name);
3732 else
3733 g_snprintf(buf, BUF_LONG, "Gaim - System Log");
3734 gtk_window_set_title(GTK_WINDOW(window), buf);
3735 gtk_container_set_border_width(GTK_CONTAINER(window), 10);
3736 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, TRUE);
3737 block = gtk_signal_connect(GTK_OBJECT(window), "delete_event",
3738 GTK_SIGNAL_FUNC(dont_destroy), window);
3739 gtk_widget_realize(window);
3740 aol_icon(window->window);
3742 layout = gtk_imhtml_new(NULL, NULL);
3743 bbox = gtk_hbox_new(FALSE, 0);
3745 box = gtk_vbox_new(FALSE, 5);
3746 gtk_container_add(GTK_CONTAINER(window), box);
3748 hbox = gtk_hbox_new(FALSE, 5);
3749 gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0);
3751 if (name) {
3752 char *tmp = gaim_user_dir();
3753 g_snprintf(filename, 256, "%s/logs/%s.log", tmp, normalize(name));
3754 g_free(tmp);
3755 if ((fp = fopen(filename, "r")) == NULL) {
3756 g_snprintf(buf, BUF_LONG, "Unable to open log file %s", filename);
3757 do_error_dialog(buf, "Error!");
3758 return;
3761 list = gtk_list_new();
3763 frame = gtk_frame_new(_("Date"));
3764 gtk_widget_show(frame);
3766 sw = gtk_scrolled_window_new(NULL, NULL);
3767 gtk_container_set_border_width(GTK_CONTAINER(sw), 5);
3768 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), list);
3769 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
3770 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
3771 gtk_widget_set_usize(sw, 220, 220);
3772 gtk_container_add(GTK_CONTAINER(frame), sw);
3773 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
3775 while (fgets(buf, BUF_LONG, fp)) {
3776 if (strstr(buf, "---- New C")) {
3777 int length;
3778 char *temp = strchr(buf, '@');
3780 if (temp == NULL || strlen(temp) < 2)
3781 continue;
3783 if (i == 1 && item_list) {
3784 item_list = g_list_remove(item_list, last);
3785 last = NULL;
3788 i = 0;
3790 temp++;
3791 length = strcspn(temp, "-");
3792 if (length > 31) length = 31;
3794 offset = ftell(fp);
3795 g_snprintf(convo_start, length, "%s", temp);
3796 item = gtk_list_item_new_with_label(convo_start);
3797 view = g_new0(struct view_log, 1);
3798 view->options = options;
3799 view->offset = offset;
3800 view->name = g_strdup(name);
3801 view->bbox = bbox;
3802 view->window = window;
3803 view->layout = layout;
3804 gtk_signal_connect(GTK_OBJECT(item), "select",
3805 GTK_SIGNAL_FUNC(log_show_convo), view);
3806 gtk_signal_connect(GTK_OBJECT(item), "destroy",
3807 GTK_SIGNAL_FUNC(des_view_item), view);
3808 last = item;
3809 item_list = g_list_append(item_list, item);
3811 gtk_widget_show(item);
3813 i++;
3815 fclose(fp);
3816 if (i == 1 && item_list)
3817 item_list = g_list_remove(item_list, item);
3819 if (item_list)
3820 gtk_list_insert_items(GTK_LIST(list), item_list, 0 );
3823 gtk_signal_disconnect(GTK_OBJECT(window), block);
3824 gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(destroy_dialog), window);
3826 frame = gtk_frame_new(_("Conversation"));
3827 gtk_widget_show(frame);
3829 sw = gtk_scrolled_window_new(NULL, NULL);
3830 gtk_container_set_border_width(GTK_CONTAINER(sw), 5);
3831 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
3832 gtk_widget_set_usize(sw, 390, 220);
3833 gtk_container_add(GTK_CONTAINER(frame), sw);
3834 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
3836 gtk_signal_connect(GTK_OBJECT(layout), "url_clicked", GTK_SIGNAL_FUNC(open_url), NULL);
3837 gtk_container_add(GTK_CONTAINER(sw), layout);
3838 GTK_LAYOUT(layout)->hadjustment->step_increment = 10.0;
3839 GTK_LAYOUT(layout)->vadjustment->step_increment = 10.0;
3840 gaim_setup_imhtml(layout);
3842 gtk_box_pack_start(GTK_BOX(box), bbox, FALSE, FALSE, 0);
3843 gtk_widget_set_sensitive(bbox, FALSE);
3845 close_button = picture_button(window, _("Close"), cancel_xpm);
3846 gtk_box_pack_end(GTK_BOX(bbox), close_button, FALSE, FALSE, 5);
3847 gtk_signal_connect(GTK_OBJECT(close_button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), window);
3849 clear_button = picture_button(window, _("Clear"), close_xpm);
3850 gtk_object_set_user_data(GTK_OBJECT(clear_button), window);
3851 gtk_box_pack_end(GTK_BOX(bbox), clear_button, FALSE, FALSE, 5);
3852 gtk_signal_connect(GTK_OBJECT(clear_button), "clicked", GTK_SIGNAL_FUNC(show_clear_log), name);
3854 save_button = picture_button(window, _("Save"), save_xpm);
3855 gtk_box_pack_end(GTK_BOX(bbox), save_button, FALSE, FALSE, 5);
3856 gtk_signal_connect(GTK_OBJECT(save_button), "clicked", GTK_SIGNAL_FUNC(show_save_log), name);
3858 gtk_widget_show_all(window);
3860 if (!name) {
3861 view = g_new0(struct view_log, 1);
3862 view->options = options;
3863 view->name = NULL;
3864 view->bbox = bbox;
3865 view->window = window;
3866 view->layout = layout;
3867 log_show_convo(layout, view);
3868 gtk_signal_connect(GTK_OBJECT(layout), "destroy", GTK_SIGNAL_FUNC(des_view_item), view);
3869 } else {
3870 gtk_list_select_item(GTK_LIST(list), 0);
3873 gtk_widget_set_sensitive(bbox, TRUE);
3875 return;
3878 /*------------------------------------------------------------------------*/
3879 /* The dialog for renaming groups */
3880 /*------------------------------------------------------------------------*/
3882 static void do_rename_group(GtkObject *obj, GtkWidget *entry)
3884 char *new_name;
3885 struct group *g;
3886 struct group *orig;
3887 struct gaim_connection *gc;
3889 new_name = gtk_entry_get_text(GTK_ENTRY(entry));
3890 g = gtk_object_get_user_data(obj);
3892 if (new_name && (strlen(new_name) != 0) && strcmp(new_name, g->name)) {
3893 char *prevname;
3894 gc = g->gc;
3895 if ((orig = find_group(g->gc, new_name)) != NULL) {
3896 orig->members = g_slist_concat(orig->members, g->members);
3897 handle_group_rename(orig, g->name);
3898 g->gc->groups = g_slist_remove(g->gc->groups, g);
3899 /* FIXME, i don't like calling this. it's sloppy. */ build_edit_tree();
3900 g_free(g);
3901 } else {
3902 prevname = g_strdup(g->name);
3903 g_snprintf(g->name, sizeof(g->name), "%s", new_name);
3904 handle_group_rename(g, prevname);
3905 g_free(prevname);
3907 do_export(gc);
3910 destroy_dialog(rename_dialog, rename_dialog);
3913 void show_rename_group(GtkWidget *unused, struct group *g)
3915 GtkWidget *mainbox;
3916 GtkWidget *frame;
3917 GtkWidget *fbox;
3918 GtkWidget *bbox;
3919 GtkWidget *button;
3920 GtkWidget *name_entry;
3921 GtkWidget *label;
3923 if (!rename_dialog) {
3924 GAIM_DIALOG(rename_dialog);
3925 gtk_window_set_wmclass(GTK_WINDOW(rename_dialog), "rename_dialog", "Gaim");
3926 gtk_window_set_policy(GTK_WINDOW(rename_dialog), FALSE, TRUE, TRUE);
3927 gtk_window_set_title(GTK_WINDOW(rename_dialog), _("Gaim - Rename Group"));
3928 gtk_signal_connect(GTK_OBJECT(rename_dialog), "destroy",
3929 GTK_SIGNAL_FUNC(destroy_dialog), rename_dialog);
3930 gtk_widget_realize(rename_dialog);
3931 aol_icon(rename_dialog->window);
3933 mainbox = gtk_vbox_new(FALSE, 5);
3934 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
3935 gtk_container_add(GTK_CONTAINER(rename_dialog), mainbox);
3937 frame = gtk_frame_new(_("Rename Group"));
3938 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
3940 fbox = gtk_hbox_new(FALSE, 5);
3941 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
3942 gtk_container_add(GTK_CONTAINER(frame), fbox);
3944 label = gtk_label_new(_("New name:"));
3945 gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0);
3947 name_entry = gtk_entry_new();
3948 gtk_box_pack_start(GTK_BOX(fbox), name_entry, TRUE, TRUE, 0);
3949 gtk_object_set_user_data(GTK_OBJECT(name_entry), g);
3950 gtk_entry_set_text(GTK_ENTRY(name_entry), g->name);
3951 gtk_signal_connect(GTK_OBJECT(name_entry), "activate",
3952 GTK_SIGNAL_FUNC(do_rename_group), name_entry);
3953 gtk_widget_grab_focus(name_entry);
3955 bbox = gtk_hbox_new(FALSE, 5);
3956 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
3958 button = picture_button(rename_dialog, _("Cancel"), cancel_xpm);
3959 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
3960 gtk_signal_connect(GTK_OBJECT(button), "clicked",
3961 GTK_SIGNAL_FUNC(destroy_dialog), rename_dialog);
3963 button = picture_button(rename_dialog, _("OK"), ok_xpm);
3964 gtk_object_set_user_data(GTK_OBJECT(button), g);
3965 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
3966 gtk_signal_connect(GTK_OBJECT(button), "clicked",
3967 GTK_SIGNAL_FUNC(do_rename_group), name_entry);
3970 gtk_widget_show_all(rename_dialog);
3974 /*------------------------------------------------------------------------*/
3975 /* The dialog for renaming buddies */
3976 /*------------------------------------------------------------------------*/
3978 static void do_rename_buddy(GtkObject *obj, GtkWidget *entry)
3980 char *new_name;
3981 struct buddy *b;
3982 GSList *gr;
3984 new_name = gtk_entry_get_text(GTK_ENTRY(entry));
3985 b = gtk_object_get_user_data(obj);
3987 if (!g_slist_find(connections, b->gc)) {
3988 destroy_dialog(rename_bud_dialog, rename_bud_dialog);
3989 return;
3992 gr = b->gc->groups;
3993 while (gr) {
3994 if (g_slist_find(((struct group *)gr->data)->members, b))
3995 break;
3996 gr = gr->next;
3998 if (!gr) {
3999 destroy_dialog(rename_bud_dialog, rename_bud_dialog);
4000 return;
4003 if (new_name && (strlen(new_name) != 0) && strcmp(new_name, b->name)) {
4004 struct group *g = find_group_by_buddy(b->gc, b->name);
4005 char *prevname = g_strdup(b->name);
4006 if (g)
4007 serv_remove_buddy(b->gc, b->name, g->name);
4008 if (!strcmp(b->name, b->show))
4009 g_snprintf(b->show, sizeof(b->show), "%s", new_name);
4010 g_snprintf(b->name, sizeof(b->name), "%s", new_name);
4011 serv_add_buddy(b->gc, b->name);
4012 handle_buddy_rename(b, prevname);
4013 g_free(prevname);
4016 destroy_dialog(rename_bud_dialog, rename_bud_dialog);
4019 void show_rename_buddy(GtkWidget *unused, struct buddy *b)
4021 GtkWidget *mainbox;
4022 GtkWidget *frame;
4023 GtkWidget *fbox;
4024 GtkWidget *bbox;
4025 GtkWidget *button;
4026 GtkWidget *name_entry;
4027 GtkWidget *label;
4029 if (!rename_bud_dialog) {
4030 GAIM_DIALOG(rename_bud_dialog);
4031 gtk_window_set_wmclass(GTK_WINDOW(rename_bud_dialog), "rename_bud_dialog", "Gaim");
4032 gtk_window_set_policy(GTK_WINDOW(rename_bud_dialog), FALSE, TRUE, TRUE);
4033 gtk_window_set_title(GTK_WINDOW(rename_bud_dialog), _("Gaim - Rename Buddy"));
4034 gtk_signal_connect(GTK_OBJECT(rename_bud_dialog), "destroy",
4035 GTK_SIGNAL_FUNC(destroy_dialog), rename_bud_dialog);
4036 gtk_widget_realize(rename_bud_dialog);
4037 aol_icon(rename_bud_dialog->window);
4039 mainbox = gtk_vbox_new(FALSE, 5);
4040 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
4041 gtk_container_add(GTK_CONTAINER(rename_bud_dialog), mainbox);
4043 frame = gtk_frame_new(_("Rename Buddy"));
4044 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
4046 fbox = gtk_hbox_new(FALSE, 5);
4047 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
4048 gtk_container_add(GTK_CONTAINER(frame), fbox);
4050 label = gtk_label_new(_("New name:"));
4051 gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0);
4053 name_entry = gtk_entry_new();
4054 gtk_box_pack_start(GTK_BOX(fbox), name_entry, TRUE, TRUE, 0);
4055 gtk_object_set_user_data(GTK_OBJECT(name_entry), b);
4056 gtk_entry_set_text(GTK_ENTRY(name_entry), b->name);
4057 gtk_signal_connect(GTK_OBJECT(name_entry), "activate",
4058 GTK_SIGNAL_FUNC(do_rename_buddy), name_entry);
4059 gtk_widget_grab_focus(name_entry);
4061 bbox = gtk_hbox_new(FALSE, 5);
4062 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
4064 button = picture_button(rename_bud_dialog, _("Cancel"), cancel_xpm);
4065 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
4066 gtk_signal_connect(GTK_OBJECT(button), "clicked",
4067 GTK_SIGNAL_FUNC(destroy_dialog), rename_bud_dialog);
4069 button = picture_button(rename_bud_dialog, _("OK"), ok_xpm);
4070 gtk_object_set_user_data(GTK_OBJECT(button), b);
4071 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
4072 gtk_signal_connect(GTK_OBJECT(button), "clicked",
4073 GTK_SIGNAL_FUNC(do_rename_buddy), name_entry);
4076 gtk_widget_show_all(rename_bud_dialog);
4079 #ifdef USE_PERL
4081 static GtkWidget *perl_config = NULL;
4082 static char *perl_last_dir = NULL;
4084 static void cfdes(GtkWidget *m, gpointer n)
4086 if (perl_config)
4087 gtk_widget_destroy(perl_config);
4088 perl_config = NULL;
4091 static void do_load(GtkWidget *m, gpointer n)
4093 const char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(perl_config));
4094 gchar *f = NULL;
4095 if (!file || !strlen(file)) {
4096 return;
4099 if (file_is_dir(file, perl_config)) {
4100 return;
4103 if (perl_last_dir) {
4104 g_free(perl_last_dir);
4106 perl_last_dir = g_dirname(file);
4108 debug_printf("Loading perl script: %s\n", file);
4110 f = g_strdup(file);
4111 perl_load_file(f);
4112 g_free(f);
4113 cfdes(perl_config, NULL);
4116 void load_perl_script()
4118 char *buf, *temp;
4120 if (perl_config) {
4121 gtk_widget_show(perl_config);
4122 gdk_window_raise(perl_config->window);
4123 return;
4126 /* Below is basically stolen from plugins.c */
4127 perl_config = gtk_file_selection_new(_("Gaim - Select Perl Script"));
4129 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(perl_config));
4131 if (!perl_last_dir) {
4132 temp = gaim_user_dir();
4133 buf = g_strconcat(temp, G_DIR_SEPARATOR_S, NULL);
4134 g_free(temp);
4135 } else {
4136 buf = g_strconcat(perl_last_dir, G_DIR_SEPARATOR_S, NULL);
4139 gtk_file_selection_set_filename(GTK_FILE_SELECTION(perl_config), buf);
4140 gtk_file_selection_complete(GTK_FILE_SELECTION(perl_config), "*.pl");
4141 gtk_signal_connect(GTK_OBJECT(perl_config), "destroy", GTK_SIGNAL_FUNC(cfdes), perl_config);
4143 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(perl_config)->ok_button),
4144 "clicked", GTK_SIGNAL_FUNC(do_load), NULL);
4146 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(perl_config)->cancel_button),
4147 "clicked", GTK_SIGNAL_FUNC(cfdes), NULL);
4149 g_free(buf);
4150 gtk_widget_show(perl_config);
4151 gdk_window_raise(perl_config->window);
4154 #endif /* USE_PERL */
4156 static GdkPixmap *icon_pm = NULL;
4157 static GdkBitmap *icon_bm = NULL;
4159 void aol_icon(GdkWindow *w)
4161 #ifndef _WIN32
4162 if (icon_pm == NULL) {
4163 icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm, NULL, (gchar **)aimicon_xpm);
4165 gdk_window_set_icon(w, NULL, icon_pm, icon_bm);
4166 if (mainwindow)
4167 gdk_window_set_group(w, mainwindow->window);
4168 #endif
4171 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm)
4173 GtkWidget *button;
4174 GtkWidget *button_box, *button_box_2, *button_box_3;
4175 GtkWidget *label;
4176 GdkBitmap *mask;
4177 GdkPixmap *pm;
4178 GtkWidget *pixmap;
4180 button = gtk_button_new();
4181 if (misc_options & OPT_MISC_COOL_LOOK)
4182 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
4184 button_box = gtk_hbox_new(FALSE, 5);
4185 gtk_container_add(GTK_CONTAINER(button), button_box);
4187 button_box_2 = gtk_hbox_new(FALSE, 0);
4188 button_box_3 = gtk_hbox_new(FALSE, 0);
4189 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
4190 gtk_box_pack_start(GTK_BOX(button_box), button_box_3, TRUE, TRUE, 0);
4191 pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
4192 pixmap = gtk_pixmap_new(pm, mask);
4193 gtk_box_pack_end(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
4195 if (text) {
4196 label = gtk_label_new(text);
4197 gtk_box_pack_start(GTK_BOX(button_box_3), label, FALSE, FALSE, 2);
4198 gtk_widget_show(label);
4201 gtk_widget_show(pixmap);
4202 gtk_widget_show(button_box_2);
4203 gtk_widget_show(button_box_3);
4204 gtk_widget_show(button_box);
4206 /* this causes clipping on lots of buttons with long text */
4207 /* gtk_widget_set_usize(button, 75, 30);*/
4208 gtk_widget_show(button);
4209 gdk_pixmap_unref(pm);
4210 gdk_bitmap_unref(mask);
4212 return button;
4215 static GtkTooltips *button_tips = NULL;
4216 GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short dispstyle)
4218 GtkWidget *button;
4219 GtkWidget *button_box, *button_box_2;
4220 GdkBitmap *mask;
4221 GdkPixmap *pm;
4222 GtkWidget *pixmap;
4223 GtkWidget *label;
4225 if (!button_tips)
4226 button_tips = gtk_tooltips_new();
4227 button = gtk_button_new();
4228 if (misc_options & OPT_MISC_COOL_LOOK)
4229 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
4231 button_box = gtk_hbox_new(FALSE, 0);
4232 gtk_container_add(GTK_CONTAINER(button), button_box);
4234 button_box_2 = gtk_vbox_new(FALSE, 0);
4236 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
4237 gtk_widget_show(button_box_2);
4238 gtk_widget_show(button_box);
4239 if (dispstyle == 2 || dispstyle == 0) {
4240 pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
4241 pixmap = gtk_pixmap_new(pm, mask);
4242 gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
4244 gtk_widget_show(pixmap);
4246 gdk_pixmap_unref(pm);
4247 gdk_bitmap_unref(mask);
4250 if (dispstyle == 2 || dispstyle == 1) {
4251 label = gtk_label_new(text);
4252 gtk_widget_show(label);
4253 gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0);
4256 gtk_tooltips_set_tip(button_tips, button, text, "Gaim");
4257 gtk_widget_show(button);
4258 return button;
4261 int file_is_dir(const char *path, GtkWidget *w)
4263 struct stat st;
4264 char *name;
4266 if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
4267 /* append a / if needed */
4268 if (path[strlen(path) - 1] != '/') {
4269 name = g_strconcat(path, "/", NULL);
4270 } else {
4271 name = g_strdup(path);
4273 gtk_file_selection_set_filename(GTK_FILE_SELECTION(w), name);
4274 g_free(name);
4275 return 1;
4278 return 0;
4281 /*------------------------------------------------------------------------*/
4282 /* The dialog for setting V-Card info */
4283 /*------------------------------------------------------------------------*/
4285 * There are actually two "chunks" of code following: generic "multi-entry dialog"
4286 * support and V-Card dialog specific support.
4288 * At first blush, this may seem like an unnecessary duplication of effort given
4289 * that a "set dir info" dialog already exists. However, this is not so because:
4291 * 1. V-Cards can have a lot more data in them than what the current
4292 * "set dir" dialog supports.
4294 * 2. V-Card data, at least with respect to Jabber, is currently in a
4295 * state of flux. As the data and format changes, all that need be
4296 * changed with the V-Card support I've written is the "template"
4297 * data.
4299 * 3. The "multi entry dialog" support itself was originally written
4300 * to support Jabber server user registration (TBD). A "dynamically
4301 * configurable" multi-entry dialog is needed for that, as different
4302 * servers may require different registration information. It just
4303 * turned out to be well-suited to adding V-Card setting support, as
4304 * well :-).
4306 * TBD: Add check-box support to the generic multi-entry dialog support so that
4307 * it can be used to "replace" the "set dir info" support?
4309 * Multiple-language support. Currently Not In There. I think this should
4310 * be easy. Note that when it's added: if anybody saved their data in
4311 * English, it'll be lost when MLS is added and they'll have to re-enter it.
4313 * More "TBDs" noted in the code.
4317 /*------------------------------------*/
4318 /* generic multi-entry dialog support */
4319 /*------------------------------------*/
4322 * Print all multi-entry items
4324 * Note: Simply a debug helper
4326 void multi_entry_item_print_all(const GSList *list) {
4328 int cnt = 0;
4330 /* While there's something to print... */
4331 while(list != NULL) {
4332 fprintf(stderr, "label %2d: \"%s\"", ++cnt, ((MultiEntryData *) (list->data))->label);
4333 if(((MultiEntryData *) (list->data))->text != NULL) {
4334 fprintf(stderr, ", text: \"%s\"", ((MultiEntryData *) (list->data))->text);
4336 fputs("\n", stderr);
4337 list = list->next;
4342 * Print all multi-text items
4344 * Note: Simply a debug helper
4346 void multi_text_item_print_all(const GSList *list) {
4348 int cnt = 0;
4350 /* While there's something to print... */
4351 while(list != NULL) {
4352 fprintf(stderr, "label %2d: \"%s\"", ++cnt, ((MultiTextData *) (list->data))->label);
4353 if(((MultiTextData *) (list->data))->text != NULL) {
4354 fprintf(stderr, ", text: \"%s\"", ((MultiTextData *) (list->data))->text);
4356 fputs("\n", stderr);
4357 list = list->next;
4363 * Free all multi-entry item allocs and NULL the list pointer
4365 void multi_entry_items_free_all(GSList **list)
4368 GSList *next = *list;
4369 MultiEntryData *data;
4371 /* While there's something to free() ... */
4372 while(next != NULL) {
4373 data = (MultiEntryData *) next->data;
4374 g_free(data->label);
4375 g_free(data->text);
4376 g_free(data);
4377 next = next->next;
4379 g_slist_free(*list);
4380 *list = NULL;
4384 * Free all multi-text item allocs and NULL the list pointer
4386 void multi_text_items_free_all(GSList **list)
4389 GSList *next = *list;
4390 MultiTextData *data;
4392 /* While there's something to free() ... */
4393 while(next != NULL) {
4394 data = (MultiTextData *) next->data;
4395 g_free(data->label);
4396 g_free(data->text);
4397 g_free(data);
4398 next = next->next;
4400 g_slist_free(*list);
4401 *list = NULL;
4405 * See if a MultiEntryData item contains a given label
4407 * See: glib docs for g_slist_compare_custom() for details
4409 static gint multi_entry_data_label_compare(gconstpointer data, gconstpointer label)
4411 return(strcmp(((MultiEntryData *) (data))->label, (char *) label));
4415 * Add a new multi-entry item to list
4417 * If adding to existing list: will search the list for existence of
4418 * "label" and change/create "text" entry if necessary.
4421 MultiEntryData *multi_entry_list_update(GSList **list, const char *label, const char *text, int add_it)
4423 GSList *found;
4424 MultiEntryData *data;
4426 if((found = g_slist_find_custom(*list, (void *)label, multi_entry_data_label_compare)) == NULL) {
4427 if(add_it) {
4428 data = (MultiEntryData *) g_slist_last(*list =
4429 g_slist_append(*list, g_malloc(sizeof(MultiEntryData))))->data;
4430 data->label = strcpy(g_malloc(strlen(label) +1), label);
4431 data->text = NULL;
4433 * default to setting "visible" and editable to TRUE - they can be
4434 * overridden later, of course.
4436 data->visible = TRUE;
4437 data->editable = TRUE;
4438 } else {
4439 data = NULL;
4441 } else {
4442 data = found->data;
4445 if(data != NULL && text != NULL && text[0] != '\0') {
4446 if(data->text == NULL) {
4447 data->text = g_malloc(strlen(text) + 1);
4448 } else {
4449 data->text = g_realloc(data->text, strlen(text) + 1);
4451 strcpy(data->text, text);
4454 return(data);
4458 * See if a MultiTextData item contains a given label
4460 * See: glib docs for g_slist_compare_custom() for details
4462 static gint multi_text_data_label_compare(gconstpointer data, gconstpointer label)
4464 return(strcmp(((MultiTextData *) (data))->label, (char *) label));
4468 * Add a new multi-text item to list
4470 * If adding to existing list: will search the list for existence of
4471 * "label" and change/create "text" text if necessary.
4474 MultiTextData *multi_text_list_update(GSList **list, const char *label, const char *text, int add_it)
4476 GSList *found;
4477 MultiTextData *data;
4479 if((found = g_slist_find_custom(*list, (void *)label, multi_text_data_label_compare)) == NULL) {
4480 if(add_it) {
4481 data = (MultiTextData *) g_slist_last(*list =
4482 g_slist_append(*list, g_malloc(sizeof(MultiTextData))))->data;
4483 data->label = strcpy(g_malloc(strlen(label) +1), label);
4484 data->text = NULL;
4485 } else {
4486 data = NULL;
4488 } else {
4489 data = found->data;
4492 if(data != NULL && text != NULL && text[0] != '\0') {
4493 if(data->text == NULL) {
4494 data->text = g_malloc(strlen(text) + 1);
4495 } else {
4496 data->text = g_realloc(data->text, strlen(text) + 1);
4498 strcpy(data->text, text);
4501 return(data);
4505 * Free-up the multi-entry item list and the MultiEntryDlg
4506 * struct alloc.
4508 void multi_entry_free(struct multi_entry_dlg *b)
4510 multi_entry_items_free_all(&(b->multi_entry_items));
4511 multi_text_items_free_all(&(b->multi_text_items));
4512 g_free(b->instructions->text);
4513 g_free(b->instructions);
4514 g_free(b->entries_title);
4515 g_free(b);
4519 * Multi-Entry dialog "destroyed" catcher
4521 * Free-up the multi-entry item list, destroy the dialog widget
4522 * and free the MultiEntryDlg struct alloc.
4525 void multi_entry_dialog_destroy(GtkWidget *widget, gpointer data)
4527 MultiEntryDlg *b = data;
4529 multi_entry_free(b);
4533 * Show/Re-show instructions
4535 void re_show_multi_entry_instr(MultiInstrData *instructions)
4537 if(instructions->label != NULL) {
4538 if(instructions->text == NULL) {
4539 gtk_widget_hide(instructions->label);
4540 } else {
4541 gtk_label_set_text(GTK_LABEL (instructions->label), instructions->text);
4542 gtk_widget_show(instructions->label);
4548 * Show/Re-show entry boxes
4550 void re_show_multi_entry_entries(GtkWidget **entries_table,
4551 GtkWidget *entries_frame,
4552 GSList *multi_entry_items)
4554 GtkWidget *label;
4555 GSList *multi_entry;
4556 MultiEntryData *med;
4557 int rows, row_num, col_num, col_offset;
4558 int cols = 1;
4560 /* Figure-out number of rows needed for table */
4561 if((rows = g_slist_length(multi_entry_items)) > 9) {
4562 rows /= 2;
4563 ++cols;
4566 if(*entries_table != NULL) {
4567 gtk_widget_destroy(GTK_WIDGET (*entries_table));
4569 *entries_table = gtk_table_new(rows, 3 * cols, FALSE);
4570 gtk_container_add(GTK_CONTAINER (entries_frame), *entries_table);
4572 for(col_num = 0, multi_entry = multi_entry_items; col_num < cols && multi_entry != NULL;
4573 ++col_num) {
4574 col_offset = col_num * 3;
4575 for(row_num = 0; row_num < rows && multi_entry != NULL;
4576 ++row_num, multi_entry = multi_entry->next) {
4578 med = (MultiEntryData *) multi_entry->data;
4580 label = gtk_label_new(med->label);
4581 gtk_misc_set_alignment(GTK_MISC(label), (gfloat) 1.0, (gfloat) 0.5);
4582 gtk_table_attach_defaults(GTK_TABLE (*entries_table), label,
4583 col_offset, 1 + col_offset, row_num, row_num +1);
4584 gtk_widget_show(label);
4586 label = gtk_label_new(": ");
4587 gtk_misc_set_alignment(GTK_MISC(label), (gfloat) 0.0, (gfloat) 0.5);
4588 gtk_table_attach_defaults(GTK_TABLE (*entries_table), label,
4589 1 + col_offset, 2 + col_offset, row_num, row_num +1);
4590 gtk_widget_show(label);
4592 med->widget = gtk_entry_new_with_max_length(50);
4593 if(med->text != NULL) {
4594 gtk_entry_set_text(GTK_ENTRY (med->widget), med->text);
4596 gtk_entry_set_visibility(GTK_ENTRY (med->widget), med->visible);
4597 gtk_entry_set_editable(GTK_ENTRY (med->widget), med->editable);
4598 gtk_table_attach(GTK_TABLE (*entries_table), med->widget,
4599 2 + col_offset, 3 + col_offset, row_num, row_num +1,
4600 GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 5, 0);
4601 gtk_widget_show(med->widget);
4605 gtk_widget_show(*entries_table);
4609 * Show/Re-show textboxes
4611 void re_show_multi_entry_textboxes(GtkWidget **texts_ibox,
4612 GtkWidget *texts_obox,
4613 GSList *multi_text_items)
4615 GSList *multi_text;
4616 MultiTextData *mtd;
4617 GtkWidget *frame;
4618 GtkWidget *hbox;
4619 GtkWidget *vscrollbar;
4621 if(*texts_ibox != NULL) {
4622 gtk_widget_destroy(GTK_WIDGET (*texts_ibox));
4624 *texts_ibox = gtk_vbox_new(FALSE, 5);
4625 gtk_container_add(GTK_CONTAINER (texts_obox), *texts_ibox);
4627 for(multi_text = multi_text_items; multi_text != NULL; multi_text = multi_text->next) {
4628 mtd = (MultiTextData *) multi_text->data;
4629 frame = gtk_frame_new(mtd->label);
4630 gtk_container_add(GTK_CONTAINER (*texts_ibox), frame);
4631 hbox = gtk_hbox_new(FALSE, 0);
4632 gtk_container_add(GTK_CONTAINER (frame), hbox);
4633 mtd->textbox = gtk_text_new(NULL, NULL);
4634 gtk_text_set_editable(GTK_TEXT(mtd->textbox), TRUE);
4635 gtk_text_set_word_wrap(GTK_TEXT(mtd->textbox), TRUE);
4636 gtk_widget_set_usize(mtd->textbox, 300, 100);
4637 gtk_text_insert(GTK_TEXT(mtd->textbox), NULL, NULL, NULL, mtd->text, -1);
4638 gtk_box_pack_start(GTK_BOX (hbox), mtd->textbox, FALSE, FALSE, 0);
4639 vscrollbar = gtk_vscrollbar_new (GTK_TEXT(mtd->textbox)->vadj);
4640 gtk_box_pack_start(GTK_BOX (hbox), vscrollbar, FALSE, FALSE, 0);
4641 gtk_widget_show(mtd->textbox);
4642 gtk_widget_show (vscrollbar);
4643 gtk_widget_show(hbox);
4644 gtk_widget_show(frame);
4647 gtk_widget_show(*texts_ibox);
4651 * Create and initialize a new Multi-Entry Dialog struct
4653 MultiEntryDlg *multi_entry_dialog_new()
4655 MultiEntryDlg *b = g_new0(MultiEntryDlg, 1);
4656 b->instructions = g_new0(MultiInstrData, 1);
4657 b->multi_entry_items = NULL;
4658 b->multi_text_items = NULL;
4659 return(b);
4663 * Instantiate a new multi-entry dialog
4665 * data == pointer to MultiEntryDlg with the following
4666 * initialized:
4668 * wmclass_name
4669 * wmclass_class
4670 * title
4671 * user
4672 * multi_entry_items - pointers to MultiEntryData list
4673 * and MultiTextData list
4674 * instructions (optional)
4675 * ok function pointer
4676 * cancel function pointer (actually used to set
4677 * window destroy signal--cancel asserts destroy)
4679 * sets the following in the MultiEntryDialog struct:
4681 * window
4683 void show_multi_entry_dialog(gpointer data)
4685 GtkWidget *vbox, *hbox;
4686 GtkWidget *button;
4687 MultiEntryDlg *b = data;
4689 GAIM_DIALOG(b->window);
4690 gtk_container_set_border_width(GTK_CONTAINER(b->window), 5);
4691 gtk_window_set_wmclass(GTK_WINDOW(b->window), b->wmclass_name, b->wmclass_class);
4692 gtk_window_set_title(GTK_WINDOW (b->window), b->title);
4694 /* Clean up if user dismisses window via window manager! */
4695 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(b->cancel), (gpointer) b);
4696 gtk_widget_realize(b->window);
4697 aol_icon(b->window->window);
4699 vbox = gtk_vbox_new(FALSE, 5);
4700 gtk_container_add(GTK_CONTAINER (b->window), vbox);
4702 b->instructions->label = gtk_label_new(NULL);
4703 gtk_label_set_line_wrap(GTK_LABEL (b->instructions->label), TRUE);
4704 gtk_box_pack_start(GTK_BOX (vbox), b->instructions->label, TRUE, TRUE, 5);
4705 re_show_multi_entry_instr(b->instructions);
4707 b->entries_frame = gtk_frame_new(b->entries_title);
4708 gtk_box_pack_start(GTK_BOX (vbox), b->entries_frame, TRUE, TRUE, 5);
4709 gtk_widget_show(b->entries_frame);
4710 b->entries_table = NULL;
4711 re_show_multi_entry_entries(&(b->entries_table), b->entries_frame, b->multi_entry_items);
4713 b->texts_obox = gtk_vbox_new(FALSE, 0);
4714 gtk_box_pack_start(GTK_BOX (vbox), b->texts_obox, TRUE, TRUE, 5);
4715 gtk_widget_show(b->texts_obox);
4716 b->texts_ibox = NULL;
4717 re_show_multi_entry_textboxes(&(b->texts_ibox), b->texts_obox, b->multi_text_items);
4719 hbox = gtk_hbox_new(FALSE, 0);
4720 gtk_box_pack_start(GTK_BOX (vbox), hbox, FALSE, FALSE, 5);
4721 gtk_widget_show(hbox);
4723 button = picture_button(b->window, _("Cancel"), cancel_xpm);
4725 /* Let "destroy handling" (set above) handle cleanup */
4726 gtk_signal_connect_object(GTK_OBJECT (button), "clicked",
4727 GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (b->window));
4728 gtk_box_pack_end(GTK_BOX (hbox), button, FALSE, FALSE, 5);
4729 gtk_widget_show(button);
4731 button = picture_button(b->window, _("Save"), save_xpm);
4732 gtk_signal_connect(GTK_OBJECT (button), "clicked",
4733 GTK_SIGNAL_FUNC (b->ok), (gpointer) b);
4734 gtk_box_pack_end(GTK_BOX (hbox), button, FALSE, FALSE, 5);
4735 gtk_widget_show(button);
4737 gtk_widget_show(vbox);
4738 gtk_widget_show(b->window);
4742 /*------------------------------------*/
4743 /* V-Card dialog specific support */
4744 /*------------------------------------*/
4747 * V-Card "set info" dialog "Save" clicked
4749 * Copy data from GTK+ dialogs into GSLists, call protocol-specific
4750 * formatter and save the user info data.
4752 void set_vcard_dialog_ok_clicked(GtkWidget *widget, gpointer data)
4754 MultiEntryDlg *b = (MultiEntryDlg *) data;
4755 struct gaim_connection *gc;
4756 gchar *tmp;
4757 GSList *list;
4759 for(list = b->multi_entry_items; list != NULL; list = list->next) {
4760 if(((MultiEntryData *) list->data)->text != NULL) {
4761 g_free(((MultiEntryData *) list->data)->text);
4763 ((MultiEntryData *) list->data)->text =
4764 g_strdup(gtk_entry_get_text(GTK_ENTRY(((MultiEntryData *) list->data)->widget)));
4767 for(list = b->multi_text_items; list != NULL; list = list->next) {
4768 if(((MultiTextData *) list->data)->text != NULL) {
4769 g_free(((MultiTextData *) list->data)->text);
4771 ((MultiTextData *) list->data)->text =
4772 gtk_editable_get_chars((GtkEditable *) (((MultiTextData *) list->data)->textbox),
4773 0, -1);
4777 tmp = b->custom(b);
4780 * Set the user info and (possibly) send to the server
4782 if (b->user) {
4783 strncpy(b->user->user_info, tmp, sizeof b->user->user_info);
4784 gc = b->user->gc;
4786 save_prefs();
4788 if (gc)
4789 serv_set_info(gc, b->user->user_info);
4792 g_free(tmp);
4794 /* Let multi-edit dialog window "destroy" event catching handle remaining cleanup */
4795 gtk_widget_destroy(GTK_WIDGET (b->window));
4799 * Instantiate a v-card dialog
4801 void show_set_vcard(MultiEntryDlg *b)
4803 b->ok = set_vcard_dialog_ok_clicked;
4804 b->cancel = multi_entry_dialog_destroy;
4806 show_multi_entry_dialog(b);
4810 /*------------------------------------------------------------------------*/
4811 /* End dialog for setting v-card info */
4812 /*------------------------------------------------------------------------*/