From a12232f527666695c57a6014401c1a34c2fb6611 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sat, 17 Aug 2013 14:57:40 +0200 Subject: GUI is now locked on slow operations (e.g. Filling). --- main.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 2e81dd6..3520de5 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ type GUI struct { showbiomes *gtk.CheckButton statusContext uint + lastStatus string mapw *MapWidget } @@ -201,7 +202,7 @@ func (g *GUI) Init() { hbox := gtk.NewHBox(false, 0) - g.mapw = NewMapWidget(g.reportError, g.updateInfo) + g.mapw = NewMapWidget(g.reportError, g.updateInfo, g.setBusy) hbox.PackStart(g.mapw.DArea(), true, true, 3) sidebar := g.mkSidebar() @@ -221,6 +222,17 @@ func (g *GUI) Init() { g.setTool(NewFillTool()) } +func (g *GUI) setBusy(b bool) { + g.window.SetSensitive(!b) + g.statusbar.Pop(g.statusContext) + if b { + g.statusbar.Push(g.statusContext, "!!! PLEASE WAIT !!!") + + } else { + g.statusbar.Push(g.statusContext, g.lastStatus) + } +} + func (g *GUI) reportError(msg string) { dlg := gtk.NewMessageDialog(g.window, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg) dlg.Run() @@ -229,8 +241,9 @@ func (g *GUI) reportError(msg string) { } func (g *GUI) updateInfo(x, z int, bio mcmap.Biome) { + g.lastStatus = fmt.Sprintf("X:%d, Z:%d, Biome:%s", x, z, bio) g.statusbar.Pop(g.statusContext) - g.statusbar.Push(g.statusContext, fmt.Sprintf("X:%d, Z:%d, Biome:%s", x, z, bio)) + g.statusbar.Push(g.statusContext, g.lastStatus) } func (g *GUI) mkUpdateToolFx(rb *gtk.RadioButton, t Tool) func() { -- cgit v1.2.3-54-g00ecf