Example #1
0
// 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)
}
Example #2
0
File: audio.go Project: sqp/godock
// 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.
	// })
}
Example #3
0
File: audio.go Project: sqp/godock
// 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)
}
Example #4
0
// 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())
	}
}
Example #5
0
File: action.go Project: sqp/godock
// 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)
		}
	}
}
Example #6
0
// 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())
	}
}
Example #7
0
// 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())
}
Example #8
0
File: audio.go Project: sqp/godock
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)) })
	}
}