public static LookupClassByCName ( string cname ) : |
||
cname | string | |
Résultat |
public static ObjectWrapper ReadObject(ObjectReader reader, XmlElement elem) { string className = elem.GetAttribute("class"); ClassDescriptor klass; if (reader.Format == FileFormat.Native) { klass = Registry.LookupClassByName(className); } else { klass = Registry.LookupClassByCName(className); } if (klass == null) { ErrorWidget we = new ErrorWidget(className, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } if (!klass.SupportsGtkVersion(reader.Project.TargetGtkVersion)) { ErrorWidget we = new ErrorWidget(className, klass.TargetGtkVersion, reader.Project.TargetGtkVersion, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } ObjectWrapper wrapper = klass.CreateWrapper(); wrapper.classDescriptor = klass; wrapper.proj = reader.Project; return(ReadObject(reader, elem, wrapper)); }
public static ObjectWrapper ReadObject(ObjectReader reader, XmlElement elem) { string className = elem.GetAttribute("class"); ClassDescriptor klass; if (reader.Format == FileFormat.Native) { klass = Registry.LookupClassByName(className); } else { klass = Registry.LookupClassByCName(className); } if (klass == null) { ErrorWidget we = new ErrorWidget(className, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } if (!klass.SupportsGtkVersion(reader.Project.TargetGtkVersion)) { ErrorWidget we = new ErrorWidget(className, klass.TargetGtkVersion, reader.Project.TargetGtkVersion, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } ObjectWrapper wrapper = klass.CreateWrapper(); wrapper.classDescriptor = klass; wrapper.proj = reader.Project; try { wrapper.OnBeginRead(reader.Format); wrapper.Read(reader, elem); } catch (Exception ex) { Console.WriteLine(ex); ErrorWidget we = new ErrorWidget(ex, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } finally { wrapper.OnEndRead(reader.Format); } return(wrapper); }
static public void ImportWidget(ObjectWrapper wrapper, XmlElement elem) { string className = elem.GetAttribute("class"); if (className == null) { throw new GladeException("<widget> node with no class name"); } ClassDescriptor klassBase = Registry.LookupClassByCName(className); if (klassBase == null) { throw new GladeException("No stetic ClassDescriptor for " + className); } TypedClassDescriptor klass = klassBase as TypedClassDescriptor; if (klass == null) { throw new GladeException("The widget class " + className + " is not supported by Glade"); } ReadSignals(klass, wrapper, elem); Hashtable rawProps, overrideProps; ExtractProperties(klass, elem, out rawProps, out overrideProps); string[] propNames; GLib.Value[] propVals; ParseProperties(klass.WrappedType, false, rawProps.Values, out propNames, out propVals); Gtk.Widget widget; if (wrapper.Wrapped == null) { if (className == "GtkWindow" || className == "GtkDialog") { widget = (Gtk.Widget)klass.CreateInstance(wrapper.Project); ObjectWrapper.Bind(wrapper.Project, klass, wrapper, widget, true); SetProperties(klass, widget, propNames, propVals); } else { IntPtr raw = gtksharp_object_newv(klass.GType.Val, propNames.Length, propNames, propVals); if (raw == IntPtr.Zero) { throw new GladeException("Could not create widget", className); } widget = (Gtk.Widget)GLib.Object.GetObject(raw, true); if (widget == null) { gtk_object_sink(raw); throw new GladeException("Could not create gtk# wrapper", className); } ObjectWrapper.Bind(wrapper.Project, klass, wrapper, widget, true); } } else { widget = (Gtk.Widget)wrapper.Wrapped; for (int i = 0; i < propNames.Length; i++) { g_object_set_property(widget.Handle, propNames[i], ref propVals[i]); } } MarkTranslatables(widget, rawProps); widget.Name = elem.GetAttribute("id"); SetOverrideProperties(wrapper, overrideProps); MarkTranslatables(widget, overrideProps); }