# HG changeset patch # User Sadrul Habib Chowdhury # Date 1211346445 0 # Node ID 02ef6c5c66503b5ac6b1fc9288f70adf270e8246 # Parent cd007fd9cf83327ec31220f03cb7b258e462c403 Allow account registration in a new account dialog. diff -r cd007fd9cf83 -r 02ef6c5c6650 finch/gntaccount.c --- a/finch/gntaccount.c Wed May 21 04:13:12 2008 +0000 +++ b/finch/gntaccount.c Wed May 21 05:07:25 2008 +0000 @@ -43,6 +43,7 @@ #include #include #include +#include #include "gntaccount.h" #include "gntblist.h" @@ -67,7 +68,7 @@ GntWidget *screenname; GntWidget *password; GntWidget *alias; - + GntWidget *splits; GList *split_entries; @@ -76,6 +77,7 @@ GntWidget *newmail; GntWidget *remember; + GntWidget *regserver; } AccountEditDialog; /* This is necessary to close an edit-dialog when an account is deleted */ @@ -125,7 +127,7 @@ _("Username of an account must be non-empty.")); return; } - + username = g_string_new(value); if (prplinfo != NULL) @@ -183,7 +185,7 @@ if (prplinfo) { GList *iter, *entries; - + for (iter = prplinfo->protocol_options, entries = dialog->prpl_entries; iter && entries; iter = iter->next, entries = entries->next) { @@ -228,6 +230,20 @@ gnt_box_give_focus_to_child(GNT_BOX(accounts.window), accounts.tree); } + if (prplinfo && prplinfo->register_user && + gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->regserver))) { + purple_account_register(account); + } else if (dialog->account == NULL) { + /* This is a new account. Set it to the current status. */ + /* Xerox from gtkaccount.c :D */ + const PurpleSavedStatus *saved_status; + saved_status = purple_savedstatus_get_current(); + if (saved_status != NULL) { + purple_savedstatus_activate_for_account(saved_status, account); + purple_account_set_enabled(account, FINCH_UI, TRUE); + } + } + gnt_widget_destroy(dialog->window); } @@ -419,6 +435,11 @@ } } } + + /* Show the registration checkbox only in a new account dialog, + * and when the selected prpl has the support for it. */ + gnt_widget_set_visible(dialog->regserver, account == NULL && + prplinfo->register_user != NULL); } static void @@ -559,6 +580,10 @@ gnt_box_add_widget(GNT_BOX(window), dialog->remember); gnt_box_add_widget(GNT_BOX(window), dialog->newmail); + /* Register checkbox */ + dialog->regserver = gnt_check_box_new(_("Create this account on the server")); + gnt_box_add_widget(GNT_BOX(window), dialog->regserver); + gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); /* The advanced box */