コード例 #1
0
ファイル: Stetic.cs プロジェクト: chubbyerror/Gibbo2D
 public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size)
 {
     Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
     if ((res != null))
     {
         return(res);
     }
     else
     {
         int sz;
         int sy;
         global::Gtk.Icon.SizeLookup(size, out sz, out sy);
         try {
             return(Gtk.IconTheme.Default.LoadIcon(name, sz, 0));
         } catch (System.Exception) {
             if ((name != "gtk-missing-image"))
             {
                 return(Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size));
             }
             else
             {
                 #if GTK2
                 Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
                 Gdk.GC     gc   = new Gdk.GC(pmap);
                 gc.RgbFgColor = new Gdk.Color(255, 255, 255);
                 pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
                 gc.RgbFgColor = new Gdk.Color(0, 0, 0);
                 pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1));
                 gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
                 gc.RgbFgColor = new Gdk.Color(255, 0, 0);
                 pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
                 pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
                 return(Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz));
                 #elif GTK3
                 throw new System.NotImplementedException();
                 #endif
             }
         }
     }
 }
コード例 #2
0
        public static Gdk.Pixbuf LoadIcon(string name, Gtk.IconSize size)
        {
            if (renderer == null)
            {
                renderer = new Gtk.HBox();
            }
            Gdk.Pixbuf image = renderer.RenderIcon(name, size, null);
            if (image != null)
            {
                return(image);
            }

            int w, h;

            Gtk.Icon.SizeLookup(size, out w, out h);
            try {
                return(Gtk.IconTheme.Default.LoadIcon(name, w, 0));
            } catch {
                // Icon not in theme
                return(MissingIcon);
            }
        }