Ejemplo n.º 1
0
        public static Gdk.Pixbuf GetIcon(string name, int size)
        {
            IconTheme icon_theme = new IconTheme ();

            //          foreach (string search_path in IconTheme.Default.SearchPath)
            //              icon_theme.AppendSearchPath (search_path);

            // FIXME: Temporary workaround for a bug in IconTheme.SearchPath in Gtk# on 64-bit systems
            // https://github.com/mono/gtk-sharp/commit/9c54fd5ae77f63d11fdc6873a3cb90691990e37f
            icon_theme.AppendSearchPath ("/usr/share/icons");
            icon_theme.AppendSearchPath ("/usr/local/share/icons");
            icon_theme.AppendSearchPath ("/opt/local/share/icons");
            icon_theme.AppendSearchPath (Path.Combine (SparkleUI.AssetsPath, "icons"));

            try {
                return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);

            } catch {
                try {
                    return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);

                } catch {
                    return null;
                }
            }
        }
Ejemplo n.º 2
0
 public ThemedIconList()
 {
     Gtk.IconTheme theme = Gtk.IconTheme.Default;
     foreach (string icon in ThemeIconNames)
     {
         AddIcon(icon, GetPixbuf(theme, icon), icon);
     }
 }
Ejemplo n.º 3
0
 Gdk.Pixbuf GetPixbuf(Gtk.IconTheme theme, string name)
 {
     try {
         return(theme.LoadIcon(name, 16, 0));
     } catch {
         return(RenderIcon(name, Gtk.IconSize.Menu, null));
     }
 }
Ejemplo n.º 4
0
 static void Changed_cb(IntPtr inst)
 {
     try {
         IconTheme __obj = GLib.Object.GetObject(inst, false) as IconTheme;
         __obj.OnChanged();
     } catch (Exception e) {
         GLib.ExceptionManager.RaiseUnhandledException(e, false);
     }
 }
Ejemplo n.º 5
0
		protected override void OnRealized ()
		{
			base.OnRealized ();

			theme = Gtk.IconTheme.GetForScreen (Screen);
			theme.Changed += ThemeChanged;

			LoadImages ();
		}
Ejemplo n.º 6
0
        public BansheeIconFactory()
        {
            theme = IconTheme.Default;

            string icon_theme_path = Hyena.Paths.GetInstalledDataDirectory ("icons");
            if (Directory.Exists (icon_theme_path)) {
                Hyena.Log.DebugFormat ("Adding icon theme search path: {0}", icon_theme_path);
                Theme.AppendSearchPath (icon_theme_path);
            }

            AddDefault ();
        }
Ejemplo n.º 7
0
        public static Gdk.Pixbuf GetIcon(string name, int size) {
            IconTheme icon_theme = new IconTheme();
            icon_theme.AppendSearchPath(Path.Combine(UI.AssetsPath, "icons"));

            try {
                return icon_theme.LoadIcon(name, size, IconLookupFlags.GenericFallback);
            } catch {
                try {
                    return icon_theme.LoadIcon("gtk-image-missing", size, IconLookupFlags.GenericFallback);
                } catch {
                    return null;
                }
            }
        }
Ejemplo n.º 8
0
        // Looks up an icon from the system's theme
        public static Gdk.Pixbuf GetIcon(string name, int size)
        {
            IconTheme icon_theme = new IconTheme ();
            icon_theme.AppendSearchPath (SparklePaths.SparkleIconPath);
            icon_theme.AppendSearchPath (SparklePaths.SparkleLocalIconPath);

            try {
                return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);
            } catch {
                try {
                    return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);
                } catch {
                    return null;
                }
            }
        }
Ejemplo n.º 9
0
        public static Gdk.Pixbuf GetIcon(string name, int size)
        {
            IconTheme icon_theme = new IconTheme ();
            icon_theme.AppendSearchPath (Path.Combine (UserInterface.AssetsPath, "icons"));

            foreach (string search_path in IconTheme.Default.SearchPath)
               icon_theme.AppendSearchPath (search_path);

            try {
                return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);

            } catch {
                try {
                    return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);

                } catch {
                    return null;
                }
            }
        }
Ejemplo n.º 10
0
        // Looks up an icon from the system's theme
        public static Gdk.Pixbuf GetIcon(string name, int size)
        {
            IconTheme icon_theme = new IconTheme ();

            icon_theme.AppendSearchPath (Path.Combine (SparkleUI.AssetsPath, "icons"));

            icon_theme.AppendSearchPath (
                Path.Combine (Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath), "icons"));

            try {
                return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);

            } catch {
                try {
                    return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);

                } catch {
                    return null;
                }
            }
        }
Ejemplo n.º 11
0
        public Pixbuf GetIcon(string mimeType, Gtk.IconSize size)
        {
            if (mimeType == null)
            {
                throw new ArgumentNullException("mimeType");
            }

            if (mimeType.Length == 0)
            {
                throw new ArgumentException("Argument is emtpy", "mimeType");
            }

            Pixbuf pb;
            string iconKey = mimeType + (int)size;

            if (mimeIconCache.TryGetValue(iconKey, out pb))
            {
                return(pb);
            }

            if (useCustomMimeIcons)
            {
                // render icons which are available in the custom theme
                Icon icon;
                if (customMimeMapping.TryGetIconForMimeType(mimeType, out icon))
                {
                    pb = icon.Render(widget, size);
                }
                else
                {
                    pb = defaultIcon.Render(widget, size);
                }
            }
            else
            {
                // render system mime icons dynamically
                Gtk.IconTheme iconTheme = Gtk.IconTheme.Default;
                string        iconName  = null;

                foreach (string name in ((GLib.ThemedIcon)GLib.Content.TypeGetIcon(mimeType)).Names)
                {
                    if (iconTheme.HasIcon(name))
                    {
                        iconName = name;
                        break;
                    }
                }

                if (!string.IsNullOrEmpty(iconName))
                {
                    pb = iconTheme.LoadIcon(iconName, IconUtils.GetIconSizeVal(size), 0);
                }
                else
                {
                    Icon fbIcon;
                    if (fallbackIcons.TryGetValue(mimeType, out fbIcon))
                    {
                        iconName = fbIcon.Name;
                        pb       = fbIcon.Render(widget, size);
                    }
                    else
                    {
                        pb       = defaultIcon.Render(widget, size);
                        iconName = defaultIcon.Name;
                    }
                }
            }

            if (pb != null)
            {
                mimeIconCache.Add(iconKey, pb);
            }

            return(pb);
        }
Ejemplo n.º 12
0
		Pixbuf IconFromTheme (string name, int size, IconTheme theme)
		{
			Pixbuf pixbuf = null;
			string name_noext = name;
			
			// We may have to remove the extension.
			if (name.Contains ("."))
				name_noext = name.Remove (name.LastIndexOf ("."));
			
			try {
				if (theme.HasIcon (name))
					pixbuf = theme.LoadIcon (name, size, 0);
				else if (theme.HasIcon (name_noext))
					pixbuf = theme.LoadIcon (name_noext, size, 0);
				else if (name == "gnome-mime-text-plain" && theme.HasIcon ("gnome-mime-text"))
					pixbuf = theme.LoadIcon ("gnome-mime-text", size, 0);
			} catch (Exception e) {
				Log<DrawingService>.Warn ("Error loading themed icon '" + name + "': " + e.Message);
				Log<DrawingService>.Debug (e.StackTrace);
				pixbuf = null;
			}
		
			return pixbuf;
		}
Ejemplo n.º 13
0
 // Looks up an icon from the system's theme
 public Gdk.Pixbuf GetIcon(string name, int size)
 {
     IconTheme icon_theme = new IconTheme ();
     icon_theme.AppendSearchPath (System.IO.Path.Combine ("/usr/share/sparkleshare", "icons"));
     return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);
 }
Ejemplo n.º 14
0
        public ItemView()
        {
            // set up the liststore for the view
            store = new ListStore(typeof(Gdk.Pixbuf), typeof(bool), typeof(bool), typeof(string), typeof(string), typeof(string), typeof(int));
            Model = store;

            // set up the columns for the view
            InsertColumn(-1, "Read", new CellRendererPixbuf(), "pixbuf", 0);
            CellRendererText trender = new CellRendererText();

            column_Date = new TreeViewColumn("Date", trender, "text", 3);
            column_Date.AddAttribute(trender, "weight", 6);
            column_Date.SortColumnId = 3;
            column_Date.SortIndicator = true;
            AppendColumn(column_Date);
            column_Title = new TreeViewColumn("Title", trender, "text", 4);
            column_Title.AddAttribute(trender, "weight", 6);
            AppendColumn(column_Title);

            RulesHint = true;
            HeadersClickable = true;
            store.SetSortColumnId(3, SortType.Descending);

            // set up the icon theme so that we can make stuff pretty
            icon_theme = IconTheme.Default;
        }