- gtk_toolbar_insert_widget(
- m_toolbar,
- tool->GetControl()->m_widget,
- (const char *) NULL,
- (const char *) NULL,
- posGtk
- );
-
- // connect after in order to correct size_allocate events
- g_signal_connect_after (tool->GetControl()->m_widget, "size_allocate",
- G_CALLBACK (gtktoolwidget_size_callback), tool->GetControl());
-
+ GtkWidget * const align = gtk_alignment_new(0.5, 0.5, 0, 0);
+ gtk_widget_show(align);
+ gtk_container_add(GTK_CONTAINER(align),
+ tool->GetControl()->m_widget);
+ gtk_toolbar_insert_widget(m_toolbar, align, NULL, NULL, posGtk);
+
+ // release reference obtained by wxInsertChildInToolBar
+ g_object_unref(tool->GetControl()->m_widget);
+
+ // remember the container we're in so that we could remove
+ // ourselves from it when we're detached from the toolbar
+ tool->m_item = align;