comparison src/gtkaccount.c @ 11739:a25be0e70a67

[gaim-migrate @ 14030] I changed the GtkStatusBox list stores to use an enum instead of a string to identify the items in the GtkStatusBox. This feels a lot cleaner to me committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 23 Oct 2005 06:46:07 +0000
parents ef511dec9903
children 141368559673
comparison
equal deleted inserted replaced
11738:992d49cf2b92 11739:a25be0e70a67
1426 char *username; 1426 char *username;
1427 char *tmp; 1427 char *tmp;
1428 size_t index; 1428 size_t index;
1429 gboolean new = FALSE; 1429 gboolean new = FALSE;
1430 GtkTreeIter iter; 1430 GtkTreeIter iter;
1431 GaimAccount *ret; 1431 GaimAccount *account;
1432 1432
1433 if (dialog->account == NULL) 1433 if (dialog->account == NULL)
1434 { 1434 {
1435 const char *screenname; 1435 const char *screenname;
1436 1436
1437 screenname = gtk_entry_get_text(GTK_ENTRY(dialog->screenname_entry)); 1437 screenname = gtk_entry_get_text(GTK_ENTRY(dialog->screenname_entry));
1438 1438 account = gaim_account_new(screenname, dialog->protocol_id);
1439 dialog->account = gaim_account_new(screenname, dialog->protocol_id); 1439 gaim_account_set_enabled(account, GAIM_GTK_UI, TRUE);
1440 gaim_account_set_enabled(dialog->account, GAIM_GTK_UI, TRUE);
1441 new = TRUE; 1440 new = TRUE;
1442 } 1441 }
1443 else 1442 else
1444 { 1443 {
1444 account = dialog->account;
1445
1445 /* Protocol */ 1446 /* Protocol */
1446 gaim_account_set_protocol_id(dialog->account, dialog->protocol_id); 1447 gaim_account_set_protocol_id(account, dialog->protocol_id);
1447 } 1448 }
1448 1449
1449 /* Alias */ 1450 /* Alias */
1450 value = gtk_entry_get_text(GTK_ENTRY(dialog->alias_entry)); 1451 value = gtk_entry_get_text(GTK_ENTRY(dialog->alias_entry));
1451 1452
1452 if (*value != '\0') 1453 if (*value != '\0')
1453 gaim_account_set_alias(dialog->account, value); 1454 gaim_account_set_alias(account, value);
1454 else 1455 else
1455 gaim_account_set_alias(dialog->account, NULL); 1456 gaim_account_set_alias(account, NULL);
1456 1457
1457 /* Buddy Icon */ 1458 /* Buddy Icon */
1458 gaim_account_set_buddy_icon(dialog->account, dialog->icon_path); 1459 gaim_account_set_buddy_icon(account, dialog->icon_path);
1459 1460
1460 /* Remember Password */ 1461 /* Remember Password */
1461 gaim_account_set_remember_password(dialog->account, 1462 gaim_account_set_remember_password(account,
1462 gtk_toggle_button_get_active( 1463 gtk_toggle_button_get_active(
1463 GTK_TOGGLE_BUTTON(dialog->remember_pass_check))); 1464 GTK_TOGGLE_BUTTON(dialog->remember_pass_check)));
1464 1465
1465 /* Check Mail */ 1466 /* Check Mail */
1466 if (dialog->prpl_info && dialog->prpl_info->options & OPT_PROTO_MAIL_CHECK) 1467 if (dialog->prpl_info && dialog->prpl_info->options & OPT_PROTO_MAIL_CHECK)
1467 gaim_account_set_check_mail(dialog->account, 1468 gaim_account_set_check_mail(account,
1468 gtk_toggle_button_get_active( 1469 gtk_toggle_button_get_active(
1469 GTK_TOGGLE_BUTTON(dialog->new_mail_check))); 1470 GTK_TOGGLE_BUTTON(dialog->new_mail_check)));
1470 1471
1471 /* Password */ 1472 /* Password */
1472 value = gtk_entry_get_text(GTK_ENTRY(dialog->password_entry)); 1473 value = gtk_entry_get_text(GTK_ENTRY(dialog->password_entry));
1473 1474
1474 if (gaim_account_get_remember_password(dialog->account) && *value != '\0') 1475 if (gaim_account_get_remember_password(account) && *value != '\0')
1475 gaim_account_set_password(dialog->account, value); 1476 gaim_account_set_password(account, value);
1476 else 1477 else
1477 gaim_account_set_password(dialog->account, NULL); 1478 gaim_account_set_password(account, NULL);
1478 1479
1479 /* Build the username string. */ 1480 /* Build the username string. */
1480 username = 1481 username =
1481 g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog->screenname_entry))); 1482 g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog->screenname_entry)));
1482 1483
1503 g_free(username); 1504 g_free(username);
1504 username = tmp; 1505 username = tmp;
1505 } 1506 }
1506 } 1507 }
1507 1508
1508 gaim_account_set_username(dialog->account, username); 1509 gaim_account_set_username(account, username);
1509 g_free(username); 1510 g_free(username);
1510 1511
1511 /* Add the protocol settings */ 1512 /* Add the protocol settings */
1512 1513
1513 if(dialog->prpl_info) { 1514 if(dialog->prpl_info) {
1528 setting = gaim_account_option_get_setting(option); 1529 setting = gaim_account_option_get_setting(option);
1529 1530
1530 switch (type) { 1531 switch (type) {
1531 case GAIM_PREF_STRING: 1532 case GAIM_PREF_STRING:
1532 value = gtk_entry_get_text(GTK_ENTRY(widget)); 1533 value = gtk_entry_get_text(GTK_ENTRY(widget));
1533 gaim_account_set_string(dialog->account, setting, value); 1534 gaim_account_set_string(account, setting, value);
1534 break; 1535 break;
1535 1536
1536 case GAIM_PREF_INT: 1537 case GAIM_PREF_INT:
1537 int_value = atoi(gtk_entry_get_text(GTK_ENTRY(widget))); 1538 int_value = atoi(gtk_entry_get_text(GTK_ENTRY(widget)));
1538 gaim_account_set_int(dialog->account, setting, int_value); 1539 gaim_account_set_int(account, setting, int_value);
1539 break; 1540 break;
1540 1541
1541 case GAIM_PREF_BOOLEAN: 1542 case GAIM_PREF_BOOLEAN:
1542 bool_value = 1543 bool_value =
1543 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); 1544 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
1544 gaim_account_set_bool(dialog->account, setting, bool_value); 1545 gaim_account_set_bool(account, setting, bool_value);
1545 break; 1546 break;
1546 1547
1547 default: 1548 default:
1548 break; 1549 break;
1549 } 1550 }
1550 } 1551 }
1551 } 1552 }
1552 1553
1553 /* Set the proxy stuff. */ 1554 /* Set the proxy stuff. */
1554 if (dialog->new_proxy_type == GAIM_PROXY_USE_GLOBAL) { 1555 if (dialog->new_proxy_type == GAIM_PROXY_USE_GLOBAL) {
1555 gaim_account_set_proxy_info(dialog->account, NULL); 1556 gaim_account_set_proxy_info(account, NULL);
1556 } 1557 }
1557 else { 1558 else {
1558 proxy_info = gaim_account_get_proxy_info(dialog->account); 1559 proxy_info = gaim_account_get_proxy_info(account);
1559 1560
1560 /* Create the proxy info if it doesn't exist. */ 1561 /* Create the proxy info if it doesn't exist. */
1561 if (proxy_info == NULL) { 1562 if (proxy_info == NULL) {
1562 proxy_info = gaim_proxy_info_new(); 1563 proxy_info = gaim_proxy_info_new();
1563 gaim_account_set_proxy_info(dialog->account, proxy_info); 1564 gaim_account_set_proxy_info(account, proxy_info);
1564 } 1565 }
1565 1566
1566 /* Set the proxy info type. */ 1567 /* Set the proxy info type. */
1567 gaim_proxy_info_set_type(proxy_info, dialog->new_proxy_type); 1568 gaim_proxy_info_set_type(proxy_info, dialog->new_proxy_type);
1568 1569
1599 gaim_proxy_info_set_password(proxy_info, NULL); 1600 gaim_proxy_info_set_password(proxy_info, NULL);
1600 } 1601 }
1601 1602
1602 /* Adds the account to the list, or modify the existing entry. */ 1603 /* Adds the account to the list, or modify the existing entry. */
1603 if (accounts_window != NULL) { 1604 if (accounts_window != NULL) {
1604 index = g_list_index(gaim_accounts_get_all(), dialog->account); 1605 index = g_list_index(gaim_accounts_get_all(), account);
1605 1606
1606 if (index != -1 && 1607 if (index != -1 &&
1607 (gtk_tree_model_iter_nth_child( 1608 (gtk_tree_model_iter_nth_child(
1608 GTK_TREE_MODEL(accounts_window->model), &iter, 1609 GTK_TREE_MODEL(accounts_window->model), &iter,
1609 NULL, index))) { 1610 NULL, index))) {
1610 1611
1611 set_account(accounts_window->model, &iter, 1612 set_account(accounts_window->model, &iter,
1612 dialog->account); 1613 account);
1613 } 1614 }
1614 else { 1615 else {
1615 add_account(accounts_window, dialog->account); 1616 add_account(accounts_window, account);
1616 gaim_accounts_add(dialog->account); 1617 gaim_accounts_add(account);
1617 } 1618 }
1618 } 1619 }
1619 1620
1620 ret = dialog->account;
1621
1622 account_win_destroy_cb(NULL, NULL, dialog); 1621 account_win_destroy_cb(NULL, NULL, dialog);
1623 1622
1624 gaim_signal_emit(gaim_gtk_account_get_handle(), "account-modified", ret); 1623 gaim_signal_emit(gaim_gtk_account_get_handle(), "account-modified", account);
1625 1624
1625 /* TODO: This doesn't work quite right yet. */
1626 if (new) { 1626 if (new) {
1627 const char *current_savedstatus_name;
1628 const GaimSavedStatus *saved_status;
1629
1630 current_savedstatus_name = gaim_prefs_get_string("/core/status/current");
1631 saved_status = gaim_savedstatus_find(current_savedstatus_name);
1632 gaim_savedstatus_activate_for_account(saved_status, account);
1633
1634 /*
1635 This is the old way. The new way is an improvement.
1627 GaimGtkBuddyList *gtkblist; 1636 GaimGtkBuddyList *gtkblist;
1628 GtkGaimStatusBox *status_box; 1637 GtkGaimStatusBox *status_box;
1629 char *status_type_id; 1638 char *status_type_id;
1630 1639
1631 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); 1640 gtkblist = GAIM_GTK_BLIST(gaim_get_blist());
1632 status_box = GTK_GAIM_STATUS_BOX(gtkblist->statusbox); 1641 status_box = GTK_GAIM_STATUS_BOX(gtkblist->statusbox);
1633 1642
1634 status_type_id = gtk_gaim_status_box_get_active_type(status_box); 1643 status_type_id = gtk_gaim_status_box_get_active_type(status_box);
1635 gaim_presence_set_status_active(ret->presence, status_type_id, TRUE); 1644 gaim_presence_set_status_active(account->presence, status_type_id, TRUE);
1636 g_free(status_type_id); 1645 g_free(status_type_id);
1637 } 1646 */
1638 1647 }
1639 return ret; 1648
1649 return account;
1640 } 1650 }
1641 1651
1642 static void 1652 static void
1643 register_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog) 1653 register_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog)
1644 { 1654 {