/soc/2012/tomkiewicz/gg: f1e52c746ecf: Merge pidgin-gtk fixes fo...
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Thu Jul 5 13:31:52 EDT 2012
Changeset: f1e52c746ecf00aedd2d7177899cf24d286f19d8
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2012-06-29 16:45 +0200
Branch: soc.2012.gg
URL: http://hg.pidgin.im/soc/2012/tomkiewicz/gg/rev/f1e52c746ecf
Description:
Merge pidgin-gtk fixes for account registration and request api
diffstat:
pidgin/gtkaccount.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++--
pidgin/gtkrequest.c | 7 +++++
2 files changed, 68 insertions(+), 3 deletions(-)
diffs (141 lines):
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -248,12 +248,16 @@
gtk_widget_grab_focus(dialog->protocol_menu);
if (!dialog->prpl_info || !dialog->prpl_info->register_user) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
+ dialog->register_button), FALSE);
gtk_widget_hide(dialog->register_button);
} else {
if (dialog->prpl_info != NULL &&
(dialog->prpl_info->options & OPT_PROTO_REGISTER_NOSCREENNAME)) {
gtk_widget_set_sensitive(dialog->register_button, TRUE);
} else {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
+ dialog->register_button), FALSE);
gtk_widget_set_sensitive(dialog->register_button, FALSE);
}
gtk_widget_show(dialog->register_button);
@@ -282,11 +286,20 @@
static void
username_changed_cb(GtkEntry *entry, AccountPrefsDialog *dialog)
{
- if (dialog->ok_button)
- gtk_widget_set_sensitive(dialog->ok_button,
+ int opt_noscreenname = (dialog->prpl_info != NULL &&
+ (dialog->prpl_info->options & OPT_PROTO_REGISTER_NOSCREENNAME));
+
+ if (dialog->ok_button) {
+ if (opt_noscreenname && dialog->register_button &&
+ gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(dialog->register_button)))
+ gtk_widget_set_sensitive(dialog->ok_button, TRUE);
+ else
+ gtk_widget_set_sensitive(dialog->ok_button,
*gtk_entry_get_text(entry) != '\0');
+ }
if (dialog->register_button) {
- if (dialog->prpl_info != NULL && (dialog->prpl_info->options & OPT_PROTO_REGISTER_NOSCREENNAME))
+ if (opt_noscreenname)
gtk_widget_set_sensitive(dialog->register_button, TRUE);
else
gtk_widget_set_sensitive(dialog->register_button,
@@ -294,6 +307,32 @@
}
}
+static void
+register_button_cb(GtkWidget *checkbox, AccountPrefsDialog *dialog)
+{
+ int register_checked = gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(dialog->register_button));
+ int opt_noscreenname = (dialog->prpl_info != NULL &&
+ (dialog->prpl_info->options & OPT_PROTO_REGISTER_NOSCREENNAME));
+ int register_noscreenname = (opt_noscreenname && register_checked);
+
+ if (register_noscreenname) {
+ gtk_entry_set_text(GTK_ENTRY(dialog->username_entry), "");
+ gtk_entry_set_text(GTK_ENTRY(dialog->password_entry), "");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->remember_pass_check), FALSE);
+ }
+ gtk_widget_set_sensitive(dialog->username_entry, !register_noscreenname);
+ gtk_widget_set_sensitive(dialog->password_entry, !register_noscreenname);
+ gtk_widget_set_sensitive(dialog->remember_pass_check, !register_noscreenname);
+
+ if (dialog->ok_button) {
+ gtk_widget_set_sensitive(dialog->ok_button,
+ (opt_noscreenname && register_checked) ||
+ *gtk_entry_get_text(GTK_ENTRY(dialog->username_entry))
+ != '\0');
+ }
+}
+
static gboolean
username_nofocus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog)
{
@@ -1237,6 +1276,23 @@
}
static void
+account_register_cb(PurpleAccount *account, gboolean succeeded, void *user_data)
+{
+ if (succeeded)
+ {
+ const PurpleSavedStatus *saved_status = purple_savedstatus_get_current();
+ purple_signal_emit(pidgin_account_get_handle(), "account-modified", account);
+
+ if (saved_status != NULL && purple_account_get_remember_password(account)) {
+ purple_savedstatus_activate_for_account(saved_status, account);
+ purple_account_set_enabled(account, PIDGIN_UI, TRUE);
+ }
+ }
+ else
+ purple_accounts_delete(account);
+}
+
+static void
ok_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog)
{
PurpleProxyInfo *proxy_info = NULL;
@@ -1489,6 +1545,7 @@
/* If this is a new account, then sign on! */
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->register_button))) {
+ purple_account_set_register_callback(account, account_register_cb, NULL);
purple_account_register(account);
} else if (new_acct) {
const PurpleSavedStatus *saved_status;
@@ -1585,6 +1642,7 @@
gtk_box_pack_start(GTK_BOX(main_vbox), button, FALSE, FALSE, 0);
gtk_widget_show(button);
dialog->register_button = button;
+ g_signal_connect(G_OBJECT(dialog->register_button), "toggled", G_CALLBACK(register_button_cb), dialog);
if (dialog->account == NULL)
gtk_widget_set_sensitive(button, FALSE);
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -341,6 +341,11 @@
return text;
}
+static void stop_emission_cb(GtkDialog *dialog, const gchar *signal_name)
+{
+ gtk_signal_emit_stop_by_name(GTK_OBJECT(dialog), signal_name);
+}
+
static void *
pidgin_request_input(const char *title, const char *primary,
const char *secondary, const char *default_value,
@@ -655,6 +660,8 @@
data->dialog = dialog = gtk_dialog_new();
gtk_window_set_deletable(GTK_WINDOW(data->dialog), FALSE);
+ g_signal_connect(G_OBJECT(dialog), "close",
+ G_CALLBACK(stop_emission_cb), "close");
if (title != NULL)
gtk_window_set_title(GTK_WINDOW(dialog), title);
More information about the Commits
mailing list