static void GetFieldsToBind(List <ObjectBindInfo> tobind, ObjectWrapper wrapper) { string memberName = null; if (wrapper is Wrapper.Widget) { Wrapper.Widget ww = wrapper as Wrapper.Widget; if (!String.IsNullOrEmpty(ww.UIManagerName)) { tobind.Add(new ObjectBindInfo("Gtk.UIManager", ww.UIManagerName)); } if (!ww.IsTopLevel && ww.InternalChildProperty == null && !ww.Unselectable) { memberName = ((Wrapper.Widget)wrapper).Wrapped.Name; } } else if (wrapper is Wrapper.Action) { memberName = ((Wrapper.Action)wrapper).Name; } if (memberName != null) { ObjectBindInfo binfo = new ObjectBindInfo(wrapper.WrappedTypeName, memberName); tobind.Add(binfo); } Wrapper.ActionGroup agroup = wrapper as Wrapper.ActionGroup; if (agroup != null) { foreach (Wrapper.Action ac in agroup.Actions) { GetFieldsToBind(tobind, ac); } } Wrapper.Widget widget = wrapper as Wrapper.Widget; if (widget != null && widget.IsTopLevel) { // Generate fields for local actions foreach (Wrapper.ActionGroup grp in widget.LocalActionGroups) { GetFieldsToBind(tobind, grp); } } Gtk.Container cont = wrapper.Wrapped as Gtk.Container; if (cont != null) { foreach (Gtk.Widget child in cont.AllChildren) { Stetic.Wrapper.Widget ww = Stetic.Wrapper.Widget.Lookup(child); if (ww != null) { GetFieldsToBind(tobind, ww); } } } }
void AddActionGroup(XmlElement groupElem) { ObjectReader reader = new ObjectReader(this, FileFormat.Native); Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup(); actionGroup.Read(reader, groupElem); actionGroups.Add(actionGroup); }
void NotifyGroupAdded(ActionGroup grp) { grp.SetOwner(owner); grp.ObjectChanged += OnGroupChanged; if (ActionGroupAdded != null) { ActionGroupAdded(this, new ActionGroupEventArgs(grp)); } }
void NotifyGroupRemoved(ActionGroup grp) { grp.SetOwner(null); grp.ObjectChanged -= OnGroupChanged; if (ActionGroupRemoved != null) { ActionGroupRemoved(this, new ActionGroupEventArgs(grp)); } }
static void GenerateComponentCode(object component, SteticCompilationUnit globalUnit, CodeNamespace globalNs, CodeExpression cobj, CodeStatementCollection statements, CodeTypeDeclaration globalType, GenerationOptions options, List <SteticCompilationUnit> units, CodeIdentifiers ids, ArrayList warnings) { Gtk.Widget widget = component as Gtk.Widget; Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup(widget); Wrapper.ActionGroup agroup = component as Wrapper.ActionGroup; string name = widget != null ? widget.Name : agroup.Name; string internalClassName = ids.MakeUnique(CodeIdentifier.MakeValid(name)); string typeName = widget != null ? wwidget.WrappedTypeName : "Gtk.ActionGroup"; // Create the build method for the top level CodeMemberMethod met; met = GetBuildMethod(name, internalClassName, typeName, globalUnit, options, units); // Generate the build code CodeVariableDeclarationStatement varDecHash = new CodeVariableDeclarationStatement(typeof(System.Collections.Hashtable), "bindings"); met.Statements.Add(varDecHash); varDecHash.InitExpression = new CodeObjectCreateExpression( typeof(System.Collections.Hashtable), new CodeExpression [0] ); CodeVariableReferenceExpression targetObjectVar = new CodeVariableReferenceExpression("cobj"); Stetic.WidgetMap map; if (widget != null) { map = Stetic.CodeGenerator.GenerateCreationCode(globalNs, globalType, widget, targetObjectVar, met.Statements, options, warnings); CodeGenerator.BindSignalHandlers(targetObjectVar, wwidget, map, met.Statements, options); } else { map = Stetic.CodeGenerator.GenerateCreationCode(globalNs, globalType, agroup, targetObjectVar, met.Statements, options, warnings); foreach (Wrapper.Action ac in agroup.Actions) { CodeGenerator.BindSignalHandlers(targetObjectVar, ac, map, met.Statements, options); } } GenerateBindFieldCode(met.Statements, cobj); // Add a method call to the build method statements.Add( new CodeMethodInvokeExpression( new CodeTypeReferenceExpression(options.GlobalNamespace + ".SteticGenerated." + internalClassName), "Build", new CodeCastExpression(typeName, cobj) ) ); }
public ActionPaletteGroup(string name, Wrapper.ActionGroup group) : base(name) { DND.DestSet(this, true); this.group = group; group.ActionAdded += OnActionGroupChanged; group.ActionRemoved += OnActionGroupChanged; group.ActionChanged += OnActionGroupChanged; group.ObjectChanged += OnActionGroupChanged; Fill(); }
protected void ReadActionGroups(ObjectReader reader, XmlElement elem) { if (reader.Format == FileFormat.Native) { if (actionGroups == null) { actionGroups = new ActionGroupCollection(); actionGroups.SetOwner(this); actionGroups.ActionGroupAdded += OnGroupAdded; actionGroups.ActionGroupRemoved += OnGroupRemoved; actionGroups.ActionGroupChanged += OnGroupChanged; } else { actionGroups.Clear(); } foreach (XmlElement groupElem in elem.SelectNodes("action-group")) { ActionGroup actionGroup = new ActionGroup(); actionGroup.Read(reader, groupElem); actionGroups.Add(actionGroup); } } }
public void Remove(ActionGroup group) { List.Remove(group); }
public void Insert(int n, ActionGroup group) { List.Insert(n, group); }
public int IndexOf(ActionGroup group) { return(List.IndexOf(group)); }
internal void SetActionGroup (ActionGroup g) { group = g; }
void OnAddGroup (object s, EventArgs args) { ActionGroup group = new ActionGroup (); group.Name = Catalog.GetString ("New Action Group"); actionGroups.Add (group); combo.Active = actionGroups.Count - 1; if (ActiveGroupCreated != null) ActiveGroupCreated (this, new ActionGroupEventArgs (ActiveGroup)); if (agroupEditor != null) agroupEditor.StartEditing (); }
public void Insert (int n, ActionGroup group) { List.Insert (n, group); }
void Read (XmlDocument doc) { loading = true; string basePath = fileName != null ? Path.GetDirectoryName (fileName) : null; try { string fn = fileName; Close (); fileName = fn; XmlNode node = doc.SelectSingleNode ("/stetic-interface"); if (node == null) throw new ApplicationException (Catalog.GetString ("Not a Stetic file according to node name.")); // Load configuration options foreach (XmlNode configNode in node.SelectNodes ("configuration/*")) { XmlElement config = configNode as XmlElement; if (config == null) continue; if (config.LocalName == "images-root-path") imagesRootPath = config.InnerText; else if (config.LocalName == "target-gtk-version") targetGtkVersion = config.InnerText; } // Load the assembly directories resolver = new AssemblyResolver (app); foreach (XmlElement libElem in node.SelectNodes ("import/assembly-directory")) { string dir = libElem.GetAttribute ("path"); if (dir.Length > 0) { if (basePath != null && !Path.IsPathRooted (dir)) { dir = FromOSAgnosticRelPath (Path.Combine (basePath, dir)); if (Directory.Exists (dir)) dir = Path.GetFullPath (dir); } resolver.Directories.Add (dir); } } // Import the referenced libraries foreach (XmlElement libElem in node.SelectNodes ("import/widget-library")) { string libname = libElem.GetAttribute ("name"); if (libname.EndsWith (".dll") || libname.EndsWith (".exe")) { if (basePath != null && !Path.IsPathRooted (libname)) { libname = FromOSAgnosticRelPath (Path.Combine (basePath, libname)); if (File.Exists (libname)) libname = Path.GetFullPath (libname); } } widgetLibraries.Add (libname); if (libElem.GetAttribute ("internal") == "true") internalLibs.Add (libname); } app.LoadLibraries (resolver, widgetLibraries); ObjectReader reader = new ObjectReader (this, FileFormat.Native); if (ownedGlobalActionGroups) { foreach (XmlElement groupElem in node.SelectNodes ("action-group")) { Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup (); actionGroup.Read (reader, groupElem); actionGroups.Add (actionGroup); } } XmlElement iconsElem = node.SelectSingleNode ("icon-factory") as XmlElement; if (iconsElem != null) iconFactory.Read (this, iconsElem); foreach (XmlElement toplevel in node.SelectNodes ("widget")) { topLevels.Add (new WidgetData (toplevel.GetAttribute ("id"), toplevel, null)); } } finally { loading = false; } }
internal void SetActionGroup(ActionGroup g) { group = g; }
public static WidgetMap GenerateCreationCode(CodeNamespace cns, CodeTypeDeclaration type, Wrapper.ActionGroup grp, CodeExpression groupVarExp, CodeStatementCollection statements, GenerationOptions options, ArrayList warnings) { statements.Add(new CodeCommentStatement("Action group " + grp.Name)); GeneratorContext ctx = new ProjectGeneratorContext(cns, type, statements, options); ctx.GenerateCreationCode(grp, groupVarExp); ctx.EndGeneration(); warnings.AddRange(ctx.Warnings); return(ctx.WidgetMap); }
public ActionGroup[] ToArray() { ActionGroup[] groups = new ActionGroup [Count]; List.CopyTo(groups, 0); return(groups); }
public object DeserializeChild (XmlElement data) { ObjectReader or = new ObjectReader (project, FileFormat.Native); if (data.LocalName == "action") { Wrapper.Action ac = new Wrapper.Action (); ac.Read (or, data); return ac; } else if (data.LocalName == "action-group") { ActionGroup ac = new ActionGroup (); ac.Read (or, data); return ac; } throw new NotImplementedException (); }
void NotifyGroupAdded (ActionGroup grp) { grp.SetOwner (owner); grp.ObjectChanged += OnGroupChanged; if (ActionGroupAdded != null) ActionGroupAdded (this, new ActionGroupEventArgs (grp)); }
public void Remove (ActionGroup group) { List.Remove (group); }
public int IndexOf (ActionGroup group) { return List.IndexOf (group); }
void OnActiveChanged (object s, EventArgs args) { if (!updating) { UpdateActionCommands (null); if (combo.Active != -1) currentGroup = (ActionGroup) actionGroups [combo.Active]; else currentGroup = null; NotifyActiveGroupChanged (); } }
public ActionGroupToolbar (ActionGroupDesignerFrontend frontend, Wrapper.ActionGroup actionGroup) { currentGroup = actionGroup; Initialize (frontend, null, true); }
void NotifyGroupRemoved (ActionGroup grp) { grp.SetOwner (null); grp.ObjectChanged -= OnGroupChanged; if (ActionGroupRemoved != null) ActionGroupRemoved (this, new ActionGroupEventArgs (grp)); }
public void Add (ActionGroup group) { List.Add (group); }
public ActionGroupEventArgs(ActionGroup ac) { action = ac; }
public ActionGroup[] ToArray () { ActionGroup[] groups = new ActionGroup [Count]; List.CopyTo (groups, 0); return groups; }
protected void ReadActionGroups (ObjectReader reader, XmlElement elem) { if (reader.Format == FileFormat.Native) { if (actionGroups == null) { actionGroups = new ActionGroupCollection (); actionGroups.SetOwner (this); actionGroups.ActionGroupAdded += OnGroupAdded; actionGroups.ActionGroupRemoved += OnGroupRemoved; actionGroups.ActionGroupChanged += OnGroupChanged; } else actionGroups.Clear (); foreach (XmlElement groupElem in elem.SelectNodes ("action-group")) { ActionGroup actionGroup = new ActionGroup (); actionGroup.Read (reader, groupElem); actionGroups.Add (actionGroup); } } }
public ActionGroupEventArgs (ActionGroup ac) { action = ac; }
internal ActionCollection(ActionGroup group) { this.group = group; }
void AddActionGroup (XmlElement groupElem) { ObjectReader reader = new ObjectReader (this, FileFormat.Native); Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup (); actionGroup.Read (reader, groupElem); actionGroups.Add (actionGroup); }
public ActionPaletteGroup (string name, Wrapper.ActionGroup group): base (name) { DND.DestSet (this, true); this.group = group; group.ActionAdded += OnActionGroupChanged; group.ActionRemoved += OnActionGroupChanged; group.ActionChanged += OnActionGroupChanged; group.ObjectChanged += OnActionGroupChanged; Fill (); }
public virtual void GenerateCreationCode(Wrapper.ActionGroup agroup, CodeExpression var) { rootObject = var; vars [agroup] = var; agroup.GenerateBuildCode(this, var); }
static void GenerateGlobalActionGroupCode(SteticCompilationUnit globalUnit, CodeNamespace globalNs, GenerationOptions options, List <SteticCompilationUnit> units, Wrapper.ActionGroup agroup, ArrayList warnings) { CodeTypeDeclaration type = CreatePartialClass(globalUnit, units, options, agroup.Name); // Generate the build method CodeMemberMethod met = new CodeMemberMethod(); met.Name = "Build"; type.Members.Add(met); met.ReturnType = new CodeTypeReference(typeof(void)); met.Attributes = MemberAttributes.Public; Stetic.WidgetMap map = Stetic.CodeGenerator.GenerateCreationCode(globalNs, type, agroup, new CodeThisReferenceExpression(), met.Statements, options, warnings); foreach (Wrapper.Action ac in agroup.Actions) { CodeGenerator.BindSignalHandlers(new CodeThisReferenceExpression(), ac, map, met.Statements, options); } }
public ActionGroupToolbar(ActionGroupDesignerFrontend frontend, Wrapper.ActionGroup actionGroup) { currentGroup = actionGroup; Initialize(frontend, null, true); }
void Read(XmlDocument doc) { loading = true; string basePath = fileName != null?Path.GetDirectoryName(fileName) : null; try { string fn = fileName; Close(); fileName = fn; XmlNode node = doc.SelectSingleNode("/stetic-interface"); if (node == null) { throw new ApplicationException(Catalog.GetString("Not a Stetic file according to node name.")); } // Load configuration options foreach (XmlNode configNode in node.SelectNodes("configuration/*")) { XmlElement config = configNode as XmlElement; if (config == null) { continue; } if (config.LocalName == "images-root-path") { imagesRootPath = config.InnerText; } else if (config.LocalName == "target-gtk-version") { targetGtkVersion = config.InnerText; } } // Load the assembly directories resolver = new AssemblyResolver(app); foreach (XmlElement libElem in node.SelectNodes("import/assembly-directory")) { string dir = libElem.GetAttribute("path"); if (dir.Length > 0) { if (basePath != null && !Path.IsPathRooted(dir)) { dir = Path.Combine(basePath, dir); if (Directory.Exists(dir)) { dir = Path.GetFullPath(dir); } } resolver.Directories.Add(dir); } } // Import the referenced libraries foreach (XmlElement libElem in node.SelectNodes("import/widget-library")) { string libname = libElem.GetAttribute("name"); if (libname.EndsWith(".dll") || libname.EndsWith(".exe")) { if (basePath != null && !Path.IsPathRooted(libname)) { libname = Path.Combine(basePath, libname); if (File.Exists(libname)) { libname = Path.GetFullPath(libname); } } } widgetLibraries.Add(libname); if (libElem.GetAttribute("internal") == "true") { internalLibs.Add(libname); } } app.LoadLibraries(resolver, widgetLibraries); ObjectReader reader = new ObjectReader(this, FileFormat.Native); if (ownedGlobalActionGroups) { foreach (XmlElement groupElem in node.SelectNodes("action-group")) { Wrapper.ActionGroup actionGroup = new Wrapper.ActionGroup(); actionGroup.Read(reader, groupElem); actionGroups.Add(actionGroup); } } XmlElement iconsElem = node.SelectSingleNode("icon-factory") as XmlElement; if (iconsElem != null) { iconFactory.Read(this, iconsElem); } foreach (XmlElement toplevel in node.SelectNodes("widget")) { topLevels.Add(new WidgetData(toplevel.GetAttribute("id"), toplevel, null)); } } finally { loading = false; } }
public void Add(ActionGroup group) { List.Add(group); }
internal ActionCollection (ActionGroup group) { this.group = group; }
void OnCollectionChanged (object s, ActionGroupEventArgs args) { // Avoid firing the selection change event if the selected // group is the same after the refresh ActionGroup oldGroup = currentGroup; updating = true; int i = combo.Active; Refresh (); if (actionGroups.Count == 0) { combo.Sensitive = false; currentGroup = null; } else { combo.Sensitive = true; if (i == -1) i = 0; if (i < actionGroups.Count) combo.Active = i; else combo.Active = actionGroups.Count - 1; currentGroup = (ActionGroup) actionGroups [combo.Active]; } updating = false; if (currentGroup != oldGroup) OnActiveChanged (null, null); frontend.NotifyModified (); }