Permalink
Browse files

Convert to mono-addins 0.6.

  • Loading branch information...
1 parent 624aa0d commit a8de470b5fa0919b753b6c0166ab868d49813689 @jpobst jpobst committed Mar 2, 2011
Showing with 240 additions and 142 deletions.
  1. +2 −0 Pinta.Core/Classes/BasePaintBrush.cs
  2. +2 −0 Pinta.Core/Classes/BaseTool.cs
  3. +4 −0 Pinta.Core/Effects/BaseEffect.cs
  4. +86 −0 Pinta.Core/Managers/EffectsManager.cs
  5. +6 −0 Pinta.Core/Managers/SystemManager.cs
  6. +7 −1 Pinta.Core/Pinta.Core.csproj
  7. +3 −1 Pinta.Core/PintaCore.cs
  8. +1 −1 Pinta.Effects/Adjustments/AutoLevelEffect.cs
  9. +1 −1 Pinta.Effects/Adjustments/BlackAndWhiteEffect.cs
  10. +1 −1 Pinta.Effects/Adjustments/BrightnessContrastEffect.cs
  11. +1 −1 Pinta.Effects/Adjustments/CurvesEffect.cs
  12. +1 −1 Pinta.Effects/Adjustments/HueSaturationEffect.cs
  13. +1 −1 Pinta.Effects/Adjustments/InvertColorsEffect.cs
  14. +1 −1 Pinta.Effects/Adjustments/LevelsEffect.cs
  15. +1 −1 Pinta.Effects/Adjustments/PosterizeEffect.cs
  16. +1 −1 Pinta.Effects/Adjustments/SepiaEffect.cs
  17. +1 −1 Pinta.Effects/Effects/AddNoiseEffect.cs
  18. +1 −1 Pinta.Effects/Effects/BulgeEffect.cs
  19. +1 −1 Pinta.Effects/Effects/CloudsEffect.cs
  20. +1 −1 Pinta.Effects/Effects/EdgeDetectEffect.cs
  21. +1 −1 Pinta.Effects/Effects/EmbossEffect.cs
  22. +1 −1 Pinta.Effects/Effects/FragmentEffect.cs
  23. +1 −1 Pinta.Effects/Effects/FrostedGlassEffect.cs
  24. +1 −1 Pinta.Effects/Effects/GaussianBlurEffect.cs
  25. +1 −1 Pinta.Effects/Effects/GlowEffect.cs
  26. +1 −1 Pinta.Effects/Effects/InkSketchEffect.cs
  27. +1 −1 Pinta.Effects/Effects/JuliaFractalEffect.cs
  28. +1 −1 Pinta.Effects/Effects/MandelbrotFractalEffect.cs
  29. +1 −1 Pinta.Effects/Effects/MedianEffect.cs
  30. +1 −1 Pinta.Effects/Effects/MotionBlurEffect.cs
  31. +1 −1 Pinta.Effects/Effects/OilPaintingEffect.cs
  32. +1 −1 Pinta.Effects/Effects/OutlineEffect.cs
  33. +1 −1 Pinta.Effects/Effects/PencilSketchEffect.cs
  34. +1 −1 Pinta.Effects/Effects/PixelateEffect.cs
  35. +1 −1 Pinta.Effects/Effects/PolarInversionEffect.cs
  36. +1 −1 Pinta.Effects/Effects/RadialBlurEffect.cs
  37. +1 −1 Pinta.Effects/Effects/RedEyeRemoveEffect.cs
  38. +1 −1 Pinta.Effects/Effects/ReduceNoiseEffect.cs
  39. +1 −1 Pinta.Effects/Effects/ReliefEffect.cs
  40. +1 −1 Pinta.Effects/Effects/SharpenEffect.cs
  41. +1 −1 Pinta.Effects/Effects/SoftenPortraitEffect.cs
  42. +1 −1 Pinta.Effects/Effects/TileEffect.cs
  43. +1 −1 Pinta.Effects/Effects/TwistEffect.cs
  44. +1 −1 Pinta.Effects/Effects/UnfocusEffect.cs
  45. +1 −1 Pinta.Effects/Effects/ZoomBlurEffect.cs
  46. +5 −6 Pinta.Effects/Pinta.Effects.csproj
  47. +6 −0 Pinta.Effects/Properties/AssemblyInfo.cs
  48. +1 −1 Pinta.Tools/Brushes/CircleBrush.cs
  49. +1 −1 Pinta.Tools/Brushes/GridBrush.cs
  50. +1 −1 Pinta.Tools/Brushes/PlainBrush.cs
  51. +1 −1 Pinta.Tools/Brushes/SplatterBrush.cs
  52. +1 −1 Pinta.Tools/Brushes/SquaresBrush.cs
  53. +1 −1 Pinta.Tools/CloneStampTool.cs
  54. +1 −1 Pinta.Tools/ColorPickerTool.cs
  55. +1 −1 Pinta.Tools/EllipseSelectTool.cs
  56. +1 −1 Pinta.Tools/EllipseTool.cs
  57. +1 −1 Pinta.Tools/EraserTool.cs
  58. +1 −1 Pinta.Tools/FreeformShapeTool.cs
  59. +1 −1 Pinta.Tools/GradientTool.cs
  60. +1 −1 Pinta.Tools/LassoSelectTool.cs
  61. +1 −1 Pinta.Tools/LineCurveTool.cs
  62. +1 −1 Pinta.Tools/MagicWandTool.cs
  63. +1 −1 Pinta.Tools/MoveSelectedTool.cs
  64. +1 −1 Pinta.Tools/MoveSelectionTool.cs
  65. +1 −1 Pinta.Tools/PaintBrushTool.cs
  66. +1 −1 Pinta.Tools/PaintBucketTool.cs
  67. +1 −1 Pinta.Tools/PanTool.cs
  68. +1 −1 Pinta.Tools/PencilTool.cs
  69. +5 −6 Pinta.Tools/Pinta.Tools.csproj
  70. +6 −0 Pinta.Tools/Properties/AssemblyInfo.cs
  71. +1 −1 Pinta.Tools/RecolorTool.cs
  72. +1 −1 Pinta.Tools/RectangleSelectTool.cs
  73. +1 −1 Pinta.Tools/RectangleTool.cs
  74. +1 −1 Pinta.Tools/RoundedRectangleTool.cs
  75. +1 −1 Pinta.Tools/TextTool/TextTool.cs
  76. +1 −1 Pinta.Tools/ZoomTool.cs
  77. +0 −6 Pinta.sln
  78. +33 −51 Pinta/MainWindow.cs
  79. +10 −6 Pinta/Pinta.csproj
@@ -25,9 +25,11 @@
// THE SOFTWARE.
using System;
+using Mono.Addins;
namespace Pinta.Core
{
+ [TypeExtensionPoint]
public abstract class BasePaintBrush
{
public abstract string Name { get; }
@@ -29,9 +29,11 @@
using Gtk;
using System.IO;
using Mono.Unix;
+using Mono.Addins;
namespace Pinta.Core
{
+ [TypeExtensionPoint]
public abstract class BaseTool
{
protected const int DEFAULT_BRUSH_WIDTH = 2;
@@ -27,9 +27,13 @@
using System;
using Cairo;
using Mono.Unix;
+using Mono.Addins;
+
+[assembly: AddinRoot ("Pinta", "1.0")]
namespace Pinta.Core
{
+ [TypeExtensionPoint]
public abstract class BaseEffect
{
public abstract string Icon { get; }
@@ -0,0 +1,86 @@
+//
+// EffectsManager.cs
+//
+// Author:
+// Jonathan Pobst <monkey@jpobst.com>
+//
+// Copyright (c) 2011 Jonathan Pobst
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using Gtk;
+using Mono.Unix;
+
+namespace Pinta.Core
+{
+ public class EffectsManager
+ {
+ private List<BaseEffect> adjustments;
+ private List<BaseEffect> effects;
+
+ public EffectsManager ()
+ {
+ adjustments = new List<BaseEffect> ();
+ effects = new List<BaseEffect> ();
+ }
+
+ // TODO: Needs to keep menu sorted
+ public Gtk.Action RegisterAdjustment (BaseEffect adjustment, MenuBar menu)
+ {
+ adjustments.Add (adjustment);
+
+ // Add icon to IconFactory
+ Gtk.IconFactory fact = new Gtk.IconFactory ();
+ fact.Add (adjustment.Icon, new Gtk.IconSet (PintaCore.Resources.GetIcon (adjustment.Icon)));
+ fact.AddDefault ();
+
+ // Create a gtk action for each adjustment
+ Gtk.Action act = new Gtk.Action (adjustment.GetType ().Name, adjustment.Text + (adjustment.IsConfigurable ? Catalog.GetString ("...") : ""), string.Empty, adjustment.Icon);
+ act.Activated += delegate (object sender, EventArgs e) { PintaCore.LivePreview.Start (adjustment); };
+
+ PintaCore.Actions.Adjustments.Actions.Add (act);
+
+ // Create a menu item for each adjustment
+ ((Menu)((ImageMenuItem)menu.Children[5]).Submenu).Append (act.CreateAcceleratedMenuItem (adjustment.AdjustmentMenuKey, adjustment.AdjustmentMenuKeyModifiers));
+
+ return act;
+ }
+
+ // TODO: Needs to keep menu sorted
+ public Gtk.Action RegisterEffect (BaseEffect effect, MenuBar menu)
+ {
+ effects.Add (effect);
+
+ // Add icon to IconFactory
+ Gtk.IconFactory fact = new Gtk.IconFactory ();
+ fact.Add (effect.Icon, new Gtk.IconSet (PintaCore.Resources.GetIcon (effect.Icon)));
+ fact.AddDefault ();
+
+ // Create a gtk action and menu item for each effect
+ Gtk.Action act = new Gtk.Action (effect.GetType ().Name, effect.Text + (effect.IsConfigurable ? Catalog.GetString ("...") : ""), string.Empty, effect.Icon);
+ act.Activated += delegate (object sender, EventArgs e) { PintaCore.LivePreview.Start (effect); };
+
+ PintaCore.Actions.Effects.AddEffect (effect.EffectMenuCategory, act);
+
+ return act;
+ }
+ }
+}
@@ -30,6 +30,7 @@
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
+using Mono.Addins;
namespace Pinta.Core
{
@@ -74,6 +75,11 @@ public static OS GetOperatingSystem ()
return operating_system;
}
+ public T[] GetExtensions<T> ()
+ {
+ return AddinManager.GetExtensionObjects<T> ();
+ }
+
//From Managed.Windows.Forms/XplatUI
[DllImport ("libc")]
static extern int uname (IntPtr buf);
@@ -58,6 +58,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
+ <Reference Include="Mono.Addins, Version=0.6.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
+ <HintPath>..\lib\Mono.Addins.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
</Reference>
@@ -87,7 +90,9 @@
<Compile Include="Classes\DocumentWorkspace.cs" />
<Compile Include="Classes\ScaleFactor.cs" />
<Compile Include="Classes\Palette.cs" />
- <Compile Include="Effects\BaseEffect.cs" />
+ <Compile Include="Effects\BaseEffect.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Effects\BinaryPixelOp.cs" />
<Compile Include="Effects\BitVector2DSurfaceAdapter.cs" />
<Compile Include="Effects\Histogram.cs" />
@@ -123,6 +128,7 @@
<Compile Include="HistoryItems\SimpleHistoryItem.cs" />
<Compile Include="Managers\ActionManager.cs" />
<Compile Include="Managers\ChromeManager.cs" />
+ <Compile Include="Managers\EffectsManager.cs" />
<Compile Include="Managers\FontManager.cs" />
<Compile Include="Managers\ImageConverterManager.cs" />
<Compile Include="Managers\HistoryManager.cs" />
View
@@ -44,7 +44,8 @@ public static class PintaCore
public static SystemManager System { get; private set; }
public static LivePreviewManager LivePreview { get; private set; }
public static SettingsManager Settings { get; private set; }
-
+ public static EffectsManager Effects { get; private set; }
+
static PintaCore ()
{
Resources = new ResourceManager ();
@@ -59,6 +60,7 @@ static PintaCore ()
Palette = new PaletteManager ();
Settings = new SettingsManager ();
Chrome = new ChromeManager ();
+ Effects = new EffectsManager ();
}
public static void Initialize (Toolbar toolToolBar,
@@ -13,7 +13,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class AutoLevelEffect : BaseEffect
{
UnaryPixelOps.Level op;
@@ -13,7 +13,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class BlackAndWhiteEffect : BaseEffect
{
UnaryPixelOp op = new UnaryPixelOps.Desaturate ();
@@ -14,7 +14,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class BrightnessContrastEffect : BaseEffect
{
private int multiply;
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class CurvesEffect : BaseEffect
{
UnaryPixelOp op = null;
@@ -14,7 +14,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class HueSaturationEffect : BaseEffect
{
UnaryPixelOp op;
@@ -13,7 +13,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class InvertColorsEffect : BaseEffect
{
UnaryPixelOp op = new UnaryPixelOps.Invert ();
@@ -13,7 +13,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class LevelsEffect : BaseEffect
{
public override string Icon {
@@ -13,7 +13,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class PosterizeEffect : BaseEffect
{
UnaryPixelOps.PosterizePixel op = null;
@@ -13,7 +13,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class SepiaEffect : BaseEffect
{
UnaryPixelOp desat = new UnaryPixelOps.Desaturate ();
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class AddNoiseEffect : BaseEffect
{
private int intensity;
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class BulgeEffect : BaseEffect
{
public override string Icon {
@@ -16,7 +16,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class CloudsEffect : BaseEffect
{
// This is so that repetition of the effect with CTRL+F actually shows up differently.
@@ -16,7 +16,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class EdgeDetectEffect : ColorDifferenceEffect
{
private double[][] weights;
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class EmbossEffect : BaseEffect
{
public override string Icon {
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class FragmentEffect : BaseEffect
{
public override string Icon {
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class FrostedGlassEffect : BaseEffect
{
public override string Icon {
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class GaussianBlurEffect : BaseEffect
{
public override string Icon {
@@ -16,7 +16,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class GlowEffect : BaseEffect
{
private GaussianBlurEffect blurEffect;
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class InkSketchEffect : BaseEffect
{
private static readonly int[][] conv;
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class JuliaFractalEffect : BaseEffect
{
public override string Icon {
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class MandelbrotFractalEffect : BaseEffect
{
public override string Icon {
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class MedianEffect : LocalHistogramEffect
{
private int radius;
@@ -15,7 +15,7 @@
namespace Pinta.Effects
{
- [System.ComponentModel.Composition.Export (typeof (BaseEffect))]
+ [Mono.Addins.Extension]
public class MotionBlurEffect : BaseEffect
{
public override string Icon {
Oops, something went wrong.

0 comments on commit a8de470

Please sign in to comment.