// InfoApplet asks the dock all informations about an applet. // func InfoApplet(log cdtype.Logger, name string) *packages.AppletPackage { vars, _ := DockProperties("type=Module & name=" + name) if len(vars) == 0 { log.NewErr("unknown applet", "InfoApplet", name) return nil } pack, _ := parseApplet(log, vars[0]) return pack }
// ListFieldsIDByName searches the list of fields for the matching key. // Returns the position of the field in the list. // Returns 0 if not found, to have a valid entry to select. // func ListFieldsIDByName(fields []Field, key string, log cdtype.Logger) int { for i, field := range fields { if key == field.Key { return i } } if log != nil { log.NewErr("not found", "ListFieldsIDByName", key, fields) } return 0 }
// NewBuilder creates the target renderer/builder. // The name is mandatory for a single applet (internal or not). // func NewBuilder(target SourceType, name string, log cdtype.Logger) Builder { switch target { case TypeGodock: build := &BuilderGodock{} build.SetLogger(log) return build case TypeCore: build := &BuilderCore{} build.SetLogger(log) return build case TypeApplets: build := &BuilderApplets{} build.SetLogger(log) return build case TypeAppletCompiled: dir, icon := AppletInfo(log, name) if dir == "" { log.NewErr("applet not found: "+name, "new builder") return &BuilderNull{} } build := &BuilderCompiled{Module: name} build.SetLogger(log) build.SetIcon(icon) build.SetDir(dir) return build case TypeAppletInternal: // Ask icon of module to the Dock as we can't guess its dir and icon name. _, icon := AppletInfo(log, strings.Replace(name, "-", " ", -1)) if icon == "" { icon = IconMissing } build := &BuilderInternal{Module: name} build.SetLogger(log) build.SetIcon(icon) return build } // ensure we have a valid target. return &BuilderNull{} }