Browse Source

wxGUI datacatalog: ask to create location when empty database added (#937)

Linda Kladivova 4 years ago
parent
commit
1528ba8b2c
1 changed files with 13 additions and 1 deletions
  1. 13 1
      gui/wxpython/datacatalog/catalog.py

+ 13 - 1
gui/wxpython/datacatalog/catalog.py

@@ -105,7 +105,19 @@ class DataCatalog(wx.Panel):
                            os.getcwd(), wx.DD_DEFAULT_STYLE)
         if dlg.ShowModal() == wx.ID_OK:
             grassdatabase = dlg.GetPath()
-            self.tree.InsertGrassDb(name=grassdatabase)
+            grassdb_node = self.tree.InsertGrassDb(name=grassdatabase)
+
+            # Offer to create a new location
+            if grassdb_node and not os.listdir(grassdatabase):
+                message = _("Do you want to create a location?")
+                dlg2 = wx.MessageDialog(self,
+                                        message=message,
+                                        caption=_("Create location?"),
+                                        style=wx.YES_NO | wx.YES_DEFAULT |
+                                        wx.ICON_QUESTION)
+                if dlg2.ShowModal() == wx.ID_YES:
+                    self.tree.CreateLocation(grassdb_node)
+                dlg2.Destroy()
         dlg.Destroy()
 
     def OnCreateMapset(self, event):