From: <rl...@us...> - 2006-05-02 01:44:22
|
Revision: 16122 Author: rlaager Date: 2006-05-01 18:44:14 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16122&view=rev Log Message: ----------- SF Patch #1479292 from resiak This cleans up the Ctrl-Tab and Ctrl-Shift-Tab handling so it's easier to understand. Modified Paths: -------------- trunk/src/gtkconv.c Modified: trunk/src/gtkconv.c =================================================================== --- trunk/src/gtkconv.c 2006-05-01 21:45:57 UTC (rev 16121) +++ trunk/src/gtkconv.c 2006-05-02 01:44:14 UTC (rev 16122) @@ -1732,46 +1732,27 @@ { GaimGtkConversation *next_gtkconv = NULL; GaimGtkWindow *win; - int index, i, total, found = 0; + int initial, i, total, diff; win = gtkconv->win; - index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); + initial = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), + gtkconv->tab_cont); total = gaim_gtk_conv_window_get_gtkconv_count(win); + /* By adding total here, the moduli calculated later will always have two + * positive arguments. x % y where x < 0 is not guaranteed to return a + * positive number. + */ + diff = (forward ? 1 : -1) + total; - /* First check the tabs after (forward) or before (!forward) this position. */ - for (i = forward ? index + 1 : index - 1; - !found && (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); - forward ? i++ : i--) { - if (i == -1) { - break; - } - + for (i = (initial + diff) % total; i != initial; i = (i + diff) % total) { + next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i); if (next_gtkconv->unseen_state > 0) - found = 1; + break; } - if (!found) { - /* 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_conv_window_get_gtkconv_at_index(win, i)); - forward ? i++ : i--) { - - if (next_gtkconv->unseen_state > 0) - found = 1; - } - - if (!found) { - /* 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_conv_window_get_gtkconv_at_index(win, index))) - next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); - } + if (i == initial) { /* no new messages */ + i = (i + diff) % total; + next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i); } if (next_gtkconv != NULL && next_gtkconv != gtkconv) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |