Ejemplo n.º 1
0
// New creates a DockTheme widget to load and save the main theme.
//
func New(data cftype.Source, log cdtype.Logger, switcher *pageswitch.Switcher) (cftype.Grouper, bool) {
	file := data.DirShareData(cdglobal.FileConfigThemes)
	build, ok := cfbuild.NewFromFileSafe(data, log, file, "", "")
	if !ok {
		return build, false
	}

	// Widget building.
	keyLoad := func(key *cftype.Key) {
		w := confapplets.NewLoaded(data, log, nil, confapplets.ListThemes)
		getValue := func() interface{} { return w.Selected().GetName() }
		key.PackKeyWidget(key, getValue, nil, w)
	}

	keySave := func(key *cftype.Key) {
		cfwidget.PackComboBoxWithListField(key, true, false, data.ListDockThemeSave)
	}

	build.BuildAll(switcher,
		cfbuild.TweakKeySetAlignedVertical(groupLoad, "chosen theme"),
		cfbuild.TweakKeyMakeWidget(groupLoad, "chosen theme", keyLoad),
		cfbuild.TweakKeyMakeWidget(groupSave, "theme name", keySave),
	)

	// Builder update keys.
	return &DockTheme{
		Grouper:  build,
		switcher: switcher,
		data:     data,
		log:      log,
	}, true
}
Ejemplo n.º 2
0
// New creates a welcome widget with informations about the program.
//
func New(source cftype.Source, log cdtype.Logger, switcher *pageswitch.Switcher) cftype.Grouper {
	const group = "Dev"
	title := tran.Slate("hi")

	// all packages in the application gopath.
	pathGoTest := strings.Join(append(cdglobal.AppBuildPath, "..."), "/")

	pathTestConfCmd := cdglobal.AppBuildPathFull("test", "confcmd", "confcmd.go")
	pathTestConfGUI := cdglobal.AppBuildPathFull("test", "confgui", "confgui.go")
	pathTestConfCmd, _ = filepath.EvalSymlinks(pathTestConfCmd)
	pathTestConfGUI, _ = filepath.EvalSymlinks(pathTestConfGUI)

	printConfig := func(showAll bool) {
		path := source.MainConfigFile()
		def := source.MainConfigDefault()

		otherSw := pageswitch.New()
		defer otherSw.Destroy()
		build, e := cfbuild.NewFromFile(source, log, path, def, "")
		if !log.Err(e, "load current dock config file") {
			// build.BuildSingle("TaskBar")
			build.BuildAll(otherSw)
			println("conf", path, def)
			cfprint.Default(build, showAll)
			build.Destroy()
		}
	}

	buildInfo := cfbuild.TweakAddGroup(group,
		newkey.TextLabel(group, "txt_title", common.Bold(common.Big(title))),
		newkey.Separator(group, "sep_title"),
		newkey.TextLabel(group, "txt_dev_page", "Test page, with useful tools for the developer."),
		newkey.CustomButtonLabel(group, "printConfig", "Print configuration", "show mainconf edited", func() { printConfig(false) }),
		newkey.CustomButtonLabel(group, "printConfig", "Print configuration", "show mainconf all", func() { printConfig(true) }),
		newkey.Separator(group, "sep_go_area"),
		newkey.TextLabel(group, "txt_go_area", "<b>Those commands requires the application sources in their Go environment</b>."),
		newkey.Separator(group, "sep_tests_gui"),
		newkey.LaunchCommand(group, "testConfGUI", "Launch config GUI test", "go run "+pathTestConfGUI),
		newkey.Separator(group, "sep_tests_cmd"),
		newkey.LaunchCommand(group, "testConfGUI", "Launch config console test", "go run "+pathTestConfCmd),
		newkey.LaunchCommand(group, "testConfGUI", "Launch config console mainconf diff", "go run "+pathTestConfCmd+" "+source.MainConfigFile()),
		newkey.Separator(group, "sep_tests_go"),
		newkey.LaunchCommand(group, "gotest", "Launch go tests", "go test "+pathGoTest),
		newkey.LaunchCommand(group, "golint", "Launch go lint", "golint "+pathGoTest),
		newkey.LaunchCommand(group, "govet", "Launch go vet", "go vet "+pathGoTest),
	)

	build := cfbuild.NewVirtual(source, log, "", "", "").BuildAll(switcher, buildInfo)

	build.ShowAll()
	return build
}
Ejemplo n.º 3
0
// New creates a Help widget with more informations about the program.
//
func New(data cftype.Source, log cdtype.Logger, switcher *pageswitch.Switcher) (cftype.Grouper, bool) {
	file := data.DirShareData(cdglobal.ConfigDirPlugIns, "Help", "Help.conf")
	build, ok := cfbuild.NewFromFileSafe(data, log, file, "", "")
	if !ok {
		return build, false
	}

	// Hack packs the Docks and Desklets pages into the first group to save space.

	hack := cfbuild.TweakAddKeys(groupGeneral, append(
		build.Storage().List("Docks"),
		build.Storage().List("Desklets")...,
	)...)

	// dropped: The Project, Icon, Desklet
	groups := []string{"General", "Icons", "Taskbar", "Useful Features", "Troubleshooting"}
	return build.BuildGroups(switcher, groups, hack), true
}