Exemplo n.º 1
0
 AbstractDockItemProvider ProviderForItem(AbstractDockItem item)
 {
     return(Owner.ItemProviders
            .DefaultIfEmpty(null)
            .Where(p => p.Items.Contains(item))
            .FirstOrDefault());
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public override bool RemoveItem(AbstractDockItem item)
 {
     if ((item as MountItem).UnMount())
     {
         return(base.RemoveItem(item));
     }
     return(false);
 }
Exemplo n.º 5
0
        public DockManagerDBusItem(AbstractDockItem item)
        {
            owner = item;

            timer = GLib.Timeout.Add(4 * 60 * 1000, delegate {
                TriggerConfirmation();
                return(true);
            });
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        protected override bool OnAcceptDrop(AbstractDockItem item)
        {
            if (!CanAcceptDrop(item))
            {
                return(false);
            }

            item.Owner.RemoveItem(item);
            return(true);
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
        protected override bool OnCanAcceptDrop(AbstractDockItem item)
        {
            if (item == this)
            {
                return(false);
            }

            if (item.Owner == null)
            {
                return(false);
            }

            return(item.Owner.ItemCanBeRemoved(item));
        }
Exemplo n.º 10
0
        /// <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;
            }
        }
Exemplo n.º 11
0
        /// <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;
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
        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);
                });
            }
        }
Exemplo n.º 14
0
        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);
            };
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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;
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        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());
            });
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
 bool DragItemsCanInteract(AbstractDockItem dragItem, AbstractDockItem hoveredItem)
 {
     return(dragItem != hoveredItem &&
            ProviderForItem(dragItem) == ProviderForItem(hoveredItem) &&
            ProviderForItem(dragItem) != null);
 }
Exemplo n.º 22
0
 public void ItemVisibilityChanged(AbstractDockItem item, bool newVisible)
 {
     SetItems();
 }
Exemplo n.º 23
0
 public HoveredItemChangedArgs(AbstractDockItem last)
 {
     LastItem = last;
 }
Exemplo n.º 24
0
 public override bool ItemCanBeRemoved(AbstractDockItem item)
 {
     return(!(item is NonRemovableItem));
 }
Exemplo n.º 25
0
 protected override bool OnCanAcceptDrop(AbstractDockItem item)
 {
     return(false);
 }
Exemplo n.º 26
0
 internal string PathForItem(AbstractDockItem item)
 {
     return(DockManagerItemsPath + Math.Abs(item.UniqueID().GetHashCode()));
 }
Exemplo n.º 27
0
        public WeatherItemProvider()
        {
            item = new WeatherDocklet();

            Items = item.AsSingle <AbstractDockItem> ();
        }