pidgin.next.minor: b6f1c6f2: Patch from Jaywalker to let prpls add so...

sadrul at pidgin.im sadrul at pidgin.im
Mon May 5 03:00:43 EDT 2008


-----------------------------------------------------------------
Revision: b6f1c6f279a87ac4b59426eea116c349eb31fe8c
Ancestor: f00a8560ccde5ca23be0911c55f8914f49e80c41
Author: sadrul at pidgin.im
Date: 2008-05-05T06:55:00
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/b6f1c6f279a87ac4b59426eea116c349eb31fe8c

Modified files:
        libpurple/protocols/bonjour/bonjour.c
        libpurple/protocols/gg/gg.c libpurple/protocols/irc/irc.c
        libpurple/protocols/jabber/libxmpp.c
        libpurple/protocols/msn/msn.c
        libpurple/protocols/msnp9/msn.c
        libpurple/protocols/myspace/myspace.c
        libpurple/protocols/novell/novell.c
        libpurple/protocols/oscar/libaim.c
        libpurple/protocols/oscar/libicq.c
        libpurple/protocols/qq/qq.c libpurple/protocols/silc/silc.c
        libpurple/protocols/silc10/silc.c
        libpurple/protocols/simple/simple.c
        libpurple/protocols/yahoo/yahoo.c
        libpurple/protocols/zephyr/zephyr.c libpurple/prpl.h
        pidgin/gtkaccount.c

ChangeLog: 

Patch from Jaywalker to let prpls add some helpful text for some account
fields. This includes the update from rekkanoryo that was reverted
earlier. References #2295.

-------------- next part --------------
============================================================
--- libpurple/protocols/bonjour/bonjour.c	13245405017177d9885cae94bda3cf90bf6b5208
+++ libpurple/protocols/bonjour/bonjour.c	0d2d2e4278d99e72c48f3f1edd5becb8675d0e31
@@ -488,6 +488,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/gg/gg.c	dafe006e5617133688c37cce4726f0addba6c361
+++ libpurple/protocols/gg/gg.c	2944ce2bf9dbf0b072a57eca9333c2ae4f3ddd37
@@ -2153,6 +2153,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 /* }}} */
 
============================================================
--- libpurple/protocols/irc/irc.c	639a3020e6bee9ce478599c3bb264939c5d65ed3
+++ libpurple/protocols/irc/irc.c	732b4b16ee047cf87887690d45dce55f6325bab2
@@ -906,6 +906,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static gboolean load_plugin (PurplePlugin *plugin) {
============================================================
--- libpurple/protocols/jabber/libxmpp.c	212c0b80176674a2a28246a348d7d73be6cf44f8
+++ libpurple/protocols/jabber/libxmpp.c	b56db1a878a32e93e80e36ccaa343dc7422f18cf
@@ -117,6 +117,7 @@ static PurplePluginProtocolInfo prpl_inf
 	jabber_attention_types,			/* attention_types */
 
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static gboolean load_plugin(PurplePlugin *plugin)
============================================================
--- libpurple/protocols/msn/msn.c	057e82fed61293c7a02de9257fcd12ceb9e20d2c
+++ libpurple/protocols/msn/msn.c	8f40f66791a86937b9253b95f6b54903d0b52662
@@ -132,6 +132,18 @@ msn_attention_types(PurpleAccount *accou
 	return list;
 }
 
+static GHashTable *
+msn_get_account_text_table(PurpleAccount *unused)
+{
+	GHashTable *table;
+
+	table = g_hash_table_new(g_str_hash, g_str_equal);
+
+	g_hash_table_insert(table, "login_label", (gpointer)_("E-mail Address..."));
+
+	return table;
+}
+
 static PurpleCmdRet
 msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data)
 {
@@ -2307,6 +2319,7 @@ static PurplePluginProtocolInfo prpl_inf
 	msn_attention_types,                    /* attention_types */
 
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	msn_get_account_text_table,             /* get_account_text_table */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/msnp9/msn.c	745f523b052dd2b2c3166e539832002c6df6e836
+++ libpurple/protocols/msnp9/msn.c	fdf0fe8604124a8e5013542a0c592d75ba55074e
@@ -133,6 +133,18 @@ msn_attention_types(PurpleAccount *accou
 	return list;
 }
 
+static GHashTable *
+msn_get_account_text_table(PurpleAccount *unused)
+{
+	GHashTable *table;
+
+	table = g_hash_table_new(g_str_hash, g_str_equal);
+
+	g_hash_table_insert(table, "login_label", (gpointer)_("E-mail Address..."));
+
+	return table;
+}
+
 static PurpleCmdRet
 msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data)
 {
@@ -2148,6 +2160,7 @@ static PurplePluginProtocolInfo prpl_inf
 	msn_attention_types,                    /* attention_types */
 
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	msn_get_account_text_table,             /* get_account_text_table */
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/myspace/myspace.c	4fbe9a01c821b95a906c43c36aa55d7f38045eb0
+++ libpurple/protocols/myspace/myspace.c	fb3da3d3e749904065f0f15492f704a0dc0f7646
@@ -2449,6 +2449,18 @@ const char *msim_normalize(const PurpleA
 	return normalized;
 }
 
+static GHashTable *
+msim_get_account_text_table(PurpleAccount *unused)
+{
+	GHashTable *table;
+
+	table = g_hash_table_new(g_str_hash, g_str_equal);
+
+	g_hash_table_insert(table, "login_label", (gpointer)_("E-mail Address..."));
+
+	return table;
+}
+
 /** Return whether the buddy can be messaged while offline.
  *
  * The protocol supports offline messages in just the same way as online
@@ -3133,6 +3145,7 @@ static PurplePluginProtocolInfo prpl_inf
 	msim_attention_types,  /* attention_types */
 
 	sizeof(PurplePluginProtocolInfo),  /* struct_size */
+	msim_get_account_text_table,              /* get_account_text_table */
 };
 
 
============================================================
--- libpurple/protocols/novell/novell.c	94c2831474b1518525f963406ee4516e34f0c11a
+++ libpurple/protocols/novell/novell.c	5c56264a340ff8f1604c32aff7f2224a25a5578a
@@ -3518,6 +3518,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static PurplePluginInfo info = {
============================================================
--- libpurple/protocols/oscar/libaim.c	3d4692b5e16532de368166642f44d20b11cbab75
+++ libpurple/protocols/oscar/libaim.c	d0df81e6eb6e44f1dffec69caf6fb3f88b1b25c6
@@ -97,6 +97,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* get_attention_types */
 
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/oscar/libicq.c	c2832fe4c3cdf20ce2bf5ee21a6b70a3be4aabb7
+++ libpurple/protocols/oscar/libicq.c	59744e847a4acd44d59f26ce7c5c1c38fae0fa62
@@ -97,6 +97,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* get_attention_types */
 
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/qq/qq.c	2ec3f27b766abfc994de6e5f3893f788ab7293ed
+++ libpurple/protocols/qq/qq.c	99f29644298f405b9f401f9bd126caf23df1495d
@@ -707,6 +707,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static PurplePluginInfo info = {
============================================================
--- libpurple/protocols/silc/silc.c	e025d0819c9b22cd9b945c29bc0623972814e1ea
+++ libpurple/protocols/silc/silc.c	bbb78beffb443bee34a61b7f7aa447a862ab1368
@@ -2072,6 +2072,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/silc10/silc.c	0a36b7eff1245d3097a1f24668330b9822311766
+++ libpurple/protocols/silc10/silc.c	8b8979c84bb85d01cd0951d1c1612ed0a8fb05e7
@@ -1804,6 +1804,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/simple/simple.c	df0f752b93c5362ee704ab32b4fccbcfcab17228
+++ libpurple/protocols/simple/simple.c	b0b268cac4620db012866d7da56b829b74d61fc5
@@ -2053,6 +2053,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 
============================================================
--- libpurple/protocols/yahoo/yahoo.c	87031baac3e3858fca2dca3232ec22d446640bce
+++ libpurple/protocols/yahoo/yahoo.c	d44feaafad279fb6f9c00ba6a4a1064271771e6c
@@ -4380,6 +4380,7 @@ static PurplePluginProtocolInfo prpl_inf
 	yahoo_attention_types,
 
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static PurplePluginInfo info =
============================================================
--- libpurple/protocols/zephyr/zephyr.c	7c7efe0bcd099c5ba907777a2467457399cdd6be
+++ libpurple/protocols/zephyr/zephyr.c	46d9fa4b7205eb47aa18662ec98afd0bed0033ee
@@ -2911,6 +2911,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
+	NULL
 };
 
 static PurplePluginInfo info = {
============================================================
--- libpurple/prpl.h	a4cb4e4f413855f35d133eaa3e59d7a22bc0ac78
+++ libpurple/prpl.h	26c37416cf9cbfcc3313e8672725d4e93bee2e75
@@ -418,6 +418,17 @@ struct _PurplePluginProtocolInfo
 	 * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
 	 * functions (e.g. login, send_im etc.) too.
 	 */
+
+	/** This allows protocols to specify additional strings to be used for
+	 * various purposes.  The idea is to stuff a bunch of strings in this hash
+	 * table instead of expanding the struct for every addition.  This hash
+	 * table is allocated every call and MUST be unrefed by the caller.
+	 *
+	 * @param account The account to specify.  This can be NULL.
+	 * @return The protocol's string hash table. The hash table should be
+	 *         destroyed by the caller when it's no longer needed.
+	 */
+	GHashTable *(*get_account_text_table)(PurpleAccount *account);
 };
 
 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
============================================================
--- pidgin/gtkaccount.c	e961febeca7e5acc8270f578b5f108414d67a4bb
+++ pidgin/gtkaccount.c	ca0beb9e5fbfa85d85b84186caf8cb66f31f3841
@@ -255,6 +255,25 @@ set_account_protocol_cb(GtkWidget *item,
 	}
 }
 
+static gboolean
+screenname_focus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog)
+{
+	GHashTable *table;
+	const char *label;
+
+	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), "");
+		gtk_widget_modify_text(widget, GTK_STATE_NORMAL,NULL);
+	}
+
+	g_hash_table_destroy(table);
+
+	return FALSE;
+}
+
 static void
 screenname_changed_cb(GtkEntry *entry, AccountPrefsDialog *dialog)
 {
@@ -270,6 +289,32 @@ screenname_changed_cb(GtkEntry *entry, A
 	}
 }
 
+static gboolean
+screenname_nofocus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog)
+{
+	GdkColor color = {0, 34952, 35466, 34181};
+	GHashTable *table;
+	const char *label;
+
+	table = dialog->prpl_info->get_account_text_table(NULL);
+	label = g_hash_table_lookup(table, "login_label");
+
+	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), 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);
+	}
+
+	g_hash_table_destroy(table);
+
+	return FALSE;
+}
+
 static void
 icon_filesel_choose_cb(const char *filename, gpointer data)
 {
@@ -410,6 +455,25 @@ add_login_options(AccountPrefsDialog *di
 
 	add_pref_box(dialog, vbox, _("Screen _name:"), dialog->screenname_entry);
 
+	if (dialog->account != NULL)
+		username = g_strdup(purple_account_get_username(dialog->account));
+
+	if (!username && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(dialog->prpl_info, get_account_text_table)) {
+		GdkColor color = {0, 34952, 35466, 34181};
+		GHashTable *table;
+		const char *label;
+		table = dialog->prpl_info->get_account_text_table(NULL);
+		label = g_hash_table_lookup(table, "login_label");
+
+		gtk_entry_set_text(GTK_ENTRY(dialog->screenname_entry), 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_hash_table_destroy(table);
+	}
+
 	g_signal_connect(G_OBJECT(dialog->screenname_entry), "changed",
 					 G_CALLBACK(screenname_changed_cb), dialog);
 
@@ -419,9 +483,6 @@ add_login_options(AccountPrefsDialog *di
 	else
 		user_splits = dialog->prpl_info->user_splits;
 
-	if (dialog->account != NULL)
-		username = g_strdup(purple_account_get_username(dialog->account));
-
 	if (dialog->user_split_entries != NULL) {
 		g_list_free(dialog->user_split_entries);
 		dialog->user_split_entries = NULL;
@@ -1513,6 +1574,8 @@ pidgin_account_dialog_show(PidginAccount
 
 	/* Show the window. */
 	gtk_widget_show(win);
+	if (!account)
+		gtk_widget_grab_focus(dialog->protocol_menu);
 }
 
 /**************************************************************************


More information about the Commits mailing list