changeset 26136:d68924f1265f

propagate from branch 'im.pidgin.pidgin' (head 27a5e4c3bf4db89f9d87c37d7043c1f4dc68ed1f) to branch 'im.pidgin.pidgin.vv' (head 2327fc75d25586f742fc4305b4dfc93a581c1e13)
author Mike Ruprecht <maiku@soc.pidgin.im>
date Mon, 19 Jan 2009 10:47:12 +0000
parents c334a9e17426 (current diff) 5e77f8512f5b (diff)
children c56e8826fed0
files libpurple/protocols/gg/gg.c libpurple/prpl.c
diffstat 12 files changed, 117 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jan 19 10:44:07 2009 +0000
+++ b/ChangeLog	Mon Jan 19 10:47:12 2009 +0000
@@ -1,5 +1,10 @@
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
+version 2.5.5 (??/??/????):
+	Finch:
+	* Allow rebinding keys to change the focused widget (details in the
+	  man-page, look for GntBox::binding)
+
 version 2.5.4 (01/12/2009):
 	libpurple:
 	* Fix a connection timeout with empty Gadu-Gady buddy lists. (Martin
--- a/doc/finch.1.in	Mon Jan 19 10:44:07 2009 +0000
+++ b/doc/finch.1.in	Mon Jan 19 10:47:12 2009 +0000
@@ -296,6 +296,15 @@
 \fI~/.gntrc\fR correspond to the default keybindings for the actions:
 
 .br
+[GntBox::binding]
+.br
+tab = focus-next
+.br
+right = focus-next
+.br
+left = focus-prev
+
+.br
 [GntEntry::binding]
 .br
 c-a = cursor-home
--- a/finch/libgnt/gntbox.c	Mon Jan 19 10:44:07 2009 +0000
+++ b/finch/libgnt/gntbox.c	Mon Jan 19 10:47:12 2009 +0000
@@ -21,6 +21,7 @@
  */
 
 #include "gntbox.h"
+#include "gntstyle.h"
 #include "gntutils.h"
 
 #include <string.h>
@@ -304,38 +305,38 @@
 gnt_box_key_pressed(GntWidget *widget, const char *text)
 {
 	GntBox *box = GNT_BOX(widget);
-	GntWidget *now;
+	gboolean ret;
+
+	if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_DISABLE_ACTIONS))
+		return FALSE;
 
 	if (box->active == NULL && !find_focusable_widget(box))
 		return FALSE;
 
 	if (gnt_widget_key_pressed(box->active, text))
 		return TRUE;
-	
+
+	/* This dance is necessary to make sure that the child widgets get a chance
+	   to trigger their bindings first */
+	GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_DISABLE_ACTIONS);
+	ret = gnt_widget_key_pressed(widget, text);
+	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_DISABLE_ACTIONS);
+	return ret;
+}
+
+static gboolean
+box_focus_change(GntBox *box, gboolean next)
+{
+	GntWidget *now;
 	now = box->active;
 
-	if (text[0] == 27)
-	{
-		if (strcmp(text, GNT_KEY_LEFT) == 0)
-		{
-			find_prev_focus(box);
-		}
-		else if (strcmp(text, GNT_KEY_RIGHT) == 0)
-		{
-			find_next_focus(box);
-		}
-		else if (strcmp(text, GNT_KEY_BACK_TAB) == 0)
-		{
-			find_prev_focus(box);
-		}
-	}
-	else if (text[0] == '\t')
-	{
+	if (next) {
 		find_next_focus(box);
+	} else {
+		find_prev_focus(box);
 	}
 
-	if (now && now != box->active)
-	{
+	if (now && now != box->active) {
 		gnt_widget_set_focus(now, FALSE);
 		gnt_widget_set_focus(box->active, TRUE);
 		return TRUE;
@@ -344,6 +345,18 @@
 	return FALSE;
 }
 
+static gboolean
+action_focus_next(GntBindable *bindable, GList *null)
+{
+	return box_focus_change(GNT_BOX(bindable), TRUE);
+}
+
+static gboolean
+action_focus_prev(GntBindable *bindable, GList *null)
+{
+	return box_focus_change(GNT_BOX(bindable), FALSE);
+}
+
 static void
 gnt_box_lost_focus(GntWidget *widget)
 {
@@ -556,6 +569,7 @@
 static void
 gnt_box_class_init(GntBoxClass *klass)
 {
+	GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass);
 	GObjectClass *gclass = G_OBJECT_CLASS(klass);
 	parent_class = GNT_WIDGET_CLASS(klass);
 	parent_class->destroy = gnt_box_destroy;
@@ -589,6 +603,15 @@
 				G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
 			)
 		);
+
+	gnt_bindable_class_register_action(bindable, "focus-next", action_focus_next,
+			"\t", NULL);
+	gnt_bindable_register_binding(bindable, "focus-next", GNT_KEY_RIGHT, NULL);
+	gnt_bindable_class_register_action(bindable, "focus-prev", action_focus_prev,
+			GNT_KEY_BACK_TAB, NULL);
+	gnt_bindable_register_binding(bindable, "focus-prev", GNT_KEY_LEFT, NULL);
+
+	gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable);
 }
 
 static void
@@ -599,7 +622,7 @@
 	/* Initially make both the height and width resizable.
 	 * Update the flags as necessary when widgets are added to it. */
 	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_X | GNT_WIDGET_GROW_Y);
-	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
+	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS | GNT_WIDGET_DISABLE_ACTIONS);
 	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
 	box->pad = 1;
 	box->fill = TRUE;
--- a/libpurple/protocols/gg/gg.c	Mon Jan 19 10:44:07 2009 +0000
+++ b/libpurple/protocols/gg/gg.c	Mon Jan 19 10:47:12 2009 +0000
@@ -755,18 +755,29 @@
 
 /* ----- CONFERENCES ---------------------------------------------------- */
 
-static void ggp_callback_add_to_chat_ok(PurpleConnection *gc, PurpleRequestFields *fields)
+static void ggp_callback_add_to_chat_ok(PurpleBuddy *buddy, PurpleRequestFields *fields)
 {
-	GGPInfo *info = gc->proto_data;
+	GGPInfo *info;
+	PurpleConnection *conn;
 	PurpleRequestField *field;
-	/* TODO: sel may be null. */
 	GList *sel;
 
+	conn = purple_account_get_connection(purple_buddy_get_account(buddy));
+
+	g_return_if_fail(conn != NULL);
+
+	info = conn->proto_data;
+
 	field = purple_request_fields_get_field(fields, "name");
 	sel = purple_request_field_list_get_selected(field);
 
-	ggp_confer_participants_add_uin(gc, sel->data, info->tmp_buddy);
-	info->tmp_buddy = 0;
+	if (sel == NULL) {
+		purple_debug_error("gg", "No chat selected\n");
+		return;
+	}
+
+	ggp_confer_participants_add_uin(conn, sel->data,
+					ggp_str_to_uin(purple_buddy_get_name(buddy)));
 }
 
 static void ggp_bmenu_add_to_chat(PurpleBlistNode *node, gpointer ignored)
@@ -786,9 +797,6 @@
 	gc = purple_account_get_connection(purple_buddy_get_account(buddy));
 	info = gc->proto_data;
 
-	/* TODO: It tmp_buddy != 0 then stop! */
-	info->tmp_buddy = ggp_str_to_uin(purple_buddy_get_name(buddy));
-
 	fields = purple_request_fields_new();
 	group = purple_request_field_group_new(NULL);
 	purple_request_fields_add_group(fields, group);
@@ -796,8 +804,7 @@
 	field = purple_request_field_list_new("name", "Chat name");
 	for (l = info->chats; l != NULL; l = l->next) {
 		GGPChat *chat = l->data;
-		purple_request_field_list_add(field, g_strdup(chat->name),
-					    g_strdup(chat->name));
+		purple_request_field_list_add(field, chat->name, chat->name);
 	}
 	purple_request_field_group_add_field(group, field);
 
@@ -810,8 +817,8 @@
 			fields,
 			_("Add"), G_CALLBACK(ggp_callback_add_to_chat_ok),
 			_("Cancel"), NULL,
-			purple_connection_get_account(gc), NULL, NULL,			  
-			gc);
+			purple_connection_get_account(gc), NULL, NULL,
+			buddy);
 	g_free(msg);
 }
 
@@ -1699,14 +1706,20 @@
 {
 	PurpleMenuAction *act;
 	GList *m = NULL;
+	PurpleAccount *account;
+	GGPInfo *info;
 
 	if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
 		return NULL;
 
-	act = purple_menu_action_new(_("Add to chat"),
-	                           PURPLE_CALLBACK(ggp_bmenu_add_to_chat),
-	                           NULL, NULL);
-	m = g_list_append(m, act);
+	account = purple_buddy_get_account((PurpleBuddy *) node);
+	info = purple_account_get_connection(account)->proto_data;
+	if (info->chats) {
+		act = purple_menu_action_new(_("Add to chat"),
+			PURPLE_CALLBACK(ggp_bmenu_add_to_chat),
+			NULL, NULL);
+		m = g_list_append(m, act);
+	}
 
 	/* Using a blist node boolean here is also wrong.
 	 * Once the Block and Unblock actions are added to the core,
--- a/libpurple/protocols/gg/gg.h	Mon Jan 19 10:44:07 2009 +0000
+++ b/libpurple/protocols/gg/gg.h	Mon Jan 19 10:47:12 2009 +0000
@@ -61,10 +61,7 @@
 	GGPToken *token;
 	GList *chats;
 	GGPSearches *searches;
-
-	uin_t tmp_buddy;
 	int chats_count;
-
 	GList *pending_richtext_messages;
 	GHashTable *pending_images;
 } GGPInfo;
--- a/libpurple/protocols/msn/session.h	Mon Jan 19 10:44:07 2009 +0000
+++ b/libpurple/protocols/msn/session.h	Mon Jan 19 10:47:12 2009 +0000
@@ -123,7 +123,7 @@
 	} passport_info;
 
 	GHashTable *soap_table;
-	int soap_cleanup_handle;
+	guint soap_cleanup_handle;
 };
 
 /**
--- a/libpurple/protocols/msn/slpcall.c	Mon Jan 19 10:44:07 2009 +0000
+++ b/libpurple/protocols/msn/slpcall.c	Mon Jan 19 10:47:12 2009 +0000
@@ -206,7 +206,7 @@
 	body = slpmsg->buffer;
 	body_len = slpmsg->size;
 
-	if (slpmsg->flags == 0x0)
+	if (slpmsg->flags == 0x0 || slpmsg->flags == 0x1000000)
 	{
 		char *body_str;
 
@@ -214,7 +214,9 @@
 		slpcall = msn_slp_sip_recv(slplink, body_str);
 		g_free(body_str);
 	}
-	else if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030)
+	else if (slpmsg->flags == 0x20 ||
+	         slpmsg->flags == 0x1000020 ||
+	         slpmsg->flags == 0x1000030)
 	{
 		slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->session_id);
 
@@ -237,6 +239,9 @@
 			msn_slpcall_session_init(slpcall);
 	}
 #endif
+	else
+		purple_debug_warning("msn", "Unprocessed SLP message with flags 0x%08lx\n",
+		                     slpmsg->flags);
 
 	return slpcall;
 }
--- a/libpurple/protocols/msn/slplink.c	Mon Jan 19 10:44:07 2009 +0000
+++ b/libpurple/protocols/msn/slplink.c	Mon Jan 19 10:47:12 2009 +0000
@@ -281,7 +281,8 @@
 		g_list_append(slpmsg->msgs, msg);
 	msn_slplink_send_msg(slplink, msg);
 
-	if ((slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) &&
+	if ((slpmsg->flags == 0x20 || slpmsg->flags == 0x1000020 ||
+	     slpmsg->flags == 0x1000030) &&
 		(slpmsg->slpcall != NULL))
 	{
 		slpmsg->slpcall->progress = TRUE;
@@ -316,7 +317,8 @@
 	else
 	{
 		/* The whole message has been sent */
-		if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030)
+		if (slpmsg->flags == 0x20 ||
+		    slpmsg->flags == 0x1000020 || slpmsg->flags == 0x1000030)
 		{
 			if (slpmsg->slpcall != NULL)
 			{
@@ -362,7 +364,8 @@
 		msg->msnslp_header.ack_size = slpmsg->ack_size;
 		msg->msnslp_header.ack_sub_id = slpmsg->ack_sub_id;
 	}
-	else if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030)
+	else if (slpmsg->flags == 0x20 ||
+	         slpmsg->flags == 0x1000020 || slpmsg->flags == 0x1000030)
 	{
 		MsnSlpCall *slpcall;
 		slpcall = slpmsg->slpcall;
@@ -398,6 +401,8 @@
 void
 msn_slplink_queue_slpmsg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
 {
+	g_return_if_fail(slpmsg != NULL);
+
 	slpmsg->id = slplink->slp_seq_id++;
 
 	g_queue_push_tail(slplink->slp_msg_queue, slpmsg);
@@ -530,7 +535,8 @@
 
 			if (slpmsg->slpcall != NULL)
 			{
-				if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030)
+				if (slpmsg->flags == 0x20 ||
+				    slpmsg->flags == 0x1000020 || slpmsg->flags == 0x1000030)
 				{
 					PurpleXfer *xfer;
 
@@ -593,7 +599,8 @@
 			memcpy(slpmsg->buffer + offset, data, len);
 	}
 
-	if ((slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) &&
+	if ((slpmsg->flags == 0x20 ||
+	     slpmsg->flags == 0x1000020 || slpmsg->flags == 0x1000030) &&
 		(slpmsg->slpcall != NULL))
 	{
 		slpmsg->slpcall->progress = TRUE;
@@ -628,8 +635,9 @@
 				msn_directconn_send_handshake(directconn);
 #endif
 		}
-		else if (slpmsg->flags == 0x0 || slpmsg->flags == 0x20 ||
-				 slpmsg->flags == 0x1000030)
+		else if (slpmsg->flags == 0x00 || slpmsg->flags == 0x1000000 ||  
+		         slpmsg->flags == 0x20 || slpmsg->flags == 0x1000020 ||  
+		         slpmsg->flags == 0x1000030)
 		{
 			/* Release all the messages and send the ACK */
 
--- a/libpurple/protocols/oscar/odc.c	Mon Jan 19 10:44:07 2009 +0000
+++ b/libpurple/protocols/oscar/odc.c	Mon Jan 19 10:47:12 2009 +0000
@@ -394,7 +394,7 @@
 		}
 	}
 
-	/* Send the message */
+	/* Display the message we received */
 	imflags = 0;
 	if (images != NULL)
 		imflags |= PURPLE_MESSAGE_IMAGES;
--- a/libpurple/protocols/oscar/oscar.c	Mon Jan 19 10:44:07 2009 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Mon Jan 19 10:47:12 2009 +0000
@@ -4337,8 +4337,7 @@
 	}
 	g_string_free(data, TRUE);
 
-	peer_odc_send_im(conn, msg->str, msg->len, charset,
-			imflags & PURPLE_MESSAGE_AUTO_RESP);
+	peer_odc_send_im(conn, msg->str, msg->len, charset, imflags);
 	g_string_free(msg, TRUE);
 }
 
--- a/libpurple/prpl.c	Mon Jan 19 10:44:07 2009 +0000
+++ b/libpurple/prpl.c	Mon Jan 19 10:47:12 2009 +0000
@@ -190,7 +190,7 @@
 
 	g_return_if_fail(account != NULL);
 	g_return_if_fail(name    != NULL);
-	g_return_if_fail(purple_account_is_connected(account));
+	g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account));
 
 	if ((list = purple_find_buddies(account, name)) == NULL)
 		return;
--- a/pidgin/pidgintooltip.c	Mon Jan 19 10:44:07 2009 +0000
+++ b/pidgin/pidgintooltip.c	Mon Jan 19 10:47:12 2009 +0000
@@ -82,7 +82,8 @@
 static void
 destroy_tooltip_data(PidginTooltipData *data)
 {
-	gtk_tree_path_free(data->common.treeview.path);
+	if (data->common.treeview.path)
+		gtk_tree_path_free(data->common.treeview.path);
 	pidgin_tooltip_destroy();
 	g_free(data);
 }
@@ -380,7 +381,7 @@
 
 	g_signal_connect(G_OBJECT(widget), "motion-notify-event", G_CALLBACK(widget_motion_cb), wdata);
 	g_signal_connect(G_OBJECT(widget), "leave-notify-event", G_CALLBACK(widget_leave_cb), NULL);
-	g_signal_connect_swapped(G_OBJECT(widget), "destroy", G_CALLBACK(g_free), wdata);
+	g_signal_connect_swapped(G_OBJECT(widget), "destroy", G_CALLBACK(destroy_tooltip_data), wdata);
 	return TRUE;
 }