+ wxCHECK_MSG(pos<=m_clientList.GetCount(), -1, wxT("invalid index"));
+
+ GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) );
+
+ size_t index;
+ if ( m_strings )
+ {
+ // sorted control, need to insert at the correct index
+ index = m_strings->Add(item);
+
+ gtk_menu_insert( GTK_MENU(menu), menu_item, index );
+
+ if ( index )
+ {
+ m_clientList.Insert( m_clientList.Item(index - 1),
+ NULL );
+ }
+ else
+ {
+ m_clientList.Insert( NULL );
+ }
+ }
+ else
+ {
+ // don't call wxChoice::GetCount() from here because it doesn't work
+ // if we're called from ctor (and GtkMenuShell is still NULL)
+
+ // normal control, just append
+ if (pos == m_clientList.GetCount())
+ {
+ gtk_menu_append( GTK_MENU(menu), menu_item );
+ m_clientList.Append( NULL );
+ index = m_clientList.GetCount() - 1;
+ }
+ else
+ {
+ gtk_menu_insert( GTK_MENU(menu), menu_item, pos );
+ m_clientList.Insert( pos, NULL );
+ index = pos;
+ }
+ }
+
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_realize( menu_item );
+ gtk_widget_realize( GTK_BIN(menu_item)->child );
+
+ ApplyWidgetStyle();
+ }
+
+ // The best size of a wxChoice should probably
+ // be changed everytime the control has been
+ // changed, but at least after adding an item
+ // it has to change. Adapted from Matt Ownby.
+ InvalidateBestSize();
+
+ gtk_signal_connect_after( GTK_OBJECT( menu_item ), "activate",
+ GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
+
+ gtk_widget_show( menu_item );