本文整理匯總了Golang中github.com/sqp/godock/libs/cdtype.Events.End方法的典型用法代碼示例。如果您正苦於以下問題:Golang Events.End方法的具體用法?Golang Events.End怎麽用?Golang Events.End使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/sqp/godock/libs/cdtype.Events
的用法示例。
在下文中一共展示了Events.End方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewApplet
// NewApplet creates a new applet instance.
//
func NewApplet(base cdtype.AppBase, events *cdtype.Events) cdtype.AppInstance {
app := &Applet{AppBase: base}
app.SetConfig(&app.conf)
// Events.
events.OnClick = app.Command().Callback(cmdLeft)
events.OnMiddleClick = app.Command().Callback(cmdMiddle)
events.OnBuildMenu = app.buildMenu
events.End = func() { app.video.WebUnregister() }
events.OnDropData = func(data string) {
if strings.HasPrefix(data, "http://") || strings.HasPrefix(data, "https://") {
if app.conf.VideoDLEnabled {
app.DownloadVideo(data)
}
} else {
app.UpToShareUpload(data)
}
}
// Uptoshare actions
app.up = uptoshare.New()
app.up.Log = app.Log()
app.up.SetPreCheck(func() { app.SetEmblem(app.FileLocation("icon"), EmblemAction) })
app.up.SetPostCheck(func() { app.SetEmblem("none", EmblemAction) })
app.up.SetOnResult(app.onUploadDone)
// Network activity actions.
app.service = sysinfo.NewIOActivity(app)
app.service.Log = app.Log()
app.service.FormatIcon = sysinfo.FormatIcon
app.service.FormatLabel = formatLabel
app.service.GetData = sysinfo.GetNetActivity
app.Poller().Add(app.service.Check)
// Video download actions.
ActionsVideoDL := 0
hist := videodl.NewHistoryVideo(app, videodl.HistoryFile)
app.video = videodl.NewManager(app, app.Log(), hist)
app.video.SetPreCheck(func() error { return app.SetEmblem(app.FileLocation("img", "go-down.svg"), EmblemDownload) })
app.video.SetPostCheck(func() error { return app.SetEmblem("none", EmblemDownload) })
app.video.Actions(ActionsVideoDL, app.Action().Add)
app.video.WebRegister()
hist.Load()
return app
}
示例2: NewApplet
// NewApplet creates a new applet instance.
//
func NewApplet(base cdtype.AppBase, events *cdtype.Events) cdtype.AppInstance {
app := &Applet{AppBase: base}
app.SetConfig(&app.conf, app.actions()...)
// Events.
events.OnClick = func() { // Left click: open and manage the gui window.
if app.Window().IsOpened() { // Window opened.
app.Window().ToggleVisibility()
} else {
app.createGui(true, true)
}
}
events.OnMiddleClick = func() { app.Action().Launch(app.Action().ID(app.conf.ActionClickMiddle)) }
events.OnScroll = func(scrollUp bool) {
var key int
switch app.conf.ActionMouseWheel {
case "Change volume":
key = ternary.Int(scrollUp, int(upnptype.ActionVolumeUp), int(upnptype.ActionVolumeDown))
case "Seek in track":
key = ternary.Int(scrollUp, int(upnptype.ActionSeekForward), int(upnptype.ActionSeekBackward))
}
app.Action().Launch(key)
}
events.OnBuildMenu = app.Action().CallbackMenu(dockMenu)
events.End = func() {
if app.win != nil {
glib.IdleAdd(app.win.Destroy)
}
}
// Create the UPnP device manager.
var e error
app.cp, e = gupnp.New(&logger{app.Log()})
app.Log().Err(e, "temp Dir")
// Connect local tests.
hook := app.cp.SubscribeHook("applet")
hook.OnRendererFound = app.onMediaRendererFound
hook.OnServerFound = app.onMediaServerFound
hook.OnRendererLost = app.onMediaRendererLost
hook.OnServerLost = app.onMediaServerLost
// hook.OnRendererSelected = gui.SetRenderer
// hook.OnServerSelected = gui.SetServer
// hook.OnTransportState = func(r upnptype.Renderer, state upnptype.PlaybackState) { gui.SetPlaybackState(state) }
// hook.OnCurrentTrackDuration = func(r upnptype.Renderer, dur int) { gui.SetDuration(mediacp.TimeToString(dur)) }
// hook.OnCurrentTrackMetaData = func(r upnptype.Renderer, item upnptype.Item) { gui.SetTitle(item.Title) }
// hook.OnMute = func(r upnptype.Renderer, muted bool) { gui.SetMuted(muted) }
// hook.OnVolume = func(r upnptype.Renderer, vol uint) { gui.SetVolume(int(vol)) }
// hook.OnCurrentTime = func(r upnptype.Renderer, secs int, f float64) { gui.SetCurrentTime(secs, f*100) }
// hook.OnSetVolumeDelta = func(delta int) { gui.SetVolumeDelta(delta) }
// }
// Connect an UPnP backend to the manager.
// mgr := backendsonos.NewManager(&logger{app.Log()})
// mgr.SetEvents(app.cp.DefineEvents())
// go mgr.Start(true)
cp := backendgupnp.NewControlPoint()
cp.SetEvents(app.cp.DefineEvents())
return app
}