[gaim-migrate @ 3063]
[pidgin-git.git] / src / dialogs.c
blobc3424211c473409675e578f5fa78cf93499376d0
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>
40 #include <math.h>
42 #include <gtk/gtk.h>
43 #include "gaim.h"
44 #include "gtkimhtml.h"
45 #include "prpl.h"
46 #ifdef USE_APPLET
47 #include "applet.h"
48 #endif
50 #include "pixmaps/gnome_preferences.xpm"
51 #include "pixmaps/cancel.xpm"
52 #include "pixmaps/save.xpm"
53 #include "pixmaps/ok.xpm"
54 #include "pixmaps/add.xpm"
55 #include "pixmaps/warn.xpm"
56 #include "pixmaps/close.xpm"
58 #include "pixmaps/angel.xpm"
59 #include "pixmaps/bigsmile.xpm"
60 #include "pixmaps/burp.xpm"
61 #include "pixmaps/crossedlips.xpm"
62 #include "pixmaps/cry.xpm"
63 #include "pixmaps/embarrassed.xpm"
64 #include "pixmaps/kiss.xpm"
65 #include "pixmaps/moneymouth.xpm"
66 #include "pixmaps/sad.xpm"
67 #include "pixmaps/scream.xpm"
68 #include "pixmaps/smile.xpm"
69 #include "pixmaps/smile8.xpm"
70 #include "pixmaps/think.xpm"
71 #include "pixmaps/tongue.xpm"
72 #include "pixmaps/wink.xpm"
73 #include "pixmaps/yell.xpm"
75 #include "pixmaps/aimicon.xpm"
77 #include "pixmaps/aol_icon.xpm"
78 #include "pixmaps/free_icon.xpm"
79 #include "pixmaps/dt_icon.xpm"
80 #include "pixmaps/admin_icon.xpm"
81 #include "pixmaps/ab.xpm"
83 #define PATHSIZE 1024
85 int smiley_array[FACE_TOTAL];
86 char *current_smiley;
87 GdkColor bgcolor;
88 GdkColor fgcolor;
90 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */
91 static GtkWidget *infodialog = NULL;
92 static GList *dialogwindows = NULL;
93 static GtkWidget *importdialog;
94 static struct gaim_connection *importgc;
95 static GtkWidget *icondlg;
96 static GtkWidget *aliasdlg = NULL;
97 static GtkWidget *aliasentry = NULL;
98 static GtkWidget *aliasname = NULL;
99 static GtkWidget *rename_dialog = NULL;
100 static GtkWidget *rename_bud_dialog = NULL;
102 struct confirm_del {
103 GtkWidget *window;
104 GtkWidget *label;
105 GtkWidget *ok;
106 GtkWidget *cancel;
107 char name[1024];
108 struct gaim_connection *gc;
111 struct create_away {
112 GtkWidget *window;
113 GtkWidget *entry;
114 GtkWidget *text;
115 struct away_message *mess;
118 struct warning {
119 GtkWidget *window;
120 GtkWidget *anon;
121 char *who;
122 struct gaim_connection *gc;
125 struct addbuddy {
126 GtkWidget *window;
127 GtkWidget *combo;
128 GtkWidget *entry;
129 GtkWidget *entry_for_alias;
130 GtkWidget *account;
131 struct gaim_connection *gc;
134 struct addperm {
135 GtkWidget *window;
136 GtkWidget *entry;
137 struct gaim_connection *gc;
138 gboolean permit;
141 struct addbp {
142 GtkWidget *window;
143 GtkWidget *nameentry;
144 GtkWidget *messentry;
145 GtkWidget *commentry;
146 GtkWidget *command;
147 GtkWidget *sendim;
148 GtkWidget *openwindow;
149 GtkWidget *popupnotify;
150 GtkWidget *p_signon;
151 GtkWidget *p_unaway;
152 GtkWidget *p_unidle;
153 GtkWidget *p_typing;
154 GtkWidget *save;
155 GtkWidget *menu;
156 GtkWidget *sound;
157 GtkWidget *soundentry;
159 struct aim_user *user;
160 struct buddy_pounce *buddy_pounce;
163 struct findbyemail {
164 GtkWidget *window;
165 GtkWidget *emailentry;
166 struct gaim_connection *gc;
169 struct findbyinfo {
170 struct gaim_connection *gc;
171 GtkWidget *window;
172 GtkWidget *firstentry;
173 GtkWidget *middleentry;
174 GtkWidget *lastentry;
175 GtkWidget *maidenentry;
176 GtkWidget *cityentry;
177 GtkWidget *stateentry;
178 GtkWidget *countryentry;
181 struct info_dlg {
182 struct gaim_connection *gc;
183 char *who;
184 GtkWidget *window;
185 GtkWidget *text;
187 static GSList *info_dlgs = NULL;
189 static struct info_dlg *find_info_dlg(struct gaim_connection *gc, char *who)
191 GSList *i = info_dlgs;
192 while (i) {
193 struct info_dlg *d = i->data;
194 i = i->next;
195 if (d->gc != gc)
196 continue;
197 if (d->who == NULL)
198 continue;
199 if (!who)
200 continue;
201 if (!g_strcasecmp(normalize(who), d->who))
202 return d;
204 return NULL;
207 struct set_info_dlg {
208 GtkWidget *window;
209 GtkWidget *menu;
210 struct aim_user *user;
211 GtkWidget *text;
212 GtkWidget *save;
213 GtkWidget *cancel;
216 struct set_icon_dlg {
217 GtkWidget *window;
218 struct aim_user *user;
219 GtkWidget *ok;
220 GtkWidget *cancel;
221 GtkWidget *entry;
224 struct set_dir_dlg {
225 struct gaim_connection *gc;
226 GtkWidget *window;
227 GtkWidget *first;
228 GtkWidget *middle;
229 GtkWidget *last;
230 GtkWidget *maiden;
231 GtkWidget *city;
232 GtkWidget *state;
233 GtkWidget *country;
234 GtkWidget *web;
235 GtkWidget *cancel;
236 GtkWidget *save;
239 struct linkdlg {
240 GtkWidget *ok;
241 GtkWidget *cancel;
242 GtkWidget *window;
243 GtkWidget *url;
244 GtkWidget *text;
245 GtkWidget *toggle;
246 GtkWidget *entry;
249 struct passwddlg {
250 GtkWidget *window;
251 GtkWidget *ok;
252 GtkWidget *cancel;
253 GtkWidget *original;
254 GtkWidget *new1;
255 GtkWidget *new2;
256 struct gaim_connection *gc;
259 struct view_log {
260 long offset;
261 int options;
262 char *name;
263 GtkWidget *bbox;
264 GtkWidget *window;
265 GtkWidget *layout;
268 /*------------------------------------------------------------------------*/
269 /* Destroys */
270 /*------------------------------------------------------------------------*/
272 static gint delete_event_dialog(GtkWidget *w, GdkEventAny *e, struct conversation *c)
274 gchar *object_data;
275 object_data = gtk_object_get_user_data(GTK_OBJECT(w));
277 if (GTK_IS_COLOR_SELECTION_DIALOG(w)) {
278 set_state_lock(1);
279 if (w == c->fg_color_dialog) {
280 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->fgcolorbtn), FALSE);
281 c->fg_color_dialog = NULL;
282 } else {
283 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->bgcolorbtn), FALSE);
284 c->bg_color_dialog = NULL;
286 set_state_lock(0);
287 } else if (GTK_IS_FONT_SELECTION_DIALOG(w)) {
288 set_state_lock(1);
289 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->font), FALSE);
290 set_state_lock(0);
291 c->font_dialog = NULL;
292 } else if (!g_strcasecmp(object_data, "smiley dialog")) {
293 set_state_lock(1);
294 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->smiley), FALSE);
295 set_state_lock(0);
296 c->smiley_dialog = NULL;
297 } else if (!g_strcasecmp(object_data, "log dialog")) {
298 set_state_lock(1);
299 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->wood), FALSE);
300 set_state_lock(0);
301 c->log_dialog = NULL;
304 dialogwindows = g_list_remove(dialogwindows, w);
305 gtk_widget_destroy(w);
307 return FALSE;
310 static void destroy_dialog(GtkWidget *w, GtkWidget *w2)
312 GtkWidget *dest;
314 if (!GTK_IS_WIDGET(w2))
315 dest = w;
316 else
317 dest = w2;
319 if (dest == imdialog)
320 imdialog = NULL;
322 if (dest == infodialog)
323 infodialog = NULL;
325 if (dest == importdialog) {
326 importdialog = NULL;
327 importgc = NULL;
330 if (dest == icondlg)
331 icondlg = NULL;
333 if (dest == aliasdlg) {
334 aliasdlg = NULL;
335 aliasentry = NULL;
336 aliasname = NULL;
339 if (dest == rename_dialog)
340 rename_dialog = NULL;
342 if (dest == rename_bud_dialog)
343 rename_bud_dialog = NULL;
345 dialogwindows = g_list_remove(dialogwindows, dest);
346 gtk_widget_destroy(dest);
351 void destroy_all_dialogs()
353 while (dialogwindows)
354 destroy_dialog(NULL, dialogwindows->data);
356 if (awaymessage)
357 do_im_back(NULL, NULL);
359 if (imdialog) {
360 destroy_dialog(NULL, imdialog);
361 imdialog = NULL;
364 if (infodialog) {
365 destroy_dialog(NULL, infodialog);
366 infodialog = NULL;
369 if (importdialog) {
370 destroy_dialog(NULL, importdialog);
371 importdialog = NULL;
374 if (icondlg) {
375 destroy_dialog(NULL, icondlg);
376 icondlg = NULL;
380 static void do_warn(GtkWidget *widget, struct warning *w)
382 serv_warn(w->gc, w->who, (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))) ? 1 : 0);
384 destroy_dialog(NULL, w->window);
387 static void free_warn_data(GtkObject *obj, struct warning *w)
389 g_free(w);
392 void show_warn_dialog(struct gaim_connection *gc, char *who)
394 GtkWidget *cancel;
395 GtkWidget *warn;
396 GtkWidget *label;
397 GtkWidget *vbox;
398 GtkWidget *bbox;
399 GtkWidget *frame;
400 GtkWidget *fbox;
401 char buf[128];
403 struct warning *w = g_new0(struct warning, 1);
404 w->who = who;
405 w->gc = gc;
407 GAIM_DIALOG(w->window);
408 dialogwindows = g_list_prepend(dialogwindows, w->window);
409 gtk_window_set_wmclass(GTK_WINDOW(w->window), "warning", "Gaim");
410 gtk_window_set_policy(GTK_WINDOW(w->window), FALSE, FALSE, TRUE);
411 gtk_window_set_title(GTK_WINDOW(w->window), _("Gaim - Warn user?"));
412 gtk_container_set_border_width(GTK_CONTAINER(w->window), 5);
413 gtk_signal_connect(GTK_OBJECT(w->window), "delete_event",
414 GTK_SIGNAL_FUNC(destroy_dialog), w->window);
415 gtk_signal_connect(GTK_OBJECT(w->window), "delete_event", GTK_SIGNAL_FUNC(free_warn_data), w);
416 gtk_widget_realize(w->window);
417 aol_icon(w->window->window);
419 fbox = gtk_vbox_new(FALSE, 5);
420 gtk_container_add(GTK_CONTAINER(w->window), fbox);
421 gtk_widget_show(fbox);
423 frame = gtk_frame_new(_("Warn"));
424 gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 5);
425 gtk_widget_show(frame);
427 vbox = gtk_vbox_new(FALSE, 5);
428 gtk_container_add(GTK_CONTAINER(frame), vbox);
429 gtk_widget_show(vbox);
431 g_snprintf(buf, 127, _("Do you really want to warn %s?"), who);
432 label = gtk_label_new(buf);
433 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
434 gtk_widget_show(label);
436 w->anon = gtk_check_button_new_with_label(_("Warn anonymously?"));
437 gtk_box_pack_start(GTK_BOX(vbox), w->anon, TRUE, TRUE, 5);
438 gtk_widget_show(w->anon);
440 label = gtk_label_new(_("Anonymous warnings are less harsh."));
441 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
442 gtk_widget_show(label);
444 bbox = gtk_hbox_new(TRUE, 10);
445 gtk_box_pack_start(GTK_BOX(fbox), bbox, FALSE, FALSE, 5);
446 gtk_widget_show(bbox);
448 cancel = picture_button(w->window, _("Cancel"), cancel_xpm);
449 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
450 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), w->window);
452 warn = picture_button(w->window, _("Warn"), warn_xpm);
453 gtk_box_pack_end(GTK_BOX(bbox), warn, FALSE, FALSE, 5);
454 gtk_signal_connect(GTK_OBJECT(warn), "clicked", GTK_SIGNAL_FUNC(do_warn), w);
456 gtk_widget_show(w->window);
459 void do_remove_buddy(GtkWidget *w, struct buddy *b)
461 struct group *g = find_group_by_buddy(b->gc, b->name);
462 struct gaim_connection *gc = b->gc;
463 struct conversation *cv;
465 if (!b)
466 return;
468 debug_printf(_("Removing '%s' from buddylist.\n"), b->name);
469 serv_remove_buddy(b->gc, b->name, g->name);
470 remove_buddy(gc, g, b);
471 do_export(gc);
472 build_edit_tree();
474 cv = find_conversation(b->name);
476 if (cv)
477 update_convo_add_button(cv);
481 void show_confirm_del(struct gaim_connection *gc, gchar *name)
483 struct confirm_del *b = g_new0(struct confirm_del, 1);
484 struct buddy *bd;
485 GtkWidget *hbox;
486 GtkWidget *vbox;
487 GtkWidget *fbox;
488 GtkWidget *frame;
489 gchar tmp[2048];
491 GAIM_DIALOG(b->window);
492 dialogwindows = g_list_prepend(dialogwindows, b->window);
494 g_snprintf(tmp, sizeof(tmp), _("Gaim - Remove %s?"), name);
495 gtk_window_set_title(GTK_WINDOW(b->window), tmp);
496 gtk_window_set_wmclass(GTK_WINDOW(b->window), "confirm_del", "Gaim");
497 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, FALSE, TRUE);
498 gtk_signal_connect(GTK_OBJECT(b->window), "delete_event",
499 GTK_SIGNAL_FUNC(destroy_dialog), b->window);
501 gtk_widget_realize(b->window);
503 vbox = gtk_vbox_new(FALSE, 0);
504 gtk_container_add(GTK_CONTAINER(b->window), vbox);
505 gtk_widget_show(vbox);
507 frame = gtk_frame_new(_("Remove Buddy"));
508 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
509 gtk_container_set_border_width(GTK_CONTAINER(frame), 5);
510 gtk_widget_show(frame);
512 fbox = gtk_vbox_new(FALSE, 5);
513 gtk_container_add(GTK_CONTAINER(frame), fbox);
514 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
515 gtk_widget_show(fbox);
517 g_snprintf(tmp, sizeof(tmp), _("You are about to remove '%s' from\nyour buddylist. Do you want to continue?"), name);
518 b->label = gtk_label_new(tmp);
519 gtk_misc_set_alignment(GTK_MISC(b->label), 0, 0.5);
520 gtk_label_set_justify(GTK_LABEL(b->label), GTK_JUSTIFY_LEFT);
521 gtk_box_pack_start(GTK_BOX(fbox), b->label, FALSE, FALSE, 0);
522 gtk_widget_show(b->label);
524 hbox = gtk_hbox_new(FALSE, 5);
525 gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
526 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, FALSE, 0);
527 gtk_widget_show(hbox);
529 b->ok = picture_button(b->window, _("Accept"), ok_xpm);
530 gtk_box_pack_start(GTK_BOX(hbox), b->ok, FALSE, FALSE, 5);
532 bd = find_buddy(gc, name);
534 if (bd)
535 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(do_remove_buddy), bd);
537 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
539 b->cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
540 gtk_box_pack_start(GTK_BOX(hbox), b->cancel, FALSE, FALSE, 5);
541 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
543 gtk_widget_show(b->window);
548 /*------------------------------------------------------------------------*/
549 /* The dialog for getting an error */
550 /*------------------------------------------------------------------------*/
552 GtkWidget *do_error_dialog(char *message, char *title)
554 GtkWidget *d;
555 GtkWidget *label;
556 GtkWidget *close;
559 d = gtk_dialog_new();
560 gtk_window_set_policy(GTK_WINDOW(d), FALSE, FALSE, TRUE);
561 gtk_widget_realize(d);
562 label = gtk_label_new(message);
563 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
564 gtk_widget_show(label);
565 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), label, FALSE, FALSE, 5);
567 close = picture_button(d, _("Close"), cancel_xpm);
569 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), close, FALSE, FALSE, 5);
571 gtk_container_set_border_width(GTK_CONTAINER(d), 5);
572 gtk_window_set_title(GTK_WINDOW(d), title);
573 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), d);
574 aol_icon(d->window);
576 gtk_widget_show(d);
577 gtk_widget_grab_focus(close);
578 return d;
583 static void do_im(GtkWidget *widget, GtkWidget *imentry)
585 char *who;
586 struct conversation *c;
588 who = g_strdup(gtk_entry_get_text(GTK_ENTRY(imentry)));
589 destroy_dialog(NULL, imdialog);
590 imdialog = NULL;
592 if (!g_strcasecmp(who, "")) {
593 g_free(who);
594 return;
597 c = find_conversation(who);
599 if (c == NULL) {
600 c = new_conversation(who);
601 } else {
602 gdk_window_raise(c->window->window);
604 g_free(who);
607 static void do_info(GtkWidget *widget, GtkWidget *infoentry)
609 char *who;
611 who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(infoentry))));
612 destroy_dialog(NULL, infodialog);
613 infodialog = NULL;
615 if (!g_strcasecmp(who, "")) {
616 g_free(who);
617 return;
620 /* what do we want to do about this case? */
621 if (connections)
622 serv_get_info(connections->data, who);
624 g_free(who);
627 void show_ee_dialog(int ee)
629 GtkWidget *ok;
630 GtkWidget *label;
631 GtkWidget *box;
632 GtkWidget *eedialog;
634 GAIM_DIALOG(eedialog);
635 gtk_widget_realize(eedialog);
636 ok = picture_button(eedialog, _("OK"), ok_xpm);
637 box = gtk_vbox_new(FALSE, 10);
639 if (ee == 0)
640 label = gtk_label_new("Amazing! Simply Amazing!");
641 else if (ee == 1)
642 label = gtk_label_new("Pimpin\' Penguin Style! *Waddle Waddle*");
643 else if (ee == 2)
644 label = gtk_label_new("You should be me. I'm so cute!");
645 else if (ee == 3)
646 label = gtk_label_new("Now that's what I like!");
647 else if (ee == 4)
648 label = gtk_label_new("Ahh, and excellent choice!");
649 else if (ee == 5)
650 label = gtk_label_new("Everytime you click my name, an angel gets its wings.");
651 else
652 label = gtk_label_new("This sunflower seed taste like pizza.");
654 gtk_widget_show(label);
655 gtk_widget_show(ok);
657 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 10);
658 gtk_box_pack_start(GTK_BOX(box), ok, FALSE, FALSE, 10);
660 gtk_widget_show(box);
662 gtk_container_add(GTK_CONTAINER(eedialog), box);
663 gtk_window_set_title(GTK_WINDOW(eedialog), "Gaim - SUPRISE!");
665 gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), eedialog);
666 gtk_widget_realize(eedialog);
667 aol_icon(eedialog->window);
669 gtk_widget_show(eedialog);
672 void show_im_dialog()
674 GtkWidget *mainbox;
675 GtkWidget *frame;
676 GtkWidget *fbox;
677 GtkWidget *bbox;
678 GtkWidget *button;
679 GtkWidget *imentry;
680 GtkWidget *label;
682 if (!imdialog) {
683 GAIM_DIALOG(imdialog);
684 gtk_window_set_wmclass(GTK_WINDOW(imdialog), "imdialog", "Gaim");
685 gtk_window_set_policy(GTK_WINDOW(imdialog), FALSE, TRUE, TRUE);
686 gtk_window_set_title(GTK_WINDOW(imdialog), _("Gaim - IM user"));
687 gtk_signal_connect(GTK_OBJECT(imdialog), "destroy",
688 GTK_SIGNAL_FUNC(destroy_dialog), imdialog);
689 gtk_widget_realize(imdialog);
690 aol_icon(imdialog->window);
692 mainbox = gtk_vbox_new(FALSE, 5);
693 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
694 gtk_container_add(GTK_CONTAINER(imdialog), mainbox);
696 frame = gtk_frame_new(_("Send Instant Message"));
697 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
699 fbox = gtk_hbox_new(FALSE, 5);
700 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
701 gtk_container_add(GTK_CONTAINER(frame), fbox);
703 label = gtk_label_new(_("IM who:"));
704 gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0);
706 imentry = gtk_entry_new();
707 gtk_box_pack_start(GTK_BOX(fbox), imentry, TRUE, TRUE, 0);
708 gtk_signal_connect(GTK_OBJECT(imentry), "activate", GTK_SIGNAL_FUNC(do_im), imentry);
709 gtk_widget_grab_focus(imentry);
711 bbox = gtk_hbox_new(FALSE, 5);
712 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
714 button = picture_button(imdialog, _("Cancel"), cancel_xpm);
715 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
716 gtk_signal_connect(GTK_OBJECT(button), "clicked",
717 GTK_SIGNAL_FUNC(destroy_dialog), imdialog);
719 button = picture_button(imdialog, _("OK"), ok_xpm);
720 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
721 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_im), imentry);
724 gtk_widget_show_all(imdialog);
727 void show_info_dialog()
729 GtkWidget *mainbox;
730 GtkWidget *frame;
731 GtkWidget *fbox;
732 GtkWidget *bbox;
733 GtkWidget *button;
734 GtkWidget *infoentry;
735 GtkWidget *label;
737 if (!infodialog) {
739 GAIM_DIALOG(infodialog);
740 gtk_window_set_wmclass(GTK_WINDOW(infodialog), "infodialog", "Gaim");
741 gtk_window_set_policy(GTK_WINDOW(infodialog), FALSE, TRUE, TRUE);
742 gtk_widget_realize(infodialog);
744 mainbox = gtk_vbox_new(FALSE, 5);
745 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
746 gtk_container_add(GTK_CONTAINER(infodialog), mainbox);
748 frame = gtk_frame_new(_("Get User Info"));
749 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
751 fbox = gtk_hbox_new(FALSE, 5);
752 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
753 gtk_container_add(GTK_CONTAINER(frame), fbox);
755 label = gtk_label_new(_("User:"));
756 gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0);
757 gtk_widget_show(label);
759 infoentry = gtk_entry_new();
760 gtk_box_pack_start(GTK_BOX(fbox), infoentry, TRUE, TRUE, 0);
762 /* Handle closes right */
763 gtk_signal_connect(GTK_OBJECT(infoentry), "activate",
764 GTK_SIGNAL_FUNC(do_info), infoentry);
765 gtk_signal_connect(GTK_OBJECT(infodialog), "destroy",
766 GTK_SIGNAL_FUNC(destroy_dialog), infodialog);
768 /* Buttons */
769 bbox = gtk_hbox_new(FALSE, 5);
770 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
772 button = picture_button(infodialog, _("Cancel"), cancel_xpm);
773 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
774 gtk_signal_connect(GTK_OBJECT(button), "clicked",
775 GTK_SIGNAL_FUNC(destroy_dialog), infodialog);
777 button = picture_button(infodialog, _("OK"), ok_xpm);
778 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
779 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_info), infoentry);
781 /* Finish up */
782 gtk_window_set_title(GTK_WINDOW(infodialog), _("Gaim - Get User Info"));
783 gtk_widget_grab_focus(infoentry);
785 aol_icon(infodialog->window);
787 gtk_widget_show_all(infodialog);
791 /*------------------------------------------------------------------------*/
792 /* The dialog for adding buddies */
793 /*------------------------------------------------------------------------*/
795 extern void add_callback(GtkWidget *, struct conversation *);
797 void do_add_buddy(GtkWidget *w, struct addbuddy *a)
799 char *grp, *who, *whoalias;
800 struct conversation *c;
802 who = gtk_entry_get_text(GTK_ENTRY(a->entry));
803 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(a->combo)->entry));
804 whoalias = gtk_entry_get_text(GTK_ENTRY(a->entry_for_alias));
806 c = find_conversation(who);
808 add_buddy(a->gc, grp, who, whoalias);
809 serv_add_buddy(a->gc, who);
811 if (c != NULL) {
812 update_buttons_by_protocol(c);
815 do_export(a->gc);
817 destroy_dialog(NULL, a->window);
820 void do_add_group(GtkWidget *w, struct addbuddy *a)
822 char *grp;
824 grp = gtk_entry_get_text(GTK_ENTRY(a->entry));
826 if (!a->gc)
827 a->gc = connections->data;
829 add_group(a->gc, grp);
830 do_export(a->gc);
832 destroy_dialog(NULL, a->window);
836 static GList *groups_tree(struct gaim_connection *gc)
838 GList *tmp = NULL;
839 char *tmp2;
840 struct group *g;
841 GSList *grp = gc->groups;
843 if (!grp) {
844 tmp2 = g_strdup(_("Buddies"));
845 tmp = g_list_append(tmp, tmp2);
846 } else {
847 while (grp) {
848 g = (struct group *)grp->data;
849 tmp2 = g->name;
850 tmp = g_list_append(tmp, tmp2);
851 grp = g_slist_next(grp);
854 return tmp;
857 static void free_dialog(GtkWidget *w, struct addbuddy *a)
859 g_free(a);
863 void show_add_group(struct gaim_connection *gc)
865 GtkWidget *cancel;
866 GtkWidget *add;
867 GtkWidget *label;
868 GtkWidget *bbox;
869 GtkWidget *vbox;
870 GtkWidget *topbox;
871 GtkWidget *frame;
873 struct addbuddy *a = g_new0(struct addbuddy, 1);
874 a->gc = gc;
876 GAIM_DIALOG(a->window);
877 gtk_window_set_wmclass(GTK_WINDOW(a->window), "add_group", "Gaim");
878 gtk_window_set_policy(GTK_WINDOW(a->window), FALSE, FALSE, TRUE);
879 gtk_widget_realize(a->window);
880 dialogwindows = g_list_prepend(dialogwindows, a->window);
882 bbox = gtk_hbox_new(TRUE, 10);
883 topbox = gtk_hbox_new(FALSE, 5);
884 vbox = gtk_vbox_new(FALSE, 5);
886 a->entry = gtk_entry_new();
887 /* Put the buttons in the box */
889 add = picture_button(a->window, _("Add"), add_xpm);
891 cancel = picture_button(a->window, _("Cancel"), cancel_xpm);
893 gtk_box_pack_start(GTK_BOX(bbox), add, FALSE, FALSE, 5);
894 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
896 frame = gtk_frame_new(NULL);
897 gtk_frame_set_label(GTK_FRAME(frame), _("Add Group"));
899 label = gtk_label_new(_("Group"));
900 gtk_widget_show(label);
901 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
902 gtk_box_pack_start(GTK_BOX(topbox), a->entry, FALSE, FALSE, 5);
904 /* And the boxes in the box */
905 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5);
906 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5);
908 /* Handle closes right */
909 gtk_signal_connect(GTK_OBJECT(a->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), a->window);
910 gtk_signal_connect(GTK_OBJECT(a->window), "destroy", GTK_SIGNAL_FUNC(free_dialog), a);
911 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), a->window);
912 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(do_add_group), a);
913 gtk_signal_connect(GTK_OBJECT(a->entry), "activate", GTK_SIGNAL_FUNC(do_add_group), a);
914 /* Finish up */
915 gtk_widget_show(add);
916 gtk_widget_show(cancel);
917 gtk_widget_show(a->entry);
918 gtk_widget_show(topbox);
919 gtk_widget_show(bbox);
920 gtk_widget_show(vbox);
921 gtk_widget_show(frame);
922 gtk_window_set_title(GTK_WINDOW(a->window), _("Gaim - Add Group"));
923 gtk_window_set_focus(GTK_WINDOW(a->window), a->entry);
924 gtk_container_add(GTK_CONTAINER(frame), vbox);
925 gtk_container_add(GTK_CONTAINER(a->window), frame);
926 gtk_container_set_border_width(GTK_CONTAINER(a->window), 5);
927 gtk_widget_realize(a->window);
928 aol_icon(a->window->window);
930 gtk_widget_show(a->window);
933 static void addbuddy_select_account(GtkObject *w, struct gaim_connection *gc)
935 struct addbuddy *b = gtk_object_get_user_data(w);
937 /* Save our account */
938 b->gc = gc;
940 /* We also want to update our group list */
941 gtk_combo_set_popdown_strings(GTK_COMBO(b->combo), groups_tree(gc));
944 static void create_online_user_names(struct addbuddy *b)
946 char buf[2048]; /* Never hurts to be safe ;-) */
947 GSList *g = connections;
948 struct gaim_connection *c;
949 GtkWidget *menu, *opt;
950 int count = 0;
951 int place = 0;
953 menu = gtk_menu_new();
955 while (g) {
956 c = (struct gaim_connection *)g->data;
957 g_snprintf(buf, sizeof(buf), "%s (%s)",
958 c->username, c->prpl->name());
959 opt = gtk_menu_item_new_with_label(buf);
960 gtk_object_set_user_data(GTK_OBJECT(opt), b);
961 gtk_signal_connect(GTK_OBJECT(opt), "activate",
962 GTK_SIGNAL_FUNC(addbuddy_select_account),
964 gtk_widget_show(opt);
965 gtk_menu_append(GTK_MENU(menu), opt);
967 /* Now check to see if it's our current menu */
968 if (c == b->gc) {
969 place = count;
970 gtk_menu_item_activate(GTK_MENU_ITEM(opt));
971 gtk_option_menu_set_history(GTK_OPTION_MENU(b->account), count);
973 /* Do the cha cha cha */
976 count++;
978 g = g->next;
981 gtk_option_menu_remove_menu(GTK_OPTION_MENU(b->account));
982 gtk_option_menu_set_menu(GTK_OPTION_MENU(b->account), menu);
983 gtk_option_menu_set_history(GTK_OPTION_MENU(b->account), place);
985 gtk_widget_show(b->account);
986 gtk_widget_show(b->account->parent);
990 void show_add_buddy(struct gaim_connection *gc, char *buddy, char *group, char *alias)
992 GtkWidget *mainbox;
993 GtkWidget *frame;
994 GtkWidget *table;
995 GtkWidget *bbox;
996 GtkWidget *cancel;
997 GtkWidget *add;
998 GtkWidget *label;
1000 struct addbuddy *a = g_new0(struct addbuddy, 1);
1001 a->gc = gc ? gc : connections->data;
1003 GAIM_DIALOG(a->window);
1004 gtk_window_set_wmclass(GTK_WINDOW(a->window), "add_buddy", "Gaim");
1005 gtk_window_set_policy(GTK_WINDOW(a->window), FALSE, FALSE, TRUE);
1006 gtk_window_set_title(GTK_WINDOW(a->window), _("Gaim - Add Buddy"));
1008 gtk_widget_realize(a->window);
1009 aol_icon(a->window->window);
1010 gtk_signal_connect(GTK_OBJECT(a->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), a->window);
1011 gtk_signal_connect(GTK_OBJECT(a->window), "destroy", GTK_SIGNAL_FUNC(free_dialog), a);
1012 dialogwindows = g_list_prepend(dialogwindows, a->window);
1014 mainbox = gtk_vbox_new(FALSE, 5);
1015 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
1016 gtk_container_add(GTK_CONTAINER(a->window), mainbox);
1018 frame = gtk_frame_new(_("Add Buddy"));
1019 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
1020 gtk_widget_show(frame);
1022 table = gtk_table_new(4, 2, FALSE);
1023 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
1024 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1025 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
1026 gtk_container_add(GTK_CONTAINER(frame), table);
1028 label = gtk_label_new(_("Contact"));
1029 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
1031 a->entry = gtk_entry_new();
1032 gtk_table_attach_defaults(GTK_TABLE(table), a->entry, 1, 2, 0, 1);
1033 gtk_window_set_focus(GTK_WINDOW(a->window), a->entry);
1034 if (buddy != NULL)
1035 gtk_entry_set_text(GTK_ENTRY(a->entry), buddy);
1036 gtk_signal_connect(GTK_OBJECT(a->entry), "activate", GTK_SIGNAL_FUNC(do_add_buddy), a);
1038 label = gtk_label_new(_("Alias"));
1039 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
1041 a->entry_for_alias = gtk_entry_new();
1042 gtk_table_attach_defaults(GTK_TABLE(table), a->entry_for_alias, 1, 2, 1, 2);
1043 if (alias != NULL)
1044 gtk_entry_set_text(GTK_ENTRY(a->entry_for_alias), alias);
1046 label = gtk_label_new(_("Group"));
1047 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
1049 a->combo = gtk_combo_new();
1050 gtk_combo_set_popdown_strings(GTK_COMBO(a->combo), groups_tree(a->gc));
1051 gtk_table_attach_defaults(GTK_TABLE(table), a->combo, 1, 2, 2, 3);
1053 /* Set up stuff for the account box */
1054 label = gtk_label_new(_("Add To"));
1055 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
1057 a->account = gtk_option_menu_new();
1058 gtk_table_attach_defaults(GTK_TABLE(table), a->account, 1, 2, 3, 4);
1060 create_online_user_names(a);
1062 /* End of account box */
1064 bbox = gtk_hbox_new(FALSE, 5);
1065 gtk_box_pack_start(GTK_BOX(mainbox), bbox, TRUE, TRUE, 0);
1067 cancel = picture_button(a->window, _("Cancel"), cancel_xpm);
1068 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 0);
1069 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), a->window);
1071 add = picture_button(a->window, _("Add"), add_xpm);
1072 gtk_box_pack_end(GTK_BOX(bbox), add, FALSE, FALSE, 0);
1073 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(do_add_buddy), a);
1075 gtk_widget_show_all(a->window);
1076 if (group != NULL)
1077 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(a->combo)->entry), group);
1081 /*------------------------------------------------------------------------*/
1082 /* The dialog for new buddy pounces */
1083 /*------------------------------------------------------------------------*/
1086 void do_new_bp(GtkWidget *w, struct addbp *b)
1088 struct buddy_pounce *bp;
1090 if (strlen(gtk_entry_get_text(GTK_ENTRY(b->nameentry))) == 0) {
1091 do_error_dialog(_("Please enter a buddy to pounce."), _("Buddy Pounce Error"));
1092 return;
1095 if(!b->buddy_pounce)
1096 bp = g_new0(struct buddy_pounce, 1);
1097 else
1098 bp = b->buddy_pounce;
1101 g_snprintf(bp->name, 80, "%s", gtk_entry_get_text(GTK_ENTRY(b->nameentry)));
1102 g_snprintf(bp->message, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->messentry)));
1103 g_snprintf(bp->command, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->commentry)));
1104 g_snprintf(bp->sound, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->soundentry)));
1105 g_snprintf(bp->pouncer, 80, "%s", b->user->username);
1107 bp->protocol = b->user->protocol;
1109 bp->options = 0;
1111 if (GTK_TOGGLE_BUTTON(b->popupnotify)->active)
1112 bp->options |= OPT_POUNCE_NOTIFY;
1114 if (GTK_TOGGLE_BUTTON(b->openwindow)->active)
1115 bp->options |= OPT_POUNCE_POPUP;
1117 if (GTK_TOGGLE_BUTTON(b->sendim)->active)
1118 bp->options |= OPT_POUNCE_SEND_IM;
1120 if (GTK_TOGGLE_BUTTON(b->command)->active)
1121 bp->options |= OPT_POUNCE_COMMAND;
1123 if (GTK_TOGGLE_BUTTON(b->sound)->active)
1124 bp->options |= OPT_POUNCE_SOUND;
1126 if (GTK_TOGGLE_BUTTON(b->p_signon)->active)
1127 bp->options |= OPT_POUNCE_SIGNON;
1129 if (GTK_TOGGLE_BUTTON(b->p_unaway)->active)
1130 bp->options |= OPT_POUNCE_UNAWAY;
1132 if (GTK_TOGGLE_BUTTON(b->p_unidle)->active)
1133 bp->options |= OPT_POUNCE_UNIDLE;
1135 if (GTK_TOGGLE_BUTTON(b->p_typing)->active)
1136 bp->options |= OPT_POUNCE_TYPING;
1138 if (GTK_TOGGLE_BUTTON(b->save)->active)
1139 bp->options |= OPT_POUNCE_SAVE;
1141 if(!b->buddy_pounce)
1142 buddy_pounces = g_list_append(buddy_pounces, bp);
1144 do_bp_menu();
1146 destroy_dialog(NULL, b->window);
1148 save_prefs();
1149 g_free(b);
1152 static void pounce_choose(GtkWidget *opt, struct addbp *b)
1154 struct aim_user *u = gtk_object_get_user_data(GTK_OBJECT(opt));
1155 b->user = u;
1158 static GtkWidget *pounce_user_menu(struct addbp *b, struct gaim_connection *gc)
1160 GtkWidget *optmenu;
1161 GtkWidget *menu;
1162 GtkWidget *opt;
1163 GSList *u = aim_users;
1164 struct aim_user *a;
1165 int count = 0;
1166 int place = 0;
1168 optmenu = gtk_option_menu_new();
1170 menu = gtk_menu_new();
1172 while (u) {
1173 a = (struct aim_user *)u->data;
1174 opt = gtk_menu_item_new_with_label(a->username);
1175 gtk_object_set_user_data(GTK_OBJECT(opt), a);
1176 gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(pounce_choose), b);
1177 gtk_menu_append(GTK_MENU(menu), opt);
1178 gtk_widget_show(opt);
1180 if (b->user == a) {
1181 gtk_menu_item_activate(GTK_MENU_ITEM(opt));
1182 place = count;
1185 count++;
1187 u = u->next;
1190 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
1191 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), place);
1193 b->menu = optmenu;
1195 return optmenu;
1199 void show_new_bp(char *name, struct gaim_connection *gc, int idle, int away, struct buddy_pounce *edit_bp)
1201 GtkWidget *label;
1202 GtkWidget *bbox;
1203 GtkWidget *vbox;
1204 GtkWidget *button;
1205 GtkWidget *frame;
1206 GtkWidget *table;
1207 GtkWidget *optmenu;
1209 struct addbp *b = g_new0(struct addbp, 1);
1211 if(edit_bp) {
1212 b->buddy_pounce = edit_bp;
1213 b->user = find_user(edit_bp->pouncer, edit_bp->protocol);
1214 } else {
1215 b->user = gc ? gc->user : aim_users->data;
1216 b->buddy_pounce = NULL;
1219 GAIM_DIALOG(b->window);
1220 dialogwindows = g_list_prepend(dialogwindows, b->window);
1221 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
1222 gtk_window_set_wmclass(GTK_WINDOW(b->window), "new_bp", "Gaim");
1223 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - New Buddy Pounce"));
1224 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1225 gtk_widget_realize(b->window);
1226 aol_icon(b->window->window);
1228 vbox = gtk_vbox_new(FALSE, 5);
1229 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1230 gtk_container_add(GTK_CONTAINER(b->window), vbox);
1231 gtk_widget_show(vbox);
1233 /* <pounce type="who"> */
1234 frame = gtk_frame_new(_("Pounce Who"));
1235 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
1236 gtk_widget_show(GTK_WIDGET(frame));
1238 table = gtk_table_new(2, 2, FALSE);
1239 gtk_container_add(GTK_CONTAINER(frame), table);
1240 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
1241 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1242 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
1243 gtk_widget_show(table);
1245 label = gtk_label_new(_("Account"));
1246 gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
1247 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
1248 gtk_widget_show(label);
1250 optmenu = pounce_user_menu(b, gc);
1251 gtk_table_attach(GTK_TABLE(table), optmenu, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1252 gtk_widget_show(optmenu);
1254 label = gtk_label_new(_("Buddy"));
1255 gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
1256 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1257 gtk_widget_show(label);
1259 b->nameentry = gtk_entry_new();
1260 gtk_table_attach(GTK_TABLE(table), b->nameentry, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1261 if (name !=NULL)
1262 gtk_entry_set_text(GTK_ENTRY(b->nameentry), name);
1263 else if(edit_bp)
1264 gtk_entry_set_text(GTK_ENTRY(b->nameentry), edit_bp->name);
1265 gtk_window_set_focus(GTK_WINDOW(b->window), b->nameentry);
1266 gtk_widget_show(b->nameentry);
1267 /* </pounce type="who"> */
1270 /* <pounce type="when"> */
1271 frame = gtk_frame_new(_("Pounce When"));
1272 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
1273 gtk_widget_show(GTK_WIDGET(frame));
1275 table = gtk_table_new(2, 2, FALSE);
1276 gtk_container_add(GTK_CONTAINER(frame), table);
1277 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
1278 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1279 gtk_widget_show(table);
1281 b->p_signon = gtk_check_button_new_with_label(_("Pounce on sign on"));
1282 if(edit_bp)
1283 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_signon),
1284 (edit_bp->options & OPT_POUNCE_SIGNON) ? TRUE : FALSE);
1285 else
1286 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_signon), TRUE);
1287 gtk_table_attach(GTK_TABLE(table), b->p_signon, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
1288 gtk_widget_show(b->p_signon);
1290 b->p_unaway = gtk_check_button_new_with_label(_("Pounce on return from away"));
1291 if (away)
1292 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unaway), TRUE);
1293 else if(edit_bp)
1294 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unaway),
1295 (edit_bp->options & OPT_POUNCE_UNAWAY) ? TRUE : FALSE);
1296 gtk_table_attach(GTK_TABLE(table), b->p_unaway, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1297 gtk_widget_show(b->p_unaway);
1299 b->p_unidle = gtk_check_button_new_with_label(_("Pounce on return from idle"));
1300 if (idle)
1301 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unidle), TRUE);
1302 else if(edit_bp)
1303 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unidle),
1304 (edit_bp->options & OPT_POUNCE_UNIDLE) ? TRUE : FALSE);
1305 gtk_table_attach(GTK_TABLE(table), b->p_unidle, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1306 gtk_widget_show(b->p_unidle);
1308 b->p_typing = gtk_check_button_new_with_label(_("Pounce when buddy is typing to you"));
1309 if (edit_bp)
1310 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_typing),
1311 (edit_bp->options & OPT_POUNCE_TYPING) ? TRUE : FALSE);
1312 gtk_table_attach(GTK_TABLE(table), b->p_typing,1,2,1,2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1313 gtk_widget_show(b->p_typing);
1315 /* </pounce type="when"> */
1317 /* <pounce type="action"> */
1318 frame = gtk_frame_new(_("Pounce Action"));
1319 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
1320 gtk_widget_show(GTK_WIDGET(frame));
1322 table = gtk_table_new(4, 2, FALSE);
1323 gtk_container_add(GTK_CONTAINER(frame), table);
1324 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
1325 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1326 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
1327 gtk_widget_show(table);
1329 b->openwindow = gtk_check_button_new_with_label(_("Open IM Window"));
1330 if(edit_bp)
1331 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->openwindow),
1332 (edit_bp->options & OPT_POUNCE_POPUP) ? TRUE : FALSE);
1333 else
1334 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->openwindow), FALSE);
1335 gtk_table_attach(GTK_TABLE(table), b->openwindow, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
1336 gtk_widget_show(b->openwindow);
1338 b->popupnotify = gtk_check_button_new_with_label(_("Popup Notification"));
1339 if(edit_bp)
1340 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->popupnotify),
1341 (edit_bp->options & OPT_POUNCE_NOTIFY) ? TRUE : FALSE);
1342 else
1343 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->popupnotify), FALSE);
1344 gtk_table_attach(GTK_TABLE(table), b->popupnotify, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
1345 gtk_widget_show(b->popupnotify);
1347 b->sendim = gtk_check_button_new_with_label(_("Send Message"));
1348 if(edit_bp)
1349 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sendim),
1350 (edit_bp->options & OPT_POUNCE_SEND_IM) ? TRUE : FALSE);
1351 else
1352 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sendim), TRUE);
1353 gtk_table_attach(GTK_TABLE(table), b->sendim, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1354 gtk_widget_show(b->sendim);
1356 b->messentry = gtk_entry_new();
1357 gtk_table_attach(GTK_TABLE(table), b->messentry, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1358 gtk_signal_connect(GTK_OBJECT(b->messentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b);
1359 if(edit_bp) {
1360 gtk_widget_set_sensitive(GTK_WIDGET(b->messentry),
1361 (edit_bp->options & OPT_POUNCE_SEND_IM) ? TRUE : FALSE);
1362 gtk_entry_set_text(GTK_ENTRY(b->messentry), edit_bp->message);
1364 gtk_widget_show(b->messentry);
1366 gtk_signal_connect(GTK_OBJECT(b->sendim), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->messentry);
1368 b->command = gtk_check_button_new_with_label(_("Execute command on pounce"));
1369 gtk_table_attach(GTK_TABLE(table), b->command, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1370 if(edit_bp)
1371 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->command),
1372 (edit_bp->options & OPT_POUNCE_COMMAND) ? TRUE : FALSE);
1373 else
1374 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->command), FALSE);
1375 gtk_widget_show(b->command);
1377 b->commentry = gtk_entry_new();
1378 gtk_table_attach(GTK_TABLE(table), b->commentry, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1379 gtk_signal_connect(GTK_OBJECT(b->commentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b);
1380 if(edit_bp) {
1381 gtk_widget_set_sensitive(GTK_WIDGET(b->commentry),
1382 (edit_bp->options & OPT_POUNCE_COMMAND) ? TRUE : FALSE);
1383 gtk_entry_set_text(GTK_ENTRY(b->commentry), edit_bp->command);
1385 else
1386 gtk_widget_set_sensitive(GTK_WIDGET(b->commentry), FALSE);
1387 gtk_widget_show(b->commentry);
1388 gtk_signal_connect(GTK_OBJECT(b->command), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->commentry);
1390 b->sound = gtk_check_button_new_with_label(_("Play sound on pounce"));
1391 if(edit_bp)
1392 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sound),
1393 (edit_bp->options & OPT_POUNCE_SOUND) ? TRUE : FALSE);
1394 else
1395 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sound), FALSE);
1396 gtk_table_attach(GTK_TABLE(table), b->sound, 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
1397 gtk_widget_show(b->sound);
1399 b->soundentry = gtk_entry_new();
1400 gtk_table_attach(GTK_TABLE(table), b->soundentry, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1401 gtk_signal_connect(GTK_OBJECT(b->soundentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b);
1402 if(edit_bp) {
1403 gtk_widget_set_sensitive(GTK_WIDGET(b->soundentry),
1404 (edit_bp->options & OPT_POUNCE_SOUND) ? TRUE : FALSE);
1405 gtk_entry_set_text(GTK_ENTRY(b->soundentry), edit_bp->sound);
1406 } else
1407 gtk_widget_set_sensitive(GTK_WIDGET(b->soundentry), FALSE);
1408 gtk_widget_show(b->soundentry);
1409 gtk_signal_connect(GTK_OBJECT(b->sound), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->soundentry);
1410 /* </pounce type="action"> */
1412 b->save = gtk_check_button_new_with_label(_("Save this pounce after activation"));
1413 gtk_container_set_border_width(GTK_CONTAINER(b->save), 7);
1414 if(edit_bp)
1415 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->save),
1416 (edit_bp->options & OPT_POUNCE_SAVE) ? TRUE : FALSE);
1417 else
1418 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->save), FALSE);
1419 gtk_box_pack_start(GTK_BOX(vbox), b->save, FALSE, FALSE, 0);
1420 gtk_widget_show(b->save);
1422 bbox = gtk_hbox_new(FALSE, 5);
1423 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
1424 gtk_widget_show(bbox);
1426 button = picture_button(b->window, _("Cancel"), cancel_xpm);
1427 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1428 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
1430 button = picture_button(b->window, _("OK"), ok_xpm);
1431 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_new_bp), b);
1432 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
1434 gtk_widget_show(b->window);
1439 /*------------------------------------------------------------------------*/
1440 /* The dialog for SET INFO / SET DIR INFO */
1441 /*------------------------------------------------------------------------*/
1443 void do_save_info(GtkWidget *widget, struct set_info_dlg *b)
1445 gchar *junk;
1446 struct gaim_connection *gc;
1448 junk = gtk_editable_get_chars(GTK_EDITABLE(b->text), 0, -1);
1450 if (b->user) {
1451 strncpy_withhtml(b->user->user_info, junk, sizeof b->user->user_info);
1452 gc = b->user->gc;
1454 save_prefs();
1456 if (gc)
1457 serv_set_info(gc, b->user->user_info);
1459 g_free(junk);
1460 destroy_dialog(NULL, b->window);
1461 g_free(b);
1464 void do_set_dir(GtkWidget *widget, struct set_dir_dlg *b)
1466 char *first = gtk_entry_get_text(GTK_ENTRY(b->first));
1467 int web = GTK_TOGGLE_BUTTON(b->web)->active;
1468 char *middle = gtk_entry_get_text(GTK_ENTRY(b->middle));
1469 char *last = gtk_entry_get_text(GTK_ENTRY(b->last));
1470 char *maiden = gtk_entry_get_text(GTK_ENTRY(b->maiden));
1471 char *city = gtk_entry_get_text(GTK_ENTRY(b->city));
1472 char *state = gtk_entry_get_text(GTK_ENTRY(b->state));
1473 char *country = gtk_entry_get_text(GTK_ENTRY(b->country));
1475 serv_set_dir(b->gc, first, middle, last, maiden, city, state, country, web);
1477 destroy_dialog(NULL, b->window);
1478 g_free(b);
1481 void show_set_dir(struct gaim_connection *gc)
1483 GtkWidget *label;
1484 GtkWidget *bot;
1485 GtkWidget *vbox;
1486 GtkWidget *hbox;
1487 GtkWidget *frame;
1488 GtkWidget *fbox;
1489 char buf[256];
1491 struct set_dir_dlg *b = g_new0(struct set_dir_dlg, 1);
1492 b->gc = gc;
1494 GAIM_DIALOG(b->window);
1495 dialogwindows = g_list_prepend(dialogwindows, b->window);
1496 gtk_window_set_wmclass(GTK_WINDOW(b->window), "set_dir", "Gaim");
1497 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
1498 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Set Dir Info"));
1499 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1500 gtk_widget_realize(b->window);
1501 aol_icon(b->window->window);
1503 fbox = gtk_vbox_new(FALSE, 5);
1504 gtk_container_add(GTK_CONTAINER(b->window), fbox);
1505 gtk_widget_show(fbox);
1507 frame = gtk_frame_new(_("Directory Info"));
1508 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
1509 gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 0);
1510 gtk_widget_show(frame);
1512 vbox = gtk_vbox_new(FALSE, 5);
1513 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1514 gtk_container_add(GTK_CONTAINER(frame), vbox);
1515 gtk_widget_show(vbox);
1517 g_snprintf(buf, sizeof(buf), "Setting Dir Info for %s:", gc->username);
1518 label = gtk_label_new(buf);
1519 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5);
1520 gtk_widget_show(label);
1522 b->first = gtk_entry_new();
1523 b->middle = gtk_entry_new();
1524 b->last = gtk_entry_new();
1525 b->maiden = gtk_entry_new();
1526 b->city = gtk_entry_new();
1527 b->state = gtk_entry_new();
1528 b->country = gtk_entry_new();
1529 b->web = gtk_check_button_new_with_label(_("Allow Web Searches To Find Your Info"));
1531 /* Line 1 */
1532 label = gtk_label_new(_("First Name"));
1533 gtk_widget_show(label);
1535 hbox = gtk_hbox_new(FALSE, 5);
1536 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1537 gtk_box_pack_end(GTK_BOX(hbox), b->first, FALSE, FALSE, 0);
1539 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1540 gtk_widget_show(hbox);
1542 /* Line 2 */
1543 label = gtk_label_new(_("Middle Name"));
1544 gtk_widget_show(label);
1546 hbox = gtk_hbox_new(FALSE, 5);
1547 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1548 gtk_box_pack_end(GTK_BOX(hbox), b->middle, FALSE, FALSE, 0);
1550 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1551 gtk_widget_show(hbox);
1554 /* Line 3 */
1555 label = gtk_label_new(_("Last Name"));
1556 gtk_widget_show(label);
1558 hbox = gtk_hbox_new(FALSE, 5);
1559 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1560 gtk_box_pack_end(GTK_BOX(hbox), b->last, FALSE, FALSE, 0);
1562 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1563 gtk_widget_show(hbox);
1565 /* Line 4 */
1566 label = gtk_label_new(_("Maiden Name"));
1567 gtk_widget_show(label);
1569 hbox = gtk_hbox_new(FALSE, 5);
1570 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1571 gtk_box_pack_end(GTK_BOX(hbox), b->maiden, FALSE, FALSE, 0);
1573 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1574 gtk_widget_show(hbox);
1576 /* Line 5 */
1577 label = gtk_label_new(_("City"));
1578 gtk_widget_show(label);
1580 hbox = gtk_hbox_new(FALSE, 5);
1581 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1582 gtk_box_pack_end(GTK_BOX(hbox), b->city, FALSE, FALSE, 0);
1584 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1585 gtk_widget_show(hbox);
1587 /* Line 6 */
1588 label = gtk_label_new(_("State"));
1589 gtk_widget_show(label);
1591 hbox = gtk_hbox_new(FALSE, 5);
1592 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1593 gtk_box_pack_end(GTK_BOX(hbox), b->state, FALSE, FALSE, 0);
1595 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1596 gtk_widget_show(hbox);
1598 /* Line 7 */
1599 label = gtk_label_new(_("Country"));
1600 gtk_widget_show(label);
1602 hbox = gtk_hbox_new(FALSE, 5);
1603 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1604 gtk_box_pack_end(GTK_BOX(hbox), b->country, FALSE, FALSE, 0);
1606 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1607 gtk_widget_show(hbox);
1609 /* Line 8 */
1611 hbox = gtk_hbox_new(FALSE, 5);
1612 gtk_box_pack_start(GTK_BOX(hbox), b->web, TRUE, TRUE, 0);
1613 gtk_widget_show(hbox);
1614 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1616 gtk_widget_show(b->first);
1617 gtk_widget_show(b->middle);
1618 gtk_widget_show(b->last);
1619 gtk_widget_show(b->maiden);
1620 gtk_widget_show(b->city);
1621 gtk_widget_show(b->state);
1622 gtk_widget_show(b->country);
1623 gtk_widget_show(b->web);
1625 /* And add the buttons */
1627 bot = gtk_hbox_new(FALSE, 5);
1628 gtk_box_pack_start(GTK_BOX(fbox), bot, FALSE, FALSE, 0);
1629 gtk_widget_show(bot);
1631 b->cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
1632 gtk_box_pack_end(GTK_BOX(bot), b->cancel, FALSE, FALSE, 0);
1633 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1635 b->save = picture_button(b->window, _("Save"), save_xpm);
1636 gtk_box_pack_end(GTK_BOX(bot), b->save, FALSE, FALSE, 0);
1637 gtk_signal_connect(GTK_OBJECT(b->save), "clicked", GTK_SIGNAL_FUNC(do_set_dir), b);
1639 gtk_window_set_focus(GTK_WINDOW(b->window), b->first);
1641 gtk_widget_show(b->window);
1644 void do_change_password(GtkWidget *widget, struct passwddlg *b)
1646 gchar *orig, *new1, *new2;
1648 orig = gtk_entry_get_text(GTK_ENTRY(b->original));
1649 new1 = gtk_entry_get_text(GTK_ENTRY(b->new1));
1650 new2 = gtk_entry_get_text(GTK_ENTRY(b->new2));
1652 if (g_strcasecmp(new1, new2)) {
1653 do_error_dialog(_("New Passwords Do Not Match"), _("Gaim - Change Password Error"));
1654 return;
1657 if ((strlen(orig) < 1) || (strlen(new1) < 1) || (strlen(new2) < 1)) {
1658 do_error_dialog(_("Fill out all fields completely"), _("Gaim - Change Password Error"));
1659 return;
1662 serv_change_passwd(b->gc, orig, new1);
1664 destroy_dialog(NULL, b->window);
1665 g_free(b);
1668 void show_change_passwd(struct gaim_connection *gc)
1670 GtkWidget *hbox;
1671 GtkWidget *label;
1672 GtkWidget *vbox;
1673 GtkWidget *fbox;
1674 GtkWidget *frame;
1675 char buf[256];
1677 struct passwddlg *b = g_new0(struct passwddlg, 1);
1678 b->gc = gc;
1680 GAIM_DIALOG(b->window);
1681 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
1682 gtk_window_set_wmclass(GTK_WINDOW(b->window), "change_passwd", "Gaim");
1683 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Password Change"));
1684 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1685 gtk_widget_realize(b->window);
1686 aol_icon(b->window->window);
1687 dialogwindows = g_list_prepend(dialogwindows, b->window);
1689 fbox = gtk_vbox_new(FALSE, 5);
1690 gtk_container_border_width(GTK_CONTAINER(fbox), 5);
1691 gtk_container_add(GTK_CONTAINER(b->window), fbox);
1692 gtk_widget_show(fbox);
1694 frame = gtk_frame_new(_("Change Password"));
1695 gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 0);
1696 gtk_widget_show(frame);
1698 vbox = gtk_vbox_new(FALSE, 5);
1699 gtk_container_border_width(GTK_CONTAINER(vbox), 5);
1700 gtk_container_add(GTK_CONTAINER(frame), vbox);
1701 gtk_widget_show(vbox);
1703 g_snprintf(buf, sizeof(buf), "Changing password for %s:", gc->username);
1704 label = gtk_label_new(buf);
1705 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5);
1706 gtk_widget_show(label);
1708 /* First Line */
1709 hbox = gtk_hbox_new(FALSE, 5);
1710 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1711 gtk_widget_show(hbox);
1713 label = gtk_label_new(_("Original Password"));
1714 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1715 gtk_widget_show(label);
1717 b->original = gtk_entry_new();
1718 gtk_entry_set_visibility(GTK_ENTRY(b->original), FALSE);
1719 gtk_box_pack_end(GTK_BOX(hbox), b->original, FALSE, FALSE, 0);
1720 gtk_widget_show(b->original);
1722 /* Next Line */
1723 hbox = gtk_hbox_new(FALSE, 5);
1724 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1725 gtk_widget_show(hbox);
1727 label = gtk_label_new(_("New Password"));
1728 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1729 gtk_widget_show(label);
1731 b->new1 = gtk_entry_new();
1732 gtk_entry_set_visibility(GTK_ENTRY(b->new1), FALSE);
1733 gtk_box_pack_end(GTK_BOX(hbox), b->new1, FALSE, FALSE, 0);
1734 gtk_widget_show(b->new1);
1736 /* Next Line */
1737 hbox = gtk_hbox_new(FALSE, 5);
1738 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1739 gtk_widget_show(hbox);
1741 label = gtk_label_new(_("New Password (again)"));
1742 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1743 gtk_widget_show(label);
1745 b->new2 = gtk_entry_new();
1746 gtk_entry_set_visibility(GTK_ENTRY(b->new2), FALSE);
1747 gtk_box_pack_end(GTK_BOX(hbox), b->new2, FALSE, FALSE, 0);
1748 gtk_widget_show(b->new2);
1750 /* Now do our row of buttons */
1751 hbox = gtk_hbox_new(FALSE, 5);
1752 gtk_box_pack_start(GTK_BOX(fbox), hbox, FALSE, FALSE, 0);
1753 gtk_widget_show(hbox);
1755 b->cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
1756 gtk_box_pack_end(GTK_BOX(hbox), b->cancel, FALSE, FALSE, 0);
1757 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1759 b->ok = picture_button(b->window, _("OK"), ok_xpm);
1760 gtk_box_pack_end(GTK_BOX(hbox), b->ok, FALSE, FALSE, 0);
1761 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(do_change_password), b);
1764 gtk_widget_show(b->window);
1767 void show_set_info(struct gaim_connection *gc)
1769 GtkWidget *buttons;
1770 GtkWidget *label;
1771 GtkWidget *vbox;
1772 gchar *buf;
1773 struct aim_user *tmp;
1775 struct set_info_dlg *b = g_new0(struct set_info_dlg, 1);
1776 tmp = gc->user;
1777 b->user = tmp;
1779 GAIM_DIALOG(b->window);
1780 gtk_window_set_wmclass(GTK_WINDOW(b->window), "set_info", "Gaim");
1781 dialogwindows = g_list_prepend(dialogwindows, b->window);
1782 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Set User Info"));
1783 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1784 gtk_widget_realize(b->window);
1785 aol_icon(b->window->window);
1787 vbox = gtk_vbox_new(FALSE, 5);
1788 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1789 gtk_container_add(GTK_CONTAINER(b->window), vbox);
1790 gtk_widget_show(vbox);
1792 buf = g_malloc(256);
1793 g_snprintf(buf, 256, "Changing info for %s:", tmp->username);
1794 label = gtk_label_new(buf);
1795 g_free(buf);
1796 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5);
1797 gtk_widget_show(label);
1799 b->text = gtk_text_new(NULL, NULL);
1800 gtk_text_set_word_wrap(GTK_TEXT(b->text), TRUE);
1801 gtk_text_set_editable(GTK_TEXT(b->text), TRUE);
1802 gtk_widget_set_usize(b->text, 300, 200);
1803 buf = g_malloc(strlen(tmp->user_info) + 1);
1804 strncpy_nohtml(buf, tmp->user_info, strlen(tmp->user_info) + 1);
1805 gtk_text_insert(GTK_TEXT(b->text), NULL, NULL, NULL, buf, -1);
1806 g_free(buf);
1807 gtk_box_pack_start(GTK_BOX(vbox), b->text, TRUE, TRUE, 0);
1808 gtk_widget_show(b->text);
1809 gtk_window_set_focus(GTK_WINDOW(b->window), b->text);
1811 buttons = gtk_hbox_new(FALSE, 5);
1812 gtk_box_pack_start(GTK_BOX(vbox), buttons, FALSE, FALSE, 0);
1813 gtk_widget_show(buttons);
1815 b->cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
1816 gtk_box_pack_end(GTK_BOX(buttons), b->cancel, FALSE, FALSE, 0);
1817 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
1819 b->save = picture_button(b->window, _("Save"), save_xpm);
1820 gtk_box_pack_end(GTK_BOX(buttons), b->save, FALSE, FALSE, 0);
1821 gtk_signal_connect(GTK_OBJECT(b->save), "clicked", GTK_SIGNAL_FUNC(do_save_info), b);
1823 gtk_widget_show(b->window);
1827 /*------------------------------------------------------------------------*/
1828 /* The dialog for the info requests */
1829 /*------------------------------------------------------------------------*/
1831 static void info_dlg_free(GtkWidget *b, struct info_dlg *d)
1833 if (g_slist_find(info_dlgs, d))
1834 info_dlgs = g_slist_remove(info_dlgs, d);
1835 g_free(d->who);
1836 g_free(d);
1839 gchar **info_img_handler(gchar *url)
1841 if (!g_strcasecmp(url, "free_icon.gif"))
1842 return free_icon_xpm;
1843 if (!g_strcasecmp(url, "aol_icon.gif"))
1844 return aol_icon_xpm;
1845 if (!g_strcasecmp(url, "dt_icon.gif"))
1846 return dt_icon_xpm;
1847 if (!g_strcasecmp(url, "admin_icon.gif"))
1848 return admin_icon_xpm;
1849 if (!g_strcasecmp(url, "ab_icon.gif"))
1850 return ab_xpm;
1851 return NULL;
1854 /* if away is 0, show regardless and try to get away message
1855 * 1, don't show if regular info isn't shown
1856 * 2, show regardless but don't try to get away message
1858 * i wish this were my client. if i were i wouldn't have to deal with this shit.
1860 void g_show_info_text(struct gaim_connection *gc, char *who, int away, char *info, ...)
1862 GtkWidget *ok;
1863 GtkWidget *label;
1864 GtkWidget *text;
1865 GtkWidget *bbox;
1866 GtkWidget *sw;
1867 gint options = 0;
1868 char *more_info;
1869 va_list ap;
1871 struct info_dlg *b = find_info_dlg(gc, who);
1872 if (!b && (away == 1))
1873 return;
1874 if (!b) {
1875 b = g_new0(struct info_dlg, 1);
1876 b->gc = gc;
1877 b->who = who ? g_strdup(normalize(who)) : NULL;
1878 info_dlgs = g_slist_append(info_dlgs, b);
1880 GAIM_DIALOG(b->window);
1881 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim");
1882 gtk_container_border_width(GTK_CONTAINER(b->window), 5);
1883 gtk_widget_realize(GTK_WIDGET(b->window));
1884 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(info_dlg_free), b);
1885 aol_icon(b->window->window);
1887 bbox = gtk_vbox_new(FALSE, 5);
1888 gtk_container_add(GTK_CONTAINER(b->window), bbox);
1890 label = gtk_label_new(_("Below are the results of your search: "));
1891 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
1893 sw = gtk_scrolled_window_new(NULL, NULL);
1894 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
1895 gtk_box_pack_start(GTK_BOX(bbox), sw, TRUE, TRUE, 0);
1897 text = gtk_imhtml_new(NULL, NULL);
1898 b->text = text;
1899 gtk_container_add(GTK_CONTAINER(sw), text);
1900 GTK_LAYOUT(text)->hadjustment->step_increment = 10.0;
1901 GTK_LAYOUT(text)->vadjustment->step_increment = 10.0;
1902 gtk_widget_set_usize(sw, 300, 250);
1903 gtk_imhtml_set_img_handler(GTK_IMHTML(text), info_img_handler);
1904 gaim_setup_imhtml(text);
1906 ok = picture_button(b->window, _("OK"), ok_xpm);
1907 gtk_signal_connect_object(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
1908 GTK_OBJECT(b->window));
1909 gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0);
1911 gtk_widget_show_all(b->window);
1914 if (convo_options & OPT_CONVO_IGNORE_COLOUR)
1915 options ^= GTK_IMHTML_NO_COLOURS;
1916 if (convo_options & OPT_CONVO_IGNORE_FONTS)
1917 options ^= GTK_IMHTML_NO_FONTS;
1918 if (convo_options & OPT_CONVO_IGNORE_SIZES)
1919 options ^= GTK_IMHTML_NO_SIZES;
1920 options ^= GTK_IMHTML_NO_COMMENTS;
1921 options ^= GTK_IMHTML_NO_TITLE;
1922 options ^= GTK_IMHTML_NO_NEWLINE;
1923 options ^= GTK_IMHTML_NO_SCROLL;
1925 gtk_imhtml_append_text(GTK_IMHTML(b->text), info, -1, options);
1927 va_start(ap, info);
1928 while ((more_info = va_arg(ap, char *)) != NULL)
1929 gtk_imhtml_append_text(GTK_IMHTML(b->text), more_info, -1, options);
1930 va_end(ap);
1932 if (away)
1933 info_dlgs = g_slist_remove(info_dlgs, b);
1934 else
1935 serv_get_away(gc, who);
1938 /*------------------------------------------------------------------------*/
1939 /* The dialog for adding to permit/deny */
1940 /*------------------------------------------------------------------------*/
1943 static void do_add_perm(GtkWidget *w, struct addperm *p)
1946 char *who;
1947 char *name;
1950 who = gtk_entry_get_text(GTK_ENTRY(p->entry));
1952 name = g_malloc(strlen(who) + 2);
1953 g_snprintf(name, strlen(who) + 2, "%s", who);
1955 if (!p->permit) {
1956 GSList *d = p->gc->deny;
1957 char *n;
1958 n = g_strdup(normalize(name));
1959 while (d) {
1960 if (!g_strcasecmp(n, normalize(d->data)))
1961 break;
1962 d = d->next;
1964 g_free(n);
1965 if (!d) {
1966 p->gc->deny = g_slist_append(p->gc->deny, name);
1967 serv_add_deny(p->gc, name);
1968 build_block_list();
1969 do_export(p->gc);
1970 } else
1971 g_free(name);
1972 } else {
1973 GSList *d = p->gc->permit;
1974 char *n;
1975 n = g_strdup(normalize(name));
1976 while (d) {
1977 if (!g_strcasecmp(n, normalize(d->data)))
1978 break;
1979 d = d->next;
1981 g_free(n);
1982 if (!d) {
1983 p->gc->permit = g_slist_append(p->gc->permit, name);
1984 serv_add_permit(p->gc, name);
1985 build_allow_list();
1986 do_export(p->gc);
1987 } else
1988 g_free(name);
1991 destroy_dialog(NULL, p->window);
1996 void show_add_perm(struct gaim_connection *gc, char *who, gboolean permit)
1998 GtkWidget *cancel;
1999 GtkWidget *add;
2000 GtkWidget *label;
2001 GtkWidget *bbox;
2002 GtkWidget *vbox;
2003 GtkWidget *topbox;
2004 GtkWidget *frame;
2006 struct addperm *p = g_new0(struct addperm, 1);
2007 p->gc = gc;
2008 p->permit = permit;
2010 GAIM_DIALOG(p->window);
2011 gtk_container_set_border_width(GTK_CONTAINER(p->window), 5);
2012 gtk_window_set_policy(GTK_WINDOW(p->window), FALSE, FALSE, TRUE);
2013 gtk_widget_realize(p->window);
2015 dialogwindows = g_list_prepend(dialogwindows, p->window);
2017 bbox = gtk_hbox_new(TRUE, 10);
2018 topbox = gtk_hbox_new(FALSE, 5);
2019 vbox = gtk_vbox_new(FALSE, 5);
2020 p->entry = gtk_entry_new();
2022 if (permit)
2023 frame = gtk_frame_new(_("Permit"));
2024 else
2025 frame = gtk_frame_new(_("Deny"));
2027 /* Build Add Button */
2029 if (permit)
2030 add = picture_button(p->window, _("Permit"), add_xpm);
2031 else
2032 add = picture_button(p->window, _("Deny"), add_xpm);
2033 cancel = picture_button(p->window, _("Cancel"), cancel_xpm);
2035 /* End of Cancel Button */
2036 if (who != NULL)
2037 gtk_entry_set_text(GTK_ENTRY(p->entry), who);
2039 /* Put the buttons in the box */
2041 gtk_box_pack_start(GTK_BOX(bbox), add, FALSE, FALSE, 5);
2042 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
2044 label = gtk_label_new(_("Add"));
2045 gtk_widget_show(label);
2046 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
2047 gtk_box_pack_start(GTK_BOX(topbox), p->entry, FALSE, FALSE, 5);
2048 /* And the boxes in the box */
2049 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5);
2050 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5);
2051 gtk_container_add(GTK_CONTAINER(frame), vbox);
2054 /* Handle closes right */
2055 gtk_signal_connect(GTK_OBJECT(p->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), p->window);
2056 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), p->window);
2057 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(do_add_perm), p);
2058 gtk_signal_connect(GTK_OBJECT(p->entry), "activate", GTK_SIGNAL_FUNC(do_add_perm), p);
2060 /* Finish up */
2061 gtk_widget_show(add);
2062 gtk_widget_show(cancel);
2063 gtk_widget_show(p->entry);
2064 gtk_widget_show(topbox);
2065 gtk_widget_show(bbox);
2066 gtk_widget_show(vbox);
2067 gtk_widget_show(frame);
2068 if (permit)
2069 gtk_window_set_title(GTK_WINDOW(p->window), _("Gaim - Add Permit"));
2070 else
2071 gtk_window_set_title(GTK_WINDOW(p->window), _("Gaim - Add Deny"));
2072 gtk_window_set_focus(GTK_WINDOW(p->window), p->entry);
2073 gtk_container_add(GTK_CONTAINER(p->window), frame);
2074 gtk_widget_realize(p->window);
2075 aol_icon(p->window->window);
2077 gtk_widget_show(p->window);
2081 /*------------------------------------------------------------------------*/
2082 /* Functions Called To Add A Log */
2083 /*------------------------------------------------------------------------*/
2085 void cancel_log(GtkWidget *widget, struct conversation *c)
2087 if (c->wood) {
2088 set_state_lock(1);
2089 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->wood), FALSE);
2090 set_state_lock(0);
2092 dialogwindows = g_list_remove(dialogwindows, c->log_dialog);
2093 gtk_widget_destroy(c->log_dialog);
2094 c->log_dialog = NULL;
2097 void do_log(GtkWidget *w, struct conversation *c)
2099 struct log_conversation *l;
2100 char buf[128];
2101 char *file;
2102 char path[PATHSIZE];
2104 if (!find_log_info(c->name)) {
2105 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(c->log_dialog));
2106 strncpy(path, file, PATHSIZE - 1);
2107 if (file_is_dir(path, c->log_dialog)) {
2108 return;
2111 l = (struct log_conversation *)g_new0(struct log_conversation, 1);
2112 strcpy(l->name, c->name);
2113 strcpy(l->filename, file);
2114 log_conversations = g_list_append(log_conversations, l);
2116 if (c != NULL) {
2117 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, c->name);
2118 gtk_window_set_title(GTK_WINDOW(c->window), buf);
2122 save_prefs();
2123 cancel_log(NULL, c);
2126 void show_log_dialog(struct conversation *c)
2128 char *buf = g_malloc(BUF_LEN);
2130 if (!c->log_dialog) {
2131 c->log_dialog = gtk_file_selection_new(_("Gaim - Log Conversation"));
2133 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(c->log_dialog));
2135 g_snprintf(buf, BUF_LEN - 1, "%s/%s.log", getenv("HOME"), normalize(c->name));
2136 gtk_object_set_user_data(GTK_OBJECT(c->log_dialog), "log dialog");
2137 gtk_file_selection_set_filename(GTK_FILE_SELECTION(c->log_dialog), buf);
2138 gtk_signal_connect(GTK_OBJECT(c->log_dialog), "delete_event",
2139 GTK_SIGNAL_FUNC(delete_event_dialog), c);
2140 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(c->log_dialog)->ok_button), "clicked",
2141 GTK_SIGNAL_FUNC(do_log), c);
2142 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(c->log_dialog)->cancel_button),
2143 "clicked", GTK_SIGNAL_FUNC(cancel_log), c);
2146 g_free(buf);
2148 gtk_widget_show(c->log_dialog);
2149 gdk_window_raise(c->log_dialog->window);
2152 /*------------------------------------------------------*/
2153 /* Find Buddy By Email */
2154 /*------------------------------------------------------*/
2156 void do_find_info(GtkWidget *w, struct findbyinfo *b)
2158 char *first;
2159 char *middle;
2160 char *last;
2161 char *maiden;
2162 char *city;
2163 char *state;
2164 char *country;
2166 first = gtk_entry_get_text(GTK_ENTRY(b->firstentry));
2167 middle = gtk_entry_get_text(GTK_ENTRY(b->middleentry));
2168 last = gtk_entry_get_text(GTK_ENTRY(b->lastentry));
2169 maiden = gtk_entry_get_text(GTK_ENTRY(b->maidenentry));
2170 city = gtk_entry_get_text(GTK_ENTRY(b->cityentry));
2171 state = gtk_entry_get_text(GTK_ENTRY(b->stateentry));
2172 country = gtk_entry_get_text(GTK_ENTRY(b->countryentry));
2174 serv_dir_search(b->gc, first, middle, last, maiden, city, state, country, "");
2175 destroy_dialog(NULL, b->window);
2178 void do_find_email(GtkWidget *w, struct findbyemail *b)
2180 char *email;
2182 email = gtk_entry_get_text(GTK_ENTRY(b->emailentry));
2184 serv_dir_search(b->gc, "", "", "", "", "", "", "", email);
2186 destroy_dialog(NULL, b->window);
2189 void show_find_info(struct gaim_connection *gc)
2191 GtkWidget *cancel;
2192 GtkWidget *ok;
2193 GtkWidget *label;
2194 GtkWidget *bbox;
2195 GtkWidget *vbox;
2196 GtkWidget *hbox;
2197 GtkWidget *fbox;
2198 GtkWidget *frame;
2200 struct findbyinfo *b = g_new0(struct findbyinfo, 1);
2201 b->gc = gc;
2202 GAIM_DIALOG(b->window);
2203 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
2204 gtk_window_set_wmclass(GTK_WINDOW(b->window), "find_info", "Gaim");
2205 gtk_widget_show(b->window);
2207 dialogwindows = g_list_prepend(dialogwindows, b->window);
2209 frame = gtk_frame_new(_("Search for Buddy"));
2210 fbox = gtk_vbox_new(FALSE, 5);
2212 /* Build OK Button */
2214 ok = picture_button(b->window, _("OK"), ok_xpm);
2215 cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
2217 bbox = gtk_hbox_new(FALSE, 5);
2218 vbox = gtk_vbox_new(FALSE, 5);
2219 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2221 b->firstentry = gtk_entry_new();
2222 b->middleentry = gtk_entry_new();
2223 b->lastentry = gtk_entry_new();
2224 b->maidenentry = gtk_entry_new();
2225 b->cityentry = gtk_entry_new();
2226 b->stateentry = gtk_entry_new();
2227 b->countryentry = gtk_entry_new();
2229 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 0);
2230 gtk_box_pack_end(GTK_BOX(bbox), ok, FALSE, FALSE, 0);
2232 /* Line 1 */
2233 label = gtk_label_new(_("First Name"));
2234 gtk_widget_show(label);
2236 hbox = gtk_hbox_new(FALSE, 5);
2237 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2238 gtk_box_pack_end(GTK_BOX(hbox), b->firstentry, FALSE, FALSE, 0);
2240 gtk_widget_show(hbox);
2241 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2243 /* Line 2 */
2245 label = gtk_label_new(_("Middle Name"));
2246 gtk_widget_show(label);
2248 hbox = gtk_hbox_new(FALSE, 5);
2249 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2250 gtk_box_pack_end(GTK_BOX(hbox), b->middleentry, FALSE, FALSE, 0);
2252 gtk_widget_show(hbox);
2253 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2255 /* Line 3 */
2257 label = gtk_label_new(_("Last Name"));
2258 gtk_widget_show(label);
2260 hbox = gtk_hbox_new(FALSE, 5);
2261 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2262 gtk_box_pack_end(GTK_BOX(hbox), b->lastentry, FALSE, FALSE, 0);
2264 gtk_widget_show(hbox);
2265 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2267 /* Line 4 */
2269 label = gtk_label_new(_("Maiden Name"));
2270 gtk_widget_show(label);
2272 hbox = gtk_hbox_new(FALSE, 5);
2273 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2274 gtk_box_pack_end(GTK_BOX(hbox), b->maidenentry, FALSE, FALSE, 0);
2276 gtk_widget_show(hbox);
2277 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2279 /* Line 5 */
2281 label = gtk_label_new(_("City"));
2282 gtk_widget_show(label);
2284 hbox = gtk_hbox_new(FALSE, 5);
2285 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2286 gtk_box_pack_end(GTK_BOX(hbox), b->cityentry, FALSE, FALSE, 0);
2288 gtk_widget_show(hbox);
2289 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2291 /* Line 6 */
2292 label = gtk_label_new(_("State"));
2293 gtk_widget_show(label);
2295 hbox = gtk_hbox_new(FALSE, 5);
2296 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2297 gtk_box_pack_end(GTK_BOX(hbox), b->stateentry, FALSE, FALSE, 0);
2299 gtk_widget_show(hbox);
2300 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2302 /* Line 7 */
2303 label = gtk_label_new(_("Country"));
2304 gtk_widget_show(label);
2306 hbox = gtk_hbox_new(FALSE, 5);
2307 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
2308 gtk_box_pack_end(GTK_BOX(hbox), b->countryentry, FALSE, FALSE, 0);
2310 gtk_widget_show(hbox);
2311 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
2313 /* Merge The Boxes */
2315 gtk_container_add(GTK_CONTAINER(frame), vbox);
2316 gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 0);
2317 gtk_box_pack_start(GTK_BOX(fbox), bbox, FALSE, FALSE, 0);
2319 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
2320 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
2321 gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(do_find_info), b);
2323 gtk_widget_show(ok);
2324 gtk_widget_show(cancel);
2325 gtk_widget_show(b->firstentry);
2326 gtk_widget_show(b->middleentry);
2327 gtk_widget_show(b->lastentry);
2328 gtk_widget_show(b->maidenentry);
2329 gtk_widget_show(b->cityentry);
2330 gtk_widget_show(b->stateentry);
2331 gtk_widget_show(b->countryentry);
2332 gtk_widget_show(bbox);
2333 gtk_widget_show(vbox);
2334 gtk_widget_show(frame);
2335 gtk_widget_show(fbox);
2337 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Find Buddy By Info"));
2338 gtk_window_set_focus(GTK_WINDOW(b->window), b->firstentry);
2339 gtk_container_add(GTK_CONTAINER(b->window), fbox);
2340 gtk_container_border_width(GTK_CONTAINER(b->window), 5);
2341 gtk_widget_realize(b->window);
2342 aol_icon(b->window->window);
2344 gtk_widget_show(b->window);
2347 void show_find_email(struct gaim_connection *gc)
2349 GtkWidget *label;
2350 GtkWidget *bbox;
2351 GtkWidget *vbox;
2352 GtkWidget *frame;
2353 GtkWidget *topbox;
2354 GtkWidget *button;
2356 struct findbyemail *b = g_new0(struct findbyemail, 1);
2357 if (g_slist_find(connections, gc))
2358 b->gc = gc;
2359 GAIM_DIALOG(b->window);
2360 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
2361 gtk_window_set_wmclass(GTK_WINDOW(b->window), "find_email", "Gaim");
2362 gtk_widget_realize(b->window);
2363 aol_icon(b->window->window);
2364 dialogwindows = g_list_prepend(dialogwindows, b->window);
2365 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
2366 gtk_window_set_title(GTK_WINDOW(b->window), _("Gaim - Find Buddy By Email"));
2368 vbox = gtk_vbox_new(FALSE, 5);
2369 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2370 gtk_container_add(GTK_CONTAINER(b->window), vbox);
2372 frame = gtk_frame_new(_("Search for Buddy"));
2373 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
2375 topbox = gtk_hbox_new(FALSE, 5);
2376 gtk_container_add(GTK_CONTAINER(frame), topbox);
2377 gtk_container_set_border_width(GTK_CONTAINER(topbox), 5);
2379 label = gtk_label_new(_("Email"));
2380 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 0);
2382 b->emailentry = gtk_entry_new();
2383 gtk_box_pack_start(GTK_BOX(topbox), b->emailentry, TRUE, TRUE, 0);
2384 gtk_signal_connect(GTK_OBJECT(b->emailentry), "activate", GTK_SIGNAL_FUNC(do_find_email), b);
2385 gtk_window_set_focus(GTK_WINDOW(b->window), b->emailentry);
2387 bbox = gtk_hbox_new(FALSE, 5);
2388 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
2390 button = picture_button(b->window, _("Cancel"), cancel_xpm);
2391 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
2392 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
2394 button = picture_button(b->window, _("OK"), ok_xpm);
2395 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_find_email), b);
2396 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
2398 gtk_widget_show_all(b->window);
2401 /*------------------------------------------------------*/
2402 /* Link Dialog */
2403 /*------------------------------------------------------*/
2405 void cancel_link(GtkWidget *widget, struct conversation *c)
2407 if (c->link) {
2408 set_state_lock(1);
2409 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->link), FALSE);
2410 set_state_lock(0);
2412 destroy_dialog(NULL, c->link_dialog);
2413 c->link_dialog = NULL;
2416 void do_add_link(GtkWidget *widget, struct linkdlg *b)
2418 char *open_tag;
2419 char *urltext, *showtext;
2420 open_tag = g_malloc(2048);
2423 urltext = gtk_entry_get_text(GTK_ENTRY(b->url));
2424 showtext = gtk_entry_get_text(GTK_ENTRY(b->text));
2426 g_snprintf(open_tag, 2048, "<A HREF=\"%s\">%s", urltext, showtext);
2427 surround(b->entry, open_tag, "</A>");
2429 g_free(open_tag);
2430 destroy_dialog(NULL, b->window);
2434 void show_add_link(GtkWidget *linky, struct conversation *c)
2436 GtkWidget *vbox;
2437 GtkWidget *bbox;
2438 GtkWidget *hbox;
2439 GtkWidget *label;
2440 GtkWidget *frame;
2441 GtkWidget *fbox;
2443 if (!c->link_dialog) {
2444 struct linkdlg *b = g_new0(struct linkdlg, 1);
2445 GAIM_DIALOG(c->link_dialog);
2446 gtk_window_set_wmclass(GTK_WINDOW(c->link_dialog), "add_link", "Gaim");
2447 dialogwindows = g_list_prepend(dialogwindows, c->link_dialog);
2449 gtk_widget_set_usize(c->link_dialog, 270, 165);
2450 gtk_window_set_policy(GTK_WINDOW(c->link_dialog), FALSE, FALSE, TRUE);
2451 gtk_widget_show(c->link_dialog);
2453 vbox = gtk_vbox_new(FALSE, 10);
2454 bbox = gtk_hbox_new(TRUE, 10);
2455 frame = gtk_frame_new(_("Insert Link"));
2456 fbox = gtk_vbox_new(FALSE, 5);
2458 /* Build OK Button */
2460 b->ok = picture_button(c->link_dialog, _("OK"), ok_xpm);
2461 b->cancel = picture_button(c->link_dialog, _("Cancel"), cancel_xpm);
2463 gtk_widget_set_usize(b->ok, 75, 30);
2464 gtk_widget_set_usize(b->cancel, 75, 30);
2466 gtk_box_pack_start(GTK_BOX(bbox), b->ok, FALSE, FALSE, 10);
2467 gtk_box_pack_end(GTK_BOX(bbox), b->cancel, FALSE, FALSE, 10);
2468 gtk_widget_show(bbox);
2470 b->url = gtk_entry_new();
2471 b->text = gtk_entry_new();
2473 hbox = gtk_hbox_new(FALSE, 5);
2474 label = gtk_label_new(_("URL"));
2475 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2476 gtk_box_pack_end(GTK_BOX(hbox), b->url, 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 hbox = gtk_hbox_new(FALSE, 5);
2482 label = gtk_label_new(_("Description"));
2483 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2484 gtk_box_pack_end(GTK_BOX(hbox), b->text, FALSE, FALSE, 5);
2485 gtk_widget_show(label);
2486 gtk_widget_show(hbox);
2487 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
2489 gtk_widget_show(b->url);
2490 gtk_widget_show(b->text);
2491 gtk_widget_show(frame);
2492 gtk_widget_show(fbox);
2494 gtk_container_add(GTK_CONTAINER(frame), vbox);
2495 gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 5);
2496 gtk_box_pack_start(GTK_BOX(fbox), bbox, TRUE, TRUE, 5);
2497 gtk_widget_show(vbox);
2499 gtk_signal_connect(GTK_OBJECT(c->link_dialog), "destroy",
2500 GTK_SIGNAL_FUNC(cancel_link), c);
2501 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(cancel_link), c);
2502 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(do_add_link), b);
2504 gtk_container_add(GTK_CONTAINER(c->link_dialog), fbox);
2505 gtk_container_border_width(GTK_CONTAINER(c->link_dialog), 10);
2506 gtk_window_set_title(GTK_WINDOW(c->link_dialog), _("Gaim - Add URL"));
2507 gtk_window_set_focus(GTK_WINDOW(c->link_dialog), b->url);
2508 b->window = c->link_dialog;
2509 b->toggle = linky;
2510 b->entry = c->entry;
2511 gtk_widget_realize(c->link_dialog);
2512 aol_icon(c->link_dialog->window);
2516 gtk_widget_show(c->link_dialog);
2517 gdk_window_raise(c->link_dialog->window);
2521 /*------------------------------------------------------*/
2522 /* Color Selection Dialog */
2523 /*------------------------------------------------------*/
2525 static GtkWidget *fgcseld = NULL;
2526 static GtkWidget *bgcseld = NULL;
2528 void cancel_fgcolor(GtkWidget *widget, struct conversation *c)
2530 if (c->fgcolorbtn && widget) {
2531 set_state_lock(1);
2532 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->fgcolorbtn), FALSE);
2533 set_state_lock(0);
2535 dialogwindows = g_list_remove(dialogwindows, c->fg_color_dialog);
2536 gtk_widget_destroy(c->fg_color_dialog);
2537 c->fg_color_dialog = NULL;
2540 void cancel_bgcolor(GtkWidget *widget, struct conversation *c)
2542 if (c->bgcolorbtn && widget) {
2543 set_state_lock(1);
2544 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->bgcolorbtn), FALSE);
2545 set_state_lock(0);
2547 dialogwindows = g_list_remove(dialogwindows, c->bg_color_dialog);
2548 gtk_widget_destroy(c->bg_color_dialog);
2549 c->bg_color_dialog = NULL;
2552 void do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
2554 gdouble color[3];
2555 GdkColor text_color;
2556 struct conversation *c;
2557 char *open_tag;
2559 open_tag = g_malloc(30);
2561 gtk_color_selection_get_color(colorsel, color);
2563 c = gtk_object_get_user_data(GTK_OBJECT(colorsel));
2564 /* GTK_IS_EDITABLE(c->entry); huh? */
2566 text_color.red = ((guint16)(color[0] * 65535)) >> 8;
2567 text_color.green = ((guint16)(color[1] * 65535)) >> 8;
2568 text_color.blue = ((guint16)(color[2] * 65535)) >> 8;
2570 c->fgcol = text_color;
2571 c->hasfg = 1;
2572 g_snprintf(open_tag, 23, "<FONT COLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green,
2573 text_color.blue);
2574 surround(c->entry, open_tag, "</FONT>");
2575 debug_printf("#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue);
2576 g_free(open_tag);
2577 cancel_fgcolor(NULL, c);
2580 void do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
2582 gdouble color[3];
2583 GdkColor text_color;
2584 struct conversation *c;
2585 char *open_tag;
2587 open_tag = g_malloc(30);
2589 gtk_color_selection_get_color(colorsel, color);
2591 c = gtk_object_get_user_data(GTK_OBJECT(colorsel));
2592 /* GTK_IS_EDITABLE(c->entry); huh? */
2594 text_color.red = ((guint16)(color[0] * 65535)) >> 8;
2595 text_color.green = ((guint16)(color[1] * 65535)) >> 8;
2596 text_color.blue = ((guint16)(color[2] * 65535)) >> 8;
2598 c->bgcol = text_color;
2599 c->hasbg = 1;
2600 g_snprintf(open_tag, 25, "<BODY BGCOLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green,
2601 text_color.blue);
2602 surround(c->entry, open_tag, "</BODY>");
2603 debug_printf("#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue);
2604 g_free(open_tag);
2605 cancel_bgcolor(NULL, c);
2608 static void destroy_colorsel(GtkWidget *w, gpointer d)
2610 if (d) {
2611 gtk_widget_destroy(fgcseld);
2612 fgcseld = NULL;
2613 } else {
2614 gtk_widget_destroy(bgcseld);
2615 bgcseld = NULL;
2619 static void apply_color_dlg(GtkWidget *w, gpointer d)
2621 gdouble color[3];
2622 if ((int)d == 1) {
2623 gtk_color_selection_get_color(GTK_COLOR_SELECTION
2624 (GTK_COLOR_SELECTION_DIALOG(fgcseld)->colorsel), color);
2625 destroy_colorsel(NULL, (void *)1);
2627 fgcolor.red = ((guint16)(color[0] * 65535)) >> 8;
2628 fgcolor.green = ((guint16)(color[1] * 65535)) >> 8;
2629 fgcolor.blue = ((guint16)(color[2] * 65535)) >> 8;
2630 update_color(NULL, pref_fg_picture);
2631 update_convo_color(TRUE);
2632 } else {
2633 gtk_color_selection_get_color(GTK_COLOR_SELECTION
2634 (GTK_COLOR_SELECTION_DIALOG(bgcseld)->colorsel), color);
2635 destroy_colorsel(NULL, (void *)0);
2637 bgcolor.red = ((guint16)(color[0] * 65535)) >> 8;
2638 bgcolor.green = ((guint16)(color[1] * 65535)) >> 8;
2639 bgcolor.blue = ((guint16)(color[2] * 65535)) >> 8;
2640 update_color(NULL, pref_bg_picture);
2641 update_convo_color(FALSE);
2645 void show_fgcolor_dialog(struct conversation *c, GtkWidget *color)
2647 GtkWidget *colorsel;
2648 gdouble fgclr[3];
2650 if (color == NULL) { /* we came from the prefs */
2651 if (fgcseld)
2652 return;
2653 fgclr[0] = (gdouble)(fgcolor.red) / 255;
2654 fgclr[1] = (gdouble)(fgcolor.green) / 255;
2655 fgclr[2] = (gdouble)(fgcolor.blue) / 255;
2657 fgcseld = gtk_color_selection_dialog_new(_("Select Text Color"));
2658 gtk_color_selection_set_color(GTK_COLOR_SELECTION
2659 (GTK_COLOR_SELECTION_DIALOG(fgcseld)->colorsel), fgclr);
2660 gtk_signal_connect(GTK_OBJECT(fgcseld), "delete_event",
2661 GTK_SIGNAL_FUNC(destroy_colorsel), (void *)1);
2662 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(fgcseld)->cancel_button),
2663 "clicked", GTK_SIGNAL_FUNC(destroy_colorsel), (void *)1);
2664 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(fgcseld)->ok_button), "clicked",
2665 GTK_SIGNAL_FUNC(apply_color_dlg), (void *)1);
2666 gtk_widget_realize(fgcseld);
2667 aol_icon(fgcseld->window);
2668 gtk_widget_show(fgcseld);
2669 gdk_window_raise(fgcseld->window);
2670 return;
2673 if (!c->fg_color_dialog) {
2674 fgclr[0] = (gdouble)(c->fgcol.red) / 255;
2675 fgclr[1] = (gdouble)(c->fgcol.green) / 255;
2676 fgclr[2] = (gdouble)(c->fgcol.blue) / 255;
2678 c->fg_color_dialog = gtk_color_selection_dialog_new(_("Select Text Color"));
2679 colorsel = GTK_COLOR_SELECTION_DIALOG(c->fg_color_dialog)->colorsel;
2680 gtk_color_selection_set_color(GTK_COLOR_SELECTION(colorsel), fgclr);
2681 gtk_object_set_user_data(GTK_OBJECT(colorsel), c);
2683 gtk_signal_connect(GTK_OBJECT(c->fg_color_dialog), "delete_event",
2684 GTK_SIGNAL_FUNC(delete_event_dialog), c);
2685 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->fg_color_dialog)->ok_button),
2686 "clicked", GTK_SIGNAL_FUNC(do_fgcolor), colorsel);
2687 gtk_signal_connect(GTK_OBJECT
2688 (GTK_COLOR_SELECTION_DIALOG(c->fg_color_dialog)->cancel_button),
2689 "clicked", GTK_SIGNAL_FUNC(cancel_fgcolor), c);
2691 gtk_widget_realize(c->fg_color_dialog);
2692 aol_icon(c->fg_color_dialog->window);
2695 gtk_widget_show(c->fg_color_dialog);
2696 gdk_window_raise(c->fg_color_dialog->window);
2699 void show_bgcolor_dialog(struct conversation *c, GtkWidget *color)
2701 GtkWidget *colorsel;
2702 gdouble bgclr[3];
2704 if (color == NULL) { /* we came from the prefs */
2705 if (bgcseld)
2706 return;
2707 bgclr[0] = (gdouble)(bgcolor.red) / 255;
2708 bgclr[1] = (gdouble)(bgcolor.green) / 255;
2709 bgclr[2] = (gdouble)(bgcolor.blue) / 255;
2711 bgcseld = gtk_color_selection_dialog_new(_("Select Background Color"));
2712 gtk_color_selection_set_color(GTK_COLOR_SELECTION
2713 (GTK_COLOR_SELECTION_DIALOG(bgcseld)->colorsel), bgclr);
2714 gtk_signal_connect(GTK_OBJECT(bgcseld), "delete_event",
2715 GTK_SIGNAL_FUNC(destroy_colorsel), NULL);
2716 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(bgcseld)->cancel_button),
2717 "clicked", GTK_SIGNAL_FUNC(destroy_colorsel), NULL);
2718 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(bgcseld)->ok_button), "clicked",
2719 GTK_SIGNAL_FUNC(apply_color_dlg), (void *)2);
2720 gtk_widget_realize(bgcseld);
2721 aol_icon(bgcseld->window);
2722 gtk_widget_show(bgcseld);
2723 gdk_window_raise(bgcseld->window);
2724 return;
2727 if (!c->bg_color_dialog) {
2728 bgclr[0] = (gdouble)(c->bgcol.red) / 255;
2729 bgclr[1] = (gdouble)(c->bgcol.green) / 255;
2730 bgclr[2] = (gdouble)(c->bgcol.blue) / 255;
2732 c->bg_color_dialog = gtk_color_selection_dialog_new(_("Select Text Color"));
2733 colorsel = GTK_COLOR_SELECTION_DIALOG(c->bg_color_dialog)->colorsel;
2734 gtk_color_selection_set_color(GTK_COLOR_SELECTION(colorsel), bgclr);
2735 gtk_object_set_user_data(GTK_OBJECT(colorsel), c);
2737 gtk_signal_connect(GTK_OBJECT(c->bg_color_dialog), "delete_event",
2738 GTK_SIGNAL_FUNC(delete_event_dialog), c);
2739 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(c->bg_color_dialog)->ok_button),
2740 "clicked", GTK_SIGNAL_FUNC(do_bgcolor), colorsel);
2741 gtk_signal_connect(GTK_OBJECT
2742 (GTK_COLOR_SELECTION_DIALOG(c->bg_color_dialog)->cancel_button),
2743 "clicked", GTK_SIGNAL_FUNC(cancel_bgcolor), c);
2745 gtk_widget_realize(c->bg_color_dialog);
2746 aol_icon(c->bg_color_dialog->window);
2749 gtk_widget_show(c->bg_color_dialog);
2750 gdk_window_raise(c->bg_color_dialog->window);
2753 /*------------------------------------------------------------------------*/
2754 /* Font Selection Dialog */
2755 /*------------------------------------------------------------------------*/
2757 void cancel_font(GtkWidget *widget, struct conversation *c)
2759 if (c->font && widget) {
2760 set_state_lock(1);
2761 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->font), FALSE);
2762 set_state_lock(0);
2764 dialogwindows = g_list_remove(dialogwindows, c->font_dialog);
2765 gtk_widget_destroy(c->font_dialog);
2766 c->font_dialog = NULL;
2769 void apply_font(GtkWidget *widget, GtkFontSelection *fontsel)
2771 /* this could be expanded to include font size, weight, etc.
2772 but for now only works with font face */
2773 int i, j = 0, k = 0;
2774 char *fontname;
2775 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(fontsel));
2777 if (c) {
2778 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel));
2780 set_font_face(fontname, c);
2781 } else {
2782 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel));
2784 for (i = 0; i < strlen(fontname); i++) {
2785 if (fontname[i] == '-') {
2786 if (++j > 2)
2787 break;
2788 } else if (j == 2)
2789 fontface[k++] = fontname[i];
2791 fontface[k] = '\0';
2793 g_snprintf(fontxfld, sizeof(fontxfld), "%s", fontname);
2796 cancel_font(NULL, c);
2799 static GtkWidget *fontseld;
2801 void destroy_fontsel(GtkWidget *w, gpointer d)
2803 gtk_widget_destroy(fontseld);
2804 fontseld = NULL;
2807 void apply_font_dlg(GtkWidget *w, GtkWidget *f)
2809 int i, j = 0, k = 0;
2810 char *fontname;
2812 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontseld));
2813 destroy_fontsel(0, 0);
2814 for (i = 0; i < strlen(fontname); i++) {
2815 if (fontname[i] == '-') {
2816 if (++j > 2)
2817 break;
2818 } else if (j == 2)
2819 fontface[k++] = fontname[i];
2821 fontface[k] = '\0';
2822 g_snprintf(fontxfld, sizeof(fontxfld), "%s", fontname);
2823 update_convo_font();
2826 void show_font_dialog(struct conversation *c, GtkWidget *font)
2829 if (!font) { /* we came from the prefs dialog */
2830 if (fontseld)
2831 return;
2832 fontseld = gtk_font_selection_dialog_new(_("Select Font"));
2833 if (fontxfld[0]) {
2834 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
2835 fontxfld);
2836 } else {
2837 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
2838 DEFAULT_FONT_XFLD);
2841 gtk_object_set_user_data(GTK_OBJECT(fontseld), NULL);
2842 gtk_signal_connect(GTK_OBJECT(fontseld), "delete_event",
2843 GTK_SIGNAL_FUNC(destroy_fontsel), NULL);
2844 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->cancel_button),
2845 "clicked", GTK_SIGNAL_FUNC(destroy_fontsel), NULL);
2846 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->ok_button), "clicked",
2847 GTK_SIGNAL_FUNC(apply_font_dlg), NULL);
2848 gtk_widget_realize(fontseld);
2849 aol_icon(fontseld->window);
2850 gtk_widget_show(fontseld);
2851 gdk_window_raise(fontseld->window);
2852 return;
2855 if (!c->font_dialog) {
2856 c->font_dialog = gtk_font_selection_dialog_new(_("Select Font"));
2858 if (font)
2859 gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), c);
2860 else
2861 gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), NULL);
2863 if (c->fontxfld[0]) {
2864 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(c->font_dialog),
2865 c->fontxfld);
2866 } else {
2867 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(c->font_dialog),
2868 DEFAULT_FONT_XFLD);
2871 gtk_signal_connect(GTK_OBJECT(c->font_dialog), "delete_event",
2872 GTK_SIGNAL_FUNC(delete_event_dialog), c);
2873 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->ok_button),
2874 "clicked", GTK_SIGNAL_FUNC(apply_font), c->font_dialog);
2875 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->cancel_button),
2876 "clicked", GTK_SIGNAL_FUNC(cancel_font), c);
2878 gtk_widget_realize(c->font_dialog);
2880 aol_icon(c->font_dialog->window);
2882 gtk_widget_show(c->font_dialog);
2883 gdk_window_raise(c->font_dialog->window);
2886 /*------------------------------------------------------------------------*/
2887 /* The dialog for import/export */
2888 /*------------------------------------------------------------------------*/
2890 static void do_import_dialog(GtkWidget *w, struct gaim_connection *gc)
2892 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(importdialog));
2893 if (file_is_dir(file, importdialog)) {
2894 return;
2896 if (g_slist_find(connections, importgc)) {
2897 do_import(importgc, file);
2898 do_export(importgc);
2900 destroy_dialog(NULL, importdialog);
2903 static void set_import_gc(gpointer data, struct gaim_connection *gc)
2905 importgc = gc;
2908 static void create_import_dropdown(GtkFileSelection *fs)
2910 GtkWidget *hbox;
2911 GtkWidget *label;
2912 GSList *g = connections;
2913 struct gaim_connection *c;
2914 GtkWidget *optmenu;
2915 GtkWidget *menu;
2916 char buf[256];
2917 GtkWidget *opt;
2919 if (!connections)
2920 return;
2921 importgc = connections->data;
2922 if (!connections->next)
2923 return;
2925 hbox = gtk_hbox_new(FALSE, 0);
2926 gtk_box_pack_end(GTK_BOX(fs->action_area), hbox, FALSE, FALSE, 0);
2927 gtk_widget_show(hbox);
2929 optmenu = gtk_option_menu_new();
2930 gtk_box_pack_end(GTK_BOX(hbox), optmenu, FALSE, FALSE, 5);
2931 gtk_widget_show(optmenu);
2933 label = gtk_label_new(_("Import to:"));
2934 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 5);
2935 gtk_widget_show(label);
2937 menu = gtk_menu_new();
2939 while (g) {
2940 c = (struct gaim_connection *)g->data;
2941 g_snprintf(buf, sizeof buf, "%s (%s)", c->username, c->prpl->name());
2942 opt = gtk_menu_item_new_with_label(buf);
2943 gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(set_import_gc), c);
2944 gtk_widget_show(opt);
2945 gtk_menu_append(GTK_MENU(menu), opt);
2946 g = g->next;
2949 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
2950 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0);
2953 void show_import_dialog()
2955 char *buf = g_malloc(BUF_LEN);
2956 if (!importdialog) {
2957 importdialog = gtk_file_selection_new(_("Gaim - Import Buddy List"));
2959 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(importdialog));
2961 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("HOME"));
2963 gtk_file_selection_set_filename(GTK_FILE_SELECTION(importdialog), buf);
2964 gtk_signal_connect(GTK_OBJECT(importdialog), "destroy",
2965 GTK_SIGNAL_FUNC(destroy_dialog), importdialog);
2967 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(importdialog)->ok_button),
2968 "clicked", GTK_SIGNAL_FUNC(do_import_dialog), NULL);
2969 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(importdialog)->cancel_button),
2970 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), importdialog);
2972 create_import_dropdown(GTK_FILE_SELECTION(importdialog));
2975 g_free(buf);
2976 gtk_widget_show(importdialog);
2977 gdk_window_raise(importdialog->window);
2980 /*------------------------------------------------------------------------*/
2981 /* The dialog for new away messages */
2982 /*------------------------------------------------------------------------*/
2984 static struct away_message *save_away_message(struct create_away *ca)
2986 struct away_message *am;
2987 guint text_len;
2988 gchar *away_message;
2990 if (!ca->mess)
2991 am = g_new0(struct away_message, 1);
2992 else {
2993 #ifdef USE_APPLET
2994 char *awayname = g_strdup_printf("away/%s", ca->mess->name);
2995 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname);
2996 g_free(awayname);
2997 #endif
2998 am = ca->mess;
3001 g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry)));
3002 text_len = gtk_text_get_length(GTK_TEXT(ca->text));
3003 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len);
3005 g_snprintf(am->message, sizeof(am->message), "%s", away_message);
3006 g_free(away_message);
3008 if (!ca->mess) {
3009 away_messages = g_slist_insert_sorted(away_messages, am, sort_awaymsg_list);
3012 save_prefs();
3013 do_away_menu();
3014 if (prefs_away_list != NULL)
3015 gtk_list_select_item(GTK_LIST(prefs_away_list), g_slist_index(away_messages, am));
3017 return am;
3020 int check_away_mess(struct create_away *ca, int type)
3022 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) {
3023 /* We shouldn't allow a blank title */
3024 do_error_dialog(_("You cannot create an away message with a blank title"),
3025 _("Gaim - Error"));
3026 return 0;
3029 if ((gtk_text_get_length(GTK_TEXT(ca->text)) == 0) && (type <= 1)) {
3030 /* We shouldn't allow a blank message */
3031 do_error_dialog(_("You cannot create an empty away message"), _("Gaim - Error"));
3032 return 0;
3035 return 1;
3038 void save_away_mess(GtkWidget *widget, struct create_away *ca)
3040 if (!check_away_mess(ca, 1))
3041 return;
3043 save_away_message(ca);
3044 destroy_dialog(NULL, ca->window);
3045 g_free(ca);
3048 void use_away_mess(GtkWidget *widget, struct create_away *ca)
3050 static struct away_message am;
3051 guint text_len;
3052 gchar *away_message;
3054 if (!check_away_mess(ca, 0))
3055 return;
3057 g_snprintf(am.name, sizeof(am.name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry)));
3058 text_len = gtk_text_get_length(GTK_TEXT(ca->text));
3059 if (text_len < 0)
3060 return;
3061 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len);
3063 g_snprintf(am.message, sizeof(am.message), "%s", away_message);
3064 g_free(away_message);
3066 do_away_message(NULL, &am);
3068 destroy_dialog(NULL, ca->window);
3069 g_free(ca);
3072 void su_away_mess(GtkWidget *widget, struct create_away *ca)
3074 if (!check_away_mess(ca, 1))
3075 return;
3076 do_away_message(NULL, save_away_message(ca));
3077 destroy_dialog(NULL, ca->window);
3078 g_free(ca);
3081 void create_away_mess(GtkWidget *widget, void *dummy)
3083 GtkWidget *hbox;
3084 GtkWidget *titlebox;
3085 GtkWidget *tbox;
3086 GtkWidget *sw;
3087 GtkWidget *label;
3088 GtkWidget *frame;
3089 GtkWidget *fbox;
3090 GtkWidget *button;
3092 struct create_away *ca = g_new0(struct create_away, 1);
3094 /* Set up window */
3095 GAIM_DIALOG(ca->window);
3096 gtk_widget_set_usize(ca->window, -1, 250);
3097 gtk_container_border_width(GTK_CONTAINER(ca->window), 5);
3098 gtk_window_set_wmclass(GTK_WINDOW(ca->window), "away_mess", "Gaim");
3099 gtk_window_set_title(GTK_WINDOW(ca->window), _("Gaim - New away message"));
3100 gtk_signal_connect(GTK_OBJECT(ca->window), "delete_event",
3101 GTK_SIGNAL_FUNC(destroy_dialog), ca->window);
3102 gtk_widget_realize(ca->window);
3103 aol_icon(ca->window->window);
3105 tbox = gtk_vbox_new(FALSE, 5);
3106 gtk_container_add(GTK_CONTAINER(ca->window), tbox);
3107 gtk_widget_show(tbox);
3109 frame = gtk_frame_new(_("New away message"));
3110 gtk_box_pack_start(GTK_BOX(tbox), frame, TRUE, TRUE, 0);
3111 gtk_widget_show(frame);
3113 fbox = gtk_vbox_new(FALSE, 5);
3114 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
3115 gtk_container_add(GTK_CONTAINER(frame), fbox);
3116 gtk_widget_show(fbox);
3118 titlebox = gtk_hbox_new(FALSE, 5);
3119 gtk_box_pack_start(GTK_BOX(fbox), titlebox, FALSE, FALSE, 0);
3120 gtk_widget_show(titlebox);
3122 label = gtk_label_new(_("Away title: "));
3123 gtk_box_pack_start(GTK_BOX(titlebox), label, FALSE, FALSE, 0);
3124 gtk_widget_show(label);
3126 ca->entry = gtk_entry_new();
3127 gtk_box_pack_start(GTK_BOX(titlebox), ca->entry, TRUE, TRUE, 0);
3128 gtk_widget_grab_focus(ca->entry);
3129 gtk_widget_show(ca->entry);
3131 sw = gtk_scrolled_window_new(NULL, NULL);
3132 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
3133 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
3134 gtk_box_pack_start(GTK_BOX(fbox), sw, TRUE, TRUE, 0);
3135 gtk_widget_show(sw);
3137 ca->text = gtk_text_new(NULL, NULL);
3138 gtk_text_set_word_wrap(GTK_TEXT(ca->text), TRUE);
3139 gtk_text_set_editable(GTK_TEXT(ca->text), TRUE);
3140 gtk_container_add(GTK_CONTAINER(sw), ca->text);
3141 gtk_widget_show(ca->text);
3143 if (dummy && GTK_LIST(prefs_away_list)->selection) {
3144 GtkWidget *item = GTK_LIST(prefs_away_list)->selection->data;
3145 struct away_message *amt = gtk_object_get_user_data(GTK_OBJECT(item));
3146 int pos = 0;
3147 gtk_entry_set_text(GTK_ENTRY(ca->entry), amt->name);
3148 gtk_editable_insert_text(GTK_EDITABLE(ca->text), amt->message,
3149 strlen(amt->message), &pos);
3150 ca->mess = amt;
3153 hbox = gtk_hbox_new(FALSE, 5);
3154 gtk_box_pack_start(GTK_BOX(tbox), hbox, FALSE, FALSE, 0);
3155 gtk_widget_show(hbox);
3157 button = picture_button(ca->window, _("Cancel"), cancel_xpm);
3158 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), ca->window);
3159 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
3161 button = picture_button(ca->window, _("Use"), gnome_preferences_xpm);
3162 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(use_away_mess), ca);
3163 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
3165 button = picture_button(ca->window, _("Save & Use"), add_xpm);
3166 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(su_away_mess), ca);
3167 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
3169 button = picture_button(ca->window, _("Save"), ok_xpm);
3170 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(save_away_mess), ca);
3171 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
3173 gtk_widget_show(ca->window);
3176 /* smiley dialog */
3178 void close_smiley_dialog(GtkWidget *widget, struct conversation *c)
3180 if (c->smiley) {
3181 set_state_lock(1);
3182 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->smiley), FALSE);
3183 set_state_lock(0);
3185 dialogwindows = g_list_remove(dialogwindows, c->smiley_dialog);
3186 gtk_widget_destroy(c->smiley_dialog);
3187 c->smiley_dialog = NULL;
3190 void set_smiley(GtkWidget *w, char *face)
3192 current_smiley = face;
3195 void set_smiley_array(GtkWidget *widget, int smiley_type)
3197 int i;
3199 for (i = 0; i < FACE_TOTAL; i++)
3200 smiley_array[i] = 0;
3202 smiley_array[smiley_type] = 1;
3204 return;
3207 void insert_smiley_text(GtkWidget *widget, struct conversation *c)
3209 char *smiley_text;
3210 int i;
3212 smiley_text = strdup(current_smiley);
3214 /* surround(c->entry, smiley_text, ""); */
3216 if (GTK_OLD_EDITABLE(c->entry)->has_selection) {
3217 int finish = GTK_OLD_EDITABLE(c->entry)->selection_end_pos;
3218 gtk_editable_insert_text(GTK_EDITABLE(c->entry),
3219 smiley_text, strlen(smiley_text), &finish);
3220 } else {
3221 int pos = GTK_OLD_EDITABLE(c->entry)->current_pos;
3222 gtk_editable_insert_text(GTK_EDITABLE(c->entry), smiley_text, strlen(smiley_text), &pos);
3225 g_free(smiley_text);
3227 close_smiley_dialog(NULL, c);
3229 return;
3232 static void toolbar_add_smiley(struct conversation *c, GtkWidget *bar, char **xpm, GtkWidget *win,
3233 char *face)
3235 GtkWidget *tpm;
3236 GdkBitmap *mask;
3237 GdkPixmap *dpm;
3238 GtkWidget *button;
3240 dpm = gdk_pixmap_create_from_xpm_d(win->window, &mask, &win->style->white, xpm);
3241 tpm = gtk_pixmap_new(dpm, mask);
3242 gtk_widget_show(tpm);
3243 gdk_pixmap_unref(dpm);
3244 gdk_bitmap_unref(mask);
3245 button =
3246 gtk_toolbar_append_element(GTK_TOOLBAR(bar), GTK_TOOLBAR_CHILD_BUTTON, NULL, NULL, NULL,
3247 NULL, tpm, GTK_SIGNAL_FUNC(set_smiley), (char *)face);
3248 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(insert_smiley_text), c);
3250 /* these look really weird with borders */
3251 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
3254 void show_smiley_dialog(struct conversation *c, GtkWidget *widget)
3256 GtkWidget *dialog;
3257 GtkWidget *vbox, *smiley_box = NULL;
3258 GtkWidget *win;
3259 GtkWidget *bbox;
3260 GSList *smilies;
3261 int smiley_count = 0;
3262 int total_count = 0;
3264 if (c->smiley_dialog)
3265 return;
3267 win = c->window;
3269 GAIM_DIALOG(dialog);
3270 gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, TRUE);
3271 gtk_window_set_wmclass(GTK_WINDOW(dialog), "smiley_dialog", "Gaim");
3272 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
3274 /* setup boxes */
3275 vbox = gtk_vbox_new(TRUE, 5);
3276 bbox = gtk_hbox_new(FALSE, 5);
3279 /* setup buttons */
3281 /* pack buttons */
3282 if (c->gc->prpl->smiley_list == NULL) {
3283 smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
3284 gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0);
3286 toolbar_add_smiley(c, smiley_box, angel_xpm, win, "O:-)");
3287 toolbar_add_smiley(c, smiley_box, bigsmile_xpm, win, ":-D");
3288 toolbar_add_smiley(c, smiley_box, burp_xpm, win, ":-!");
3289 toolbar_add_smiley(c, smiley_box, crossedlips_xpm, win, ":-X");
3291 smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
3292 gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0);
3294 toolbar_add_smiley(c, smiley_box, cry_xpm, win, ":'(");
3295 toolbar_add_smiley(c, smiley_box, embarrassed_xpm, win, ":-[");
3296 toolbar_add_smiley(c, smiley_box, kiss_xpm, win, ":-*");
3297 toolbar_add_smiley(c, smiley_box, moneymouth_xpm, win, ":-$");
3299 smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
3300 gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0);
3302 toolbar_add_smiley(c, smiley_box, sad_xpm, win, ":-(");
3303 toolbar_add_smiley(c, smiley_box, scream_xpm, win, "=-O");
3304 toolbar_add_smiley(c, smiley_box, smile_xpm, win, ":-)");
3305 toolbar_add_smiley(c, smiley_box, smile8_xpm, win, "8-)");
3307 smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
3308 gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0);
3310 toolbar_add_smiley(c, smiley_box, think_xpm, win, ":-/");
3311 toolbar_add_smiley(c, smiley_box, tongue_xpm, win, ":-P");
3312 toolbar_add_smiley(c, smiley_box, wink_xpm, win, ";-)");
3313 toolbar_add_smiley(c, smiley_box, yell_xpm, win, ">:o");
3314 } else {
3316 smilies = c->gc->prpl->smiley_list();
3318 while (smilies) {
3319 struct _prpl_smiley *smile =
3320 (struct _prpl_smiley *)smilies->data;
3322 if (smile->show) {
3323 total_count++;
3326 smilies = g_slist_next(smilies);
3329 smilies = c->gc->prpl->smiley_list();
3331 smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
3332 gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0);
3334 while (smilies) {
3335 struct _prpl_smiley *smile =
3336 (struct _prpl_smiley *)smilies->data;
3338 if (smile->show) {
3340 if ((!(smiley_count % ((int)(sqrt(total_count))))) && (smiley_count > 0)) {
3341 smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
3342 gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0);
3345 toolbar_add_smiley(c, smiley_box, smile->xpm, win, smile->key);
3346 smiley_count++;
3349 smilies = g_slist_next(smilies);
3355 gtk_container_add(GTK_CONTAINER(dialog), vbox);
3356 gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
3358 /* connect signals */
3359 gtk_object_set_user_data(GTK_OBJECT(dialog), "smiley dialog");
3360 gtk_signal_connect(GTK_OBJECT(dialog), "delete_event", GTK_SIGNAL_FUNC(delete_event_dialog), c);
3362 /* show everything */
3363 gtk_window_set_title(GTK_WINDOW(dialog), _("Smile!"));
3364 gtk_widget_show_all(dialog);
3366 c->smiley_dialog = dialog;
3368 return;
3371 static void do_alias_bud(GtkWidget *w, struct buddy *b)
3373 char *al = gtk_entry_get_text(GTK_ENTRY(aliasname));
3374 g_snprintf(b->show, sizeof(b->show), "%s", (al && strlen(al)) ? al : b->name);
3375 handle_buddy_rename(b, b->name);
3376 destroy_dialog(aliasdlg, aliasdlg);
3379 void alias_dialog_bud(struct buddy *b)
3381 GtkWidget *frame;
3382 GtkWidget *vbox;
3383 GtkWidget *bbox;
3384 GtkWidget *cancel;
3385 static GtkWidget *add = NULL;
3386 GtkWidget *label;
3387 GtkWidget *topbox;
3388 static int a, c;
3390 if (aliasdlg)
3391 gtk_widget_destroy(aliasdlg);
3393 GAIM_DIALOG(aliasdlg);
3394 gtk_window_set_policy(GTK_WINDOW(aliasdlg), FALSE, FALSE, TRUE);
3395 gtk_window_set_wmclass(GTK_WINDOW(aliasdlg), "alias_dialog", "Gaim");
3396 gtk_widget_realize(aliasdlg);
3397 dialogwindows = g_list_prepend(dialogwindows, aliasdlg);
3399 bbox = gtk_hbox_new(TRUE, 10);
3400 topbox = gtk_hbox_new(FALSE, 5);
3401 vbox = gtk_vbox_new(FALSE, 5);
3403 aliasentry = gtk_entry_new();
3404 aliasname = gtk_entry_new();
3405 /* Put the buttons in the box */
3407 add = picture_button(aliasdlg, _("Alias"), add_xpm);
3409 cancel = picture_button(aliasdlg, _("Cancel"), cancel_xpm);
3411 gtk_box_pack_start(GTK_BOX(bbox), add, FALSE, FALSE, 5);
3412 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
3414 frame = gtk_frame_new(NULL);
3415 gtk_frame_set_label(GTK_FRAME(frame), _("Alias Buddy"));
3417 label = gtk_label_new(_("Buddy"));
3418 gtk_widget_show(label);
3419 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
3420 gtk_box_pack_start(GTK_BOX(topbox), aliasentry, FALSE, FALSE, 5);
3421 gtk_entry_set_editable(GTK_ENTRY(aliasentry), FALSE);
3422 label = gtk_label_new(_("Alias"));
3423 gtk_widget_show(label);
3424 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
3425 gtk_box_pack_start(GTK_BOX(topbox), aliasname, FALSE, FALSE, 5);
3427 gtk_entry_set_text(GTK_ENTRY(aliasentry), b->name);
3428 gtk_entry_set_text(GTK_ENTRY(aliasname), b->show);
3430 /* And the boxes in the box */
3431 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5);
3432 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5);
3434 /* Handle closes right */
3435 gtk_signal_connect(GTK_OBJECT(aliasdlg), "destroy", GTK_SIGNAL_FUNC(destroy_dialog), aliasdlg);
3436 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), aliasdlg);
3437 a = gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(do_alias_bud), b);
3438 c = gtk_signal_connect(GTK_OBJECT(aliasname), "activate", GTK_SIGNAL_FUNC(do_alias_bud), b);
3439 /* Finish up */
3440 gtk_widget_show(add);
3441 gtk_widget_show(cancel);
3442 gtk_widget_show(aliasentry);
3443 gtk_widget_show(aliasname);
3444 gtk_widget_show(topbox);
3445 gtk_widget_show(bbox);
3446 gtk_widget_show(vbox);
3447 gtk_widget_show(frame);
3448 gtk_window_set_title(GTK_WINDOW(aliasdlg), _("Gaim - Alias Buddy"));
3449 gtk_window_set_focus(GTK_WINDOW(aliasdlg), aliasentry);
3450 gtk_container_add(GTK_CONTAINER(frame), vbox);
3451 gtk_container_add(GTK_CONTAINER(aliasdlg), frame);
3452 gtk_container_set_border_width(GTK_CONTAINER(aliasdlg), 5);
3453 gtk_widget_realize(aliasdlg);
3454 aol_icon(aliasdlg->window);
3456 gtk_widget_show(aliasdlg);
3460 static gboolean dont_destroy(gpointer a, gpointer b, gpointer c)
3462 return TRUE;
3465 static void do_save_log(GtkWidget *w, GtkWidget *filesel)
3467 char *file;
3468 char path[PATHSIZE];
3469 char buf[BUF_LONG];
3470 char error[BUF_LEN];
3471 FILE *fp_old, *fp_new;
3472 char filename[PATHSIZE];
3473 char *name;
3474 char *tmp;
3476 name = gtk_object_get_user_data(GTK_OBJECT(filesel));
3477 tmp = gaim_user_dir();
3478 g_snprintf(filename, PATHSIZE, "%s/logs/%s%s", tmp,
3479 name ? normalize(name) : "system", name ? ".log" : "");
3480 g_free(tmp);
3482 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel));
3483 strncpy(path, file, PATHSIZE - 1);
3484 if (file_is_dir(path, filesel))
3485 return;
3487 if ((fp_new = fopen(path, "w")) == NULL) {
3488 g_snprintf(error, BUF_LONG,
3489 "Can't open file %s for writing - %s", path, strerror(errno));
3490 do_error_dialog(error, "Error");
3491 return;
3494 if ((fp_old = fopen(filename, "r")) == NULL) {
3495 g_snprintf(error, BUF_LONG,
3496 "Can't open file %s for reading - %s", filename, strerror(errno));
3497 do_error_dialog(error, "Error");
3498 fclose(fp_new);
3499 return;
3502 while (fgets(buf, BUF_LONG, fp_old))
3503 fputs(buf, fp_new);
3504 fclose(fp_old);
3505 fclose(fp_new);
3507 gtk_widget_destroy(filesel);
3509 return;
3512 static void show_save_log(GtkWidget *w, gchar *name)
3514 GtkWidget *filesel;
3515 gchar buf[BUF_LEN];
3517 g_snprintf(buf, BUF_LEN - 1, "%s/%s%s", getenv("HOME"),
3518 name ? normalize(name) : "system", name ? ".log" : "");
3520 filesel = gtk_file_selection_new(_("Gaim - Save Log File"));
3521 gtk_signal_connect(GTK_OBJECT(filesel), "delete_event",
3522 GTK_SIGNAL_FUNC(destroy_dialog), filesel);
3524 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(filesel));
3525 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), buf);
3526 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button),
3527 "clicked", GTK_SIGNAL_FUNC(do_save_log), filesel);
3528 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button),
3529 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), filesel);
3530 gtk_object_set_user_data(GTK_OBJECT(filesel), name);
3532 gtk_widget_realize(filesel);
3533 aol_icon(filesel->window);
3534 gtk_widget_show(filesel);
3536 return;
3539 static void do_clear_log_file(GtkWidget *w, gchar *name)
3541 gchar buf[256];
3542 gchar filename[256];
3543 GtkWidget *window;
3544 char *tmp;
3546 tmp = gaim_user_dir();
3547 g_snprintf(filename, 256, "%s/logs/%s%s", tmp,
3548 name ? normalize(name) : "system", name ? ".log" : "");
3549 g_free(tmp);
3551 if ((remove(filename)) == -1) {
3552 g_snprintf(buf, 256, _("Unable to remove file %s - %s"), filename, strerror(errno));
3553 do_error_dialog(buf, _("Error"));
3556 window = gtk_object_get_user_data(GTK_OBJECT(w));
3557 destroy_dialog(NULL, window);
3560 static void show_clear_log(GtkWidget *w, gchar *name)
3562 GtkWidget *window;
3563 GtkWidget *box;
3564 GtkWidget *hbox;
3565 GtkWidget *button;
3566 GtkWidget *label;
3567 GtkWidget *hsep;
3569 GAIM_DIALOG(window);
3570 gtk_window_set_wmclass(GTK_WINDOW(window), "dialog", "Gaim");
3571 gtk_container_set_border_width(GTK_CONTAINER(window), 10);
3572 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, TRUE);
3573 gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(destroy_dialog), window);
3574 gtk_widget_realize(window);
3575 aol_icon(window->window);
3577 box = gtk_vbox_new(FALSE, 5);
3578 gtk_container_add(GTK_CONTAINER(window), box);
3580 label = gtk_label_new(_("Really clear log?"));
3581 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 15);
3583 hsep = gtk_hseparator_new();
3584 gtk_box_pack_start(GTK_BOX(box), hsep, FALSE, FALSE, 0);
3586 hbox = gtk_hbox_new(FALSE, 0);
3587 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);
3588 gtk_widget_show(hbox);
3590 button = picture_button(window, _("Cancel"), cancel_xpm);
3591 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), window);
3592 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5);
3593 gtk_widget_show(button);
3595 button = picture_button(window, _("Okay"), ok_xpm);
3596 gtk_object_set_user_data(GTK_OBJECT(button), gtk_object_get_user_data(GTK_OBJECT(w)));
3597 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_clear_log_file), name);
3598 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), window);
3599 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5);
3600 gtk_widget_show(button);
3602 gtk_widget_show_all(window);
3604 return;
3607 static void log_show_convo(GtkWidget *w, struct view_log *view)
3609 gchar buf[BUF_LONG];
3610 FILE *fp;
3611 char filename[256];
3612 int i=0;
3613 GString *string;
3614 guint block;
3616 string = g_string_new("");
3618 if (view->name) {
3619 char *tmp = gaim_user_dir();
3620 g_snprintf(filename, 256, "%s/logs/%s.log", tmp, normalize(view->name));
3621 g_free(tmp);
3622 } else {
3623 char *tmp = gaim_user_dir();
3624 g_snprintf(filename, 256, "%s/logs/system", tmp);
3625 g_free(tmp);
3627 if ((fp = fopen(filename, "r")) == NULL) {
3628 g_snprintf(buf, BUF_LONG, "Unable to open log file %s", filename);
3629 do_error_dialog(buf, "Error!");
3630 return;
3633 gtk_widget_set_sensitive(view->bbox, FALSE);
3634 gtk_signal_disconnect_by_func(GTK_OBJECT(view->window),
3635 GTK_SIGNAL_FUNC(destroy_dialog), view->window);
3636 block = gtk_signal_connect(GTK_OBJECT(view->window), "delete_event",
3637 GTK_SIGNAL_FUNC(dont_destroy), view->window);
3639 fseek(fp, view->offset, SEEK_SET);
3640 gtk_imhtml_clear(GTK_IMHTML(view->layout));
3642 while (gtk_events_pending())
3643 gtk_main_iteration();
3646 while (fgets(buf, BUF_LONG, fp) && !strstr(buf, "---- New C")) {
3647 i++;
3648 if (strlen(buf) >= 5 && (!strncmp(buf + strlen(buf) - 5, "<BR>\n", 5)))
3649 /* take off the \n */
3650 buf[strlen(buf) - 1] = '\0';
3652 /* don't lose the thirtieth line of conversation. thanks FeRD */
3653 g_string_append(string, buf);
3655 if (i == 30) {
3656 gtk_imhtml_append_text(GTK_IMHTML(view->layout), string->str, -1, view->options);
3657 g_string_free(string, TRUE);
3658 string = g_string_new("");
3659 /* you can't have these anymore. if someone clicks on another item while one is
3660 * drawing, it will try to move to that item, and that causes problems here.
3661 while (gtk_events_pending())
3662 gtk_main_iteration();
3664 i = 0;
3668 gtk_imhtml_append_text(GTK_IMHTML(view->layout), string->str, -1, view->options);
3669 gtk_imhtml_append_text(GTK_IMHTML(view->layout), "<BR>", -1, view->options);
3671 gtk_widget_set_sensitive(view->bbox, TRUE);
3672 gtk_signal_disconnect(GTK_OBJECT(view->window), block);
3673 gtk_signal_connect(GTK_OBJECT(view->window), "delete_event",
3674 GTK_SIGNAL_FUNC(destroy_dialog), view->window);
3675 g_string_free(string, TRUE);
3676 fclose(fp);
3679 static void des_view_item(GtkObject *obj, struct view_log *view)
3681 if (view->name)
3682 g_free(view->name);
3683 g_free(view);
3686 static void des_log_win(GtkObject *win, gpointer data)
3688 char *x = gtk_object_get_user_data(win);
3689 if (x)
3690 g_free(x);
3693 void show_log(char *nm)
3695 gchar filename[256];
3696 gchar buf[BUF_LONG];
3697 FILE *fp;
3698 GtkWidget *window;
3699 GtkWidget *box;
3700 GtkWidget *hbox;
3701 GtkWidget *bbox;
3702 GtkWidget *sw;
3703 GtkWidget *layout;
3704 GtkWidget *close_button;
3705 GtkWidget *clear_button;
3706 GtkWidget *save_button;
3707 GtkWidget *list = NULL;
3708 GList *item_list = NULL;
3709 GtkWidget *item = NULL;
3710 GtkWidget *last = NULL;
3711 GtkWidget *frame;
3712 struct view_log *view;
3713 char *name = nm ? g_strdup(nm) : NULL;
3715 int options;
3716 guint block;
3717 char convo_start[32];
3718 long offset = 0;
3719 unsigned int i = 0;
3721 options = GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL;
3722 if (convo_options & OPT_CONVO_IGNORE_COLOUR)
3723 options ^= GTK_IMHTML_NO_COLOURS;
3724 if (convo_options & OPT_CONVO_IGNORE_FONTS)
3725 options ^= GTK_IMHTML_NO_FONTS;
3726 if (convo_options & OPT_CONVO_IGNORE_SIZES)
3727 options ^= GTK_IMHTML_NO_SIZES;
3729 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3730 gtk_object_set_user_data(GTK_OBJECT(window), name);
3731 gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(des_log_win), NULL);
3732 gtk_window_set_wmclass(GTK_WINDOW(window), "log", "Gaim");
3733 if (name)
3734 g_snprintf(buf, BUF_LONG, "Gaim - Conversations with %s", name);
3735 else
3736 g_snprintf(buf, BUF_LONG, "Gaim - System Log");
3737 gtk_window_set_title(GTK_WINDOW(window), buf);
3738 gtk_container_set_border_width(GTK_CONTAINER(window), 10);
3739 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, TRUE);
3740 block = gtk_signal_connect(GTK_OBJECT(window), "delete_event",
3741 GTK_SIGNAL_FUNC(dont_destroy), window);
3742 gtk_widget_realize(window);
3743 aol_icon(window->window);
3745 layout = gtk_imhtml_new(NULL, NULL);
3746 bbox = gtk_hbox_new(FALSE, 0);
3748 box = gtk_vbox_new(FALSE, 5);
3749 gtk_container_add(GTK_CONTAINER(window), box);
3751 hbox = gtk_hbox_new(FALSE, 5);
3752 gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0);
3754 if (name) {
3755 char *tmp = gaim_user_dir();
3756 g_snprintf(filename, 256, "%s/logs/%s.log", tmp, normalize(name));
3757 g_free(tmp);
3758 if ((fp = fopen(filename, "r")) == NULL) {
3759 g_snprintf(buf, BUF_LONG, "Unable to open log file %s", filename);
3760 do_error_dialog(buf, "Error!");
3761 return;
3764 list = gtk_list_new();
3766 frame = gtk_frame_new(_("Date"));
3767 gtk_widget_show(frame);
3769 sw = gtk_scrolled_window_new(NULL, NULL);
3770 gtk_container_set_border_width(GTK_CONTAINER(sw), 5);
3771 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), list);
3772 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
3773 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
3774 gtk_widget_set_usize(sw, 220, 220);
3775 gtk_container_add(GTK_CONTAINER(frame), sw);
3776 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
3778 while (fgets(buf, BUF_LONG, fp)) {
3779 if (strstr(buf, "---- New C")) {
3780 int length;
3781 char *temp = strchr(buf, '@');
3783 if (temp == NULL || strlen(temp) < 2)
3784 continue;
3786 if (i == 1 && item_list) {
3787 item_list = g_list_remove(item_list, last);
3788 last = NULL;
3791 i = 0;
3793 temp++;
3794 length = strcspn(temp, "-");
3795 if (length > 31) length = 31;
3797 offset = ftell(fp);
3798 g_snprintf(convo_start, length, "%s", temp);
3799 item = gtk_list_item_new_with_label(convo_start);
3800 view = g_new0(struct view_log, 1);
3801 view->options = options;
3802 view->offset = offset;
3803 view->name = g_strdup(name);
3804 view->bbox = bbox;
3805 view->window = window;
3806 view->layout = layout;
3807 gtk_signal_connect(GTK_OBJECT(item), "select",
3808 GTK_SIGNAL_FUNC(log_show_convo), view);
3809 gtk_signal_connect(GTK_OBJECT(item), "destroy",
3810 GTK_SIGNAL_FUNC(des_view_item), view);
3811 last = item;
3812 item_list = g_list_append(item_list, item);
3814 gtk_widget_show(item);
3816 i++;
3818 fclose(fp);
3819 if (i == 1 && item_list)
3820 item_list = g_list_remove(item_list, item);
3822 if (item_list)
3823 gtk_list_insert_items(GTK_LIST(list), item_list, 0 );
3826 gtk_signal_disconnect(GTK_OBJECT(window), block);
3827 gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(destroy_dialog), window);
3829 frame = gtk_frame_new(_("Conversation"));
3830 gtk_widget_show(frame);
3832 sw = gtk_scrolled_window_new(NULL, NULL);
3833 gtk_container_set_border_width(GTK_CONTAINER(sw), 5);
3834 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
3835 gtk_widget_set_usize(sw, 390, 220);
3836 gtk_container_add(GTK_CONTAINER(frame), sw);
3837 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
3839 gtk_signal_connect(GTK_OBJECT(layout), "url_clicked", GTK_SIGNAL_FUNC(open_url), NULL);
3840 gtk_container_add(GTK_CONTAINER(sw), layout);
3841 GTK_LAYOUT(layout)->hadjustment->step_increment = 10.0;
3842 GTK_LAYOUT(layout)->vadjustment->step_increment = 10.0;
3843 gaim_setup_imhtml(layout);
3845 gtk_box_pack_start(GTK_BOX(box), bbox, FALSE, FALSE, 0);
3846 gtk_widget_set_sensitive(bbox, FALSE);
3848 close_button = picture_button(window, _("Close"), cancel_xpm);
3849 gtk_box_pack_end(GTK_BOX(bbox), close_button, FALSE, FALSE, 5);
3850 gtk_signal_connect(GTK_OBJECT(close_button), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), window);
3852 clear_button = picture_button(window, _("Clear"), close_xpm);
3853 gtk_object_set_user_data(GTK_OBJECT(clear_button), window);
3854 gtk_box_pack_end(GTK_BOX(bbox), clear_button, FALSE, FALSE, 5);
3855 gtk_signal_connect(GTK_OBJECT(clear_button), "clicked", GTK_SIGNAL_FUNC(show_clear_log), name);
3857 save_button = picture_button(window, _("Save"), save_xpm);
3858 gtk_box_pack_end(GTK_BOX(bbox), save_button, FALSE, FALSE, 5);
3859 gtk_signal_connect(GTK_OBJECT(save_button), "clicked", GTK_SIGNAL_FUNC(show_save_log), name);
3861 gtk_widget_show_all(window);
3863 if (!name) {
3864 view = g_new0(struct view_log, 1);
3865 view->options = options;
3866 view->name = NULL;
3867 view->bbox = bbox;
3868 view->window = window;
3869 view->layout = layout;
3870 log_show_convo(layout, view);
3871 gtk_signal_connect(GTK_OBJECT(layout), "destroy", GTK_SIGNAL_FUNC(des_view_item), view);
3872 } else {
3873 gtk_list_select_item(GTK_LIST(list), 0);
3876 gtk_widget_set_sensitive(bbox, TRUE);
3878 return;
3881 /*------------------------------------------------------------------------*/
3882 /* The dialog for renaming groups */
3883 /*------------------------------------------------------------------------*/
3885 static void do_rename_group(GtkObject *obj, GtkWidget *entry)
3887 char *new_name;
3888 struct group *g;
3889 struct group *orig;
3890 struct gaim_connection *gc;
3892 new_name = gtk_entry_get_text(GTK_ENTRY(entry));
3893 g = gtk_object_get_user_data(obj);
3895 if (new_name && (strlen(new_name) != 0) && strcmp(new_name, g->name)) {
3896 char *prevname;
3897 gc = g->gc;
3898 if ((orig = find_group(g->gc, new_name)) != NULL) {
3899 orig->members = g_slist_concat(orig->members, g->members);
3900 handle_group_rename(orig, g->name);
3901 g->gc->groups = g_slist_remove(g->gc->groups, g);
3902 /* FIXME, i don't like calling this. it's sloppy. */ build_edit_tree();
3903 g_free(g);
3904 } else {
3905 prevname = g_strdup(g->name);
3906 g_snprintf(g->name, sizeof(g->name), "%s", new_name);
3907 handle_group_rename(g, prevname);
3908 g_free(prevname);
3910 do_export(gc);
3913 destroy_dialog(rename_dialog, rename_dialog);
3916 void show_rename_group(GtkWidget *unused, struct group *g)
3918 GtkWidget *mainbox;
3919 GtkWidget *frame;
3920 GtkWidget *fbox;
3921 GtkWidget *bbox;
3922 GtkWidget *button;
3923 GtkWidget *name_entry;
3924 GtkWidget *label;
3926 if (!rename_dialog) {
3927 GAIM_DIALOG(rename_dialog);
3928 gtk_window_set_wmclass(GTK_WINDOW(rename_dialog), "rename_dialog", "Gaim");
3929 gtk_window_set_policy(GTK_WINDOW(rename_dialog), FALSE, TRUE, TRUE);
3930 gtk_window_set_title(GTK_WINDOW(rename_dialog), _("Gaim - Rename Group"));
3931 gtk_signal_connect(GTK_OBJECT(rename_dialog), "destroy",
3932 GTK_SIGNAL_FUNC(destroy_dialog), rename_dialog);
3933 gtk_widget_realize(rename_dialog);
3934 aol_icon(rename_dialog->window);
3936 mainbox = gtk_vbox_new(FALSE, 5);
3937 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
3938 gtk_container_add(GTK_CONTAINER(rename_dialog), mainbox);
3940 frame = gtk_frame_new(_("Rename Group"));
3941 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
3943 fbox = gtk_hbox_new(FALSE, 5);
3944 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
3945 gtk_container_add(GTK_CONTAINER(frame), fbox);
3947 label = gtk_label_new(_("New name:"));
3948 gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0);
3950 name_entry = gtk_entry_new();
3951 gtk_box_pack_start(GTK_BOX(fbox), name_entry, TRUE, TRUE, 0);
3952 gtk_object_set_user_data(GTK_OBJECT(name_entry), g);
3953 gtk_entry_set_text(GTK_ENTRY(name_entry), g->name);
3954 gtk_signal_connect(GTK_OBJECT(name_entry), "activate",
3955 GTK_SIGNAL_FUNC(do_rename_group), name_entry);
3956 gtk_widget_grab_focus(name_entry);
3958 bbox = gtk_hbox_new(FALSE, 5);
3959 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
3961 button = picture_button(rename_dialog, _("Cancel"), cancel_xpm);
3962 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
3963 gtk_signal_connect(GTK_OBJECT(button), "clicked",
3964 GTK_SIGNAL_FUNC(destroy_dialog), rename_dialog);
3966 button = picture_button(rename_dialog, _("OK"), ok_xpm);
3967 gtk_object_set_user_data(GTK_OBJECT(button), g);
3968 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
3969 gtk_signal_connect(GTK_OBJECT(button), "clicked",
3970 GTK_SIGNAL_FUNC(do_rename_group), name_entry);
3973 gtk_widget_show_all(rename_dialog);
3977 /*------------------------------------------------------------------------*/
3978 /* The dialog for renaming buddies */
3979 /*------------------------------------------------------------------------*/
3981 static void do_rename_buddy(GtkObject *obj, GtkWidget *entry)
3983 char *new_name;
3984 struct buddy *b;
3985 GSList *gr;
3987 new_name = gtk_entry_get_text(GTK_ENTRY(entry));
3988 b = gtk_object_get_user_data(obj);
3990 if (!g_slist_find(connections, b->gc)) {
3991 destroy_dialog(rename_bud_dialog, rename_bud_dialog);
3992 return;
3995 gr = b->gc->groups;
3996 while (gr) {
3997 if (g_slist_find(((struct group *)gr->data)->members, b))
3998 break;
3999 gr = gr->next;
4001 if (!gr) {
4002 destroy_dialog(rename_bud_dialog, rename_bud_dialog);
4003 return;
4006 if (new_name && (strlen(new_name) != 0) && strcmp(new_name, b->name)) {
4007 struct group *g = find_group_by_buddy(b->gc, b->name);
4008 char *prevname = g_strdup(b->name);
4009 if (g)
4010 serv_remove_buddy(b->gc, b->name, g->name);
4011 if (!strcmp(b->name, b->show))
4012 g_snprintf(b->show, sizeof(b->show), "%s", new_name);
4013 g_snprintf(b->name, sizeof(b->name), "%s", new_name);
4014 serv_add_buddy(b->gc, b->name);
4015 handle_buddy_rename(b, prevname);
4016 g_free(prevname);
4019 destroy_dialog(rename_bud_dialog, rename_bud_dialog);
4022 void show_rename_buddy(GtkWidget *unused, struct buddy *b)
4024 GtkWidget *mainbox;
4025 GtkWidget *frame;
4026 GtkWidget *fbox;
4027 GtkWidget *bbox;
4028 GtkWidget *button;
4029 GtkWidget *name_entry;
4030 GtkWidget *label;
4032 if (!rename_bud_dialog) {
4033 GAIM_DIALOG(rename_bud_dialog);
4034 gtk_window_set_wmclass(GTK_WINDOW(rename_bud_dialog), "rename_bud_dialog", "Gaim");
4035 gtk_window_set_policy(GTK_WINDOW(rename_bud_dialog), FALSE, TRUE, TRUE);
4036 gtk_window_set_title(GTK_WINDOW(rename_bud_dialog), _("Gaim - Rename Buddy"));
4037 gtk_signal_connect(GTK_OBJECT(rename_bud_dialog), "destroy",
4038 GTK_SIGNAL_FUNC(destroy_dialog), rename_bud_dialog);
4039 gtk_widget_realize(rename_bud_dialog);
4040 aol_icon(rename_bud_dialog->window);
4042 mainbox = gtk_vbox_new(FALSE, 5);
4043 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
4044 gtk_container_add(GTK_CONTAINER(rename_bud_dialog), mainbox);
4046 frame = gtk_frame_new(_("Rename Buddy"));
4047 gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
4049 fbox = gtk_hbox_new(FALSE, 5);
4050 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
4051 gtk_container_add(GTK_CONTAINER(frame), fbox);
4053 label = gtk_label_new(_("New name:"));
4054 gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0);
4056 name_entry = gtk_entry_new();
4057 gtk_box_pack_start(GTK_BOX(fbox), name_entry, TRUE, TRUE, 0);
4058 gtk_object_set_user_data(GTK_OBJECT(name_entry), b);
4059 gtk_entry_set_text(GTK_ENTRY(name_entry), b->name);
4060 gtk_signal_connect(GTK_OBJECT(name_entry), "activate",
4061 GTK_SIGNAL_FUNC(do_rename_buddy), name_entry);
4062 gtk_widget_grab_focus(name_entry);
4064 bbox = gtk_hbox_new(FALSE, 5);
4065 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
4067 button = picture_button(rename_bud_dialog, _("Cancel"), cancel_xpm);
4068 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
4069 gtk_signal_connect(GTK_OBJECT(button), "clicked",
4070 GTK_SIGNAL_FUNC(destroy_dialog), rename_bud_dialog);
4072 button = picture_button(rename_bud_dialog, _("OK"), ok_xpm);
4073 gtk_object_set_user_data(GTK_OBJECT(button), b);
4074 gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
4075 gtk_signal_connect(GTK_OBJECT(button), "clicked",
4076 GTK_SIGNAL_FUNC(do_rename_buddy), name_entry);
4079 gtk_widget_show_all(rename_bud_dialog);
4082 #ifdef USE_PERL
4084 static GtkWidget *perl_config = NULL;
4085 static char *perl_last_dir = NULL;
4087 static void cfdes(GtkWidget *m, gpointer n)
4089 if (perl_config)
4090 gtk_widget_destroy(perl_config);
4091 perl_config = NULL;
4094 static void do_load(GtkWidget *m, gpointer n)
4096 const char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(perl_config));
4097 gchar *f = NULL;
4098 if (!file || !strlen(file)) {
4099 return;
4102 if (file_is_dir(file, perl_config)) {
4103 return;
4106 if (perl_last_dir) {
4107 g_free(perl_last_dir);
4109 perl_last_dir = g_dirname(file);
4111 debug_printf("Loading perl script: %s\n", file);
4113 f = g_strdup(file);
4114 perl_load_file(f);
4115 g_free(f);
4116 cfdes(perl_config, NULL);
4119 void load_perl_script()
4121 char *buf, *temp;
4123 if (perl_config) {
4124 gtk_widget_show(perl_config);
4125 gdk_window_raise(perl_config->window);
4126 return;
4129 /* Below is basically stolen from plugins.c */
4130 perl_config = gtk_file_selection_new(_("Gaim - Select Perl Script"));
4132 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(perl_config));
4134 if (!perl_last_dir) {
4135 temp = gaim_user_dir();
4136 buf = g_strconcat(temp, G_DIR_SEPARATOR_S, NULL);
4137 g_free(temp);
4138 } else {
4139 buf = g_strconcat(perl_last_dir, G_DIR_SEPARATOR_S, NULL);
4142 gtk_file_selection_set_filename(GTK_FILE_SELECTION(perl_config), buf);
4143 gtk_file_selection_complete(GTK_FILE_SELECTION(perl_config), "*.pl");
4144 gtk_signal_connect(GTK_OBJECT(perl_config), "destroy", GTK_SIGNAL_FUNC(cfdes), perl_config);
4146 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(perl_config)->ok_button),
4147 "clicked", GTK_SIGNAL_FUNC(do_load), NULL);
4149 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(perl_config)->cancel_button),
4150 "clicked", GTK_SIGNAL_FUNC(cfdes), NULL);
4152 g_free(buf);
4153 gtk_widget_show(perl_config);
4154 gdk_window_raise(perl_config->window);
4157 #endif /* USE_PERL */
4159 static GdkPixmap *icon_pm = NULL;
4160 static GdkBitmap *icon_bm = NULL;
4162 void aol_icon(GdkWindow *w)
4164 #ifndef _WIN32
4165 if (icon_pm == NULL) {
4166 icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm, NULL, (gchar **)aimicon_xpm);
4168 gdk_window_set_icon(w, NULL, icon_pm, icon_bm);
4169 if (mainwindow)
4170 gdk_window_set_group(w, mainwindow->window);
4171 #endif
4174 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm)
4176 GtkWidget *button;
4177 GtkWidget *button_box, *button_box_2, *button_box_3;
4178 GtkWidget *label;
4179 GdkBitmap *mask;
4180 GdkPixmap *pm;
4181 GtkWidget *pixmap;
4183 button = gtk_button_new();
4184 if (misc_options & OPT_MISC_COOL_LOOK)
4185 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
4187 button_box = gtk_hbox_new(FALSE, 5);
4188 gtk_container_add(GTK_CONTAINER(button), button_box);
4190 button_box_2 = gtk_hbox_new(FALSE, 0);
4191 button_box_3 = gtk_hbox_new(FALSE, 0);
4192 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
4193 gtk_box_pack_start(GTK_BOX(button_box), button_box_3, TRUE, TRUE, 0);
4194 pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
4195 pixmap = gtk_pixmap_new(pm, mask);
4196 gtk_box_pack_end(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
4198 if (text) {
4199 label = gtk_label_new(text);
4200 gtk_box_pack_start(GTK_BOX(button_box_3), label, FALSE, FALSE, 2);
4201 gtk_widget_show(label);
4204 gtk_widget_show(pixmap);
4205 gtk_widget_show(button_box_2);
4206 gtk_widget_show(button_box_3);
4207 gtk_widget_show(button_box);
4209 /* this causes clipping on lots of buttons with long text */
4210 /* gtk_widget_set_usize(button, 75, 30);*/
4211 gtk_widget_show(button);
4212 gdk_pixmap_unref(pm);
4213 gdk_bitmap_unref(mask);
4215 return button;
4218 static GtkTooltips *button_tips = NULL;
4219 GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short dispstyle)
4221 GtkWidget *button;
4222 GtkWidget *button_box, *button_box_2;
4223 GdkBitmap *mask;
4224 GdkPixmap *pm;
4225 GtkWidget *pixmap;
4226 GtkWidget *label;
4228 if (!button_tips)
4229 button_tips = gtk_tooltips_new();
4230 button = gtk_button_new();
4231 if (misc_options & OPT_MISC_COOL_LOOK)
4232 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
4234 button_box = gtk_hbox_new(FALSE, 0);
4235 gtk_container_add(GTK_CONTAINER(button), button_box);
4237 button_box_2 = gtk_vbox_new(FALSE, 0);
4239 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
4240 gtk_widget_show(button_box_2);
4241 gtk_widget_show(button_box);
4242 if (dispstyle == 2 || dispstyle == 0) {
4243 pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
4244 pixmap = gtk_pixmap_new(pm, mask);
4245 gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
4247 gtk_widget_show(pixmap);
4249 gdk_pixmap_unref(pm);
4250 gdk_bitmap_unref(mask);
4253 if (dispstyle == 2 || dispstyle == 1) {
4254 label = gtk_label_new(text);
4255 gtk_widget_show(label);
4256 gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0);
4259 gtk_tooltips_set_tip(button_tips, button, text, "Gaim");
4260 gtk_widget_show(button);
4261 return button;
4264 int file_is_dir(const char *path, GtkWidget *w)
4266 struct stat st;
4267 char *name;
4269 if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
4270 /* append a / if needed */
4271 if (path[strlen(path) - 1] != '/') {
4272 name = g_strconcat(path, "/", NULL);
4273 } else {
4274 name = g_strdup(path);
4276 gtk_file_selection_set_filename(GTK_FILE_SELECTION(w), name);
4277 g_free(name);
4278 return 1;
4281 return 0;
4284 /*------------------------------------------------------------------------*/
4285 /* The dialog for setting V-Card info */
4286 /*------------------------------------------------------------------------*/
4288 * There are actually two "chunks" of code following: generic "multi-entry dialog"
4289 * support and V-Card dialog specific support.
4291 * At first blush, this may seem like an unnecessary duplication of effort given
4292 * that a "set dir info" dialog already exists. However, this is not so because:
4294 * 1. V-Cards can have a lot more data in them than what the current
4295 * "set dir" dialog supports.
4297 * 2. V-Card data, at least with respect to Jabber, is currently in a
4298 * state of flux. As the data and format changes, all that need be
4299 * changed with the V-Card support I've written is the "template"
4300 * data.
4302 * 3. The "multi entry dialog" support itself was originally written
4303 * to support Jabber server user registration (TBD). A "dynamically
4304 * configurable" multi-entry dialog is needed for that, as different
4305 * servers may require different registration information. It just
4306 * turned out to be well-suited to adding V-Card setting support, as
4307 * well :-).
4309 * TBD: Add check-box support to the generic multi-entry dialog support so that
4310 * it can be used to "replace" the "set dir info" support?
4312 * Multiple-language support. Currently Not In There. I think this should
4313 * be easy. Note that when it's added: if anybody saved their data in
4314 * English, it'll be lost when MLS is added and they'll have to re-enter it.
4316 * More "TBDs" noted in the code.
4320 /*------------------------------------*/
4321 /* generic multi-entry dialog support */
4322 /*------------------------------------*/
4325 * Print all multi-entry items
4327 * Note: Simply a debug helper
4329 void multi_entry_item_print_all(const GSList *list) {
4331 int cnt = 0;
4333 /* While there's something to print... */
4334 while(list != NULL) {
4335 fprintf(stderr, "label %2d: \"%s\"", ++cnt, ((MultiEntryData *) (list->data))->label);
4336 if(((MultiEntryData *) (list->data))->text != NULL) {
4337 fprintf(stderr, ", text: \"%s\"", ((MultiEntryData *) (list->data))->text);
4339 fputs("\n", stderr);
4340 list = list->next;
4345 * Print all multi-text items
4347 * Note: Simply a debug helper
4349 void multi_text_item_print_all(const GSList *list) {
4351 int cnt = 0;
4353 /* While there's something to print... */
4354 while(list != NULL) {
4355 fprintf(stderr, "label %2d: \"%s\"", ++cnt, ((MultiTextData *) (list->data))->label);
4356 if(((MultiTextData *) (list->data))->text != NULL) {
4357 fprintf(stderr, ", text: \"%s\"", ((MultiTextData *) (list->data))->text);
4359 fputs("\n", stderr);
4360 list = list->next;
4366 * Free all multi-entry item allocs and NULL the list pointer
4368 void multi_entry_items_free_all(GSList **list)
4371 GSList *next = *list;
4372 MultiEntryData *data;
4374 /* While there's something to free() ... */
4375 while(next != NULL) {
4376 data = (MultiEntryData *) next->data;
4377 g_free(data->label);
4378 g_free(data->text);
4379 g_free(data);
4380 next = next->next;
4382 g_slist_free(*list);
4383 *list = NULL;
4387 * Free all multi-text item allocs and NULL the list pointer
4389 void multi_text_items_free_all(GSList **list)
4392 GSList *next = *list;
4393 MultiTextData *data;
4395 /* While there's something to free() ... */
4396 while(next != NULL) {
4397 data = (MultiTextData *) next->data;
4398 g_free(data->label);
4399 g_free(data->text);
4400 g_free(data);
4401 next = next->next;
4403 g_slist_free(*list);
4404 *list = NULL;
4408 * See if a MultiEntryData item contains a given label
4410 * See: glib docs for g_slist_compare_custom() for details
4412 static gint multi_entry_data_label_compare(gconstpointer data, gconstpointer label)
4414 return(strcmp(((MultiEntryData *) (data))->label, (char *) label));
4418 * Add a new multi-entry item to list
4420 * If adding to existing list: will search the list for existence of
4421 * "label" and change/create "text" entry if necessary.
4424 MultiEntryData *multi_entry_list_update(GSList **list, const char *label, const char *text, int add_it)
4426 GSList *found;
4427 MultiEntryData *data;
4429 if((found = g_slist_find_custom(*list, (void *)label, multi_entry_data_label_compare)) == NULL) {
4430 if(add_it) {
4431 data = (MultiEntryData *) g_slist_last(*list =
4432 g_slist_append(*list, g_malloc(sizeof(MultiEntryData))))->data;
4433 data->label = strcpy(g_malloc(strlen(label) +1), label);
4434 data->text = NULL;
4436 * default to setting "visible" and editable to TRUE - they can be
4437 * overridden later, of course.
4439 data->visible = TRUE;
4440 data->editable = TRUE;
4441 } else {
4442 data = NULL;
4444 } else {
4445 data = found->data;
4448 if(data != NULL && text != NULL && text[0] != '\0') {
4449 if(data->text == NULL) {
4450 data->text = g_malloc(strlen(text) + 1);
4451 } else {
4452 data->text = g_realloc(data->text, strlen(text) + 1);
4454 strcpy(data->text, text);
4457 return(data);
4461 * See if a MultiTextData item contains a given label
4463 * See: glib docs for g_slist_compare_custom() for details
4465 static gint multi_text_data_label_compare(gconstpointer data, gconstpointer label)
4467 return(strcmp(((MultiTextData *) (data))->label, (char *) label));
4471 * Add a new multi-text item to list
4473 * If adding to existing list: will search the list for existence of
4474 * "label" and change/create "text" text if necessary.
4477 MultiTextData *multi_text_list_update(GSList **list, const char *label, const char *text, int add_it)
4479 GSList *found;
4480 MultiTextData *data;
4482 if((found = g_slist_find_custom(*list, (void *)label, multi_text_data_label_compare)) == NULL) {
4483 if(add_it) {
4484 data = (MultiTextData *) g_slist_last(*list =
4485 g_slist_append(*list, g_malloc(sizeof(MultiTextData))))->data;
4486 data->label = strcpy(g_malloc(strlen(label) +1), label);
4487 data->text = NULL;
4488 } else {
4489 data = NULL;
4491 } else {
4492 data = found->data;
4495 if(data != NULL && text != NULL && text[0] != '\0') {
4496 if(data->text == NULL) {
4497 data->text = g_malloc(strlen(text) + 1);
4498 } else {
4499 data->text = g_realloc(data->text, strlen(text) + 1);
4501 strcpy(data->text, text);
4504 return(data);
4508 * Free-up the multi-entry item list and the MultiEntryDlg
4509 * struct alloc.
4511 void multi_entry_free(struct multi_entry_dlg *b)
4513 multi_entry_items_free_all(&(b->multi_entry_items));
4514 multi_text_items_free_all(&(b->multi_text_items));
4515 g_free(b->instructions->text);
4516 g_free(b->instructions);
4517 g_free(b->entries_title);
4518 g_free(b);
4522 * Multi-Entry dialog "destroyed" catcher
4524 * Free-up the multi-entry item list, destroy the dialog widget
4525 * and free the MultiEntryDlg struct alloc.
4528 void multi_entry_dialog_destroy(GtkWidget *widget, gpointer data)
4530 MultiEntryDlg *b = data;
4532 multi_entry_free(b);
4536 * Show/Re-show instructions
4538 void re_show_multi_entry_instr(MultiInstrData *instructions)
4540 if(instructions->label != NULL) {
4541 if(instructions->text == NULL) {
4542 gtk_widget_hide(instructions->label);
4543 } else {
4544 gtk_label_set_text(GTK_LABEL (instructions->label), instructions->text);
4545 gtk_widget_show(instructions->label);
4551 * Show/Re-show entry boxes
4553 void re_show_multi_entry_entries(GtkWidget **entries_table,
4554 GtkWidget *entries_frame,
4555 GSList *multi_entry_items)
4557 GtkWidget *label;
4558 GSList *multi_entry;
4559 MultiEntryData *med;
4560 int rows, row_num, col_num, col_offset;
4561 int cols = 1;
4563 /* Figure-out number of rows needed for table */
4564 if((rows = g_slist_length(multi_entry_items)) > 9) {
4565 rows /= 2;
4566 ++cols;
4569 if(*entries_table != NULL) {
4570 gtk_widget_destroy(GTK_WIDGET (*entries_table));
4572 *entries_table = gtk_table_new(rows, 3 * cols, FALSE);
4573 gtk_container_add(GTK_CONTAINER (entries_frame), *entries_table);
4575 for(col_num = 0, multi_entry = multi_entry_items; col_num < cols && multi_entry != NULL;
4576 ++col_num) {
4577 col_offset = col_num * 3;
4578 for(row_num = 0; row_num < rows && multi_entry != NULL;
4579 ++row_num, multi_entry = multi_entry->next) {
4581 med = (MultiEntryData *) multi_entry->data;
4583 label = gtk_label_new(med->label);
4584 gtk_misc_set_alignment(GTK_MISC(label), (gfloat) 1.0, (gfloat) 0.5);
4585 gtk_table_attach_defaults(GTK_TABLE (*entries_table), label,
4586 col_offset, 1 + col_offset, row_num, row_num +1);
4587 gtk_widget_show(label);
4589 label = gtk_label_new(": ");
4590 gtk_misc_set_alignment(GTK_MISC(label), (gfloat) 0.0, (gfloat) 0.5);
4591 gtk_table_attach_defaults(GTK_TABLE (*entries_table), label,
4592 1 + col_offset, 2 + col_offset, row_num, row_num +1);
4593 gtk_widget_show(label);
4595 med->widget = gtk_entry_new_with_max_length(50);
4596 if(med->text != NULL) {
4597 gtk_entry_set_text(GTK_ENTRY (med->widget), med->text);
4599 gtk_entry_set_visibility(GTK_ENTRY (med->widget), med->visible);
4600 gtk_entry_set_editable(GTK_ENTRY (med->widget), med->editable);
4601 gtk_table_attach(GTK_TABLE (*entries_table), med->widget,
4602 2 + col_offset, 3 + col_offset, row_num, row_num +1,
4603 GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 5, 0);
4604 gtk_widget_show(med->widget);
4608 gtk_widget_show(*entries_table);
4612 * Show/Re-show textboxes
4614 void re_show_multi_entry_textboxes(GtkWidget **texts_ibox,
4615 GtkWidget *texts_obox,
4616 GSList *multi_text_items)
4618 GSList *multi_text;
4619 MultiTextData *mtd;
4620 GtkWidget *frame;
4621 GtkWidget *hbox;
4622 GtkWidget *vscrollbar;
4624 if(*texts_ibox != NULL) {
4625 gtk_widget_destroy(GTK_WIDGET (*texts_ibox));
4627 *texts_ibox = gtk_vbox_new(FALSE, 5);
4628 gtk_container_add(GTK_CONTAINER (texts_obox), *texts_ibox);
4630 for(multi_text = multi_text_items; multi_text != NULL; multi_text = multi_text->next) {
4631 mtd = (MultiTextData *) multi_text->data;
4632 frame = gtk_frame_new(mtd->label);
4633 gtk_container_add(GTK_CONTAINER (*texts_ibox), frame);
4634 hbox = gtk_hbox_new(FALSE, 0);
4635 gtk_container_add(GTK_CONTAINER (frame), hbox);
4636 mtd->textbox = gtk_text_new(NULL, NULL);
4637 gtk_text_set_editable(GTK_TEXT(mtd->textbox), TRUE);
4638 gtk_text_set_word_wrap(GTK_TEXT(mtd->textbox), TRUE);
4639 gtk_widget_set_usize(mtd->textbox, 300, 100);
4640 gtk_text_insert(GTK_TEXT(mtd->textbox), NULL, NULL, NULL, mtd->text, -1);
4641 gtk_box_pack_start(GTK_BOX (hbox), mtd->textbox, FALSE, FALSE, 0);
4642 vscrollbar = gtk_vscrollbar_new (GTK_TEXT(mtd->textbox)->vadj);
4643 gtk_box_pack_start(GTK_BOX (hbox), vscrollbar, FALSE, FALSE, 0);
4644 gtk_widget_show(mtd->textbox);
4645 gtk_widget_show (vscrollbar);
4646 gtk_widget_show(hbox);
4647 gtk_widget_show(frame);
4650 gtk_widget_show(*texts_ibox);
4654 * Create and initialize a new Multi-Entry Dialog struct
4656 MultiEntryDlg *multi_entry_dialog_new()
4658 MultiEntryDlg *b = g_new0(MultiEntryDlg, 1);
4659 b->instructions = g_new0(MultiInstrData, 1);
4660 b->multi_entry_items = NULL;
4661 b->multi_text_items = NULL;
4662 return(b);
4666 * Instantiate a new multi-entry dialog
4668 * data == pointer to MultiEntryDlg with the following
4669 * initialized:
4671 * wmclass_name
4672 * wmclass_class
4673 * title
4674 * user
4675 * multi_entry_items - pointers to MultiEntryData list
4676 * and MultiTextData list
4677 * instructions (optional)
4678 * ok function pointer
4679 * cancel function pointer (actually used to set
4680 * window destroy signal--cancel asserts destroy)
4682 * sets the following in the MultiEntryDialog struct:
4684 * window
4686 void show_multi_entry_dialog(gpointer data)
4688 GtkWidget *vbox, *hbox;
4689 GtkWidget *button;
4690 MultiEntryDlg *b = data;
4692 GAIM_DIALOG(b->window);
4693 gtk_container_set_border_width(GTK_CONTAINER(b->window), 5);
4694 gtk_window_set_wmclass(GTK_WINDOW(b->window), b->wmclass_name, b->wmclass_class);
4695 gtk_window_set_title(GTK_WINDOW (b->window), b->title);
4697 /* Clean up if user dismisses window via window manager! */
4698 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", GTK_SIGNAL_FUNC(b->cancel), (gpointer) b);
4699 gtk_widget_realize(b->window);
4700 aol_icon(b->window->window);
4702 vbox = gtk_vbox_new(FALSE, 5);
4703 gtk_container_add(GTK_CONTAINER (b->window), vbox);
4705 b->instructions->label = gtk_label_new(NULL);
4706 gtk_label_set_line_wrap(GTK_LABEL (b->instructions->label), TRUE);
4707 gtk_box_pack_start(GTK_BOX (vbox), b->instructions->label, TRUE, TRUE, 5);
4708 re_show_multi_entry_instr(b->instructions);
4710 b->entries_frame = gtk_frame_new(b->entries_title);
4711 gtk_box_pack_start(GTK_BOX (vbox), b->entries_frame, TRUE, TRUE, 5);
4712 gtk_widget_show(b->entries_frame);
4713 b->entries_table = NULL;
4714 re_show_multi_entry_entries(&(b->entries_table), b->entries_frame, b->multi_entry_items);
4716 b->texts_obox = gtk_vbox_new(FALSE, 0);
4717 gtk_box_pack_start(GTK_BOX (vbox), b->texts_obox, TRUE, TRUE, 5);
4718 gtk_widget_show(b->texts_obox);
4719 b->texts_ibox = NULL;
4720 re_show_multi_entry_textboxes(&(b->texts_ibox), b->texts_obox, b->multi_text_items);
4722 hbox = gtk_hbox_new(FALSE, 0);
4723 gtk_box_pack_start(GTK_BOX (vbox), hbox, FALSE, FALSE, 5);
4724 gtk_widget_show(hbox);
4726 button = picture_button(b->window, _("Cancel"), cancel_xpm);
4728 /* Let "destroy handling" (set above) handle cleanup */
4729 gtk_signal_connect_object(GTK_OBJECT (button), "clicked",
4730 GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (b->window));
4731 gtk_box_pack_end(GTK_BOX (hbox), button, FALSE, FALSE, 5);
4732 gtk_widget_show(button);
4734 button = picture_button(b->window, _("Save"), save_xpm);
4735 gtk_signal_connect(GTK_OBJECT (button), "clicked",
4736 GTK_SIGNAL_FUNC (b->ok), (gpointer) b);
4737 gtk_box_pack_end(GTK_BOX (hbox), button, FALSE, FALSE, 5);
4738 gtk_widget_show(button);
4740 gtk_widget_show(vbox);
4741 gtk_widget_show(b->window);
4745 /*------------------------------------*/
4746 /* V-Card dialog specific support */
4747 /*------------------------------------*/
4750 * V-Card "set info" dialog "Save" clicked
4752 * Copy data from GTK+ dialogs into GSLists, call protocol-specific
4753 * formatter and save the user info data.
4755 void set_vcard_dialog_ok_clicked(GtkWidget *widget, gpointer data)
4757 MultiEntryDlg *b = (MultiEntryDlg *) data;
4758 struct gaim_connection *gc;
4759 gchar *tmp;
4760 GSList *list;
4762 for(list = b->multi_entry_items; list != NULL; list = list->next) {
4763 if(((MultiEntryData *) list->data)->text != NULL) {
4764 g_free(((MultiEntryData *) list->data)->text);
4766 ((MultiEntryData *) list->data)->text =
4767 g_strdup(gtk_entry_get_text(GTK_ENTRY(((MultiEntryData *) list->data)->widget)));
4770 for(list = b->multi_text_items; list != NULL; list = list->next) {
4771 if(((MultiTextData *) list->data)->text != NULL) {
4772 g_free(((MultiTextData *) list->data)->text);
4774 ((MultiTextData *) list->data)->text =
4775 gtk_editable_get_chars((GtkEditable *) (((MultiTextData *) list->data)->textbox),
4776 0, -1);
4780 tmp = b->custom(b);
4783 * Set the user info and (possibly) send to the server
4785 if (b->user) {
4786 strncpy(b->user->user_info, tmp, sizeof b->user->user_info);
4787 gc = b->user->gc;
4789 save_prefs();
4791 if (gc)
4792 serv_set_info(gc, b->user->user_info);
4795 g_free(tmp);
4797 /* Let multi-edit dialog window "destroy" event catching handle remaining cleanup */
4798 gtk_widget_destroy(GTK_WIDGET (b->window));
4802 * Instantiate a v-card dialog
4804 void show_set_vcard(MultiEntryDlg *b)
4806 b->ok = set_vcard_dialog_ok_clicked;
4807 b->cancel = multi_entry_dialog_destroy;
4809 show_multi_entry_dialog(b);
4813 /*------------------------------------------------------------------------*/
4814 /* End dialog for setting v-card info */
4815 /*------------------------------------------------------------------------*/