本文整理匯總了Golang中github.com/sqp/godock/libs/cdtype.Events.OnDropData方法的典型用法代碼示例。如果您正苦於以下問題:Golang Events.OnDropData方法的具體用法?Golang Events.OnDropData怎麽用?Golang Events.OnDropData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/sqp/godock/libs/cdtype.Events
的用法示例。
在下文中一共展示了Events.OnDropData方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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, app.actions()...)
app.Action().SetMax(1)
// Events
events.OnClick = app.onClick
events.OnMiddleClick = app.onMiddleClick
events.OnScroll = app.onScroll
events.OnBuildMenu = app.onBuildMenu
events.OnDropData = app.GrepTarget
// Create a cairo-dock sources version checker.
app.version = versions.NewVersions(app.onGotVersions)
// The poller will check for new versions on a timer.
poller := app.Poller().Add(app.version.Check)
// Set "working" emblem during version check. It should be removed or changed by the check.
poller.SetPreCheck(func() { app.SetEmblem(app.FileLocation("img", app.conf.VersionEmblemWork), EmblemVersion) })
poller.SetPostCheck(func() {
for _, v := range app.version.Sources() {
v.Log = strhelp.EscapeGtk(v.Log) // Escape <>&
}
})
return app
}
示例2: NewApplet
// NewApplet create a new applet instance.
//
// It will be trigered remotely by the dock when the applet icon is created.
// Only called once for each running instance.
//
// The goal is to:
// -Create and fill the applet struct.
// -Set the config pointer, and maybe some actions.
// -Register (dock to) applet events (See cdtype.Events for the full list).
// -Declare and load permanent items required during all the applet lifetime.
// (those who do not require a config setting, unless it's in a callback).
//
func NewApplet(base cdtype.AppBase, events *cdtype.Events) cdtype.AppInstance {
app := &Applet{AppBase: base}
app.SetConfig(&app.conf)
// Events.
// Forward click events to the defined command launcher.
events.OnClick = app.Command().Callback(cmdClickLeft)
events.OnMiddleClick = app.Command().Callback(cmdClickMiddle)
// For simple callbacks event, use a closure.
events.OnDropData = func(data string) {
app.Log().Info("dropped", data)
}
events.OnBuildMenu = func(menu cdtype.Menuer) { // Another closure.
menu.AddEntry("disabled entry", "icon-name", nil)
menu.AddSeparator()
menu.AddEntry("my action", "system-run", func() {
app.Log().Info("clicked")
})
}
events.OnScroll = app.myonScroll // Or use another function with the same args.
//
// Create and set your other permanent items here...
return app
}
示例3: 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
}