| 284 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(treeview), TRUE); |
303 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(treeview), TRUE); |
| 285 gtk_widget_show(win); |
304 gtk_widget_show(win); |
| 286 return win; |
305 return win; |
| 287 } |
306 } |
| 288 |
307 |
| 289 static void delmod(GtkWidget *w, struct mod_user *u) |
308 static void delmod(GtkWidget *w, struct mod_account *ma) |
| 290 { |
309 { |
| 291 mod_users = g_slist_remove(mod_users, u); |
310 mod_accounts = g_slist_remove(mod_accounts, ma); |
| 292 g_free(u); |
311 g_free(ma); |
| 293 } |
312 } |
| 294 |
313 |
| 295 static void mod_opt(GtkWidget *b, struct mod_usr_opt *m) |
314 static void mod_opt(GtkWidget *b, struct mod_account_opt *mao) |
| 296 { |
315 { |
| 297 m->user->options = m->user->options ^ m->opt; |
316 mao->ma->options = mao->ma->options ^ mao->opt; |
| 298 } |
317 } |
| 299 |
318 |
| 300 static void free_muo(GtkWidget *b, struct mod_usr_opt *m) |
319 static void free_mao(GtkWidget *b, struct mod_account_opt *mao) |
| 301 { |
320 { |
| 302 g_free(m); |
321 g_free(mao); |
| 303 } |
322 } |
| 304 |
323 |
| 305 static GtkWidget *acct_button(const char *text, struct mod_user *u, int option, GtkWidget *box) |
324 static GtkWidget *acct_button(const char *text, struct mod_account *ma, int option, GtkWidget *box) |
| 306 { |
325 { |
| 307 GtkWidget *button; |
326 GtkWidget *button; |
| 308 struct mod_usr_opt *muo = g_new0(struct mod_usr_opt, 1); |
327 struct mod_account_opt *mao = g_new0(struct mod_account_opt, 1); |
| 309 button = gtk_check_button_new_with_label(text); |
328 button = gtk_check_button_new_with_label(text); |
| 310 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (u->options & option)); |
329 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (ma->options & option)); |
| 311 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); |
330 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); |
| 312 muo->user = u; |
331 mao->ma = ma; |
| 313 muo->opt = option; |
332 mao->opt = option; |
| 314 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(mod_opt), muo); |
333 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(mod_opt), mao); |
| 315 g_signal_connect(GTK_OBJECT(button), "destroy", G_CALLBACK(free_muo), muo); |
334 g_signal_connect(GTK_OBJECT(button), "destroy", G_CALLBACK(free_mao), mao); |
| 316 gtk_widget_show(button); |
335 gtk_widget_show(button); |
| 317 return button; |
336 return button; |
| 318 } |
337 } |
| 319 |
338 |
| 320 static void ok_mod(GtkWidget *w, struct mod_user *u) |
339 static void ok_mod(GtkWidget *w, struct mod_account *ma) |
| 321 { |
340 { |
| 322 GList *tmp; |
341 GList *tmp; |
| 323 const char *txt; |
342 const char *txt; |
| 324 struct aim_user *a; |
343 struct gaim_account *a; |
| 325 struct prpl *p; |
344 struct prpl *p; |
| 326 GtkTreeIter iter; |
345 GtkTreeIter iter; |
| 327 |
346 |
| 328 if (!u->user) { |
347 if (!ma->account) { |
| 329 txt = gtk_entry_get_text(GTK_ENTRY(u->name)); |
348 txt = gtk_entry_get_text(GTK_ENTRY(ma->name)); |
| 330 u->user = new_user(txt, u->protocol, u->options); |
349 ma->account = gaim_account_new(txt, ma->protocol, ma->options); |
| 331 } |
350 } |
| 332 a = u->user; |
351 a = ma->account; |
| 333 |
352 |
| 334 a->options = u->options; |
353 a->options = ma->options; |
| 335 a->protocol = u->protocol; |
354 a->protocol = ma->protocol; |
| 336 txt = gtk_entry_get_text(GTK_ENTRY(u->name)); |
355 txt = gtk_entry_get_text(GTK_ENTRY(ma->name)); |
| 337 g_snprintf(a->username, sizeof(a->username), "%s", txt); |
356 g_snprintf(a->username, sizeof(a->username), "%s", txt); |
| 338 txt = gtk_entry_get_text(GTK_ENTRY(u->alias)); |
357 txt = gtk_entry_get_text(GTK_ENTRY(ma->alias)); |
| 339 g_snprintf(a->alias, sizeof(a->alias), "%s", txt); |
358 g_snprintf(a->alias, sizeof(a->alias), "%s", txt); |
| 340 txt = gtk_entry_get_text(GTK_ENTRY(u->pass)); |
359 txt = gtk_entry_get_text(GTK_ENTRY(ma->pass)); |
| 341 if (a->options & OPT_USR_REM_PASS) |
360 if (a->options & OPT_ACCT_REM_PASS) |
| 342 g_snprintf(a->password, sizeof(a->password), "%s", txt); |
361 g_snprintf(a->password, sizeof(a->password), "%s", txt); |
| 343 else |
362 else |
| 344 a->password[0] = '\0'; |
363 a->password[0] = '\0'; |
| 345 |
364 |
| 346 if (get_iter_from_data(GTK_TREE_VIEW(treeview), a, &iter)) { |
365 if (get_iter_from_data(GTK_TREE_VIEW(treeview), a, &iter)) { |
| 347 gtk_list_store_set(model, &iter, |
366 gtk_list_store_set(model, &iter, |
| 348 COLUMN_SCREENNAME, a->username, |
367 COLUMN_SCREENNAME, a->username, |
| 349 COLUMN_AUTOLOGIN, (a->options & OPT_USR_AUTO), |
368 COLUMN_AUTOLOGIN, (a->options & OPT_ACCT_AUTO), |
| 350 COLUMN_PROTOCOL, proto_name(a->protocol), |
369 COLUMN_PROTOCOL, proto_name(a->protocol), |
| 351 -1); |
370 -1); |
| 352 } |
371 } |
| 353 |
372 |
| 354 #if 0 |
373 #if 0 |
| 355 i = gtk_clist_find_row_from_data(GTK_CLIST(list), a); |
374 i = gtk_clist_find_row_from_data(GTK_CLIST(list), a); |
| 356 gtk_clist_set_text(GTK_CLIST(list), i, 0, a->username); |
375 gtk_clist_set_text(GTK_CLIST(list), i, 0, a->username); |
| 357 gtk_clist_set_text(GTK_CLIST(list), i, 2, |
376 gtk_clist_set_text(GTK_CLIST(list), i, 2, |
| 358 (a->options & OPT_USR_AUTO) ? "True" : "False"); |
377 (a->options & OPT_ACCT_AUTO) ? "True" : "False"); |
| 359 gtk_clist_set_text(GTK_CLIST(list), i, 3, proto_name(a->protocol)); |
378 gtk_clist_set_text(GTK_CLIST(list), i, 3, proto_name(a->protocol)); |
| 360 #endif |
379 #endif |
| 361 |
380 |
| 362 tmp = u->opt_entries; |
381 tmp = ma->opt_entries; |
| 363 while (tmp) { |
382 while (tmp) { |
| 364 GtkEntry *entry = tmp->data; |
383 GtkEntry *entry = tmp->data; |
| 365 int pos = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); |
384 int pos = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); |
| 366 g_snprintf(a->proto_opt[pos], sizeof(a->proto_opt[pos]), "%s", |
385 g_snprintf(a->proto_opt[pos], sizeof(a->proto_opt[pos]), "%s", |
| 367 gtk_entry_get_text(entry)); |
386 gtk_entry_get_text(entry)); |
| 368 tmp = tmp->next; |
387 tmp = tmp->next; |
| 369 } |
388 } |
| 370 if (u->opt_entries) |
389 if (ma->opt_entries) |
| 371 g_list_free(u->opt_entries); |
390 g_list_free(ma->opt_entries); |
| 372 u->opt_entries = NULL; |
391 ma->opt_entries = NULL; |
| 373 |
392 |
| 374 g_snprintf(a->iconfile, sizeof(a->iconfile), "%s", u->iconfile); |
393 g_snprintf(a->iconfile, sizeof(a->iconfile), "%s", ma->iconfile); |
| 375 if (u->icondlg) |
394 if (ma->icondlg) |
| 376 gtk_widget_destroy(u->icondlg); |
395 gtk_widget_destroy(ma->icondlg); |
| 377 u->icondlg = NULL; |
396 ma->icondlg = NULL; |
| 378 |
397 |
| 379 /* |
398 /* |
| 380 * See if user registration is supported/required |
399 * See if user registration is supported/required |
| 381 */ |
400 */ |
| 382 if((p = find_prpl(u->protocol)) == NULL) { |
401 if((p = find_prpl(ma->protocol)) == NULL) { |
| 383 /* TBD: error dialog here! (This should never happen, you know...) */ |
402 /* TBD: error dialog here! (This should never happen, you know...) */ |
| 384 fprintf(stderr, "dbg: couldn't find protocol for protocol number %d!\n", u->protocol); |
403 fprintf(stderr, "dbg: couldn't find protocol for protocol number %d!\n", ma->protocol); |
| 385 fflush(stderr); |
404 fflush(stderr); |
| 386 } else { |
405 } else { |
| 387 if(p->register_user != NULL && |
406 if(p->register_user != NULL && |
| 388 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(u->register_user)) == TRUE) { |
407 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ma->register_user)) == TRUE) { |
| 389 ref_protocol(p); |
408 ref_protocol(p); |
| 390 p->register_user(a); |
409 p->register_user(a); |
| 391 /* we don't unref the protocol because register user has callbacks |
410 /* we don't unref the protocol because register user has callbacks |
| 392 * that need to get called first, then they will unref the protocol |
411 * that need to get called first, then they will unref the protocol |
| 393 * appropriately */ |
412 * appropriately */ |
| 394 } |
413 } |
| 395 } |
414 } |
| 396 |
415 |
| 397 save_prefs(); |
416 save_prefs(); |
| 398 |
417 |
| 399 gtk_widget_destroy(u->mod); |
418 gtk_widget_destroy(ma->mod); |
| 400 } |
419 } |
| 401 |
420 |
| 402 static void cancel_mod(GtkWidget *w, struct mod_user *u) |
421 static void cancel_mod(GtkWidget *w, struct mod_account *ma) |
| 403 { |
422 { |
| 404 if (u->opt_entries) |
423 if (ma->opt_entries) |
| 405 g_list_free(u->opt_entries); |
424 g_list_free(ma->opt_entries); |
| 406 u->opt_entries = NULL; |
425 ma->opt_entries = NULL; |
| 407 if (u->icondlg) |
426 if (ma->icondlg) |
| 408 gtk_widget_destroy(u->icondlg); |
427 gtk_widget_destroy(ma->icondlg); |
| 409 u->icondlg = NULL; |
428 ma->icondlg = NULL; |
| 410 gtk_widget_destroy(u->mod); |
429 gtk_widget_destroy(ma->mod); |
| 411 } |
430 } |
| 412 |
431 |
| 413 static void set_prot(GtkWidget *opt, int proto) |
432 static void set_prot(GtkWidget *opt, int proto) |
| 414 { |
433 { |
| 415 struct mod_user *u = gtk_object_get_user_data(GTK_OBJECT(opt)); |
434 struct mod_account *ma = gtk_object_get_user_data(GTK_OBJECT(opt)); |
| 416 struct prpl *p, *q; |
435 struct prpl *p, *q; |
| 417 q = find_prpl(proto); |
436 q = find_prpl(proto); |
| 418 if (u->protocol != proto) { |
437 if (ma->protocol != proto) { |
| 419 int i; |
438 int i; |
| 420 for (i = 0; i < 7; i++) |
439 for (i = 0; i < 7; i++) |
| 421 u->proto_opt[i][0] = '\0'; |
440 ma->proto_opt[i][0] = '\0'; |
| 422 p = find_prpl(u->protocol); |
441 p = find_prpl(ma->protocol); |
| 423 |
442 |
| 424 if (!(p->options & OPT_PROTO_NO_PASSWORD) && (q->options & OPT_PROTO_NO_PASSWORD)) { |
443 if (!(p->options & OPT_PROTO_NO_PASSWORD) && (q->options & OPT_PROTO_NO_PASSWORD)) { |
| 425 gtk_widget_hide(u->pwdbox); |
444 gtk_widget_hide(ma->pwdbox); |
| 426 gtk_widget_hide(u->rempass); |
445 gtk_widget_hide(ma->rempass); |
| 427 } else if ((p->options & OPT_PROTO_NO_PASSWORD) && !(q->options & OPT_PROTO_NO_PASSWORD)) { |
446 } else if ((p->options & OPT_PROTO_NO_PASSWORD) && !(q->options & OPT_PROTO_NO_PASSWORD)) { |
| 428 gtk_widget_show(u->pwdbox); |
447 gtk_widget_show(ma->pwdbox); |
| 429 gtk_widget_show(u->rempass); |
448 gtk_widget_show(ma->rempass); |
| 430 } |
449 } |
| 431 if (!(p->options & OPT_PROTO_MAIL_CHECK) && (q->options & OPT_PROTO_MAIL_CHECK)) { |
450 if (!(p->options & OPT_PROTO_MAIL_CHECK) && (q->options & OPT_PROTO_MAIL_CHECK)) { |
| 432 gtk_widget_show(u->checkmail); |
451 gtk_widget_show(ma->checkmail); |
| 433 } else if ((p->options & OPT_PROTO_MAIL_CHECK) && !(q->options & OPT_PROTO_MAIL_CHECK)) { |
452 } else if ((p->options & OPT_PROTO_MAIL_CHECK) && !(q->options & OPT_PROTO_MAIL_CHECK)) { |
| 434 gtk_widget_hide(u->checkmail); |
453 gtk_widget_hide(ma->checkmail); |
| 435 } |
454 } |
| 436 |
455 |
| 437 if (!(p->options & OPT_PROTO_BUDDY_ICON) && (q->options & OPT_PROTO_BUDDY_ICON)) { |
456 if (!(p->options & OPT_PROTO_BUDDY_ICON) && (q->options & OPT_PROTO_BUDDY_ICON)) { |
| 438 gtk_widget_show(u->iconsel); |
457 gtk_widget_show(ma->iconsel); |
| 439 } else if ((p->options & OPT_PROTO_BUDDY_ICON) && !(q->options & OPT_PROTO_BUDDY_ICON)) { |
458 } else if ((p->options & OPT_PROTO_BUDDY_ICON) && !(q->options & OPT_PROTO_BUDDY_ICON)) { |
| 440 gtk_widget_hide(u->iconsel); |
459 gtk_widget_hide(ma->iconsel); |
| 441 } |
460 } |
| 442 |
461 |
| 443 if ((q->options & OPT_PROTO_BUDDY_ICON) || (q->options & OPT_PROTO_MAIL_CHECK)) |
462 if ((q->options & OPT_PROTO_BUDDY_ICON) || (q->options & OPT_PROTO_MAIL_CHECK)) |
| 444 gtk_widget_show(u->user_frame); |
463 gtk_widget_show(ma->user_frame); |
| 445 else |
464 else |
| 446 gtk_widget_hide(u->user_frame); |
465 gtk_widget_hide(ma->user_frame); |
| 447 |
466 |
| 448 u->protocol = proto; |
467 ma->protocol = proto; |
| 449 generate_protocol_options(u, u->main); |
468 generate_protocol_options(ma, ma->main); |
| 450 } |
469 } |
| 451 } |
470 } |
| 452 |
471 |
| 453 static GtkWidget *make_protocol_menu(GtkWidget *box, struct mod_user *u) |
472 static GtkWidget *make_protocol_menu(GtkWidget *box, struct mod_account *ma) |
| 454 { |
473 { |
| 455 GtkWidget *optmenu; |
474 GtkWidget *optmenu; |
| 456 GtkWidget *menu; |
475 GtkWidget *menu; |
| 457 GtkWidget *opt; |
476 GtkWidget *opt; |
| 458 GSList *p = protocols; |
477 GSList *p = protocols; |
| 488 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), count); |
507 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), count); |
| 489 |
508 |
| 490 return optmenu; |
509 return optmenu; |
| 491 } |
510 } |
| 492 |
511 |
| 493 static void des_icon_sel(GtkWidget *w, struct mod_user *u) |
512 static void des_icon_sel(GtkWidget *w, struct mod_account *ma) |
| 494 { |
513 { |
| 495 w = u->icondlg; |
514 w = ma->icondlg; |
| 496 if (u->icondlg) |
515 if (ma->icondlg) |
| 497 u->icondlg = NULL; |
516 ma->icondlg = NULL; |
| 498 if (w) |
517 if (w) |
| 499 gtk_widget_destroy(w); |
518 gtk_widget_destroy(w); |
| 500 } |
519 } |
| 501 |
520 |
| 502 static void set_icon(GtkWidget *w, struct mod_user *u) |
521 static void set_icon(GtkWidget *w, struct mod_account *ma) |
| 503 { |
522 { |
| 504 GtkWidget *sel = u->icondlg; |
523 GtkWidget *sel = ma->icondlg; |
| 505 const char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sel)); |
524 const char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sel)); |
| 506 |
525 |
| 507 if (file_is_dir(file, sel)) |
526 if (file_is_dir(file, sel)) |
| 508 return; |
527 return; |
| 509 |
528 |
| 510 gtk_entry_set_text(GTK_ENTRY(u->iconentry), file); |
529 gtk_entry_set_text(GTK_ENTRY(ma->iconentry), file); |
| 511 g_snprintf(u->iconfile, sizeof(u->iconfile), "%s", file); |
530 g_snprintf(ma->iconfile, sizeof(ma->iconfile), "%s", file); |
| 512 u->icondlg = NULL; |
531 ma->icondlg = NULL; |
| 513 |
532 |
| 514 gtk_widget_destroy(sel); |
533 gtk_widget_destroy(sel); |
| 515 } |
534 } |
| 516 |
535 |
| 517 static void sel_icon_dlg(GtkWidget *w, struct mod_user *u) |
536 static void sel_icon_dlg(GtkWidget *w, struct mod_account *ma) |
| 518 { |
537 { |
| 519 GtkWidget *dlg; |
538 GtkWidget *dlg; |
| 520 char buf[256]; |
539 char buf[256]; |
| 521 |
540 |
| 522 if (u->icondlg) { |
541 if (ma->icondlg) { |
| 523 gtk_widget_show(u->icondlg); |
542 gtk_widget_show(ma->icondlg); |
| 524 return; |
543 return; |
| 525 } |
544 } |
| 526 |
545 |
| 527 dlg = gtk_file_selection_new(_("Gaim - Load Buddy Icon")); |
546 dlg = gtk_file_selection_new(_("Gaim - Load Buddy Icon")); |
| 528 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dlg)); |
547 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dlg)); |
| 529 if (u->iconfile) { |
548 if (ma->iconfile) { |
| 530 char *tmp = g_dirname(u->iconfile); |
549 char *tmp = g_dirname(ma->iconfile); |
| 531 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dlg), tmp); |
550 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dlg), tmp); |
| 532 g_free(tmp); |
551 g_free(tmp); |
| 533 } else { |
552 } else { |
| 534 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S, gaim_home_dir()); |
553 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S, gaim_home_dir()); |
| 535 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dlg), buf); |
554 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dlg), buf); |
| 536 } |
555 } |
| 537 |
556 |
| 538 g_signal_connect(GTK_OBJECT(dlg), "destroy", G_CALLBACK(des_icon_sel), u); |
557 g_signal_connect(GTK_OBJECT(dlg), "destroy", G_CALLBACK(des_icon_sel), ma); |
| 539 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dlg)->cancel_button), "clicked", |
558 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dlg)->cancel_button), "clicked", |
| 540 G_CALLBACK(des_icon_sel), u); |
559 G_CALLBACK(des_icon_sel), ma); |
| 541 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dlg)->ok_button), "clicked", |
560 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dlg)->ok_button), "clicked", |
| 542 G_CALLBACK(set_icon), u); |
561 G_CALLBACK(set_icon), ma); |
| 543 |
562 |
| 544 u->icondlg = dlg; |
563 ma->icondlg = dlg; |
| 545 |
564 |
| 546 gtk_widget_show(dlg); |
565 gtk_widget_show(dlg); |
| 547 } |
566 } |
| 548 |
567 |
| 549 static void reset_icon(GtkWidget *w, struct mod_user *u) |
568 static void reset_icon(GtkWidget *w, struct mod_account *ma) |
| 550 { |
569 { |
| 551 u->iconfile[0] = 0; |
570 ma->iconfile[0] = 0; |
| 552 gtk_entry_set_text(GTK_ENTRY(u->iconentry), ""); |
571 gtk_entry_set_text(GTK_ENTRY(ma->iconentry), ""); |
| 553 } |
572 } |
| 554 |
573 |
| 555 static GtkWidget *build_icon_selection(struct mod_user *u, GtkWidget *box) |
574 static GtkWidget *build_icon_selection(struct mod_account *ma, GtkWidget *box) |
| 556 { |
575 { |
| 557 GtkWidget *hbox; |
576 GtkWidget *hbox; |
| 558 GtkWidget *label; |
577 GtkWidget *label; |
| 559 GtkWidget *name; |
578 GtkWidget *name; |
| 560 GtkWidget *browse; |
579 GtkWidget *browse; |
| 561 GtkWidget *reset; |
580 GtkWidget *reset; |
| 562 |
581 |
| 563 if (u->user) |
582 if (ma->account) |
| 564 g_snprintf(u->iconfile, sizeof(u->iconfile), "%s", u->user->iconfile); |
583 g_snprintf(ma->iconfile, sizeof(ma->iconfile), "%s", ma->account->iconfile); |
| 565 |
584 |
| 566 hbox = gtk_hbox_new(FALSE, 0); |
585 hbox = gtk_hbox_new(FALSE, 0); |
| 567 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); |
586 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); |
| 568 gtk_widget_show(hbox); |
587 gtk_widget_show(hbox); |
| 569 |
588 |
| 570 label = gtk_label_new(_("Buddy Icon File:")); |
589 label = gtk_label_new(_("Buddy Icon File:")); |
| 571 gtk_size_group_add_widget(u->sg, label); |
590 gtk_size_group_add_widget(ma->sg, label); |
| 572 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
591 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| 573 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
592 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| 574 gtk_widget_show(label); |
593 gtk_widget_show(label); |
| 575 |
594 |
| 576 name = gtk_entry_new(); |
595 name = gtk_entry_new(); |
| 577 gtk_entry_set_text(GTK_ENTRY(name), u->iconfile); |
596 gtk_entry_set_text(GTK_ENTRY(name), ma->iconfile); |
| 578 gtk_entry_set_editable(GTK_ENTRY(name), FALSE); |
597 gtk_entry_set_editable(GTK_ENTRY(name), FALSE); |
| 579 gtk_box_pack_start(GTK_BOX(hbox), name, TRUE, TRUE, 5); |
598 gtk_box_pack_start(GTK_BOX(hbox), name, TRUE, TRUE, 5); |
| 580 gtk_widget_show(name); |
599 gtk_widget_show(name); |
| 581 u->iconentry = name; |
600 ma->iconentry = name; |
| 582 |
601 |
| 583 browse = gtk_button_new_with_label(_("Browse")); |
602 browse = gtk_button_new_with_label(_("Browse")); |
| 584 g_signal_connect(GTK_OBJECT(browse), "clicked", G_CALLBACK(sel_icon_dlg), u); |
603 g_signal_connect(GTK_OBJECT(browse), "clicked", G_CALLBACK(sel_icon_dlg), ma); |
| 585 gtk_box_pack_start(GTK_BOX(hbox), browse, FALSE, FALSE, 0); |
604 gtk_box_pack_start(GTK_BOX(hbox), browse, FALSE, FALSE, 0); |
| 586 gtk_widget_show(browse); |
605 gtk_widget_show(browse); |
| 587 |
606 |
| 588 reset = gtk_button_new_with_label(_("Reset")); |
607 reset = gtk_button_new_with_label(_("Reset")); |
| 589 g_signal_connect(GTK_OBJECT(reset), "clicked", G_CALLBACK(reset_icon), u); |
608 g_signal_connect(GTK_OBJECT(reset), "clicked", G_CALLBACK(reset_icon), ma); |
| 590 gtk_box_pack_start(GTK_BOX(hbox), reset, FALSE, FALSE, 0); |
609 gtk_box_pack_start(GTK_BOX(hbox), reset, FALSE, FALSE, 0); |
| 591 gtk_widget_show(reset); |
610 gtk_widget_show(reset); |
| 592 |
611 |
| 593 return hbox; |
612 return hbox; |
| 594 } |
613 } |
| 595 |
614 |
| 596 static void generate_login_options(struct mod_user *u, GtkWidget *box) |
615 static void generate_login_options(struct mod_account *ma, GtkWidget *box) |
| 597 { |
616 { |
| 598 GtkWidget *frame, *frame_parent; |
617 GtkWidget *frame, *frame_parent; |
| 599 GtkWidget *vbox; |
618 GtkWidget *vbox; |
| 600 GtkWidget *hbox; |
619 GtkWidget *hbox; |
| 601 GtkWidget *label; |
620 GtkWidget *label; |
| 611 |
630 |
| 612 hbox = gtk_hbox_new(FALSE, 5); |
631 hbox = gtk_hbox_new(FALSE, 5); |
| 613 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
632 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 614 |
633 |
| 615 label = gtk_label_new(_("Screenname:")); |
634 label = gtk_label_new(_("Screenname:")); |
| 616 gtk_size_group_add_widget(u->sg, label); |
635 gtk_size_group_add_widget(ma->sg, label); |
| 617 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
636 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| 618 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
637 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| 619 |
638 |
| 620 u->name = gtk_entry_new(); |
639 ma->name = gtk_entry_new(); |
| 621 gtk_box_pack_start(GTK_BOX(hbox), u->name, TRUE, TRUE, 0); |
640 gtk_box_pack_start(GTK_BOX(hbox), ma->name, TRUE, TRUE, 0); |
| 622 |
641 |
| 623 u->pwdbox = gtk_hbox_new(FALSE, 5); |
642 ma->pwdbox = gtk_hbox_new(FALSE, 5); |
| 624 gtk_box_pack_start(GTK_BOX(vbox), u->pwdbox, FALSE, FALSE, 0); |
643 gtk_box_pack_start(GTK_BOX(vbox), ma->pwdbox, FALSE, FALSE, 0); |
| 625 |
644 |
| 626 label = gtk_label_new(_("Password:")); |
645 label = gtk_label_new(_("Password:")); |
| 627 gtk_size_group_add_widget(u->sg, label); |
646 gtk_size_group_add_widget(ma->sg, label); |
| 628 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
647 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| 629 gtk_box_pack_start(GTK_BOX(u->pwdbox), label, FALSE, FALSE, 0); |
648 gtk_box_pack_start(GTK_BOX(ma->pwdbox), label, FALSE, FALSE, 0); |
| 630 |
649 |
| 631 u->pass = gtk_entry_new(); |
650 ma->pass = gtk_entry_new(); |
| 632 gtk_box_pack_start(GTK_BOX(u->pwdbox), u->pass, TRUE, TRUE, 0); |
651 gtk_box_pack_start(GTK_BOX(ma->pwdbox), ma->pass, TRUE, TRUE, 0); |
| 633 gtk_entry_set_visibility(GTK_ENTRY(u->pass), FALSE); |
652 gtk_entry_set_visibility(GTK_ENTRY(ma->pass), FALSE); |
| 634 |
653 |
| 635 hbox = gtk_hbox_new(FALSE, 5); |
654 hbox = gtk_hbox_new(FALSE, 5); |
| 636 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
655 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 637 |
656 |
| 638 label = gtk_label_new(_("Alias:")); |
657 label = gtk_label_new(_("Alias:")); |
| 639 gtk_size_group_add_widget(u->sg, label); |
658 gtk_size_group_add_widget(ma->sg, label); |
| 640 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
659 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| 641 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
660 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| 642 |
661 |
| 643 u->alias = gtk_entry_new(); |
662 ma->alias = gtk_entry_new(); |
| 644 gtk_box_pack_start(GTK_BOX(hbox), u->alias, TRUE, TRUE, 0); |
663 gtk_box_pack_start(GTK_BOX(hbox), ma->alias, TRUE, TRUE, 0); |
| 645 |
664 |
| 646 hbox = gtk_hbox_new(FALSE, 5); |
665 hbox = gtk_hbox_new(FALSE, 5); |
| 647 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
666 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 648 gtk_widget_show(hbox); |
667 gtk_widget_show(hbox); |
| 649 |
668 |
| 650 label = gtk_label_new(_("Protocol:")); |
669 label = gtk_label_new(_("Protocol:")); |
| 651 gtk_size_group_add_widget(u->sg, label); |
670 gtk_size_group_add_widget(ma->sg, label); |
| 652 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
671 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| 653 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
672 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| 654 |
673 |
| 655 make_protocol_menu(hbox, u); |
674 make_protocol_menu(hbox, ma); |
| 656 |
675 |
| 657 u->rempass = acct_button(_("Remember Password"), u, OPT_USR_REM_PASS, vbox); |
676 ma->rempass = acct_button(_("Remember Password"), ma, OPT_ACCT_REM_PASS, vbox); |
| 658 acct_button(_("Auto-Login"), u, OPT_USR_AUTO, vbox); |
677 acct_button(_("Auto-Login"), ma, OPT_ACCT_AUTO, vbox); |
| 659 |
678 |
| 660 gtk_widget_show_all(frame_parent); |
679 gtk_widget_show_all(frame_parent); |
| 661 |
680 |
| 662 if (u->user) { |
681 if (ma->account) { |
| 663 gtk_entry_set_text(GTK_ENTRY(u->name), u->user->username); |
682 gtk_entry_set_text(GTK_ENTRY(ma->name), ma->account->username); |
| 664 gtk_entry_set_text(GTK_ENTRY(u->alias), u->user->alias); |
683 gtk_entry_set_text(GTK_ENTRY(ma->alias), ma->account->alias); |
| 665 gtk_entry_set_text(GTK_ENTRY(u->pass), u->user->password); |
684 gtk_entry_set_text(GTK_ENTRY(ma->pass), ma->account->password); |
| 666 } |
685 } |
| 667 |
686 |
| 668 p = find_prpl(u->protocol); |
687 p = find_prpl(ma->protocol); |
| 669 if (p && (p->options & OPT_PROTO_NO_PASSWORD)) { |
688 if (p && (p->options & OPT_PROTO_NO_PASSWORD)) { |
| 670 gtk_widget_hide(u->pwdbox); |
689 gtk_widget_hide(ma->pwdbox); |
| 671 gtk_widget_hide(u->rempass); |
690 gtk_widget_hide(ma->rempass); |
| 672 } |
691 } |
| 673 } |
692 } |
| 674 |
693 |
| 675 static void generate_user_options(struct mod_user *u, GtkWidget *box) |
694 static void generate_user_options(struct mod_account *ma, GtkWidget *box) |
| 676 { |
695 { |
| 677 /* This function will add the appropriate (depending on the current |
696 /* This function will add the appropriate (depending on the current |
| 678 * protocol) widgets to frame and return TRUE if there anything |
697 * protocol) widgets to frame and return TRUE if there anything |
| 679 * was added (meaning the frame should be shown) |
698 * was added (meaning the frame should be shown) |
| 680 * Eric will most likely change this (as he does all other submitted code) |
699 * Eric will most likely change this (as he does all other submitted code) |
| 767 hbox = gtk_hbox_new(FALSE, 5); |
786 hbox = gtk_hbox_new(FALSE, 5); |
| 768 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
787 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 769 gtk_widget_show(hbox); |
788 gtk_widget_show(hbox); |
| 770 |
789 |
| 771 label = gtk_label_new(puo->label); |
790 label = gtk_label_new(puo->label); |
| 772 gtk_size_group_add_widget(u->sg, label); |
791 gtk_size_group_add_widget(ma->sg, label); |
| 773 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
792 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| 774 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
793 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| 775 gtk_widget_show(label); |
794 gtk_widget_show(label); |
| 776 |
795 |
| 777 entry = gtk_entry_new(); |
796 entry = gtk_entry_new(); |
| 778 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
797 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
| 779 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)puo->pos); |
798 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)puo->pos); |
| 780 if (u->proto_opt[puo->pos][0]) { |
799 if (ma->proto_opt[puo->pos][0]) { |
| 781 debug_printf("setting text %s\n", u->proto_opt[puo->pos]); |
800 debug_printf("setting text %s\n", ma->proto_opt[puo->pos]); |
| 782 gtk_entry_set_text(GTK_ENTRY(entry), u->proto_opt[puo->pos]); |
801 gtk_entry_set_text(GTK_ENTRY(entry), ma->proto_opt[puo->pos]); |
| 783 } else { |
802 } else { |
| 784 gtk_entry_set_text(GTK_ENTRY(entry), puo->def); |
803 gtk_entry_set_text(GTK_ENTRY(entry), puo->def); |
| 785 } |
804 } |
| 786 gtk_widget_show(entry); |
805 gtk_widget_show(entry); |
| 787 |
806 |
| 788 u->opt_entries = g_list_append(u->opt_entries, entry); |
807 ma->opt_entries = g_list_append(ma->opt_entries, entry); |
| 789 |
808 |
| 790 op = op->next; |
809 op = op->next; |
| 791 } |
810 } |
| 792 |
811 |
| 793 if(p->register_user != NULL) { |
812 if(p->register_user != NULL) { |
| 794 u->register_user = gtk_check_button_new_with_label(_("Register with server")); |
813 ma->register_user = gtk_check_button_new_with_label(_("Register with server")); |
| 795 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(u->register_user), FALSE); |
814 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ma->register_user), FALSE); |
| 796 gtk_box_pack_start(GTK_BOX(vbox), u->register_user, FALSE, FALSE, 0); |
815 gtk_box_pack_start(GTK_BOX(vbox), ma->register_user, FALSE, FALSE, 0); |
| 797 gtk_widget_show(u->register_user); |
816 gtk_widget_show(ma->register_user); |
| 798 } |
817 } |
| 799 |
818 |
| 800 } |
819 } |
| 801 |
820 |
| 802 static void show_acct_mod(struct aim_user *a) |
821 static void show_acct_mod(struct gaim_account *a) |
| 803 { |
822 { |
| 804 /* This is the fucking modify account dialog. I've fucking seperated it into |
823 /* This is the fucking modify account dialog. I've fucking seperated it into |
| 805 * three fucking frames: |
824 * three fucking frames: |
| 806 * a fucking Login Options frame, a fucking User Options frame and a fucking |
825 * a fucking Login Options frame, a fucking User Options frame and a fucking |
| 807 * Protcol Options frame. This fucking removes the two fucking tabs, which were |
826 * Protcol Options frame. This fucking removes the two fucking tabs, which |
| 808 * quite fucking uneccessary. Fuck. */ |
827 * were quite fucking uneccessary. Fuck. */ |
| 809 /* -- SeanEgan */ |
828 /* -- SeanEgan */ |
| 810 /* YEAH!! -- ChipX86 */ |
829 /* YEAH!! -- ChipX86 */ |
| 811 GtkWidget *hbox, *vbox; |
830 GtkWidget *hbox, *vbox; |
| 812 GtkWidget *button; |
831 GtkWidget *button; |
| 813 GtkWidget *sep; |
832 GtkWidget *sep; |
| 814 GtkSizeGroup *button_sg; |
833 GtkSizeGroup *button_sg; |
| 815 |
834 |
| 816 struct mod_user *u = find_mod_user(a); |
835 struct mod_account *ma = mod_account_find(a); |
| 817 |
836 |
| 818 if (!u) { |
837 if (!ma) { |
| 819 u = g_new0(struct mod_user, 1); |
838 ma = g_new0(struct mod_account, 1); |
| 820 u->user = a; |
839 ma->account = a; |
| 821 mod_users = g_slist_append(mod_users, u); |
840 mod_accounts = g_slist_append(mod_accounts, ma); |
| 822 |
841 |
| 823 if (a) { |
842 if (a) { |
| 824 int i; |
843 int i; |
| 825 u->options = a->options; |
844 ma->options = a->options; |
| 826 if (find_prpl(a->protocol)) |
845 if (find_prpl(a->protocol)) |
| 827 u->protocol = a->protocol; |
846 ma->protocol = a->protocol; |
| 828 else if (protocols) |
847 else if (protocols) |
| 829 u->protocol = ((struct prpl *)protocols->data)->protocol; |
848 ma->protocol = ((struct prpl *)protocols->data)->protocol; |
| 830 else |
849 else |
| 831 u->protocol = -1; |
850 ma->protocol = -1; |
| 832 g_snprintf(u->iconfile, sizeof(u->iconfile), "%s", a->iconfile); |
851 g_snprintf(ma->iconfile, sizeof(ma->iconfile), "%s", a->iconfile); |
| 833 for (i = 0; i < 7; i++) |
852 for (i = 0; i < 7; i++) |
| 834 g_snprintf(u->proto_opt[i], sizeof(u->proto_opt[i]), "%s", |
853 g_snprintf(ma->proto_opt[i], sizeof(ma->proto_opt[i]), "%s", |
| 835 a->proto_opt[i]); |
854 a->proto_opt[i]); |
| 836 } else { |
855 } else { |
| 837 u->options = OPT_USR_REM_PASS; |
856 ma->options = OPT_ACCT_REM_PASS; |
| 838 if (find_prpl(DEFAULT_PROTO)) |
857 if (find_prpl(DEFAULT_PROTO)) |
| 839 u->protocol = DEFAULT_PROTO; |
858 ma->protocol = DEFAULT_PROTO; |
| 840 else if (protocols) |
859 else if (protocols) |
| 841 u->protocol = ((struct prpl *)protocols->data)->protocol; |
860 ma->protocol = ((struct prpl *)protocols->data)->protocol; |
| 842 else |
861 else |
| 843 u->protocol = -1; |
862 ma->protocol = -1; |
| 844 } |
863 } |
| 845 } else { |
864 } else { |
| 846 gtk_widget_show(u->mod); |
865 gtk_widget_show(ma->mod); |
| 847 return; |
866 return; |
| 848 } |
867 } |
| 849 |
868 |
| 850 u->mod = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
869 ma->mod = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 851 gtk_window_set_role(GTK_WINDOW(u->mod), "account"); |
870 gtk_window_set_role(GTK_WINDOW(ma->mod), "account"); |
| 852 gtk_widget_realize(u->mod); |
871 gtk_widget_realize(ma->mod); |
| 853 gtk_window_set_title(GTK_WINDOW(u->mod), _("Gaim - Modify Account")); |
872 gtk_window_set_title(GTK_WINDOW(ma->mod), _("Gaim - Modify Account")); |
| 854 gtk_window_set_policy(GTK_WINDOW(u->mod), FALSE, FALSE, TRUE); /* nothing odd here :) */ |
873 gtk_window_set_policy(GTK_WINDOW(ma->mod), FALSE, FALSE, TRUE); /* nothing odd here :) */ |
| 855 g_signal_connect(GTK_OBJECT(u->mod), "destroy", G_CALLBACK(delmod), u); |
874 g_signal_connect(GTK_OBJECT(ma->mod), "destroy", G_CALLBACK(delmod), ma); |
| 856 |
875 |
| 857 vbox = gtk_vbox_new(FALSE, 6); |
876 vbox = gtk_vbox_new(FALSE, 6); |
| 858 gtk_container_border_width(GTK_CONTAINER(vbox), 6); |
877 gtk_container_border_width(GTK_CONTAINER(vbox), 6); |
| 859 gtk_container_add(GTK_CONTAINER(u->mod), vbox); |
878 gtk_container_add(GTK_CONTAINER(ma->mod), vbox); |
| 860 gtk_widget_show(vbox); |
879 gtk_widget_show(vbox); |
| 861 |
880 |
| 862 u->main = gtk_vbox_new(FALSE, 12); |
881 ma->main = gtk_vbox_new(FALSE, 12); |
| 863 gtk_container_border_width(GTK_CONTAINER(u->main), 6); |
882 gtk_container_border_width(GTK_CONTAINER(ma->main), 6); |
| 864 gtk_box_pack_start(GTK_BOX(vbox), u->main, FALSE, FALSE, 0); |
883 gtk_box_pack_start(GTK_BOX(vbox), ma->main, FALSE, FALSE, 0); |
| 865 gtk_widget_show(u->main); |
884 gtk_widget_show(ma->main); |
| 866 |
885 |
| 867 u->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
886 ma->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| 868 |
887 |
| 869 generate_login_options(u, u->main); |
888 generate_login_options(ma, ma->main); |
| 870 generate_user_options(u, u->main); |
889 generate_user_options(ma, ma->main); |
| 871 generate_protocol_options(u, u->main); |
890 generate_protocol_options(ma, ma->main); |
| 872 |
891 |
| 873 hbox = gtk_hbox_new(FALSE, 6); |
892 hbox = gtk_hbox_new(FALSE, 6); |
| 874 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); |
893 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); |
| 875 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
894 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
| 876 |
895 |
| 877 button_sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); |
896 button_sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); |
| 878 |
897 |
| 879 button = gtk_button_new_from_stock(GTK_STOCK_OK); |
898 button = gtk_button_new_from_stock(GTK_STOCK_OK); |
| 880 gtk_size_group_add_widget(button_sg, button); |
899 gtk_size_group_add_widget(button_sg, button); |
| 881 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
900 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
| 882 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(ok_mod), u); |
901 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(ok_mod), ma); |
| 883 |
902 |
| 884 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); |
903 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); |
| 885 gtk_size_group_add_widget(button_sg, button); |
904 gtk_size_group_add_widget(button_sg, button); |
| 886 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
905 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
| 887 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(cancel_mod), u); |
906 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(cancel_mod), ma); |
| 888 |
907 |
| 889 sep = gtk_hseparator_new(); |
908 sep = gtk_hseparator_new(); |
| 890 gtk_box_pack_end (GTK_BOX (vbox), sep, FALSE, FALSE, 0); |
909 gtk_box_pack_end (GTK_BOX (vbox), sep, FALSE, FALSE, 0); |
| 891 gtk_widget_show(sep); |
910 gtk_widget_show(sep); |
| 892 |
911 |
| 893 gtk_widget_show_all(hbox); |
912 gtk_widget_show_all(hbox); |
| 894 gtk_widget_show(u->mod); |
913 gtk_widget_show(ma->mod); |
| 895 } |
914 } |
| 896 |
915 |
| 897 static void add_acct(GtkWidget *w, gpointer d) |
916 static void add_acct(GtkWidget *w, gpointer d) |
| 898 { |
917 { |
| 899 show_acct_mod(NULL); |
918 show_acct_mod(NULL); |
| 900 } |
919 } |
| 901 |
920 |
| 902 static void mod_acct_func(GtkTreeModel *model, GtkTreePath *path, |
921 static void mod_acct_func(GtkTreeModel *model, GtkTreePath *path, |
| 903 GtkTreeIter *iter, gpointer data) |
922 GtkTreeIter *iter, gpointer data) |
| 904 { |
923 { |
| 905 struct aim_user *u; |
924 struct gaim_account *a; |
| 906 |
925 |
| 907 gtk_tree_model_get(model, iter, COLUMN_DATA, &u, -1); |
926 gtk_tree_model_get(model, iter, COLUMN_DATA, &a, -1); |
| 908 |
927 |
| 909 if (u != NULL) |
928 if (a != NULL) |
| 910 show_acct_mod(u); |
929 show_acct_mod(a); |
| 911 } |
930 } |
| 912 |
931 |
| 913 static void mod_acct(GtkWidget *w, gpointer d) |
932 static void mod_acct(GtkWidget *w, gpointer d) |
| 914 { |
933 { |
| 915 GtkTreeSelection *selection; |
934 GtkTreeSelection *selection; |
| 916 |
935 |
| 917 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); |
936 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); |
| 918 |
937 |
| 919 gtk_tree_selection_selected_foreach(selection, mod_acct_func, NULL); |
938 gtk_tree_selection_selected_foreach(selection, mod_acct_func, NULL); |
| 920 |
|
| 921 #if 0 |
|
| 922 while (l) { |
|
| 923 row = (int)l->data; |
|
| 924 if (row != -1) { |
|
| 925 u = g_slist_nth_data(aim_users, row); |
|
| 926 if (u) |
|
| 927 show_acct_mod(u); |
|
| 928 } |
|
| 929 l = l->next; |
|
| 930 } |
|
| 931 #endif |
|
| 932 } |
939 } |
| 933 |
940 |
| 934 struct pass_prompt { |
941 struct pass_prompt { |
| 935 struct aim_user *u; |
942 struct gaim_account *account; |
| 936 GtkWidget *win; |
943 GtkWidget *win; |
| 937 GtkWidget *entry; |
944 GtkWidget *entry; |
| 938 }; |
945 }; |
| 939 static GSList *passes = NULL; |
946 static GSList *passes = NULL; |
| 940 |
947 |
| 941 static struct pass_prompt *find_pass_prompt(struct aim_user *u) |
948 static struct pass_prompt *find_pass_prompt(struct gaim_account *account) |
| 942 { |
949 { |
| 943 GSList *p = passes; |
950 GSList *p = passes; |
| 944 while (p) { |
951 while (p) { |
| 945 struct pass_prompt *r = p->data; |
952 struct pass_prompt *r = p->data; |
| 946 if (r->u == u) |
953 if (r->account == account) |
| 947 return r; |
954 return r; |
| 948 p = p->next; |
955 p = p->next; |
| 949 } |
956 } |
| 950 return NULL; |
957 return NULL; |
| 951 } |
958 } |
| 952 |
959 |
| 953 static void pass_callback(GtkDialog *d, gint resp, struct pass_prompt *p) |
960 static void pass_callback(GtkDialog *d, gint resp, struct pass_prompt *p) |
| 954 { |
961 { |
| 955 if (resp == GTK_RESPONSE_YES) { |
962 if (resp == GTK_RESPONSE_YES) { |
| 956 const char *txt = gtk_entry_get_text(GTK_ENTRY(p->entry)); |
963 const char *txt = gtk_entry_get_text(GTK_ENTRY(p->entry)); |
| 957 g_snprintf(p->u->password, sizeof(p->u->password), "%s", txt); |
964 g_snprintf(p->account->password, sizeof(p->account->password), "%s", txt); |
| 958 serv_login(p->u); |
965 serv_login(p->account); |
| 959 } |
966 } |
| 960 passes = g_slist_remove(passes, p); |
967 passes = g_slist_remove(passes, p); |
| 961 gtk_widget_destroy(p->win); |
968 gtk_widget_destroy(p->win); |
| 962 g_free(p); |
969 g_free(p); |
| 963 } |
970 } |
| 964 |
971 |
| 965 static void do_pass_dlg(struct aim_user *u) |
972 static void do_pass_dlg(struct gaim_account *account) |
| 966 { |
973 { |
| 967 /* we can safely assume that u is not NULL */ |
974 /* we can safely assume that u is not NULL */ |
| 968 struct pass_prompt *p = find_pass_prompt(u); |
975 struct pass_prompt *p = find_pass_prompt(account); |
| 969 GtkWidget *label; |
976 GtkWidget *label; |
| 970 GtkWidget *hbox, *vbox; |
977 GtkWidget *hbox, *vbox; |
| 971 char *labeltext=NULL; |
978 char *labeltext=NULL; |
| 972 char *filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_auth.png", NULL); |
979 char *filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_auth.png", NULL); |
| 973 GtkWidget *img = gtk_image_new_from_file(filename); |
980 GtkWidget *img = gtk_image_new_from_file(filename); |
| 974 g_free(filename); |
981 g_free(filename); |
| 975 |
982 |
| 976 |
983 |
| 977 if (p) { |
984 if (p) { |
| 978 gtk_widget_show(p->win); |
985 gtk_widget_show(p->win); |
| 979 return; |
986 return; |
| 980 } |
987 } |
| 981 |
988 |
| 982 p = g_new0(struct pass_prompt, 1); |
989 p = g_new0(struct pass_prompt, 1); |
| 983 p->u = u; |
990 p->account = account; |
| 984 passes = g_slist_append(passes, p); |
991 passes = g_slist_append(passes, p); |
| 985 |
992 |
| 986 p->win = gtk_dialog_new_with_buttons("", NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
993 p->win = gtk_dialog_new_with_buttons("", NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
| 987 _("_Login"), GTK_RESPONSE_YES, NULL); |
994 _("_Login"), GTK_RESPONSE_YES, NULL); |
| 988 |
995 |
| 989 gtk_dialog_set_default_response (GTK_DIALOG(p->win), GTK_RESPONSE_YES); |
996 gtk_dialog_set_default_response (GTK_DIALOG(p->win), GTK_RESPONSE_YES); |
| 990 g_signal_connect(G_OBJECT(p->win), "response", G_CALLBACK(pass_callback), p); |
997 g_signal_connect(G_OBJECT(p->win), "response", G_CALLBACK(pass_callback), p); |
| 991 |
998 |
| 1495 GtkWidget *graphic; |
1485 GtkWidget *graphic; |
| 1496 GtkWidget *label; |
1486 GtkWidget *label; |
| 1497 GtkWidget *nest_vbox; |
1487 GtkWidget *nest_vbox; |
| 1498 GString *name_to_print; |
1488 GString *name_to_print; |
| 1499 struct signon_meter *meter; |
1489 struct signon_meter *meter; |
| 1500 |
1490 |
| 1501 name_to_print = g_string_new(gc->username); |
1491 name_to_print = g_string_new(gc->username); |
| 1502 |
1492 |
| 1503 meter = g_new0(struct signon_meter, 1); |
1493 meter = g_new0(struct signon_meter, 1); |
| 1504 |
1494 |
| 1505 (*rows)++; |
1495 (*rows)++; |
| 1506 gtk_table_resize (table, *rows, 4); |
1496 gtk_table_resize (table, *rows, 4); |
| 1507 |
1497 |
| 1508 graphic = create_meter_pixmap( widget , gc); |
1498 graphic = create_meter_pixmap( widget , gc); |
| 1509 |
1499 |
| 1510 nest_vbox = gtk_vbox_new (FALSE, 0); |
1500 nest_vbox = gtk_vbox_new (FALSE, 0); |
| 1511 |
1501 |
| 1512 g_string_prepend(name_to_print, _("Signon: ")); |
1502 g_string_prepend(name_to_print, _("Signon: ")); |
| 1513 label = gtk_label_new (name_to_print->str); |
1503 label = gtk_label_new (name_to_print->str); |
| 1514 g_string_free(name_to_print, TRUE); |
1504 g_string_free(name_to_print, TRUE); |
| 1515 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); |
1505 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); |
| 1516 |
1506 |
| 1517 meter->status = gtk_statusbar_new(); |
1507 meter->status = gtk_statusbar_new(); |
| 1518 gtk_widget_set_usize(meter->status, 250, 0); |
1508 gtk_widget_set_usize(meter->status, 250, 0); |
| 1519 |
1509 |
| 1520 meter->progress = gtk_progress_bar_new (); |
1510 meter->progress = gtk_progress_bar_new (); |
| 1521 |
1511 |
| 1522 meter->button = gtk_button_new_with_label (_("Cancel")); |
1512 meter->button = gtk_button_new_with_label (_("Cancel")); |
| 1523 g_signal_connect (GTK_OBJECT (meter->button), "clicked", G_CALLBACK (cancel_signon), meter); |
1513 g_signal_connect (GTK_OBJECT (meter->button), "clicked", G_CALLBACK (cancel_signon), meter); |
| 1524 |
1514 |
| 1525 gtk_table_attach (GTK_TABLE (table), graphic, 0, 1, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); |
1515 gtk_table_attach (GTK_TABLE (table), graphic, 0, 1, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); |
| 1526 gtk_table_attach (GTK_TABLE (table), nest_vbox, 1, 2, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); |
1516 gtk_table_attach (GTK_TABLE (table), nest_vbox, 1, 2, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); |
| 1527 gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (label), FALSE, FALSE, 0); |
1517 gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (label), FALSE, FALSE, 0); |
| 1528 gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (meter->status), FALSE, FALSE, 0); |
1518 gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (meter->status), FALSE, FALSE, 0); |
| 1529 gtk_table_attach (GTK_TABLE (table), meter->progress, 2, 3, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); |
1519 gtk_table_attach (GTK_TABLE (table), meter->progress, 2, 3, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); |
| 1530 gtk_table_attach (GTK_TABLE (table), meter->button, 3, 4, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); |
1520 gtk_table_attach (GTK_TABLE (table), meter->button, 3, 4, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); |
| 1531 |
1521 |
| 1532 gtk_widget_show_all (GTK_WIDGET (meter_win->window)); |
1522 gtk_widget_show_all (GTK_WIDGET (meter_win->window)); |
| 1533 |
1523 |
| 1534 meter_win->active_count++; |
1524 meter_win->active_count++; |
| 1535 |
1525 |
| 1536 return meter; |
1526 return meter; |
| 1537 } |
1527 } |
| 1538 |
1528 |
| 1539 static void loop_cancel () { |
1529 static void loop_cancel () { |
| 1540 GSList *m = meters; |
1530 GSList *m = meters; |