# HG changeset patch # User Sadrul Habib Chowdhury # Date 1209970500 0 # Node ID bb41bdce8981414ee6794dfdbbfa00f44003ca5f # Parent 718a9c28783964c77212108deb3b3fe32dc8fac6 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. diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/bonjour/bonjour.c --- a/libpurple/protocols/bonjour/bonjour.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/bonjour/bonjour.c Mon May 05 06:55:00 2008 +0000 @@ -488,6 +488,7 @@ NULL, NULL, sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static PurplePluginInfo info = diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/gg/gg.c --- a/libpurple/protocols/gg/gg.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/gg/gg.c Mon May 05 06:55:00 2008 +0000 @@ -2153,6 +2153,7 @@ NULL, NULL, sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; /* }}} */ diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/irc/irc.c --- a/libpurple/protocols/irc/irc.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/irc/irc.c Mon May 05 06:55:00 2008 +0000 @@ -906,6 +906,7 @@ NULL, NULL, sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static gboolean load_plugin (PurplePlugin *plugin) { diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/jabber/libxmpp.c --- a/libpurple/protocols/jabber/libxmpp.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/jabber/libxmpp.c Mon May 05 06:55:00 2008 +0000 @@ -117,6 +117,7 @@ jabber_attention_types, /* attention_types */ sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static gboolean load_plugin(PurplePlugin *plugin) diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/msn/msn.c --- a/libpurple/protocols/msn/msn.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/msn/msn.c Mon May 05 06:55:00 2008 +0000 @@ -132,6 +132,18 @@ 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 @@ msn_attention_types, /* attention_types */ sizeof(PurplePluginProtocolInfo), /* struct_size */ + msn_get_account_text_table, /* get_account_text_table */ }; static PurplePluginInfo info = diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/msnp9/msn.c --- a/libpurple/protocols/msnp9/msn.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/msnp9/msn.c Mon May 05 06:55:00 2008 +0000 @@ -133,6 +133,18 @@ 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 @@ msn_attention_types, /* attention_types */ sizeof(PurplePluginProtocolInfo), /* struct_size */ + msn_get_account_text_table, /* get_account_text_table */ }; static PurplePluginInfo info = diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/myspace/myspace.c --- a/libpurple/protocols/myspace/myspace.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/myspace/myspace.c Mon May 05 06:55:00 2008 +0000 @@ -2449,6 +2449,18 @@ 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 @@ msim_attention_types, /* attention_types */ sizeof(PurplePluginProtocolInfo), /* struct_size */ + msim_get_account_text_table, /* get_account_text_table */ }; diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/novell/novell.c --- a/libpurple/protocols/novell/novell.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/novell/novell.c Mon May 05 06:55:00 2008 +0000 @@ -3518,6 +3518,7 @@ NULL, NULL, sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static PurplePluginInfo info = { diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/oscar/libaim.c --- a/libpurple/protocols/oscar/libaim.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/oscar/libaim.c Mon May 05 06:55:00 2008 +0000 @@ -97,6 +97,7 @@ NULL, /* get_attention_types */ sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static PurplePluginInfo info = diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/oscar/libicq.c --- a/libpurple/protocols/oscar/libicq.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/oscar/libicq.c Mon May 05 06:55:00 2008 +0000 @@ -97,6 +97,7 @@ NULL, /* get_attention_types */ sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static PurplePluginInfo info = diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/qq/qq.c --- a/libpurple/protocols/qq/qq.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/qq/qq.c Mon May 05 06:55:00 2008 +0000 @@ -707,6 +707,7 @@ NULL, NULL, sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static PurplePluginInfo info = { diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/silc/silc.c --- a/libpurple/protocols/silc/silc.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/silc/silc.c Mon May 05 06:55:00 2008 +0000 @@ -2072,6 +2072,7 @@ NULL, NULL, sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static PurplePluginInfo info = diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/silc10/silc.c --- a/libpurple/protocols/silc10/silc.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/silc10/silc.c Mon May 05 06:55:00 2008 +0000 @@ -1804,6 +1804,7 @@ NULL, NULL, sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static PurplePluginInfo info = diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/simple/simple.c --- a/libpurple/protocols/simple/simple.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/simple/simple.c Mon May 05 06:55:00 2008 +0000 @@ -2053,6 +2053,7 @@ NULL, NULL, sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/yahoo/yahoo.c --- a/libpurple/protocols/yahoo/yahoo.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/yahoo/yahoo.c Mon May 05 06:55:00 2008 +0000 @@ -4380,6 +4380,7 @@ yahoo_attention_types, sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static PurplePluginInfo info = diff -r 718a9c287839 -r bb41bdce8981 libpurple/protocols/zephyr/zephyr.c --- a/libpurple/protocols/zephyr/zephyr.c Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/protocols/zephyr/zephyr.c Mon May 05 06:55:00 2008 +0000 @@ -2911,6 +2911,7 @@ NULL, NULL, sizeof(PurplePluginProtocolInfo), /* struct_size */ + NULL }; static PurplePluginInfo info = { diff -r 718a9c287839 -r bb41bdce8981 libpurple/prpl.h --- a/libpurple/prpl.h Mon May 05 06:19:46 2008 +0000 +++ b/libpurple/prpl.h Mon May 05 06:55:00 2008 +0000 @@ -418,6 +418,17 @@ * 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) \ diff -r 718a9c287839 -r bb41bdce8981 pidgin/gtkaccount.c --- a/pidgin/gtkaccount.c Mon May 05 06:19:46 2008 +0000 +++ b/pidgin/gtkaccount.c Mon May 05 06:55:00 2008 +0000 @@ -255,6 +255,25 @@ } } +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 @@ } } +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_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 @@ 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 @@ /* Show the window. */ gtk_widget_show(win); + if (!account) + gtk_widget_grab_focus(dialog->protocol_menu); } /**************************************************************************