### Eclipse Workspace Patch 1.0 #P org.eclipse.ui.workbench Index: Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolder.java,v retrieving revision 1.23 diff -u -r1.23 DefaultTabFolder.java --- Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolder.java 8 Apr 2008 18:40:41 -0000 1.23 +++ Eclipse UI/org/eclipse/ui/internal/presentations/defaultpresentation/DefaultTabFolder.java 10 Apr 2008 18:24:19 -0000 @@ -7,7 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Remy Chi Jian Suen - Bug 145557 [WorkbenchParts] Content description label needs a hover + * Remy Chi Jian Suen + * - Bug 145557 [WorkbenchParts] Content description label needs a hover + * - Bug 158910 [GTK/Linux] Support switching tabs by mousewheel scrolling w/ Gtk *******************************************************************************/ package org.eclipse.ui.internal.presentations.defaultpresentation; @@ -86,6 +88,32 @@ } } }; + + private Listener mouseWheelListener = new Listener() { + public void handleEvent(Event e) { + int index = paneFolder.getSelectionIndex(); + int numItems = paneFolder.getItemCount(); + // make sure that the tab folder has an item selected and that we + // actually have an item to jump to + if (index != -1 && numItems != 1) { + // positive e.count value implies up + if (e.count > 0) { + // we move forward to the next tab only if we're not on the + // last tab, if we are, just stay there + if (index != numItems) { + paneFolder.setSelection(index + 1); + } + } else { + // only move back if we're not on the last tab + if (index != 0) { + paneFolder.setSelection(index - 1); + } + } + // fire a selection event so that the contents are actually swapped + fireEvent(TabFolderEvent.EVENT_TAB_SELECTED, getSelection()); + } + } + }; private static DefaultTabFolderColors defaultColors = new DefaultTabFolderColors(); @@ -106,6 +134,7 @@ paneFolder.addButtonListener(buttonListener); paneFolder.setMinimizeVisible(allowMin); paneFolder.setMaximizeVisible(allowMax); + paneFolder.getControl().addListener(SWT.MouseWheel, mouseWheelListener); paneFolder.getControl().addListener(SWT.Selection, selectionListener); paneFolder.setTopRight(null);