summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eventMouseClick.go7
-rw-r--r--find.go50
-rw-r--r--structs.go1
-rw-r--r--table.go22
-rw-r--r--treeWidget.go32
5 files changed, 64 insertions, 48 deletions
diff --git a/eventMouseClick.go b/eventMouseClick.go
index ed3eafe..0dfa7e4 100644
--- a/eventMouseClick.go
+++ b/eventMouseClick.go
@@ -4,6 +4,7 @@
package main
import (
+ "github.com/awesome-gocui/gocui"
"go.wit.com/log"
"go.wit.com/widget"
)
@@ -115,6 +116,12 @@ func doMouseClick(w int, h int) {
}
}
+// todo: use this?
+func ctrlDown(g *gocui.Gui, v *gocui.View) error {
+ log.Info("todo: clicked with ctrlDown")
+ return nil
+}
+
func doMouseDoubleClick(w int, h int) {
me.mouse.double = false
// log.Printf("actually a double click (%d,%d)", w, h)
diff --git a/find.go b/find.go
index d3aa19d..2cb94f3 100644
--- a/find.go
+++ b/find.go
@@ -176,12 +176,6 @@ func findWindowUnderMouse() *guiWidget {
return nil
}
-// todo: use this?
-func ctrlDown(g *gocui.Gui, v *gocui.View) error {
- log.Info("todo: clicked with ctrlDown")
- return nil
-}
-
func (tk *guiWidget) findParentWindow() *guiWidget {
if tk.WidgetType() == widget.Window {
return tk
@@ -191,3 +185,47 @@ func (tk *guiWidget) findParentWindow() *guiWidget {
}
return tk.parent.findParentWindow()
}
+
+func (tk *guiWidget) findWidgetByName(name string) *guiWidget {
+ if tk.cuiName == name {
+ return tk
+ }
+ for _, child := range tk.children {
+ found := child.findWidgetByName(name)
+ if found != nil {
+ return found
+ }
+ }
+ return nil
+}
+
+func (tk *guiWidget) findWidgetByView(v *gocui.View) *guiWidget {
+ if tk.v == v {
+ return tk
+ }
+ if tk.cuiName == v.Name() {
+ log.Log(NOW, "findWidget() error. names are mismatched or out of sync", tk.cuiName)
+ log.Log(NOW, "findWidget() or maybe the view has been deleted")
+ // return tk
+ }
+ for _, child := range tk.children {
+ found := child.findWidgetByView(v)
+ if found != nil {
+ return found
+ }
+ }
+ return nil
+}
+
+func (tk *guiWidget) findWidgetById(id int) *guiWidget {
+ if tk.WidgetId() == id {
+ return tk
+ }
+ for _, child := range tk.children {
+ found := child.findWidgetById(id)
+ if found != nil {
+ return found
+ }
+ }
+ return nil
+}
diff --git a/structs.go b/structs.go
index d7acb28..fcd04cf 100644
--- a/structs.go
+++ b/structs.go
@@ -153,7 +153,6 @@ type libnotify struct {
icon internalTK // libnotify menu icon
window internalTK // the libnotify menu
help internalTK // the help menu
- // menuWindow internalTK // libnotify menu window
}
// this is the gocui way
diff --git a/table.go b/table.go
index 97bc81d..a6f31e6 100644
--- a/table.go
+++ b/table.go
@@ -13,7 +13,8 @@ import (
"go.wit.com/widget"
)
-func initWindowPB(pb *guipb.Widget) *guiWidget {
+/*
+func initGridPB(pb *guipb.Widget) *guiWidget {
var w *guiWidget
w = new(guiWidget)
@@ -24,6 +25,7 @@ func initWindowPB(pb *guipb.Widget) *guiWidget {
w.labelN = pb.Name
return w
}
+*/
func initGridPB(pb *guipb.Widget) *guiWidget {
var w *guiWidget
@@ -42,19 +44,21 @@ func showTable(t *guipb.Table) {
return
}
log.Info("gocui: table.Title", t.Title)
- if t.Window == nil {
- log.Info("gocui: missing window widget. tree plugin error")
- return
- }
- log.Info("gocui: need to add window here id =", t.Window.Id, t.Window.Name)
+ // log.Info("gocui: need to add window here id =", t.Window.Id, t.Window.Name)
if t.Grid == nil {
log.Info("gocui: missing grid widget. tree plugin error")
return
}
+ root := me.treeRoot.TK.(*guiWidget)
+ parent := root.findWidgetById(int(t.Parent.Id))
+ if parent == nil {
+ log.Info("gocui: show table error. parent.Id not found", t.Parent.Id)
+ return
+ }
+
log.Info("gocui: need to add grid here id =", t.Grid.Id)
- win := initWindowPB(t.Window)
- grid := initWindowPB(t.Window)
- grid.parent = win
+ grid := initGridPB(t.Grid)
+ grid.parent = parent
}
func enableWidget(n *tree.Node) {
diff --git a/treeWidget.go b/treeWidget.go
index 5b231bb..6cd75dd 100644
--- a/treeWidget.go
+++ b/treeWidget.go
@@ -7,7 +7,6 @@ import (
"strconv"
"strings"
- "github.com/awesome-gocui/gocui"
"go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
@@ -121,34 +120,3 @@ func (tk *guiWidget) SetVisible(b bool) {
tk.Hide()
}
}
-
-func (tk *guiWidget) findWidgetByName(name string) *guiWidget {
- if tk.cuiName == name {
- return tk
- }
- for _, child := range tk.children {
- found := child.findWidgetByName(name)
- if found != nil {
- return found
- }
- }
- return nil
-}
-
-func (tk *guiWidget) findWidgetByView(v *gocui.View) *guiWidget {
- if tk.v == v {
- return tk
- }
- if tk.cuiName == v.Name() {
- log.Log(NOW, "findWidget() error. names are mismatched or out of sync", tk.cuiName)
- log.Log(NOW, "findWidget() or maybe the view has been deleted")
- // return tk
- }
- for _, child := range tk.children {
- found := child.findWidgetByView(v)
- if found != nil {
- return found
- }
- }
- return nil
-}