/pidgin/main: 777039ec6a98: Use the builtin placeholder function...

Elliott Sales de Andrade qulogic at pidgin.im
Sun Jan 27 05:57:51 EST 2013


Changeset: 777039ec6a988144f023892ba93219c8e46f57ad
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2013-01-27 05:57 -0500
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/777039ec6a98

Description:

Use the builtin placeholder function on GTK3.2.

diffstat:

 pidgin/gtkaccount.c |  129 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 70 insertions(+), 59 deletions(-)

diffs (174 lines):

diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -271,34 +271,6 @@ set_account_protocol_cb(GtkWidget *widge
 	}
 }
 
-static gboolean
-username_focus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog)
-{
-	GHashTable *table;
-	const char *label;
-
-	if (!dialog->prpl_info || ! PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(
-		dialog->prpl_info, get_account_text_table)) {
-		return FALSE;
-	}
-
-	table = dialog->prpl_info->get_account_text_table(NULL);
-	label = g_hash_table_lookup(table, "login_label");
-
-	if(!strcmp(gtk_entry_get_text(GTK_ENTRY(widget)), label)) {
-		gtk_entry_set_text(GTK_ENTRY(widget), "");
-#if GTK_CHECK_VERSION(3,0,0)
-		gtk_widget_override_color(widget, GTK_STATE_NORMAL, NULL);
-#else
-		gtk_widget_modify_text(widget, GTK_STATE_NORMAL,NULL);
-#endif
-	}
-
-	g_hash_table_destroy(table);
-
-	return FALSE;
-}
-
 static void
 username_changed_cb(GtkEntry *entry, AccountPrefsDialog *dialog)
 {
@@ -326,6 +298,35 @@ username_changed_cb(GtkEntry *entry, Acc
 	}
 }
 
+#if !GTK_CHECK_VERSION(3,2,0)
+static gboolean
+username_focus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog)
+{
+	GHashTable *table;
+	const char *label;
+
+	if (!dialog->prpl_info || ! PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(
+		dialog->prpl_info, get_account_text_table)) {
+		return FALSE;
+	}
+
+	table = dialog->prpl_info->get_account_text_table(NULL);
+	label = g_hash_table_lookup(table, "login_label");
+
+	if(!strcmp(gtk_entry_get_text(GTK_ENTRY(widget)), label)) {
+		gtk_entry_set_text(GTK_ENTRY(widget), "");
+#if GTK_CHECK_VERSION(3,0,0)
+		gtk_widget_override_color(widget, GTK_STATE_NORMAL, NULL);
+#else
+		gtk_widget_modify_text(widget, GTK_STATE_NORMAL,NULL);
+#endif
+	}
+
+	g_hash_table_destroy(table);
+
+	return FALSE;
+}
+
 static gboolean
 username_nofocus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog)
 {
@@ -357,37 +358,6 @@ username_nofocus_cb(GtkWidget *widget, G
 	return FALSE;
 }
 
-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);
-
-	/* get rid of login_label in username field */
-	username_focus_cb(dialog->username_entry, NULL, dialog);
-
-	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');
-	}
-
-	username_nofocus_cb(dialog->username_entry, NULL, dialog);
-}
-
 static gboolean
 username_themechange_cb(GObject *widget, GdkEventFocus *event, AccountPrefsDialog *dialog)
 {
@@ -464,6 +434,42 @@ username_themechange_cb(GObject *widget,
 
 	return FALSE;
 }
+#endif
+
+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 !GTK_CHECK_VERSION(3,2,0)
+	/* get rid of login_label in username field */
+	username_focus_cb(dialog->username_entry, NULL, dialog);
+#endif
+
+	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');
+	}
+
+#if !GTK_CHECK_VERSION(3,2,0)
+	username_nofocus_cb(dialog->username_entry, NULL, dialog);
+#endif
+}
 
 static void
 icon_filesel_choose_cb(const char *filename, gpointer data)
@@ -625,6 +631,9 @@ add_login_options(AccountPrefsDialog *di
 		table = dialog->prpl_info->get_account_text_table(NULL);
 		label = g_hash_table_lookup(table, "login_label");
 
+#if GTK_CHECK_VERSION(3,2,0)
+		gtk_entry_set_placeholder_text(GTK_ENTRY(dialog->username_entry), label);
+#else
 		gtk_entry_set_text(GTK_ENTRY(dialog->username_entry), label);
 		username_themechange_cb(G_OBJECT(dialog->username_entry), NULL, dialog);
 		g_signal_connect(G_OBJECT(dialog->username_entry), "style-set",
@@ -633,6 +642,8 @@ add_login_options(AccountPrefsDialog *di
 				G_CALLBACK(username_focus_cb), dialog);
 		g_signal_connect(G_OBJECT(dialog->username_entry), "focus-out-event",
 				G_CALLBACK(username_nofocus_cb), dialog);
+#endif
+
 		g_hash_table_destroy(table);
 	}
 



More information about the Commits mailing list