浏览代码

wxGUI: move highlighting of command tab from lmgr to notebook

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53923 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 年之前
父节点
当前提交
09f6bda4f3
共有 2 个文件被更改,包括 25 次插入9 次删除
  1. 25 7
      gui/wxpython/gui_core/widgets.py
  2. 0 2
      gui/wxpython/lmgr/frame.py

+ 25 - 7
gui/wxpython/gui_core/widgets.py

@@ -72,8 +72,12 @@ class NotebookController:
         self.notebookPages = {}
         self.notebookPages = {}
         self.classObject = classObject
         self.classObject = classObject
         self.widget = widget
         self.widget = widget
-        # TODO: (...) should be only once in wxGUI
         self.highlightedTextEnd = _(" (...)")
         self.highlightedTextEnd = _(" (...)")
+        self.BindPageChanged()
+
+    def BindPageChanged(self):
+        """!Binds page changed event."""
+        self.widget.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnRemoveHighlight)
 
 
     def AddPage(self, **kwargs):
     def AddPage(self, **kwargs):
         """!Add a new page
         """!Add a new page
@@ -131,12 +135,23 @@ class NotebookController:
         idx = self.GetPageIndexByName(page)
         idx = self.GetPageIndexByName(page)
         if self.classObject.GetSelection(self.widget) != idx:
         if self.classObject.GetSelection(self.widget) != idx:
             self.classObject.SetSelection(self.widget, idx)
             self.classObject.SetSelection(self.widget, idx)
-            # FIXME: this code was not explicitly tested
-            # FIXME: remove this from function lmgr.frame.Frame.OnPageChanged
-            text = self.classObject.GetPageText(self.widget, idx)
-            if text.endswith(self.highlightedTextEnd):
-                text.replace(self.highlightedTextEnd, '')
-                self.classObject.SetPageText(self.widget, idx, text)
+
+            self.RemoveHighlight(idx)
+
+    def OnRemoveHighlight(self, event):
+        """!Highlighted tab name should be removed."""
+        page = event.GetSelection()
+        self.RemoveHighlight(page)
+
+    def RemoveHighlight(self, page):
+        """!Removes highlight string from notebook tab name if necessary.
+
+        @param page index
+        """
+        text = self.classObject.GetPageText(self.widget, page)
+        if text.endswith(self.highlightedTextEnd):
+            text = text.replace(self.highlightedTextEnd, '')
+            self.classObject.SetPageText(self.widget, page, text)
 
 
     def GetPageIndexByName(self, page):
     def GetPageIndexByName(self, page):
         """!Get notebook page index
         """!Get notebook page index
@@ -176,6 +191,9 @@ class FlatNotebookController(NotebookController):
     def __init__(self, classObject, widget):
     def __init__(self, classObject, widget):
         NotebookController.__init__(self, classObject, widget)
         NotebookController.__init__(self, classObject, widget)
 
 
+    def BindPageChanged(self):
+        self.widget.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnRemoveHighlight)
+
     def GetPageIndexByName(self, page):
     def GetPageIndexByName(self, page):
         """!Get notebook page index
         """!Get notebook page index
         
         

+ 0 - 2
gui/wxpython/lmgr/frame.py

@@ -477,8 +477,6 @@ class GMFrame(wx.Frame):
         """!Page in notebook changed"""
         """!Page in notebook changed"""
         page = event.GetSelection()
         page = event.GetSelection()
         if page == self.notebook.GetPageIndexByName('output'):
         if page == self.notebook.GetPageIndexByName('output'):
-            # remove '(...)'
-            self.notebook.SetPageText(page, _("Command console"))
             wx.CallAfter(self.goutput.ResetFocus)
             wx.CallAfter(self.goutput.ResetFocus)
         self.SetStatusText('', 0)
         self.SetStatusText('', 0)