Esempio n. 1
0
        private static Platform.Common.IO.DriveType GuessDriveType(string uriScheme, GLib.Icon icon, Drive dr)
        {
            switch (uriScheme)
            {
            case "ssh":
            case "smb":
            case "ftp":
                return(DriveType.Network);

            case "cdda":
                return(DriveType.CDRom);
            }

            ThemedIcon themedIcon = icon as ThemedIcon;

            if ((themedIcon != null) && (Array.FindIndex(themedIcon.Names, i => i.Contains("optical")) != -1))
            {
                return(DriveType.CDRom);
            }

            if (dr != null)
            {
                return(dr.IsMediaRemovable ? DriveType.Removable : DriveType.Fixed);
            }

            return(DriveType.Unknown);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
 public static Gtk.IconInfo IconThemeLookUpByGIcon(Gtk.IconTheme theme, GLib.Icon icon, int size, int flags)
 {
     return(NativeHelper <Gtk.IconInfo> (() =>
     {
         IntPtr raw_ret = gtk_icon_theme_lookup_by_gicon(theme.Handle,
                                                         icon == null ? IntPtr.Zero : ((icon is GLib.Object) ? (icon as GLib.Object).Handle : (icon as GLib.IconAdapter).Handle),
                                                         size, (int)flags);
         Gtk.IconInfo ret = raw_ret == IntPtr.Zero ? null : (Gtk.IconInfo)GLib.Opaque.GetOpaque(raw_ret, typeof(Gtk.IconInfo), true);
         return ret;
     }, null, GTK_NOT_FOUND,
                                         "Failed to lookup by GIcon: {0}"));
 }
Esempio n. 4
0
        /// <summary>
        /// Returns the string name of the supplied icon.
        /// </summary>
        /// <param name="icon">
        /// A <see cref="GLib.Icon"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/>
        /// </returns>
        public string IconFromGIcon(GLib.Icon icon)
        {
            string name = "";

            if (icon is ThemedIcon)
            {
                ThemedIcon themeIcon = new ThemedIcon(icon.Handle);
                // if the icon exists in the theme, this will return the relevent icon
                if (themeIcon.Names.Any())
                {
                    name = themeIcon.Names.FirstOrDefault(n => IconTheme.Default.HasIcon(n));
                }
                themeIcon.Dispose();
            }
            else if (icon is FileIcon)
            {
                // in some cases, devices provide their own icon.  This will use the device icon.
                FileIcon iconFile = new FileIcon(icon.Handle);
                name = iconFile.File.Path;
                iconFile.Dispose();
            }
            return(name);
        }