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
        void PixbufDataFunc(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
        {
            var renderer = cell as CellRendererPixbuf;

            string stock;
            var    uri = folder_tree_model.GetUriByIter(iter);

            if (uri == null)
            {
                return;
            }
            File file = FileFactory.NewForUri(uri);

            try {
                FileInfo info =
                    file.QueryInfo("standard::icon", FileQueryInfoFlags.None, null);

                ThemedIcon themed_icon = info.Icon as ThemedIcon;
                if (themed_icon != null && themed_icon.Names.Length > 0)
                {
                    stock = themed_icon.Names[0];
                }
                else
                {
                    stock = "gtk-directory";
                }
            } catch (Exception) {
                stock = "gtk-directory";
            }

            TreeIter tmp;

            if (tree_model.IterParent(out tmp, iter))
            {
                renderer.IconName       = stock;
                renderer.CellBackground = null;
            }
            else
            {
                renderer.IconName          = stock;
                renderer.CellBackgroundGdk = Style.Background(StateType.Selected);
            }
        }
Esempio n. 3
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);
        }