244 |
244 |
245 IDEFrame._init_utils(self) |
245 IDEFrame._init_utils(self) |
246 |
246 |
247 def _init_coll_FileMenu_Items(self, parent): |
247 def _init_coll_FileMenu_Items(self, parent): |
248 AppendMenu(parent, help='', id=wx.ID_NEW, |
248 AppendMenu(parent, help='', id=wx.ID_NEW, |
249 kind=wx.ITEM_NORMAL, text=_(u'New') + '\tCTRL+N') |
249 kind=wx.ITEM_NORMAL, text=_('New') + '\tCTRL+N') |
250 AppendMenu(parent, help='', id=wx.ID_OPEN, |
250 AppendMenu(parent, help='', id=wx.ID_OPEN, |
251 kind=wx.ITEM_NORMAL, text=_(u'Open') + '\tCTRL+O') |
251 kind=wx.ITEM_NORMAL, text=_('Open') + '\tCTRL+O') |
252 parent.Append(ID_FILEMENURECENTPROJECTS, _("&Recent Projects"), self.RecentProjectsMenu) |
252 parent.Append(ID_FILEMENURECENTPROJECTS, _("&Recent Projects"), self.RecentProjectsMenu) |
253 parent.AppendSeparator() |
253 parent.AppendSeparator() |
254 parent.Append(wx.ID_ANY, _("&Tutorials and Examples"), self.TutorialsProjectsMenu) |
254 parent.Append(wx.ID_ANY, _("&Tutorials and Examples"), self.TutorialsProjectsMenu) |
255 |
255 |
256 exemples_dir = Bpath("exemples") |
256 exemples_dir = Bpath("exemples") |
257 project_list = sorted(os.listdir(exemples_dir)) |
257 project_list = sorted(os.listdir(exemples_dir)) |
258 |
258 |
259 for idx, dirname in enumerate(project_list): |
259 for idx, dirname in enumerate(project_list): |
260 text = u'&%d: %s' % (idx + 1, dirname) |
260 text = '&%d: %s' % (idx + 1, dirname) |
261 |
261 |
262 item = self.TutorialsProjectsMenu.Append(wx.ID_ANY, text, '') |
262 item = self.TutorialsProjectsMenu.Append(wx.ID_ANY, text, '') |
263 |
263 |
264 projectpath = os.path.join(exemples_dir, dirname) |
264 projectpath = os.path.join(exemples_dir, dirname) |
265 |
265 |
272 self.ResetView() |
272 self.ResetView() |
273 |
273 |
274 self.Bind(wx.EVT_MENU, OpenExemple, item) |
274 self.Bind(wx.EVT_MENU, OpenExemple, item) |
275 parent.AppendSeparator() |
275 parent.AppendSeparator() |
276 AppendMenu(parent, help='', id=wx.ID_SAVE, |
276 AppendMenu(parent, help='', id=wx.ID_SAVE, |
277 kind=wx.ITEM_NORMAL, text=_(u'Save') + '\tCTRL+S') |
277 kind=wx.ITEM_NORMAL, text=_('Save') + '\tCTRL+S') |
278 AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
278 AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
279 kind=wx.ITEM_NORMAL, text=_(u'Save as') + '\tCTRL+SHIFT+S') |
279 kind=wx.ITEM_NORMAL, text=_('Save as') + '\tCTRL+SHIFT+S') |
280 AppendMenu(parent, help='', id=wx.ID_CLOSE, |
280 AppendMenu(parent, help='', id=wx.ID_CLOSE, |
281 kind=wx.ITEM_NORMAL, text=_(u'Close Tab') + '\tCTRL+W') |
281 kind=wx.ITEM_NORMAL, text=_('Close Tab') + '\tCTRL+W') |
282 AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, |
282 AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, |
283 kind=wx.ITEM_NORMAL, text=_(u'Close Project') + '\tCTRL+SHIFT+W') |
283 kind=wx.ITEM_NORMAL, text=_('Close Project') + '\tCTRL+SHIFT+W') |
284 parent.AppendSeparator() |
284 parent.AppendSeparator() |
285 AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
285 AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
286 kind=wx.ITEM_NORMAL, text=_(u'Page Setup') + '\tCTRL+ALT+P') |
286 kind=wx.ITEM_NORMAL, text=_('Page Setup') + '\tCTRL+ALT+P') |
287 AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
287 AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
288 kind=wx.ITEM_NORMAL, text=_(u'Preview') + '\tCTRL+SHIFT+P') |
288 kind=wx.ITEM_NORMAL, text=_('Preview') + '\tCTRL+SHIFT+P') |
289 AppendMenu(parent, help='', id=wx.ID_PRINT, |
289 AppendMenu(parent, help='', id=wx.ID_PRINT, |
290 kind=wx.ITEM_NORMAL, text=_(u'Print') + '\tCTRL+P') |
290 kind=wx.ITEM_NORMAL, text=_('Print') + '\tCTRL+P') |
291 parent.AppendSeparator() |
291 parent.AppendSeparator() |
292 AppendMenu(parent, help='', id=wx.ID_EXIT, |
292 AppendMenu(parent, help='', id=wx.ID_EXIT, |
293 kind=wx.ITEM_NORMAL, text=_(u'Quit') + '\tCTRL+Q') |
293 kind=wx.ITEM_NORMAL, text=_('Quit') + '\tCTRL+Q') |
294 |
294 |
295 self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
295 self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
296 self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
296 self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
297 self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
297 self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
298 self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) |
298 self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) |
301 self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) |
301 self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) |
302 self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
302 self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
303 self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
303 self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
304 self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
304 self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
305 |
305 |
306 self.AddToMenuToolBar([(wx.ID_NEW, "new", _(u'New'), None), |
306 self.AddToMenuToolBar([(wx.ID_NEW, "new", _('New'), None), |
307 (wx.ID_OPEN, "open", _(u'Open'), None), |
307 (wx.ID_OPEN, "open", _('Open'), None), |
308 (wx.ID_SAVE, "save", _(u'Save'), None), |
308 (wx.ID_SAVE, "save", _('Save'), None), |
309 (wx.ID_SAVEAS, "saveas", _(u'Save As...'), None), |
309 (wx.ID_SAVEAS, "saveas", _('Save As...'), None), |
310 (wx.ID_PRINT, "print", _(u'Print'), None)]) |
310 (wx.ID_PRINT, "print", _('Print'), None)]) |
311 |
311 |
312 def _RecursiveAddMenuItems(self, menu, items): |
312 def _RecursiveAddMenuItems(self, menu, items): |
313 for name, text, helpstr, children in items: |
313 for name, text, helpstr, children in items: |
314 if len(children) > 0: |
314 if len(children) > 0: |
315 new_menu = wx.Menu(title='') |
315 new_menu = wx.Menu(title='') |
325 |
325 |
326 def _init_coll_HelpMenu_Items(self, parent): |
326 def _init_coll_HelpMenu_Items(self, parent): |
327 def handler(event): |
327 def handler(event): |
328 return wx.MessageBox( |
328 return wx.MessageBox( |
329 version.GetCommunityHelpMsg(), |
329 version.GetCommunityHelpMsg(), |
330 _(u'Community support'), |
330 _('Community support'), |
331 wx.OK | wx.ICON_INFORMATION) |
331 wx.OK | wx.ICON_INFORMATION) |
332 |
332 |
333 item = parent.Append(wx.ID_ANY, _(u'Community support'), '') |
333 item = parent.Append(wx.ID_ANY, _('Community support'), '') |
334 self.Bind(wx.EVT_MENU, handler, item) |
334 self.Bind(wx.EVT_MENU, handler, item) |
335 |
335 |
336 parent.Append(wx.MenuItem(helpString='', id=wx.ID_ABOUT, |
336 parent.Append(wx.MenuItem(helpString='', id=wx.ID_ABOUT, |
337 kind=wx.ITEM_NORMAL, text=_(u'About'))) |
337 kind=wx.ITEM_NORMAL, text=_('About'))) |
338 self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
338 self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
339 |
339 |
340 def _init_coll_ConnectionStatusBar_Fields(self, parent): |
340 def _init_coll_ConnectionStatusBar_Fields(self, parent): |
341 parent.SetFieldsCount(3) |
341 parent.SetFieldsCount(3) |
342 |
342 |
698 MenuToolBar.EnableTool(wx.ID_SAVEAS, False) |
698 MenuToolBar.EnableTool(wx.ID_SAVEAS, False) |
699 self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
699 self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
700 |
700 |
701 def RefreshRecentProjectsMenu(self): |
701 def RefreshRecentProjectsMenu(self): |
702 try: |
702 try: |
703 recent_projects = map(DecodeFileSystemPath, |
703 recent_projects = list(map(DecodeFileSystemPath, |
704 self.GetConfigEntry("RecentProjects", [])) |
704 self.GetConfigEntry("RecentProjects", []))) |
705 except Exception: |
705 except Exception: |
706 recent_projects = [] |
706 recent_projects = [] |
707 |
707 |
708 while self.RecentProjectsMenu.GetMenuItemCount() > 0: |
708 while self.RecentProjectsMenu.GetMenuItemCount() > 0: |
709 item = self.RecentProjectsMenu.FindItemByPosition(0) |
709 item = self.RecentProjectsMenu.FindItemByPosition(0) |
710 self.RecentProjectsMenu.Remove(item) |
710 self.RecentProjectsMenu.Remove(item) |
711 |
711 |
712 self.FileMenu.Enable(ID_FILEMENURECENTPROJECTS, len(recent_projects) > 0) |
712 self.FileMenu.Enable(ID_FILEMENURECENTPROJECTS, len(recent_projects) > 0) |
713 for idx, projectpath in enumerate(recent_projects): |
713 for idx, projectpath in enumerate(recent_projects): |
714 text = u'&%d: %s' % (idx + 1, projectpath) |
714 text = '&%d: %s' % (idx + 1, projectpath) |
715 |
715 |
716 item = self.RecentProjectsMenu.Append(wx.ID_ANY, text, '') |
716 item = self.RecentProjectsMenu.Append(wx.ID_ANY, text, '') |
717 self.Bind(wx.EVT_MENU, self.GenerateOpenRecentProjectFunction(projectpath), item) |
717 self.Bind(wx.EVT_MENU, self.GenerateOpenRecentProjectFunction(projectpath), item) |
718 |
718 |
719 def GenerateOpenRecentProjectFunction(self, projectpath): |
719 def GenerateOpenRecentProjectFunction(self, projectpath): |
797 self.EditMenu.AppendSeparator() |
797 self.EditMenu.AppendSeparator() |
798 self.GenerateMenuRecursive(items, self.EditMenu) |
798 self.GenerateMenuRecursive(items, self.EditMenu) |
799 if panel is not None: |
799 if panel is not None: |
800 panel.RefreshConfNodeMenu(self.EditMenu) |
800 panel.RefreshConfNodeMenu(self.EditMenu) |
801 else: |
801 else: |
802 for i in xrange(self.EditMenuSize, self.EditMenu.GetMenuItemCount()): |
802 for i in range(self.EditMenuSize, self.EditMenu.GetMenuItemCount()): |
803 item = self.EditMenu.FindItemByPosition(i) |
803 item = self.EditMenu.FindItemByPosition(i) |
804 if item is not None: |
804 if item is not None: |
805 if item.IsSeparator(): |
805 if item.IsSeparator(): |
806 self.EditMenu.RemoveItem(item) |
806 self.EditMenu.RemoveItem(item) |
807 else: |
807 else: |
825 |
825 |
826 def GetConfigEntry(self, entry_name, default): |
826 def GetConfigEntry(self, entry_name, default): |
827 return cPickle.loads(str(self.Config.Read(entry_name, cPickle.dumps(default)))) |
827 return cPickle.loads(str(self.Config.Read(entry_name, cPickle.dumps(default)))) |
828 |
828 |
829 def ResetConnectionStatusBar(self): |
829 def ResetConnectionStatusBar(self): |
830 for field in xrange(self.ConnectionStatusBar.GetFieldsCount()): |
830 for field in range(self.ConnectionStatusBar.GetFieldsCount()): |
831 self.ConnectionStatusBar.SetStatusText('', field) |
831 self.ConnectionStatusBar.SetStatusText('', field) |
832 |
832 |
833 def ResetView(self): |
833 def ResetView(self): |
834 IDEFrame.ResetView(self) |
834 IDEFrame.ResetView(self) |
835 if self.CTR is not None: |
835 if self.CTR is not None: |
840 self.DebugVariablePanel.SetDataProducer(None) |
840 self.DebugVariablePanel.SetDataProducer(None) |
841 self.ResetConnectionStatusBar() |
841 self.ResetConnectionStatusBar() |
842 |
842 |
843 def RefreshConfigRecentProjects(self, projectpath, err=False): |
843 def RefreshConfigRecentProjects(self, projectpath, err=False): |
844 try: |
844 try: |
845 recent_projects = map(DecodeFileSystemPath, |
845 recent_projects = list(map(DecodeFileSystemPath, |
846 self.GetConfigEntry("RecentProjects", [])) |
846 self.GetConfigEntry("RecentProjects", []))) |
847 except Exception: |
847 except Exception: |
848 recent_projects = [] |
848 recent_projects = [] |
849 if projectpath in recent_projects: |
849 if projectpath in recent_projects: |
850 recent_projects.remove(projectpath) |
850 recent_projects.remove(projectpath) |
851 if not err: |
851 if not err: |
852 recent_projects.insert(0, projectpath) |
852 recent_projects.insert(0, projectpath) |
853 self.Config.Write("RecentProjects", cPickle.dumps( |
853 self.Config.Write("RecentProjects", cPickle.dumps( |
854 map(EncodeFileSystemPath, recent_projects[:MAX_RECENT_PROJECTS]))) |
854 list(map(EncodeFileSystemPath, recent_projects[:MAX_RECENT_PROJECTS])))) |
855 self.Config.Flush() |
855 self.Config.Flush() |
856 |
856 |
857 def ResetPerspective(self): |
857 def ResetPerspective(self): |
858 IDEFrame.ResetPerspective(self) |
858 IDEFrame.ResetPerspective(self) |
859 self.RefreshStatusToolBar() |
859 self.RefreshStatusToolBar() |