3
using System.Collections;
5
namespace Stetic.Wrapper {
7
public class Image : Misc {
11
public static new Gtk.Image CreateInstance ()
13
return new Gtk.Image (Gtk.Stock.Execute, Gtk.IconSize.Dialog);
16
protected override void ReadProperties (ObjectReader reader, XmlElement elem)
18
if (reader.Format == FileFormat.Glade) {
19
string file = (string)GladeUtils.ExtractProperty (elem, "pixbuf", "");
20
string stock = (string)GladeUtils.ExtractProperty (elem, "stock", "");
21
string iconSize = (string)GladeUtils.ExtractProperty (elem, "icon_size", "");
22
base.ReadProperties (reader, elem);
24
if (stock != null && stock.Length > 0) {
25
Pixbuf = ImageInfo.FromTheme (stock, (Gtk.IconSize) int.Parse (iconSize));
26
} else if (file != null && file != "") {
27
Pixbuf = ImageInfo.FromFile (file);
30
base.ReadProperties (reader, elem);
33
protected override XmlElement WriteProperties (ObjectWriter writer)
35
XmlElement elem = base.WriteProperties (writer);
36
if (imageInfo != null) {
37
if (writer.Format == FileFormat.Glade) {
38
// The generated pixbuf property doesn't have a valid value, it needs to be replaced.
39
GladeUtils.ExtractProperty (elem, "pixbuf", "");
40
switch (imageInfo.Source) {
41
case ImageSource.File:
42
GladeUtils.SetProperty (elem, "pixbuf", imageInfo.Name);
44
case ImageSource.Theme:
45
GladeUtils.SetProperty (elem, "stock", imageInfo.Name);
46
GladeUtils.SetProperty (elem, "icon_size", ((int)imageInfo.ThemeIconSize).ToString ());
49
throw new System.NotSupportedException ("Image source not supported by Glade.");
58
return (Gtk.Image)Wrapped;
64
image.IconSize = (int)Gtk.IconSize.Button;
65
image.Stock = Gtk.Stock.MissingImage;
68
public ImageInfo Pixbuf {
69
get { return imageInfo; }
72
if (imageInfo == null)
75
image.Pixbuf = imageInfo.GetImage (Project);
76
EmitNotify ("Pixbuf");