@Override void createHandle(int index) { state |= HANDLE | THEME_BACKGROUND; fixedHandle = OS.g_object_new(display.gtk_fixed_get_type(), 0); if (fixedHandle == 0) error(SWT.ERROR_NO_HANDLES); OS.gtk_widget_set_has_window(fixedHandle, true); handle = OS.gtk_toolbar_new(); if (handle == 0) error(SWT.ERROR_NO_HANDLES); OS.gtk_container_add(fixedHandle, handle); if ((style & SWT.FLAT) != 0) { byte[] swt_toolbar_flat = Converter.wcsToMbcs(null, "swt-toolbar-flat", true); OS.gtk_widget_set_name(handle, swt_toolbar_flat); } /* * Bug in GTK. For some reason, the toolbar style context does not read * the CSS style sheet until the window containing the toolbar is shown. * The fix is to call gtk_style_context_invalidate() which it seems to * force the style sheet to be read. */ if (OS.GTK3) { long /*int*/ context = OS.gtk_widget_get_style_context(handle); String css = "GtkToolbar {padding-top: 4px; padding-bottom: 4px; }"; gtk_css_provider_load_from_css(context, css); OS.gtk_style_context_invalidate(context); } /* * Bug in GTK. GTK will segment fault if gtk_widget_reparent() is called * on a tool bar or on a widget hierarchy containing a tool bar when the icon * size is not GTK_ICON_SIZE_LARGE_TOOLBAR. The fix is to set the icon * size to GTK_ICON_SIZE_LARGE_TOOLBAR. * * Note that the segmentation fault does not happen on GTK 3, but the * tool bar preferred size is too big with GTK_ICON_SIZE_LARGE_TOOLBAR * when the tool bar item has no image or text. */ OS.gtk_toolbar_set_icon_size( handle, OS.GTK3 ? OS.GTK_ICON_SIZE_SMALL_TOOLBAR : OS.GTK_ICON_SIZE_LARGE_TOOLBAR); // In GTK 3 font description is inherited from parent widget which is not how SWT has always // worked, // reset to default font to get the usual behavior if (OS.GTK3) { setFontDescription(defaultFont().handle); } }