public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz)
 {
     Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
     if ((res != null))
     {
         return(res);
     }
     else
     {
         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, sz));
             }
             else
             {
                 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));
             }
         }
     }
 }
 private void ShowStatusImage(string icon, Pixbuf buf)
 {
     if (buf == null)
     {
         Gtk.Widget widget = (Gtk.Widget) this;
         buf = widget.RenderIcon(icon, Gtk.IconSize.LargeToolbar, null);
     }
     //if(statusImage.Pixbuf != buf)
     statusImage.Pixbuf = buf;
 }
Beispiel #3
0
 /// <summary>
 /// Loads the stock icon for a given name and size.
 /// </summary>
 /// <returns>The stock icon.</returns>
 /// <param name="widget">Widget to get the icon for. Themes can modify the stock icon for a specific widget.</param>
 /// <param name="name">Name.</param>
 /// <param name="size">Size as Gtk.IconSize.</param>
 public static Gdk.Pixbuf LoadStockIcon(Gtk.Widget widget, string name, Gtk.IconSize size)
 {
     Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
     if ((res != null))
     {
         return(res);
     }
     else
     {
         return(LoadMissingIcon(size));
     }
 }
        public void RenderDoc(Cairo.Context CairoContext, Gtk.Widget widget, int height)
        {
            Pixbuf icon = widget.RenderIcon(_IconName, _IconsSize, "");

            Pango.Layout Layout = Pango.CairoHelper.CreateLayout(CairoContext);
            Layout.FontDescription = _font;
            Layout.SetMarkup(_Text);

            int layout_x = icon.Width + 5;
            int layoutWidth, layoutHeight;

            Layout.GetPixelSize(out layoutWidth, out layoutHeight);

            int layout_y = (height - layoutHeight) / 2;

            CairoContext.MoveTo((double)layout_x, (double)layout_y);
            Pango.CairoHelper.ShowLayout(CairoContext, Layout);

            Gdk.CairoHelper.SetSourcePixbuf(CairoContext, icon, 0, 0);
            CairoContext.Paint();
            Layout.FontDescription.Dispose();
            Layout.Dispose();
        }
Beispiel #5
0
        public Pixbuf Render(Widget w, Gtk.IconSize size)
        {
            // most basenji icons are gtk stock icons,
            // so try to render the icon via widget.RenderIcon() first
            // (RenderIcon return null if the stock_id wasn't knwon)
            Pixbuf pb = w.RenderIcon(this.name, size, string.Empty);

            if (pb == null) {
                // try to render the icon via Gtk.IconTheme
                if (Gtk.IconTheme.Default.HasIcon(this.name)) {
                    pb = Gtk.IconTheme.Default.LoadIcon(this.name, IconUtils.GetIconSizeVal(size), 0);
                } else {
                    Debug.WriteLine(string.Format("Icon.Render(): Failed to render icon \"{0}\"", this.name));
                }
            }
            return pb;
        }