pidgin.next.minor: 8086f2cf: This patch from Jaywalker enables text t...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Wed Apr 30 01:45:50 EDT 2008


-----------------------------------------------------------------
Revision: 8086f2cffaab6ed17431381836b9227a64a53270
Ancestor: 86658ba4e6c0791a427102c9612b41a665bd2a06
Author: rekkanoryo at pidgin.im
Date: 2008-04-30T03:24:35
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/8086f2cffaab6ed17431381836b9227a64a53270

Modified files:
        libpurple/protocols/msn/msn.c
        libpurple/protocols/msnp9/msn.c
        libpurple/protocols/myspace/myspace.c libpurple/prpl.h
        pidgin/gtkaccount.c

ChangeLog: 

This patch from Jaywalker enables text to appear in the screen name entry box.
This text is intended to be helpful and let the user know what to enter.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msn.c	6ce042f757eef19bfda47427cb21f176131e14bd
+++ libpurple/protocols/msn/msn.c	bbeeed30805a3fcac1562d5cb4c6f6df5aeb873f
@@ -132,6 +132,9 @@ msn_attention_types(PurpleAccount *accou
 	return list;
 }
 
+const char *msn_get_login_label() {
+	return _("E-mail Address...");
+}
 
 static PurpleCmdRet
 msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data)
@@ -2306,9 +2309,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* unregister_user */
 	msn_send_attention,                     /* send_attention */
 	msn_attention_types,                    /* attention_types */
-
-	/* padding */
-	NULL
+	msn_get_login_label			/* account_login_label */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/msnp9/msn.c	bb0278b1641ea4342d88d96c226b19562000c8fe
+++ libpurple/protocols/msnp9/msn.c	81c303657f22b0c165b34a1c8ec1ee7aca476670
@@ -134,6 +134,10 @@ msn_attention_types(PurpleAccount *accou
 }
 
 
+const char *msn_get_login_label() {
+	return _("E-mail Address...");
+}
+
 static PurpleCmdRet
 msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data)
 {
@@ -2147,9 +2151,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* unregister_user */
 	msn_send_attention,                     /* send_attention */
 	msn_attention_types,                    /* attention_types */
-
-	/* padding */
-	NULL
+	msn_get_login_label			/* account_login_label */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/myspace/myspace.c	2bb03dbf1f14bd88735ed083293d0723f893db82
+++ libpurple/protocols/myspace/myspace.c	2b9a44b140569fdd1d658d122e4216f5abaaf72d
@@ -2449,6 +2449,10 @@ const char *msim_normalize(const PurpleA
 	return normalized;
 }
 
+const char *msim_get_login_label() {
+	return _("E-mail Address...");
+}
+
 /** Return whether the buddy can be messaged while offline.
  *
  * The protocol supports offline messages in just the same way as online
@@ -3131,7 +3135,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,                  /* unregister_user */
 	msim_send_attention,   /* send_attention */
 	msim_attention_types,  /* attention_types */
-	NULL                /* _purple_reserved4 */
+	msim_get_login_label /* get screen name field title */
 };
 
 
============================================================
--- libpurple/prpl.h	efd045aa1c1a4a44959d513dbb3aa5dee4d5a5e2
+++ libpurple/prpl.h	b58e091cb58e9cfb723b022a482f413d24e5be38
@@ -398,7 +398,11 @@ struct _PurplePluginProtocolInfo
 	gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
 	GList *(*get_attention_types)(PurpleAccount *acct);
 
-	void (*_purple_reserved4)(void);
+	/* This allows protocols to specify a more specific term for the "ScreenName" field
+	 * in the add account window. This helps avoid confusion for users using protocols
+	 * such as MySpace or MSN
+	 */
+	const char *(*account_login_label)(void);
 };
 
 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \
============================================================
--- pidgin/gtkaccount.c	eab593e665e6425c44421c59170ecfbc811cdcfb
+++ pidgin/gtkaccount.c	b6ee355b36da4f62e58dad1dabc863c2d30051d2
@@ -255,6 +255,16 @@ set_account_protocol_cb(GtkWidget *item,
 	}
 }
 
+static gboolean
+screenname_focus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog)
+{
+	if (!strcmp(gtk_entry_get_text(GTK_ENTRY(widget)),dialog->prpl_info->account_login_label())) {
+		gtk_entry_set_text(GTK_ENTRY(widget),"");
+		gtk_widget_modify_text(widget,GTK_STATE_NORMAL,NULL);
+	}
+	return FALSE;
+}
+
 static void
 screenname_changed_cb(GtkEntry *entry, AccountPrefsDialog *dialog)
 {
@@ -270,6 +280,23 @@ screenname_changed_cb(GtkEntry *entry, A
 	}
 }
 
+static gboolean
+screenname_nofocus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog)
+{
+	GdkColor color = {0, 34952, 35466, 34181};
+	if (*gtk_entry_get_text(GTK_ENTRY(widget)) == '\0') {
+		/* We have to avoid hitting the screenname_changed_cb function 
+		 * because it enables buttons we don't want enabled yet ;)
+		 */
+		g_signal_handlers_block_by_func(widget, G_CALLBACK(screenname_changed_cb), dialog);
+		gtk_entry_set_text(GTK_ENTRY(widget),dialog->prpl_info->account_login_label());
+		/* Make sure we can hit it again */
+		g_signal_handlers_unblock_by_func(widget, G_CALLBACK(screenname_changed_cb), dialog);
+		gtk_widget_modify_text(widget,GTK_STATE_NORMAL,&color);
+	}
+	return FALSE;
+}
+
 static void
 icon_filesel_choose_cb(const char *filename, gpointer data)
 {
@@ -364,6 +391,7 @@ add_login_options(AccountPrefsDialog *di
 	GList *user_splits;
 	GList *l, *l2;
 	char *username = NULL;
+	GdkColor color = {0, 34952, 35466, 34181};
 
 	if (dialog->protocol_menu != NULL)
 	{
@@ -410,6 +438,15 @@ add_login_options(AccountPrefsDialog *di
 
 	add_pref_box(dialog, vbox, _("Screen _name:"), dialog->screenname_entry);
 
+	if (dialog->prpl_info->account_login_label) {
+		gtk_entry_set_text(dialog->screenname_entry,dialog->prpl_info->account_login_label());
+		g_signal_connect(G_OBJECT(dialog->screenname_entry), "focus-in-event",
+						G_CALLBACK(screenname_focus_cb), dialog);
+		g_signal_connect(G_OBJECT(dialog->screenname_entry), "focus-out-event",
+						G_CALLBACK(screenname_nofocus_cb), dialog);
+		gtk_widget_modify_text(dialog->screenname_entry,GTK_STATE_NORMAL,&color);
+	}
+
 	g_signal_connect(G_OBJECT(dialog->screenname_entry), "changed",
 					 G_CALLBACK(screenname_changed_cb), dialog);
 


More information about the Commits mailing list