Mercurial > pidgin
changeset 31402:c0a122c22475
Show invite message entry in the Add Buddy dialog.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 20 Mar 2011 22:04:23 +0000 |
parents | 0cf50b0f7af4 |
children | 68c6d980e35c |
files | pidgin/gtkblist.c |
diffstat | 1 files changed, 34 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkblist.c Sun Mar 20 22:03:48 2011 +0000 +++ b/pidgin/gtkblist.c Sun Mar 20 22:04:23 2011 +0000 @@ -85,6 +85,7 @@ GtkWidget *combo; GtkWidget *entry; GtkWidget *entry_for_alias; + GtkWidget *entry_for_invite; } PidginAddBuddyData; @@ -6966,8 +6967,24 @@ add_buddy_select_account_cb(GObject *w, PurpleAccount *account, PidginAddBuddyData *data) { + PurpleConnection *pc = NULL; + PurplePlugin *prpl = NULL; + PurplePluginProtocolInfo *prpl_info = NULL; + gboolean invite_enabled = TRUE; + /* Save our account */ data->rq_data.account = account; + + if (account) + pc = purple_account_get_connection(account); + if (pc) + prpl = purple_connection_get_prpl(pc); + if (prpl) + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); + if (prpl_info && !(prpl_info->options & OPT_PROTO_INVITE_MESSAGE)) + invite_enabled = FALSE; + + gtk_widget_set_sensitive(data->entry_for_invite, invite_enabled); } static void @@ -6979,7 +6996,7 @@ static void add_buddy_cb(GtkWidget *w, int resp, PidginAddBuddyData *data) { - const char *grp, *who, *whoalias; + const char *grp, *who, *whoalias, *invite; PurpleAccount *account; PurpleGroup *g; PurpleBuddy *b; @@ -6993,6 +7010,9 @@ whoalias = gtk_entry_get_text(GTK_ENTRY(data->entry_for_alias)); if (*whoalias == '\0') whoalias = NULL; + invite = gtk_entry_get_text(GTK_ENTRY(data->entry_for_invite)); + if (*invite == '\0') + invite = NULL; account = data->rq_data.account; @@ -7018,7 +7038,7 @@ purple_blist_add_buddy(b, NULL, g, NULL); } - purple_account_add_buddy(account, b); + purple_account_add_buddy_with_invite(account, b, invite); /* Offer to merge people with the same alias. */ if (whoalias != NULL && g != NULL) @@ -7056,9 +7076,11 @@ { PidginAddBuddyData *data = g_new0(PidginAddBuddyData, 1); + if (account == NULL) + account = purple_connection_get_account(purple_connections_get_all()->data); + make_blist_request_dialog((PidginBlistRequestData *)data, - (account != NULL - ? account : purple_connection_get_account(purple_connections_get_all()->data)), + account, _("Add Buddy"), "add_buddy", _("Add a buddy.\n"), G_CALLBACK(add_buddy_select_account_cb), NULL, @@ -7102,11 +7124,19 @@ if (username != NULL) 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->combo = pidgin_text_combo_box_entry_new(group, groups_tree()); pidgin_add_widget_to_vbox(data->rq_data.vbox, _("Add buddy to _group:"), data->rq_data.sg, data->combo, TRUE, NULL); gtk_widget_show_all(data->rq_data.window); + + /* Force update of invite message entry sensitivity */ + add_buddy_select_account_cb(NULL, account, data); } static void