当前位置: 首页>>代码示例>>Golang>>正文


Golang cdtype.Menuer类代码示例

本文整理汇总了Golang中github.com/sqp/godock/libs/cdtype.Menuer的典型用法代码示例。如果您正苦于以下问题:Golang Menuer类的具体用法?Golang Menuer怎么用?Golang Menuer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Menuer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: buildMenu

// buildMenu fills the menu with left and middle click actions if they're set.
//
func (app *Applet) buildMenu(menu cdtype.Menuer) {
	needSep := false
	if app.conf.LeftAction > 0 && app.conf.LeftCommand != "" {
		menu.AddEntry("Action left click", "system-run", app.Command().Callback(cmdLeft))
		needSep = true
	}
	if app.conf.MiddleAction > 0 && app.conf.MiddleCommand != "" {
		menu.AddEntry("Action middle click", "system-run", app.Command().Callback(cmdMiddle))
		needSep = true
	}
	if needSep {
		menu.AddSeparator()
	}
	subup := menu.AddSubMenu("Upload", "")
	for _, hist := range app.up.ListHistory() {
		hist := hist
		subup.AddEntry(hist["file"], "", func() {
			app.Log().Info(hist["link"])
			clipboard.Write(hist["link"])
			// app.ShowDialog(link, 5)
		})
	}

	menu.AddSeparator()
	app.video.Menu(menu)
}
开发者ID:sqp,项目名称:godock,代码行数:28,代码来源:NetActivity.go

示例2: onSubBuildMenu

// onSubBuildMenu fills the menu with stream actions: select device.
//
func (app *Applet) onSubBuildMenu(icon string, menu cdtype.Menuer) { // stream actions menu: select device.
	dev := app.pulse.Stream(dbus.ObjectPath(icon))

	mute, _ := dev.Bool("Mute")
	menu.AddCheckEntry("Mute volume", mute, func() {
		toggleMute(dev)
	})

	sel, es := dev.ObjectPath("Device")
	if log.Err(es) {
		return
	}
	app.menuAddDevices(menu, sel, "Output", func(sink dbus.ObjectPath) error {
		return dev.Call("Move", 0, sink).Err
	})

	// Kill works but seem to leave the client app into a bugged state (same for stream or client kill).
	// app.menu.Append("Kill", func() {
	// 	// log.Err(dev.Call("Kill", 0).Err, "Kill") // kill stream.
	// client, ec := dev.ObjectPath("Client")
	// if ec != nil {
	// 	return
	// }
	// app.pulse.Client.Client(client).Call("Kill", 0) // kill client.
	// })
}
开发者ID:sqp,项目名称:godock,代码行数:28,代码来源:audio.go

示例3: onBuildMenu

// onBuildMenu fills the menu with device actions: mute, mixer, select device.
//
func (app *Applet) onBuildMenu(menu cdtype.Menuer) { // device actions menu: mute, mixer, select device.
	mute, _ := app.pulse.Device(app.pulse.sink).Bool("Mute")
	menu.AddCheckEntry("Mute volume", mute, app.pulse.ToggleMute)
	if app.conf.MixerCommand != "" {
		menu.AddEntry("Open mixer", "multimedia-volume-control", app.Command().Callback(cmdMixer))
	}
	app.menuAddDevices(menu, app.pulse.sink, "Managed device", app.pulse.SetSink)
}
开发者ID:sqp,项目名称:godock,代码行数:10,代码来源:audio.go

示例4: MenuTypeDL

// MenuTypeDL fills the menu with a submenu to select TypeDL (audio, video or both).
//
func (m *Manager) MenuTypeDL(menu cdtype.Menuer, typ *TypeDL) {
	sub := menu.AddSubMenu("File Type: "+typ.String(), iconMenuTypeDL)

	for _, t := range []TypeDL{TypeDLAll, TypeDLAudio, TypeDLVideo, TypeDLVideoWithAudio} {
		stt := t // force static for the callback.
		sub.AddRadioEntry(
			t.String(),
			*typ == t,
			groupTypeDL,
			func() { *typ = stt },
		).SetTooltipText(t.Tooltip())
	}
}
开发者ID:sqp,项目名称:godock,代码行数:15,代码来源:manager.go

示例5: BuildMenu

// BuildMenu fills the menu with the given actions list.
//
func (o *Actions) BuildMenu(menu cdtype.Menuer, actionIds []int) {
	for _, ID := range actionIds {
		act := o.list[ID]
		var entry cdtype.MenuWidgeter
		switch act.Menu {
		case cdtype.MenuEntry:
			entry = menu.AddEntry(act.Name, act.Icon, o.Callback(act.ID))

		case cdtype.MenuSeparator:
			menu.AddSeparator()

		case cdtype.MenuCheckBox:
			entry = menu.AddCheckEntry(act.Name, *act.Bool, o.Callback(act.ID))
			if act.Call == nil {
				act.Call = func() {
					*act.Bool = !*act.Bool
				}
			}

		case cdtype.MenuRadioButton:
			entry = menu.AddRadioEntry(act.Name, *act.Bool, act.Group, o.Callback(act.ID))

			// case cdtype.MenuSubMenu:
		}

		if entry != nil && act.Tooltip != "" {
			entry.SetTooltipText(act.Tooltip)
		}
	}
}
开发者ID:sqp,项目名称:godock,代码行数:32,代码来源:action.go

示例6: MenuQuality

// MenuQuality returns the list of available streams and formats for the video.
//
func (m *Manager) MenuQuality(menu cdtype.Menuer, qual *Quality, list []Quality) {
	if len(list) == 0 {
		return
	}

	sub := menu.AddSubMenu("Quality: "+qual.String(), iconMenuQuality)

	for _, q := range list {
		stq := q // force static for the callback.
		sub.AddRadioEntry(
			q.String(),
			*qual == q,
			groupQuality,
			func() { *qual = stq },
		).SetTooltipText(q.Tooltip())
	}
}
开发者ID:sqp,项目名称:godock,代码行数:19,代码来源:manager.go

示例7: Menu

// Menu fills an applet actions list with videodl actions.
//
func (m *Manager) Menu(menu cdtype.Menuer) {
	m.control.Action().BuildMenu(menu, []int{m.firstID + ActionOpenFolder, m.firstID + ActionEnableDownload})

	if m.active {
		m.control.Action().BuildMenu(menu, []int{m.firstID + ActionCancelDownload})
	}

	subTitle := "Video Download"
	if !m.EnabledDL {
		subTitle += " (paused)"
	}
	sub := menu.AddSubMenu(subTitle, iconMenuMain)
	if m.history.Queued() > 0 {
		sub.AddEntry("Queued: "+strconv.Itoa(m.history.Queued()), "emblem-downloads", nil)
		sub.AddSeparator()
	}

	// sub.AddEntry("Edit list", "media-playlist-repeat", func() { m.log.ExecAsync(m.cmdOpenWeb, m.WebURL()) }).
	// 	SetTooltipText("Note that this will enable the web service\nYou may have to stop it manually when not needed anymore if you prefer.")
	m.control.Action().BuildMenu(sub, []int{m.firstID + ActionEditList, m.firstID + ActionEnableWeb})

	m.MenuTypeDL(sub, &m.TypeDL)
	m.MenuQuality(sub, &m.Quality, m.backend.MenuQuality())
}
开发者ID:sqp,项目名称:godock,代码行数:26,代码来源:manager.go

示例8: menuAddDevices

func (app *Applet) menuAddDevices(menu cdtype.Menuer, selected dbus.ObjectPath, title string, call func(dbus.ObjectPath) error) {
	sinks, _ := app.pulse.Core().ListPath("Sinks")
	if len(sinks) < 2 { // Only show the sinks list if we have at least 2 devices to switch between.
		return
	}
	menu.AddSeparator()
	menu.AddEntry(title, "audio-card", nil)
	menu.AddSeparator()
	for _, sink := range sinks {
		dev := app.pulse.Device(sink)
		sink := sink // make static reference of sink for the callback (we're in a range).

		v, e := dev.MapString("PropertyList")
		name := ternary.String(e == nil, v["device.description"], "unknown")
		menu.AddCheckEntry(name, sink == selected, func() { log.Err(call(sink)) })
	}
}
开发者ID:sqp,项目名称:godock,代码行数:17,代码来源:audio.go


注:本文中的github.com/sqp/godock/libs/cdtype.Menuer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。