Пример #1
0
        internal static XmlElement CreatePacking(XmlDocument doc, Stetic.Wrapper.Container.ContainerChild childwrapper)
        {
            XmlElement packing_elem = doc.CreateElement("packing");

            GetProps(childwrapper, packing_elem);
            return(packing_elem);
        }
Пример #2
0
        void UpdateSelection(Wrapper.Widget w)
        {
            Clear();
            selection = w;

            if (selection == null)
            {
                combo.SetSelection(null);
                return;
            }

            // Look for the root widget, and only update the bar if the selected
            // widget is a child of the root widget

            while (w != null && !w.IsTopLevel)
            {
                w = Stetic.Wrapper.Container.LookupParent((Gtk.Widget)w.Wrapped);
            }
            if (w == null || w != rootWidget)
            {
                return;
            }

            combo.SetSelection(selection);

            selection.Notify += Notified;
            packingSelection  = Stetic.Wrapper.Container.ChildWrapper(selection);
            if (packingSelection != null)
            {
                packingSelection.Notify += Notified;
            }

            AddWidgetCommands(selection);
            UpdateSensitivity();
        }
Пример #3
0
        void Clear()
        {
            if (selection != null)
            {
                selection.Notify -= Notified;
                if (packingSelection != null)
                {
                    packingSelection.Notify -= Notified;
                }
            }

            selection        = null;
            packingSelection = null;

            editors.Clear();
            wrappers.Clear();
            sensitives.Clear();
            invisibles.Clear();
            toggles.Clear();

            foreach (Gtk.Widget child in Children)
            {
                if (child != comboItem)
                {
                    Remove(child);
                    child.Destroy();
                }
            }
        }
Пример #4
0
        bool SelectedHandler()
        {
            ClassDescriptor klass;

            Clear();

            selection = newSelection;

            if (selection == null || selection.Wrapped is ErrorWidget)
            {
                noSelection.Show();
                return(false);
            }

            header.Show();

            selection.Notify += Notified;

            klass = selection.ClassDescriptor;

            header.AttachObject(selection.Wrapped);
            AppendItemGroups(klass, selection.Wrapped);

            packingSelection = Stetic.Wrapper.Container.ChildWrapper(selection);
            if (packingSelection != null)
            {
                klass = packingSelection.ClassDescriptor;
                if (klass.ItemGroups.Count > 0)
                {
                    AppendItemGroups(klass, packingSelection.Wrapped);
                    packingSelection.Notify += Notified;
                }
            }
            return(false);
        }
Пример #5
0
        static public void SetPacking(Stetic.Wrapper.Container.ContainerChild wrapper, XmlElement child_elem)
        {
            XmlElement packing = child_elem["packing"];

            if (packing == null)
            {
                return;
            }

            Gtk.Container.ContainerChild cc = wrapper.Wrapped as Gtk.Container.ContainerChild;
            ClassDescriptor klass           = wrapper.ClassDescriptor;

            ReadMembers(klass, wrapper, cc, packing);
        }
Пример #6
0
        bool SelectedHandler()
        {
            SaveStatus();

            Clear();

            selection = newSelection;
            if (selection == null || selection.Wrapped is ErrorWidget || project == null)
            {
                return(false);
            }

            Wrapper.Widget selWidget = selection as Wrapper.Widget;
            if (selWidget != null)
            {
                selWidget.Notify += Notified;

                PropertyDescriptor name = (PropertyDescriptor)Registry.LookupClassByName("Gtk.Widget") ["Name"];
                AppendProperty(name, selection.Wrapped);
            }

            AddProperties(selection.ClassDescriptor.ItemGroups, selection.Wrapped, project.TargetGtkVersion);

            if (selWidget != null)
            {
                packingSelection = Stetic.Wrapper.Container.ChildWrapper(selWidget);
                if (packingSelection != null)
                {
                    ClassDescriptor childklass = packingSelection.ClassDescriptor;
                    if (childklass.ItemGroups.Count > 0)
                    {
                        AddProperties(childklass.ItemGroups, packingSelection.Wrapped, project.TargetGtkVersion);
                        packingSelection.Notify += Notified;
                    }
                }
            }

            RestoreStatus();
            return(false);
        }
Пример #7
0
        void AddCommands(ObjectWrapper wrapper)
        {
            foreach (ItemGroup igroup in wrapper.ClassDescriptor.ItemGroups)
            {
                foreach (ItemDescriptor desc in igroup)
                {
                    if ((desc is CommandDescriptor) && desc.SupportsGtkVersion(project.TargetGtkVersion))
                    {
                        AppendCommand((CommandDescriptor)desc, wrapper);
                    }
                }
            }

            Stetic.Wrapper.Widget widget = wrapper as Stetic.Wrapper.Widget;
            if (widget != null)
            {
                Stetic.Wrapper.Container.ContainerChild packingSelection = Stetic.Wrapper.Container.ChildWrapper(widget);
                if (packingSelection != null)
                {
                    AddCommands(packingSelection);
                }
            }
        }
Пример #8
0
        static public void SetPacking(Stetic.Wrapper.Container.ContainerChild wrapper, XmlElement child_elem)
        {
            XmlElement packing = child_elem["packing"];

            if (packing == null)
            {
                return;
            }

            Gtk.Container.ContainerChild cc = wrapper.Wrapped as Gtk.Container.ContainerChild;

            TypedClassDescriptor klass = wrapper.ClassDescriptor as TypedClassDescriptor;

            if (klass == null)
            {
                throw new GladeException("The widget class " + cc.GetType() + " is not supported by Glade");
            }

            Hashtable rawProps, overrideProps;

            ExtractProperties(klass, packing, out rawProps, out overrideProps);

            string[]     propNames;
            GLib.Value[] propVals;
            ParseProperties(cc.Parent.GetType(), true, rawProps.Values,
                            out propNames, out propVals);

            for (int i = 0; i < propNames.Length; i++)
            {
                cc.Parent.ChildSetProperty(cc.Child, propNames[i], propVals[i]);
            }
            MarkTranslatables(cc, rawProps);

            SetOverrideProperties(wrapper, overrideProps);
            MarkTranslatables(cc, overrideProps);
        }
Пример #9
0
        static string PropToString(ObjectWrapper wrapper, TypedPropertyDescriptor prop)
        {
            object value;

            if (!prop.GladeOverride)
            {
                Stetic.Wrapper.Container.ContainerChild ccwrap = wrapper as Stetic.Wrapper.Container.ContainerChild;
                GLib.Value gval;

                if (ccwrap != null)
                {
                    Gtk.Container.ContainerChild cc = (Gtk.Container.ContainerChild)ccwrap.Wrapped;
                    gval = new GLib.Value((GLib.GType)prop.PropertyType);
                    gtk_container_child_get_property(cc.Parent.Handle, cc.Child.Handle, prop.GladeName, ref gval);
                }
                else
                {
                    Gtk.Widget widget = wrapper.Wrapped as Gtk.Widget;
                    gval = new GLib.Value(widget, prop.GladeName);
                    g_object_get_property(widget.Handle, prop.GladeName, ref gval);
                }
                value = gval.Val;
            }
            else
            {
                value = prop.GetValue(wrapper.Wrapped);
            }
            if (value == null)
            {
                return(null);
            }

            // If the property has its default value, we don't need to write it
            if (prop.HasDefault && prop.ParamSpec.IsDefaultValue(value))
            {
                return(null);
            }

            if (value is Gtk.Adjustment)
            {
                Gtk.Adjustment adj = value as Gtk.Adjustment;
                return(String.Format("{0:G} {1:G} {2:G} {3:G} {4:G} {5:G}",
                                     adj.Value, adj.Lower, adj.Upper,
                                     adj.StepIncrement, adj.PageIncrement,
                                     adj.PageSize));
            }
            else if (value is Enum && prop.ParamSpec != null)
            {
                IntPtr klass = g_type_class_ref(((GLib.GType)prop.PropertyType).Val);

                if (prop.PropertyType.IsDefined(typeof(FlagsAttribute), false))
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    uint val = (uint)System.Convert.ChangeType(value, typeof(uint));

                    while (val != 0)
                    {
                        IntPtr flags_value = g_flags_get_first_value(klass, val);
                        if (flags_value == IntPtr.Zero)
                        {
                            break;
                        }
                        IntPtr fval = Marshal.ReadIntPtr(flags_value);
                        val &= ~(uint)fval;

                        IntPtr name = Marshal.ReadIntPtr(flags_value, Marshal.SizeOf(typeof(IntPtr)));
                        if (name != IntPtr.Zero)
                        {
                            if (sb.Length != 0)
                            {
                                sb.Append('|');
                            }
                            sb.Append(GLib.Marshaller.Utf8PtrToString(name));
                        }
                    }

                    g_type_class_unref(klass);
                    return(sb.ToString());
                }
                else
                {
                    int    val        = (int)System.Convert.ChangeType(value, typeof(int));
                    IntPtr enum_value = g_enum_get_value(klass, val);
                    g_type_class_unref(klass);

                    IntPtr name = Marshal.ReadIntPtr(enum_value, Marshal.SizeOf(typeof(IntPtr)));
                    return(GLib.Marshaller.Utf8PtrToString(name));
                }
            }
            else if (value is bool)
            {
                return((bool)value ? "True" : "False");
            }
            else
            {
                return(value.ToString());
            }
        }
		bool SelectedHandler ()
		{
			SaveStatus ();
			
			Clear ();
			
			selection = newSelection;
			if (selection == null || selection.Wrapped is ErrorWidget || project == null) {
				return false;
			}

			Wrapper.Widget selWidget = selection as Wrapper.Widget;
			if (selWidget != null) {
				selWidget.Notify += Notified;
			
				PropertyDescriptor name = (PropertyDescriptor)Registry.LookupClassByName ("Gtk.Widget") ["Name"];
				AppendProperty (name, selection.Wrapped);
			}

			AddProperties (selection.ClassDescriptor.ItemGroups, selection.Wrapped, project.TargetGtkVersion);
			
			if (selWidget != null) {
				packingSelection = Stetic.Wrapper.Container.ChildWrapper (selWidget);
				if (packingSelection != null) {
					ClassDescriptor childklass = packingSelection.ClassDescriptor;
					if (childklass.ItemGroups.Count > 0) {
						AddProperties (childklass.ItemGroups, packingSelection.Wrapped, project.TargetGtkVersion);
						packingSelection.Notify += Notified;
					}
				}
			}
			
			RestoreStatus ();
			return false;
		}
Пример #11
0
		void Clear ()
		{
			if (selection != null) {
				selection.Notify -= Notified;
				if (packingSelection != null)
					packingSelection.Notify -= Notified;
			}
			
			selection = null;
			packingSelection = null;
			
			editors.Clear ();
			wrappers.Clear ();
			sensitives.Clear ();
			invisibles.Clear ();
			toggles.Clear ();
				
			foreach (Gtk.Widget child in Children)
				if (child != comboItem) {
					Remove (child);
					child.Destroy ();
				}
		}
Пример #12
0
		void UpdateSelection (Wrapper.Widget w)
		{
			Clear ();
			selection = w;
			
			if (selection == null) {
				combo.SetSelection (null);
				return;
			}

			// Look for the root widget, and only update the bar if the selected
			// widget is a child of the root widget
			
			while (w != null && !w.IsTopLevel) {
				w = Stetic.Wrapper.Container.LookupParent ((Gtk.Widget) w.Wrapped);
			}
			if (w == null || w != rootWidget)
				return;

			combo.SetSelection (selection);
			
			selection.Notify += Notified;
			packingSelection = Stetic.Wrapper.Container.ChildWrapper (selection);
			if (packingSelection != null)
				packingSelection.Notify += Notified;
				
			AddWidgetCommands (selection);
			UpdateSensitivity ();
		}
Пример #13
0
		bool SelectedHandler ()
		{
			ClassDescriptor klass;

			Clear ();
			
			selection = newSelection;

			if (selection == null || selection.Wrapped is ErrorWidget) {
				noSelection.Show ();
				return false;
			}
			
			header.Show ();

			selection.Notify += Notified;

			klass = selection.ClassDescriptor;

			header.AttachObject (selection.Wrapped);
			AppendItemGroups (klass, selection.Wrapped);

			packingSelection = Stetic.Wrapper.Container.ChildWrapper (selection);
			if (packingSelection != null) {
				klass = packingSelection.ClassDescriptor;
				if (klass.ItemGroups.Count > 0) {
					AppendItemGroups (klass, packingSelection.Wrapped);
					packingSelection.Notify += Notified;
				}
			}
			return false;
		}