4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
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
32 #include "gtkimhtml.h"
34 #include <gtkspell/gtkspell.h>
36 #include <gdk/gdkkeysyms.h>
44 static GList
*chatentries
= NULL
;
45 static GtkWidget
*joinchat
= NULL
;
46 static GtkWidget
*jc_vbox
= NULL
;
47 static struct gaim_connection
*joinchatgc
;
58 for (tmp
= chatentries
; tmp
!= NULL
; tmp
= tmp
->next
) {
59 if (g_object_get_data(tmp
->data
, "is_spin")) {
60 ival
= g_new0(int, 1);
61 *ival
= gtk_spin_button_get_value_as_int(tmp
->data
);
62 data
= g_list_append(data
, ival
);
65 sval
= g_strdup(gtk_entry_get_text(tmp
->data
));
66 data
= g_list_append(data
, sval
);
70 serv_join_chat(joinchatgc
, data
);
72 for (tmp
= data
; tmp
!= NULL
; tmp
= tmp
->next
)
77 gtk_widget_destroy(joinchat
);
80 g_list_free(chatentries
);
91 struct proto_chat_entry
*pce
;
92 gboolean focus
= TRUE
;
97 while (GTK_BOX(jc_vbox
)->children
)
98 gtk_container_remove(GTK_CONTAINER(jc_vbox
),
99 ((GtkBoxChild
*)GTK_BOX(jc_vbox
)->children
->data
)->widget
);
102 g_list_free(chatentries
);
106 list
= joinchatgc
->prpl
->chat_info(joinchatgc
);
108 for (tmp
= list
; tmp
!= NULL
; tmp
= tmp
->next
) {
114 rowbox
= gtk_hbox_new(FALSE
, 5);
115 gtk_box_pack_start(GTK_BOX(jc_vbox
), rowbox
, TRUE
, TRUE
, 0);
116 gtk_widget_show(rowbox
);
118 label
= gtk_label_new(pce
->label
);
119 gtk_box_pack_start(GTK_BOX(rowbox
), label
, FALSE
, FALSE
, 0);
120 gtk_widget_show(label
);
125 adjust
= gtk_adjustment_new(pce
->min
, pce
->min
,
126 pce
->max
, 1, 10, 10);
127 spin
= gtk_spin_button_new(GTK_ADJUSTMENT(adjust
), 1, 0);
128 g_object_set_data(G_OBJECT(spin
), "is_spin", GINT_TO_POINTER(TRUE
));
129 chatentries
= g_list_append(chatentries
, spin
);
130 gtk_widget_set_size_request(spin
, 50, -1);
131 gtk_box_pack_end(GTK_BOX(rowbox
), spin
, FALSE
, FALSE
, 0);
132 gtk_widget_show(spin
);
137 entry
= gtk_entry_new();
138 gtk_box_pack_end(GTK_BOX(rowbox
), entry
, FALSE
, FALSE
, 0);
140 chatentries
= g_list_append(chatentries
, entry
);
143 gtk_entry_set_text(GTK_ENTRY(entry
), pce
->def
);
146 gtk_widget_grab_focus(entry
);
150 g_signal_connect(G_OBJECT(entry
), "activate",
151 G_CALLBACK(do_join_chat
), NULL
);
153 gtk_widget_show(entry
);
163 joinchat_choose(GtkWidget
*w
, struct gaim_connection
*g
)
174 create_joinchat_menu(GtkWidget
*box
)
180 struct gaim_connection
*g
;
183 optmenu
= gtk_option_menu_new();
184 gtk_box_pack_start(GTK_BOX(box
), optmenu
, FALSE
, FALSE
, 0);
186 menu
= gtk_menu_new();
189 for (c
= connections
; c
!= NULL
; c
= c
->next
) {
190 g
= (struct gaim_connection
*)c
->data
;
192 if (!g
->prpl
->join_chat
)
198 g_snprintf(buf
, sizeof(buf
), "%s (%s)", g
->username
, g
->prpl
->name
);
199 opt
= gtk_menu_item_new_with_label(buf
);
201 g_object_set_data(G_OBJECT(opt
), "gaim_connection", g
);
203 g_signal_connect(G_OBJECT(opt
), "activate",
204 G_CALLBACK(joinchat_choose
), g
);
206 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), opt
);
207 gtk_widget_show(opt
);
210 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu
), menu
);
211 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu
), 0);
218 gtk_widget_destroy(joinchat
);
236 struct gaim_connection
*gc
= NULL
;
238 for (c
= connections
; c
!= NULL
; c
= c
->next
) {
241 if (gc
->prpl
->join_chat
)
249 _("You are not currently signed on with any protocols that have "
250 "the ability to chat."), NULL
, GAIM_ERROR
);
256 GAIM_DIALOG(joinchat
);
257 gtk_window_set_role(GTK_WINDOW(joinchat
), "joinchat");
258 gtk_window_set_resizable(GTK_WINDOW(joinchat
), TRUE
);
259 gtk_widget_realize(joinchat
);
260 g_signal_connect(G_OBJECT(joinchat
), "delete_event",
261 G_CALLBACK(destroy_join_chat
), joinchat
);
262 gtk_window_set_title(GTK_WINDOW(joinchat
), _("Join Chat"));
264 mainbox
= gtk_vbox_new(FALSE
, 5);
265 gtk_container_set_border_width(GTK_CONTAINER(mainbox
), 5);
266 gtk_container_add(GTK_CONTAINER(joinchat
), mainbox
);
268 frame
= make_frame(mainbox
, _("Buddy Chat"));
270 fbox
= gtk_vbox_new(FALSE
, 5);
271 gtk_container_set_border_width(GTK_CONTAINER(fbox
), 5);
272 gtk_container_add(GTK_CONTAINER(frame
), fbox
);
275 rowbox
= gtk_hbox_new(FALSE
, 5);
276 gtk_box_pack_start(GTK_BOX(fbox
), rowbox
, TRUE
, TRUE
, 0);
278 label
= gtk_label_new(_("Join Chat As:"));
279 gtk_box_pack_start(GTK_BOX(rowbox
), label
, FALSE
, FALSE
, 0);
281 create_joinchat_menu(rowbox
);
283 jc_vbox
= gtk_vbox_new(FALSE
, 5);
284 gtk_container_add(GTK_CONTAINER(fbox
), jc_vbox
);
285 gtk_container_set_border_width(GTK_CONTAINER(jc_vbox
), 0);
288 joinchatgc
= connections
->data
;
293 sep
= gtk_hseparator_new();
294 gtk_widget_show(sep
);
295 gtk_box_pack_start(GTK_BOX(mainbox
), sep
, FALSE
, FALSE
, 0);
297 bbox
= gtk_hbox_new(FALSE
, 5);
298 gtk_box_pack_start(GTK_BOX(mainbox
), bbox
, FALSE
, FALSE
, 0);
301 join
= gaim_pixbuf_button_from_stock(_("Join"), GTK_STOCK_JUMP_TO
,
302 GAIM_BUTTON_HORIZONTAL
);
303 gtk_box_pack_end(GTK_BOX(bbox
), join
, FALSE
, FALSE
, 0);
304 g_signal_connect(G_OBJECT(join
), "clicked",
305 G_CALLBACK(do_join_chat
), NULL
);
307 cancel
= gaim_pixbuf_button_from_stock(_("Cancel"), GTK_STOCK_CANCEL
,
308 GAIM_BUTTON_HORIZONTAL
);
309 gtk_box_pack_end(GTK_BOX(bbox
), cancel
, FALSE
, FALSE
, 0);
310 g_signal_connect(G_OBJECT(cancel
), "clicked",
311 G_CALLBACK(destroy_join_chat
), joinchat
);
315 gtk_widget_show_all(joinchat
);