-#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)
- static char s_accel[50]; // must be big enougg
- wxString tmp( GetHotKey(*mitem) );
- strncpy(s_accel, tmp.mb_str(), WXSIZEOF(s_accel));
- 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, path.mb_str() );
-#else // GTK+ 1.0
- menuItem = checkable ? gtk_check_menu_item_new_with_label( mitem->GetText().mb_str() )
- : gtk_menu_item_new_with_label( mitem->GetText().mb_str() );
+ case wxITEM_RADIO:
+ {
+ GSList *group = NULL;
+ if ( m_prevRadio == NULL )
+ {
+ // start of a new radio group
+#ifdef __WXGTK20__
+ m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) );
+#else
+ m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
+ GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
+ // set new text
+ gtk_label_set_text( label, wxGTK_CONV( text ) );
+ // reparse key accel
+ guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
+ if (accel_key != GDK_VoidSymbol)
+ {
+ gtk_widget_add_accelerator (menuItem,
+ "activate_item",
+ gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
+ accel_key,
+ GDK_MOD1_MASK,
+ GTK_ACCEL_LOCKED);
+ }
+#endif
+ }
+ else // continue the radio group
+ {
+#ifdef __WXGTK20__
+ group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (m_prevRadio));
+ m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) );
+#else
+ group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (m_prevRadio));
+ m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
+ GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
+ // set new text
+ gtk_label_set_text( label, wxGTK_CONV( text ) );
+ // reparse key accel
+ guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
+ if (accel_key != GDK_VoidSymbol)
+ {
+ gtk_widget_add_accelerator (menuItem,
+ "activate_item",
+ gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
+ accel_key,
+ GDK_MOD1_MASK,
+ GTK_ACCEL_LOCKED);
+ }
+#endif
+ }
+ break;
+ }
+
+ default:
+ wxFAIL_MSG( _T("unexpected menu item kind") );
+ // fall through
+
+ case wxITEM_NORMAL:
+ {
+#ifdef __WXGTK20__
+ menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
+#else
+ menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
+ GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
+ // set new text
+ gtk_label_set_text( label, wxGTK_CONV( text ) );
+ // reparse key accel
+ guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
+ if (accel_key != GDK_VoidSymbol)
+ {
+ gtk_widget_add_accelerator (menuItem,
+ "activate_item",
+ gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
+ accel_key,
+ GDK_MOD1_MASK,
+ GTK_ACCEL_LOCKED);
+ }
+#endif
+ m_prevRadio = NULL;
+ break;
+ }
+ }