Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Z-Bolt/OctoScreen.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffB42 <10328858+JeffB42@users.noreply.github.com>2021-04-17 21:50:38 +0300
committerJeffB42 <10328858+JeffB42@users.noreply.github.com>2021-04-17 21:50:38 +0300
commitc87fc2af68d91ee43e545b9ac201bd783d8c4776 (patch)
treeb1a728c14e25fd358036c318f4dfa445dd521bbd
parent9818157a8a6b90a00f8167cbc12890a48a396a28 (diff)
added 'yellow bar' to scripts which display a confirmation
-rwxr-xr-xuiWidgets/CommandButton.go15
-rwxr-xr-xuiWidgets/ControlButton.go17
2 files changed, 27 insertions, 5 deletions
diff --git a/uiWidgets/CommandButton.go b/uiWidgets/CommandButton.go
index 030d4c8..3914897 100755
--- a/uiWidgets/CommandButton.go
+++ b/uiWidgets/CommandButton.go
@@ -4,12 +4,14 @@ import (
// "fmt"
"github.com/gotk3/gotk3/gtk"
+
"github.com/Z-Bolt/OctoScreen/logger"
"github.com/Z-Bolt/OctoScreen/octoprintApis"
"github.com/Z-Bolt/OctoScreen/octoprintApis/dataModels"
"github.com/Z-Bolt/OctoScreen/utils"
)
+
type CommandButton struct {
*gtk.Button
@@ -24,7 +26,12 @@ func CreateCommandButton(
commandDefinition *dataModels.CommandDefinition,
iconName string,
) *CommandButton {
- base := utils.MustButtonImage(utils.StrEllipsisLen(commandDefinition.Name, 16), iconName + ".svg", nil)
+ style := ""
+ if commandRequiresConfirmation(commandDefinition) {
+ style = "color-warning-sign-yellow"
+ }
+ base := utils.MustButtonImageStyle(utils.StrEllipsisLen(commandDefinition.Name, 16), iconName + ".svg", style, nil)
+
instance := &CommandButton {
Button: base,
client: client,
@@ -40,8 +47,12 @@ func CreateCommandButton(
return instance
}
+func commandRequiresConfirmation(commandDefinition *dataModels.CommandDefinition) bool {
+ return commandDefinition != nil && len(commandDefinition.Confirm) > 0
+}
+
func (this *CommandButton) handleClicked() {
- if len(this.commandDefinition.Confirm) != 0 {
+ if commandRequiresConfirmation(this.commandDefinition) {
utils.MustConfirmDialogBox(
this.parentWindow,
this.commandDefinition.Confirm,
diff --git a/uiWidgets/ControlButton.go b/uiWidgets/ControlButton.go
index 232abed..53ae63e 100755
--- a/uiWidgets/ControlButton.go
+++ b/uiWidgets/ControlButton.go
@@ -4,12 +4,14 @@ import (
// "fmt"
"github.com/gotk3/gotk3/gtk"
+
"github.com/Z-Bolt/OctoScreen/logger"
"github.com/Z-Bolt/OctoScreen/octoprintApis"
"github.com/Z-Bolt/OctoScreen/octoprintApis/dataModels"
"github.com/Z-Bolt/OctoScreen/utils"
)
+
type ControlButton struct {
*gtk.Button
@@ -24,7 +26,12 @@ func CreateControlButton(
controlDefinition *dataModels.ControlDefinition,
iconName string,
) *ControlButton {
- base := utils.MustButtonImage(utils.StrEllipsisLen(controlDefinition.Name, 16), iconName + ".svg", nil)
+ style := ""
+ if controlRequiresConfirmation(controlDefinition) {
+ style = "color-warning-sign-yellow"
+ }
+ base := utils.MustButtonImageStyle(utils.StrEllipsisLen(controlDefinition.Name, 16), iconName + ".svg", style, nil)
+
instance := &ControlButton {
Button: base,
client: client,
@@ -40,8 +47,12 @@ func CreateControlButton(
return instance
}
+func controlRequiresConfirmation(controlDefinition *dataModels.ControlDefinition) bool {
+ return controlDefinition != nil && len(controlDefinition.Confirm) > 0
+}
+
func (this *ControlButton) handleClicked() {
- if len(this.controlDefinition.Confirm) != 0 {
+ if controlRequiresConfirmation(this.controlDefinition) {
utils.MustConfirmDialogBox(
this.parentWindow,
this.controlDefinition.Confirm,
@@ -54,7 +65,7 @@ func (this *ControlButton) handleClicked() {
func (this *ControlButton) sendCommand() {
logger.Infof("ControlButton.sendCommand(), now sending command %q", this.controlDefinition.Name)
-
+
commandRequest := &octoprintApis.CommandRequest{
Commands: this.controlDefinition.Commands,
}