Ejemplo n.º 1
0
        // list all of the subdirs for a given directory
        public static IEnumerable <GLib.File> SubDirs(this GLib.File file, bool recurse)
        {
            if (!IO.Directory.Exists(file.Path))
            {
                return(Enumerable.Empty <GLib.File> ());
            }

            try {
                // ignore symlinks
                if ((IO.File.GetAttributes(file.Path) & IO.FileAttributes.ReparsePoint) != 0)
                {
                    return(Enumerable.Empty <GLib.File> ());
                }

                // get all dirs contained in this dir
                List <GLib.File> dirs = IO.Directory.GetDirectories(file.Path)
                                        .Select(d => GLib.FileFactory.NewForPath(d)).ToList();

                // if we are recursing, for each dir we found get its subdirs
                if (recurse)
                {
                    dirs.AddRange(dirs.SelectMany(d => d.SubDirs(true)));
                }

                return(dirs);
            } catch {
                return(Enumerable.Empty <GLib.File> ());
            }
        }
Ejemplo n.º 2
0
        public static IntPtr GFileQueryInfo(GLib.File file, string attributes, FileQueryInfoFlags flags, Cancellable cancellable)
        {
            return(NativeHelper <IntPtr> (() =>
            {
                IntPtr error;
                IntPtr info;
                if (attributes.StartsWith("filesystem::"))
                {
                    info = g_file_query_filesystem_info(file.Handle, attributes,
                                                        cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
                }
                else
                {
                    info = g_file_query_info(file.Handle, attributes, (int)flags,
                                             cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
                }

                if (error != IntPtr.Zero)
                {
                    throw new GException(error);
                }
                return info;
            }, IntPtr.Zero, GIO_NOT_FOUND,
                                          string.Format("Failed to query info for '{0}': ", file.Path) + "{0}"));
        }
Ejemplo n.º 3
0
        public void PlayStream(string url)
        {
            DockServices.System.RunOnThread(() => {
                try {
                    WebClient cl = new WebClient();
                    cl.Headers.Add("user-agent", DockServices.System.UserAgent);
                    if (DockServices.System.UseProxy)
                    {
                        cl.Proxy = DockServices.System.Proxy;
                    }
                    string tempPath = System.IO.Path.GetTempPath();
                    string filename = url.Split(new [] { '/' }).Last();
                    filename        = System.IO.Path.Combine(tempPath, filename);

                    GLib.File file = FileFactory.NewForPath(filename);
                    if (file.Exists)
                    {
                        file.Delete();
                    }

                    cl.DownloadFile(url, file.Path);
                    DockServices.System.Open(file);
                } catch (Exception e) {
                    Docky.Services.Log <Station> .Error("Failed to play streaming url ({0}) : {1}", url, e.Message);
                    Docky.Services.Log <Station> .Debug(e.StackTrace);
                    // also notify the user that we couldn't play this stream for some reason.
                    Docky.Services.Log.Notify(Name, Icon, "The streaming link failed to play.  " +
                                              "This is most likely a problem with the NPR station.");
                }
            });
        }
Ejemplo n.º 4
0
        protected virtual void OnInstallThemeClicked(object sender, System.EventArgs e)
        {
            GLib.File             file           = null;
            Gtk.FileChooserDialog script_chooser = new Gtk.FileChooserDialog("Themes", this, FileChooserAction.Open, Gtk.Stock.Cancel, ResponseType.Cancel, Catalog.GetString("_Select"), ResponseType.Ok);
            FileFilter            filter         = new FileFilter();

            filter.AddPattern("*.tar");
            filter.Name = Catalog.GetString(".tar Archives");
            script_chooser.AddFilter(filter);

            if ((ResponseType)script_chooser.Run() == ResponseType.Ok)
            {
                file = GLib.FileFactory.NewForPath(script_chooser.Filename);
            }

            script_chooser.Destroy();

            if (file == null)
            {
                return;
            }

            string theme = DockServices.Theme.InstallTheme(file);

            if (theme != null)
            {
                theme_combo.AppendText(theme);
            }
        }
Ejemplo n.º 5
0
        public RemoteFileMenuEntry(GLib.File file, string groupTitle) : base(file.Basename, "", groupTitle)
        {
            Clicked += delegate {
                DockServices.System.Open(file);
            };

            // only check the icon if it's mounted (ie: .Path != null)
            if (!string.IsNullOrEmpty(file.Path))
            {
                string thumbnailPath = file.QueryInfo <string> ("thumbnail::path");
                if (!string.IsNullOrEmpty(thumbnailPath))
                {
                    Icon = thumbnailPath;
                }
                else
                {
                    Icon = file.Icon();
                }
            }

            if (string.IsNullOrEmpty(Icon))
            {
                Icon = "gtk-file";
            }
        }
        private void Delete(string directory, GLib.File dir, bool recursive)
        {
            if (!dir.Exists)
            {
                return;
            }

            if (dir.QueryFileType(FileQueryInfoFlags.NofollowSymlinks, null) != FileType.Directory)
            {
                return;
            }

            // If native, use the System.IO recursive delete
            if (dir.IsNative && !DisableNativeOptimizations)
            {
                System.IO.Directory.Delete(directory, recursive);
                return;
            }

            if (recursive)
            {
                foreach (string child in GetFiles(dir, false))
                {
                    FileFactory.NewForUri(child).Delete();
                }

                foreach (string child in GetDirectories(dir, false))
                {
                    Delete(child, GetDir(child, true), true);
                }
            }

            dir.Delete();
        }
Ejemplo n.º 7
0
        // This is the recursive equivalent of GLib.File.Copy ()
        /// <summary>
        /// Recursive equivalent to GLib.File.Copy () when called on a directory.
        /// Functionally equivalent to GLib.File.Copy () when called on files.
        /// </summary>
        /// <param name="source">
        /// A <see cref="GLib.File"/>
        /// </param>
        /// <param name="dest">
        /// A <see cref="GLib.File"/>
        /// </param>
        /// <param name="flags">
        /// A <see cref="FileCopyFlags"/>
        /// </param>
        /// <param name="progress_cb">
        /// A <see cref="FileProgressCallback"/>
        /// </param>
        public static void Copy_Recurse(this GLib.File source, GLib.File dest, FileCopyFlags flags, FileProgressCallback progress_cb)
        {
            long totalBytes  = source.GetSize();
            long copiedBytes = 0;

            Recursive_Copy(source, dest, flags, ref copiedBytes, totalBytes, progress_cb);
        }
Ejemplo n.º 8
0
        Pixbuf IconFromFile(string name, int width, int height)
        {
            Pixbuf pixbuf;

            string home = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            name = name.Replace("~", home);
            GLib.File iconFile = (name.StartsWith("/")) ? FileFactory.NewForPath(name) : FileFactory.NewForUri(name);
            try {
                if (width <= 0 || height <= 0)
                {
                    pixbuf = new Pixbuf(iconFile.Path);
                }
                else
                {
                    pixbuf = new Pixbuf(iconFile.Path, width, height, true);
                }
            } catch (Exception e) {
                Log <DrawingService> .Warn("Error loading icon from file '" + iconFile.Path + "': " + e.Message);

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

                pixbuf = null;
            }
            return(pixbuf);
        }
Ejemplo n.º 9
0
        public static ApplicationDockItem NewFromUri(string uri)
        {
            try {
                GLib.File file = FileFactory.NewForUri(uri);
                if (!file.Exists)
                {
                    return(null);
                }

                DesktopItem desktopItem = DockServices.DesktopItems.DesktopItemFromDesktopFile(file.Path);

                if (desktopItem == null)
                {
                    desktopItem = new DesktopItem(file.Path);
                }

                return(new ApplicationDockItem(desktopItem));
            } catch (Exception e) {
                Log <ApplicationDockItem> .Error(e.Message);

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

            return(null);
        }
Ejemplo n.º 10
0
        public static bool CopyRecursive(this GLib.File source, GLib.File target, GLib.FileCopyFlags flags, GLib.Cancellable cancellable, GLib.FileProgressCallback callback)
        {
            bool result = true;

            GLib.FileType ft = source.QueryFileType(GLib.FileQueryInfoFlags.None, cancellable);

            if (ft != GLib.FileType.Directory)
            {
                Hyena.Log.DebugFormat("Copying \"{0}\" to \"{1}\"", source.Path, target.Path);
                return(source.Copy(target, flags, cancellable, callback));
            }

            if (!target.Exists)
            {
                Hyena.Log.DebugFormat("Creating directory: \"{0}\"", target.Path);
                result = result && target.MakeDirectoryWithParents(cancellable);
            }

            GLib.FileEnumerator fe = source.EnumerateChildren("standard::name", GLib.FileQueryInfoFlags.None, cancellable);
            GLib.FileInfo       fi = fe.NextFile();
            while (fi != null)
            {
                GLib.File source_file = GLib.FileFactory.NewForPath(Path.Combine(source.Path, fi.Name));
                GLib.File target_file = GLib.FileFactory.NewForPath(Path.Combine(target.Path, fi.Name));
                result = result && source_file.CopyRecursive(target_file, flags, cancellable, callback);
                fi     = fe.NextFile();
            }
            fe.Close(cancellable);
            fe.Dispose();
            return(result);
        }
Ejemplo n.º 11
0
        public static Gnome.Vfs.Uri UniqueName(Gnome.Vfs.Uri path, string shortname)
#endif
        {
            int i = 1;

#if GIO_2_16
            GLib.File dest = FileFactory.NewForUri(new System.Uri(path, shortname));
#else
            Gnome.Vfs.Uri target = path.Clone();
            Gnome.Vfs.Uri dest   = target.AppendFileName(shortname);
#endif
            while (dest.Exists)
            {
                string numbered_name = System.String.Format("{0}-{1}{2}",
                                                            System.IO.Path.GetFileNameWithoutExtension(shortname),
                                                            i++,
                                                            System.IO.Path.GetExtension(shortname));

#if GIO_2_16
                dest = FileFactory.NewForUri(new System.Uri(path, numbered_name));
#else
                dest = target.AppendFileName(numbered_name);
#endif
            }

            return(dest);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Removes an action from the mount actions list for this file.
 /// </summary>
 /// <param name="file">
 /// A <see cref="GLib.File"/>
 /// </param>
 /// <param name="action">
 /// A <see cref="Action"/>
 /// </param>
 public static void RemoveAction(this GLib.File file, Action action)
 {
     if (MountActions.ContainsKey(file) && MountActions [file].Contains(action))
     {
         MountActions [file].Remove(action);
     }
 }
Ejemplo n.º 13
0
        static void Recursive_Copy(GLib.File source, GLib.File dest, FileCopyFlags flags, ref long copiedBytes, long totalBytes, FileProgressCallback progress_cb)
        {
            if (IO.File.Exists(source.Path))
            {
                source.Copy(dest, flags, null, (current, total) => {
                    progress_cb.Invoke(current, totalBytes);
                });
                return;
            }

            foreach (GLib.File subdir in source.SubDirs())
            {
                dest.GetChild(subdir.Basename).MakeDirectoryWithParents(null);
                // if it's a directory, continue the recursion
                Recursive_Copy(subdir, dest.GetChild(subdir.Basename), flags, ref copiedBytes, totalBytes, progress_cb);
            }

            foreach (File child in source.GetFiles())
            {
                long copied = copiedBytes;

                child.Copy(dest.GetChild(child.Basename), flags, null, (current, total) => {
                    progress_cb.Invoke(copied + current, totalBytes);
                });
                copiedBytes += child.GetSize();
            }
        }
Ejemplo n.º 14
0
        public static string NewFileName(this GLib.File fileToMove, File dest)
        {
            string name, ext;

            if (fileToMove.Basename.Split('.').Count() > 1)
            {
                name = fileToMove.Basename.Split('.').First();
                ext  = fileToMove.Basename.Substring(fileToMove.Basename.IndexOf('.'));
            }
            else
            {
                name = fileToMove.Basename;
                ext  = "";
            }
            if (dest.GetChild(fileToMove.Basename).Exists)
            {
                int i = 1;
                while (dest.GetChild(string.Format("{0} ({1}){2}", name, i, ext)).Exists)
                {
                    i++;
                }
                return(string.Format("{0} ({1}){2}", name, i, ext));
            }
            else
            {
                return(fileToMove.Basename);
            }
        }
Ejemplo n.º 15
0
        public void Transfer()
        {
            try {
                bool result = true;

                if (clean)
                {
                    Clean(dest);
                }

                foreach (IPhoto photo in selection.Items)
                {
                    //FIXME need to implement the uniquename as a filter
                    using (FilterRequest request = new FilterRequest(photo.DefaultVersion.Uri)) {
                        GLib.File            source = FileFactory.NewForUri(request.Current.ToString());
                        GLib.File            target = UniqueName(dest, photo.Name);
                        FileProgressCallback cb     = Progress;

                        progress_dialog.Message      = string.Format(Catalog.GetString("Transferring picture \"{0}\" To CD"), photo.Name);
                        progress_dialog.Fraction     = photo_index / (double)selection.Count;
                        progress_dialog.ProgressText = string.Format(Catalog.GetString("{0} of {1}"),
                                                                     photo_index, selection.Count);

                        result &= source.Copy(target,
                                              FileCopyFlags.None,
                                              null,
                                              cb);
                    }
                    photo_index++;
                }

                // FIXME the error dialog here is ugly and needs improvement when strings are not frozen.
                if (result)
                {
                    progress_dialog.Message      = Catalog.GetString("Done Sending Photos");
                    progress_dialog.Fraction     = 1.0;
                    progress_dialog.ProgressText = Catalog.GetString("Transfer Complete");
                    progress_dialog.ButtonLabel  = Gtk.Stock.Ok;
                    progress_dialog.Hide();
                    burner.Run();
                }
                else
                {
                    throw new Exception(string.Format("{0}{3}{1}{3}{2}",
                                                      progress_dialog.Message,
                                                      Catalog.GetString("Error While Transferring"),
                                                      result.ToString(),
                                                      Environment.NewLine));
                }
            } catch (Exception e) {
                Hyena.Log.DebugException(e);
                progress_dialog.Message      = e.ToString();
                progress_dialog.ProgressText = Catalog.GetString("Error Transferring");
                return;
            }
            ThreadAssist.ProxyToMain(() => {
                progress_dialog.Destroy();
            });
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Add an action that gets invoked when a file gets mounted.
 /// </summary>
 /// <param name="file">
 /// A <see cref="GLib.File"/>
 /// </param>
 /// <param name="action">
 /// A <see cref="Action"/>
 /// </param>
 public static void AddMountAction(this GLib.File file, Action action)
 {
     if (!MountActions.ContainsKey(file))
     {
         MountActions[file] = new List <Action> ();
     }
     MountActions [file].Add(action);
 }
Ejemplo n.º 17
0
        static long Size(this GLib.File file)
        {
            IntPtr info = NativeInterop.GFileQueryInfo(file, "standard::size", FileQueryInfoFlags.None, null);
            long   size = NativeInterop.GFileInfoSize(info);

            NativeInterop.GObjectUnref(info);
            return(size);
        }
Ejemplo n.º 18
0
 bool IsDestEmpty(System.Uri path)
 {
     GLib.File f = FileFactory.NewForUri(path);
     foreach (GLib.FileInfo info in f.EnumerateChildren("*", FileQueryInfoFlags.None, null))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 19
0
        public DemuxVfs(string path)
        {
            file = path.StartsWith("/") ? FileFactory.NewForPath(path) : FileFactory.NewForUri(path);

            if (file.Exists)
            {
                file_info = file.QueryInfo("etag::value,access::can-read,access::can-write", FileQueryInfoFlags.None, null);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Indicates whether or not a directory has files.
        /// </summary>
        /// <remarks>
        /// Will return false if called on a file.
        /// </remarks>
        /// <param name="file">
        /// A <see cref="GLib.File"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        public static bool DirectoryHasFiles(this GLib.File file)
        {
            IO.DirectoryInfo dir = new IO.DirectoryInfo(file.Path);

            if (dir.GetFiles().Count() > 0 || dir.GetDirectories().Count() > 0)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 21
0
 public DirectoryLoader(UriCollection collection, SafeUri uri)
 {
     this.collection = collection;
     file            = FileFactory.NewForUri(uri);
     file.EnumerateChildrenAsync("standard::*",
                                 FileQueryInfoFlags.None,
                                 500,
                                 null,
                                 InfoLoaded);
 }
Ejemplo n.º 22
0
        public static string Icon(this GLib.File file)
        {
            IntPtr info = NativeInterop.GFileQueryInfo(file, "standard::icon", FileQueryInfoFlags.None, null);

            GLib.Icon icon     = NativeInterop.GFileInfoIcon(info);
            string    iconName = DockServices.Drawing.IconFromGIcon(icon);

            NativeInterop.GObjectUnref(info);
            return(iconName);
        }
Ejemplo n.º 23
0
 public DemuxVfs (string path)
 {
     file = path.StartsWith ("/") ? FileFactory.NewForPath (path) : FileFactory.NewForUri (path);
     if (file.Exists) {
         using (var info = file.QueryInfo ("etag::value,access::can-read,access::can-write", FileQueryInfoFlags.None, null)) {
             IsReadable = info.GetAttributeBoolean ("access::can-read");
             IsWritable = info.GetAttributeBoolean ("access::can-write");
         }
     }
 }
Ejemplo n.º 24
0
 private IEnumerable <string> GetDirectories(GLib.File dir, bool followSymlinks)
 {
     foreach (FileInfo file in dir.EnumerateChildren("standard::type,standard::name", followSymlinks ? FileQueryInfoFlags.None : FileQueryInfoFlags.NofollowSymlinks, null))
     {
         if ((file.FileType & FileType.Directory) != 0)
         {
             yield return(System.IO.Path.Combine(dir.Uri.AbsoluteUri, file.Name));
         }
     }
 }
        void MonitorDesktopFileDirs(GLib.File dir)
        {
            // build a list of all the subdirectories
            List <GLib.File> dirs = new List <GLib.File> ()
            {
                dir
            };

            try {
                dirs = dirs.Union(dir.SubDirs()).ToList();
            } catch {}

            foreach (GLib.File d in dirs)
            {
                GLib.FileMonitor mon = d.Monitor(GLib.FileMonitorFlags.None, null);
                mon.RateLimit = 2500;
                mon.Changed  += delegate(object o, GLib.ChangedArgs args) {
                    // bug in GIO#, calling args.File or args.OtherFile crashes hard
                    GLib.File file      = GLib.FileAdapter.GetObject((GLib.Object)args.Args [0]);
                    GLib.File otherFile = GLib.FileAdapter.GetObject((GLib.Object)args.Args [1]);

                    // according to GLib documentation, the change signal runs on the same
                    // thread that the monitor was created on.  Without running this part on a thread
                    // docky freezes up for about 500-800 ms while the .desktop files are parsed.
                    DockServices.System.RunOnThread(() => {
                        // if a new directory was created, make sure we watch that dir as well
                        if (file.QueryFileType(GLib.FileQueryInfoFlags.NofollowSymlinks, null) == GLib.FileType.Directory)
                        {
                            MonitorDesktopFileDirs(file);
                        }

                        // we only care about .desktop files
                        if (!file.Path.EndsWith(".desktop"))
                        {
                            return;
                        }

                        lock (update_lock) {
                            UpdateDesktopItemsList();
                            DesktopItemsChanged();
                            SaveDesktopItemsCache();
                        }

                        // Make sure to trigger event on main thread
                        DockServices.System.RunOnMainThread(() => {
                            if (DesktopFileChanged != null)
                            {
                                DesktopFileChanged(this, new DesktopFileChangedEventArgs(args.EventType, file, otherFile));
                            }
                        });
                    });
                };
            }
        }
 public DemuxVfs(string path)
 {
     file = path.StartsWith("/") ? FileFactory.NewForPath(path) : FileFactory.NewForUri(path);
     if (file.Exists)
     {
         using (var info = file.QueryInfo("etag::value,access::can-read,access::can-write", FileQueryInfoFlags.None, null)) {
             IsReadable = info.GetAttributeBoolean("access::can-read");
             IsWritable = info.GetAttributeBoolean("access::can-write");
         }
     }
 }
Ejemplo n.º 27
0
 void Clean(System.Uri path)
 {
     GLib.File source = FileFactory.NewForUri(path);
     foreach (GLib.FileInfo info in source.EnumerateChildren("*", FileQueryInfoFlags.None, null))
     {
         if (info.FileType == FileType.Directory)
         {
             Clean(new System.Uri(path, info.Name + "/"));
         }
         FileFactory.NewForUri(new System.Uri(path, info.Name)).Delete();
     }
 }
Ejemplo n.º 28
0
 void ListAll(Gtk.TextBuffer t, System.Uri path)
 {
     GLib.File f = FileFactory.NewForUri(path);
     foreach (GLib.FileInfo info in f.EnumerateChildren("*", FileQueryInfoFlags.None, null))
     {
         t.Text += new System.Uri(path, info.Name).ToString() + Environment.NewLine;
         if (info.FileType == FileType.Directory)
         {
             ListAll(t, new System.Uri(path, info.Name + "/"));
         }
     }
 }
        void LoadRemaps(GLib.File file)
        {
            if (file.Exists)
            {
                Log <DesktopItemService> .Debug("Loading remap file '{0}'.", file.Path);
            }
            else
            {
                Log <DesktopItemService> .Warn("Could not find remap file '{0}'!", file.Path);

                return;
            }

            Regex keyValueRegex = new Regex(
                @"(^(\s)*(?<Key>([^\=^\n]+))[\s^\n]*\=(\s)*(?<Value>([^\n]+(\n){0,1})))",
                RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled | RegexOptions.CultureInvariant
                );

            try {
                using (StreamReader reader = new StreamReader(file.Path)) {
                    string line;

                    while ((line = reader.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.Length <= 0 || line.Substring(0, 1) == "#")
                        {
                            continue;
                        }

                        Match match = keyValueRegex.Match(line);
                        if (match.Success)
                        {
                            string key = match.Groups ["Key"].Value;
                            string val = match.Groups ["Value"].Value;
                            if (!string.IsNullOrEmpty(key))
                            {
                                Remaps [key] = val;
                                Log <DesktopItemService> .Debug("Remapping '{0}' to '{1}'.", key, val);
                            }
                        }
                    }
                    reader.Close();
                }
            } catch (Exception e) {
                Log <DesktopItemService> .Error("Error loading remap file: {0}", e.Message);

                Log <DesktopItemService> .Error(e.StackTrace);
            }
        }
Ejemplo n.º 30
0
    static void Main()
    {
        Gtk.Application.Init ();
        file = FileFactory.NewForUri (new Uri ("smb://[email protected]/myshare/test"));

        Window w = new Window ("test");
        operation = new Gtk.MountOperation (w);
        Button b = new Button ("Mount");
        b.Clicked += new EventHandler (HandleButtonClicked);
        b.Show ();
        w.Add (b);
        w.Show ();
        Gtk.Application.Run ();
    }
Ejemplo n.º 31
0
        // gets all files under the given GLib.File (directory) with the extension of extension
        public static IEnumerable <GLib.File> GetFiles(this GLib.File file, string extension)
        {
            if (!IO.Directory.Exists(file.Path))
            {
                return(Enumerable.Empty <GLib.File> ());
            }

            try {
                return(IO.Directory.GetFiles(file.Path, string.Format("*{0}", extension))
                       .Select(f => GLib.FileFactory.NewForPath(f)));
            } catch {
                return(Enumerable.Empty <GLib.File> ());
            }
        }
Ejemplo n.º 32
0
        private SystemManager()
        {
            try {
                SystemBus = Bus.System.GetObject <IBus> ("org.freedesktop.DBus", new ObjectPath("/org/freedesktop/DBus"));

                SystemBus.NameOwnerChanged += delegate(string name, string old_owner, string new_owner) {
                    if (name != UPowerName && name != DeviceKitPowerName && name != SystemdName && name != ConsoleKitName)
                    {
                        return;
                    }

                    Log <SystemManager> .Debug("DBus services changed, reconnecting now");

                    if (upower != null)
                    {
                        upower = null;
                    }

                    if (devicekit != null)
                    {
                        devicekit = null;
                    }

                    if (systemd != null)
                    {
                        systemd = null;
                    }

                    if (consolekit != null)
                    {
                        consolekit = null;
                    }

                    Initialize();
                    HandlePowerBusChanged();
                    HandleCapabilitiesChanged();
                };

                Initialize();

                // Set up file monitor to watch for reboot_required file
                GLib.File reboot_required_file = FileFactory.NewForPath("/var/run/reboot-required");
                reboot_required_monitor           = reboot_required_file.Monitor(FileMonitorFlags.None, null);
                reboot_required_monitor.RateLimit = 10000;
                reboot_required_monitor.Changed  += HandleRebootRequired;
            } catch (Exception e) {
                Log <SessionManagerItem> .Error(e.Message);
            }
        }
Ejemplo n.º 33
0
 public DirectoryLoader(UriCollection collection, System.Uri uri)
 {
     this.collection = collection;
     this.uri = uri;
     file = FileFactory.NewForUri (uri);
     file.EnumerateChildrenAsync ("standard::*",
                      FileQueryInfoFlags.None,
                      500,
                      null,
                      InfoLoaded);
 }