Ejemplo n.º 1
0
        /// <summary>
        /// Pins an <see cref="Docky.Items.ApplicationDockItem"/> to the dock.
        /// </summary>
        /// <param name='item'>
        /// Item.
        /// </param>
        public void PinToDock(ApplicationDockItem item)
        {
            if (items.ContainsKey(item.OwnedItem.Uri.AbsoluteUri))
            {
                return;
            }

            item.WindowsChanged -= HandleTransientWindowsChanged;
            transient_items.Remove(item);
            items.Add(item.OwnedItem.Uri.AbsoluteUri, item);

            OnItemsChanged(null, null);
        }
Ejemplo n.º 2
0
        AbstractDockItem Insert(string uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            if (items.ContainsKey(uri))
            {
                return(null);
            }

            AbstractDockItem item;

            try {
                if (uri.EndsWith(".desktop"))
                {
                    item = ApplicationDockItem.NewFromUri(uri);
                }
                else
                {
                    item = FileDockItem.NewFromUri(uri);
                }
            } catch (Exception e) {
                Log <FileApplicationProvider> .Debug(e.Message);

                Log <FileApplicationProvider> .Debug(e.StackTrace);

                item = null;
            }

            if (item == null)
            {
                return(null);
            }

            items[uri] = item;


            Items = InternalItems;
            UpdateTransientItems();

            return(item);
        }
		/// <summary>
		/// Pins an <see cref="Docky.Items.ApplicationDockItem"/> to the dock.
		/// </summary>
		/// <param name='item'>
		/// Item.
		/// </param>
		public void PinToDock (ApplicationDockItem item)
		{
			if (items.ContainsKey (item.OwnedItem.Uri.AbsoluteUri))
				return;
			
			item.WindowsChanged -= HandleTransientWindowsChanged;
			transient_items.Remove (item);
			items.Add (item.OwnedItem.Uri.AbsoluteUri, item);

			OnItemsChanged (null, null);
		}
		/// <summary>
		/// Updates the transient items.
		/// </summary>
		public void UpdateTransientItems ()
		{
			// if we are not a window-manager-provider then remove transient items
			if (!IsWindowManager) {
				RemoveTransientItems (transient_items.ToList ());
				return;
			}

			if (longMatchInProgress)
				return;

			// handle unmanaged windows
			foreach (Wnck.Window window in UnmanagedWindows) {
				if (transient_items.Where (adi => adi is WnckDockItem)
					.Cast<WnckDockItem> ()
					.SelectMany (wdi => wdi.Windows)
					.Contains (window))
					continue;
				
				DesktopItem desktopItem = DockServices.WindowMatcher.DesktopItemForWindow (window);
				WnckDockItem item;
				
				if (desktopItem != null) {
					// This fixes WindowMatching for OpenOffice which is a bit slow setting up its window title
					// Check if an existing ApplicationDockItem already uses this DesktopItem
					ApplicationDockItem appdi = InternalItems
						.Where (adi => (adi is ApplicationDockItem && (adi as ApplicationDockItem).OwnedItem == desktopItem))
						.Cast<ApplicationDockItem> ()
						.FirstOrDefault ();
					
					// Try again to gain this missing window
					if (appdi != null) {
						appdi.RecollectWindows ();
						continue;
					}
					
					item = new ApplicationDockItem (desktopItem);
				} else {
					item = new WindowDockItem (window);
				}
				
				transient_items.Add (item);
				item.WindowsChanged += HandleTransientWindowsChanged;
			}
			
			// remove old transient items
			List<WnckDockItem> removed_transient_items = new List<WnckDockItem> ();
			foreach (WnckDockItem wdi in transient_items.Where (adi => adi is WnckDockItem).Cast<WnckDockItem> ()) {
				foreach (Wnck.Window window in ManagedWindows)
					if (wdi.Windows.Contains (window)) {
						removed_transient_items.Add (wdi);
						continue;
					}
				if (!wdi.ManagedWindows.Any ())
					removed_transient_items.Add (wdi);
			}
			RemoveTransientItems (removed_transient_items);
		}
Ejemplo n.º 5
0
        /// <summary>
        /// Updates the transient items.
        /// </summary>
        public void UpdateTransientItems()
        {
            // if we are not a window-manager-provider then remove transient items
            if (!IsWindowManager)
            {
                RemoveTransientItems(transient_items.ToList());
                return;
            }

            if (longMatchInProgress)
            {
                return;
            }

            // handle unmanaged windows
            foreach (Wnck.Window window in UnmanagedWindows)
            {
                if (transient_items.Where(adi => adi is WnckDockItem)
                    .Cast <WnckDockItem> ()
                    .SelectMany(wdi => wdi.Windows)
                    .Contains(window))
                {
                    continue;
                }

                DesktopItem  desktopItem = DockServices.WindowMatcher.DesktopItemForWindow(window);
                WnckDockItem item;

                if (desktopItem != null)
                {
                    // This fixes WindowMatching for OpenOffice which is a bit slow setting up its window title
                    // Check if an existing ApplicationDockItem already uses this DesktopItem
                    ApplicationDockItem appdi = InternalItems
                                                .Where(adi => (adi is ApplicationDockItem && (adi as ApplicationDockItem).OwnedItem == desktopItem))
                                                .Cast <ApplicationDockItem> ()
                                                .FirstOrDefault();

                    // Try again to gain this missing window
                    if (appdi != null)
                    {
                        appdi.RecollectWindows();
                        continue;
                    }

                    item = new ApplicationDockItem(desktopItem);
                }
                else
                {
                    item = new WindowDockItem(window);
                }

                transient_items.Add(item);
                item.WindowsChanged += HandleTransientWindowsChanged;
            }

            // remove old transient items
            List <WnckDockItem> removed_transient_items = new List <WnckDockItem> ();

            foreach (WnckDockItem wdi in transient_items.Where(adi => adi is WnckDockItem).Cast <WnckDockItem> ())
            {
                foreach (Wnck.Window window in ManagedWindows)
                {
                    if (wdi.Windows.Contains(window))
                    {
                        removed_transient_items.Add(wdi);
                        continue;
                    }
                }
                if (!wdi.ManagedWindows.Any())
                {
                    removed_transient_items.Add(wdi);
                }
            }
            RemoveTransientItems(removed_transient_items);
        }