コード例 #1
0
ファイル: idle.go プロジェクト: hauke96/go-gtk
func main() {
	glib.IdleAdd(func() bool {
		fmt.Println("start")
		return false
	})
	glib.TimeoutAdd(1000, func() bool {
		fmt.Println(fmt.Sprintf("%v", time.Now()))
		return true
	})

	glib.NewMainLoop(nil, false).Run()
}
コード例 #2
0
ファイル: main.go プロジェクト: krig/podcast-studio
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()
}