Browse Source

wxGUI: fix adding layers to tree in import dialog (https://trac.osgeo.org/grass/ticket/2860)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67644 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 9 years ago
parent
commit
bcec22a0ab
2 changed files with 9 additions and 6 deletions
  1. 8 5
      gui/wxpython/core/gconsole.py
  2. 1 1
      gui/wxpython/modules/import_export.py

+ 8 - 5
gui/wxpython/core/gconsole.py

@@ -116,7 +116,7 @@ class CmdThread(threading.Thread):
         os.environ['GRASS_MESSAGE_FORMAT'] = 'gui'
         os.environ['GRASS_MESSAGE_FORMAT'] = 'gui'
         while True:
         while True:
             requestId, args, kwds = self.requestQ.get()
             requestId, args, kwds = self.requestQ.get()
-            for key in ('callable', 'onDone', 'onPrepare', 'userData', 'notification'):
+            for key in ('callable', 'onDone', 'onPrepare', 'userData', 'addLayer', 'notification'):
                 if key in kwds:
                 if key in kwds:
                     vars()[key] = kwds[key]
                     vars()[key] = kwds[key]
                     del kwds[key]
                     del kwds[key]
@@ -202,6 +202,7 @@ class CmdThread(threading.Thread):
                                   pid=requestId,
                                   pid=requestId,
                                   onDone=vars()['onDone'],
                                   onDone=vars()['onDone'],
                                   userData=vars()['userData'],
                                   userData=vars()['userData'],
+                                  addLayer=vars()['addLayer'],
                                   notification=vars()['notification'])
                                   notification=vars()['notification'])
 
 
                 # send event
                 # send event
@@ -424,7 +425,8 @@ class GConsole(wx.EvtHandler):
         self.writeError.emit(text=text)
         self.writeError.emit(text=text)
 
 
     def RunCmd(self, command, compReg=True, skipInterface=False,
     def RunCmd(self, command, compReg=True, skipInterface=False,
-               onDone=None, onPrepare=None, userData=None, notification=Notification.MAKE_VISIBLE):
+               onDone=None, onPrepare=None, userData=None, addLayer=None,
+               notification=Notification.MAKE_VISIBLE):
         """Run command typed into console command prompt (GPrompt).
         """Run command typed into console command prompt (GPrompt).
 
 
         .. todo::
         .. todo::
@@ -445,6 +447,7 @@ class GConsole(wx.EvtHandler):
                                    given
                                    given
         :param onDone: function to be called when command is finished
         :param onDone: function to be called when command is finished
         :param onPrepare: function to be called before command is launched
         :param onPrepare: function to be called before command is launched
+        :param addLayer: to be passed in the mapCreated signal
         :param userData: data defined for the command
         :param userData: data defined for the command
         """
         """
         if len(command) == 0:
         if len(command) == 0:
@@ -531,7 +534,7 @@ class GConsole(wx.EvtHandler):
                                       stdout=self.cmdStdOut,
                                       stdout=self.cmdStdOut,
                                       stderr=self.cmdStdErr,
                                       stderr=self.cmdStdErr,
                                       onDone=onDone, onPrepare=onPrepare,
                                       onDone=onDone, onPrepare=onPrepare,
-                                      userData=userData,
+                                      userData=userData, addLayer=addLayer,
                                       env=os.environ.copy(),
                                       env=os.environ.copy(),
                                       notification=notification)
                                       notification=notification)
                 self.cmdOutputTimer.Start(50)
                 self.cmdOutputTimer.Start(50)
@@ -583,7 +586,7 @@ class GConsole(wx.EvtHandler):
                                       stdout=self.cmdStdOut,
                                       stdout=self.cmdStdOut,
                                       stderr=self.cmdStdErr,
                                       stderr=self.cmdStdErr,
                                       onDone=onDone, onPrepare=onPrepare,
                                       onDone=onDone, onPrepare=onPrepare,
-                                      userData=userData,
+                                      userData=userData, addLayer=addLayer,
                                       notification=notification)
                                       notification=notification)
             self.cmdOutputTimer.Start(50)
             self.cmdOutputTimer.Start(50)
 
 
@@ -689,7 +692,7 @@ class GConsole(wx.EvtHandler):
                         if '@' not in lname:
                         if '@' not in lname:
                             lname += '@' + grass.gisenv()['MAPSET']
                             lname += '@' + grass.gisenv()['MAPSET']
                         if grass.find_file(lname, element=p.get('element'))['fullname']:
                         if grass.find_file(lname, element=p.get('element'))['fullname']:
-                            self.mapCreated.emit(name=lname, ltype=prompt)
+                            self.mapCreated.emit(name=lname, ltype=prompt, add=event.addLayer)
         if name == 'r.mask':
         if name == 'r.mask':
             self.updateMap.emit()
             self.updateMap.emit()
         
         

+ 1 - 1
gui/wxpython/modules/import_export.py

@@ -411,7 +411,7 @@ class GdalImportDialog(ImportDialog):
                 cmd.append('--overwrite')
                 cmd.append('--overwrite')
             
             
             # run in Layer Manager
             # run in Layer Manager
-            self._giface.RunCmd(cmd, onDone = self.OnCmdDone, userData = userData)
+            self._giface.RunCmd(cmd, onDone=self.OnCmdDone, userData=userData, addLayer=False)
 
 
     def OnCmdDone(self, event):
     def OnCmdDone(self, event):
         """Load layers and close if required"""
         """Load layers and close if required"""