merge
authorEdouard Tisserant
Thu, 14 Jun 2012 18:50:28 +0200
changeset 773 3f3f1b8fcb07
parent 772 98786137232d (current diff)
parent 771 85d33a130a5c (diff)
child 774 78b5fa92dd1c
merge
--- a/Beremiz.py	Thu Jun 14 18:50:10 2012 +0200
+++ b/Beremiz.py	Thu Jun 14 18:50:28 2012 +0200
@@ -292,12 +292,6 @@
 
 class Beremiz(IDEFrame):
 	
-    def _init_coll_MenuBar_Menus(self, parent):
-        IDEFrame._init_coll_MenuBar_Menus(self, parent)
-        
-        parent.Insert(pos=CONFNODEMENU_POSITION, 
-                      menu=self.ConfNodeMenu, title=_(u'&ConfNode'))
-    
     def _init_utils(self):
         self.ConfNodeMenu = wx.Menu(title='')
         self.RecentProjectsMenu = wx.Menu(title='')
@@ -367,6 +361,8 @@
     def _init_ctrls(self, prnt):
         IDEFrame._init_ctrls(self, prnt)
         
+        self.EditMenuSize = self.EditMenu.GetMenuItemCount()
+        
         self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=ID_BEREMIZINSPECTOR)
         accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), ID_BEREMIZINSPECTOR)]
         for method,shortcut in [("Stop",     wx.WXK_F4),
@@ -470,7 +466,6 @@
         self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
         
         self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
-        self.RefreshConfNodeMenu()
         self.RefreshAll()
         self.LogConsole.SetFocus()
 
@@ -714,7 +709,9 @@
         self.AUIManager.GetPane("StatusToolBar").Position(1)
         self.AUIManager.Update()
     
-    def RefreshConfNodeMenu(self):
+    def RefreshEditMenu(self):
+        IDEFrame.RefreshEditMenu(self)
+        
         if self.CTR is not None:
             selected = self.TabsOpened.GetSelection()
             if selected >= 0:
@@ -722,20 +719,27 @@
             else:
                 panel = None
             if panel != self.LastPanelSelected:
-                for i in xrange(self.ConfNodeMenu.GetMenuItemCount()):
-                    item = self.ConfNodeMenu.FindItemByPosition(0)
-                    self.ConfNodeMenu.Delete(item.GetId())
+                for i in xrange(self.EditMenuSize, self.EditMenu.GetMenuItemCount()):
+                    item = self.EditMenu.FindItemByPosition(self.EditMenuSize)
+                    if item.IsSeparator():
+                        self.EditMenu.RemoveItem(item)
+                    else:
+                        self.EditMenu.Delete(item.GetId())
                 self.LastPanelSelected = panel
                 if panel is not None:
                     items = panel.GetConfNodeMenuItems()
                 else:
                     items = []
-                self.MenuBar.EnableTop(CONFNODEMENU_POSITION, len(items) > 0)
-                self.GenerateMenuRecursive(items, self.ConfNodeMenu)
+                if len(items) > 0:
+                    self.EditMenu.AppendSeparator()
+                    self.GenerateMenuRecursive(items, self.EditMenu)
             if panel is not None:
-                panel.RefreshConfNodeMenu(self.ConfNodeMenu)
-        else:
-            self.MenuBar.EnableTop(CONFNODEMENU_POSITION, False)
+                panel.RefreshConfNodeMenu(self.EditMenu)
+        else:
+            for i in xrange(self.EditMenuSize, self.EditMenu.GetMenuItemCount()):
+                item = self.EditMenu.FindItemByPosition(i)
+                self.EditMenu.Delete(item.GetId())
+            self.LastPanelSelected = None
         self.MenuBar.UpdateMenus()
     
     def RefreshAll(self):
@@ -882,14 +886,6 @@
     def OnAboutMenu(self, event):
         OpenHtmlFrame(self,_("About Beremiz"), Bpath("doc","about.html"), wx.Size(550, 500))
     
-    def OnPouSelectedChanged(self, event):
-        wx.CallAfter(self.RefreshConfNodeMenu)
-        IDEFrame.OnPouSelectedChanged(self, event)
-    
-    def OnPageClose(self, event):
-        wx.CallAfter(self.RefreshConfNodeMenu)
-        IDEFrame.OnPageClose(self, event)
-    
     def OnProjectTreeItemBeginEdit(self, event):
         selected = event.GetItem()
         if self.ProjectTree.GetPyData(selected)["type"] == ITEM_CONFNODE:
--- a/canfestival/NetworkEditor.py	Thu Jun 14 18:50:10 2012 +0200
+++ b/canfestival/NetworkEditor.py	Thu Jun 14 18:50:28 2012 +0200
@@ -107,4 +107,4 @@
     
     def OnNodeSelectedChanged(self, event):
         NetworkEditorTemplate.OnNodeSelectedChanged(self, event)
-        wx.CallAfter(self.ParentWindow.RefreshConfNodeMenu)
+        wx.CallAfter(self.ParentWindow.RefreshEditMenu)