+ // text has "_" instead of "&" after mitem->SetText() so don't use it
+ wxString text( mitem->GetText() );
+
+ // buffers containing the menu item path and type in multibyte form
+ char bufPath[256],
+ bufType[256];
+
+ strcpy( bufPath, "/" );
+ strncat( bufPath, wxGTK_CONV(text), WXSIZEOF(bufPath) - 2 );
+ bufPath[WXSIZEOF(bufPath) - 1] = '\0';
+
+ GtkItemFactoryEntry entry;
+ entry.path = bufPath;
+ entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
+ entry.callback_action = 0;
+
+ wxString pathRadio;
+ const char *item_type;
+ switch ( mitem->GetKind() )
+ {
+ case wxITEM_CHECK:
+ item_type = "<CheckItem>";
+ break;
+
+ case wxITEM_RADIO:
+ if ( m_pathLastRadio.empty() )
+ {
+ // start of a new radio group
+ item_type = "<RadioItem>";
+ wxString tmp( wxGTK_CONV_BACK( bufPath ) );
+ tmp.Remove(0,1);
+ m_pathLastRadio = tmp;
+ }
+ else // continue the radio group
+ {
+ pathRadio = m_pathLastRadio;
+ pathRadio.Replace(wxT("_"), wxT(""));
+ pathRadio.Prepend(wxT("<main>/"));
+
+ strncpy(bufType, wxGTK_CONV(pathRadio), WXSIZEOF(bufType));
+ bufType[WXSIZEOF(bufType) - 1] = '\0';
+ item_type = bufType;
+ }
+
+ // continue the existing radio group, if any
+ endOfRadioGroup = FALSE;
+ break;
+
+ default:
+ wxFAIL_MSG( _T("unexpected menu item kind") );
+ // fall through
+
+ case wxITEM_NORMAL:
+ item_type = "<Item>";
+ break;
+ }
+
+ entry.item_type = (char *)item_type; // cast needed for GTK+
+ entry.accelerator = (gchar*) NULL;
+
+#if wxUSE_ACCEL
+ // due to an apparent bug in GTK+, we have to use a static buffer here -
+ // otherwise GTK+ 1.2.2 manages to override the memory we pass to it
+ // somehow! (VZ)
+ char s_accel[50]; // should be big enough, we check for overruns
+ wxString tmp( GetHotKey(*mitem) );
+ strncpy(s_accel, wxGTK_CONV( tmp ), WXSIZEOF(s_accel));
+ s_accel[WXSIZEOF(s_accel) - 1] = '\0';
+ entry.accelerator = s_accel;
+#else // !wxUSE_ACCEL
+ entry.accelerator = (char*) NULL;
+#endif // wxUSE_ACCEL/!wxUSE_ACCEL
+
+ gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
+
+ wxString path( mitem->GetFactoryPath() );
+ menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) );
+
+ if (!menuItem)
+ wxLogError( wxT("Wrong menu path: %s\n"), path.c_str() );
+ }
+
+ if ( !mitem->IsSeparator() )
+ {
+ wxASSERT_MSG( menuItem, wxT("invalid menuitem") );
+