func NewPlayer() *Player { p := new(Player) p.window = gtk.NewWindow(gtk.WINDOW_TOPLEVEL) p.window.SetTitle("Player") p.window.ConnectNoi("destroy", gtk.MainQuit, nil) vbox := gtk.NewVBox(false, 0) p.window.Add(vbox.AsWidget()) hbox := gtk.NewHBox(false, 0) vbox.PackStart(hbox.AsWidget(), false, false, 0) fcb := gtk.NewFileChooserButton( "Choose media file", gtk.FILE_CHOOSER_ACTION_OPEN, ) fcb.Connect("selection-changed", (*Player).onFileSelected, p) hbox.Add(fcb.AsWidget()) button := gtk.NewButtonFromStock("gtk-media-play") button.Connect("clicked", (*Player).onPlayClicked, p) hbox.PackStart(button.AsWidget(), false, false, 0) button = gtk.NewButtonFromStock("gtk-media-pause") button.Connect("clicked", (*Player).onPauseClicked, p) hbox.PackStart(button.AsWidget(), false, false, 0) button = gtk.NewButtonFromStock("gtk-media-stop") button.Connect("clicked", (*Player).onStopClicked, p) hbox.PackStart(button.AsWidget(), false, false, 0) p.movie_area = gtk.NewDrawingArea() p.movie_area.Connect("realize", (*Player).onVideoWidgetRealize, p) p.movie_area.SetDoubleBuffered(false) p.movie_area.SetSizeRequest(640, 360) vbox.Add(p.movie_area.AsWidget()) p.window.ShowAll() p.window.Realize() p.pipe = gst.ElementFactoryMake("playbin2", "autoplay") p.bus = p.pipe.GetBus() p.bus.AddSignalWatch() p.bus.Connect("message", (*Player).onMessage, p) p.bus.EnableSyncMessageEmission() p.bus.Connect("sync-message::element", (*Player).onSyncMessage, p) return p }
func main() { w := gtk.NewWindow(gtk.WINDOW_TOPLEVEL) w.Connect("delete-event", cbDelete, nil) w.Connect("destroy", cbDestroy, nil) w.SetBorderWidth(10) w.Show() a := A{"Hello World!\n"} b := gtk.NewButtonWithLabel("Hello World") b.Connect("clicked", (*A).Hello, &a) b.ConnectNoi("clicked", (*gtk.Widget).Destroy, w.AsWidget()) w.Add(b.AsWidget()) b.Show() gtk.Main() }