Example #1
0
// Handles user interaction with the board
func (self *MainWindow) interactBoard(eb *gtk.EventBox, event *gdk.Event) {
	evbutton := &gdk.EventButton{event}

	y, x, error := self.calculatePosition(evbutton.X(), evbutton.Y())

	if error == nil && !self.Board.SelectTile(x, y) {
		lastx, lasty := self.getSelectedPiece()
		if lastx != -1 && self.Board.Places[y][x] == nil {
			err := self.Board.MovePiece(lastx, lasty, x, y)

			if err != nil {
				errorMessage, _ := gtk.LabelNew(err.Error())
				alert, _ := gtk.DialogNew()
				alert.SetTitle("Error")
				alert.AddButton("Dismiss", gtk.RESPONSE_CLOSE)
				box, _ := alert.GetContentArea()
				box.Add(errorMessage)
				box.ShowAll()
				if alert.Run() == int(gtk.RESPONSE_CLOSE) {
					alert.Destroy()
				}

			} else {
				self.Board.Places[y][x].Selected = false
			}

		}
	}

	self.BoardView.QueueDraw()
}
Example #2
0
func EditDialogNew(fts *models.FilesTreeStore) (dialog *EditDialog, err error) {
	d, err := gtk.DialogNew()
	if err != nil {
		return
	}
	dialog = &EditDialog{EditMenuDialogInit(d, fts)}
	err = dialog.init()
	if err != nil {
		return
	}
	err = dialog.CreateDialog(nil)
	if err != nil {
		return
	}
	context, e := dialog.getActiveElementType()
	dialog.setCurrentValues(context)
	dialog.stack.SetVisibleChildName(string(e))
	return
}
Example #3
0
File: newgtk.go Project: sqp/godock
// Dialog creates a *gtk.Dialog.
func Dialog() *gtk.Dialog {
	w, _ := gtk.DialogNew()
	return w
}