Пример #1
0
// Tweak prepares a build tweak to add desktop class informations for a launcher.
//
func Tweak(build cftype.Grouper, source datatype.Source, selected datatype.DesktopClasser) func(cftype.Builder) {
	return func(build cftype.Builder) {
		// Create a key for the hidden existing Origin entry.
		keyOrigin := newkey.EmptyFull(cftype.DesktopEntry, "Origin")

		// Check if a launcher origin has been set (as a desktop class file location).
		keyOrigin.SetBuilder(build)
		origins := keyOrigin.Value().String()
		if origins == "" {
			return
		}

		// Prepare the desktop class widget.
		keyOrigin.SetMakeWidget(func(key *cftype.Key) {
			w := Widget(source, selected, origins)
			key.PackWidget(w, false, false, 0)
		})

		// Add the key to the builder.
		build.AddKeys(cftype.DesktopEntry,
			newkey.Frame(cftype.DesktopEntry, "FrameOrigin", "", ""), // A frame to close the expander.
			keyOrigin)
	}
}