Skip to content

Commit

Permalink
*: cosmetic changes
Browse files Browse the repository at this point in the history
Signed-off-by: Máximo Cuadros <[email protected]>
  • Loading branch information
mcuadros committed Jan 2, 2018
1 parent 596aae8 commit e5c245f
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 15 deletions.
14 changes: 11 additions & 3 deletions ui/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ui
import (
"fmt"
"log"
"math"
"sync"
"time"

Expand All @@ -11,6 +12,7 @@ import (
)

const panelW = 4
const panelH = 2

type Panel interface {
Grid() *gtk.Grid
Expand All @@ -37,11 +39,17 @@ func NewCommonPanel(ui *UI) CommonPanel {
}

func (p *CommonPanel) Initialize() {
for i := 1; i <= panelW; i++ {
p.grid.Attach(MustBox(gtk.ORIENTATION_HORIZONTAL, 0), i, 0, 1, 1)
last := panelW * panelH
if last < len(p.buttons) {
cols := math.Ceil(float64(len(p.buttons)) / float64(panelW))
last = int(cols) * panelW
}

p.grid.Attach(MustButtonImage("Back", "back.svg", p.UI.ShowDefaultPanel), 4, 1, 1, 1)
for i := len(p.buttons) + 1; i < last; i++ {
p.AddButton(MustBox(gtk.ORIENTATION_HORIZONTAL, 0))
}

p.AddButton(MustButtonImage("Back", "back.svg", p.UI.ShowDefaultPanel))
}

func (p *CommonPanel) AddButton(b gtk.IWidget) {
Expand Down
2 changes: 1 addition & 1 deletion ui/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewControlPanel(ui *UI) *ControlPanel {
}

func (m *ControlPanel) initialize() {
m.Initialize()
defer m.Initialize()

for _, c := range m.getControl() {
b := m.createControlButton(c)
Expand Down
4 changes: 2 additions & 2 deletions ui/filament.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewFilamentPanel(ui *UI) *FilamentPanel {
}

func (m *FilamentPanel) initialize() {
m.Initialize()
defer m.Initialize()

m.grid.Attach(m.createExtrudeButton("Extrude", "extrude.svg", 1), 1, 0, 1, 1)
m.grid.Attach(m.createExtrudeButton("Retract", "retract.svg", -1), 4, 0, 1, 1)
Expand Down Expand Up @@ -79,7 +79,7 @@ func (m *FilamentPanel) loadTemperatureState(s *octoprint.TemperatureState) {
func (m *FilamentPanel) addNewTool(tool string) {
m.labels[tool] = MustLabelWithImage("extruder.svg", "")
m.box.Add(m.labels[tool])
m.tool.AddStep(Step{tool, tool})
m.tool.AddStep(Step{strings.Title(tool), tool})

Logger.Infof("New tool detected %s", tool)
}
Expand Down
2 changes: 1 addition & 1 deletion ui/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func NewHomePanel(ui *UI) *HomePanel {
}

func (m *HomePanel) initialize() {
m.Initialize()
defer m.Initialize()

m.AddButton(m.createMoveButton("Home All", "home.svg",
octoprint.XAxis, octoprint.YAxis, octoprint.ZAxis,
Expand Down
2 changes: 1 addition & 1 deletion ui/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewMovePanel(ui *UI) Panel {
}

func (m *MovePanel) initialize() {
m.Initialize()
defer m.Initialize()

m.AddButton(m.createMoveButton("X+", "move-x+.svg", octoprint.XAxis, 1))
m.AddButton(m.createMoveButton("Y+", "move-y+.svg", octoprint.YAxis, 1))
Expand Down
4 changes: 0 additions & 4 deletions ui/splash.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,3 @@ func (m *SplashPanel) initialize() {

m.grid.Attach(box, 1, 0, 1, 1)
}

func (m *SplashPanel) Connect() {

}
10 changes: 8 additions & 2 deletions ui/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ func NewStatusPanel(ui *UI) *StatusPanel {
}

func (m *StatusPanel) initialize() {
defer m.Initialize()

m.grid.Attach(m.createMainBox(), 1, 0, 4, 1)
m.grid.Attach(m.createPrintButton(), 1, 1, 1, 1)
m.grid.Attach(m.createPauseButton(), 2, 1, 1, 1)
m.grid.Attach(m.createStopButton(), 3, 1, 1, 1)
m.grid.Attach(MustButtonImage("Return", "back.svg", m.UI.ShowDefaultPanel), 4, 1, 1, 1)

m.grid.Connect("show", m.Show)
}
Expand Down Expand Up @@ -199,7 +200,12 @@ func (m *StatusPanel) updateJob() {
return
}

m.file.Label.SetLabel(fmt.Sprintf("File: %s", filenameEllipsis(s.Job.File.Name)))
file := "<not-set>"
if s.Job.File.Name != "" {
file = filenameEllipsis(s.Job.File.Name)
}

m.file.Label.SetLabel(fmt.Sprintf("File: %s", file))
m.pb.SetFraction(s.Progress.Completion / 100)

if m.UI.State.IsOperational() {
Expand Down
2 changes: 1 addition & 1 deletion ui/temperature.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewTemperaturePanel(ui *UI) *TemperaturePanel {
}

func (m *TemperaturePanel) initialize() {
m.Initialize()
defer m.Initialize()

m.grid.Attach(m.createChangeButton("Increase", "increase.svg", 1), 1, 0, 1, 1)
m.grid.Attach(m.createChangeButton("Decrease", "decrease.svg", -1), 4, 0, 1, 1)
Expand Down

0 comments on commit e5c245f

Please sign in to comment.