Skip to content

Commit

Permalink
Move tree widget into UI package
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikKalkoken committed Oct 17, 2024
1 parent cc9d870 commit 6fc6169
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions FyneApp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Website = "https://github.com/ErikKalkoken/janice"
Icon = "icon.png"
Name = "Janice"
ID = "io.github.erikkalkoken.janice"
Version = "0.4.2"
Build = 2
Version = "0.5.0"
Build = 1

[Release]
BuildName = "janice"
Expand Down
4 changes: 2 additions & 2 deletions internal/widgets/treenode.go → internal/ui/treenode.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package widgets
package ui

import (
"fmt"
Expand All @@ -16,7 +16,7 @@ type TreeNode struct {
value *widget.Label
}

// NewTreeNode returns a new TreeNode instance.
// NewTreeNode returns a new instance of the [TreeNode] widget.
func NewTreeNode() *TreeNode {
n := &TreeNode{
key: widget.NewLabel(""),
Expand Down
5 changes: 2 additions & 3 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"golang.org/x/text/message"

"github.com/ErikKalkoken/janice/internal/jsondocument"
"github.com/ErikKalkoken/janice/internal/widgets"
)

// preference keys
Expand Down Expand Up @@ -125,11 +124,11 @@ func (u *UI) makeTree() *widget.Tree {
return u.document.IsBranch(id)
},
func(branch bool) fyne.CanvasObject {
return widgets.NewTreeNode()
return NewTreeNode()
},
func(uid widget.TreeNodeID, branch bool, co fyne.CanvasObject) {
node := u.document.Value(uid)
obj := co.(*widgets.TreeNode)
obj := co.(*TreeNode)
var text string
switch v := node.Value; node.Type {
case jsondocument.Array:
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
"github.com/ErikKalkoken/janice/internal/ui"
)

const (
appID = "io.github.erikkalkoken.janice"
)

type logLevelFlag struct {
value slog.Level
}
Expand Down Expand Up @@ -42,7 +46,7 @@ func main() {
flag.Parse()
log.SetFlags(log.LstdFlags | log.Llongfile)
slog.SetLogLoggerLevel(levelFlag.value)
a := app.NewWithID("io.github.erikkalkoken.janice")
a := app.NewWithID(appID)
if *versionFlag {
fmt.Printf("Current version is: %s", a.Metadata().Version)
return
Expand Down

0 comments on commit 6fc6169

Please sign in to comment.