// 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) }