From 3731ee17810bde3c4e05e95892452a352d15dabf Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 15 Jun 2024 11:43:24 +1200 Subject: [PATCH] show current/selected driver name in status bar --- bolt.go | 5 +++++ loadedDatabase.go | 1 + main.go | 13 +++++++++++++ sqlite.go | 7 ++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/bolt.go b/bolt.go index 9386f56..fa340b1 100644 --- a/bolt.go +++ b/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 } diff --git a/loadedDatabase.go b/loadedDatabase.go index fe06b26..2a647ba 100644 --- a/loadedDatabase.go +++ b/loadedDatabase.go @@ -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) diff --git a/main.go b/main.go index 81cfbe8..69b0013 100644 --- a/main.go +++ b/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) { diff --git a/sqlite.go b/sqlite.go index 0162f68..b97d678 100644 --- a/sqlite.go +++ b/sqlite.go @@ -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 }