Example #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
}
Example #2
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
}