+ GSList* radioGroup;
+ switch ( tool->GetStyle() )
+ {
+ case wxTOOL_STYLE_BUTTON:
+ switch (tool->GetKind())
+ {
+ case wxITEM_CHECK:
+ tool->m_item = gtk_toggle_tool_button_new();
+ g_signal_connect(tool->m_item, "toggled",
+ G_CALLBACK(item_toggled), tool);
+ break;
+ case wxITEM_RADIO:
+ radioGroup = GetRadioGroup(pos);
+ if (radioGroup)
+ {
+ // 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_radio_tool_button_new(radioGroup);
+ g_signal_connect(tool->m_item, "toggled",
+ G_CALLBACK(item_toggled), tool);
+ break;
+ default:
+ wxFAIL_MSG("unknown toolbar child type");
+ // fall through
+ case wxITEM_DROPDOWN:
+ case wxITEM_NORMAL:
+ tool->m_item = gtk_tool_button_new(NULL, "");
+ g_signal_connect(tool->m_item, "clicked",
+ G_CALLBACK(item_clicked), tool);
+ break;
+ }
+ if (!HasFlag(wxTB_NOICONS))
+ {
+ GtkWidget* image = gtk_image_new();
+ gtk_tool_button_set_icon_widget(
+ GTK_TOOL_BUTTON(tool->m_item), image);
+ tool->SetImage();
+ gtk_widget_show(image);
+ g_signal_connect(image, "expose_event",
+ G_CALLBACK(image_expose_event), tool);
+ }
+ if (!tool->GetLabel().empty())
+ {
+ gtk_tool_button_set_label(
+ GTK_TOOL_BUTTON(tool->m_item), wxGTK_CONV(tool->GetLabel()));
+ // needed for labels in horizontal toolbar with wxTB_HORZ_LAYOUT
+ gtk_tool_item_set_is_important(tool->m_item, true);
+ }
+ if (!HasFlag(wxTB_NO_TOOLTIPS) && !tool->GetShortHelp().empty())
+ {
+ gtk_tool_item_set_tooltip(tool->m_item,
+ m_tooltips, wxGTK_CONV(tool->GetShortHelp()), "");
+ }
+ g_signal_connect(GTK_BIN(tool->m_item)->child, "button_press_event",
+ G_CALLBACK(button_press_event), tool);
+ g_signal_connect(tool->m_item, "enter_notify_event",
+ G_CALLBACK(enter_notify_event), tool);
+ g_signal_connect(tool->m_item, "leave_notify_event",
+ G_CALLBACK(enter_notify_event), tool);
+
+ if (tool->GetKind() == wxITEM_DROPDOWN)
+ tool->CreateDropDown();
+ gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos));
+ break;
+
+ case wxTOOL_STYLE_SEPARATOR:
+ tool->m_item = gtk_separator_tool_item_new();
+ gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos));
+ break;
+
+ case wxTOOL_STYLE_CONTROL:
+ wxWindow* control = tool->GetControl();
+ if (control->m_widget->parent == NULL)
+ AddChildGTK(control);
+ tool->m_item = GTK_TOOL_ITEM(control->m_widget->parent->parent);
+ if (gtk_toolbar_get_item_index(m_toolbar, tool->m_item) != int(pos))
+ {
+ g_object_ref(tool->m_item);
+ gtk_container_remove(
+ GTK_CONTAINER(m_toolbar), GTK_WIDGET(tool->m_item));
+ gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos));
+ g_object_unref(tool->m_item);
+ }
+ // Inserted items "slide" into place using an animated effect that
+ // causes multiple size events on the item. Must set size request
+ // to keep item size from getting permanently set too small by the
+ // first of these size events.
+ const wxSize size = control->GetSize();
+ gtk_widget_set_size_request(control->m_widget, size.x, size.y);
+ break;
+ }
+ gtk_widget_show(GTK_WIDGET(tool->m_item));