diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c --- a/libpurple/protocols/gg/gg.c +++ b/libpurple/protocols/gg/gg.c @@ -2128,6 +2128,7 @@ GHashTable *table; table = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_insert(table, "login_label", (gpointer)_("GG number...")); + g_hash_table_insert(table, "buddy_username_label", (gpointer)_("GG n_umber:")); return table; } diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c --- a/libpurple/protocols/msn/msn.c +++ b/libpurple/protocols/msn/msn.c @@ -149,6 +149,7 @@ table = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_insert(table, "login_label", (gpointer)_("Email Address...")); + g_hash_table_insert(table, "buddy_username_label", (gpointer)_("Email Address:")); return table; } diff --git a/libpurple/protocols/mxit/mxit.c b/libpurple/protocols/mxit/mxit.c --- a/libpurple/protocols/mxit/mxit.c +++ b/libpurple/protocols/mxit/mxit.c @@ -597,6 +597,7 @@ table = g_hash_table_new( g_str_hash, g_str_equal ); g_hash_table_insert( table, "login_label", (gpointer)_( "Your MXit ID..." ) ); + g_hash_table_insert( table, "buddy_username_label", (gpointer)_( "MXit ID:" ) ); return table; } diff --git a/libpurple/protocols/myspace/myspace.c b/libpurple/protocols/myspace/myspace.c --- a/libpurple/protocols/myspace/myspace.c +++ b/libpurple/protocols/myspace/myspace.c @@ -2999,6 +2999,7 @@ table = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_insert(table, "login_label", (gpointer)_("Email Address...")); + g_hash_table_insert(table, "buddy_username_label", (gpointer)_("Email Address:")); return table; } diff --git a/libpurple/protocols/oscar/libicq.c b/libpurple/protocols/oscar/libicq.c --- a/libpurple/protocols/oscar/libicq.c +++ b/libpurple/protocols/oscar/libicq.c @@ -33,6 +33,7 @@ GHashTable *table; table = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_insert(table, "login_label", (gpointer)_("ICQ UIN...")); + g_hash_table_insert(table, "buddy_username_label", (gpointer)_("ICQ _UIN:")); return table; } diff --git a/libpurple/protocols/yahoo/libyahoo.c b/libpurple/protocols/yahoo/libyahoo.c --- a/libpurple/protocols/yahoo/libyahoo.c +++ b/libpurple/protocols/yahoo/libyahoo.c @@ -164,6 +164,7 @@ GHashTable *table; table = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_insert(table, "login_label", (gpointer)_("Yahoo ID...")); + g_hash_table_insert(table, "buddy_username_label", (gpointer)_("Yahoo ID:")); return table; } diff --git a/libpurple/protocols/yahoo/libyahoojp.c b/libpurple/protocols/yahoo/libyahoojp.c --- a/libpurple/protocols/yahoo/libyahoojp.c +++ b/libpurple/protocols/yahoo/libyahoojp.c @@ -60,6 +60,7 @@ GHashTable *table; table = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_insert(table, "login_label", (gpointer)_("Yahoo JAPAN ID...")); + g_hash_table_insert(table, "buddy_username_label", (gpointer)_("Yahoo JAPAN ID:")); return table; } diff --git a/libpurple/prpl.c b/libpurple/prpl.c --- a/libpurple/prpl.c +++ b/libpurple/prpl.c @@ -646,3 +646,30 @@ return NULL; } + +gchar * purple_prpl_get_text(PurplePlugin *plugin, PurpleAccount *account, + const char *key) +{ + GHashTable *table; + const char *text; + PurplePluginProtocolInfo *prpl_info; + + g_return_val_if_fail(plugin != NULL || account != NULL, NULL); + g_return_val_if_fail(key != NULL, NULL); + + if (plugin == NULL) + plugin = purple_find_prpl( + purple_account_get_protocol_id(account)); + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); + + if (!PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_account_text_table)) + return NULL; + + table = prpl_info->get_account_text_table(account); + text = g_hash_table_lookup(table, key); + if (text != NULL) + text = g_strdup(text); + + g_hash_table_destroy(table); + return text; +} diff --git a/libpurple/prpl.h b/libpurple/prpl.h --- a/libpurple/prpl.h +++ b/libpurple/prpl.h @@ -947,6 +947,23 @@ */ PurplePlugin *purple_find_prpl(const char *id); +/** + * Lookups for string in account text table. + * + * At least @a plugin or @a account parameter must be supplied, returned pointer + * must be free'd with g_free. + * + * @param plugin The protocol plugin related to string. + * @param account The account related to string. + * @param key The string name to lookup. + * + * @return Found string (must be freed), or NULL, if it wasn't found. + * + * @see get_account_text_table + */ +gchar * purple_prpl_get_text(PurplePlugin *plugin, PurpleAccount *account, + const char *key); + /*@}*/ G_END_DECLS diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c --- a/pidgin/gtkaccount.c +++ b/pidgin/gtkaccount.c @@ -267,19 +267,14 @@ static gboolean username_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)) { + gchar *label = purple_prpl_get_text(dialog->plugin, NULL, "login_label"); + + if(label && !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); - + g_free(label); return FALSE; } @@ -311,13 +306,9 @@ username_nofocus_cb(GtkWidget *widget, GdkEventFocus *event, AccountPrefsDialog *dialog) { GdkColor color = {0, 34952, 35466, 34181}; - GHashTable *table = NULL; - const char *label = NULL; - - if(PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(dialog->prpl_info, get_account_text_table)) { - table = dialog->prpl_info->get_account_text_table(NULL); - label = g_hash_table_lookup(table, "login_label"); - + gchar *label = purple_prpl_get_text(dialog->plugin, NULL, "login_label"); + + if(label) { if (*gtk_entry_get_text(GTK_ENTRY(widget)) == '\0') { /* We have to avoid hitting the username_changed_cb function * because it enables buttons we don't want enabled yet ;) @@ -328,10 +319,9 @@ g_signal_handlers_unblock_by_func(widget, G_CALLBACK(username_changed_cb), dialog); gtk_widget_modify_text(widget, GTK_STATE_NORMAL, &color); } - - g_hash_table_destroy(table); } + g_free(label); return FALSE; } @@ -528,10 +518,7 @@ if (!username && dialog->prpl_info && 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"); + gchar *label = purple_prpl_get_text(dialog->plugin, NULL, "login_label"); gtk_entry_set_text(GTK_ENTRY(dialog->username_entry), label); g_signal_connect(G_OBJECT(dialog->username_entry), "focus-in-event", @@ -539,7 +526,8 @@ g_signal_connect(G_OBJECT(dialog->username_entry), "focus-out-event", G_CALLBACK(username_nofocus_cb), dialog); gtk_widget_modify_text(dialog->username_entry, GTK_STATE_NORMAL, &color); - g_hash_table_destroy(table); + + g_free(label); } g_signal_connect(G_OBJECT(dialog->username_entry), "changed", diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c --- a/pidgin/gtkblist.c +++ b/pidgin/gtkblist.c @@ -85,8 +85,10 @@ PidginBlistRequestData rq_data; GtkWidget *combo; GtkWidget *entry; + GtkWidget *entry_label; GtkWidget *entry_for_alias; GtkWidget *entry_for_invite; + GtkWidget *entry_for_invite_box; } PidginAddBuddyData; @@ -7044,6 +7046,7 @@ PurplePlugin *prpl = NULL; PurplePluginProtocolInfo *prpl_info = NULL; gboolean invite_enabled = TRUE; + gchar *username_label = NULL; /* Save our account */ data->rq_data.account = account; @@ -7053,11 +7056,21 @@ if (pc) prpl = purple_connection_get_prpl(pc); if (prpl) + { prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); + username_label = purple_prpl_get_text(prpl, account, "buddy_username_label"); + } if (prpl_info && !(prpl_info->options & OPT_PROTO_INVITE_MESSAGE)) invite_enabled = FALSE; - gtk_widget_set_sensitive(data->entry_for_invite, invite_enabled); + gtk_widget_set_visible(data->entry_for_invite_box, invite_enabled); + + if (username_label) + gtk_label_set_text_with_mnemonic(GTK_LABEL(data->entry_label), username_label); + else + gtk_label_set_text_with_mnemonic(GTK_LABEL(data->entry_label), _("Buddy's _username:")); + + g_free(username_label); } static void @@ -7169,9 +7182,10 @@ G_CALLBACK(destroy_add_buddy_dialog_cb), data); data->entry = gtk_entry_new(); + data->entry_label = NULL; pidgin_add_widget_to_vbox(data->rq_data.vbox, _("Buddy's _username:"), - data->rq_data.sg, data->entry, TRUE, NULL); + data->rq_data.sg, data->entry, TRUE, &data->entry_label); gtk_widget_grab_focus(data->entry); if (username != NULL) @@ -7198,9 +7212,9 @@ gtk_widget_grab_focus(GTK_WIDGET(data->entry_for_alias)); data->entry_for_invite = gtk_entry_new(); - pidgin_add_widget_to_vbox(data->rq_data.vbox, _("(Optional) _Invite message:"), - data->rq_data.sg, data->entry_for_invite, TRUE, - NULL); + data->entry_for_invite_box = pidgin_add_widget_to_vbox( + data->rq_data.vbox, _("(Optional) _Invite message:"), + data->rq_data.sg, data->entry_for_invite, TRUE, NULL); data->combo = pidgin_text_combo_box_entry_new(group, groups_tree()); pidgin_add_widget_to_vbox(data->rq_data.vbox, _("Add buddy to _group:"),