Exemplo n.º 1
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.º 2
0
func NewGtkUserInterface(launcher launchers.Launcher) (userInterface *GtkUserInterface, err error) {
	userInterface = &GtkUserInterface{
		launcher: launcher,
	}

	gladeDescriptorPath := filepath.Join(
		filepath.Dir(launcher.GetExecutable()),
		"moondeploy.glade")

	runOnUIThreadAndWait(func() interface{} {
		builder, err := gtk.BuilderNew()
		if err != nil {
			panic(err)
		}

		err = builder.AddFromFile(gladeDescriptorPath)
		if err != nil {
			panic(err)
		}

		windowObject, err := builder.GetObject("mainWindow")
		if err != nil {
			panic(err)
		}
		window := windowObject.(*gtk.Window)
		userInterface.window = window

		launcher := userInterface.launcher

		window.SetTitle(launcher.GetTitle())
		window.SetIconFromFile(launcher.GetIconPathAsPng())

		window.Connect("destroy", func() {
			window.Destroy()
			userInterface.window = nil
			gtk.MainQuit()
			userInterface.closedByUser = true
		})

		appLabelObject, err := builder.GetObject("appLabel")
		if err != nil {
			panic(err)
		}
		userInterface.appLabel = appLabelObject.(*gtk.Label)

		headerLabelObject, err := builder.GetObject("headerLabel")
		if err != nil {
			panic(err)
		}
		userInterface.headerLabel = headerLabelObject.(*gtk.Label)

		statusLabelObject, err := builder.GetObject("statusLabel")
		if err != nil {
			panic(err)
		}
		userInterface.statusLabel = statusLabelObject.(*gtk.Label)

		progressBarObject, err := builder.GetObject("progressBar")
		if err != nil {
			panic(err)
		}
		userInterface.progressBar = progressBarObject.(*gtk.ProgressBar)

		return nil
	})

	return userInterface, nil
}