From 4f19c8b64df77d204dfd0fab462f99f4ef5009b7 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 30 Jan 2024 02:38:06 -0600 Subject: disable color works Signed-off-by: Jeff Carr --- plugin.go | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'plugin.go') diff --git a/plugin.go b/plugin.go index 223d4e5..774b85d 100644 --- a/plugin.go +++ b/plugin.go @@ -28,6 +28,12 @@ func action(a widget.Action) { me.treeRoot = n } addWidget(n) + w = n.TK.(*guiWidget) + if w.enable { + // don't change the color + } else { + w.setColor(&colorDisabled) + } } else { // this is done to protect the plugin being 'refreshed' with the // widget binary tree. TODO: find a way to keep them in sync @@ -35,10 +41,19 @@ func action(a widget.Action) { a.WidgetId, a.ActionType, a.WidgetType, a.ProgName) } case widget.Show: - if widget.GetBool(a.Value) { - w.showView() + if w.Visible() { + // widget was already shown } else { - w.hideWidgets() + log.Log(INFO, "Setting Visible to true", a.ProgName) + w.SetVisible(true) + } + w.showView() + case widget.Hide: + if w.Visible() { + log.Log(INFO, "Setting Visible to false", a.ProgName) + w.SetVisible(false) + } else { + // widget was already hidden } case widget.Set: if a.WidgetType == widget.Flag { @@ -62,19 +77,11 @@ func action(a widget.Action) { log.Log(NOW, "attempting to close the plugin and release stdout and stderr") standardExit() case widget.Enable: - if w.Visible() { - // widget was already shown - } else { - log.Log(INFO, "Setting Visible to true", a.ProgName) - w.SetVisible(true) - } + w.enable = true + w.enableColor() case widget.Disable: - if w.Visible() { - log.Log(INFO, "Setting Visible to false", a.ProgName) - w.SetVisible(false) - } else { - // widget was already hidden - } + w.enable = false + w.disableColor() case widget.Delete: if w == nil { return -- cgit v1.2.3