Beispiel #1
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);
        }
		protected virtual void ChildContentsChanged (Container child)
		{
		}
Beispiel #3
0
		protected override void ChildContentsChanged (Container child)
		{
			using (UndoManager.AtomicChange) {
				Gtk.Widget widget = child.Wrapped;
				Freeze ();
				if (AutoSize[widget]) {
					Gtk.Table.TableChild tc = table[widget] as Gtk.Table.TableChild;
					tc.XOptions = 0;
					tc.YOptions = 0;
				}
				Thaw ();
			}

			base.ChildContentsChanged (child);
		}
Beispiel #4
0
        void ButtonsChanged(Container container)
        {
            Gtk.Widget[] children = dialog.ActionArea.Children;

            // If the user manually removes (or breaks) the Help button,
            // uncheck the corresponding property
            if (helpButton != null) {
                if (Array.IndexOf (children, helpButton) == -1 ||
                    !ButtonIsHelp (helpButton)) {
                    helpButton = null;
                    EmitNotify ("HelpButton");
                }
            }

            // If the user manually creates a Help button, set the property
            if (helpButton == null) {
                foreach (Gtk.Widget w in children) {
                    Gtk.Button button = w as Gtk.Button;
                    if (button != null && ButtonIsHelp (button)) {
                        helpButton = button;
                        dialog.ActionArea.ReorderChild (helpButton, 0);
                        EmitNotify ("HelpButton");
                        break;
                    }
                }
            }

            // If the user removed all (non-Secondary) buttons, add back a
            // single custom button
            if (Buttons == 0)
                Buttons = 1;
        }
Beispiel #5
0
		protected override void ChildContentsChanged (Container child) {
			Gtk.Widget widget = child.Wrapped;

			if (widget != null && AutoSize[widget]) {
				Gtk.Box.BoxChild bc = box[widget] as Gtk.Box.BoxChild;
				bool newExp = (ContainerOrientation == Gtk.Orientation.Horizontal) ? ChildHExpandable (widget) : ChildVExpandable (widget);
				if (newExp != bc.Expand)
					bc.Expand = newExp;
				if (newExp != bc.Fill)
					bc.Fill = newExp;
			}
			base.ChildContentsChanged (child);
		}