comparison src/buddy_chat.c @ 1806:c649b63382b7

[gaim-migrate @ 1816] part one of nsanch's patch. i still need to look at what got changed with zephyr. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 05 May 2001 11:11:22 +0000
parents 00c753b86710
children ba8f463744c0
comparison
equal deleted inserted replaced
1805:caa605e70917 1806:c649b63382b7
43 static struct gaim_connection *joinchatgc; 43 static struct gaim_connection *joinchatgc;
44 static GtkWidget *entry; 44 static GtkWidget *entry;
45 static GtkWidget *invite; 45 static GtkWidget *invite;
46 static GtkWidget *inviteentry; 46 static GtkWidget *inviteentry;
47 static GtkWidget *invitemess; 47 static GtkWidget *invitemess;
48 static int community; 48 static GtkWidget *jc_vbox;
49 extern int state_lock; 49 extern int state_lock;
50 50
51 GList *chats = NULL; 51 GList *chats = NULL;
52 GtkWidget *all_chats = NULL; 52 GtkWidget *all_chats = NULL;
53 GtkWidget *chat_notebook = NULL; 53 GtkWidget *chat_notebook = NULL;
54 54
55
56 static void destroy_prev_jc()
57 {
58 GList *children, *curr;
59 GtkWidget *w;
60 if (!jc_vbox)
61 return;
62
63 children = g_list_copy(gtk_container_children(GTK_CONTAINER(jc_vbox)));
64 for (curr = children; curr != NULL; curr = g_list_next(curr)) {
65 w = (GtkWidget *)curr->data;
66 gtk_container_remove(GTK_CONTAINER(jc_vbox), w);
67 }
68 g_list_free(children);
69 }
70
55 static void destroy_join_chat() 71 static void destroy_join_chat()
56 { 72 {
57 if (joinchat) 73 if (joinchat)
58 gtk_widget_destroy(joinchat); 74 gtk_widget_destroy(joinchat);
59 joinchat = NULL; 75 joinchat = NULL;
67 } 83 }
68 84
69 85
70 static void do_join_chat() 86 static void do_join_chat()
71 { 87 {
72 char *group;
73
74 group = gtk_entry_get_text(GTK_ENTRY(entry));
75
76 if (joinchat) { 88 if (joinchat) {
77 serv_join_chat(joinchatgc, community + 4, group); 89 if (joinchatgc->prpl->draw_join_chat)
90 serv_join_chat(joinchatgc, 0, NULL);
91 else
92 serv_join_chat(joinchatgc, 0, gtk_entry_get_text(GTK_ENTRY(entry)));
78 gtk_widget_destroy(joinchat); 93 gtk_widget_destroy(joinchat);
79 } 94 }
80 joinchat = NULL; 95 joinchat = NULL;
81 } 96 }
82 97
98 static void default_draw_join_chat(struct gaim_connection *gc, GtkWidget *fbox) {
99 GtkWidget *label;
100 GtkWidget *rowbox;
101
102 if (!joinchat || !fbox)
103 return;
104
105 rowbox = gtk_hbox_new(FALSE, 5);
106 gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0);
107
108 label = gtk_label_new(_("Join what group:"));
109 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0);
110 entry = gtk_entry_new();
111 gtk_box_pack_start(GTK_BOX(rowbox), entry, TRUE, TRUE, 0);
112
113 gtk_widget_show(label);
114 gtk_widget_show(entry);
115 gtk_widget_show(rowbox);
116 }
117
118 static void rebuild_jc()
119 {
120 if (!joinchatgc)
121 return;
122
123 destroy_prev_jc();
124 if (joinchatgc->prpl->draw_join_chat)
125 (*joinchatgc->prpl->draw_join_chat)(joinchatgc, jc_vbox);
126 else
127 default_draw_join_chat(joinchatgc, jc_vbox);
128 }
129
83 static void joinchat_choose(GtkWidget *w, struct gaim_connection *g) 130 static void joinchat_choose(GtkWidget *w, struct gaim_connection *g)
84 { 131 {
132 if (joinchatgc == g)
133 return;
85 joinchatgc = g; 134 joinchatgc = g;
86 } 135 rebuild_jc();
87 136 }
88 137
89 static void create_joinchat_menu(GtkWidget *box) 138 static void create_joinchat_menu(GtkWidget *box)
90 { 139 {
91 GtkWidget *optmenu; 140 GtkWidget *optmenu;
92 GtkWidget *menu; 141 GtkWidget *menu;
118 167
119 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); 168 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
120 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0); 169 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0);
121 } 170 }
122 171
123
124 void join_chat() 172 void join_chat()
125 { 173 {
126 GtkWidget *mainbox; 174 GtkWidget *mainbox;
127 GtkWidget *frame; 175 GtkWidget *frame;
128 GtkWidget *fbox; 176 GtkWidget *fbox;
129 GtkWidget *rowbox; 177 GtkWidget *rowbox;
130 GtkWidget *bbox; 178 GtkWidget *bbox;
131 GtkWidget *join; 179 GtkWidget *join;
132 GtkWidget *cancel; 180 GtkWidget *cancel;
133 GtkWidget *label; 181 GtkWidget *label;
134 GtkWidget *opt;
135 GSList *c = connections; 182 GSList *c = connections;
136 struct gaim_connection *gc = NULL; 183 struct gaim_connection *gc = NULL;
137 184
138 while (c) { 185 while (c) {
139 gc = c->data; 186 gc = c->data;
167 214
168 fbox = gtk_vbox_new(FALSE, 5); 215 fbox = gtk_vbox_new(FALSE, 5);
169 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5); 216 gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
170 gtk_container_add(GTK_CONTAINER(frame), fbox); 217 gtk_container_add(GTK_CONTAINER(frame), fbox);
171 218
172 rowbox = gtk_hbox_new(FALSE, 5);
173 gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0);
174
175 label = gtk_label_new(_("Join what group:"));
176 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0);
177
178 entry = gtk_entry_new();
179 gtk_box_pack_start(GTK_BOX(rowbox), entry, TRUE, TRUE, 0);
180 gtk_signal_connect(GTK_OBJECT(entry), "activate",
181 GTK_SIGNAL_FUNC(do_join_chat), joinchat);
182 gtk_window_set_focus(GTK_WINDOW(joinchat), entry);
183
184 #ifndef NO_MULTI 219 #ifndef NO_MULTI
185 rowbox = gtk_hbox_new(FALSE, 5); 220 rowbox = gtk_hbox_new(FALSE, 5);
186 gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); 221 gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0);
187 222
188 label = gtk_label_new(_("Join Chat As:")); 223 label = gtk_label_new(_("Join Chat As:"));
189 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); 224 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0);
190 225
191 create_joinchat_menu(rowbox); 226 create_joinchat_menu(rowbox);
227
228 {
229 GtkWidget *tmp = fbox;
230 fbox = gtk_vbox_new(FALSE, 5);
231 gtk_container_add(GTK_CONTAINER(tmp), fbox);
232 gtk_container_set_border_width(GTK_CONTAINER(fbox), 0);
233 jc_vbox = fbox;
234 }
192 #else 235 #else
193 joinchatgc = connections->data; 236 joinchatgc = connections->data;
194 #endif 237 #endif
195 238 rebuild_jc();
196 rowbox = gtk_hbox_new(FALSE, 5);
197 gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0);
198
199 community = 0;
200 opt = gtk_radio_button_new_with_label(NULL, _("AIM Private Chats"));
201 gtk_box_pack_start(GTK_BOX(rowbox), opt, TRUE, TRUE, 0);
202 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE);
203 gtk_signal_connect(GTK_OBJECT(opt), "clicked", set_option, &community);
204 gtk_widget_show(opt);
205
206 opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(opt)),
207 _("AOL Community Chats"));
208 gtk_box_pack_start(GTK_BOX(rowbox), opt, TRUE, TRUE, 0);
209
210 /* buttons */ 239 /* buttons */
211 240
212 bbox = gtk_hbox_new(FALSE, 5); 241 bbox = gtk_hbox_new(FALSE, 5);
213 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0); 242 gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
214 243