示例#1
0
// This must be called from the UI thread - otherwise bad things will happen sooner or later
func builderForDefinition(uiName string) *gtk.Builder {
	// assertInUIThread()

	template := getDefinitionWithFileFallback(uiName)

	builder, err := gtk.BuilderNew()
	if err != nil {
		//We cant recover from this
		panic(err)
	}

	err = builder.AddFromString(template)
	if err != nil {
		//This is a programming error
		panic(fmt.Sprintf("gui: failed load %s: %s\n", uiName, err.Error()))
	}

	return builder
}
示例#2
0
文件: buildhelp.go 项目: sqp/godock
// NewFromBytes creates a *BuildHelp to load gtk.Builder interfaces easily from a slice of bytes.
//
func NewFromBytes(bytes []byte) *BuildHelp {
	builder, _ := gtk.BuilderNew()
	builder.AddFromString(string(bytes))
	return &BuildHelp{Builder: *builder}
}
示例#3
0
文件: buildhelp.go 项目: sqp/godock
// New creates a *BuildHelp to load gtk.Builder interfaces easily.
//
func New() *BuildHelp {
	builder, _ := gtk.BuilderNew()
	return &BuildHelp{Builder: *builder}
}
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
}
示例#5
0
func (*RealGtk) BuilderNew() (gtki.Builder, error) {
	return wrapBuilder(gtk.BuilderNew())
}