+ wxToolBarTool* tool = wx_static_cast(wxToolBarTool*, toolBase);
+
+ if ( tool->IsButton() )
+ {
+ if ( !HasFlag(wxTB_NOICONS) )
+ {
+ wxBitmap bitmap = tool->GetNormalBitmap();
+
+ wxCHECK_MSG( bitmap.Ok(), false,
+ wxT("invalid bitmap for wxToolBar icon") );
+
+ tool->m_image = gtk_image_new();
+ tool->SetImage(bitmap);
+
+ gtk_misc_set_alignment((GtkMisc*)tool->m_image, 0.5, 0.5);
+ }
+ }
+
+ int posGtk = 0;
+ if ( pos > 0 )
+ {
+ for ( size_t i = 0; i < pos; i++ )
+ {
+ posGtk++;
+
+ // if we have a dropdown menu, we use 2 GTK tools internally
+ wxToolBarToolsList::compatibility_iterator node = m_tools.Item( i );
+ wxToolBarTool * const tool2 = (wxToolBarTool*) node->GetData();
+ if ( tool2->IsButton() && tool2->GetKind() == wxITEM_DROPDOWN )
+ posGtk++;
+ }
+ }
+
+
+ switch ( tool->GetStyle() )
+ {
+ case wxTOOL_STYLE_BUTTON:
+ // for a radio button we need the widget which starts the radio
+ // group it belongs to, i.e. the first radio button immediately
+ // preceding this one
+ {
+ GtkWidget *widget = NULL;
+
+ if ( tool->IsRadio() )
+ {
+ wxToolBarToolsList::compatibility_iterator node
+ = wxToolBarToolsList::compatibility_iterator();
+ if ( pos )
+ node = m_tools.Item(pos - 1);
+
+ while ( node )
+ {
+ wxToolBarTool *toolNext = (wxToolBarTool *)node->GetData();
+ if ( !toolNext->IsRadio() )
+ break;
+
+ widget = toolNext->m_item;
+
+ node = node->GetPrevious();
+ }
+
+ if ( !widget )
+ {
+ // this is the first button in the radio button group,
+ // it will be toggled automatically by GTK so bring the
+ // internal flag in sync
+ tool->Toggle(true);
+ }
+ }
+
+ tool->m_item = gtk_toolbar_insert_element
+ (
+ m_toolbar,
+ tool->GetGtkChildType(),
+ widget,
+ tool->GetLabel().empty()
+ ? NULL
+ : (const char*) wxGTK_CONV( tool->GetLabel() ),
+ tool->GetShortHelp().empty()
+ ? NULL
+ : (const char*) wxGTK_CONV( tool->GetShortHelp() ),
+ "", // tooltip_private_text (?)
+ tool->m_image,
+ (GtkSignalFunc)gtk_toolbar_callback,
+ (gpointer)tool,
+ posGtk
+ );
+
+ wxCHECK_MSG(tool->m_item != NULL, false, _T("gtk_toolbar_insert_element() failed"));
+
+ g_signal_connect (tool->m_item, "enter_notify_event",
+ G_CALLBACK (gtk_toolbar_tool_callback),
+ tool);
+ g_signal_connect (tool->m_item, "leave_notify_event",
+ G_CALLBACK (gtk_toolbar_tool_callback),
+ tool);
+ g_signal_connect(tool->m_item, "button-press-event",
+ G_CALLBACK (gtk_toolbar_tool_rclick_callback),
+ tool);
+
+ if (tool->GetKind() == wxITEM_DROPDOWN)
+ {
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data( arrow_down_xpm );
+ GtkWidget *dropdown = gtk_toggle_button_new();
+ GtkWidget *image = gtk_image_new_from_pixbuf( pixbuf );
+ gtk_widget_show( image );
+ gtk_container_add( GTK_CONTAINER(dropdown), image );
+
+ if (GetWindowStyle() & wxTB_FLAT)
+ gtk_button_set_relief( GTK_BUTTON(dropdown), GTK_RELIEF_NONE );
+ GTK_WIDGET_UNSET_FLAGS (dropdown, GTK_CAN_FOCUS);
+ gtk_widget_show( dropdown );
+
+ g_signal_connect (dropdown, "enter_notify_event",
+ G_CALLBACK (gtk_toolbar_buddy_enter_callback),
+ tool->m_item);
+ g_signal_connect (dropdown, "leave_notify_event",
+ G_CALLBACK (gtk_toolbar_buddy_leave_callback),
+ tool->m_item);
+ g_signal_connect(dropdown, "button-press-event",
+ G_CALLBACK (gtk_toolbar_dropdown_lclick_callback),
+ tool);
+
+ GtkRequisition req;
+ (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(tool->m_item) )->size_request )
+ (tool->m_item, &req );
+ gtk_widget_set_size_request( dropdown, -1, req.height );
+
+ gtk_toolbar_insert_widget(
+ m_toolbar,
+ dropdown,
+ (const char *) NULL,
+ (const char *) NULL,
+ posGtk+1
+ );
+ }
+ }
+ break;
+
+ case wxTOOL_STYLE_SEPARATOR:
+ gtk_toolbar_insert_space( m_toolbar, posGtk );
+
+ // skip the rest
+ return true;
+
+ case wxTOOL_STYLE_CONTROL:
+#if 1
+ GtkWidget* align = gtk_alignment_new(0.5, 0.5, 0, 0);
+ gtk_widget_show(align);
+ gtk_container_add((GtkContainer*)align, tool->GetControl()->m_widget);
+ gtk_toolbar_insert_widget(
+ m_toolbar,
+ align,
+ (const char *) NULL,
+ (const char *) NULL,
+ posGtk
+ );
+#else
+ gtk_toolbar_insert_widget(
+ m_toolbar,
+ tool->GetControl()->m_widget,
+ (const char *) NULL,
+ (const char *) NULL,
+ posGtk
+ );
+#endif
+ // release reference obtained by wxInsertChildInToolBar
+ g_object_unref(tool->GetControl()->m_widget);
+ break;
+ }
+
+ InvalidateBestSize();
+
+ return true;