Mercurial > pidgin.yaz
comparison src/main.c @ 8136:fab67640b59f
[gaim-migrate @ 8841]
the login screen doesn't suck as much anymore!
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sat, 17 Jan 2004 22:02:14 +0000 |
parents | d60272410bd5 |
children | 1d68a254237b |
comparison
equal
deleted
inserted
replaced
8135:8f4ce853e685 | 8136:fab67640b59f |
---|---|
143 } | 143 } |
144 | 144 |
145 static void dologin(GtkWidget *widget, GtkWidget *w) | 145 static void dologin(GtkWidget *widget, GtkWidget *w) |
146 { | 146 { |
147 GaimAccount *account; | 147 GaimAccount *account; |
148 const char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry)); | 148 GtkWidget *item; |
149 const char *password = gtk_entry_get_text(GTK_ENTRY(pass)); | 149 const char *password = gtk_entry_get_text(GTK_ENTRY(pass)); |
150 | 150 |
151 if (*username == '\0') { | 151 item = gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(name)))); |
152 gaim_notify_error(NULL, NULL, _("Please enter your login."), NULL); | 152 account = g_object_get_data(G_OBJECT(item), "account"); |
153 | |
154 if (!account) { | |
155 gaim_notify_error(NULL, NULL, _("Please create an account."), NULL); | |
153 return; | 156 return; |
154 } | |
155 | |
156 /* if there is more than one user of the same name, then fuck | |
157 * them, they just have to use the account editor to sign in | |
158 * the second one */ | |
159 | |
160 account = gaim_accounts_find(username, NULL); | |
161 if (!account) { | |
162 account = gaim_account_new(username, GAIM_PROTO_DEFAULT); | |
163 gaim_account_set_remember_password(account, FALSE); | |
164 gaim_accounts_add(account); | |
165 } | 157 } |
166 | 158 |
167 gaim_account_set_password(account, (*password != '\0') ? password : NULL); | 159 gaim_account_set_password(account, (*password != '\0') ? password : NULL); |
168 | 160 |
169 gaim_account_connect(account); | 161 gaim_account_connect(account); |
200 | 192 |
201 return retval; | 193 return retval; |
202 } | 194 } |
203 | 195 |
204 | 196 |
205 static void doenter(GtkWidget *widget, GtkWidget *w) | 197 static void combo_changed(GtkWidget *menu, GaimAccount *account, gpointer data) |
206 { | 198 { |
207 gtk_entry_set_text(GTK_ENTRY(pass), ""); | |
208 gtk_editable_select_region(GTK_EDITABLE(GTK_COMBO(name)->entry), 0, 0); | |
209 gtk_widget_grab_focus(pass); | |
210 } | |
211 | |
212 | |
213 static void combo_changed(GtkWidget *w, GtkWidget *combo) | |
214 { | |
215 const char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); | |
216 GaimAccount *account; | |
217 | |
218 account = gaim_accounts_find(txt, NULL); | |
219 | |
220 if (account && gaim_account_get_remember_password(account)) { | 199 if (account && gaim_account_get_remember_password(account)) { |
221 gtk_entry_set_text(GTK_ENTRY(pass), account->password); | 200 gtk_entry_set_text(GTK_ENTRY(pass), account->password); |
222 } else { | 201 } else { |
223 gtk_entry_set_text(GTK_ENTRY(pass), ""); | 202 gtk_entry_set_text(GTK_ENTRY(pass), ""); |
224 } | 203 } |
225 } | 204 } |
226 | 205 |
227 | |
228 static GList *combo_user_names() | |
229 { | |
230 GList *accts = gaim_accounts_get_all(); | |
231 GList *tmp = NULL; | |
232 GaimAccount *account; | |
233 | |
234 if (!accts) | |
235 return g_list_append(NULL, _("<New User>")); | |
236 | |
237 while (accts) { | |
238 account = (GaimAccount *)accts->data; | |
239 tmp = g_list_append(tmp, account->username); | |
240 accts = accts->next; | |
241 } | |
242 | |
243 return tmp; | |
244 } | |
245 | 206 |
246 static void login_window_closed(GtkWidget *w, GdkEvent *ev, gpointer d) | 207 static void login_window_closed(GtkWidget *w, GdkEvent *ev, gpointer d) |
247 { | 208 { |
248 if(docklet_count) { | 209 if(docklet_count) { |
249 #ifdef _WIN32 | 210 #ifdef _WIN32 |
260 GtkWidget *vbox; | 221 GtkWidget *vbox; |
261 GtkWidget *button; | 222 GtkWidget *button; |
262 GtkWidget *hbox; | 223 GtkWidget *hbox; |
263 GtkWidget *label; | 224 GtkWidget *label; |
264 GtkWidget *vbox2; | 225 GtkWidget *vbox2; |
265 GList *tmp; | |
266 | 226 |
267 /* Do we already have a main window opened? If so, bring it back, baby... ribs... yeah */ | 227 /* Do we already have a main window opened? If so, bring it back, baby... ribs... yeah */ |
268 if (mainwindow) { | 228 if (mainwindow) { |
269 gtk_window_present(GTK_WINDOW(mainwindow)); | 229 gtk_window_present(GTK_WINDOW(mainwindow)); |
270 return; | 230 return; |
288 gtk_box_pack_start(GTK_BOX(vbox), image, FALSE, FALSE, 0); | 248 gtk_box_pack_start(GTK_BOX(vbox), image, FALSE, FALSE, 0); |
289 | 249 |
290 vbox2 = gtk_vbox_new(FALSE, 0); | 250 vbox2 = gtk_vbox_new(FALSE, 0); |
291 gtk_container_set_border_width(GTK_CONTAINER(vbox2), 5); | 251 gtk_container_set_border_width(GTK_CONTAINER(vbox2), 5); |
292 | 252 |
293 label = gtk_label_new(_("Screen Name:")); | 253 /* why isn't there a gtk_label_new_with_markup? */ |
254 label = gtk_label_new(NULL); | |
255 gtk_label_set_markup(GTK_LABEL(label), _("<b>Screen Name:</b>")); | |
294 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | 256 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
295 gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0); | 257 gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0); |
296 | 258 |
297 name = gtk_combo_new(); | 259 name = gaim_gtk_account_option_menu_new(NULL, TRUE, G_CALLBACK(combo_changed), NULL, NULL); |
298 tmp = combo_user_names(); | 260 |
299 gtk_combo_set_popdown_strings(GTK_COMBO(name), tmp); | |
300 g_list_free(tmp); | |
301 g_signal_connect(G_OBJECT(GTK_COMBO(name)->entry), "activate", | |
302 G_CALLBACK(doenter), mainwindow); | |
303 g_signal_connect(G_OBJECT(GTK_COMBO(name)->entry), "changed", | |
304 G_CALLBACK(combo_changed), name); | |
305 gtk_box_pack_start(GTK_BOX(vbox2), name, FALSE, TRUE, 0); | 261 gtk_box_pack_start(GTK_BOX(vbox2), name, FALSE, TRUE, 0); |
306 gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, TRUE, 0); | 262 gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, TRUE, 0); |
307 | 263 |
308 vbox2 = gtk_vbox_new(FALSE, 0); | 264 vbox2 = gtk_vbox_new(FALSE, 0); |
309 gtk_container_set_border_width(GTK_CONTAINER(vbox2), 5); | 265 gtk_container_set_border_width(GTK_CONTAINER(vbox2), 5); |
310 | 266 |
311 label = gtk_label_new(_("Password:")); | 267 label = gtk_label_new(NULL); |
268 gtk_label_set_markup(GTK_LABEL(label), _("<b>Password:</b>")); | |
312 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | 269 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
313 gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0); | 270 gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0); |
314 | 271 |
315 pass = gtk_entry_new(); | 272 pass = gtk_entry_new(); |
316 gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); | 273 gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); |
346 /* Now grab the focus that we need */ | 303 /* Now grab the focus that we need */ |
347 if (gaim_accounts_get_all()) { | 304 if (gaim_accounts_get_all()) { |
348 GaimAccount *account = gaim_accounts_get_all()->data; | 305 GaimAccount *account = gaim_accounts_get_all()->data; |
349 | 306 |
350 if (gaim_account_get_remember_password(account)) { | 307 if (gaim_account_get_remember_password(account)) { |
351 combo_changed(NULL, name); | 308 combo_changed(NULL, account, NULL); |
352 gtk_widget_grab_focus(button); | 309 gtk_widget_grab_focus(button); |
353 } else { | 310 } else { |
354 gtk_widget_grab_focus(pass); | 311 gtk_widget_grab_focus(pass); |
355 } | 312 } |
356 } else { | 313 } else { |
357 gtk_widget_grab_focus(name); | 314 gaim_gtk_accounts_window_show(); |
315 gtk_widget_grab_focus(button); | |
358 } | 316 } |
359 | 317 |
360 /* And raise the curtain! */ | 318 /* And raise the curtain! */ |
361 gtk_widget_show_all(mainwindow); | 319 gtk_widget_show_all(mainwindow); |
362 | 320 |