コード例 #1
0
ファイル: grouper.go プロジェクト: sqp/godock
// NewFromFileSafe creates a config page builder from the file.
//
// If the load file failed, an error widget is returned with false.
//
func NewFromFileSafe(source cftype.Source, log cdtype.Logger, file, originalConf, gettextDomain string) (cftype.Grouper, bool) {
	build, e := NewFromFile(source, log, file, originalConf, gettextDomain)
	if !log.Err(e, "Load config file", file) {
		return build, true // Load ok, return it.
	}

	// Load failed. Build a warning widget from virtual source.

	conf := vstorage.NewVirtual(file, originalConf)
	build = newFromStorage(source, log, conf, originalConf, gettextDomain)

	group := "problem"
	build.AddGroup(group,
		newkey.Frame(group, "fail", "Load failed", "dialog-error"),
		newkey.TextLabel(group, "text", "Can't load the configuration file to build the interface."),
		newkey.TextLabel(group, "file", file),
	)

	hack := TweakKeyMakeWidget(group, "file", func(key *cftype.Key) {
		key.Label().SetLineWrap(true)
		// key.Label().SetJustify(gtk.JUSTIFY_FILL)
		key.Label().SetSelectable(true)
	})

	return build.BuildSingle(group, hack), false
}
コード例 #2
0
ファイル: conf_test.go プロジェクト: sqp/godock
func TestValuerToBoth(t *testing.T) {
	group := "group"

	for _, conf := range []extendedStorage{
		vstorage.NewVirtual("", "").(extendedStorage),
		&cfbuild.CDConfig{
			KeyFile:     *keyfile.New(),
			BaseStorage: cftype.BaseStorage{File: ""},
		},
	} {
		testValuerToBoth(t, conf, group)
		testSetToValuer(t, conf, group)
		testGetSet(t, conf, group)
	}
}
コード例 #3
0
ファイル: grouper.go プロジェクト: sqp/godock
// NewVirtual creates a config page builder with an empty virtual storage.
//
// configFile is unused. Can be assigned to anything (and reused for the save).
//
func NewVirtual(source cftype.Source, log cdtype.Logger, configFile, originalConf, gettextDomain string) cftype.Grouper {
	conf := vstorage.NewVirtual(configFile, originalConf)
	return newFromStorage(source, log, conf, originalConf, gettextDomain)
}