Esempio n. 1
0
        protected override void Enable()
        {
            ItemsAvailableEventArgs eventArgs = new ItemsAvailableEventArgs();

            lock (windowlist) {
                Screen.Default.ForceUpdate();
                foreach (Window win in Utils.GetWindows())
                {
                    Log.Debug("title is {0}, pid is {1}, processname is {2}", win.Name, win.Application.Pid, win.Application.Name);
                    String iconpath = String.Format("/tmp/{0}.png", win.Application.Pid);
                    win.Icon.Save(iconpath, "png");
                    WindowItem item = new WindowItem(win, iconpath);
                    windowlist [win] = item;
                }
                eventArgs.newItems = windowlist.Values;
            }

            RaiseItemsAvailable(eventArgs);
        }
Esempio n. 2
0
        private void OnItemsAvailable(object sender, ItemsAvailableEventArgs args)
        {
            DynamicItemSource source = sender as DynamicItemSource;

            if (source == null)
            {
                Log <UniverseManager> .Error("OnItemsAvailable called from a non-DynamicItemSource.");

                return;
            }
            lock (universe_lock) {
                foreach (Item item in args.newItems)
                {
                    try {
                        dynamicUniverses[source].Add(item.UniqueId, item);
                    } catch (ArgumentException) {
                        Log <UniverseManager> .Error("DynamicItemSource {0} attmpted to add duplicate Item {1}", source.Name, item.UniqueId);
                    }
                }
            }
        }
Esempio n. 3
0
        override protected void Enable()
        {
            ItemsAvailableEventArgs eventArgs = new ItemsAvailableEventArgs();

            lock (app_items) {
                foreach (var directory in desktop_file_directories.Where(dir => Directory.Exists(dir)))
                {
                    var monitor = new FileSystemWatcher(directory, "*.desktop");
                    monitor.Created            += OnFileCreated;
                    monitor.Deleted            += OnFileDeleted;
                    monitor.Renamed            += OnFileRenamed;
                    monitor.Error              += OnWatcherError;
                    monitor.EnableRaisingEvents = true;
                    directoryMonitors.Add(monitor);
                    Log <ApplicationItemSource> .Debug("Watching directory {0} for application changes.", directory);
                }
                foreach (var fileItemPair in desktop_file_directories.SelectMany(dir => LoadDesktopFiles(dir)))
                {
                    var previousMatch = app_items.FirstOrDefault(pair => pair.Value == fileItemPair.Value);
                    if (previousMatch.Key == null && previousMatch.Value == null)
                    {
                        app_items.Add(fileItemPair.Key, fileItemPair.Value);
                    }
                    else if (fileItemPair.Key != previousMatch.Key)
                    {
                        Log.Debug("Desktop file {0} hides previous file {1}", fileItemPair.Key, previousMatch.Key);
                        app_items.Remove(previousMatch.Key);
                        app_items.Add(fileItemPair.Key, fileItemPair.Value);
                    }
                }
                eventArgs.newItems = app_items.Values.Cast <Item> ().ToList();

                categories         = app_items.SelectMany(pair => LoadCategoryItems(pair.Value)).Distinct().ToList();
                eventArgs.newItems = eventArgs.newItems.Concat(categories.ToArray());
            }
            RaiseItemsAvailable(eventArgs);
        }
		protected override void Enable ()
		{
			ItemsAvailableEventArgs eventArgs = new ItemsAvailableEventArgs ();

			lock(remminaItemList) {
				String remminaconfdir = Path.Combine (Environment.GetEnvironmentVariable ("HOME"), ".remmina");
				FileSystemWatcher watcher = new FileSystemWatcher (remminaconfdir, "*.*");
				watcher.Renamed += new RenamedEventHandler (FileCreated);
				watcher.Deleted += new FileSystemEventHandler (FileDeleted);
				watcher.EnableRaisingEvents = true;
				IEnumerable<String> allfiles = Directory.GetFiles (remminaconfdir).Where (file => file.EndsWith (".remmina"));
				foreach (String remminaprefpath in allfiles) {
					Console.WriteLine (remminaprefpath);
					String itemname = ParseRemminaItem (remminaprefpath);
					if (itemname == null)
						return;
					remminaItemList [itemname] = new RemminaItem(itemname, remminaprefpath);

				}
				eventArgs.newItems = remminaItemList.Values;
			}

			RaiseItemsAvailable (eventArgs);
		}