Ejemplo n.º 1
0
// BuildMenuIcon builds the dock icon menu (2nd line).
//
func BuildMenuIcon(m *backendmenu.DockMenu) bool {

	//\_________________________ Clic en-dehors d'une icone utile => on s'arrete la.
	if m.Dock != nil && (m.Icon == nil || m.Icon.IsSeparatorAuto()) {
		return notif.AnswerLetPass
	}

	needSeparator := true

	if m.Container.IsDesklet() && m.Icon != nil && !m.Icon.IsApplet() { // not on the icons of a desklet, except the applet icon (on a desklet, it's easy to click out of any icon).
		needSeparator = false
	}

	if m.Dock != nil && m.Dock.GetRefCount() > 0 { // not on the sub-docks, except user sub-docks.
		pointingIcon := m.Dock.SearchIconPointingOnDock(nil)
		if pointingIcon != nil && !pointingIcon.IsStackIcon() {
			needSeparator = false
		}
	}

	// 	//\_________________________ class actions.
	if m.Icon != nil && m.Icon.GetClass().String() != "" && !m.Icon.GetIgnoreQuickList() {
		if needSeparator {
			m.AddSeparator()
		}
		needSeparator = m.Entry(backendmenu.MenuClassItems)
	}

	//\_________________________ Actions on applications.
	if m.Icon.IsAppli() {
		if needSeparator {
			m.AddSeparator()
		}
		needSeparator = true

		appli := m.Icon.Window()
		canMin, canMax, canClose := appli.CanMinMaxClose()

		var btns []backendmenu.MenuBtn
		if canClose {
			btns = append(btns, backendmenu.MenuWindowClose)
		}

		if !appli.IsHidden() {
			if canMax {
				btns = append(btns, backendmenu.MenuWindowMax)
			}
			if canMin {
				btns = append(btns, backendmenu.MenuWindowMin)
			}
		}

		if appli.IsHidden() || !appli.IsActive() || !appli.IsOnCurrentDesktop() {
			btns = append(btns, backendmenu.MenuWindowShow)
		}

		m.AddButtonsEntry(tran.Slate("Window"), btns...)

		//\_________________________ Other actions

		otherActions := m.AddSubMenu(tran.Slate("Other actions"), "")

		otherActions.Entry(backendmenu.MenuWindowMoveHere)
		otherActions.Entry(backendmenu.MenuWindowFullScreen)
		otherActions.Entry(backendmenu.MenuWindowBelow)
		otherActions.Entry(backendmenu.MenuWindowAbove)
		otherActions.Entry(backendmenu.MenuWindowSticky)
		otherActions.Entry(backendmenu.MenuMoveToDesktopWindow)

		otherActions.AddSeparator()

		otherActions.Entry(backendmenu.MenuWindowKill)

	} else if m.Icon.IsMultiAppli() { // Window management
		if needSeparator {
			m.AddSeparator()
		}
		needSeparator = true

		m.AddButtonsEntry("Windows",
			backendmenu.MenuWindowCloseAll,
			backendmenu.MenuWindowMinAll,
			backendmenu.MenuWindowShowAll,
		)

		otherActions := m.AddSubMenu(tran.Slate("Other actions"), "")
		otherActions.Entry(backendmenu.MenuWindowMoveAllHere)
		otherActions.Entry(backendmenu.MenuMoveToDesktopClass)
	}

	//\_________________________ Desklet positioning actions.

	if !current.DockIsLocked() && m.Container.IsDesklet() {
		if needSeparator {
			m.AddSeparator()
		}
		// needSeparator = true

		m.Entry(backendmenu.MenuDeskletVisibility)
		m.Entry(backendmenu.MenuDeskletSticky)
		m.Entry(backendmenu.MenuDeskletLock)
	}

	return notif.AnswerLetPass
}