show current/selected driver name in status bar
This commit is contained in:
parent
2481a1da20
commit
3731ee1781
5
bolt.go
5
bolt.go
@ -11,6 +11,7 @@ import (
|
||||
"github.com/ying32/govcl/vcl"
|
||||
"github.com/ying32/govcl/vcl/types"
|
||||
"go.etcd.io/bbolt"
|
||||
"go.etcd.io/bbolt/version"
|
||||
)
|
||||
|
||||
type boltLoadedDatabase struct {
|
||||
@ -26,6 +27,10 @@ func (ld *boltLoadedDatabase) DisplayName() string {
|
||||
return ld.displayName
|
||||
}
|
||||
|
||||
func (ld *boltLoadedDatabase) DriverName() string {
|
||||
return "Bolt " + version.Version
|
||||
}
|
||||
|
||||
func (ld *boltLoadedDatabase) RootElement() *vcl.TTreeNode {
|
||||
return ld.nav
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
// loadedDatabase is a DB-agnostic interface for each loaded database.
|
||||
type loadedDatabase interface {
|
||||
DisplayName() string
|
||||
DriverName() string
|
||||
RootElement() *vcl.TTreeNode
|
||||
RenderForNav(f *TMainForm, ndata *navData)
|
||||
NavChildren(ndata *navData) ([]string, error)
|
||||
|
13
main.go
13
main.go
@ -21,6 +21,7 @@ type TMainForm struct {
|
||||
|
||||
ImageList *vcl.TImageList
|
||||
Menu *vcl.TMainMenu
|
||||
StatusBar *vcl.TStatusBar
|
||||
Buckets *vcl.TTreeView
|
||||
Tabs *vcl.TPageControl
|
||||
propertiesBox *vcl.TMemo
|
||||
@ -78,6 +79,14 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
|
||||
f.Menu.SetImages(f.ImageList)
|
||||
f.Menu.Items().Add(mnuFile)
|
||||
|
||||
//
|
||||
|
||||
f.StatusBar = vcl.NewStatusBar(f)
|
||||
f.StatusBar.SetParent(f)
|
||||
f.StatusBar.SetSimpleText("")
|
||||
|
||||
//
|
||||
|
||||
f.Buckets = vcl.NewTreeView(f)
|
||||
f.Buckets.SetParent(f)
|
||||
f.Buckets.SetImages(f.ImageList)
|
||||
@ -159,7 +168,11 @@ func (f *TMainForm) OnNavChange(sender vcl.IObject, node *vcl.TTreeNode) {
|
||||
}
|
||||
|
||||
ndata := (*navData)(node.Data())
|
||||
|
||||
ndata.ld.RenderForNav(f, ndata) // Handover to the database type's own renderer function
|
||||
|
||||
// We're in charge of common status bar text updates
|
||||
f.StatusBar.SetSimpleText(ndata.ld.DisplayName() + " | " + ndata.ld.DriverName())
|
||||
}
|
||||
|
||||
func (f *TMainForm) OnNavExpanding(sender vcl.IObject, node *vcl.TTreeNode, allowExpansion *bool) {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"unsafe"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
sqlite3 "github.com/mattn/go-sqlite3"
|
||||
"github.com/ying32/govcl/vcl"
|
||||
"github.com/ying32/govcl/vcl/types"
|
||||
)
|
||||
@ -28,6 +28,11 @@ func (ld *sqliteLoadedDatabase) DisplayName() string {
|
||||
return ld.displayName
|
||||
}
|
||||
|
||||
func (ld *sqliteLoadedDatabase) DriverName() string {
|
||||
ver1, _, _ := sqlite3.Version()
|
||||
return "SQLite " + ver1
|
||||
}
|
||||
|
||||
func (ld *sqliteLoadedDatabase) RootElement() *vcl.TTreeNode {
|
||||
return ld.nav
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user