Debian Codegraph @

desktop/type.go

raw
1 package desktop
2
3 // Type is the type of desktop entry.
4 type Type uint8
5
6 // These are the possible desktop entry types.
7 const (
8 None Type = iota // No type. This is bad.
9 Application
10 Link
11 Directory
12 Unknown // Any unknown type.
13 )
14
15 // ParseType converts the given string s into a Type.
16 func ParseType(s string) Type {
17 switch s {
18 case None.String():
19 return None
20 case Application.String():
21 return Application
22 case Link.String():
23 return Link
24 case Directory.String():
25 return Directory
26 default:
27 return Unknown
28 }
29 }
30
31 // String returns the Type as a string.
32 func (t Type) String() string {
33 switch t {
34 case None:
35 return ""
36 case Application:
37 return "Application"
38 case Link:
39 return "Link"
40 case Directory:
41 return "Directory"
42 default:
43 return "Unknown"
44 }
45 }