[GRASS-SVN] r49948 - grass/branches/develbranch_6/gui/wxpython/lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Dec 28 11:02:17 EST 2011


Author: annakrat
Date: 2011-12-28 08:02:17 -0800 (Wed, 28 Dec 2011)
New Revision: 49948

Modified:
   grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py
Log:
wxGUI/lmgr: enable to rename map display by right click on tab (merge from trunk, r49947)

Modified: grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py	2011-12-28 15:58:46 UTC (rev 49947)
+++ grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py	2011-12-28 16:02:17 UTC (rev 49948)
@@ -217,6 +217,18 @@
         self.SetMenuBar(self.menubar)
         self.menucmd = self.menubar.GetCmd()
         
+    def _createTabMenu(self):
+        """!Creates context menu for display tabs.
+        
+        Used to rename display.
+        """
+        menu = wx.Menu()
+        item = wx.MenuItem(menu, id = wx.ID_ANY, text = _("Rename Map Display"))
+        menu.AppendItem(item)
+        self.Bind(wx.EVT_MENU, self.OnRenameDisplay, item)
+        
+        return menu
+        
     def _setCopyingOfSelectedText(self):
         copy = UserSettings.Get(group = 'manager', key = 'copySelectedTextToClipboard', subkey = 'enabled')
         self.goutput.SetCopyingOfSelectedText(copy)
@@ -237,6 +249,8 @@
         else:
             self.gm_cb = FN.FlatNotebook(self, id = wx.ID_ANY, style = cbStyle)
         self.gm_cb.SetTabAreaColour(globalvar.FNPageColor)
+        menu = self._createTabMenu()
+        self.gm_cb.SetRightClickMenu(menu)
         self.notebook.AddPage(page = self.gm_cb, text = _("Map layers"), name = 'layers')
         
         # create 'command output' text area
@@ -405,9 +419,6 @@
             
     def OnCBPageChanged(self, event):
         """!Page in notebook (display) changed"""
-        old_pgnum = event.GetOldSelection()
-        new_pgnum = event.GetSelection()
-        
         self.curr_page   = self.gm_cb.GetCurrentPage()
         self.curr_pagenum = self.gm_cb.GetSelection()
         try:
@@ -444,9 +455,10 @@
             
             # ask user to save current settings
             if maptree.GetCount() > 0:
+                name = self.gm_cb.GetPageText(self.curr_pagenum)
                 dlg = wx.MessageDialog(self,
                                        message = message,
-                                       caption = _("Close Map Display %d") % (self.curr_pagenum + 1),
+                                       caption = _("Close Map Display %s") % name,
                                        style = wx.YES_NO | wx.YES_DEFAULT |
                                        wx.CANCEL | wx.ICON_QUESTION | wx.CENTRE)
                 ret = dlg.ShowModal()
@@ -1079,6 +1091,20 @@
         for display in displays:
             display.OnCloseWindow(event)
         
+    def OnRenameDisplay(self, event):
+        """!Change Map Display name"""
+        name = self.gm_cb.GetPageText(self.curr_pagenum)
+        dlg = wx.TextEntryDialog(self, message = _("Enter new name:"),
+                                 caption = _("Rename Map Display"), defaultValue = name)
+        if dlg.ShowModal() == wx.ID_OK:
+            name = dlg.GetValue()
+            self.gm_cb.SetPageText(page = self.curr_pagenum, text = name)
+            mapdisplay = self.curr_page.maptree.mapdisplay
+            mapdisplay.SetTitle(_("GRASS GIS Map Display: %(name)s  - Location: %(loc)s") % \
+                                     { 'name' : name,
+                                       'loc' : grass.gisenv()["LOCATION_NAME"] })
+        dlg.Destroy()
+        
     def RulesCmd(self, event):
         """!Launches dialog for commands that need rules input and
         processes rules



More information about the grass-commit mailing list