Sfoglia il codice sorgente

wxGUI: copy&paste customization (done by Vaclav Petras)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46607 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 anni fa
parent
commit
fd3d124ee2

+ 2 - 1
gui/wxpython/docs/wxGUI.html

@@ -594,7 +594,8 @@ Michael Barton, Arizona State University, USA<br>
 Daniel Calvelo Aros<br>
 Daniel Calvelo Aros<br>
 Jachym Cepicky<br>
 Jachym Cepicky<br>
 Markus Metz, Germany<br>
 Markus Metz, Germany<br>
-Anna Kratochvilova, <a href="http://www.cvut.cz">Czech Technical University in Prague</a>, Czech Republic<br><br>
+Anna Kratochvilova, <a href="http://www.cvut.cz">Czech Technical University in Prague</a>, Czech Republic<br>
+Vaclav Petras, <a href="http://www.cvut.cz">Czech Technical University in Prague</a>, Czech Republic<br><br>
 
 
 Icons created by <a href="http://robert.szczepanek.pl">Robert Szczepanek</a>, Poland (<a href="https://svn.osgeo.org/osgeo/graphics/trunk/toolbar-icons/24x24/">SVN</a>)
 Icons created by <a href="http://robert.szczepanek.pl">Robert Szczepanek</a>, Poland (<a href="https://svn.osgeo.org/osgeo/graphics/trunk/toolbar-icons/24x24/">SVN</a>)
 
 

+ 22 - 1
gui/wxpython/gui_modules/goutput.py

@@ -9,13 +9,14 @@ Classes:
  - GMStdout
  - GMStdout
  - GMStderr
  - GMStderr
 
 
-(C) 2007-2010 by the GRASS Development Team
+(C) 2007-2011 by the GRASS Development Team
 This program is free software under the GNU General Public
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 for details.
 
 
 @author Michael Barton (Arizona State University)
 @author Michael Barton (Arizona State University)
 @author Martin Landa <landa.martin gmail.com>
 @author Martin Landa <landa.martin gmail.com>
+@author Vaclav Petras <wenzeslaus gmail.com> (copy&paste customization)
 """
 """
 
 
 import os
 import os
@@ -620,6 +621,19 @@ class GMConsole(wx.SplitterWindow):
         """!Get running command or None"""
         """!Get running command or None"""
         return self.requestQ.get()
         return self.requestQ.get()
     
     
+    def SetCopyingOfSelectedText(self, copy):
+        """!Enable or disable copying of selected text in to clipboard.
+        Effects prompt and output.
+        
+        @param copy True for enable, False for disable
+        """
+        if copy:
+            self.cmd_prompt.Bind(wx.stc.EVT_STC_PAINTED, self.cmd_prompt.OnTextSelectionChanged)
+            self.cmd_output.Bind(wx.stc.EVT_STC_PAINTED, self.cmd_output.OnTextSelectionChanged)
+        else:
+            self.cmd_prompt.Unbind(wx.stc.EVT_STC_PAINTED)
+            self.cmd_output.Unbind(wx.stc.EVT_STC_PAINTED)
+        
     def OnUpdateStatusBar(self, event):
     def OnUpdateStatusBar(self, event):
         """!Update statusbar text"""
         """!Update statusbar text"""
         if event.GetString():
         if event.GetString():
@@ -992,6 +1006,13 @@ class GMStc(wx.stc.StyledTextCtrl):
         #
         #
         self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
         self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
         
         
+    def OnTextSelectionChanged(self, event):
+        """!Copy selected text to clipboard and skip event.
+        The same function is in TextCtrlAutoComplete class (prompt.py).
+        """
+        self.Copy()
+        event.Skip()
+        
     def SetStyle(self):
     def SetStyle(self):
         """!Set styles for styled text output windows with type face 
         """!Set styles for styled text output windows with type face 
         and point size selected by user (Courier New 10 is default)"""
         and point size selected by user (Courier New 10 is default)"""

+ 16 - 0
gui/wxpython/gui_modules/preferences.py

@@ -117,6 +117,9 @@ class Settings:
                     'search' : False,
                     'search' : False,
                     'pyshell' : False,
                     'pyshell' : False,
                     },
                     },
+                'copySelectedTextToClipboard' : {
+                    'enabled' : False
+                    },
                 },
                 },
             #
             #
             # appearance
             # appearance
@@ -1158,6 +1161,19 @@ class PreferencesDialog(PreferencesBaseDialog):
         gridSizer.Add(item = hidePyShell,
         gridSizer.Add(item = hidePyShell,
                       pos = (row, 0), span = (1, 2))
                       pos = (row, 0), span = (1, 2))
         
         
+        #
+        # Selected text is copied to clipboard
+        #
+        row += 1
+        copySelectedTextToClipboard = wx.CheckBox(parent = panel, id = wx.ID_ANY,
+                                                  label = _("Automatically copy selected text to clipboard (in Command console)"),
+                                                  name = 'IsChecked')
+        copySelectedTextToClipboard.SetValue(self.settings.Get(group = 'manager', key = 'copySelectedTextToClipboard', subkey = 'enabled'))
+        self.winId['manager:copySelectedTextToClipboard:enabled'] = copySelectedTextToClipboard.GetId()
+        
+        gridSizer.Add(item = copySelectedTextToClipboard,
+                      pos = (row, 0), span = (1, 2))
+        
         sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
         sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
         
         

+ 9 - 1
gui/wxpython/gui_modules/prompt.py

@@ -10,13 +10,14 @@ Classes:
  - GPromptPopUp
  - GPromptPopUp
  - GPromptSTC
  - GPromptSTC
 
 
-(C) 2009-2010 by the GRASS Development Team
+(C) 2009-2011 by the GRASS Development Team
 This program is free software under the GNU General Public
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 for details.
 
 
 @author Martin Landa <landa.martin gmail.com>
 @author Martin Landa <landa.martin gmail.com>
 @author Michael Barton <michael.barton@asu.edu>
 @author Michael Barton <michael.barton@asu.edu>
+@author Vaclav Petras <wenzeslaus gmail.com> (copy&paste customization)
 """
 """
 
 
 import os
 import os
@@ -706,6 +707,13 @@ class GPromptSTC(GPrompt, wx.stc.StyledTextCtrl):
         self.Bind(wx.stc.EVT_STC_AUTOCOMP_SELECTION, self.OnItemSelected)
         self.Bind(wx.stc.EVT_STC_AUTOCOMP_SELECTION, self.OnItemSelected)
         self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemChanged)
         self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemChanged)
         
         
+    def OnTextSelectionChanged(self, event):
+        """!Copy selected text to clipboard and skip event.
+        The same function is in GMStc class (goutput.py).
+        """
+        self.Copy()
+        event.Skip()
+        
     def OnItemChanged(self, event):
     def OnItemChanged(self, event):
         """!Change text in statusbar 
         """!Change text in statusbar 
         if the item selection in the auto-completion list is changed"""
         if the item selection in the auto-completion list is changed"""

+ 7 - 1
gui/wxpython/wxgui.py

@@ -233,6 +233,10 @@ class GMFrame(wx.Frame):
         self.SetMenuBar(self.menubar)
         self.SetMenuBar(self.menubar)
         self.menucmd = self.menubar.GetCmd()
         self.menucmd = self.menubar.GetCmd()
         
         
+    def _setCopyingOfSelectedText(self):
+        copy = UserSettings.Get(group = 'manager', key = 'copySelectedTextToClipboard', subkey = 'enabled')
+        self.goutput.SetCopyingOfSelectedText(copy)
+        
     def _createNoteBook(self):
     def _createNoteBook(self):
         """!Creates notebook widgets"""
         """!Creates notebook widgets"""
         self.notebook = menuform.GNotebook(parent = self, style = globalvar.FNPageDStyle)
         self.notebook = menuform.GNotebook(parent = self, style = globalvar.FNPageDStyle)
@@ -248,6 +252,7 @@ class GMFrame(wx.Frame):
         # create 'command output' text area
         # create 'command output' text area
         self.goutput = goutput.GMConsole(self)
         self.goutput = goutput.GMConsole(self)
         self.notebook.AddPage(page = self.goutput, text = _("Command console"), name = 'console')
         self.notebook.AddPage(page = self.goutput, text = _("Command console"), name = 'console')
+        self._setCopyingOfSelectedText()
         
         
         # create 'search module' notebook page
         # create 'search module' notebook page
         if not UserSettings.Get(group = 'manager', key = 'hideTabs', subkey = 'search'):
         if not UserSettings.Get(group = 'manager', key = 'hideTabs', subkey = 'search'):
@@ -295,9 +300,10 @@ class GMFrame(wx.Frame):
         
         
     def OnSettingsChanged(self, event):
     def OnSettingsChanged(self, event):
         """!Here can be functions which have to be called after EVT_SETTINGS_CHANGED. 
         """!Here can be functions which have to be called after EVT_SETTINGS_CHANGED. 
-        Now recreates menu only.
+        Now recreates menu and set copying of selected text to clipboard (in goutput).
         """
         """
         self._createMenuBar()
         self._createMenuBar()
+        self._setCopyingOfSelectedText()
         
         
     def OnGCPManager(self, event):
     def OnGCPManager(self, event):
         """!Launch georectifier module
         """!Launch georectifier module