예제 #1
0
파일: action.go 프로젝트: 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)
		}
	}
}
예제 #2
0
파일: NetActivity.go 프로젝트: sqp/godock
// 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)
}
예제 #3
0
파일: audio.go 프로젝트: 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)) })
	}
}