diff options
Diffstat (limited to 'plugin.go')
| -rw-r--r-- | plugin.go | 63 |
1 files changed, 16 insertions, 47 deletions
@@ -29,12 +29,12 @@ type aplug struct { // TODO: make Main() main() and never allow the user to call it // run plugin.Main() when the plugin is loaded Main func(func ()) // this never returns. Each plugin must have it's own goroutine - Queue func(func ()) // Should this return right away? Should it wait (can it wait?) + // Queue func(func ()) // Should this return right away? Should it wait (can it wait?) Quit func() // NewWindow func(*toolkit.Widget) // simplifies passing to the plugin - Send func(*toolkit.Widget, *toolkit.Widget) + // Send func(*toolkit.Widget, *toolkit.Widget) // should replace Send() Action func(*toolkit.Action) @@ -74,16 +74,11 @@ func LoadToolkit(name string) bool { newPlug.Main = loadFuncF(&newPlug, "Main") // should send things to the goroutine above - newPlug.Queue = loadFuncF(&newPlug, "Queue") + // newPlug.Queue = loadFuncF(&newPlug, "Queue") // unload the plugin and restore state newPlug.Quit = loadFuncE(&newPlug, "Quit") - // Sends a widget (button, checkbox, etc) and it's parent widget - // This includes instructions like "Add", "Delete", "Disable", etc -// newPlug.Send = loadFunc2(&newPlug, "Send") - - // This should replace Send() // Sends instructions like "Add", "Delete", "Disable", etc // Sends a widget (button, checkbox, etc) and it's parent widget newPlug.Action = loadFuncA(&newPlug, "Action") @@ -190,7 +185,8 @@ func loadPlugin(p *aplug, name string) { homeDir, err := os.UserHomeDir() if err != nil { - exit(err) + log(logError, "loadPlugin() error. exiting here?") + return } // attempt to write out the file from the internal resource @@ -230,36 +226,6 @@ func loadfile(filename string) *plugin.Plugin { return plug } -/* -// Sends a widget and what to do with it to the plugin -// parent = n, child = c -func send(p *Node, c *Node) { - for _, aplug := range allPlugins { - log(debugPlugin, "Send() aplug =", aplug.name, "type=", c.widget.Type, "action=", c.widget.Action, "name=", c.widget.Name) - if (aplug.Send == nil) { - log(debugPlugin, "Failed. Send() == nil for", aplug.name) - continue - } - aplug.Send(&c.parent.widget, &c.widget) - } -} -*/ - -// Sends a widget and what to do with it to the plugin -// parent = n, child = c -/* -func action(a *toolkit.Action) { - for _, aplug := range allPlugins { - log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.Type) - if (aplug.Action == nil) { - log(debugPlugin, "Failed Action() == nil for", aplug.name) - continue - } - aplug.Action(a) - } -} -*/ - // Sends a widget and what to do with it to the plugin // parent = n, child = c @@ -268,16 +234,19 @@ func action(a *toolkit.Action) { func newaction(a *toolkit.Action, n *Node, where *Node) { if (n != nil) { a.Widget = &n.widget + a.WidgetId = n.id + a.WidgetType = n.widget.Type + a.ActionType = a.ActionType } // action(&a, newNode, n) // newaction(&a, newNode, n) if (where != nil) { log(debugGui, "Action() START on where X,Y, Next X,Y =", where.Name, where.X, where.Y, where.NextX, where.NextY) - a.Where = &where.widget + a.ParentId = where.id switch where.widget.Type { case toolkit.Grid: - where.Dump(true) + // where.Dump(true) log(debugGui, "Action() START on Grid (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY) // // fix values here if they are invalid. Index starts at 1 @@ -288,15 +257,15 @@ func newaction(a *toolkit.Action, n *Node, where *Node) { where.NextY = 1 } // - a.Where.X = where.NextX - a.Where.Y = where.NextY + a.X = where.NextX + a.Y = where.NextY log(debugGui, "Action() END on Grid (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY) default: } } for _, aplug := range allPlugins { - log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.Type) + log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.ActionType) if (aplug.Action == nil) { log(debugPlugin, "Failed Action() == nil for", aplug.name) continue @@ -307,19 +276,19 @@ func newaction(a *toolkit.Action, n *Node, where *Node) { if (where != nil) { switch where.widget.Type { case toolkit.Grid: - log(debugNow, "Action() START size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY) + log(logInfo, "Action() START size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY) where.NextY += 1 if (where.NextY > where.Y) { where.NextX += 1 where.NextY = 1 } - log(debugNow, "Action() END size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY) + log(logInfo, "Action() END size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY) where.Name = "jwc gridlaksdfjkl" where.Width = 320 where.Height = 240 // where.NextX = 5 // where.NextY = 7 - where.Dump(true) + // where.Dump(logInfo) default: } } |
