Esempio 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
}
Esempio n. 2
0
func (widget *ConfCore) fromFile(item *Item, file, defFile string, postSave func()) configWidget {
	build, ok := cfbuild.NewFromFileSafe(widget.data, widget.log, file, defFile, "")

	if ok {
		build.BuildSingle(item.Key)
		build.SetPostSave(postSave)
		widget.btn.SetSave()

	} else {
		widget.btn.SetNone()
	}
	return build
}
Esempio n. 3
0
// OnSelect reacts when a row is selected. Creates a new config for the icon.
//
func (widget *GuiIcons) OnSelect(icon datatype.Iconer, e error) {
	widget.switcher.Clear()

	if widget.config != nil {
		widget.config.Destroy()
		widget.config = nil
	}

	// Using the welcome widget as fallback for empty fields.
	if widget.log.Err(e, "OnSelect icon") || // shouldn't match.
		icon.ConfigPath() == "" { // for icon.ConfigGroup: datatype.KeyMainDock || datatype.GroupServices.

		widget.ShowWelcome(true)
		return
	}

	// Build a custom config widget from a dock config file.

	// Can be:
	//   field icon     Applet, Launcher, Subdock, Separator.
	//   field custom   TaskBar, Service (applet without icon).
	//   group          Desklets, Alt maindock.

	build, ok := cfbuild.NewFromFileSafe(
		widget.data,
		widget.log,
		icon.ConfigPath(),
		icon.OriginalConfigPath(),
		icon.GetGettextDomain())

	switch {
	case !ok: // Widget already build with an error message.
		widget.btn.SetNone()
		widget.setCurrent(build)
		return

	case icon.ConfigGroup() != "":
		build.BuildSingle(icon.ConfigGroup())

	case icon.IsLauncher():
		tweak := desktopclass.Tweak(build, widget.data, icon.GetClass())
		build.BuildAll(widget.switcher, tweak)

	default:
		build.BuildAll(widget.switcher)
	}

	widget.btn.SetSave()
	widget.setCurrent(build)
}
Esempio n. 4
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
}