# HG changeset patch # User Eric Warmenhoven # Date 989061082 0 # Node ID c649b63382b712ccea16cac8f21a03724ea46319 # Parent caa605e709173bb64b356c0fe5b0f2abf6812f29 [gaim-migrate @ 1816] part one of nsanch's patch. i still need to look at what got changed with zephyr. committer: Tailor Script diff -r caa605e70917 -r c649b63382b7 src/buddy_chat.c --- a/src/buddy_chat.c Sat May 05 10:36:08 2001 +0000 +++ b/src/buddy_chat.c Sat May 05 11:11:22 2001 +0000 @@ -45,13 +45,29 @@ static GtkWidget *invite; static GtkWidget *inviteentry; static GtkWidget *invitemess; -static int community; +static GtkWidget *jc_vbox; extern int state_lock; GList *chats = NULL; GtkWidget *all_chats = NULL; GtkWidget *chat_notebook = NULL; + +static void destroy_prev_jc() +{ + GList *children, *curr; + GtkWidget *w; + if (!jc_vbox) + return; + + children = g_list_copy(gtk_container_children(GTK_CONTAINER(jc_vbox))); + for (curr = children; curr != NULL; curr = g_list_next(curr)) { + w = (GtkWidget *)curr->data; + gtk_container_remove(GTK_CONTAINER(jc_vbox), w); + } + g_list_free(children); +} + static void destroy_join_chat() { if (joinchat) @@ -69,23 +85,56 @@ static void do_join_chat() { - char *group; - - group = gtk_entry_get_text(GTK_ENTRY(entry)); - if (joinchat) { - serv_join_chat(joinchatgc, community + 4, group); + if (joinchatgc->prpl->draw_join_chat) + serv_join_chat(joinchatgc, 0, NULL); + else + serv_join_chat(joinchatgc, 0, gtk_entry_get_text(GTK_ENTRY(entry))); gtk_widget_destroy(joinchat); } joinchat = NULL; } +static void default_draw_join_chat(struct gaim_connection *gc, GtkWidget *fbox) { + GtkWidget *label; + GtkWidget *rowbox; + + if (!joinchat || !fbox) + return; + + rowbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); + + label = gtk_label_new(_("Join what group:")); + gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); + entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(rowbox), entry, TRUE, TRUE, 0); + + gtk_widget_show(label); + gtk_widget_show(entry); + gtk_widget_show(rowbox); +} + +static void rebuild_jc() +{ + if (!joinchatgc) + return; + + destroy_prev_jc(); + if (joinchatgc->prpl->draw_join_chat) + (*joinchatgc->prpl->draw_join_chat)(joinchatgc, jc_vbox); + else + default_draw_join_chat(joinchatgc, jc_vbox); +} + static void joinchat_choose(GtkWidget *w, struct gaim_connection *g) { + if (joinchatgc == g) + return; joinchatgc = g; + rebuild_jc(); } - static void create_joinchat_menu(GtkWidget *box) { GtkWidget *optmenu; @@ -120,7 +169,6 @@ gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0); } - void join_chat() { GtkWidget *mainbox; @@ -131,7 +179,6 @@ GtkWidget *join; GtkWidget *cancel; GtkWidget *label; - GtkWidget *opt; GSList *c = connections; struct gaim_connection *gc = NULL; @@ -169,18 +216,6 @@ gtk_container_set_border_width(GTK_CONTAINER(fbox), 5); gtk_container_add(GTK_CONTAINER(frame), fbox); - rowbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); - - label = gtk_label_new(_("Join what group:")); - gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); - - entry = gtk_entry_new(); - gtk_box_pack_start(GTK_BOX(rowbox), entry, TRUE, TRUE, 0); - gtk_signal_connect(GTK_OBJECT(entry), "activate", - GTK_SIGNAL_FUNC(do_join_chat), joinchat); - gtk_window_set_focus(GTK_WINDOW(joinchat), entry); - #ifndef NO_MULTI rowbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); @@ -189,24 +224,18 @@ gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); create_joinchat_menu(rowbox); + + { + GtkWidget *tmp = fbox; + fbox = gtk_vbox_new(FALSE, 5); + gtk_container_add(GTK_CONTAINER(tmp), fbox); + gtk_container_set_border_width(GTK_CONTAINER(fbox), 0); + jc_vbox = fbox; + } #else joinchatgc = connections->data; #endif - - rowbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); - - community = 0; - opt = gtk_radio_button_new_with_label(NULL, _("AIM Private Chats")); - gtk_box_pack_start(GTK_BOX(rowbox), opt, TRUE, TRUE, 0); - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); - gtk_signal_connect(GTK_OBJECT(opt), "clicked", set_option, &community); - gtk_widget_show(opt); - - opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(opt)), - _("AOL Community Chats")); - gtk_box_pack_start(GTK_BOX(rowbox), opt, TRUE, TRUE, 0); - + rebuild_jc(); /* buttons */ bbox = gtk_hbox_new(FALSE, 5); diff -r caa605e70917 -r c649b63382b7 src/oscar.c --- a/src/oscar.c Sat May 05 10:36:08 2001 +0000 +++ b/src/oscar.c Sat May 05 11:11:22 2001 +0000 @@ -57,6 +57,9 @@ int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_GETFILE | AIM_CAPS_IMIMAGE; +static GtkWidget *join_chat_spin; +static GtkWidget *join_chat_entry; + struct oscar_data { struct aim_session_t *sess; struct aim_conn_t *conn; @@ -2084,6 +2087,14 @@ static void oscar_join_chat(struct gaim_connection *g, int exchange, char *name) { struct oscar_data *odata = (struct oscar_data *)g->proto_data; struct aim_conn_t *cur = NULL; + if (!name) { + if (!join_chat_entry || !join_chat_spin) + return; + name = gtk_entry_get_text(GTK_ENTRY(join_chat_entry)); + exchange = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(join_chat_spin)); + if (!name || !strlen(name)) + return; + } debug_printf("Attempting to join chat room %s.\n", name); if ((cur = aim_getconn_type(odata->sess, AIM_CONN_TYPE_CHATNAV))) { debug_printf("chatnav exists, creating room\n"); @@ -2097,6 +2108,45 @@ } } +static void des_jc() +{ + join_chat_entry = NULL; + join_chat_spin = NULL; +} + +static void oscar_draw_join_chat(struct gaim_connection *gc, GtkWidget *fbox) { + GtkWidget *label; + GtkWidget *rowbox; + GtkObject *adjust; + + rowbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); + gtk_widget_show(rowbox); + + label = gtk_label_new(_("Join what group:")); + gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); + gtk_signal_connect(GTK_OBJECT(label), "destroy", GTK_SIGNAL_CONNECT(des_jc), NULL); + gtk_widget_show(label); + + join_chat_entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(rowbox), join_chat_entry, TRUE, TRUE, 0); + gtk_widget_show(join_chat_entry); + + rowbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); + gtk_widget_show(rowbox); + + label = gtk_label_new(_("Exchange:")); + gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + adjust = gtk_adjustment_new(4, 4, 20, 1, 10, 10); + join_chat_spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); + gtk_widget_set_usize(join_chat_spin, 50, -1); + gtk_box_pack_start(GTK_BOX(rowbox), join_chat_spin, FALSE, FALSE, 0); + gtk_widget_show(join_chat_spin); +} + static void oscar_chat_invite(struct gaim_connection *g, int id, char *message, char *name) { struct oscar_data *odata = (struct oscar_data *)g->proto_data; GSList *bcs = g->buddy_chats; @@ -2677,6 +2727,7 @@ ret->warn = oscar_warn; ret->accept_chat = NULL; /* oscar doesn't have accept, it just joins */ ret->join_chat = oscar_join_chat; + ret->draw_join_chat = oscar_draw_join_chat; ret->chat_invite = oscar_chat_invite; ret->chat_leave = oscar_chat_leave; ret->chat_whisper = NULL; diff -r caa605e70917 -r c649b63382b7 src/prpl.h --- a/src/prpl.h Sat May 05 10:36:08 2001 +0000 +++ b/src/prpl.h Sat May 05 11:11:22 2001 +0000 @@ -77,6 +77,7 @@ void (* user_opts)(GtkWidget *, struct aim_user *); void (* draw_new_user)(GtkWidget *); void (* do_new_user)(); + void (* draw_join_chat) (struct gaim_connection *, GtkWidget *); /* all the server-related functions */ void (* login) (struct aim_user *); diff -r caa605e70917 -r c649b63382b7 src/toc.c --- a/src/toc.c Sat May 05 10:36:08 2001 +0000 +++ b/src/toc.c Sat May 05 11:11:22 2001 +0000 @@ -119,6 +119,9 @@ #define USEROPT_SOCKSPORT 3 #define USEROPT_PROXYTYPE 4 +static GtkWidget *join_chat_spin; +static GtkWidget *join_chat_entry; + static void toc_callback(gpointer, gint, GdkInputCondition); static unsigned char *roast_password(char *); static void accept_file_dialog(struct ft_request *); @@ -829,6 +832,14 @@ static void toc_join_chat(struct gaim_connection *g, int exchange, char *name) { char buf[BUF_LONG]; + if (!name) { + if (!join_chat_entry || !join_chat_spin) + return; + name = gtk_entry_get_text(GTK_ENTRY(join_chat_entry)); + exchange = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(join_chat_spin)); + if (!name || !strlen(name)) + return; + } g_snprintf(buf, sizeof(buf) / 2, "toc_chat_join %d \"%s\"", exchange, name); sflap_send(g, buf, -1, TYPE_DATA); } @@ -912,6 +923,45 @@ serv_get_dir(gc, who); } +static void des_jc() +{ + join_chat_entry = NULL; + join_chat_spin = NULL; +} + +static void toc_draw_join_chat(struct gaim_connection *gc, GtkWidget *fbox) { + GtkWidget *label; + GtkWidget *rowbox; + GtkObject *adjust; + + rowbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); + gtk_widget_show(rowbox); + + label = gtk_label_new(_("Join what group:")); + gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); + gtk_signal_connect(GTK_OBJECT(label), "destroy", GTK_SIGNAL_CONNECT(des_jc), NULL); + gtk_widget_show(label); + + join_chat_entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(rowbox), join_chat_entry, TRUE, TRUE, 0); + gtk_widget_show(join_chat_entry); + + rowbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); + gtk_widget_show(rowbox); + + label = gtk_label_new(_("Community:")); + gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + adjust = gtk_adjustment_new(4, 4, 20, 1, 10, 10); + join_chat_spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); + gtk_widget_set_usize(join_chat_spin, 50, -1); + gtk_box_pack_start(GTK_BOX(rowbox), join_chat_spin, FALSE, FALSE, 0); + gtk_widget_show(join_chat_spin); +} + static void toc_buddy_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) { GtkWidget *button; @@ -1266,6 +1316,7 @@ ret->rem_deny = toc_rem_deny; ret->set_permit_deny = toc_set_permit_deny; ret->warn = toc_warn; + ret->draw_join_chat = toc_draw_join_chat; ret->accept_chat = toc_accept_chat; ret->join_chat = toc_join_chat; ret->chat_invite = toc_chat_invite;