void ItemChanged()
        {
            AbstractDockItem oldItem = currentItem;

            if (oldItem != null)
            {
                oldItem.HoverTextChanged -= HandleHoverTextChanged;
                oldItem.PaintNeeded      -= HandlePaintNeeded;
                oldItem.PainterRequest   -= HandlePainterRequest;
            }

            if (CurrentPosition < 0)
            {
                CurrentPosition = Provider.Items.Count() - 1;
            }
            else if (CurrentPosition >= Provider.Items.Count())
            {
                CurrentPosition = 0;
            }

            currentItem = Provider.Items.ToArray()[CurrentPosition];
            currentItem.HoverTextChanged += HandleHoverTextChanged;
            currentItem.PaintNeeded      += HandlePaintNeeded;
            currentItem.PainterRequest   += HandlePainterRequest;

            if (CurrentItemChanged != null)
            {
                CurrentItemChanged(currentItem, new CurrentItemChangedArgs(currentItem, oldItem));
            }

            QueueRedraw();
            OnHoverTextChanged();
        }
        public bool SetItem(AbstractDockItem item, bool temporary)
        {
            if (!Provider.Items.Contains(item))
            {
                return(false);
            }

            AbstractDockItem[] items = Provider.Items.ToArray();

            for (int i = 0; i < items.Count(); i++)
            {
                if (item == items [i])
                {
                    if (temporary)
                    {
                        currentPos = i;
                    }
                    else
                    {
                        CurrentPosition = i;
                    }
                    break;
                }
            }

            ItemChanged();
            return(true);
        }
Пример #3
0
        public override bool RemoveItem(AbstractDockItem item)
        {
            if (!items.ContainsValue(item))
            {
                return(false);
            }

            string key = null;

            foreach (KeyValuePair <string, AbstractDockItem> kvp in items)
            {
                if (kvp.Value == item)
                {
                    key = kvp.Key;
                    break;
                }
            }

            // this should never happen...
            if (key == null)
            {
                return(false);
            }

            items.Remove(key);

            Items = InternalItems;

            item.Dispose();

            // this is so if the launcher has open windows and we manage those...
            UpdateTransientItems();
            return(true);
        }
Пример #4
0
        public bool AcceptDrop(string uri, int position)
        {
            AbstractDockItem newItem = null;

            try {
                newItem = OnAcceptDrop(uri);
            } catch (Exception e) {
                Log <AbstractDockItem> .Error(e.Message);

                Log <AbstractDockItemProvider> .Debug(e.StackTrace);
            }

            if (newItem != null)
            {
                newItem.Position = position;
                foreach (AbstractDockItem item in Items.Where(adi => adi != newItem && adi.Position >= newItem.Position))
                {
                    item.Position++;
                }
            }

            OnItemsChanged(null, null);

            return(newItem != null);
        }
		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 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;
		}
Пример #8
0
        public override MenuList GetMenuItems(AbstractDockItem item)
        {
            MenuList list = base.GetMenuItems(item);

            if (item is ApplicationDockItem && !items.ContainsValue(item) && allowPinToDock)
            {
                list[MenuListContainer.Actions].Insert(0,
                                                       new MenuItem(Catalog.GetString("_Pin to Dock"), "[monochrome]pin.svg@" + GetType().Assembly.FullName, (o, a) => PinToDock(item as ApplicationDockItem)));
            }

            return(list);
        }
Пример #9
0
        public virtual bool RemoveItem(AbstractDockItem item)
        {
            if (!ItemCanBeRemoved(item))
            {
                return(false);
            }

            IEnumerable <AbstractDockItem> saved = Items.Where(adi => adi != item).ToArray();

            Items = saved;
            item.Dispose();
            return(true);
        }
Пример #10
0
        /// <summary>
        /// Called by the owning dock when an AbstractDockitem has been dropped on an item and CanAcceptDrop has returned true
        /// </summary>
        /// <param name="item">
        /// A <see cref="AbstractDockItem"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        public virtual bool AcceptDrop(AbstractDockItem item)
        {
            bool result = false;

            try {
                result = OnAcceptDrop(item);
            } catch (Exception e) {
                Log <AbstractDockItem> .Error(e.Message);

                Log <AbstractDockItem> .Debug(e.StackTrace);
            }
            return(result);
        }
Пример #11
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);
			};
		}
Пример #12
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;
		}
		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 virtual bool RemoveItem (AbstractDockItem item)
		{
			if (!ItemCanBeRemoved (item))
				return false;
			
			IEnumerable<AbstractDockItem> saved = Items.Where (adi => adi != item).ToArray ();
			Items = saved;
			item.Dispose ();
			return true;
		}
		public WeatherItemProvider ()
		{
			item = new WeatherDocklet ();
			
			Items = item.AsSingle<AbstractDockItem> ();
		}
		public override MenuList GetMenuItems (AbstractDockItem item)
		{
			MenuList list = base.GetMenuItems (item);
			
			if (item is ApplicationDockItem && !items.ContainsValue (item) && allowPinToDock)
				list[MenuListContainer.Actions].Insert (0, 
					new MenuItem (Catalog.GetString ("_Pin to Dock"), "[monochrome]pin.svg@" + GetType ().Assembly.FullName, (o, a) => PinToDock (item as ApplicationDockItem)));
			
			return list;
		}
		public CurrentItemChangedArgs (AbstractDockItem newItem, AbstractDockItem oldItem)
		{
			NewItem = newItem;
			OldItem = oldItem;
		}
Пример #18
0
		public bool SetItem (AbstractDockItem item)
		{
			return SetItem (item, false);
		}
		public override bool ItemCanBeRemoved (AbstractDockItem item)
		{
			return items.ContainsValue (item);
		}
Пример #20
0
		AbstractDockItemProvider ProviderForItem (AbstractDockItem item)
		{
			return Owner.ItemProviders
				.DefaultIfEmpty (null)
				.Where (p => p.Items.Contains (item))
				.FirstOrDefault ();
		}
Пример #21
0
		void ItemChanged ()
		{
			AbstractDockItem oldItem = currentItem;
			
			if (oldItem != null) {
				oldItem.HoverTextChanged -= HandleHoverTextChanged;
				oldItem.PaintNeeded      -= HandlePaintNeeded;
				oldItem.PainterRequest   -= HandlePainterRequest;
			}
			
			if (CurrentPosition < 0)
				CurrentPosition = Provider.Items.Count () - 1;
			else if (CurrentPosition >= Provider.Items.Count ()) 
				CurrentPosition = 0;
			
			currentItem = Provider.Items.ToArray ()[CurrentPosition];
			currentItem.HoverTextChanged += HandleHoverTextChanged;
			currentItem.PaintNeeded      += HandlePaintNeeded;
			currentItem.PainterRequest   += HandlePainterRequest;
			
			if (CurrentItemChanged != null)
				CurrentItemChanged (currentItem, new CurrentItemChangedArgs (currentItem, oldItem));

			QueueRedraw ();
			OnHoverTextChanged ();
		}
Пример #22
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;
		}
Пример #23
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);
		}
Пример #24
0
		protected virtual bool OnAcceptDrop (AbstractDockItem item)
		{
			return false;
		}
Пример #25
0
		/// <summary>
		/// Called by the owning dock when an AbstractDockitem has been dropped on an item and CanAcceptDrop has returned true
		/// </summary>
		/// <param name="item">
		/// A <see cref="AbstractDockItem"/>
		/// </param>
		/// <returns>
		/// A <see cref="System.Boolean"/>
		/// </returns>
		public virtual bool AcceptDrop (AbstractDockItem item)
		{
			bool result = false;
			try {
				result = OnAcceptDrop (item);
			} catch (Exception e) {
				Log<AbstractDockItem>.Error (e.Message);
				Log<AbstractDockItem>.Debug (e.StackTrace);
			}
			return result;
		}
Пример #26
0
 public bool SetItem(AbstractDockItem item)
 {
     return(SetItem(item, false));
 }
		public void Dispose ()
		{
			if (timer > 0) {
				GLib.Source.Remove (timer);
				timer = 0;
			}
			
			update_time.Clear ();
			
			foreach (RemoteMenuEntry m in items.Values) {
				m.Clicked -= HandleActivated;
				m.Dispose ();
			}
			items.Clear ();
			
			owner = null;
		}
Пример #28
0
		bool DragItemsCanInteract (AbstractDockItem dragItem, AbstractDockItem hoveredItem)
		{
			return dragItem != hoveredItem &&
				   ProviderForItem (dragItem) == ProviderForItem (hoveredItem) && 
				   ProviderForItem (dragItem) != null;
		}
Пример #29
0
		protected override bool OnAcceptDrop (AbstractDockItem item)
		{
			if (!CanAcceptDrop (item))
				return false;

			item.Owner.RemoveItem (item);
			return true;
		}
		public PainterRequestEventArgs (AbstractDockItem owner, AbstractDockPainter painter, ShowHideType type)
		{
			Owner = owner;
			Painter = painter;
			Type = type;
		}
Пример #31
0
		public override bool AcceptDrop (AbstractDockItem item)
		{
			return currentItem.AcceptDrop (item);
		}
Пример #32
0
 public CurrentItemChangedArgs()
 {
     NewItem = null;
     OldItem = null;
 }
Пример #33
0
		public bool SetItem (AbstractDockItem item, bool temporary)
		{
			if (!Provider.Items.Contains (item))
				return false;
			
			AbstractDockItem[] items = Provider.Items.ToArray ();
			
			for (int i = 0; i < items.Count (); i++)
				if (item == items [i]) {
					if (temporary)
						currentPos = i;
					else
						CurrentPosition = i;
					break;
				}
			
			ItemChanged ();
			return true;
		}
Пример #34
0
 public virtual bool ItemCanBeRemoved(AbstractDockItem item)
 {
     return(true);
 }
		public override bool RemoveItem (AbstractDockItem item)
		{
			if (!items.ContainsValue (item))
				return false;
			
			string key = null;
			foreach (KeyValuePair<string, AbstractDockItem> kvp in items)
				if (kvp.Value == item) {
					key = kvp.Key;
					break;
				}
			
			// this should never happen...
			if (key == null)
				return false;
			
			items.Remove (key);
			
			Items = InternalItems;
			
			item.Dispose ();
			
			// this is so if the launcher has open windows and we manage those...
			UpdateTransientItems ();
			return true;
		}
Пример #36
0
 public override bool AcceptDrop(AbstractDockItem item)
 {
     return(currentItem.AcceptDrop(item));
 }
		public CurrentItemChangedArgs ()
		{
			NewItem = null;
			OldItem = null;
		}
Пример #38
0
 protected virtual bool OnAcceptDrop(AbstractDockItem item)
 {
     return(false);
 }
		public virtual bool ItemCanBeRemoved (AbstractDockItem item)
		{
			return true;
		}
Пример #40
0
 public override bool ItemCanBeRemoved(AbstractDockItem item)
 {
     return(items.ContainsValue(item));
 }
		public virtual MenuList GetMenuItems (AbstractDockItem item)
		{
			return item.GetMenuItems ();
		}
Пример #42
0
 public CurrentItemChangedArgs(AbstractDockItem newItem, AbstractDockItem oldItem)
 {
     NewItem = newItem;
     OldItem = oldItem;
 }
Пример #43
0
 public PainterRequestEventArgs(AbstractDockItem owner, AbstractDockPainter painter, ShowHideType type)
 {
     Owner   = owner;
     Painter = painter;
     Type    = type;
 }
Пример #44
0
		void UnregisterItem (AbstractDockItem item)
		{
			item.HoverTextChanged -= ItemHoverTextChanged;
			item.PaintNeeded      -= ItemPaintNeeded;
			item.PainterRequest   -= ItemPainterRequest;
			DrawValues.Remove (item);
			
			DBusManager.Default.UnregisterItem (item);
		}
Пример #45
0
 public virtual MenuList GetMenuItems(AbstractDockItem item)
 {
     return(item.GetMenuItems());
 }
Пример #46
0
		protected override bool OnCanAcceptDrop (AbstractDockItem item)
		{
			if (item == this)
				return false;

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

			return item.Owner.ItemCanBeRemoved (item);
		}