From e31126cbd7492cda012a881bb5596dcc07d48997 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 7 May 2005 18:09:18 +0000 Subject: [PATCH] committed aupdated patch that adds support for bitmaps in submenus and simplifies some of the code in GtkAppend() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33980 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/menu.cpp | 206 ++++++++++++---------------------------------- src/gtk1/menu.cpp | 206 ++++++++++++---------------------------------- 2 files changed, 102 insertions(+), 310 deletions(-) diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 787746807b..af79ceffec 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -1024,6 +1024,11 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) { GtkWidget *menuItem; + wxString text; +#ifndef __WXGTK20__ + GtkLabel* label; +#endif + if ( mitem->IsSeparator() ) { #ifdef __WXGTK20__ @@ -1032,55 +1037,10 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) // TODO menuItem = gtk_menu_item_new(); #endif - if (pos == -1) - gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); - else - gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); - } - else if ( mitem->IsSubMenu() ) - { - // text has "_" instead of "&" after mitem->SetText() - wxString text( mitem->GetText() ); - -#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 - - gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu ); - if (pos == -1) - gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); - else - gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); - - gtk_widget_show( mitem->GetSubMenu()->m_menu ); - - // if adding a submenu to a menu already existing in the menu bar, we - // must set invoking window to allow processing events from this - // submenu - if ( m_invokingWindow ) - wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow); - - m_prevRadio = NULL; } else if (mitem->GetBitmap().Ok()) { - wxString text = mitem->GetText(); + text = mitem->GetText(); const wxBitmap *bitmap = &mitem->GetBitmap(); #ifdef __WXGTK20__ @@ -1104,69 +1064,25 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem), image ); - gtk_signal_connect( GTK_OBJECT(menuItem), "activate", - GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), - (gpointer)this ); - - if (pos == -1) - gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); - else - gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); #else GdkPixmap *gdk_pixmap = bitmap->GetPixmap(); GdkBitmap *gdk_bitmap = bitmap->GetMask() ? bitmap->GetMask()->GetBitmap() : (GdkBitmap*) NULL; menuItem = gtk_pixmap_menu_item_new (); - GtkWidget *label = gtk_accel_label_new ( wxGTK_CONV( text ) ); + label = GTK_LABEL(gtk_accel_label_new ( wxGTK_CONV( text ) )); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_container_add (GTK_CONTAINER (menuItem), label); + gtk_container_add (GTK_CONTAINER (menuItem), GTK_WIDGET(label)); gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuItem); - guint accel_key; - GdkModifierType accel_mods; - - // accelerator for the item, as specified by its label - // (ex. Ctrl+O for open) - gtk_accelerator_parse(GetGtkHotKey(*mitem).c_str(), &accel_key, - &accel_mods); - if (accel_key != GDK_VoidSymbol) - { - gtk_widget_add_accelerator (menuItem, - "activate_item", - m_accel, - accel_key, accel_mods, - GTK_ACCEL_VISIBLE); - } - - // accelerator for the underlined char (ex ALT+F for the File menu) - 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); - } - gtk_widget_show (label); + gtk_widget_show (GTK_WIDGET(label)); - mitem->SetLabelWidget(label); + mitem->SetLabelWidget(GTK_WIDGET(label)); GtkWidget* pixmap = gtk_pixmap_new( gdk_pixmap, gdk_bitmap ); gtk_widget_show(pixmap); gtk_pixmap_menu_item_set_pixmap(GTK_PIXMAP_MENU_ITEM( menuItem ), pixmap); - gtk_signal_connect( GTK_OBJECT(menuItem), "activate", - GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), - (gpointer)this ); - - if (pos == -1) - gtk_menu_append( GTK_MENU(m_menu), menuItem ); - else - gtk_menu_insert( GTK_MENU(m_menu), menuItem, pos ); - gtk_widget_show( menuItem ); #endif m_prevRadio = NULL; @@ -1174,7 +1090,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) else // a normal item { // text has "_" instead of "&" after mitem->SetText() so don't use it - wxString text( mitem->GetText() ); + text = mitem->GetText() ; switch ( mitem->GetKind() ) { @@ -1184,20 +1100,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) menuItem = gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV( text ) ); #else menuItem = gtk_check_menu_item_new_with_label( wxGTK_CONV( text ) ); - GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child ); + 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; @@ -1213,20 +1118,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) 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 ); + 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 @@ -1237,20 +1131,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) #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); - } + label = GTK_LABEL( GTK_BIN(menuItem)->child ); #endif } break; @@ -1266,34 +1147,13 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) 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); - } + label = GTK_LABEL( GTK_BIN(menuItem)->child ); #endif m_prevRadio = NULL; break; } } - gtk_signal_connect( GTK_OBJECT(menuItem), "activate", - GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), - (gpointer)this ); - - if (pos == -1) - gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); - else - gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); } guint accel_key; @@ -1312,6 +1172,11 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) GTK_ACCEL_VISIBLE); } + if (pos == -1) + gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); + else + gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); + gtk_widget_show( menuItem ); if ( !mitem->IsSeparator() ) @@ -1325,6 +1190,37 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) gtk_signal_connect( GTK_OBJECT(menuItem), "deselect", GTK_SIGNAL_FUNC(gtk_menu_nolight_callback), (gpointer)this ); + + if ( mitem->IsSubMenu() && mitem->GetKind() != wxITEM_RADIO && mitem->GetKind() != wxITEM_CHECK ) + { + gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu ); + + gtk_widget_show( mitem->GetSubMenu()->m_menu ); + + // if adding a submenu to a menu already existing in the menu bar, we + // must set invoking window to allow processing events from this + // submenu + if ( m_invokingWindow ) + wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow); + } + else + { + gtk_signal_connect( GTK_OBJECT(menuItem), "activate", + GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), + (gpointer)this ); + } +#ifndef __WXGTK20__ + 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 } mitem->SetMenuItem(menuItem); diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 787746807b..af79ceffec 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -1024,6 +1024,11 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) { GtkWidget *menuItem; + wxString text; +#ifndef __WXGTK20__ + GtkLabel* label; +#endif + if ( mitem->IsSeparator() ) { #ifdef __WXGTK20__ @@ -1032,55 +1037,10 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) // TODO menuItem = gtk_menu_item_new(); #endif - if (pos == -1) - gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); - else - gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); - } - else if ( mitem->IsSubMenu() ) - { - // text has "_" instead of "&" after mitem->SetText() - wxString text( mitem->GetText() ); - -#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 - - gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu ); - if (pos == -1) - gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); - else - gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); - - gtk_widget_show( mitem->GetSubMenu()->m_menu ); - - // if adding a submenu to a menu already existing in the menu bar, we - // must set invoking window to allow processing events from this - // submenu - if ( m_invokingWindow ) - wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow); - - m_prevRadio = NULL; } else if (mitem->GetBitmap().Ok()) { - wxString text = mitem->GetText(); + text = mitem->GetText(); const wxBitmap *bitmap = &mitem->GetBitmap(); #ifdef __WXGTK20__ @@ -1104,69 +1064,25 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem), image ); - gtk_signal_connect( GTK_OBJECT(menuItem), "activate", - GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), - (gpointer)this ); - - if (pos == -1) - gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); - else - gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); #else GdkPixmap *gdk_pixmap = bitmap->GetPixmap(); GdkBitmap *gdk_bitmap = bitmap->GetMask() ? bitmap->GetMask()->GetBitmap() : (GdkBitmap*) NULL; menuItem = gtk_pixmap_menu_item_new (); - GtkWidget *label = gtk_accel_label_new ( wxGTK_CONV( text ) ); + label = GTK_LABEL(gtk_accel_label_new ( wxGTK_CONV( text ) )); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_container_add (GTK_CONTAINER (menuItem), label); + gtk_container_add (GTK_CONTAINER (menuItem), GTK_WIDGET(label)); gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuItem); - guint accel_key; - GdkModifierType accel_mods; - - // accelerator for the item, as specified by its label - // (ex. Ctrl+O for open) - gtk_accelerator_parse(GetGtkHotKey(*mitem).c_str(), &accel_key, - &accel_mods); - if (accel_key != GDK_VoidSymbol) - { - gtk_widget_add_accelerator (menuItem, - "activate_item", - m_accel, - accel_key, accel_mods, - GTK_ACCEL_VISIBLE); - } - - // accelerator for the underlined char (ex ALT+F for the File menu) - 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); - } - gtk_widget_show (label); + gtk_widget_show (GTK_WIDGET(label)); - mitem->SetLabelWidget(label); + mitem->SetLabelWidget(GTK_WIDGET(label)); GtkWidget* pixmap = gtk_pixmap_new( gdk_pixmap, gdk_bitmap ); gtk_widget_show(pixmap); gtk_pixmap_menu_item_set_pixmap(GTK_PIXMAP_MENU_ITEM( menuItem ), pixmap); - gtk_signal_connect( GTK_OBJECT(menuItem), "activate", - GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), - (gpointer)this ); - - if (pos == -1) - gtk_menu_append( GTK_MENU(m_menu), menuItem ); - else - gtk_menu_insert( GTK_MENU(m_menu), menuItem, pos ); - gtk_widget_show( menuItem ); #endif m_prevRadio = NULL; @@ -1174,7 +1090,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) else // a normal item { // text has "_" instead of "&" after mitem->SetText() so don't use it - wxString text( mitem->GetText() ); + text = mitem->GetText() ; switch ( mitem->GetKind() ) { @@ -1184,20 +1100,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) menuItem = gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV( text ) ); #else menuItem = gtk_check_menu_item_new_with_label( wxGTK_CONV( text ) ); - GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child ); + 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; @@ -1213,20 +1118,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) 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 ); + 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 @@ -1237,20 +1131,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) #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); - } + label = GTK_LABEL( GTK_BIN(menuItem)->child ); #endif } break; @@ -1266,34 +1147,13 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) 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); - } + label = GTK_LABEL( GTK_BIN(menuItem)->child ); #endif m_prevRadio = NULL; break; } } - gtk_signal_connect( GTK_OBJECT(menuItem), "activate", - GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), - (gpointer)this ); - - if (pos == -1) - gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); - else - gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); } guint accel_key; @@ -1312,6 +1172,11 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) GTK_ACCEL_VISIBLE); } + if (pos == -1) + gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); + else + gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); + gtk_widget_show( menuItem ); if ( !mitem->IsSeparator() ) @@ -1325,6 +1190,37 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) gtk_signal_connect( GTK_OBJECT(menuItem), "deselect", GTK_SIGNAL_FUNC(gtk_menu_nolight_callback), (gpointer)this ); + + if ( mitem->IsSubMenu() && mitem->GetKind() != wxITEM_RADIO && mitem->GetKind() != wxITEM_CHECK ) + { + gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu ); + + gtk_widget_show( mitem->GetSubMenu()->m_menu ); + + // if adding a submenu to a menu already existing in the menu bar, we + // must set invoking window to allow processing events from this + // submenu + if ( m_invokingWindow ) + wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow); + } + else + { + gtk_signal_connect( GTK_OBJECT(menuItem), "activate", + GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), + (gpointer)this ); + } +#ifndef __WXGTK20__ + 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 } mitem->SetMenuItem(menuItem); -- 2.45.2