changeset 25327:23bb3a96d8ea

merge of '07f8d9c59020c1f69cc21b71f8252f13efd6a6e0' and '331937f46235852e1813a1492eb351071127e02c'
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 14 Jan 2009 13:59:46 +0000
parents df25f88ff22a (diff) cb1a897ae34c (current diff)
children ed3409c4ccd6
files
diffstat 6 files changed, 93 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jan 14 13:21:10 2009 +0000
+++ b/ChangeLog	Wed Jan 14 13:59:46 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/configure.ac	Wed Jan 14 13:21:10 2009 +0000
+++ b/configure.ac	Wed Jan 14 13:59:46 2009 +0000
@@ -46,8 +46,8 @@
 m4_define([purple_lt_current], [5])
 m4_define([purple_major_version], [2])
 m4_define([purple_minor_version], [5])
-m4_define([purple_micro_version], [4])
-m4_define([purple_version_suffix], [])
+m4_define([purple_micro_version], [5])
+m4_define([purple_version_suffix], [devel])
 m4_define([purple_version],
           [purple_major_version.purple_minor_version.purple_micro_version])
 m4_define([purple_display_version], purple_version[]m4_ifdef([purple_version_suffix],[purple_version_suffix]))
@@ -55,8 +55,8 @@
 m4_define([gnt_lt_current], [5])
 m4_define([gnt_major_version], [2])
 m4_define([gnt_minor_version], [5])
-m4_define([gnt_micro_version], [4])
-m4_define([gnt_version_suffix], [])
+m4_define([gnt_micro_version], [5])
+m4_define([gnt_version_suffix], [devel])
 m4_define([gnt_version],
           [gnt_major_version.gnt_minor_version.gnt_micro_version])
 m4_define([gnt_display_version], gnt_version[]m4_ifdef([gnt_version_suffix],[gnt_version_suffix]))
--- a/doc/finch.1.in	Wed Jan 14 13:21:10 2009 +0000
+++ b/doc/finch.1.in	Wed Jan 14 13:59:46 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	Wed Jan 14 13:21:10 2009 +0000
+++ b/finch/libgnt/gntbox.c	Wed Jan 14 13:59:46 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	Wed Jan 14 13:21:10 2009 +0000
+++ b/libpurple/protocols/gg/gg.c	Wed Jan 14 13:59:46 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/prpl.c	Wed Jan 14 13:21:10 2009 +0000
+++ b/libpurple/prpl.c	Wed Jan 14 13:59:46 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;