Exemple #1
0
func (m *DockMenu) moveToDesktop(useAll bool) {
	if desktops.NbDesktops() < 2 && desktops.NbViewportX() < 2 && desktops.NbViewportY() < 2 {
		return
	}

	m.AddSeparator()
	win := m.Icon.Window()

	moveto := newMenuMoveToDesktop(m.Icon, useAll)

	for i := 0; i < desktops.NbDesktops(); i++ { // sort by desktop

		for j := 0; j < desktops.NbViewportY(); j++ { // and by columns.

			for k := 0; k < desktops.NbViewportX(); k++ { // then rows.

				entry := m.AddEntry(moveto.Label(i, j, k), "", moveto.Callback(i, j, k))

				if win != nil && win.IsOnDesktop(i, j, k) {
					entry.SetSensitive(false)
				}
			}
		}
	}
}
Exemple #2
0
func newMenuMoveToDesktop(icon gldi.Icon, useAll bool) *menuMoveToDesktop {
	// Create object and set work mode.
	desk := &menuMoveToDesktop{nbx: desktops.NbViewportX()}
	switch {
	case desktops.NbDesktops() > 1 && (desktops.NbViewportX() > 1 || desktops.NbViewportY() > 1):
		desk.mode = 2

	case desktops.NbDesktops() > 1:
		desk.mode = 1
	}

	// Set label format string.
	switch {
	case desk.mode == 2 && useAll:
		desk.format = tran.Slate("Move all to desktop %d - face %d")

	case desk.mode == 2:
		desk.format = tran.Slate("Move to desktop %d - face %d")

	case desk.mode == 1 && useAll:
		desk.format = tran.Slate("Move all to desktop %d")

	case desk.mode == 1:
		desk.format = tran.Slate("Move to desktop %d")

	case desk.mode == 0 && useAll:
		desk.format = tran.Slate("Move all to face %d")

	case desk.mode == 0:
		desk.format = tran.Slate("Move to face %d")
	}

	// Set the window action method.
	if useAll {
		desk.cbAction = icon.CallbackActionSubWindows // All windows of class.
	} else {
		desk.cbAction = icon.CallbackActionWindow // One window.
	}

	return desk
}