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