AbstractDockItemProvider ProviderForItem(AbstractDockItem item) { return(Owner.ItemProviders .DefaultIfEmpty(null) .Where(p => p.Items.Contains(item)) .FirstOrDefault()); }
public override bool RemoveItem(AbstractDockItem item) { if (item is TimerMainDockItem) { Items = Enumerable.Empty <AbstractDockItem> (); foreach (AbstractDockItem adi in items) { if (adi is TimerDockItem) { (adi as TimerDockItem).Finished -= HandleTimerFinished; } adi.Dispose(); } } else { TimerDockItem timer = item as TimerDockItem; timer.Finished -= HandleTimerFinished; items.Remove(timer); Items = items; timer.Dispose(); } return(true); }
public override MenuList GetMenuItems(AbstractDockItem item) { MenuList list = base.GetMenuItems(item); list[MenuListContainer.Footer].Add(new MenuItem(Catalog.GetString("_Undo"), "edit-undo", (o, a) => ScreenUtils.ActiveViewport.RestoreLayout(), !ScreenUtils.ActiveViewport.CanRestoreLayout())); return(list); }
public override bool RemoveItem(AbstractDockItem item) { if ((item as MountItem).UnMount()) { return(base.RemoveItem(item)); } return(false); }
public DockManagerDBusItem(AbstractDockItem item) { owner = item; timer = GLib.Timeout.Add(4 * 60 * 1000, delegate { TriggerConfirmation(); return(true); }); }
public override MenuList GetMenuItems(AbstractDockItem item) { MenuList list = base.GetMenuItems(item); list[MenuListContainer.ProxiedItems].RemoveAt(0); list[MenuListContainer.Footer].Add(new MenuItem(Catalog.GetString("_Clear Recent Documents..."), "edit-clear", (o, a) => ClearRecent(), !CanClear)); return(list); }
protected override bool OnAcceptDrop(AbstractDockItem item) { if (!CanAcceptDrop(item)) { return(false); } item.Owner.RemoveItem(item); return(true); }
/// <summary> /// Emitted on the drag source when the drag finishes /// </summary> void HandleDragEnd(object o, DragEndArgs args) { if (RepositionMode) { Owner.CursorTracker.CursorPositionChanged -= HandleCursorPositionChanged; } if (!drag_canceled && drag_item != null) { if (!Owner.DockHovered) { // Remove from dock AbstractDockItemProvider provider = ProviderForItem(drag_item); bool poof = false; if (provider != null && provider.ItemCanBeRemoved(drag_item)) { // provider can manually remove provider.RemoveItem(drag_item); if (FileApplicationProvider.WindowManager != null) { FileApplicationProvider.WindowManager.UpdateTransientItems(); } poof = true; } if (poof) { PoofWindow window = new PoofWindow(128); window.SetCenterPosition(Owner.CursorTracker.Cursor); window.Run(); } } else { // Dropped somewhere on dock AbstractDockItem item = Owner.HoveredItem; if (item != null && item.CanAcceptDrop(drag_item)) { item.AcceptDrop(drag_item); } } } InternalDragActive = false; drag_item = null; Keyboard.Ungrab(Gtk.Global.CurrentEventTime); Owner.AnimatedDraw(); Owner.CursorTracker.CancelHighResolution(this); }
protected override bool OnCanAcceptDrop(AbstractDockItem item) { if (item == this) { return(false); } if (item.Owner == null) { return(false); } return(item.Owner.ItemCanBeRemoved(item)); }
/// <summary> /// Emitted on the drag source when drag is started /// </summary> void HandleDragBegin(object o, DragBeginArgs args) { Owner.CursorTracker.RequestHighResolution(this); InternalDragActive = true; Keyboard.Grab(Owner.GdkWindow, true, Gtk.Global.CurrentEventTime); drag_canceled = false; if (proxy_window != null) { EnableDragTo(); proxy_window = null; } Gdk.Pixbuf pbuf; drag_item = Owner.HoveredItem; original_item_pos.Clear(); // If we are in Reposition Mode or over a non-draggable item // dont drag it! if (drag_item is INonPersistedItem || RepositionMode) { drag_item = null; } if (drag_item != null) { foreach (AbstractDockItem adi in ProviderForItem(drag_item).Items) { original_item_pos [adi] = adi.Position; } using (DockySurface surface = new DockySurface((int)(1.2 * Owner.ZoomedIconSize), (int)(1.2 * Owner.ZoomedIconSize))) { pbuf = Owner.HoveredItem.IconSurface(surface, (int)(1.2 * Owner.ZoomedIconSize), Owner.IconSize, 0).LoadToPixbuf(); } } else { pbuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 1, 1); } Gtk.Drag.SetIconPixbuf(args.Context, pbuf, pbuf.Width / 2, pbuf.Height / 2); pbuf.Dispose(); // Set up a cursor tracker so we can move the window on the fly if (RepositionMode) { Owner.CursorTracker.CursorPositionChanged += HandleCursorPositionChanged; } }
/// <summary> /// Emitted on the drop site when the user drops data on the widget. /// </summary> void HandleDragDrop(object o, DragDropArgs args) { args.RetVal = true; Gtk.Drag.Finish(args.Context, true, false, args.Time); if (drag_data == null) { return; } AbstractDockItem item = Owner.HoveredItem; if (ItemAcceptsDrop()) { item.AcceptDrop(drag_data); } else if (providersAcceptDrops) { AbstractDockItem rightMost = Owner.RightMostItem; int newPosition = rightMost != null ? rightMost.Position : 0; foreach (string s in drag_data) { AbstractDockItemProvider provider; if (Owner.HoveredProvider != null && Owner.HoveredProvider.CanAcceptDrop(s)) { provider = Owner.HoveredProvider; } else if (Owner.Preferences.DefaultProvider.CanAcceptDrop(s)) { provider = Owner.Preferences.DefaultProvider; } else { // nothing will take it, continue! continue; } provider.AcceptDrop(s, newPosition); if (FileApplicationProvider.WindowManager != null) { FileApplicationProvider.WindowManager.UpdateTransientItems(); } } } ExternalDragActive = false; }
void RemoveItem(string label) { if (label == GMailDockItem.DefaultLabel) { return; } AbstractDockItem item = items.First(adi => (adi as GMailDockItem).Atom.CurrentLabel == label); items.Remove(item); SetItems(); item.Dispose(); }
void HandleHoveredItemChanged(object sender, HoveredItemChangedArgs e) { if (InternalDragActive && DragItemsCanInteract(drag_item, Owner.HoveredItem)) { int destPos = Owner.HoveredItem.Position; // drag right if (drag_item.Position < destPos) { foreach (AbstractDockItem adi in ProviderForItem(drag_item).Items .Where(i => i.Position > drag_item.Position && i.Position <= destPos)) { adi.Position--; } // drag left } else if (drag_item.Position > destPos) { foreach (AbstractDockItem adi in ProviderForItem(drag_item).Items .Where(i => i.Position < drag_item.Position && i.Position >= destPos)) { adi.Position++; } } drag_item.Position = destPos; Owner.UpdateCollectionBuffer(); Owner.Preferences.SyncPreferences(); } if (drag_hover_timer > 0) { GLib.Source.Remove(drag_hover_timer); drag_hover_timer = 0; } if (ExternalDragActive && drag_data != null) { drag_hover_timer = GLib.Timeout.Add(1500, delegate { AbstractDockItem item = Owner.HoveredItem; if (item != null) { item.Scrolled(ScrollDirection.Down, Gdk.ModifierType.None); } return(true); }); } }
public ProxyMenuItem(AbstractDockItem item) : base() { this.item = item; Bold = false; Text = item.HoverText; Disabled = false; using (DockySurface surface = new DockySurface(ICON_SIZE, ICON_SIZE)) { ForcePixbuf = item.IconSurface(surface, ICON_SIZE, ICON_SIZE, 0).LoadToPixbuf(); } Clicked += delegate { this.item.Clicked(1, Gdk.ModifierType.None, 0, 0); }; }
public bool ItemAcceptsDrop() { if (drag_data == null) { return(false); } AbstractDockItem item = Owner.HoveredItem; if (!drag_is_desktop_file && item != null && item.CanAcceptDrop(drag_data)) { return(true); } return(false); }
public void RegisterItem(AbstractDockItem item) { if (item_dict == null || item_dict.ContainsKey(item)) { return; } DockManagerDBusItem dbusitem = new DockManagerDBusItem(item); item_dict[item] = dbusitem; ObjectPath path = new ObjectPath(PathForItem(item)); Bus.Session.Register(path, dbusitem); dock_manager.OnItemAdded(path); }
public void Dispose() { if (timer > 0) { GLib.Source.Remove(timer); } update_time.Clear(); foreach (RemoteMenuEntry m in items.Values) { m.Clicked -= HandleActivated; m.Dispose(); } items.Clear(); owner = null; }
public override bool RemoveItem(AbstractDockItem item) { if (!ItemCanBeRemoved(item)) { return(false); } FileDockItem bookmark = item as FileDockItem; if (!bookmark.OwnedFile.Exists) { return(false); } File tempFile = FileFactory.NewForPath(System.IO.Path.GetTempFileName()); using (DataInputStream reader = new DataInputStream(BookmarksFile.Read(null))) { using (DataOutputStream writer = new DataOutputStream(tempFile.AppendTo(FileCreateFlags.None, null))) { string line; ulong length; while ((line = reader.ReadLine(out length, null)) != null) { if (line.Split(' ')[0] != bookmark.Uri) { writer.PutString(string.Format("{0}{1}", line, reader.NewLineString()), null); } else { items.Remove(bookmark); Items = InnerItems; Log <BookmarksItemProvider> .Debug("Removing '{0}'", bookmark.HoverText); } } } } if (tempFile.Exists) { tempFile.Move(BookmarksFile, FileCopyFlags.Overwrite, null, null); } return(true); }
void CreateItems() { lockItem = new SessionManagerActionItem("system-lock-screen", Catalog.GetString("L_ock Screen"), () => { system_manager.LockScreen(); }); logoutItem = new SessionManagerActionItem("system-log-out", Catalog.GetString("_Log Out..."), () => { SessionManagerActionItem.ShowConfirmationDialog(Catalog.GetString("Log Out"), Catalog.GetString("Are you sure you want to close all programs and log out of the computer?"), "system-log-out", system_manager.LogOut); }); suspendItem = new SessionManagerActionItem("system-suspend", Catalog.GetString("_Suspend"), () => { system_manager.LockScreen(); system_manager.Suspend(); }); hibernateItem = new SessionManagerActionItem("system-hibernate", Catalog.GetString("_Hibernate"), () => { system_manager.LockScreen(); system_manager.Hibernate(); }); restartItem = new SessionManagerActionItem("system-restart", Catalog.GetString("_Restart..."), () => { SessionManagerActionItem.ShowConfirmationDialog(Catalog.GetString("Restart"), Catalog.GetString("Are you sure you want to close all programs and restart the computer?"), "system-restart", () => system_manager.Restart()); }); shutdownItem = new SessionManagerActionItem("system-shutdown", Catalog.GetString("Shut _Down..."), () => { SessionManagerActionItem.ShowConfirmationDialog(Catalog.GetString("Shut Down"), Catalog.GetString("Are you sure you want to close all programs and shut down the computer?"), "system-shutdown", () => system_manager.Stop()); }); }
public void UnregisterItem(AbstractDockItem item) { if (item_dict == null || !item_dict.ContainsKey(item)) { return; } item_dict[item].Dispose(); item_dict.Remove(item); ObjectPath path = new ObjectPath(PathForItem(item)); try { Bus.Session.Unregister(path); } catch (Exception e) { Log <DBusManager> .Error("Could not unregister: {0}", path); Log <DBusManager> .Debug(e.StackTrace); return; } dock_manager.OnItemRemoved(path); }
bool DragItemsCanInteract(AbstractDockItem dragItem, AbstractDockItem hoveredItem) { return(dragItem != hoveredItem && ProviderForItem(dragItem) == ProviderForItem(hoveredItem) && ProviderForItem(dragItem) != null); }
public void ItemVisibilityChanged(AbstractDockItem item, bool newVisible) { SetItems(); }
public HoveredItemChangedArgs(AbstractDockItem last) { LastItem = last; }
public override bool ItemCanBeRemoved(AbstractDockItem item) { return(!(item is NonRemovableItem)); }
protected override bool OnCanAcceptDrop(AbstractDockItem item) { return(false); }
internal string PathForItem(AbstractDockItem item) { return(DockManagerItemsPath + Math.Abs(item.UniqueID().GetHashCode())); }
public WeatherItemProvider() { item = new WeatherDocklet(); Items = item.AsSingle <AbstractDockItem> (); }