示例#1
0
文件: eventmouse.go 项目: sqp/godock
// OnMiddleClick triggers a dock liddle click action on the icon.
//
func OnMiddleClick(icon gldi.Icon, container *gldi.Container) bool {
	if icon == nil || !gldi.ObjectIsDock(container) {
		log.Debug("notifMiddleClick", "ignored: no icon or dock target")
		return notif.AnswerLetPass
	}

	actmid := current.Taskbar.ActionOnMiddleClick()
	simple := icon.IsAppli() && !icon.IsApplet()
	multi := icon.IsMultiAppli()

	switch {
	case (simple || multi) && actmid == 3: // Launch new.
		if icon.GetCommand() != "" {
			// 	if (! gldi_class_is_starting (icon->cClass) && ! gldi_icon_is_launching (icon))  // do not launch it twice
			icon.LaunchCommand(log)
		}
		return notif.AnswerIntercept

	case simple && actmid == 1: // Close one.
		icon.Window().Close()
		return notif.AnswerIntercept

	case simple && actmid == 2: // Minimise one.
		if !icon.Window().IsHidden() {
			icon.Window().Minimize()
		}
		return notif.AnswerIntercept

	case multi && actmid == 1: // Close all.
		icon.CallbackActionSubWindows((cdglobal.Window).Close)()
		return notif.AnswerIntercept

	case multi && actmid == 2: // Minimise all.
		hideShowInClassSubdock(icon)
		return notif.AnswerIntercept
	}

	return notif.AnswerLetPass
}
示例#2
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.
}
示例#3
0
文件: eventmouse.go 项目: sqp/godock
// OnDropData triggers a dock drop data action on the icon.
//
func OnDropData(icon gldi.Icon, container *gldi.Container, data string, order float64) bool {
	if !gldi.ObjectIsDock(container) {
		log.Debug("notifDropData", "ignored: container is not a dock")
		return notif.AnswerLetPass
	}

	receivingDock := container.ToCairoDock()

	switch {
	case strings.HasSuffix(data, ".desktop"): // -> add a new launcher if dropped on or amongst launchers.

		if !current.Taskbar.MixLauncherAppli() && icon.IsAppli() {
			log.Debug("notifDropData", "ignored: desktop file found but maybe bad location in dock (or need mix launchers)")
			return notif.AnswerLetPass
		}

		// drop onto a container icon.
		if order == gldi.IconLastOrder && icon.IsStackIcon() && icon.GetSubDock() != nil {
			// add into the pointed sub-dock.
			receivingDock = icon.GetSubDock()
		}

		// else, still try to consider it a file?

	case icon == nil || order != gldi.IconLastOrder:
		//  dropped between 2 icons -> try to add it (for instance a script).

	case icon.IsStackIcon(): // sub-dock -> propagate to the sub-dock.
		receivingDock = icon.GetSubDock()

		// dropped on an icon

	case icon.IsLauncher() || icon.IsAppli() || icon.IsClassIcon():
		// launcher/appli -> fire the command with this file.
		cmd := icon.GetCommand()
		if cmd == "" {
			log.Debug("notifDropData", "ignored: no command to trigger")
			return notif.AnswerLetPass
		}

		// Some programs doesn't handle URI. Convert it to local path.
		if strings.HasPrefix(data, "file://") {

			// gchar *cPath = g_filename_from_uri (cReceivedData, NULL, NULL);
			// data = bouine(data)
		}

		ok := icon.LaunchCommand(log, data)
		if ok {
			icon.RequestAnimation("blink", 2)
			log.Debug("notifDropData", "opened with", icon.GetName(), "::", data)
		}

		return notif.AnswerIntercept

	default: // skip any other case.
		log.Debug("notifDropData", "ignored: nothing to do with icon type", icon.GetName())
		return notif.AnswerLetPass
	}

	if current.DockIsLocked() || current.Docks.LockAll() {
		log.Debug("notifDropData", "ignored: dock is locked, can't add icon")
		return notif.AnswerLetPass
	}

	// Still here ? Try to add to target dock.

	newicon := gldi.LauncherAddNew(data, receivingDock, order)
	if newicon == nil {
		log.Debug("notifDropData", "add icon failed ::", data)
		return notif.AnswerIntercept
	}

	log.Debug("notifDropData", "icon added:", icon.GetName())
	return notif.AnswerLetPass
}