]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/menu.cpp
Do not declare "environ" variable ourselves under MSW.
[wxWidgets.git] / src / gtk / menu.cpp
index 3c99374528c5a1f5b76b05169b3b0960cd5534e9..ae2d4df83251e92bc0204b262bad096c996e3284 100644 (file)
@@ -230,13 +230,15 @@ void wxMenuBar::Detach()
 
 bool wxMenuBar::Append( wxMenu *menu, const wxString &title )
 {
 
 bool wxMenuBar::Append( wxMenu *menu, const wxString &title )
 {
-    if ( !wxMenuBarBase::Append( menu, title ) )
-        return false;
-
-    return GtkAppend(menu, title);
+    if (wxMenuBarBase::Append(menu, title))
+    {
+        GtkAppend(menu, title);
+        return true;
+    }
+    return false;
 }
 
 }
 
-bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos)
+void wxMenuBar::GtkAppend(wxMenu* menu, const wxString& title, int pos)
 {
     menu->SetLayoutDirection(GetLayoutDirection());
 
 {
     menu->SetLayoutDirection(GetLayoutDirection());
 
@@ -251,7 +253,10 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos)
         const wxString str(wxStripMenuCodes(item->GetItemLabel()));
 
         if ( item->IsSubMenu() )
         const wxString str(wxStripMenuCodes(item->GetItemLabel()));
 
         if ( item->IsSubMenu() )
-            return GtkAppend(item->GetSubMenu(), str, pos);
+        {
+            GtkAppend(item->GetSubMenu(), str, pos);
+            return;
+        }
 
         menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );
 
 
         menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );
 
@@ -282,21 +287,16 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos)
 
     if ( m_menuBarFrame )
         AttachToFrame( menu, m_menuBarFrame );
 
     if ( m_menuBarFrame )
         AttachToFrame( menu, m_menuBarFrame );
-
-    return true;
 }
 
 bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
 {
 }
 
 bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
 {
-    if ( !wxMenuBarBase::Insert(pos, menu, title) )
-        return false;
-
-    // TODO
-
-    if ( !GtkAppend(menu, title, (int)pos) )
-        return false;
-
-    return true;
+    if (wxMenuBarBase::Insert(pos, menu, title))
+    {
+        GtkAppend(menu, title, int(pos));
+        return true;
+    }
+    return false;
 }
 
 wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
 }
 
 wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
@@ -745,7 +745,7 @@ wxString wxMenu::GetTitle() const
     return wxConvertMnemonicsFromGTK(wxMenuBase::GetTitle());
 }
 
     return wxConvertMnemonicsFromGTK(wxMenuBase::GetTitle());
 }
 
-bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
+void wxMenu::GtkAppend(wxMenuItem* mitem, int pos)
 {
     GtkWidget *menuItem;
     switch (mitem->GetKind())
 {
     GtkWidget *menuItem;
     switch (mitem->GetKind())
@@ -763,9 +763,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
                 wxMenuItem* radioGroupItem = NULL;
 
                 const size_t numItems = GetMenuItemCount();
                 wxMenuItem* radioGroupItem = NULL;
 
                 const size_t numItems = GetMenuItemCount();
-                const size_t n = pos == -1 ? numItems
-                                           : static_cast<size_t>(pos);
-                if ( n > 0 )
+                const size_t n = pos == -1 ? numItems - 1 : size_t(pos);
+
+                if (n != 0)
                 {
                     wxMenuItem* const itemPrev = FindItemByPosition(n - 1);
                     if ( itemPrev->GetKind() == wxITEM_RADIO )
                 {
                     wxMenuItem* const itemPrev = FindItemByPosition(n - 1);
                     if ( itemPrev->GetKind() == wxITEM_RADIO )
@@ -776,9 +776,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
                     }
                 }
 
                     }
                 }
 
-                if ( n < numItems )
+                if (radioGroupItem == NULL && n != numItems - 1)
                 {
                 {
-                    wxMenuItem* const itemNext = FindItemByPosition(n);
+                    wxMenuItem* const itemNext = FindItemByPosition(n + 1);
                     if ( itemNext->GetKind() == wxITEM_RADIO )
                     {
                         // Inserting an item before an existing radio item
                     if ( itemNext->GetKind() == wxITEM_RADIO )
                     {
                         // Inserting an item before an existing radio item
@@ -850,24 +850,26 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
                               mitem);
         }
     }
                               mitem);
         }
     }
-
-    return true;
 }
 
 wxMenuItem* wxMenu::DoAppend(wxMenuItem *mitem)
 {
 }
 
 wxMenuItem* wxMenu::DoAppend(wxMenuItem *mitem)
 {
-    if (!GtkAppend(mitem))
-        return NULL;
-
-    return wxMenuBase::DoAppend(mitem);
+    if (wxMenuBase::DoAppend(mitem))
+    {
+        GtkAppend(mitem);
+        return mitem;
+    }
+    return NULL;
 }
 
 wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 {
 }
 
 wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 {
-    if ( !GtkAppend(item, (int)pos) )
-        return NULL;
-
-    return wxMenuBase::DoInsert(pos, item);
+    if (wxMenuBase::DoInsert(pos, item))
+    {
+        GtkAppend(item, int(pos));
+        return item;
+    }
+    return NULL;
 }
 
 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
 }
 
 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)