// BuildMenuContainer builds the dock container menu (1st line). // func BuildMenuContainer(m *backendmenu.DockMenu) bool { 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). return notif.AnswerLetPass } 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() { return notif.AnswerLetPass } } if m.Dock != nil && (m.Icon == nil || m.Icon.IsSeparatorAuto()) { return notif.AnswerLetPass } //\_________________________ First item is the Cairo-Dock sub-menu. dockmenu := m.AddSubMenu("Cairo-Dock", globals.FileCairoDockIcon()) if !current.DockIsLocked() { dockmenu.Entry(backendmenu.MenuConfigure) if m.Dock != nil && !m.Dock.IsMainDock() && m.Dock.GetRefCount() == 0 { // root dock settings dockmenu.Entry(backendmenu.MenuEditDock) dockmenu.Entry(backendmenu.MenuDeleteDock) } // if backendgui.CanManageThemes () {// themes. won't have a menu entry. // dockmenu.Entry(backendmenu.MenuThemes) // } // Show edit icon below edit dock when icons are locked (only thing needed from the icon submenu). if current.Docks.LockIcons() { dockmenu.Entry(backendmenu.MenuEditTarget) } else { // Submenu add new item. if m.Dock != nil { sub := dockmenu.AddSubMenu(tran.Slate("Add"), globals.IconNameAdd) sub.Entry(backendmenu.MenuAddSubDock) sub.Entry(backendmenu.MenuAddMainDock) sub.Entry(backendmenu.MenuAddSeparator) sub.Entry(backendmenu.MenuAddLauncher) sub.Entry(backendmenu.MenuAddApplet) } } dockmenu.AddSeparator() dockmenu.Entry(backendmenu.MenuLockIcons) } if m.Dock != nil && !m.Dock.IsAutoHide() { dockmenu.Entry(backendmenu.MenuQuickHide) } if !globals.FullLock { // dockmenu.Entry(backendmenu.MenuAutostart) // removed crap. // dockmenu.Entry(backendmenu.MenuThirdParty) // not needed with the download page. dockmenu.Entry(backendmenu.MenuHelp) // Don't show if locked, because it would open the configuration window. } dockmenu.Entry(backendmenu.MenuAbout) if !globals.FullLock { dockmenu.Entry(backendmenu.MenuQuit) } // //\_________________________ Second item is the Icon sub-menu. // Icon *pIcon = icon; // if (pIcon == NULL && CAIRO_DOCK_IS_DESKLET (pContainer)) // on a desklet, the main applet icon may not be drawn; therefore we add the applet sub-menu if we clicked outside of an icon. // { // pIcon = CAIRO_DESKLET (pContainer)->pIcon; // } // pIcon := GetIconForDesklet(icon, container) if m.Icon != nil && !m.Icon.IsSeparatorAuto() && !current.Docks.LockIcons() { items := m.AddSubMenu(m.Icon.DefaultNameIcon()) // GtkWidget *pItemSubMenu = _add_item_sub_menu (pIcon, menu); if current.DockIsLocked() { switch { case m.Icon.IsAppli() && m.Icon.GetCommand() != "": items.Entry(backendmenu.MenuLaunchNew) case m.Icon.IsApplet(): items.Entry(backendmenu.MenuHandbook) default: items.SetSensitive(false) // empty, the submenu is added for consistency between icons, but disabled. } } else { if m.Icon.IsAppli() && m.Icon.GetCommand() != "" { items.Entry(backendmenu.MenuLaunchNew) } switch { case m.Icon.GetDesktopFileName() != "" && (m.Icon.IsLauncher() || m.Icon.IsStackIcon() || m.Icon.IsSeparator()): items.Entry(backendmenu.MenuEditIcon) items.Entry(backendmenu.MenuRemoveIcon) items.Entry(backendmenu.MenuMoveToDock) case (m.Icon.IsAppli() || m.Icon.IsStackIcon()) && // appli with no launcher !m.Icon.ClassIsInhibited(): // if the class doesn't already have an inhibator somewhere. items.Entry(backendmenu.MenuMakeLauncher) if !current.Docks.LockAll() && m.Icon.IsAppli() { if current.Taskbar.OverWriteXIcons() { items.Entry(backendmenu.MenuCustomIconRemove) } items.Entry(backendmenu.MenuCustomIconSet) } case m.Icon.IsApplet(): // applet (icon or desklet) (the sub-icons have been filtered before and won't have this menu). items.Entry(backendmenu.MenuEditApplet) if m.Icon.IsDetachableApplet() { items.Entry(backendmenu.MenuDetachApplet) } items.Entry(backendmenu.MenuRemoveApplet) if m.Icon.ModuleInstance().Module().VisitCard().IsMultiInstance() { items.Entry(backendmenu.MenuDuplicateApplet) } if m.Dock != nil && m.Icon.GetContainer() != nil { items.Entry(backendmenu.MenuMoveToDock) } items.AddSeparator() items.Entry(backendmenu.MenuHandbook) } } } return notif.AnswerLetPass }
// 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 }
// 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 }