當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Events.OnScroll方法代碼示例

本文整理匯總了Golang中github.com/sqp/godock/libs/cdtype.Events.OnScroll方法的典型用法代碼示例。如果您正苦於以下問題:Golang Events.OnScroll方法的具體用法?Golang Events.OnScroll怎麽用?Golang Events.OnScroll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/sqp/godock/libs/cdtype.Events的用法示例。


在下文中一共展示了Events.OnScroll方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
}
開發者ID:sqp,項目名稱:godock,代碼行數:30,代碼來源:update.go

示例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
}
開發者ID:sqp,項目名稱:godock,代碼行數:42,代碼來源:example_cdtype_test.go

示例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.onClick
	events.OnMiddleClick = app.onMiddleClick
	events.OnScroll = app.onScroll
	events.OnBuildMenu = app.onBuildMenu
	events.OnSubMiddleClick = app.onSubMiddleClick
	events.OnSubScroll = app.onSubScroll
	events.OnSubBuildMenu = app.onSubBuildMenu

	// Pulseaudio service.
	log = app.Log()
	var e error
	app.pulse, e = NewAppPulse(app)
	if log.Err(e, "pulseaudio dbus") {
		return nil
	}
	return app
}
開發者ID:sqp,項目名稱:godock,代碼行數:24,代碼來源:audio.go

示例4: 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
}
開發者ID:sqp,項目名稱:godock,代碼行數:72,代碼來源:TVPlay.go


注:本文中的github.com/sqp/godock/libs/cdtype.Events.OnScroll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。