本文整理匯總了Golang中github.com/giancosta86/moondeploy/v3/launchers.Launcher.GetExecutable方法的典型用法代碼示例。如果您正苦於以下問題:Golang Launcher.GetExecutable方法的具體用法?Golang Launcher.GetExecutable怎麽用?Golang Launcher.GetExecutable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/giancosta86/moondeploy/v3/launchers.Launcher
的用法示例。
在下文中一共展示了Launcher.GetExecutable方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateDesktopShortcut
func (app *App) CreateDesktopShortcut(launcher launchers.Launcher, referenceDescriptor descriptors.AppDescriptor) (err error) {
desktopDir, err := caravel.GetUserDesktop()
if err != nil {
return err
}
if !caravel.DirectoryExists(desktopDir) {
return fmt.Errorf("Expected desktop dir '%v' not found", desktopDir)
}
shortcutFileName := caravel.FormatFileName(referenceDescriptor.GetName()) + ".desktop"
log.Debug("Shortcut file name: '%v'", shortcutFileName)
shortcutFilePath := filepath.Join(desktopDir, shortcutFileName)
log.Info("Creating desktop shortcut: '%v'...", shortcutFilePath)
shortcutFile, err := os.OpenFile(shortcutFilePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0700)
if err != nil {
return err
}
defer func() {
shortcutFile.Close()
if err != nil {
os.Remove(shortcutFilePath)
}
}()
actualIconPath := app.GetActualIconPath(launcher)
shortcutContent := fmt.Sprintf(linuxShortcutContent,
referenceDescriptor.GetName(),
referenceDescriptor.GetDescription(),
launcher.GetExecutable(),
app.GetLocalDescriptorPath(),
actualIconPath)
_, err = shortcutFile.Write([]byte(shortcutContent))
if err != nil {
return err
}
log.Notice("Desktop shortcut created")
return nil
}
示例2: CreateDesktopShortcut
func (app *App) CreateDesktopShortcut(launcher launchers.Launcher, referenceDescriptor descriptors.AppDescriptor) (err error) {
desktopDir, err := caravel.GetUserDesktop()
if err != nil {
return err
}
if !caravel.DirectoryExists(desktopDir) {
return fmt.Errorf("Expected desktop dir '%v' not found", desktopDir)
}
scriptFileName := caravel.FormatFileName(referenceDescriptor.GetName())
log.Debug("Bash shortcut name: '%v'", scriptFileName)
scriptFilePath := filepath.Join(desktopDir, scriptFileName)
log.Info("Creating Bash shortcut: '%v'...", scriptFilePath)
scriptFile, err := os.OpenFile(scriptFilePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0700)
if err != nil {
return err
}
defer func() {
scriptFile.Close()
if err != nil {
os.Remove(scriptFilePath)
}
}()
scriptContent := fmt.Sprintf(macScriptContentFormat,
launcher.GetExecutable(),
app.localDescriptorPath)
_, err = scriptFile.Write([]byte(scriptContent))
if err != nil {
return err
}
log.Notice("Bash shortcut script created")
return nil
}
示例3: NewGtkUserInterface
func NewGtkUserInterface(launcher launchers.Launcher) (userInterface *GtkUserInterface, err error) {
userInterface = &GtkUserInterface{
launcher: launcher,
}
gladeDescriptorPath := filepath.Join(
filepath.Dir(launcher.GetExecutable()),
"moondeploy.glade")
runOnUIThreadAndWait(func() interface{} {
builder, err := gtk.BuilderNew()
if err != nil {
panic(err)
}
err = builder.AddFromFile(gladeDescriptorPath)
if err != nil {
panic(err)
}
windowObject, err := builder.GetObject("mainWindow")
if err != nil {
panic(err)
}
window := windowObject.(*gtk.Window)
userInterface.window = window
launcher := userInterface.launcher
window.SetTitle(launcher.GetTitle())
window.SetIconFromFile(launcher.GetIconPathAsPng())
window.Connect("destroy", func() {
window.Destroy()
userInterface.window = nil
gtk.MainQuit()
userInterface.closedByUser = true
})
appLabelObject, err := builder.GetObject("appLabel")
if err != nil {
panic(err)
}
userInterface.appLabel = appLabelObject.(*gtk.Label)
headerLabelObject, err := builder.GetObject("headerLabel")
if err != nil {
panic(err)
}
userInterface.headerLabel = headerLabelObject.(*gtk.Label)
statusLabelObject, err := builder.GetObject("statusLabel")
if err != nil {
panic(err)
}
userInterface.statusLabel = statusLabelObject.(*gtk.Label)
progressBarObject, err := builder.GetObject("progressBar")
if err != nil {
panic(err)
}
userInterface.progressBar = progressBarObject.(*gtk.ProgressBar)
return nil
})
return userInterface, nil
}