func main() { glib.IdleAdd(func() bool { println("start") return false }) glib.TimeoutAdd(1000, func() bool { println(fmt.Sprintf("%v", time.Now())) return true }) glib.MainLoopNew(nil, false).Run() }
func (self *FileChooserWindow) setupDefult(msgId, url, ext string) { self.Connect(self.save, "clicked", func() { dirname := self.fileChooser.GetFilename() if dirname != "" { go func() { glib.IdleAdd(self.window.Destroy) downloadingWindow := NewDownloadingWindow(msgId) glib.IdleAdd(downloadingWindow.window.ShowAll) defer glib.IdleAdd(downloadingWindow.window.Destroy) content, err := downloadContentToTemp(msgId, url, ext) if err != nil { goline.LoggerPrintln(err) glib.IdleAdd(func() { RunAlertMessage(self.parent.window, "Failed to download file: %s", err) }) return } err = os.Rename(content, path.Join(dirname, path.Base(content))) if err != nil { goline.LoggerPrintln(err) glib.IdleAdd(func() { RunAlertMessage(self.parent.window, "Failed to move file: %s", err) }) return } }() } }) self.Connect(self.cancel, "clicked", func() { glib.IdleAdd(self.window.Destroy) }) }
func main() { runtime.LockOSThread() // Parse command line flag.Parse() tracks := []string{} if flag.NArg() > 0 { tracks = flag.Args()[0:] } log.Println("Tracks: ", tracks) // Init libSoX and SDL if !sox.Init() { log.Fatal("Failed to init sox") } defer sox.Quit() einfo := sox.GetEncodingsInfo() log.Println("Supported encodings:") for _, e := range einfo { log.Printf("%s: %s (%x)\n", e.Name, e.Desc, e.Flags) } effects := sox.GetEffectHandlers() log.Println("Supported effects:") for _, e := range effects { log.Printf("%s: %s (%x)\n", e.Name(), e.Usage(), e.Flags()) } if sdl.Init(sdl.INIT_NOPARACHUTE|sdl.INIT_VIDEO|sdl.INIT_EVENTS) != 0 { log.Fatal(sdl.GetError()) } defer sdl.Quit() gtk.Init(nil) //sdl.GL_SetAttribute(sdl.GL_CONTEXT_MAJOR_VERSION, 2) //sdl.GL_SetAttribute(sdl.GL_CONTEXT_MINOR_VERSION, 1) //sdl.GL_SetAttribute(sdl.GL_DOUBLEBUFFER, 1) //sdl.GL_SetAttribute(sdl.GL_DEPTH_SIZE, 24) window, renderer := sdl.CreateWindowAndRenderer(640, 480, sdl.WINDOW_SHOWN|sdl.WINDOW_OPENGL|sdl.RENDERER_ACCELERATED|sdl.RENDERER_PRESENTVSYNC) if (window == nil) || (renderer == nil) { log.Fatal(sdl.GetError()) } //window.GL_CreateContext() if ttf.Init() != 0 { log.Fatal(sdl.GetError()) } defer window.Destroy() defer renderer.Destroy() defer ttf.Quit() window.SetTitle("Podcast Studio") log.Println("Video Driver:", sdl.GetCurrentVideoDriver()) // Jump to studio.go //run_studio(window, renderer, tracks) screen := studioSetup(window, renderer, tracks) defer screen.rsc.Free() defer screen.Destroy() loop := glib.NewMainLoop(nil, false) glib.IdleAdd(func() bool { ret := studioUpdate(window, renderer, screen) if !ret { loop.Quit() return false } return true }) loop.Run() }