Exemplo n.º 1
0
        protected override XmlElement WriteProperties(ObjectWriter writer)
        {
            XmlElement elem = base.WriteProperties(writer);

            if (imageInfo != null)
            {
                if (writer.Format == FileFormat.Glade)
                {
                    // The generated pixbuf property doesn't have a valid value, it needs to be replaced.
                    GladeUtils.ExtractProperty(elem, "pixbuf", "");
                    switch (imageInfo.Source)
                    {
                    case ImageSource.File:
                        GladeUtils.SetProperty(elem, "pixbuf", imageInfo.Name);
                        break;

                    case ImageSource.Theme:
                        GladeUtils.SetProperty(elem, "stock", imageInfo.Name);
                        GladeUtils.SetProperty(elem, "icon_size", ((int)imageInfo.ThemeIconSize).ToString());
                        break;

                    default:
                        throw new System.NotSupportedException("Image source not supported by Glade.");
                    }
                }
            }
            return(elem);
        }
Exemplo n.º 2
0
        protected override void ReadProperties(ObjectReader reader, XmlElement elem)
        {
            Gtk.StockItem stockItem = Gtk.StockItem.Zero;
            bool          use_stock = (bool)GladeUtils.ExtractProperty(elem, "use_stock", false);

            if (use_stock)
            {
                string label = (string)GladeUtils.GetProperty(elem, "label", "");
                stockItem = Gtk.Stock.Lookup(label);
                if (stockItem.Label != null)
                {
                    GladeUtils.ExtractProperty(elem, "label", "");
                }
            }
            base.ReadProperties(reader, elem);

            if (stockItem.StockId != null)
            {
                Image = "stock:" + stockItem.StockId;
            }
            if (stockItem.Keyval != 0)
            {
                Accelerator = Gtk.Accelerator.Name(stockItem.Keyval, stockItem.Modifier);
            }
        }
Exemplo n.º 3
0
        public override void Read(ObjectReader reader, XmlElement element)
        {
            object cp = GladeUtils.ExtractProperty(element, "CurrentPage", 0);

            base.Read(reader, element);
            notebook.CurrentPage = (int)cp;
        }
Exemplo n.º 4
0
 protected virtual XmlElement WriteProperties(ObjectWriter writer)
 {
     if (writer.Format == FileFormat.Native)
     {
         XmlElement elem = WidgetUtils.Write(this, writer.XmlDocument);
         if (writer.CreateUndoInfo)
         {
             elem.SetAttribute("undoId", UndoId);
         }
         return(elem);
     }
     else
     {
         XmlElement elem = GladeUtils.ExportWidget(this, writer.XmlDocument);
         GladeUtils.ExtractProperty(elem, "name", "");
         return(elem);
     }
 }
        protected override XmlElement WriteProperties(ObjectWriter writer)
        {
            XmlElement elem = base.WriteProperties(writer);

            if (writer.Format == FileFormat.Native)
            {
                // The style is already stored in ButtonStyle
                GladeUtils.ExtractProperty(elem, "ToolbarStyle", "");
                if (toolbarInfo != null)
                {
                    elem.AppendChild(writer.XmlDocument.ImportNode(toolbarInfo, true));
                }
                else
                {
                    elem.AppendChild(actionTree.Write(writer.XmlDocument, writer.Format));
                }
            }
            return(elem);
        }
Exemplo n.º 6
0
        protected override void ReadProperties(ObjectReader reader, XmlElement elem)
        {
            int history = (int)GladeUtils.ExtractProperty(elem, "history", -1);

            base.ReadProperties(reader, elem);

            // Fiddle with things to make the optionmenu resize itself correctly
            Gtk.Widget menu = optionmenu.Menu;
            optionmenu.Menu = new Gtk.Menu();
            optionmenu.Menu = menu;

            if (history != -1)
            {
                Active = history;
            }
            else
            {
                Active = 0;
            }
        }
        protected override void ReadProperties(ObjectReader reader, XmlElement elem)
        {
            string group  = (string)GladeUtils.ExtractProperty(elem, "group", "");
            bool   active = (bool)GladeUtils.ExtractProperty(elem, "active", false);

            base.ReadProperties(reader, elem);

            if (group != "")
            {
                Group = group;
            }
            else
            {
                Group = Wrapped.Name;
            }
            if (active)
            {
                ((Gtk.RadioMenuItem)Wrapped).Active = true;
            }
        }
Exemplo n.º 8
0
        protected override void ReadProperties(ObjectReader reader, XmlElement elem)
        {
            if (reader.Format == FileFormat.Glade)
            {
                string file     = (string)GladeUtils.ExtractProperty(elem, "pixbuf", "");
                string stock    = (string)GladeUtils.ExtractProperty(elem, "stock", "");
                string iconSize = (string)GladeUtils.ExtractProperty(elem, "icon_size", "");
                base.ReadProperties(reader, elem);

                if (stock != null && stock.Length > 0)
                {
                    Pixbuf = ImageInfo.FromTheme(stock, (Gtk.IconSize) int.Parse(iconSize));
                }
                else if (file != null && file != "")
                {
                    Pixbuf = ImageInfo.FromFile(file);
                }
            }
            else
            {
                base.ReadProperties(reader, elem);
            }
        }
Exemplo n.º 9
0
        protected override XmlElement WriteProperties(ObjectWriter writer)
        {
            XmlElement elem = base.WriteProperties(writer);

            if (writer.Format == FileFormat.Native)
            {
                // The style and icon size is already stored in ButtonStyle and ButtonIconSize
                GladeUtils.ExtractProperty(elem, "ToolbarStyle", "");
                GladeUtils.ExtractProperty(elem, "IconSize", "");

                // Store ButtonIconSize as IconSize, for backwards compat
                GladeUtils.RenameProperty(elem, "ButtonIconSize", "IconSize");

                if (toolbarInfo != null)
                {
                    elem.AppendChild(writer.XmlDocument.ImportNode(toolbarInfo, true));
                }
                else
                {
                    elem.AppendChild(actionTree.Write(writer.XmlDocument, writer.Format));
                }
            }
            return(elem);
        }
Exemplo n.º 10
0
        protected override void ReadProperties(ObjectReader reader, XmlElement elem)
        {
            if (reader.Format == FileFormat.Glade)
            {
                string icon = (string)GladeUtils.ExtractProperty(elem, "icon", "");
                stockId = (string)GladeUtils.ExtractProperty(elem, "stock_id", "");
                label   = (string)GladeUtils.ExtractProperty(elem, "label", "");
                base.ReadProperties(reader, elem);

                if (stockId != null && stockId.Length > 0)
                {
                    Type = ButtonType.StockItem;
                }
                else if (icon != null && icon != "")
                {
                    imageInfo = ImageInfo.FromFile(icon);
                    Type      = ButtonType.TextAndIcon;
                }
            }
            else
            {
                base.ReadProperties(reader, elem);
            }
        }