Project: SWT
Bug 29837 [Contributions] Combo control does not show on GTK toolbar, works fine on Win and Motif
Reported: 2003-01-20 15:39:24 | Status: resolved fixed

I created a combo control on the toolbar by extending ControlContribution and creating the control content with a Label and Combo. Via my editor MultiPageEditorActionBarContributor, I add this control to the platform toolbar. This works great on Windows, and works pretty well on motif (except that the combo is not properly vertically centered on motif. But on Linux GTK, all I get is a blank space big enough to hold the label+combo, but no display. The same problem shows on GTK for 2.0.2 and 2.1M4. I am running RedHat 8.0, with basic new installation of the OS config. Also JDK 1.4.1. Here is a copy of the offending code: import org.eclipse.jface.action.ControlContribution; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.ui.IEditorPart; public class ZoomComboAction extends ControlContribution { public static final String FIT_TO_SCREEN = "Fit"; private String[] zoomValues= new String[] { FIT_TO_SCREEN, "30", "50", "80", "100", "120" }; private Label label; private Combo zoomCombo = null; public ZoomComboAction() { super("ZoomComboAction"); } public void setEnabled( boolean enabled ) { if( label != null ) { label.setEnabled(enabled); zoomCombo.setEnabled(enabled); } } protected Control createControl( Composite parent ) { Composite wrapper = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = 1; wrapper.setLayout(layout); label = new Label(wrapper, SWT.NONE); label.setText("Zoom"); zoomCombo = new Combo(wrapper, SWT.DROP_DOWN | SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); zoomCombo.setLayoutData(gd); zoomCombo.setTextLimit(3); zoomCombo.setItems(zoomValues); return wrapper; } }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java