Mercurial > pidgin.yaz
comparison src/aim.c @ 989:bd8eb3efe14e
[gaim-migrate @ 999]
putting the login window back the way it was, mostly
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 13 Oct 2000 20:21:38 +0000 |
parents | 9523b772e546 |
children | 3dbc2cd326e2 |
comparison
equal
deleted
inserted
replaced
988:9523b772e546 | 989:bd8eb3efe14e |
---|---|
51 #include <signal.h> | 51 #include <signal.h> |
52 #endif | 52 #endif |
53 #include "locale.h" | 53 #include "locale.h" |
54 #include "gtkticker.h" | 54 #include "gtkticker.h" |
55 | 55 |
56 static GtkWidget *name; | |
57 static GtkWidget *pass; | |
58 | |
56 GList *permit = NULL; | 59 GList *permit = NULL; |
57 GList *deny = NULL; | 60 GList *deny = NULL; |
58 GList *log_conversations = NULL; | 61 GList *log_conversations = NULL; |
59 GList *buddy_pounces = NULL; | 62 GList *buddy_pounces = NULL; |
60 GSList *away_messages = NULL; | 63 GSList *away_messages = NULL; |
141 | 144 |
142 return; | 145 return; |
143 } | 146 } |
144 | 147 |
145 | 148 |
149 static void dologin(GtkWidget *widget, GtkWidget *w) | |
150 { | |
151 struct aim_user *u; | |
152 char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry)); | |
153 char *password = gtk_entry_get_text(GTK_ENTRY(pass)); | |
154 | |
155 if (!strlen(username)) { | |
156 do_error_dialog(_("Please enter your logon"), _("Signon Error")); | |
157 return; | |
158 } | |
159 | |
160 if (!strlen(password)) { | |
161 do_error_dialog(_("Please enter your password"), _("Signon Error")); | |
162 return; | |
163 } | |
164 | |
165 u = find_user(username); | |
166 if (!u) { | |
167 /* FIXME : add user */ | |
168 } | |
169 g_snprintf(u->password, sizeof u->password, "%s", password); | |
170 save_prefs(); | |
171 serv_login(u); | |
172 } | |
173 | |
174 | |
175 static void doenter(GtkWidget *widget, GtkWidget *w) | |
176 { | |
177 if (widget == name) { | |
178 gtk_entry_set_text(GTK_ENTRY(pass), ""); | |
179 gtk_entry_select_region(GTK_ENTRY(GTK_COMBO(name)->entry), 0, 0); | |
180 gtk_widget_grab_focus(pass); | |
181 } else if (widget == pass) { | |
182 dologin(widget, w); | |
183 } | |
184 } | |
185 | |
186 | |
187 static void combo_changed(GtkWidget *w, GtkWidget *combo) | |
188 { | |
189 char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); | |
190 struct aim_user *u; | |
191 | |
192 u = find_user(txt); | |
193 | |
194 if (u && u->options & OPT_USR_REM_PASS) { | |
195 gtk_entry_set_text(GTK_ENTRY(pass), u->password); | |
196 } else { | |
197 gtk_entry_set_text(GTK_ENTRY(pass), ""); | |
198 } | |
199 } | |
200 | |
201 | |
202 static GList *combo_user_names() | |
203 { | |
204 GList *usr = aim_users; | |
205 GList *tmp = NULL; | |
206 struct aim_user *u; | |
207 | |
208 if (!usr) | |
209 return g_list_append(NULL, "<unknown>"); | |
210 | |
211 while (usr) { | |
212 u = (struct aim_user *)usr->data; | |
213 tmp = g_list_append(tmp, g_strdup(u->username)); | |
214 usr = usr->next; | |
215 } | |
216 | |
217 return tmp; | |
218 } | |
146 | 219 |
147 | 220 |
148 void show_login() | 221 void show_login() |
149 { | 222 { |
150 GtkWidget *options; | 223 GtkWidget *options; |
151 #ifdef GAIM_PLUGINS | 224 #ifdef GAIM_PLUGINS |
152 GtkWidget *plugs; | 225 GtkWidget *plugs; |
153 #endif | 226 #endif |
154 GtkWidget *accts; | 227 GtkWidget *accts; |
228 GtkWidget *signon; | |
155 GtkWidget *cancel; | 229 GtkWidget *cancel; |
156 GtkWidget *reg; | 230 GtkWidget *reg; |
157 GtkWidget *bbox; | 231 GtkWidget *bbox; |
158 GtkWidget *hbox; | 232 GtkWidget *hbox; |
159 GtkWidget *sbox; | 233 GtkWidget *sbox; |
234 GtkWidget *label; | |
160 GtkWidget *table; | 235 GtkWidget *table; |
161 | 236 |
162 GtkWidget *pmw; | 237 GtkWidget *pmw; |
163 GdkPixmap *pm; | 238 GdkPixmap *pm; |
164 GtkStyle *style; | 239 GtkStyle *style; |
174 gtk_window_set_wmclass(GTK_WINDOW(mainwindow), "login", | 249 gtk_window_set_wmclass(GTK_WINDOW(mainwindow), "login", |
175 "Gaim"); | 250 "Gaim"); |
176 /* Disallow resizing */ | 251 /* Disallow resizing */ |
177 gtk_window_set_policy(GTK_WINDOW(mainwindow), FALSE, FALSE, TRUE); | 252 gtk_window_set_policy(GTK_WINDOW(mainwindow), FALSE, FALSE, TRUE); |
178 gtk_widget_realize(mainwindow); | 253 gtk_widget_realize(mainwindow); |
254 | |
255 signon = gtk_button_new_with_label(_("Signon")); | |
179 accts = gtk_button_new_with_label(_("Accounts")); | 256 accts = gtk_button_new_with_label(_("Accounts")); |
180 cancel = gtk_button_new_with_label(_("Cancel")); | 257 cancel = gtk_button_new_with_label(_("Cancel")); |
181 reg = gtk_button_new_with_label(_("Register")); | 258 reg = gtk_button_new_with_label(_("Register")); |
182 options = gtk_button_new_with_label(_("Options")); | 259 options = gtk_button_new_with_label(_("Options")); |
183 #ifdef GAIM_PLUGINS | 260 #ifdef GAIM_PLUGINS |
184 plugs = gtk_button_new_with_label(_("Plugins")); | 261 plugs = gtk_button_new_with_label(_("Plugins")); |
185 #endif | 262 #endif |
186 table = gtk_table_new(8, 2, FALSE); | 263 table = gtk_table_new(8, 2, FALSE); |
264 name = gtk_combo_new(); | |
265 pass = gtk_entry_new(); | |
266 | |
267 gtk_combo_set_popdown_strings(GTK_COMBO(name), combo_user_names()); | |
187 | 268 |
188 if (display_options & OPT_DISP_COOL_LOOK) | 269 if (display_options & OPT_DISP_COOL_LOOK) |
189 { | 270 { |
271 gtk_button_set_relief(GTK_BUTTON(signon), GTK_RELIEF_NONE); | |
190 gtk_button_set_relief(GTK_BUTTON(accts), GTK_RELIEF_NONE); | 272 gtk_button_set_relief(GTK_BUTTON(accts), GTK_RELIEF_NONE); |
191 gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE); | 273 gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE); |
192 gtk_button_set_relief(GTK_BUTTON(reg), GTK_RELIEF_NONE); | 274 gtk_button_set_relief(GTK_BUTTON(reg), GTK_RELIEF_NONE); |
193 gtk_button_set_relief(GTK_BUTTON(options), GTK_RELIEF_NONE); | 275 gtk_button_set_relief(GTK_BUTTON(options), GTK_RELIEF_NONE); |
194 #ifdef GAIM_PLUGINS | 276 #ifdef GAIM_PLUGINS |
196 #endif | 278 #endif |
197 } | 279 } |
198 | 280 |
199 /* Make the buttons do stuff */ | 281 /* Make the buttons do stuff */ |
200 /* Clicking the button initiates a login */ | 282 /* Clicking the button initiates a login */ |
283 gtk_signal_connect(GTK_OBJECT(signon), "clicked", | |
284 GTK_SIGNAL_FUNC(dologin), mainwindow); | |
201 gtk_signal_connect(GTK_OBJECT(accts), "clicked", | 285 gtk_signal_connect(GTK_OBJECT(accts), "clicked", |
202 GTK_SIGNAL_FUNC(account_editor), mainwindow); | 286 GTK_SIGNAL_FUNC(account_editor), mainwindow); |
203 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | 287 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", |
204 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); | 288 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); |
205 /* Allow user to change prefs before logging in */ | 289 /* Allow user to change prefs before logging in */ |
212 #endif | 296 #endif |
213 | 297 |
214 /* Register opens the right URL */ | 298 /* Register opens the right URL */ |
215 gtk_signal_connect(GTK_OBJECT(reg), "clicked", | 299 gtk_signal_connect(GTK_OBJECT(reg), "clicked", |
216 GTK_SIGNAL_FUNC(open_url), "http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no"); | 300 GTK_SIGNAL_FUNC(open_url), "http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no"); |
301 /* Enter in the username clears the password and sets | |
302 the pointer in the password field */ | |
303 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "activate", | |
304 GTK_SIGNAL_FUNC(doenter), mainwindow); | |
305 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "changed", | |
306 GTK_SIGNAL_FUNC(combo_changed), name); | |
307 | |
308 gtk_signal_connect(GTK_OBJECT(pass), "activate", | |
309 GTK_SIGNAL_FUNC(doenter), mainwindow); | |
217 gtk_signal_connect(GTK_OBJECT(mainwindow), "delete_event", | 310 gtk_signal_connect(GTK_OBJECT(mainwindow), "delete_event", |
218 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); | 311 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); |
219 /* Homogenous spacing, 10 padding */ | 312 /* Homogenous spacing, 10 padding */ |
220 bbox = gtk_hbox_new(TRUE, 10); | 313 bbox = gtk_hbox_new(TRUE, 10); |
221 hbox = gtk_hbox_new(TRUE, 10); | 314 hbox = gtk_hbox_new(TRUE, 10); |
222 sbox = gtk_vbox_new(TRUE, 5); | 315 sbox = gtk_vbox_new(TRUE, 5); |
223 | 316 |
224 gtk_box_pack_start(GTK_BOX(bbox), reg, TRUE, TRUE, 0); | |
225 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | 317 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); |
226 | 318 gtk_box_pack_start(GTK_BOX(bbox), accts, TRUE, TRUE, 0); |
319 gtk_box_pack_start(GTK_BOX(bbox), signon, TRUE, TRUE, 0); | |
320 | |
321 gtk_box_pack_start(GTK_BOX(hbox), reg, TRUE, TRUE, 0); | |
227 gtk_box_pack_start(GTK_BOX(hbox), options, TRUE, TRUE, 0); | 322 gtk_box_pack_start(GTK_BOX(hbox), options, TRUE, TRUE, 0); |
228 #ifdef GAIM_PLUGINS | 323 #ifdef GAIM_PLUGINS |
229 gtk_box_pack_start(GTK_BOX(hbox), plugs, TRUE, TRUE, 0); | 324 gtk_box_pack_start(GTK_BOX(hbox), plugs, TRUE, TRUE, 0); |
230 #endif | 325 #endif |
231 | 326 |
327 gtk_box_pack_start(GTK_BOX(sbox), bbox, TRUE, TRUE, 0); | |
232 gtk_box_pack_start(GTK_BOX(sbox), hbox, TRUE, TRUE, 0); | 328 gtk_box_pack_start(GTK_BOX(sbox), hbox, TRUE, TRUE, 0); |
233 gtk_box_pack_start(GTK_BOX(sbox), bbox, TRUE, TRUE, 0); | |
234 | 329 |
235 /* Labels for selectors and text boxes */ | 330 /* Labels for selectors and text boxes */ |
331 label = gtk_label_new(_("Screen Name: ")); | |
332 gtk_table_attach(GTK_TABLE(table), label, 0,1,2,3,0,0, 5, 5); | |
333 gtk_widget_show(label); | |
334 label = gtk_label_new(_("Password: ")); | |
335 gtk_table_attach(GTK_TABLE(table), label, 0,1,3,4,0,0, 5, 5); | |
336 gtk_widget_show(label); | |
236 | 337 |
237 gtk_widget_show(options); | 338 gtk_widget_show(options); |
238 #ifdef GAIM_PLUGINS | 339 #ifdef GAIM_PLUGINS |
239 gtk_widget_show(plugs); | 340 gtk_widget_show(plugs); |
240 #endif | 341 #endif |
342 | |
343 /* Adjust sizes of inputs */ | |
344 gtk_widget_set_usize(name,100,0); | |
345 gtk_widget_set_usize(pass,100,0); | |
346 | |
241 | 347 |
242 /* Attach the buttons at the bottom */ | 348 /* Attach the buttons at the bottom */ |
349 gtk_widget_show(signon); | |
243 gtk_widget_show(cancel); | 350 gtk_widget_show(cancel); |
244 gtk_widget_show(reg); | 351 gtk_widget_show(reg); |
245 gtk_widget_show(accts); | 352 gtk_widget_show(accts); |
246 gtk_widget_show(bbox); | 353 gtk_widget_show(bbox); |
247 gtk_widget_show(hbox); | 354 gtk_widget_show(hbox); |
248 gtk_widget_show(sbox); | 355 gtk_widget_show(sbox); |
249 gtk_table_attach(GTK_TABLE(table), accts, 0,2,6,7,0,0, 5, 5); | |
250 gtk_table_attach(GTK_TABLE(table), sbox, 0,2,7,8,0,0, 5, 5); | 356 gtk_table_attach(GTK_TABLE(table), sbox, 0,2,7,8,0,0, 5, 5); |
251 | 357 |
252 /* Text fields */ | 358 /* Text fields */ |
359 | |
360 gtk_table_attach(GTK_TABLE(table),name,1,2,2,3,0,0,5,5); | |
361 gtk_widget_show(name); | |
362 gtk_table_attach(GTK_TABLE(table),pass,1,2,3,4,0,0,5,5); | |
363 gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); | |
364 gtk_widget_show(pass); | |
253 | 365 |
254 gtk_container_border_width(GTK_CONTAINER(sbox), 10); | 366 gtk_container_border_width(GTK_CONTAINER(sbox), 10); |
255 | 367 |
256 gtk_container_add(GTK_CONTAINER(mainwindow),table ); | 368 gtk_container_add(GTK_CONTAINER(mainwindow),table ); |
257 | 369 |
258 gtk_widget_show(table); | 370 gtk_widget_show(table); |
259 gtk_window_set_title(GTK_WINDOW(mainwindow),_("Gaim - Login")); | 371 gtk_window_set_title(GTK_WINDOW(mainwindow),_("Gaim - Login")); |
260 | 372 |
373 | |
374 if (aim_users) { | |
375 struct aim_user *c = (struct aim_user *)aim_users->data; | |
376 sprintf(debug_buff, "First user is %s\n", c->username); | |
377 if (c->options & OPT_USR_REM_PASS) { | |
378 combo_changed(NULL, name); | |
379 gtk_widget_grab_focus(signon); | |
380 } else { | |
381 gtk_widget_grab_focus(pass); | |
382 } | |
383 } else { | |
384 gtk_widget_grab_focus(name); | |
385 } | |
261 | 386 |
262 gtk_widget_realize(mainwindow); | 387 gtk_widget_realize(mainwindow); |
263 | 388 |
264 /* Logo at the top */ | 389 /* Logo at the top */ |
265 style = gtk_widget_get_style(mainwindow); | 390 style = gtk_widget_get_style(mainwindow); |