예제 #1
0
파일: mgrgldi.go 프로젝트: sqp/godock
// sendIconOrSub sends an event to the applet matching the icon or subicon.
//
func (o *AppManager) sendIconOrSub(icon gldi.Icon, container *gldi.Container, mainEvent, subEvent string, data ...interface{}) bool {
	var appIcon gldi.Icon
	switch { // Find the base icon of the icon that was clicked on (for subdock or desklets).
	case container.IsDesklet():
		appIcon = container.ToDesklet().GetIcon()

	case gldi.ObjectIsDock(container) && container.ToCairoDock().GetRefCount() != 0 && !icon.IsApplet():
		appIcon = container.ToCairoDock().SearchIconPointingOnDock(nil)

	default:
		appIcon = icon
	}

	if appIcon == nil || icon == nil || icon.ToNative() == nil { // TODO: need to check why.
		return notif.AnswerLetPass
	}

	if appIcon.ToNative() == icon.ToNative() {
		return o.sendApp(appIcon, mainEvent, data...) // Main Icon event.
	}
	data = append(data, icon.GetCommand())       // add reference to subicon key.
	return o.sendApp(appIcon, subEvent, data...) // SubIcon event.
}
예제 #2
0
파일: backendmenu.go 프로젝트: sqp/godock
// GetIconForDesklet will return the correct icon if clicked on a desklet.
//
func GetIconForDesklet(icon gldi.Icon, container *gldi.Container) gldi.Icon {
	if container.IsDesklet() {
		return container.ToDesklet().GetIcon()
	}
	return icon
}