func CreateActivatableDemo(vbox *gtk.VBox) { action_entry := gtk.NewAction("ActionEntry", "Button attached to Action", "", gtk.STOCK_INFO) action_entry.Connect("activate", func() { fmt.Println("Action clicked") }) frame1 := gtk.NewFrame("GtkActivatable interface demonstration") frame1.SetBorderWidth(5) hbox2 := gtk.NewHBox(false, 5) hbox2.SetSizeRequest(400, 50) hbox2.SetBorderWidth(5) button1 := gtk.NewButton() button1.SetSizeRequest(250, 0) button1.SetRelatedAction(action_entry) hbox2.PackStart(button1, false, false, 0) hbox2.PackStart(gtk.NewVSeparator(), false, false, 0) button2 := gtk.NewButtonWithLabel("Hide Action") button2.SetSizeRequest(150, 0) button2.Connect("clicked", func() { action_entry.SetVisible(false) fmt.Println("Hide Action") }) hbox2.PackStart(button2, false, false, 0) button3 := gtk.NewButtonWithLabel("Unhide Action") button3.SetSizeRequest(150, 0) button3.Connect("clicked", func() { action_entry.SetVisible(true) fmt.Println("Show Action") }) hbox2.PackStart(button3, false, false, 0) frame1.Add(hbox2) vbox.PackStart(frame1, false, true, 0) }
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) }
func CreateMenuAndToolbar(w *gtk.Window, vbox *gtk.VBox) { action_group := gtk.NewActionGroup("my_group") ui_manager := CreateUIManager() accel_group := ui_manager.GetAccelGroup() w.AddAccelGroup(accel_group) AddFileMenuActions(action_group) AddEditMenuActions(action_group) AddChoicesMenuActions(action_group) ui_manager.InsertActionGroup(action_group, 0) menubar := ui_manager.GetWidget("/MenuBar") vbox.PackStart(menubar, false, false, 0) toolbar := ui_manager.GetWidget("/ToolBar") vbox.PackStart(toolbar, false, false, 0) eventbox := gtk.NewEventBox() vbox.PackStart(eventbox, false, false, 0) // label := gtk.NewLabel("Right-click to see the popup menu.") // vbox.PackStart(label, false, false, 0) }
func menu_bar(vbox *gtk.VBox) { menubar := gtk.NewMenuBar() vbox.PackStart(menubar, false, false, 0) buttons := gtk.NewAlignment(0, 0, 0, 0) checkbox := gtk.NewAlignment(1, 0, 0, 0) newPlayerGameButton := gtk.NewButtonWithLabel("Player vs Player") newIaGameButton := gtk.NewButtonWithLabel("Player vs AI") info = gtk.NewLabel("Hint: Not yet") threeCheckBox := gtk.NewCheckButtonWithLabel("Three and three") endCheckBox := gtk.NewCheckButtonWithLabel("Unbreakable end") hintCheckBox := gtk.NewCheckButtonWithLabel("Hint") hbox := gtk.NewHBox(false, 1) hbox0 := gtk.NewHBox(false, 1) hbox1 := gtk.NewHBox(false, 1) hbox0.Add(newPlayerGameButton) hbox0.Add(newIaGameButton) hbox1.Add(hintCheckBox) hbox1.Add(threeCheckBox) hbox1.Add(endCheckBox) buttons.Add(hbox0) checkbox.Add(hbox1) hbox.Add(buttons) hbox.Add(info) hbox.Add(checkbox) vbox.PackStart(hbox, false, true, 0) cascademenu := gtk.NewMenuItemWithMnemonic("_Game") menubar.Append(cascademenu) submenu := gtk.NewMenu() cascademenu.SetSubmenu(submenu) playermenuitem := gtk.NewMenuItemWithMnemonic("_Player Vs Player") playermenuitem.Connect("activate", func() { gc.SetRgbFgColor(gdk.NewColor("grey")) pixmap.GetDrawable().DrawRectangle(gc, true, 0, 0, -1, -1) game = Gomoku{make([]int, 361), true, game.endgameTake, game.doubleThree, 1, [2]int{10, 10}, 0} player = 1 countTake = 0 iamode = false display_init_grid(gc, pixmap) drawingarea.Hide() drawingarea.Show() stopGame = false stopClick = false context_id := statusbar.GetContextId("go-gtk") statusbar.Push(context_id, "(not so) Proudly propulsed by the inglorious Gomoku Project, with love, and Golang!") }) submenu.Append(playermenuitem) newPlayerGameButton.Clicked(func() { playermenuitem.Activate() }) iamenuitem := gtk.NewMenuItemWithMnemonic("_Player Vs AI") iamenuitem.Connect("activate", func() { gc.SetRgbFgColor(gdk.NewColor("grey")) pixmap.GetDrawable().DrawRectangle(gc, true, 0, 0, -1, -1) game = Gomoku{make([]int, 361), true, game.endgameTake, game.doubleThree, 1, [2]int{10, 10}, 0} player = 1 countTake = 0 iamode = true display_init_grid(gc, pixmap) drawingarea.Hide() drawingarea.Show() stopGame = false stopClick = false context_id := statusbar.GetContextId("go-gtk") statusbar.Push(context_id, "(not so) Proudly propulsed by the inglorious Gomoku Project, with love, and Golang!") }) submenu.Append(iamenuitem) newIaGameButton.Clicked(func() { iamenuitem.Activate() }) menuitem = gtk.NewMenuItemWithMnemonic("E_xit") menuitem.Connect("activate", func() { gtk.MainQuit() }) submenu.Append(menuitem) threeCheckBox.Connect("toggled", func() { if game.doubleThree == false { game.doubleThree = true } else { game.doubleThree = false } }) endCheckBox.Connect("toggled", func() { if game.endgameTake == false { game.endgameTake = true } else { game.endgameTake = false } }) hintCheckBox.Connect("toggled", func() { if hint == false { hint = true calcHint <- true } else { hint = false } }) }
func status_bar(vbox *gtk.VBox) { statusbar = gtk.NewStatusbar() context_id := statusbar.GetContextId("go-gtk") statusbar.Push(context_id, "(not so) Proudly propulsed by the inglorious Gomoku Project, with love, and Golang!") vbox.PackStart(statusbar, false, false, 0) }