Exemplo n.º 1
0
func backgroundOrchestrator(launcher launchers.Launcher, bootDescriptorPath string, guiOutcomeChannel chan guiOutcomeStruct) {
	outcome := runEngineWithGtk(launcher, bootDescriptorPath)
	userInterface := outcome.userInterface
	err := outcome.err

	log.SetCallback(func(level logging.Level, message string) {})
	log.Debug("Result returned by the background routine. Is UI available? %v", userInterface != nil)

	if err != nil {
		log.Warning("Err is: %v", err)

		if userInterface != nil {
			switch err.(type) {

			case *engine.ExecutionCanceled:
				break

			default:
				userInterface.ShowError(err.Error())
			}
		}
	}

	log.Debug("Now programmatically quitting GTK")
	gtk.MainQuit()

	guiOutcomeChannel <- outcome
}
Exemplo n.º 2
0
func setupUserInterface(launcher launchers.Launcher, userInterface ui.UserInterface) {
	userInterface.SetApp(launcher.GetTitle())

	log.SetCallback(func(level logging.Level, message string) {
		if level <= logging.INFO {
			userInterface.SetStatus(message)
		}
	})

	userInterface.Show()
}
Exemplo n.º 3
0
func StartGUI(launcher launchers.Launcher, bootDescriptorPath string) (err error) {
	log.Debug("Initializing GTK...")
	gtkui.InitGTK()
	log.Debug("GTK initialized")

	guiOutcomeChannel := make(chan guiOutcomeStruct)
	defer close(guiOutcomeChannel)

	go backgroundOrchestrator(launcher, bootDescriptorPath, guiOutcomeChannel)

	log.Debug("Starting GTK main loop...")
	gtk.Main()

	log.SetCallback(func(level logging.Level, message string) {})
	log.Debug("GTK main loop terminated")

	select {
	case guiOutcome := <-guiOutcomeChannel:
		log.Debug("Outcome retrieved from the GUI channel")

		if guiOutcome.userInterface != nil && guiOutcome.userInterface.IsClosedByUser() {
			return &engine.ExecutionCanceled{}
		}

		err = guiOutcome.err
		if err != nil {
			log.Warning("Err is: %v", err)
			return err
		}

		log.Notice("OK")
		return nil
	default:
		log.Debug("The user has manually closed the program")
		return &engine.ExecutionCanceled{}
	}
}
Exemplo n.º 4
0
func dismissUserInterface(userInterface ui.UserInterface) {
	log.SetCallback(func(level logging.Level, message string) {})

	userInterface.Hide()
}