Пример #1
0
        public Gtk.Widget GetTopLevel(string name)
        {
            WidgetData w = GetWidgetData(name);

            if (w != null)
            {
                return(GetWidget(w));
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public void CopyWidgetToProject(string name, ProjectBackend other, string replacedName)
        {
            WidgetData wdata = GetWidgetData(name);

            if (name == null)
            {
                throw new InvalidOperationException("Component not found: " + name);
            }

            XmlElement data;

            if (wdata.Widget != null)
            {
                data = Stetic.WidgetUtils.ExportWidget(wdata.Widget);
            }
            else
            {
                data = (XmlElement)wdata.XmlData.Clone();
            }

            // If widget already exist, replace it
            wdata = other.GetWidgetData(replacedName);
            if (wdata == null)
            {
                wdata = new WidgetData(name, data, null);
                other.topLevels.Add(wdata);
            }
            else
            {
                if (wdata.Widget != null)
                {
                    // If a widget instance already exist, load the new data on it
                    Wrapper.Widget sw = Wrapper.Widget.Lookup(wdata.Widget);
                    sw.Read(new ObjectReader(other, FileFormat.Native), data);
                    sw.NotifyChanged();
                    if (name != replacedName)
                    {
                        other.OnWidgetNameChanged(new Wrapper.WidgetNameChangedArgs(sw, replacedName, name), true);
                    }
                }
                else
                {
                    wdata.SetXmlData(name, data);
                    if (name != replacedName)
                    {
                        other.OnWidgetNameChanged(new Wrapper.WidgetNameChangedArgs(null, replacedName, name), true);
                    }
                }
            }
        }
Пример #3
0
        public Gtk.Widget GetWidget(WidgetData data)
        {
            if (data.Widget == null)
            {
                try {
                    loading = true;
                    ObjectReader      reader  = new ObjectReader(this, FileFormat.Native);
                    Wrapper.Container wrapper = Stetic.ObjectWrapper.ReadObject(reader, data.XmlData) as Wrapper.Container;
                    data.Widget = wrapper.Wrapped;
                } finally {
                    loading = false;
                }
            }

            return(data.Widget);
        }
Пример #4
0
        public bool ReloadTopLevel(string topLevelName)
        {
            XmlElement topLevelElem = ReadDesignerFile(topLevelName, "widget");

            if (topLevelName != null)
            {
                WidgetData data = GetWidgetData(topLevelName);

                if (data != null)
                {
                    //Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup (data.Widget);
                    data.SetXmlData(topLevelName, topLevelElem);
                    GetWidget(data);
                    return(true);
                }
            }
            return(false);
        }
Пример #5
0
        public void RemoveWidget(string name)
        {
            WidgetData data = GetWidgetData(name);

            if (data == null)
            {
                return;
            }

            if (frontend != null)
            {
                frontend.NotifyWidgetRemoved(data.Name);
            }

            if (modifiedTopLevels.Contains(name))
            {
                modifiedTopLevels.Remove(name);
            }
        }
Пример #6
0
        public void RemoveWidget(string name)
        {
            WidgetData data = GetWidgetData(name);

            if (data == null)
            {
                return;
            }

            if (frontend != null)
            {
                frontend.NotifyWidgetRemoved(data.Name);
            }

            topLevels.Remove(data);
            if (data.Widget != null)
            {
                data.Widget.Destroy();
            }
        }
Пример #7
0
        public void RemoveWidget(string name)
        {
            WidgetData data = GetWidgetData(name);

            if (data == null)
            {
                return;
            }

            if (frontend != null)
            {
                frontend.NotifyWidgetRemoved(data.Name);
            }

            XmlElement elem;

            if (data.Widget != null)
            {
                elem = Stetic.WidgetUtils.ExportWidget(data.Widget);
            }
            else
            {
                elem = (XmlElement)data.XmlData.Clone();
            }
            XmlDocument doc  = new XmlDocument();
            XmlNode     node = doc.ImportNode(elem, true);

            doc.AppendChild(node);
            string dir = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "stetic"), "deleted-designs");

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            doc.Save(Path.Combine(dir, name + ".xml"));
            topLevels.Remove(data);
            if (data.Widget != null)
            {
                data.Widget.Destroy();
            }
        }
Пример #8
0
		public void CopyWidgetToProject (string name, ProjectBackend other, string replacedName)
		{
			WidgetData wdata = GetWidgetData (name);
			if (name == null)
				throw new InvalidOperationException ("Component not found: " + name);
			
			XmlElement data;
			if (wdata.Widget != null)
				data = Stetic.WidgetUtils.ExportWidget (wdata.Widget);
			else
				data = (XmlElement) wdata.XmlData.Clone ();
			
			// If widget already exist, replace it
			wdata = other.GetWidgetData (replacedName);
			if (wdata == null) {
				wdata = new WidgetData (name, data, null);
				other.topLevels.Add (wdata);
			} else {
				if (wdata.Widget != null) {
					// If a widget instance already exist, load the new data on it
					Wrapper.Widget sw = Wrapper.Widget.Lookup (wdata.Widget);
					sw.Read (new ObjectReader (other, FileFormat.Native), data);
					sw.NotifyChanged ();
					if (name != replacedName)
						other.OnWidgetNameChanged (new Wrapper.WidgetNameChangedArgs (sw, replacedName, name), true);
				} else {
					wdata.SetXmlData (name, data);
					if (name != replacedName)
						other.OnWidgetNameChanged (new Wrapper.WidgetNameChangedArgs (null, replacedName, name), true);
				}
			}
		}
Пример #9
0
		public Gtk.Widget GetWidget (WidgetData data)
		{
			if (data.Widget == null) {
				try {
					loading = true;
					ObjectReader reader = new ObjectReader (this, FileFormat.Native);
					Wrapper.Container wrapper = Stetic.ObjectWrapper.ReadObject (reader, data.XmlData) as Wrapper.Container;
					data.Widget = wrapper.Wrapped;
				} finally {
					loading = false;
				}
			}
			
			return data.Widget;
		}