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:
authorAleksei Kvitinskii <aleksei.kvitinskii@gmail.com>2019-12-25 14:21:08 +0300
committerAleksei Kvitinskii <aleksei.kvitinskii@gmail.com>2019-12-25 14:21:22 +0300
commitef1d8cf76b80f02165798bf5d1d89b019a6d9d8b (patch)
treeb2b2d4af16ba225fa0f110f4e09e8511846c8cf4
parent6c98fa4526777f3a26c8d2e362ea8651fb941960 (diff)
stabilizationv2.5.1
-rw-r--r--default_menu.json76
-rw-r--r--ui/common.go27
-rw-r--r--ui/idle_status.go7
-rw-r--r--ui/menu.go106
-rw-r--r--vendor/github.com/mcuadros/go-octoprint/common.go3
5 files changed, 112 insertions, 107 deletions
diff --git a/default_menu.json b/default_menu.json
deleted file mode 100644
index 46a50b9..0000000
--- a/default_menu.json
+++ /dev/null
@@ -1,76 +0,0 @@
-[
- {
- "name": "Home",
- "icon": "home",
- "panel": "home"
- },
- {
- "name": "Actions",
- "icon": "actions",
- "panel": "menu",
- "items": [
- {
- "name": "Move",
- "icon": "move",
- "panel": "move"
- },
- {
- "name": "Extrude",
- "icon": "filament",
- "panel": "extrude_multitool"
- },
- {
- "name": "Fan",
- "icon": "fan",
- "panel": "fan"
- },
- {
- "name": "Temperature",
- "icon": "heat-up",
- "panel": "temperature"
- },
- {
- "name": "Control",
- "icon": "control",
- "panel": "control"
- },
- {
- "name": "ToolChanger",
- "icon": "toolchanger",
- "panel": "toolchanger"
- }
- ]
- },
- {
- "name": "Filament",
- "icon": "filament",
- "panel": "filament_multitool"
- },
- {
- "name": "Configuration",
- "icon": "control",
- "panel": "menu",
- "items": [
- {
- "name": "Bed Level",
- "icon": "bed-level",
- "panel": "bed-level"
- },
- {
- "name": "ZOffsets",
- "icon": "z-offset-increase",
- "panel": "nozzle-calibration"
- },
- {
- "name": "Network",
- "icon": "network",
- "panel": "network"
- },
- {
- "name": "System",
- "icon": "info",
- "panel": "system"
- }
- ]
- }
-] \ No newline at end of file
diff --git a/ui/common.go b/ui/common.go
index 5d9d6f1..3ddaed7 100644
--- a/ui/common.go
+++ b/ui/common.go
@@ -1,12 +1,9 @@
package ui
import (
- "encoding/json"
"fmt"
- "io/ioutil"
"log"
"math"
- "os"
"strings"
"sync"
"time"
@@ -396,27 +393,3 @@ func MessageDialog(parent *gtk.Window, msg string) {
win.Run()
}
-
-func getDeafultMenu() []octoprint.MenuItem {
-
- jsonFile, err := os.Open("default_menu.json")
- // if we os.Open returns an error then handle it
- if err != nil {
- fmt.Println(err)
- }
-
- defer jsonFile.Close()
-
- var items []octoprint.MenuItem
-
- byteValue, err := ioutil.ReadAll(jsonFile)
- if err != nil {
- fmt.Println("Error in default_menu.json")
- fmt.Println(err)
- return items
- }
-
- json.Unmarshal(byteValue, &items)
-
- return items
-}
diff --git a/ui/idle_status.go b/ui/idle_status.go
index 6bca46c..1eb68d2 100644
--- a/ui/idle_status.go
+++ b/ui/idle_status.go
@@ -38,12 +38,15 @@ func (m *idleStatusPanel) initialize() {
var menuItems []octoprint.MenuItem
- if m.UI.Settings == nil {
+ Logger.Info(m.UI.Settings)
+
+ if m.UI.Settings == nil || len(m.UI.Settings.MenuStructure) == 0 {
+ Logger.Info("Loading default menu")
menuItems = getDeafultMenu()
} else {
+ Logger.Info("Loading octo menu")
menuItems = m.UI.Settings.MenuStructure
}
- // fmt.Print(m.UI.Settings.MenuStructure)
buttons := MustGrid()
buttons.SetRowHomogeneous(true)
diff --git a/ui/menu.go b/ui/menu.go
index c1148b2..aa1301f 100644
--- a/ui/menu.go
+++ b/ui/menu.go
@@ -1,11 +1,12 @@
package ui
import (
+ "encoding/json"
+
"github.com/mcuadros/go-octoprint"
)
func getPanel(ui *UI, parent Panel, item octoprint.MenuItem) Panel {
-
switch item.Panel {
case "menu":
return MenuPanel(ui, parent, item.Items)
@@ -65,3 +66,106 @@ func (m *menuPanel) initialize() {
defer m.Initialize()
m.arrangeMenuItems(m.g, m.items, 4)
}
+
+func getDeafultMenu() []octoprint.MenuItem {
+
+ default_menu := `[
+ {
+ "name": "Home",
+ "icon": "home",
+ "panel": "home"
+ },
+ {
+ "name": "Actions",
+ "icon": "actions",
+ "panel": "menu",
+ "items": [
+ {
+ "name": "Move",
+ "icon": "move",
+ "panel": "move"
+ },
+ {
+ "name": "Extrude",
+ "icon": "filament",
+ "panel": "extrude_multitool"
+ },
+ {
+ "name": "Fan",
+ "icon": "fan",
+ "panel": "fan"
+ },
+ {
+ "name": "Temperature",
+ "icon": "heat-up",
+ "panel": "temperature"
+ },
+ {
+ "name": "Control",
+ "icon": "control",
+ "panel": "control"
+ },
+ {
+ "name": "ToolChanger",
+ "icon": "toolchanger",
+ "panel": "toolchanger"
+ }
+ ]
+ },
+ {
+ "name": "Filament",
+ "icon": "filament",
+ "panel": "filament_multitool"
+ },
+ {
+ "name": "Configuration",
+ "icon": "control",
+ "panel": "menu",
+ "items": [
+ {
+ "name": "Bed Level",
+ "icon": "bed-level",
+ "panel": "bed-level"
+ },
+ {
+ "name": "ZOffsets",
+ "icon": "z-offset-increase",
+ "panel": "nozzle-calibration"
+ },
+ {
+ "name": "Network",
+ "icon": "network",
+ "panel": "network"
+ },
+ {
+ "name": "System",
+ "icon": "info",
+ "panel": "system"
+ }
+ ]
+ }
+ ]`
+
+ // filePath := filepath.Join(os.Getenv("OCTOSCREEN_STYLE_PATH"), "default_menu.json")
+ // // filePath := "/etc/octoscreen/config/default_menu.json"
+ // jsonFile, err := os.Open(filePath)
+
+ // if err != nil {
+ // Logger.Info(err)
+ // }
+
+ // defer jsonFile.Close()
+
+ // byteValue, err := ioutil.ReadAll(jsonFile)
+ // if err != nil {
+ // Logger.Info("Error in default_menu.json")
+ // Logger.Info(err)
+ // return items
+ // }
+
+ var items []octoprint.MenuItem
+
+ json.Unmarshal([]byte(default_menu), &items)
+
+ return items
+}
diff --git a/vendor/github.com/mcuadros/go-octoprint/common.go b/vendor/github.com/mcuadros/go-octoprint/common.go
index a6f8c4d..0533b77 100644
--- a/vendor/github.com/mcuadros/go-octoprint/common.go
+++ b/vendor/github.com/mcuadros/go-octoprint/common.go
@@ -183,6 +183,7 @@ func (s ConnectionState) IsOperational() bool {
func (s ConnectionState) IsPrinting() bool {
return strings.HasPrefix(string(s), "Printing") ||
+ strings.HasPrefix(string(s), "Starting") ||
strings.HasPrefix(string(s), "Sending") ||
strings.HasPrefix(string(s), "Paused") ||
strings.HasPrefix(string(s), "Transfering") ||
@@ -863,7 +864,7 @@ type PrinterProfile struct {
} `json:"volume"`
Extruder struct {
- Count int `json:"count"`
+ Count int `json:"count"`
SharedNozzle bool `json:"sharedNozzle"`
} `json:"extruder"`
}