func configure_board(vbox *gtk.VBox) { drawingarea = gtk.NewDrawingArea() drawingarea.Connect("configure-event", func() { if pixmap != nil { pixmap.Unref() } var allocation gtk.Allocation drawingarea.GetAllocation(&allocation) pixmap = gdk.NewPixmap(drawingarea.GetWindow().GetDrawable(), allocation.Width, allocation.Height, 24) gc = gdk.NewGC(pixmap.GetDrawable()) display_init_grid(gc, pixmap) }) drawingarea.Connect("button-press-event", func(ctx *glib.CallbackContext) { // Check if the game is running and if player click in the goban if stopGame == true || stopClick == true { return } if gdkwin == nil { gdkwin = drawingarea.GetWindow() } arg := ctx.Args(0) mev := *(**gdk.EventMotion)(unsafe.Pointer(&arg)) var mt gdk.ModifierType var x, y int if mev.IsHint != 0 { gdkwin.GetPointer(&x, &y, &mt) } else { x, y = int(mev.X), int(mev.Y) } x = ((x - INTER/2) / INTER) y = ((y - INTER/2) / INTER) if x < 0 || x >= 19 || y < 0 || y >= 19 { return } // end check good, vic := event_play(x, y) if good && iamode && stopGame == false && stopClick == false && vic == 0 { calc_ai() } if good && !iamode && stopGame == false && stopClick == false && hint { calcHint <- true } }) drawingarea.Connect("expose-event", func() { if pixmap != nil { drawingarea.GetWindow().GetDrawable().DrawDrawable(gc, pixmap.GetDrawable(), 0, 0, 0, 0, -1, -1) } }) drawingarea.SetEvents(int(gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK | gdk.BUTTON_PRESS_MASK)) vbox.Add(drawingarea) }
func (g *Gui) buildList(vbox *gtk.VBox) { frame := gtk.NewFrame("Device List") framebox := gtk.NewVBox(false, 1) frame.Add(framebox) vbox.Add(frame) g.Status = gtk.NewStatusbar() vbox.PackStart(g.Status, false, false, 0) g.Store = gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING) treeview := gtk.NewTreeView() framebox.Add(treeview) treeview.SetModel(g.Store) treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Device", gtk.NewCellRendererText(), "text", 0)) treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Name", gtk.NewCellRendererText(), "text", 1)) treeview.GetSelection().SetMode(gtk.SELECTION_SINGLE) controls := gtk.NewHBox(true, 0) g.Start = gtk.NewButtonWithLabel("Start Sync") g.Start.Clicked(func() { var iter gtk.TreeIter var device glib.GValue selection := treeview.GetSelection() if selection.CountSelectedRows() > 0 { selection.GetSelected(&iter) g.Store.GetValue(&iter, 0, &device) MainGui.notify("Start Writing On: " + device.GetString()) doWrite(device.GetString()) } else { MainGui.notify("No Active Selection") } }) controls.Add(g.Start) g.Recheck = gtk.NewButtonWithLabel("Rescan") g.Recheck.Clicked(func() { devices := SearchValid() MainGui.Store.Clear() for _, x := range devices { MainGui.appendItem("/dev/hidraw"+strconv.FormatUint(x.SeqNum(), 10), x.SysAttrValue("product")) } MainGui.notify("Scanning Done") }) controls.Add(g.Recheck) framebox.PackStart(controls, false, false, 0) }