diff options
author | Lluis Sanchez <lluis@novell.com> | 2007-03-23 19:04:39 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@novell.com> | 2007-03-23 19:04:39 +0300 |
commit | 12fbd74b695dac72bde1a7ea9f88350bcd9a40ed (patch) | |
tree | 3b6b2e97b03d5de76ab7a0ba7da06ff296834825 /Samples |
Initial import of Mono.Addins
svn path=/trunk/mono-addins/; revision=74886
Diffstat (limited to 'Samples')
66 files changed, 1985 insertions, 0 deletions
diff --git a/Samples/Samples.mds b/Samples/Samples.mds new file mode 100644 index 0000000..f454405 --- /dev/null +++ b/Samples/Samples.mds @@ -0,0 +1,45 @@ +<Combine name="Samples" fileversion="2.0"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="CombineConfiguration"> + <Entry build="True" name="WriterService" configuration="Debug" /> + <Entry build="True" name="WriterServiceHost" configuration="Debug" /> + <Entry build="True" name="WriterService.SampleExtender" configuration="Debug" /> + <Entry build="True" name="TextEditor" configuration="Debug" /> + <Entry build="True" name="TextEditorLib" configuration="Debug" /> + <Entry build="True" name="TextEditor.Xml" configuration="Debug" /> + <Entry build="True" name="TextEditor.CompilerService" configuration="Debug" /> + <Entry build="True" name="TextEditor.CompilerService.CSharp" configuration="Debug" /> + </Configuration> + <Configuration name="Release" ctype="CombineConfiguration"> + <Entry build="True" name="WriterService" configuration="Release" /> + <Entry build="True" name="WriterServiceHost" configuration="Release" /> + <Entry build="True" name="WriterService.SampleExtender" configuration="Release" /> + <Entry build="True" name="TextEditor" configuration="Release" /> + <Entry build="True" name="TextEditorLib" configuration="Release" /> + <Entry build="True" name="TextEditor.Xml" configuration="Release" /> + <Entry build="True" name="TextEditor.CompilerService" configuration="Release" /> + <Entry build="True" name="TextEditor.CompilerService.CSharp" configuration="Release" /> + </Configuration> + </Configurations> + <StartMode startupentry="TextEditor" single="True"> + <Execute type="None" entry="WriterService" /> + <Execute type="None" entry="WriterServiceHost" /> + <Execute type="None" entry="WriterService.SampleExtender" /> + <Execute type="None" entry="WriterGui" /> + <Execute type="None" entry="TextEditor" /> + <Execute type="None" entry="TextEditorLib" /> + <Execute type="None" entry="TextEditor.Xml" /> + <Execute type="None" entry="TextEditor.CompilerService" /> + <Execute type="None" entry="TextEditor.CompilerService.CSharp" /> + </StartMode> + <Entries> + <Entry filename="./WriterService/WriterService.mdp" /> + <Entry filename="./WriterServiceHost/WriterServiceHost.mdp" /> + <Entry filename="./WriterService.SampleExtender/WriterService.SampleExtender.mdp" /> + <Entry filename="./TextEditor/TextEditor.mdp" /> + <Entry filename="./TextEditorLib/TextEditorLib.mdp" /> + <Entry filename="./TextEditor.Xml/TextEditor.Xml.mdp" /> + <Entry filename="./TextEditor.CompilerService/TextEditor.CompilerService.mdp" /> + <Entry filename="./TextEditor.CompilerService.CSharp/TextEditor.CompilerService.CSharp.mdp" /> + </Entries> +</Combine>
\ No newline at end of file diff --git a/Samples/TextEditor.CompilerService.CSharp/AssemblyInfo.cs b/Samples/TextEditor.CompilerService.CSharp/AssemblyInfo.cs new file mode 100644 index 0000000..af4e275 --- /dev/null +++ b/Samples/TextEditor.CompilerService.CSharp/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes specify the key for the sign of your assembly. See the +// .NET Framework documentation for more information about signing. +// This is not required, if you don't want signing let these attributes like they're. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/Samples/TextEditor.CompilerService.CSharp/CSharpCompiler.cs b/Samples/TextEditor.CompilerService.CSharp/CSharpCompiler.cs new file mode 100644 index 0000000..7845725 --- /dev/null +++ b/Samples/TextEditor.CompilerService.CSharp/CSharpCompiler.cs @@ -0,0 +1,38 @@ +using System; +using System.IO; +using System.Diagnostics; +using Mono.Addins; +using TextEditor.CompilerService; + +[assembly:Addin] +[assembly:AddinDependency ("TextEditor.CompilerService", "1.0")] + +namespace TextEditor.CompilerService.CSharp +{ + [Extension] + public class CSharpCompiler: ICompiler + { + public bool CanCompile (string file) + { + return Path.GetExtension (file) == ".cs"; + } + + public string Compile (string file, string outFile) + { + string messages = ""; + + ProcessStartInfo ps = new ProcessStartInfo (); + ps.FileName = "mcs"; + ps.Arguments = "file"; + ps.UseShellExecute = false; + ps.RedirectStandardOutput = true; + Process p = Process.Start (ps); + + string line = null; + while ((line = p.StandardOutput.ReadLine ()) != null) { + messages += line + "\n"; + } + return messages; + } + } +}
\ No newline at end of file diff --git a/Samples/TextEditor.CompilerService.CSharp/TextEditor.CompilerService.CSharp.mdp b/Samples/TextEditor.CompilerService.CSharp/TextEditor.CompilerService.CSharp.mdp new file mode 100644 index 0000000..65948cb --- /dev/null +++ b/Samples/TextEditor.CompilerService.CSharp/TextEditor.CompilerService.CSharp.mdp @@ -0,0 +1,25 @@ +<Project name="TextEditor.CompilerService.CSharp" fileversion="2.0" language="C#" clr-version="Net_1_1" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../bin" assembly="TextEditor.CompilerService.CSharp" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" generatexmldocumentation="False" win32Icon="./" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="./bin/Release" assembly="TextEditor.CompilerService.CSharp" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="./CSharpCompiler.cs" subtype="Code" buildaction="Compile" /> + <File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="True" refto="Mono.Addins" /> + <ProjectReference type="Project" localcopy="True" refto="TextEditor.CompilerService" /> + </References> +</Project>
\ No newline at end of file diff --git a/Samples/TextEditor.CompilerService/AssemblyInfo.cs b/Samples/TextEditor.CompilerService/AssemblyInfo.cs new file mode 100644 index 0000000..af4e275 --- /dev/null +++ b/Samples/TextEditor.CompilerService/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes specify the key for the sign of your assembly. See the +// .NET Framework documentation for more information about signing. +// This is not required, if you don't want signing let these attributes like they're. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/Samples/TextEditor.CompilerService/CompilerManager.cs b/Samples/TextEditor.CompilerService/CompilerManager.cs new file mode 100644 index 0000000..e65ab65 --- /dev/null +++ b/Samples/TextEditor.CompilerService/CompilerManager.cs @@ -0,0 +1,34 @@ + +using System; +using Mono.Addins; + +namespace TextEditor.CompilerService +{ + public class CompilerManager + { + public static void Run (string file) + { + ICompiler[] compilers = (ICompiler[]) AddinManager.GetExtensionObjects (typeof(ICompiler)); + + ICompiler compiler = null; + foreach (ICompiler comp in compilers) { + if (comp.CanCompile (file)) { + compiler = comp; + break; + } + } + if (compiler == null) { + string msg = "No compiler available for this kind of file."; + Gtk.MessageDialog dlg = new Gtk.MessageDialog (TextEditorApp.MainWindow, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Close, msg); + dlg.Run (); + dlg.Destroy (); + return; + } + + string messages = compiler.Compile (file, file + ".exe"); + + TextEditorApp.MainWindow.ConsoleWrite ("Compilation finished.\n"); + TextEditorApp.MainWindow.ConsoleWrite (messages); + } + } +} diff --git a/Samples/TextEditor.CompilerService/ICompiler.cs b/Samples/TextEditor.CompilerService/ICompiler.cs new file mode 100644 index 0000000..de63e69 --- /dev/null +++ b/Samples/TextEditor.CompilerService/ICompiler.cs @@ -0,0 +1,13 @@ + +using System; +using Mono.Addins; + +namespace TextEditor.CompilerService +{ + [TypeExtensionPoint] + public interface ICompiler + { + bool CanCompile (string file); + string Compile (string file, string outFile); + } +} diff --git a/Samples/TextEditor.CompilerService/MyClass.cs b/Samples/TextEditor.CompilerService/MyClass.cs new file mode 100644 index 0000000..a10af2e --- /dev/null +++ b/Samples/TextEditor.CompilerService/MyClass.cs @@ -0,0 +1,7 @@ +// project created on 23/03/2007 at 14:10 +using System; + +public class MyClass +{ + +}
\ No newline at end of file diff --git a/Samples/TextEditor.CompilerService/RunCommand.cs b/Samples/TextEditor.CompilerService/RunCommand.cs new file mode 100644 index 0000000..7480bc3 --- /dev/null +++ b/Samples/TextEditor.CompilerService/RunCommand.cs @@ -0,0 +1,15 @@ + +using System; +using TextEditor; +using Mono.Addins; + +namespace TextEditor.CompilerService +{ + public class RunCommand: ICommand + { + public void Run () + { + CompilerManager.Run (TextEditorApp.OpenFileName); + } + } +} diff --git a/Samples/TextEditor.CompilerService/TextEditor.CompilerService.addin.xml b/Samples/TextEditor.CompilerService/TextEditor.CompilerService.addin.xml new file mode 100644 index 0000000..eacf5a4 --- /dev/null +++ b/Samples/TextEditor.CompilerService/TextEditor.CompilerService.addin.xml @@ -0,0 +1,8 @@ +<Addin namespace="TextEditor" id="CompilerService" version="1.0"> + <Dependencies> + <Addin id="Core" version="1.0" /> + </Dependencies> + <Extension path = "/TextEditor/ToolbarButtons"> + <ToolButton icon="gtk-execute" commandType="TextEditor.CompilerService.RunCommand" /> + </Extension> +</Addin> diff --git a/Samples/TextEditor.CompilerService/TextEditor.CompilerService.mdp b/Samples/TextEditor.CompilerService/TextEditor.CompilerService.mdp new file mode 100644 index 0000000..b451e2d --- /dev/null +++ b/Samples/TextEditor.CompilerService/TextEditor.CompilerService.mdp @@ -0,0 +1,30 @@ +<Project name="TextEditor.CompilerService" fileversion="2.0" language="C#" clr-version="Net_1_1" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../bin" assembly="TextEditor.CompilerService" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" generatexmldocumentation="False" win32Icon="./" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="./bin/Release" assembly="TextEditor.CompilerService" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="./MyClass.cs" subtype="Code" buildaction="Compile" /> + <File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" /> + <File name="./RunCommand.cs" subtype="Code" buildaction="Compile" /> + <File name="./ICompiler.cs" subtype="Code" buildaction="Compile" /> + <File name="./CompilerManager.cs" subtype="Code" buildaction="Compile" /> + <File name="./TextEditor.CompilerService.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="True" refto="TextEditorLib" /> + <ProjectReference type="Project" localcopy="True" refto="Mono.Addins" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + </References> +</Project>
\ No newline at end of file diff --git a/Samples/TextEditor.Xml/AssemblyInfo.cs b/Samples/TextEditor.Xml/AssemblyInfo.cs new file mode 100644 index 0000000..198a48c --- /dev/null +++ b/Samples/TextEditor.Xml/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.0.0")] + +// The following attributes specify the key for the sign of your assembly. See the +// .NET Framework documentation for more information about signing. +// This is not required, if you don't want signing let these attributes like they're. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/Samples/TextEditor.Xml/EmptyFile.xml b/Samples/TextEditor.Xml/EmptyFile.xml new file mode 100644 index 0000000..fcfff84 --- /dev/null +++ b/Samples/TextEditor.Xml/EmptyFile.xml @@ -0,0 +1,2 @@ +<xml> +</xml>
\ No newline at end of file diff --git a/Samples/TextEditor.Xml/FormatXmlCommand.cs b/Samples/TextEditor.Xml/FormatXmlCommand.cs new file mode 100644 index 0000000..ec63370 --- /dev/null +++ b/Samples/TextEditor.Xml/FormatXmlCommand.cs @@ -0,0 +1,39 @@ + +using System; +using System.IO; +using System.Xml; +using TextEditor; +using Mono.Addins; + +[assembly: Addin (Namespace="TextEditor")] +[assembly: AddinDependency ("Core", "1.0")] + + +namespace TextEditor.Xml +{ + public class FormatXmlCommand: ICommand + { + public void Run () + { + string text = TextEditorApp.MainWindow.View.Buffer.Text; + XmlDocument doc = new XmlDocument (); + try { + doc.LoadXml (text); + StringWriter sw = new StringWriter (); + XmlTextWriter tw = new XmlTextWriter (sw); + tw.Formatting = Formatting.Indented; + doc.Save (tw); + TextEditorApp.MainWindow.View.Buffer.Text = sw.ToString (); + } + catch { + Gtk.MessageDialog dlg = new Gtk.MessageDialog (TextEditorApp.MainWindow, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Close, "Error parsing XML."); + dlg.Run (); + dlg.Destroy (); + } + } + } + + class Subno: TextEditor.CopyCommand + { + } +} diff --git a/Samples/TextEditor.Xml/MyClass.cs b/Samples/TextEditor.Xml/MyClass.cs new file mode 100644 index 0000000..cad7be3 --- /dev/null +++ b/Samples/TextEditor.Xml/MyClass.cs @@ -0,0 +1,12 @@ +// project created on 20/03/2007 at 13:01 +using System; +using Mono.Addins; + +[assembly: Addin (Namespace="TextEditor")] +[assembly: AddinDependency ("Core", "1.0")] + + +public class MyClass +{ + +}
\ No newline at end of file diff --git a/Samples/TextEditor.Xml/TextEditor.Xml.addin.xml b/Samples/TextEditor.Xml/TextEditor.Xml.addin.xml new file mode 100644 index 0000000..0605d03 --- /dev/null +++ b/Samples/TextEditor.Xml/TextEditor.Xml.addin.xml @@ -0,0 +1,14 @@ +<Addin> + + <Extension path = "/TextEditor/MainMenu/Edit"> + <Condition id="OpenFile" extension="xml,config"> + <MenuSeparator insertafter="Paste" /> + <MenuItem label="Format XML" commandType="TextEditor.Xml.FormatXmlCommand" /> + </Condition> + </Extension> + + <Extension path = "/TextEditor/Templates"> + <FileTemplate name="Xml File" resource="EmptyFile.xml" /> + </Extension> + +</Addin> diff --git a/Samples/TextEditor.Xml/TextEditor.Xml.mdp b/Samples/TextEditor.Xml/TextEditor.Xml.mdp new file mode 100644 index 0000000..feb5798 --- /dev/null +++ b/Samples/TextEditor.Xml/TextEditor.Xml.mdp @@ -0,0 +1,29 @@ +<Project name="TextEditor.Xml" fileversion="2.0" language="C#" clr-version="Net_1_1" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../bin" assembly="XmlAddin" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="./bin/Release" assembly="XmlAddin" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" /> + <File name="./TextEditor.Xml.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="./FormatXmlCommand.cs" subtype="Code" buildaction="Compile" /> + <File name="./EmptyFile.xml" subtype="Code" buildaction="EmbedAsResource" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="True" refto="Mono.Addins" /> + <ProjectReference type="Project" localcopy="True" refto="TextEditorLib" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + </References> +</Project>
\ No newline at end of file diff --git a/Samples/TextEditor/AssemblyInfo.cs b/Samples/TextEditor/AssemblyInfo.cs new file mode 100644 index 0000000..76d5c81 --- /dev/null +++ b/Samples/TextEditor/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using Mono.Addins; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.0.0")] + +// The following attributes specify the key for the sign of your assembly. See the +// .NET Framework documentation for more information about signing. +// This is not required, if you don't want signing let these attributes like they're. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/Samples/TextEditor/Main.cs b/Samples/TextEditor/Main.cs new file mode 100644 index 0000000..4f90b32 --- /dev/null +++ b/Samples/TextEditor/Main.cs @@ -0,0 +1,52 @@ +using System; +using Gtk; +using Mono.Addins; + +namespace TextEditor +{ + class MainClass + { + public static void Main (string[] args) + { + Application.Init (); + + AddinManager.AddinLoadError += OnLoadError; + AddinManager.AddinLoaded += OnLoad; + AddinManager.AddinUnloaded += OnUnload; + + AddinManager.Initialize ("."); + AddinManager.Registry.Update (null); + AddinManager.ExtensionChanged += OnExtensionChange; + + + MainWindow win = new MainWindow (); + + foreach (ICommand cmd in AddinManager.GetExtensionObjects ("/TextEditor/StartupCommands")) + cmd.Run (); + + win.Show (); + Application.Run (); + } + + static void OnLoadError (object s, AddinErrorEventArgs args) + { + Console.WriteLine ("Add-in error: " + args.Message); + Console.WriteLine (args.AddinId); + } + + static void OnLoad (object s, AddinEventArgs args) + { + Console.WriteLine ("Add-in loaded: " + args.AddinId); + } + + static void OnUnload (object s, AddinEventArgs args) + { + Console.WriteLine ("Add-in unloaded: " + args.AddinId); + } + + static void OnExtensionChange (object s, ExtensionEventArgs args) + { + Console.WriteLine ("Extension changed: " + args.Path); + } + } +}
\ No newline at end of file diff --git a/Samples/TextEditor/TextEditor.mdp b/Samples/TextEditor/TextEditor.mdp new file mode 100644 index 0000000..d145c62 --- /dev/null +++ b/Samples/TextEditor/TextEditor.mdp @@ -0,0 +1,34 @@ +<Project name="TextEditor" fileversion="2.0" language="C#" clr-version="Net_1_1" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../bin" assembly="TextEditor" /> + <Build debugmode="True" target="Exe" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="./bin/Release" assembly="TextEditor" /> + <Build debugmode="False" target="Exe" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="./gtk-gui/generated.cs" subtype="Code" buildaction="Compile" /> + <File name="./Main.cs" subtype="Code" buildaction="Compile" /> + <File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" /> + <File name="./gtk-gui/gui.stetic" subtype="Code" buildaction="EmbedAsResource" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="glade-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> + <ProjectReference type="Project" localcopy="True" refto="Mono.Addins" /> + <ProjectReference type="Project" localcopy="True" refto="TextEditorLib" /> + </References> + <GtkDesignInfo partialTypes="True" /> +</Project>
\ No newline at end of file diff --git a/Samples/TextEditor/gtk-gui/generated.cs b/Samples/TextEditor/gtk-gui/generated.cs new file mode 100644 index 0000000..dd4abdd --- /dev/null +++ b/Samples/TextEditor/gtk-gui/generated.cs @@ -0,0 +1,35 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace Stetic { + + + internal class Gui { + + private static bool initialized; + + internal static void Initialize() { + if ((Stetic.Gui.initialized == false)) { + Stetic.Gui.initialized = true; + } + } + } + + internal class ActionGroups { + + public static Gtk.ActionGroup GetActionGroup(System.Type type) { + return Stetic.ActionGroups.GetActionGroup(type.FullName); + } + + public static Gtk.ActionGroup GetActionGroup(string name) { + return null; + } + } +} diff --git a/Samples/TextEditor/gtk-gui/gui.stetic b/Samples/TextEditor/gtk-gui/gui.stetic new file mode 100644 index 0000000..7f73057 --- /dev/null +++ b/Samples/TextEditor/gtk-gui/gui.stetic @@ -0,0 +1,2 @@ +<stetic-interface> +</stetic-interface> diff --git a/Samples/TextEditorLib/AssemblyInfo.cs b/Samples/TextEditorLib/AssemblyInfo.cs new file mode 100644 index 0000000..e7981d7 --- /dev/null +++ b/Samples/TextEditorLib/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using Mono.Addins; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.0.0")] + +// The following attributes specify the key for the sign of your assembly. See the +// .NET Framework documentation for more information about signing. +// This is not required, if you don't want signing let these attributes like they're. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] + + + + diff --git a/Samples/TextEditorLib/Commands/CopyCommand.cs b/Samples/TextEditorLib/Commands/CopyCommand.cs new file mode 100644 index 0000000..c8dae47 --- /dev/null +++ b/Samples/TextEditorLib/Commands/CopyCommand.cs @@ -0,0 +1,14 @@ + +using System; + +namespace TextEditor +{ + public class CopyCommand: ICommand + { + public void Run () + { + Gtk.Clipboard clipboard = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false)); + TextEditorApp.MainWindow.View.Buffer.CopyClipboard (clipboard); + } + } +} diff --git a/Samples/TextEditorLib/Commands/CutCommand.cs b/Samples/TextEditorLib/Commands/CutCommand.cs new file mode 100644 index 0000000..751cac7 --- /dev/null +++ b/Samples/TextEditorLib/Commands/CutCommand.cs @@ -0,0 +1,16 @@ + +using System; + +namespace TextEditor +{ + + + public class CutCommand: ICommand + { + public void Run () + { + Gtk.Clipboard clipboard = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false)); + TextEditorApp.MainWindow.View.Buffer.CutClipboard (clipboard, true); + } + } +} diff --git a/Samples/TextEditorLib/Commands/ExitCommand.cs b/Samples/TextEditorLib/Commands/ExitCommand.cs new file mode 100644 index 0000000..314ebdf --- /dev/null +++ b/Samples/TextEditorLib/Commands/ExitCommand.cs @@ -0,0 +1,13 @@ + +using System; + +namespace TextEditor +{ + public class ExitCommand: ICommand + { + public void Run () + { + Gtk.Application.Quit (); + } + } +} diff --git a/Samples/TextEditorLib/Commands/NewCommand.cs b/Samples/TextEditorLib/Commands/NewCommand.cs new file mode 100644 index 0000000..c377618 --- /dev/null +++ b/Samples/TextEditorLib/Commands/NewCommand.cs @@ -0,0 +1,13 @@ + +using System; + +namespace TextEditor +{ + public class NewCommand: ICommand + { + public void Run () + { + TextEditorApp.NewFile (""); + } + } +} diff --git a/Samples/TextEditorLib/Commands/OpenCommand.cs b/Samples/TextEditorLib/Commands/OpenCommand.cs new file mode 100644 index 0000000..8c56415 --- /dev/null +++ b/Samples/TextEditorLib/Commands/OpenCommand.cs @@ -0,0 +1,23 @@ + +using System; +using System.IO; + +namespace TextEditor +{ + public class OpenCommand: ICommand + { + public void Run () + { + Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Open File", null, Gtk.FileChooserAction.Open);
+ fcd.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
+ fcd.AddButton (Gtk.Stock.Open, Gtk.ResponseType.Ok);
+ fcd.DefaultResponse = Gtk.ResponseType.Ok;
+ fcd.SelectMultiple = false;
+
+ Gtk.ResponseType response = (Gtk.ResponseType) fcd.Run (); + if (response == Gtk.ResponseType.Ok) + TextEditorApp.OpenFile (fcd.Filename); + fcd.Destroy (); + } + } +} diff --git a/Samples/TextEditorLib/Commands/PasteCommand.cs b/Samples/TextEditorLib/Commands/PasteCommand.cs new file mode 100644 index 0000000..6a09738 --- /dev/null +++ b/Samples/TextEditorLib/Commands/PasteCommand.cs @@ -0,0 +1,14 @@ + +using System; + +namespace TextEditor +{ + public class PasteCommand: ICommand + { + public void Run () + { + Gtk.Clipboard clipboard = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false)); + TextEditorApp.MainWindow.View.Buffer.PasteClipboard (clipboard); + } + } +} diff --git a/Samples/TextEditorLib/Commands/SaveCommand.cs b/Samples/TextEditorLib/Commands/SaveCommand.cs new file mode 100644 index 0000000..5ab9987 --- /dev/null +++ b/Samples/TextEditorLib/Commands/SaveCommand.cs @@ -0,0 +1,13 @@ + +using System; + +namespace TextEditor +{ + public class SaveCommand: ICommand + { + public void Run () + { + TextEditorApp.SaveFile (); + } + } +} diff --git a/Samples/TextEditorLib/Commands/SetupCommand.cs b/Samples/TextEditorLib/Commands/SetupCommand.cs new file mode 100644 index 0000000..2462450 --- /dev/null +++ b/Samples/TextEditorLib/Commands/SetupCommand.cs @@ -0,0 +1,14 @@ + +using System; +using Mono.Addins.Gui; + +namespace TextEditor +{ + public class SetupCommand: ICommand + { + public void Run () + { + AddinManagerWindow.Run (TextEditorApp.MainWindow); + } + } +} diff --git a/Samples/TextEditorLib/ExtensionNodes/FileTemplateNode.cs b/Samples/TextEditorLib/ExtensionNodes/FileTemplateNode.cs new file mode 100644 index 0000000..5fe93ff --- /dev/null +++ b/Samples/TextEditorLib/ExtensionNodes/FileTemplateNode.cs @@ -0,0 +1,27 @@ + +using System; +using System.IO; +using Mono.Addins; + +namespace TextEditor +{ + public class FileTemplateNode: ExtensionNode + { + [NodeAttribute] + string resource; + + [NodeAttribute] + string name; + + public string Name { + get { return name != null ? name : Id; } + } + + public virtual string GetContent () + { + using (StreamReader sr = new StreamReader(Addin.GetResource (resource))) { + return sr.ReadToEnd (); + } + } + } +} diff --git a/Samples/TextEditorLib/ExtensionNodes/MenuItemNode.cs b/Samples/TextEditorLib/ExtensionNodes/MenuItemNode.cs new file mode 100644 index 0000000..e6e0fdf --- /dev/null +++ b/Samples/TextEditorLib/ExtensionNodes/MenuItemNode.cs @@ -0,0 +1,38 @@ + +using System; +using Mono.Addins; + +namespace TextEditor +{ + [ExtensionNode ("MenuItem")] + public class MenuItemNode: MenuNode + { + [NodeAttribute] + string label; + + [NodeAttribute] + string icon; + + [NodeAttribute] + string commandType; + + static Gtk.AccelGroup accelGroup = new Gtk.AccelGroup (); + + public override Gtk.MenuItem GetMenuItem () + { + Gtk.MenuItem item; + if (icon != null) + item = new Gtk.ImageMenuItem (icon, accelGroup); + else + item = new Gtk.MenuItem (label); + item.Activated += OnClicked; + return item; + } + + void OnClicked (object s, EventArgs a) + { + ICommand command = (ICommand) Addin.CreateInstance (commandType); + command.Run (); + } + } +} diff --git a/Samples/TextEditorLib/ExtensionNodes/MenuNode.cs b/Samples/TextEditorLib/ExtensionNodes/MenuNode.cs new file mode 100644 index 0000000..bcde02d --- /dev/null +++ b/Samples/TextEditorLib/ExtensionNodes/MenuNode.cs @@ -0,0 +1,13 @@ + +using System; +using Mono.Addins; + +namespace TextEditor +{ + public abstract class MenuNode: ExtensionNode + { + // Abstract method to be implemented by subclasses, and which + // should return a menu item. + public abstract Gtk.MenuItem GetMenuItem (); + } +} diff --git a/Samples/TextEditorLib/ExtensionNodes/MenuSeparatorNode.cs b/Samples/TextEditorLib/ExtensionNodes/MenuSeparatorNode.cs new file mode 100644 index 0000000..bfd6ce6 --- /dev/null +++ b/Samples/TextEditorLib/ExtensionNodes/MenuSeparatorNode.cs @@ -0,0 +1,15 @@ + +using System; +using Mono.Addins; + +namespace TextEditor +{ + [ExtensionNode ("MenuSeparator")] + public class MenuSeparatorNode: MenuNode + { + public override Gtk.MenuItem GetMenuItem () + { + return new Gtk.SeparatorMenuItem (); + } + } +} diff --git a/Samples/TextEditorLib/ExtensionNodes/SubmenuNode.cs b/Samples/TextEditorLib/ExtensionNodes/SubmenuNode.cs new file mode 100644 index 0000000..d211445 --- /dev/null +++ b/Samples/TextEditorLib/ExtensionNodes/SubmenuNode.cs @@ -0,0 +1,26 @@ + +using System; +using Mono.Addins; + +namespace TextEditor +{ + [ExtensionNode ("Menu")] + [ExtensionNodeChild (typeof(MenuItemNode))] + [ExtensionNodeChild (typeof(MenuSeparatorNode))] + [ExtensionNodeChild (typeof(SubmenuNode))] + public class SubmenuNode: MenuNode + { + [NodeAttribute] + string label; + + public override Gtk.MenuItem GetMenuItem () + { + Gtk.MenuItem it = new Gtk.MenuItem (label); + Gtk.Menu submenu = new Gtk.Menu (); + foreach (MenuNode node in ChildNodes) + submenu.Insert (node.GetMenuItem (), -1); + it.Submenu = submenu; + return it; + } + } +} diff --git a/Samples/TextEditorLib/ExtensionNodes/TemplateCategoryNode.cs b/Samples/TextEditorLib/ExtensionNodes/TemplateCategoryNode.cs new file mode 100644 index 0000000..3161eff --- /dev/null +++ b/Samples/TextEditorLib/ExtensionNodes/TemplateCategoryNode.cs @@ -0,0 +1,21 @@ + +using System; +using Mono.Addins; + +namespace TextEditor +{ + public class TemplateCategoryNode: ExtensionNode + { + [NodeAttribute] + string name; + + public string Name { + get { + if (name != null && name.Length > 0) + return name; + else + return Id; + } + } + } +} diff --git a/Samples/TextEditorLib/ExtensionNodes/ToolButtonNode.cs b/Samples/TextEditorLib/ExtensionNodes/ToolButtonNode.cs new file mode 100644 index 0000000..4c3c7ec --- /dev/null +++ b/Samples/TextEditorLib/ExtensionNodes/ToolButtonNode.cs @@ -0,0 +1,28 @@ + +using System; +using Mono.Addins; + +namespace TextEditor +{ + public class ToolButtonNode: ToolbarNode + { + [NodeAttribute] + string icon; + + [NodeAttribute] + string commandType; + + public override Gtk.ToolItem GetToolItem () + { + Gtk.ToolButton but = new Gtk.ToolButton (icon); + but.Clicked += OnClicked; + return but; + } + + void OnClicked (object s, EventArgs a) + { + ICommand command = (ICommand) Addin.CreateInstance (commandType); + command.Run (); + } + } +} diff --git a/Samples/TextEditorLib/ExtensionNodes/ToolSeparatorNode.cs b/Samples/TextEditorLib/ExtensionNodes/ToolSeparatorNode.cs new file mode 100644 index 0000000..b46106b --- /dev/null +++ b/Samples/TextEditorLib/ExtensionNodes/ToolSeparatorNode.cs @@ -0,0 +1,13 @@ + +using System; + +namespace TextEditor +{ + public class ToolSeparatorNode: ToolbarNode + { + public override Gtk.ToolItem GetToolItem () + { + return new Gtk.SeparatorToolItem (); + } + } +} diff --git a/Samples/TextEditorLib/ExtensionNodes/ToolbarNode.cs b/Samples/TextEditorLib/ExtensionNodes/ToolbarNode.cs new file mode 100644 index 0000000..57b647a --- /dev/null +++ b/Samples/TextEditorLib/ExtensionNodes/ToolbarNode.cs @@ -0,0 +1,11 @@ + +using System; +using Mono.Addins; + +namespace TextEditor +{ + public abstract class ToolbarNode: ExtensionNode + { + public abstract Gtk.ToolItem GetToolItem (); + } +} diff --git a/Samples/TextEditorLib/ICommand.cs b/Samples/TextEditorLib/ICommand.cs new file mode 100644 index 0000000..0ca66bb --- /dev/null +++ b/Samples/TextEditorLib/ICommand.cs @@ -0,0 +1,12 @@ + +using System; +using Mono.Addins; + +namespace TextEditor +{ + [TypeExtensionPoint ("/TextEditor/StartupCommands")] + public interface ICommand + { + void Run (); + } +} diff --git a/Samples/TextEditorLib/MainWindow.cs b/Samples/TextEditorLib/MainWindow.cs new file mode 100644 index 0000000..cc63e38 --- /dev/null +++ b/Samples/TextEditorLib/MainWindow.cs @@ -0,0 +1,107 @@ +using System; +using Gtk; +using Mono.Addins; +using TextEditor; + +public partial class MainWindow: Gtk.Window +{ + internal static MainWindow Instance; + + public MainWindow (): base (Gtk.WindowType.Toplevel) + { + Instance = this; + Build (); + + AddinManager.ExtensionChanged += OnExtensionChanged; + BuildToolbar (); + BuildMenu (); + } + + public void ConsoleWrite (string txt) + { + console.Show (); + consoleView.Buffer.Text += txt; + consoleView.ScrollToMark (consoleView.Buffer.InsertMark, 0d, false, 0d, 0d); + } + + void BuildToolbar () + { + // Clean the toolbar + foreach (Gtk.Widget w in toolbar.Children) + toolbar.Remove (w); + + // Add the new buttons + foreach (ToolbarNode node in AddinManager.GetExtensionNodes ("/TextEditor/ToolbarButtons")) + toolbar.Insert (node.GetToolItem (), -1); + + toolbar.ShowAll (); + } + + void BuildMenu () + { + // Clean the toolbar + foreach (Gtk.Widget w in menubar.Children) + menubar.Remove (w); + + // Add the new buttons + foreach (MenuNode node in AddinManager.GetExtensionNodes ("/TextEditor/MainMenu")) + menubar.Insert (node.GetMenuItem (), -1); + + // Create the menu for creating documents from templates + + Gtk.Menu menu = BuildTemplateItems (AddinManager.GetExtensionNodes ("/TextEditor/Templates")); + Gtk.MenuItem it = new MenuItem ("New From Template"); + it.Submenu = menu; + + Gtk.MenuItem men = (Gtk.MenuItem) menubar.Children [0]; + ((Gtk.Menu)men.Submenu).Insert (it, 1); + + menubar.ShowAll (); + } + + Gtk.Menu BuildTemplateItems (ExtensionNodeList nodes) + { + Gtk.Menu menu = new Gtk.Menu (); + foreach (ExtensionNode tn in nodes) { + Gtk.MenuItem item; + if (tn is TemplateCategoryNode) { + TemplateCategoryNode cat = (TemplateCategoryNode) tn; + item = new Gtk.MenuItem (cat.Name); + item.Submenu = BuildTemplateItems (cat.ChildNodes); + } + else { + FileTemplateNode t = (FileTemplateNode) tn; + item = new Gtk.MenuItem (t.Name); + item.Activated += delegate { + TextEditorApp.NewFile (t.GetContent ()); + }; + } + menu.Insert (item, -1); + } + return menu; + } + + + void OnExtensionChanged (object o, ExtensionEventArgs args) + { + if (args.PathChanged ("/TextEditor/ToolbarButtons")) + BuildToolbar (); + else if (args.PathChanged ("/TextEditor/MainMenu")) + BuildMenu (); + } + + protected void OnDeleteEvent (object sender, DeleteEventArgs a) + { + Application.Quit (); + a.RetVal = true; + } + + protected virtual void OnButton1Clicked(object sender, System.EventArgs e) + { + console.Hide (); + } + + public Gtk.TextView View { + get { return textview; } + } +} diff --git a/Samples/TextEditorLib/OpenFileCondition.cs b/Samples/TextEditorLib/OpenFileCondition.cs new file mode 100644 index 0000000..f3356b4 --- /dev/null +++ b/Samples/TextEditorLib/OpenFileCondition.cs @@ -0,0 +1,33 @@ + +using System; +using System.IO; +using Mono.Addins; + +namespace TextEditor +{ + public class OpenFileCondition: ConditionType + { + public OpenFileCondition () + { + // It's important to notify changes in the status of a condition, + // to make sure the extension points are properly updated. + TextEditorApp.OpenFileChanged += delegate { + NotifyChanged (); + }; + } + + public override bool Evaluate (NodeElement conditionNode) + { + // Get the required extension value from an attribute, + // and check againts the extension of the currently open document + string val = conditionNode.GetAttribute ("extension"); + if (val.Length > 0) { + string ext = Path.GetExtension (TextEditorApp.OpenFileName); + foreach (string requiredExtension in val.Split (',')) + if (ext == "." + requiredExtension) + return true; + } + return false; + } + } +} diff --git a/Samples/TextEditorLib/Templates/ChangeLogTemplate.txt b/Samples/TextEditorLib/Templates/ChangeLogTemplate.txt new file mode 100644 index 0000000..589bf18 --- /dev/null +++ b/Samples/TextEditorLib/Templates/ChangeLogTemplate.txt @@ -0,0 +1,4 @@ +yyyy-mm-dd Developer name <some@email.com> + + * File name: change done + diff --git a/Samples/TextEditorLib/Templates/DotConfigTemplate.txt b/Samples/TextEditorLib/Templates/DotConfigTemplate.txt new file mode 100644 index 0000000..d2437a1 --- /dev/null +++ b/Samples/TextEditorLib/Templates/DotConfigTemplate.txt @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + +</configuration> diff --git a/Samples/TextEditorLib/Templates/TextEditor.addin.xml b/Samples/TextEditorLib/Templates/TextEditor.addin.xml new file mode 100644 index 0000000..ad75f08 --- /dev/null +++ b/Samples/TextEditorLib/Templates/TextEditor.addin.xml @@ -0,0 +1,62 @@ +<Addin namespace="TextEditor" id="Core" version="1.0" isroot="true"> + + <Runtime> + <Import assembly="TextEditor.exe"/> + <Import assembly="TextEditorLib.dll"/> + </Runtime> + + <ConditionType id="OpenFile" type="TextEditor.OpenFileCondition" /> + + <ExtensionPoint path = "/TextEditor/ToolbarButtons"> + <ExtensionNode name="ToolButton" type="TextEditor.ToolButtonNode"/> + <ExtensionNode name="ToolSeparator" type="TextEditor.ToolSeparatorNode"/> + </ExtensionPoint> + + <ExtensionPoint path = "/TextEditor/MainMenu"> + <ExtensionNode type="TextEditor.SubmenuNode"/> + </ExtensionPoint> + + <ExtensionPoint path = "/TextEditor/Templates"> + <ExtensionNode name="Category" type="TextEditor.TemplateCategoryNode"> + <ExtensionNode name="FileTemplate" type="TextEditor.FileTemplateNode" /> + </ExtensionNode> + <ExtensionNode name="FileTemplate" type="TextEditor.FileTemplateNode" /> + </ExtensionPoint> + + <Extension path = "/TextEditor/ToolbarButtons"> + <ToolButton icon="gtk-new" commandType="TextEditor.NewCommand" /> + <ToolButton icon="gtk-open" commandType="TextEditor.OpenCommand" /> + <ToolButton icon="gtk-save" commandType="TextEditor.SaveCommand" /> + <ToolSeparator /> + <ToolButton icon="gtk-cut" commandType="TextEditor.CutCommand" /> + <ToolButton icon="gtk-copy" commandType="TextEditor.CopyCommand" /> + <ToolButton icon="gtk-paste" commandType="TextEditor.PasteCommand" /> + </Extension> + + <Extension path = "/TextEditor/MainMenu"> + <Menu id="File" label="File"> + <MenuItem id="New" icon="gtk-new" commandType="TextEditor.NewCommand" /> + <MenuItem id="Open" icon="gtk-open" commandType="TextEditor.OpenCommand" /> + <MenuItem id="Save" icon="gtk-save" commandType="TextEditor.SaveCommand" /> + <MenuSeparator /> + <MenuItem id="Quit" icon="gtk-quit" commandType="TextEditor.ExitCommand" /> + </Menu> + <Menu id="Edit" label="Edit"> + <MenuItem id="Cut" icon="gtk-cut" commandType="TextEditor.CutCommand" /> + <MenuItem id="Copy" icon="gtk-copy" commandType="TextEditor.CopyCommand" /> + <MenuItem id="Paste" icon="gtk-paste" commandType="TextEditor.PasteCommand" /> + </Menu> + <Menu id="Tools" label="Tools"> + <MenuItem id="Setup" label="Add-in Manager" commandType="TextEditor.SetupCommand" /> + </Menu> + </Extension> + + <Extension path = "/TextEditor/Templates"> + <Category id="Development" > + <FileTemplate name="ChangeLog" resource="ChangeLogTemplate.txt" /> + <FileTemplate name=".config file" resource="DotConfigTemplate.txt" /> + <FileTemplate name="Work report" resource="WorkReport.txt" /> + </Category> + </Extension> + +</Addin> diff --git a/Samples/TextEditorLib/Templates/WorkReport.txt b/Samples/TextEditorLib/Templates/WorkReport.txt new file mode 100644 index 0000000..b3b53a0 --- /dev/null +++ b/Samples/TextEditorLib/Templates/WorkReport.txt @@ -0,0 +1,8 @@ + +Work done last week: +* ... +* ... + +Work to do next week: +* ... +* ...
\ No newline at end of file diff --git a/Samples/TextEditorLib/TextEditorApp.cs b/Samples/TextEditorLib/TextEditorApp.cs new file mode 100644 index 0000000..1401143 --- /dev/null +++ b/Samples/TextEditorLib/TextEditorApp.cs @@ -0,0 +1,74 @@ + +using System; +using System.IO; + +namespace TextEditor +{ + public class TextEditorApp + { + static string openFile = ""; + + private TextEditorApp() + { + } + + public static string OpenFileName { + get { return openFile; } + } + + public static MainWindow MainWindow { + get { return MainWindow.Instance; } + } + + public static void OpenFile (string file) + { + using (StreamReader sr = new StreamReader (file)) { + MainWindow.View.Buffer.Text = sr.ReadToEnd (); + } + SetOpenFile (file); + } + + public static void SaveFile () + { + if (openFile == "") { + Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Save File", null, Gtk.FileChooserAction.Save);
+ fcd.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
+ fcd.AddButton (Gtk.Stock.Open, Gtk.ResponseType.Ok);
+ fcd.DefaultResponse = Gtk.ResponseType.Ok;
+ fcd.SelectMultiple = false;
+
+ Gtk.ResponseType response = (Gtk.ResponseType) fcd.Run (); + if (response != Gtk.ResponseType.Ok) { + fcd.Destroy (); + return; + } + + SetOpenFile (fcd.Filename); + fcd.Destroy (); + } + using (StreamWriter sr = new StreamWriter (openFile)) { + sr.Write (TextEditorApp.MainWindow.View.Buffer.Text); + } + } + + public static void NewFile (string content) + { + SetOpenFile (""); + MainWindow.View.Buffer.Text = content; + } + + static void SetOpenFile (string file) + { + openFile = file; + if (file.Length > 0) + MainWindow.Title = Path.GetFileName (file); + else + MainWindow.Title = "New File"; + + if (OpenFileChanged != null) + OpenFileChanged (null, EventArgs.Empty); + } + + public static event EventHandler OpenFileChanged; + } +} diff --git a/Samples/TextEditorLib/TextEditorLib.mdp b/Samples/TextEditorLib/TextEditorLib.mdp new file mode 100644 index 0000000..4226993 --- /dev/null +++ b/Samples/TextEditorLib/TextEditorLib.mdp @@ -0,0 +1,57 @@ +<Project name="TextEditorLib" fileversion="2.0" language="C#" clr-version="Net_1_1" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../bin" assembly="TextEditorLib" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="./bin/Release" assembly="TextEditorLib" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" /> + <File name="./ICommand.cs" subtype="Code" buildaction="Compile" /> + <File name="./gtk-gui/gui.stetic" subtype="Code" buildaction="EmbedAsResource" /> + <File name="./gtk-gui/generated.cs" subtype="Code" buildaction="Compile" /> + <File name="./MainWindow.cs" subtype="Code" buildaction="Compile" /> + <File name="./gtk-gui/MainWindow.cs" subtype="Code" buildaction="Compile" /> + <File name="./TextEditorApp.cs" subtype="Code" buildaction="Compile" /> + <File name="./Commands/CopyCommand.cs" subtype="Code" buildaction="Compile" /> + <File name="./Commands/CutCommand.cs" subtype="Code" buildaction="Compile" /> + <File name="./Commands/NewCommand.cs" subtype="Code" buildaction="Compile" /> + <File name="./Commands/OpenCommand.cs" subtype="Code" buildaction="Compile" /> + <File name="./Commands/PasteCommand.cs" subtype="Code" buildaction="Compile" /> + <File name="./Commands/SaveCommand.cs" subtype="Code" buildaction="Compile" /> + <File name="./ExtensionNodes/MenuItemNode.cs" subtype="Code" buildaction="Compile" /> + <File name="./ExtensionNodes/MenuSeparatorNode.cs" subtype="Code" buildaction="Compile" /> + <File name="./ExtensionNodes/SubmenuNode.cs" subtype="Code" buildaction="Compile" /> + <File name="./ExtensionNodes/ToolButtonNode.cs" subtype="Code" buildaction="Compile" /> + <File name="./ExtensionNodes/ToolSeparatorNode.cs" subtype="Code" buildaction="Compile" /> + <File name="./ExtensionNodes/MenuNode.cs" subtype="Code" buildaction="Compile" /> + <File name="./ExtensionNodes/ToolbarNode.cs" subtype="Code" buildaction="Compile" /> + <File name="./Commands/ExitCommand.cs" subtype="Code" buildaction="Compile" /> + <File name="./OpenFileCondition.cs" subtype="Code" buildaction="Compile" /> + <File name="./Templates/ChangeLogTemplate.txt" subtype="Code" buildaction="EmbedAsResource" /> + <File name="./Templates/DotConfigTemplate.txt" subtype="Code" buildaction="EmbedAsResource" /> + <File name="./Templates/TextEditor.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="./Templates/WorkReport.txt" subtype="Code" buildaction="EmbedAsResource" /> + <File name="./ExtensionNodes/TemplateCategoryNode.cs" subtype="Code" buildaction="Compile" /> + <File name="./ExtensionNodes/FileTemplateNode.cs" subtype="Code" buildaction="Compile" /> + <File name="./Commands/SetupCommand.cs" subtype="Code" buildaction="Compile" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="True" refto="Mono.Addins" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> + <ProjectReference type="Project" localcopy="True" refto="Mono.Addins.Setup" /> + <ProjectReference type="Project" localcopy="True" refto="Mono.Addins.Gui" /> + </References> + <GtkDesignInfo partialTypes="True" /> +</Project>
\ No newline at end of file diff --git a/Samples/TextEditorLib/gtk-gui/MainWindow.cs b/Samples/TextEditorLib/gtk-gui/MainWindow.cs new file mode 100644 index 0000000..d9da4a7 --- /dev/null +++ b/Samples/TextEditorLib/gtk-gui/MainWindow.cs @@ -0,0 +1,183 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + + + +public partial class MainWindow { + + private Gtk.VBox vbox2; + + private Gtk.MenuBar menubar; + + private Gtk.Toolbar toolbar; + + private Gtk.ScrolledWindow scrolledwindow1; + + private Gtk.TextView textview; + + private Gtk.VBox console; + + private Gtk.HBox hbox1; + + private Gtk.Label label1; + + private Gtk.Button button1; + + private Gtk.ScrolledWindow scrolledwindow2; + + private Gtk.TextView consoleView; + + private Gtk.Statusbar statusbar1; + + protected virtual void Build() { + Stetic.Gui.Initialize(); + // Widget MainWindow + Gtk.UIManager w1 = new Gtk.UIManager(); + Gtk.ActionGroup w2 = new Gtk.ActionGroup("Default"); + w1.InsertActionGroup(w2, 0); + this.AddAccelGroup(w1.AccelGroup); + this.Name = "MainWindow"; + this.Title = Mono.Unix.Catalog.GetString("Text Editor"); + this.WindowPosition = ((Gtk.WindowPosition)(4)); + // Container child MainWindow.Gtk.Container+ContainerChild + this.vbox2 = new Gtk.VBox(); + this.vbox2.Name = "vbox2"; + // Container child vbox2.Gtk.Box+BoxChild + w1.AddUiFromString("<ui><menubar name='menubar'/></ui>"); + this.menubar = ((Gtk.MenuBar)(w1.GetWidget("/menubar"))); + this.menubar.Name = "menubar"; + this.vbox2.Add(this.menubar); + Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.vbox2[this.menubar])); + w3.Position = 0; + w3.Expand = false; + w3.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + w1.AddUiFromString("<ui><toolbar name='toolbar'/></ui>"); + this.toolbar = ((Gtk.Toolbar)(w1.GetWidget("/toolbar"))); + this.toolbar.Name = "toolbar"; + this.toolbar.ShowArrow = false; + this.toolbar.Tooltips = true; + this.toolbar.ToolbarStyle = ((Gtk.ToolbarStyle)(0)); + this.toolbar.IconSize = ((Gtk.IconSize)(3)); + this.vbox2.Add(this.toolbar); + Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vbox2[this.toolbar])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + this.scrolledwindow1 = new Gtk.ScrolledWindow(); + this.scrolledwindow1.CanFocus = true; + this.scrolledwindow1.Name = "scrolledwindow1"; + this.scrolledwindow1.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow1.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow1.ShadowType = ((Gtk.ShadowType)(1)); + // Container child scrolledwindow1.Gtk.Container+ContainerChild + this.textview = new Gtk.TextView(); + this.textview.CanFocus = true; + this.textview.Name = "textview"; + this.scrolledwindow1.Add(this.textview); + this.vbox2.Add(this.scrolledwindow1); + Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.vbox2[this.scrolledwindow1])); + w6.Position = 2; + // Container child vbox2.Gtk.Box+BoxChild + this.console = new Gtk.VBox(); + this.console.Name = "console"; + this.console.Spacing = 6; + this.console.BorderWidth = ((uint)(6)); + // Container child console.Gtk.Box+BoxChild + this.hbox1 = new Gtk.HBox(); + this.hbox1.Name = "hbox1"; + // Container child hbox1.Gtk.Box+BoxChild + this.label1 = new Gtk.Label(); + this.label1.Name = "label1"; + this.label1.Xalign = 0F; + this.label1.LabelProp = Mono.Unix.Catalog.GetString("Console"); + this.hbox1.Add(this.label1); + Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.hbox1[this.label1])); + w7.Position = 0; + w7.Expand = false; + w7.Fill = false; + // Container child hbox1.Gtk.Box+BoxChild + this.button1 = new Gtk.Button(); + this.button1.WidthRequest = 27; + this.button1.HeightRequest = 20; + this.button1.Name = "button1"; + this.button1.UseUnderline = true; + this.button1.Relief = ((Gtk.ReliefStyle)(2)); + // Container child button1.Gtk.Container+ContainerChild + Gtk.Alignment w8 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F); + w8.Name = "GtkAlignment"; + // Container child GtkAlignment.Gtk.Container+ContainerChild + Gtk.HBox w9 = new Gtk.HBox(); + w9.Name = "GtkHBox"; + w9.Spacing = 2; + // Container child GtkHBox.Gtk.Container+ContainerChild + Gtk.Image w10 = new Gtk.Image(); + w10.Name = "image11"; + w10.Pixbuf = Gtk.IconTheme.Default.LoadIcon("gtk-close", 16, 0); + w9.Add(w10); + // Container child GtkHBox.Gtk.Container+ContainerChild + Gtk.Label w12 = new Gtk.Label(); + w12.Name = "GtkLabel1"; + w12.LabelProp = ""; + w9.Add(w12); + w8.Add(w9); + this.button1.Add(w8); + this.hbox1.Add(this.button1); + Gtk.Box.BoxChild w16 = ((Gtk.Box.BoxChild)(this.hbox1[this.button1])); + w16.PackType = ((Gtk.PackType)(1)); + w16.Position = 1; + w16.Expand = false; + w16.Fill = false; + this.console.Add(this.hbox1); + Gtk.Box.BoxChild w17 = ((Gtk.Box.BoxChild)(this.console[this.hbox1])); + w17.Position = 0; + w17.Expand = false; + w17.Fill = false; + // Container child console.Gtk.Box+BoxChild + this.scrolledwindow2 = new Gtk.ScrolledWindow(); + this.scrolledwindow2.CanFocus = true; + this.scrolledwindow2.Name = "scrolledwindow2"; + this.scrolledwindow2.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow2.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow2.ShadowType = ((Gtk.ShadowType)(1)); + // Container child scrolledwindow2.Gtk.Container+ContainerChild + this.consoleView = new Gtk.TextView(); + this.consoleView.CanFocus = true; + this.consoleView.Name = "consoleView"; + this.scrolledwindow2.Add(this.consoleView); + this.console.Add(this.scrolledwindow2); + Gtk.Box.BoxChild w19 = ((Gtk.Box.BoxChild)(this.console[this.scrolledwindow2])); + w19.Position = 1; + this.vbox2.Add(this.console); + Gtk.Box.BoxChild w20 = ((Gtk.Box.BoxChild)(this.vbox2[this.console])); + w20.Position = 3; + w20.Expand = false; + w20.Fill = false; + // Container child vbox2.Gtk.Box+BoxChild + this.statusbar1 = new Gtk.Statusbar(); + this.statusbar1.Name = "statusbar1"; + this.statusbar1.Spacing = 2; + this.vbox2.Add(this.statusbar1); + Gtk.Box.BoxChild w21 = ((Gtk.Box.BoxChild)(this.vbox2[this.statusbar1])); + w21.Position = 4; + w21.Expand = false; + w21.Fill = false; + this.Add(this.vbox2); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 586; + this.DefaultHeight = 356; + this.Show(); + this.DeleteEvent += new Gtk.DeleteEventHandler(this.OnDeleteEvent); + this.button1.Clicked += new System.EventHandler(this.OnButton1Clicked); + } +} diff --git a/Samples/TextEditorLib/gtk-gui/generated.cs b/Samples/TextEditorLib/gtk-gui/generated.cs new file mode 100644 index 0000000..dd4abdd --- /dev/null +++ b/Samples/TextEditorLib/gtk-gui/generated.cs @@ -0,0 +1,35 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace Stetic { + + + internal class Gui { + + private static bool initialized; + + internal static void Initialize() { + if ((Stetic.Gui.initialized == false)) { + Stetic.Gui.initialized = true; + } + } + } + + internal class ActionGroups { + + public static Gtk.ActionGroup GetActionGroup(System.Type type) { + return Stetic.ActionGroups.GetActionGroup(type.FullName); + } + + public static Gtk.ActionGroup GetActionGroup(string name) { + return null; + } + } +} diff --git a/Samples/TextEditorLib/gtk-gui/gui.stetic b/Samples/TextEditorLib/gtk-gui/gui.stetic new file mode 100644 index 0000000..14ecf74 --- /dev/null +++ b/Samples/TextEditorLib/gtk-gui/gui.stetic @@ -0,0 +1,172 @@ +<?xml version="1.0" encoding="utf-8"?> +<stetic-interface> + <widget class="Gtk.Window" id="MainWindow" design-size="586 356"> + <action-group name="Default" /> + <property name="MemberName" /> + <property name="GeneratePublic">True</property> + <property name="Title" translatable="yes">Text Editor</property> + <property name="WindowPosition">CenterOnParent</property> + <signal name="DeleteEvent" handler="OnDeleteEvent" /> + <child> + <widget class="Gtk.VBox" id="vbox2"> + <property name="MemberName" /> + <property name="GeneratePublic">True</property> + <child> + <widget class="Gtk.MenuBar" id="menubar"> + <property name="MemberName" /> + <property name="GeneratePublic">True</property> + <node name="menubar" type="Menubar" /> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Toolbar" id="toolbar"> + <property name="MemberName" /> + <property name="GeneratePublic">True</property> + <property name="ShowArrow">False</property> + <property name="Tooltips">True</property> + <property name="ButtonStyle">Icons</property> + <property name="IconSize">LargeToolbar</property> + <node name="toolbar" type="Toolbar" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.ScrolledWindow" id="scrolledwindow1"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="GeneratePublic">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TextView" id="textview"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="GeneratePublic">True</property> + <property name="Text" translatable="yes" /> + </widget> + </child> + </widget> + <packing> + <property name="Position">2</property> + <property name="AutoSize">True</property> + </packing> + </child> + <child> + <widget class="Gtk.VBox" id="console"> + <property name="MemberName" /> + <property name="GeneratePublic">True</property> + <property name="Spacing">6</property> + <property name="BorderWidth">6</property> + <child> + <widget class="Gtk.HBox" id="hbox1"> + <property name="MemberName" /> + <property name="GeneratePublic">True</property> + <child> + <widget class="Gtk.Label" id="label1"> + <property name="MemberName" /> + <property name="GeneratePublic">True</property> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Console</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="button1"> + <property name="MemberName" /> + <property name="WidthRequest">27</property> + <property name="HeightRequest">20</property> + <property name="GeneratePublic">True</property> + <property name="Type">TextAndIcon</property> + <property name="Icon">stock:gtk-close Menu</property> + <property name="Label" /> + <property name="UseUnderline">True</property> + <property name="IsDialogButton">False</property> + <property name="Relief">None</property> + <signal name="Clicked" handler="OnButton1Clicked" /> + </widget> + <packing> + <property name="PackType">End</property> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.ScrolledWindow" id="scrolledwindow2"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="GeneratePublic">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TextView" id="consoleView"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="GeneratePublic">True</property> + <property name="Text" translatable="yes" /> + </widget> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">3</property> + <property name="AutoSize">False</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Statusbar" id="statusbar1"> + <property name="MemberName" /> + <property name="GeneratePublic">True</property> + <property name="Spacing">2</property> + <child> + <placeholder /> + </child> + <child> + <placeholder /> + </child> + </widget> + <packing> + <property name="Position">4</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> +</stetic-interface>
\ No newline at end of file diff --git a/Samples/WriterService.SampleExtender/AssemblyInfo.cs b/Samples/WriterService.SampleExtender/AssemblyInfo.cs new file mode 100644 index 0000000..af4e275 --- /dev/null +++ b/Samples/WriterService.SampleExtender/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes specify the key for the sign of your assembly. See the +// .NET Framework documentation for more information about signing. +// This is not required, if you don't want signing let these attributes like they're. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/Samples/WriterService.SampleExtender/MyWriter.cs b/Samples/WriterService.SampleExtender/MyWriter.cs new file mode 100644 index 0000000..1e599b6 --- /dev/null +++ b/Samples/WriterService.SampleExtender/MyWriter.cs @@ -0,0 +1,21 @@ +using System; +using WriterService; + +namespace SampleExtender +{ + public class MyWriter: IWriter + { + public string Write () + { + return "Some writer"; + } + } + + public class DebugWriter: IWriter + { + public string Write () + { + return "Some debug output"; + } + } +} diff --git a/Samples/WriterService.SampleExtender/SampleExtender.addin.xml b/Samples/WriterService.SampleExtender/SampleExtender.addin.xml new file mode 100644 index 0000000..e010776 --- /dev/null +++ b/Samples/WriterService.SampleExtender/SampleExtender.addin.xml @@ -0,0 +1,18 @@ +<Addin> + + <Runtime> + <Import assembly="SampleExtender.dll"/> + </Runtime> + + <Dependencies> + <Addin id="WriterService" version="0.1.0" /> + </Dependencies> + + <Extension path = "/WriterService/Writers"> + <Writer type="SampleExtender.MyWriter" /> + <Condition id="HasFlag" value="debug"> + <Writer type="SampleExtender.DebugWriter" /> + </Condition> + </Extension> + +</Addin> diff --git a/Samples/WriterService.SampleExtender/WriterService.SampleExtender.mdp b/Samples/WriterService.SampleExtender/WriterService.SampleExtender.mdp new file mode 100644 index 0000000..378ec87 --- /dev/null +++ b/Samples/WriterService.SampleExtender/WriterService.SampleExtender.mdp @@ -0,0 +1,25 @@ +<Project name="WriterService.SampleExtender" fileversion="2.0" language="C#" clr-version="Net_1_1" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../bin" assembly="SampleExtender" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="./bin/Release" assembly="SampleExtender" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="./MyWriter.cs" subtype="Code" buildaction="Compile" /> + <File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" /> + <File name="./SampleExtender.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="True" refto="WriterService" /> + </References> +</Project>
\ No newline at end of file diff --git a/Samples/WriterService/AssemblyInfo.cs b/Samples/WriterService/AssemblyInfo.cs new file mode 100644 index 0000000..af4e275 --- /dev/null +++ b/Samples/WriterService/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes specify the key for the sign of your assembly. See the +// .NET Framework documentation for more information about signing. +// This is not required, if you don't want signing let these attributes like they're. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/Samples/WriterService/FlagsCondition.cs b/Samples/WriterService/FlagsCondition.cs new file mode 100644 index 0000000..93833e2 --- /dev/null +++ b/Samples/WriterService/FlagsCondition.cs @@ -0,0 +1,22 @@ + +using System; +using Mono.Addins; + +namespace WriterService +{ + public class FlagsCondition: ConditionType + { + string[] flags; + + public FlagsCondition (string[] flags) + { + this.flags = flags; + } + + public override bool Evaluate (NodeElement attributes) + { + string flag = attributes.GetAttribute ("value"); + return Array.IndexOf (flags, flag) != -1; + } + } +} diff --git a/Samples/WriterService/IWriter.cs b/Samples/WriterService/IWriter.cs new file mode 100644 index 0000000..5df34ae --- /dev/null +++ b/Samples/WriterService/IWriter.cs @@ -0,0 +1,10 @@ + +using System; + +namespace WriterService +{ + public interface IWriter + { + string Write (); + } +} diff --git a/Samples/WriterService/MyClass.cs b/Samples/WriterService/MyClass.cs new file mode 100644 index 0000000..50a02ea --- /dev/null +++ b/Samples/WriterService/MyClass.cs @@ -0,0 +1,7 @@ +// project created on 14/03/2007 at 00:07 +using System; + +public class MyClass +{ + +}
\ No newline at end of file diff --git a/Samples/WriterService/WriterManager.cs b/Samples/WriterService/WriterManager.cs new file mode 100644 index 0000000..12be6a7 --- /dev/null +++ b/Samples/WriterService/WriterManager.cs @@ -0,0 +1,34 @@ + +using System; +using Mono.Addins; + +namespace WriterService +{ + public class WriterManager + { + ExtensionContext ctx; + public event EventHandler Changed; + + public WriterManager (string[] flags) + { + // Create a new extension context + ctx = AddinManager.CreateExtensionContext (); + + // Register the flags condition in the new context + FlagsCondition condition = new FlagsCondition (flags); + ctx.RegisterCondition ("HasFlag", condition); + + ctx.AddExtensionNodeHandler ("/WriterService/Writers", delegate { + if (Changed != null) + Changed (this, EventArgs.Empty); + }); + } + + public IWriter[] GetWriters () + { + // Returns the IWriter objects registered in the Writers path + return (IWriter[]) ctx.GetExtensionObjects ("/WriterService/Writers", typeof(IWriter)); + } + } +} + diff --git a/Samples/WriterService/WriterService.addin.xml b/Samples/WriterService/WriterService.addin.xml new file mode 100644 index 0000000..e574b11 --- /dev/null +++ b/Samples/WriterService/WriterService.addin.xml @@ -0,0 +1,12 @@ +<Addin id = "WriterService" version = "0.1.0" isroot="true"> + + <Runtime> + <Import assembly="WriterService.dll"/> + </Runtime> + + <ExtensionPoint path = "/WriterService/Writers"> + <ExtensionNode name="Writer" objectType="WriterService.IWriter"/> + <Condition id="HasFlag" type="SampleAddin.SampleCondition" /> + </ExtensionPoint> + +</Addin> diff --git a/Samples/WriterService/WriterService.mdp b/Samples/WriterService/WriterService.mdp new file mode 100644 index 0000000..ec68c76 --- /dev/null +++ b/Samples/WriterService/WriterService.mdp @@ -0,0 +1,27 @@ +<Project name="WriterService" fileversion="2.0" language="C#" clr-version="Net_1_1" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../bin" assembly="WriterService" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="./bin/Release" assembly="SampleAddin" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" /> + <File name="./WriterService.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="./IWriter.cs" subtype="Code" buildaction="Compile" /> + <File name="./WriterManager.cs" subtype="Code" buildaction="Compile" /> + <File name="./FlagsCondition.cs" subtype="Code" buildaction="Compile" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="True" refto="Mono.Addins" /> + </References> +</Project>
\ No newline at end of file diff --git a/Samples/WriterServiceHost/AssemblyInfo.cs b/Samples/WriterServiceHost/AssemblyInfo.cs new file mode 100644 index 0000000..af4e275 --- /dev/null +++ b/Samples/WriterServiceHost/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes specify the key for the sign of your assembly. See the +// .NET Framework documentation for more information about signing. +// This is not required, if you don't want signing let these attributes like they're. +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/Samples/WriterServiceHost/Main.cs b/Samples/WriterServiceHost/Main.cs new file mode 100644 index 0000000..14e0681 --- /dev/null +++ b/Samples/WriterServiceHost/Main.cs @@ -0,0 +1,25 @@ +using System; +using WriterService; +using Mono.Addins; + +namespace SampleAddinHost +{ + class MainClass + { + public static void Main(string[] args) + { + AddinManager.Initialize ("."); + AddinManager.Registry.Update (null); + + Console.WriteLine ("Normal writers:"); + WriterManager manager = new WriterManager (new string[0]); + foreach (IWriter w in manager.GetWriters ()) + Console.WriteLine (w.Write ()); + + Console.WriteLine ("Including debug writers:"); + WriterManager debugManager = new WriterManager (new string[] { "debug" }); + foreach (IWriter w in debugManager.GetWriters ()) + Console.WriteLine (w.Write ()); + } + } +}
\ No newline at end of file diff --git a/Samples/WriterServiceHost/WriterServiceHost.mdp b/Samples/WriterServiceHost/WriterServiceHost.mdp new file mode 100644 index 0000000..291b97d --- /dev/null +++ b/Samples/WriterServiceHost/WriterServiceHost.mdp @@ -0,0 +1,25 @@ +<Project name="WriterServiceHost" fileversion="2.0" language="C#" clr-version="Net_1_1" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../bin" assembly="SampleAddinHost" /> + <Build debugmode="True" target="Exe" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" generatexmldocumentation="True" win32Icon="./" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../bin" assembly="SampleAddinHost" /> + <Build debugmode="False" target="Exe" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_1_1" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="./Main.cs" subtype="Code" buildaction="Compile" /> + <File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="True" refto="WriterService" /> + <ProjectReference type="Project" localcopy="True" refto="Mono.Addins" /> + </References> +</Project>
\ No newline at end of file |