git.deanishe.net/deanishe/awgo.git@v0.15.0/icons.go (about)

     1  //
     2  // Copyright (c) 2016 Dean Jackson <deanishe@deanishe.net>
     3  //
     4  // MIT Licence. See http://opensource.org/licenses/MIT
     5  //
     6  
     7  package aw
     8  
     9  // IconType specifies the type of an aw.Icon struct. It can be an image file,
    10  // the icon of a file, e.g. an application's icon, or the icon for a UTI.
    11  type IconType string
    12  
    13  // Valid icon types.
    14  const (
    15  	// Indicates that Icon.Value is the path to an image file that should
    16  	// be used as the Item's icon.
    17  	IconTypeImage IconType = ""
    18  	// Icon.Value points to an object whose icon should be show in Alfred,
    19  	//e.g. combine with "/Applications/Safari.app" to show Safari's icon.
    20  	IconTypeFileIcon IconType = "fileicon"
    21  	// Indicates that Icon.Value is a UTI, e.g. "public.folder",
    22  	// which will give you the icon for a folder.
    23  	IconTypeFileType IconType = "filetype"
    24  )
    25  
    26  // Ready-to-use icons based on macOS system icons. These icons are all found in
    27  //
    28  //     /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources
    29  //
    30  // The icons are the same as found in the Alfred-Workflow library
    31  // for Python. Preview them here:
    32  // http://www.deanishe.net/alfred-workflow/guide/icons.html#list-of-icons
    33  var (
    34  	// Workflow's own icon
    35  	IconWorkflow = &Icon{"icon.png", IconTypeImage}
    36  
    37  	sysIcons = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/"
    38  	// System icons
    39  	IconAccount   = &Icon{Value: sysIcons + "Accounts.icns"}
    40  	IconBurn      = &Icon{Value: sysIcons + "BurningIcon.icns"}
    41  	IconClock     = &Icon{Value: sysIcons + "Clock.icns"}
    42  	IconColor     = &Icon{Value: sysIcons + "ProfileBackgroundColor.icns"}
    43  	IconColour    = &Icon{Value: sysIcons + "ProfileBackgroundColor.icns"}
    44  	IconEject     = &Icon{Value: sysIcons + "EjectMediaIcon.icns"}
    45  	IconError     = &Icon{Value: sysIcons + "AlertStopIcon.icns"}
    46  	IconFavorite  = &Icon{Value: sysIcons + "ToolbarFavoritesIcon.icns"}
    47  	IconFavourite = &Icon{Value: sysIcons + "ToolbarFavoritesIcon.icns"}
    48  	IconGroup     = &Icon{Value: sysIcons + "GroupIcon.icns"}
    49  	IconHelp      = &Icon{Value: sysIcons + "HelpIcon.icns"}
    50  	IconHome      = &Icon{Value: sysIcons + "HomeFolderIcon.icns"}
    51  	IconInfo      = &Icon{Value: sysIcons + "ToolbarInfo.icns"}
    52  	IconNetwork   = &Icon{Value: sysIcons + "GenericNetworkIcon.icns"}
    53  	IconNote      = &Icon{Value: sysIcons + "AlertNoteIcon.icns"}
    54  	IconSettings  = &Icon{Value: sysIcons + "ToolbarAdvanced.icns"}
    55  	IconSwirl     = &Icon{Value: sysIcons + "ErasingIcon.icns"}
    56  	IconSwitch    = &Icon{Value: sysIcons + "General.icns"}
    57  	IconSync      = &Icon{Value: sysIcons + "Sync.icns"}
    58  	IconTrash     = &Icon{Value: sysIcons + "TrashIcon.icns"}
    59  	IconUser      = &Icon{Value: sysIcons + "UserIcon.icns"}
    60  	IconWarning   = &Icon{Value: sysIcons + "AlertCautionIcon.icns"}
    61  	IconWeb       = &Icon{Value: sysIcons + "BookmarkIcon.icns"}
    62  )
    63  
    64  // Icon represents the icon for an Item.
    65  //
    66  // Alfred can show icons based on image files, UTIs (e.g. "public.folder") or
    67  // can use the icon of a specific file (e.g. "/Applications/Safari.app"
    68  // to use Safari's icon.
    69  //
    70  // Type = "" (the default) will treat Value as the path to an image file.
    71  // Alfred supports (at least) PNG, ICNS, JPG, GIF.
    72  //
    73  // Type = IconTypeFileIcon will treat Value as the path to a file or
    74  // directory and use that file's icon, e.g:
    75  //
    76  //    icon := &Icon{"/Applications/Mail.app", IconTypeFileIcon}
    77  //
    78  // will display Mail.app's icon.
    79  //
    80  // Type = IconTypeFileType will treat Value as a UTI, such as
    81  // "public.movie" or "com.microsoft.word.doc". UTIs are useful when
    82  // you don't have a local path to point to.
    83  //
    84  // You can find out the UTI of a filetype by dragging one of the files
    85  // to a File Filter's File Types list in Alfred, or in a shell with:
    86  //
    87  //    mdls -name kMDItemContentType -raw /path/to/the/file
    88  //
    89  // This will only work on Spotlight-indexed files.
    90  type Icon struct {
    91  	Value string   `json:"path"`           // Path or UTI
    92  	Type  IconType `json:"type,omitempty"` // "fileicon", "filetype" or ""
    93  }