changeset 18218:571e0ca28d6c

Show immediate feedback when getting information about someone in a chat. Fixes #387.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 21 Jun 2007 06:46:27 +0000
parents e3a4ed0febd2
children b96ea6cbc22c
files ChangeLog.API pidgin/gtkconv.c pidgin/gtkutils.c pidgin/gtkutils.h
diffstat 4 files changed, 47 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Thu Jun 21 05:58:23 2007 +0000
+++ b/ChangeLog.API	Thu Jun 21 06:46:27 2007 +0000
@@ -66,8 +66,8 @@
 		Added:
 		* gtk_imhtml_setup_entry
 		* pidgin_create_window
-		* pidgin_retrieve_user_info, shows immediate feedback when getting
-		  information about a user.
+		* pidgin_retrieve_user_info and pidgin_retrieve_user_info_in_chat,
+		  shows immediate feedback when getting information about a user.
 		* gtk_imhtml_animation_new
 		    Can be used for inserting an animated image into an IMHTML.
 		* pidgin_menu_position_func_helper
--- a/pidgin/gtkconv.c	Thu Jun 21 05:58:23 2007 +0000
+++ b/pidgin/gtkconv.c	Thu Jun 21 06:46:27 2007 +0000
@@ -628,23 +628,10 @@
 static void chat_do_info(PidginConversation *gtkconv, const char *who)
 {
 	PurpleConversation *conv = gtkconv->active_conv;
-	PurplePluginProtocolInfo *prpl_info = NULL;
 	PurpleConnection *gc;
 
 	if ((gc = purple_conversation_get_gc(conv))) {
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
-
-		/*
-		 * If there are special needs for getting info on users in
-		 * buddy chat "rooms"...
-		 */
-		if (prpl_info->get_cb_info != NULL)
-		{
-			prpl_info->get_cb_info(gc,
-				purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who);
-		}
-		else
-			pidgin_retrieve_user_info(gc, who);
+		pidgin_retrieve_user_info_in_chat(gc, who, purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)));
 	}
 }
 
@@ -4416,20 +4403,21 @@
 				GTK_TREE_MODEL(gtkconv->infopane_model));
 	gtk_list_store_append(gtkconv->infopane_model, &(gtkconv->infopane_iter));
 	gtk_box_pack_start(GTK_BOX(gtkconv->infopane_hbox), gtkconv->infopane, TRUE, TRUE, 0);
-        path = gtk_tree_path_new_from_string("0");
-        gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(gtkconv->infopane), path);
+	path = gtk_tree_path_new_from_string("0");
+	gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(gtkconv->infopane), path);
+	gtk_tree_path_free(path);
 	gtk_widget_set_size_request(gtkconv->infopane, -1, 32);
 	gtk_widget_show(gtkconv->infopane);
 
 	rend = gtk_cell_renderer_pixbuf_new();
 	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkconv->infopane), rend, FALSE);
 	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkconv->infopane), rend, "pixbuf", ICON_COLUMN, NULL);
-        g_object_set(rend, "xalign", 0.0, "xpad", 6, "ypad", 0, NULL);
+	g_object_set(rend, "xalign", 0.0, "xpad", 6, "ypad", 0, NULL);
 
 	rend = gtk_cell_renderer_text_new();
 	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkconv->infopane), rend, TRUE);
 	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkconv->infopane), rend, "markup", TEXT_COLUMN, NULL);
-        g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL);
+	g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL);
 
 #if GTK_CHECK_VERSION(2, 6, 0)
 	g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
--- a/pidgin/gtkutils.c	Thu Jun 21 05:58:23 2007 +0000
+++ b/pidgin/gtkutils.c	Thu Jun 21 06:46:27 2007 +0000
@@ -913,15 +913,44 @@
 	g_free(filename);
 }
 
-void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name)
+static void
+show_retrieveing_info(PurpleConnection *conn, const char *name)
 {
 	PurpleNotifyUserInfo *info = purple_notify_user_info_new();
 	purple_notify_user_info_add_pair(info, _("Information"), _("Retrieving..."));
 	purple_notify_userinfo(conn, name, info, NULL, NULL);
 	purple_notify_user_info_destroy(info);
+}
+
+void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name)
+{
+	show_retrieveing_info(conn, name);
 	serv_get_info(conn, name);
 }
 
+void pidgin_retrieve_user_info_in_chat(PurpleConnection *conn, const char *name, int chat)
+{
+	char *who = NULL;
+	PurplePluginProtocolInfo *prpl_info = NULL;
+
+	if (chat < 0) {
+		pidgin_retrieve_user_info(conn, name);
+		return;
+	}
+
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(conn->prpl);
+	if (prpl_info == NULL || prpl_info->get_cb_info == NULL) {
+		pidgin_retrieve_user_info(conn, name);
+		return;
+	}
+
+	if (prpl_info->get_cb_real_name)
+		who = prpl_info->get_cb_real_name(conn, chat, name);
+	show_retrieveing_info(conn, who ? who : name);
+	prpl_info->get_cb_info(conn, chat, name);
+	g_free(who);
+}
+
 gboolean
 pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts,
 							PurpleAccount **ret_account, char **ret_protocol,
--- a/pidgin/gtkutils.h	Thu Jun 21 05:58:23 2007 +0000
+++ b/pidgin/gtkutils.h	Thu Jun 21 06:46:27 2007 +0000
@@ -329,6 +329,15 @@
 void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name);
 
 /**
+ * Get information about a user in a chat. Show immediate feedback.
+ *
+ * @param conn   The connection to get information from.
+ * @param name   The user to get information about.
+ * @param chatid The chat id.
+ */
+void pidgin_retrieve_user_info_in_chat(PurpleConnection *conn, const char *name, int chatid);
+
+/**
  * Parses an application/x-im-contact MIME message and returns the
  * data inside.
  *