changeset 11467:2952c6dfa738

[gaim-migrate @ 13707] Control-Shift-Tab behaves like Control-Tab does, but going in reverse order. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 08 Sep 2005 17:47:51 +0000
parents eaa10266cd96
children c3cb62d33f53
files COPYRIGHT ChangeLog src/gtkconv.c
diffstat 3 files changed, 34 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Thu Sep 08 05:11:07 2005 +0000
+++ b/COPYRIGHT	Thu Sep 08 17:47:51 2005 +0000
@@ -232,6 +232,7 @@
 István Váradi
 Philip Van Hoof
 Kristof Vansant
+James Vega
 David Vermeille
 Sid Vicious
 Bjoern Voigt
--- a/ChangeLog	Thu Sep 08 05:11:07 2005 +0000
+++ b/ChangeLog	Thu Sep 08 17:47:51 2005 +0000
@@ -54,6 +54,8 @@
 	* Jabber support for SRV lookups
 	* When opening the log viewer, show the most recent log by default
 	  (Peter McCurdy)
+	* Control-Shift-Tab will reverse cycle through the conversation tabs
+	  (James Vega)
 
 	Bug fixes:
 	* People using input methods can now use Enter again.
--- a/src/gtkconv.c	Thu Sep 08 05:11:07 2005 +0000
+++ b/src/gtkconv.c	Thu Sep 08 17:47:51 2005 +0000
@@ -1717,19 +1717,25 @@
 }
 
 static void
-move_to_next_unread_tab(GaimGtkConversation *gtkconv)
+move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward)
 {
 	GaimGtkConversation *next_gtkconv = NULL;
 	GaimConvWindow *win;
 	GList *l;
-	int index, i, found = 0;
+	int index, i, total, found = 0;
 
 	win   = gaim_conversation_get_window(gtkconv->active_conv);
 	index = gtk_notebook_page_num(GTK_NOTEBOOK(GAIM_GTK_WINDOW(win)->notebook), gtkconv->tab_cont);
-
-	/* First check the tabs after this position. */
-	for (i = index; !found && (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i)); i++) {
-		for (l = next_gtkconv->convs; l; l = l->next) {
+	total = gaim_conv_window_get_conversation_count(win);
+
+	/* First check the tabs after (forward) or before (!forward) this position. */
+	for (i = index;
+		 !found && (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i));
+		 forward ? i++ : i--) {
+		if (i == -1) {
+			break;
+		}
+		for (l = next_gtkconv->convs; l; l = forward ? l->next : l->prev) {
 			GaimConversation *c = l->data;
 			if (gaim_conversation_get_unseen(c) > 0)
 			{
@@ -1740,9 +1746,11 @@
 	}
 
 	if (!found) {
-		/* Now check from the beginning up to this position. */
-		for (i = 0; !found && i < index && (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i)); i++) {
-			for (l = next_gtkconv->convs; l; l = l->next) {
+		/* Now check from the beginning up to (forward) or end back to (!forward) this position. */
+		for (i = forward ? 0 : total - 1;
+			 !found && (forward ? i < index : i >= 0) && (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i));
+			 forward ? i++ : i--) {
+			for (l = next_gtkconv->convs; l; l = forward ? l->next : l->prev) {
 				GaimConversation *c = l->data;
 				if (gaim_conversation_get_unseen(c) > 0) {
 					found = 1;
@@ -1752,8 +1760,14 @@
 		}
 
 		if (!found) {
-			/* Okay, just grab the next conversation tab. */
-			if (!(next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, index + 1)))
+			/* Okay, just grab the next (forward) or previous (!forward) conversation tab. */
+			if (forward) {
+				index++;
+			}
+			else {
+				index = (index == 0) ? total - 1 : index - 1;
+			}
+			if (!(next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, index)))
 				next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, 0);
 		}
 	}
@@ -1888,7 +1902,12 @@
 				break;
 
 			case GDK_Tab:
-				move_to_next_unread_tab(gtkconv);
+			case GDK_ISO_Left_Tab:
+				if (event->state & GDK_SHIFT_MASK) {
+					move_to_next_unread_tab(gtkconv, FALSE);
+				} else {
+					move_to_next_unread_tab(gtkconv, TRUE);
+				}
 
 				return TRUE;
 				break;