pidgin: 6be1d8af: Some updates to the account window.

sadrul at pidgin.im sadrul at pidgin.im
Sun Jul 4 23:05:47 EDT 2010


----------------------------------------------------------------------
Revision: 6be1d8afd29f8e7fdee5f915814fb2153900a136
Parent:   3ac8d903a9f4e67e9787c4c66b150906100a7678
Author:   sadrul at pidgin.im
Date:     07/04/10 23:07:37
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6be1d8afd29f8e7fdee5f915814fb2153900a136

Changelog: 

Some updates to the account window.

Update the list of accounts when an account is modified. Also, do not
allow changing the protocol or username of a connected account, and show
more appropriate error messages when an error happens.

Changes against parent 3ac8d903a9f4e67e9787c4c66b150906100a7678

  patched  finch/gntaccount.c

-------------- next part --------------
============================================================
--- finch/gntaccount.c	afd939b0b11d6aa01dce2f4ec8a02b9362d284b3
+++ finch/gntaccount.c	435ca1f5d9c19b704338e273d3cd5db4253e68d1
@@ -125,7 +125,8 @@ save_account_cb(AccountEditDialog *dialo
 
 	if (value == NULL || *value == '\0')
 	{
-		purple_notify_error(NULL, _("Error"), _("Account was not added"),
+		purple_notify_error(NULL, _("Error"),
+				dialog->account ? _("Account was not modified") : _("Account was not added"),
 				_("Username of an account must be non-empty."));
 		return;
 	}
@@ -160,8 +161,28 @@ save_account_cb(AccountEditDialog *dialo
 		account = dialog->account;
 
 		/* Protocol */
-		purple_account_set_protocol_id(account, purple_plugin_get_id(plugin));
-		purple_account_set_username(account, username->str);
+		if (purple_account_is_disconnected(account)) {
+			purple_account_set_protocol_id(account, purple_plugin_get_id(plugin));
+			purple_account_set_username(account, username->str);
+		} else {
+			const char *old = purple_account_get_protocol_id(account);
+			char *oldprpl;
+			if (strcmp(old, purple_plugin_get_id(plugin))) {
+				purple_notify_error(NULL, _("Error"), _("Account was not modified"),
+						_("The account's protocol cannot be changed while it is connected to the server."));
+				return;
+			}
+
+			oldprpl = g_strdup(purple_normalize(account, purple_account_get_username(account)));
+			if (g_utf8_collate(oldprpl, purple_normalize(account, username->str))) {
+				purple_notify_error(NULL, _("Error"), _("Account was not modified"),
+						_("The account's username cannot be changed while it is connected to the server."));
+				g_free(oldprpl);
+				return;
+			}
+			g_free(oldprpl);
+			purple_account_set_username(account, username->str);
+		}
 	}
 	g_string_free(username, TRUE);
 
@@ -245,6 +266,17 @@ save_account_cb(AccountEditDialog *dialo
 		}
 	}
 
+	/* In case of a new account, the 'Accounts' window is updated from the account-added
+	 * callback. In case of changes in an existing account, we need to explicitly do it
+	 * here.
+	 */
+	if (dialog->account != NULL && accounts.window) {
+		gnt_tree_change_text(GNT_TREE(accounts.tree), dialog->account,
+				0, purple_account_get_username(dialog->account));
+		gnt_tree_change_text(GNT_TREE(accounts.tree), dialog->account,
+				1, purple_account_get_protocol_name(dialog->account));
+	}
+
 	gnt_widget_destroy(dialog->window);
 }
 
@@ -603,7 +635,7 @@ edit_account(PurpleAccount *account)
 	button = gnt_button_new(_("Cancel"));
 	gnt_box_add_widget(GNT_BOX(hbox), button);
 	g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window);
-	
+
 	button = gnt_button_new(_("Save"));
 	gnt_box_add_widget(GNT_BOX(hbox), button);
 	g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(save_account_cb), dialog);


More information about the Commits mailing list