Write() public method

public Write ( ObjectWriter writer ) : XmlElement
writer ObjectWriter
return System.Xml.XmlElement
Exemplo n.º 1
0
        public static XmlElement ExportWidget(Gtk.Widget widget)
        {
            XmlDocument doc = new XmlDocument();

            Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup(widget);
            if (wrapper == null)
            {
                throw new InvalidOperationException();
            }

            XmlElement elem = wrapper.Write(new ObjectWriter(doc, FileFormat.Native));

            doc.AppendChild(elem);
            return(doc.DocumentElement);
        }
Exemplo n.º 2
0
        public static XmlDocument Export(Gtk.Widget widget)
        {
            Stetic.Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup(widget);
            if (wrapper == null)
            {
                return(null);
            }

            XmlDocument doc = new XmlDocument();

            doc.PreserveWhitespace = true;

            XmlElement toplevel = doc.CreateElement("glade-interface");

            doc.AppendChild(toplevel);

            // For toplevel widgets, glade just saves it as-is. For
            // non-toplevels, it puts the widget into a dummy GtkWindow,
            // but using the packing attributes of the widget's real
            // container (so as to preserve expand/fill settings and the
            // like).

            XmlElement elem;

            Stetic.Wrapper.Container parent = wrapper.ParentWrapper;
            ObjectWriter             writer = new ObjectWriter(doc, FileFormat.Glade);

            if (parent == null)
            {
                elem = wrapper.Write(writer);
                if (elem == null)
                {
                    return(null);
                }
                if (!(widget is Gtk.Window))
                {
                    XmlElement window = doc.CreateElement("widget");
                    window.SetAttribute("class", "GtkWindow");
                    window.SetAttribute("id", "glade-dummy-container");
                    XmlElement child = doc.CreateElement("child");
                    window.AppendChild(child);
                    child.AppendChild(elem);
                    elem = window;
                }
            }
            else
            {
                elem = doc.CreateElement("widget");
                // Set the class correctly (temporarily) so the XSL
                // transforms will work correctly.
                ClassDescriptor klass = parent.ClassDescriptor;
                elem.SetAttribute("class", klass.CName);
                elem.AppendChild(parent.WriteContainerChild(writer, wrapper));
            }
            toplevel.AppendChild(elem);

            doc = XslExportTransform(doc);

            if (parent != null)
            {
                elem = (XmlElement)doc.SelectSingleNode("glade-interface/widget");
                elem.SetAttribute("class", "GtkWindow");
                elem.SetAttribute("id", "glade-dummy-container");
            }
            return(doc);
        }