Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First pass at massive refactoring to move to a more MVC design to all…

…ow greater freedom to extensions.
  • Loading branch information...
commit 2a63c823521e0b7e3416e9ee09a4175f1041de4e 1 parent a8de470
@jpobst jpobst authored
Showing with 2,806 additions and 1,384 deletions.
  1. +9 −25 Pinta.Core/Actions/FileActions.cs
  2. +2 −2 Pinta.Core/Actions/ImageActions.cs
  3. +1 −1  Pinta.Core/Classes/BaseTool.cs
  4. +2 −2 Pinta.Core/Classes/Document.cs
  5. +8 −8 Pinta.Core/Classes/DocumentWorkspace.cs
  6. +15 −0 Pinta.Core/Classes/IExtension.cs
  7. +3 −1 Pinta.Core/EventArgs/DocumentCancelEventArgs.cs
  8. +41 −0 Pinta.Core/EventArgs/ToolEventArgs.cs
  9. +40 −16 Pinta.Core/Managers/ChromeManager.cs
  10. +3 −3 Pinta.Core/Managers/EffectsManager.cs
  11. +1 −1  Pinta.Core/Managers/LivePreviewManager.cs
  12. +12 −0 Pinta.Core/Managers/PaintBrushManager.cs
  13. +21 −0 Pinta.Core/Managers/SystemManager.cs
  14. +28 −4 Pinta.Core/Managers/ToolManager.cs
  15. +2 −0  Pinta.Core/Managers/WorkspaceManager.cs
  16. +2 −0  Pinta.Core/Pinta.Core.csproj
  17. +1 −10 Pinta.Core/PintaCore.cs
  18. +0 −1  Pinta.Effects/Adjustments/AutoLevelEffect.cs
  19. +0 −1  Pinta.Effects/Adjustments/BlackAndWhiteEffect.cs
  20. +0 −1  Pinta.Effects/Adjustments/BrightnessContrastEffect.cs
  21. +0 −1  Pinta.Effects/Adjustments/CurvesEffect.cs
  22. +0 −1  Pinta.Effects/Adjustments/HueSaturationEffect.cs
  23. +0 −1  Pinta.Effects/Adjustments/InvertColorsEffect.cs
  24. +0 −1  Pinta.Effects/Adjustments/LevelsEffect.cs
  25. +0 −1  Pinta.Effects/Adjustments/PosterizeEffect.cs
  26. +0 −1  Pinta.Effects/Adjustments/SepiaEffect.cs
  27. +65 −0 Pinta.Effects/CoreEffectsExtension.cs
  28. +0 −1  Pinta.Effects/Effects/AddNoiseEffect.cs
  29. +0 −1  Pinta.Effects/Effects/BulgeEffect.cs
  30. +0 −1  Pinta.Effects/Effects/CloudsEffect.cs
  31. +0 −1  Pinta.Effects/Effects/EdgeDetectEffect.cs
  32. +0 −1  Pinta.Effects/Effects/EmbossEffect.cs
  33. +0 −1  Pinta.Effects/Effects/FragmentEffect.cs
  34. +0 −1  Pinta.Effects/Effects/FrostedGlassEffect.cs
  35. +0 −1  Pinta.Effects/Effects/GaussianBlurEffect.cs
  36. +0 −1  Pinta.Effects/Effects/GlowEffect.cs
  37. +0 −1  Pinta.Effects/Effects/InkSketchEffect.cs
  38. +0 −1  Pinta.Effects/Effects/JuliaFractalEffect.cs
  39. +0 −1  Pinta.Effects/Effects/MandelbrotFractalEffect.cs
  40. +0 −1  Pinta.Effects/Effects/MedianEffect.cs
  41. +0 −1  Pinta.Effects/Effects/MotionBlurEffect.cs
  42. +0 −1  Pinta.Effects/Effects/OilPaintingEffect.cs
  43. +0 −1  Pinta.Effects/Effects/OutlineEffect.cs
  44. +0 −1  Pinta.Effects/Effects/PencilSketchEffect.cs
  45. +0 −1  Pinta.Effects/Effects/PixelateEffect.cs
  46. +0 −1  Pinta.Effects/Effects/PolarInversionEffect.cs
  47. +0 −1  Pinta.Effects/Effects/RadialBlurEffect.cs
  48. +0 −1  Pinta.Effects/Effects/RedEyeRemoveEffect.cs
  49. +0 −1  Pinta.Effects/Effects/ReduceNoiseEffect.cs
  50. +0 −1  Pinta.Effects/Effects/ReliefEffect.cs
  51. +0 −1  Pinta.Effects/Effects/SharpenEffect.cs
  52. +0 −1  Pinta.Effects/Effects/SoftenPortraitEffect.cs
  53. +0 −1  Pinta.Effects/Effects/TileEffect.cs
  54. +0 −1  Pinta.Effects/Effects/TwistEffect.cs
  55. +0 −1  Pinta.Effects/Effects/UnfocusEffect.cs
  56. +0 −1  Pinta.Effects/Effects/ZoomBlurEffect.cs
  57. +1 −0  Pinta.Effects/Pinta.Effects.csproj
  58. +3 −2 Pinta.Gui.Widgets/Widgets/Canvas/PintaCanvas.cs
  59. +9 −0 Pinta.Gui.Widgets/Widgets/ToolBoxWidget.cs
  60. +0 −1  Pinta.Tools/Brushes/CircleBrush.cs
  61. +0 −1  Pinta.Tools/Brushes/GridBrush.cs
  62. +0 −1  Pinta.Tools/Brushes/PlainBrush.cs
  63. +0 −1  Pinta.Tools/Brushes/SplatterBrush.cs
  64. +0 −1  Pinta.Tools/Brushes/SquaresBrush.cs
  65. +50 −0 Pinta.Tools/CoreToolsExtension.cs
  66. +31 −30 Pinta.Tools/Pinta.Tools.csproj
  67. 0  Pinta.Tools/{ → Tools}/BaseBrushTool.cs
  68. +0 −1  Pinta.Tools/{ → Tools}/CloneStampTool.cs
  69. +0 −1  Pinta.Tools/{ → Tools}/ColorPickerTool.cs
  70. +0 −1  Pinta.Tools/{ → Tools}/EllipseSelectTool.cs
  71. +0 −1  Pinta.Tools/{ → Tools}/EllipseTool.cs
  72. +0 −1  Pinta.Tools/{ → Tools}/EraserTool.cs
  73. 0  Pinta.Tools/{ → Tools}/FloodTool.cs
  74. +0 −1  Pinta.Tools/{ → Tools}/FreeformShapeTool.cs
  75. +0 −1  Pinta.Tools/{ → Tools}/GradientTool.cs
  76. +0 −1  Pinta.Tools/{ → Tools}/LassoSelectTool.cs
  77. +0 −1  Pinta.Tools/{ → Tools}/LineCurveTool.cs
  78. +1 −2  Pinta.Tools/{ → Tools}/MagicWandTool.cs
  79. +1 −2  Pinta.Tools/{ → Tools}/MoveSelectedTool.cs
  80. +1 −2  Pinta.Tools/{ → Tools}/MoveSelectionTool.cs
  81. +0 −1  Pinta.Tools/{ → Tools}/PaintBrushTool.cs
  82. +0 −1  Pinta.Tools/{ → Tools}/PaintBucketTool.cs
  83. +1 −2  Pinta.Tools/{ → Tools}/PanTool.cs
  84. +0 −1  Pinta.Tools/{ → Tools}/PencilTool.cs
  85. +0 −1  Pinta.Tools/{ → Tools}/RecolorTool.cs
  86. +0 −1  Pinta.Tools/{ → Tools}/RectangleSelectTool.cs
  87. +0 −1  Pinta.Tools/{ → Tools}/RectangleTool.cs
  88. +0 −1  Pinta.Tools/{ → Tools}/RoundedRectangleTool.cs
  89. 0  Pinta.Tools/{ → Tools}/SelectTool.cs
  90. 0  Pinta.Tools/{ → Tools}/ShapeTool.cs
  91. 0  Pinta.Tools/{ → Tools}/TextTool/EditingMode.cs
  92. 0  Pinta.Tools/{ → Tools}/TextTool/Position.cs
  93. 0  Pinta.Tools/{ → Tools}/TextTool/TextAlignment.cs
  94. +1 −1  Pinta.Tools/{ → Tools}/TextTool/TextEngine.cs
  95. +5 −6 Pinta.Tools/{ → Tools}/TextTool/TextTool.cs
  96. +4 −5 Pinta.Tools/{ → Tools}/ZoomTool.cs
  97. +80 −0 Pinta/Actions/Edit/PasteIntoNewImageAction.cs
  98. +91 −0 Pinta/Actions/Edit/PasteIntoNewLayerAction.cs
  99. +61 −0 Pinta/Actions/Edit/ResizePaletteAction.cs
  100. +88 −0 Pinta/Actions/File/CloseDocumentAction.cs
  101. +67 −0 Pinta/Actions/File/ExitAction.cs
  102. +62 −0 Pinta/Actions/File/ModifyCompressionAction.cs
  103. +68 −0 Pinta/Actions/File/NewDocumentAction.cs
  104. +88 −0 Pinta/Actions/File/NewScreenshotAction.cs
  105. +82 −0 Pinta/Actions/File/OpenDocumentAction.cs
  106. +55 −0 Pinta/Actions/File/OpenRecentAction.cs
  107. +51 −0 Pinta/Actions/File/SaveDocumentAction.cs
  108. +51 −0 Pinta/Actions/File/SaveDocumentAsAction.cs
  109. +209 −0 Pinta/Actions/File/SaveDocumentImplmentationAction.cs
  110. +68 −0 Pinta/Actions/Help/AboutDialogAction.cs
  111. +13 −0 Pinta/Actions/IActionHandler.cs
  112. +62 −0 Pinta/Actions/Image/ResizeCanvasAction.cs
  113. +62 −0 Pinta/Actions/Image/ResizeImageAction.cs
  114. +112 −0 Pinta/Actions/Layers/LayerPropertiesAction.cs
  115. +52 −0 Pinta/Actions/View/ToolBarToggledAction.cs
  116. +60 −0 Pinta/Actions/Window/CloseAllDocumentsAction.cs
  117. +60 −0 Pinta/Actions/Window/SaveAllDocumentsAction.cs
  118. +131 −618 Pinta/DialogHandlers.cs
  119. +14 −0 Pinta/Extensions/GtkExtensions.cs
  120. +3 −5 Pinta/Main.cs
  121. +203 −577 Pinta/MainWindow.cs
  122. +175 −0 Pinta/Pads/CanvasPad.cs
  123. +57 −0 Pinta/Pads/ColorPalettePad.cs
  124. +57 −0 Pinta/Pads/HistoryPad.cs
  125. +11 −0 Pinta/Pads/IDockPad.cs
  126. +63 −0 Pinta/Pads/LayersPad.cs
  127. +55 −0 Pinta/Pads/ToolBoxPad.cs
  128. +29 −0 Pinta/Pinta.csproj
  129. +102 −0 Pinta/WindowShell.cs
View
34 Pinta.Core/Actions/FileActions.cs
@@ -38,7 +38,7 @@ public class FileActions
public Gtk.Action New { get; private set; }
public Gtk.Action NewScreenshot { get; private set; }
public Gtk.Action Open { get; private set; }
- public Gtk.Action OpenRecent { get; private set; }
+ public Gtk.RecentAction OpenRecent { get; private set; }
public Gtk.Action Close { get; private set; }
public Gtk.Action Save { get; private set; }
public Gtk.Action SaveAs { get; private set; }
@@ -95,14 +95,19 @@ public void CreateMainMenu (Gtk.Menu menu)
public void RegisterHandlers ()
{
- Exit.Activated += HandlePintaCoreActionsFileExitActivated;
}
#endregion
#region Event Invokers
- internal bool RaiseSaveDocument (Document document)
+ public void RaiseBeforeQuit ()
{
- DocumentCancelEventArgs e = new DocumentCancelEventArgs (document);
+ if (BeforeQuit != null)
+ BeforeQuit (this, EventArgs.Empty);
+ }
+
+ internal bool RaiseSaveDocument (Document document, bool saveAs)
+ {
+ DocumentCancelEventArgs e = new DocumentCancelEventArgs (document, saveAs);
if (SaveDocument == null)
throw new InvalidOperationException ("GUI is not handling PintaCore.Workspace.SaveDocument");
@@ -122,26 +127,5 @@ internal int RaiseModifyCompression (int defaultCompression)
return e.Cancel ? -1 : e.Quality;
}
#endregion
-
- #region Action Handlers
- private void HandlePintaCoreActionsFileExitActivated (object sender, EventArgs e)
- {
- while (PintaCore.Workspace.HasOpenDocuments) {
- int count = PintaCore.Workspace.OpenDocuments.Count;
-
- Close.Activate ();
-
- // If we still have the same number of open documents,
- // the user cancelled on a Save prompt.
- if (count == PintaCore.Workspace.OpenDocuments.Count)
- return;
- }
-
- if (BeforeQuit != null)
- BeforeQuit (this, EventArgs.Empty);
-
- Application.Quit ();
- }
- #endregion
}
}
View
4 Pinta.Core/Actions/ImageActions.cs
@@ -182,14 +182,14 @@ private void HandlePintaCoreActionsImageCropToSelectionActivated (object sender,
hist.TakeSnapshotOfImage ();
hist.RestorePath = doc.SelectionPath.Clone ();
- PintaCore.Chrome.DrawingArea.GdkWindow.FreezeUpdates ();
+ PintaCore.Chrome.Canvas.GdkWindow.FreezeUpdates ();
double original_scale = doc.Workspace.Scale;
doc.ImageSize = rect.Size;
doc.Workspace.CanvasSize = rect.Size;
doc.Workspace.Scale = original_scale;
- PintaCore.Chrome.DrawingArea.GdkWindow.ThawUpdates ();
+ PintaCore.Chrome.Canvas.GdkWindow.ThawUpdates ();
foreach (var layer in doc.Layers)
layer.Crop (rect, doc.SelectionPath);
View
2  Pinta.Core/Classes/BaseTool.cs
@@ -226,7 +226,7 @@ protected virtual ToggleToolButton CreateToolButton ()
protected void SetCursor (Gdk.Cursor cursor)
{
- PintaCore.Chrome.DrawingArea.GdkWindow.Cursor = cursor;
+ //PintaCore.Chrome.DrawingArea.GdkWindow.Cursor = cursor;
}
#endregion
View
4 Pinta.Core/Classes/Document.cs
@@ -685,9 +685,9 @@ public void RotateImageCCW ()
}
// Returns true if successful, false if canceled
- public bool Save ()
+ public bool Save (bool saveAs)
{
- return PintaCore.Actions.File.RaiseSaveDocument (this);
+ return PintaCore.Actions.File.RaiseSaveDocument (this, saveAs);
}
public void SetCurrentLayer (int i)
View
16 Pinta.Core/Classes/DocumentWorkspace.cs
@@ -50,7 +50,7 @@ internal DocumentWorkspace (Document document)
#region Public Properties
public bool CanvasFitsInWindow {
get {
- Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.DrawingArea.Parent;
+ Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.Canvas.Parent;
int window_x = view.Allocation.Width;
int window_y = view.Children[0].Allocation.Height;
@@ -76,7 +76,7 @@ internal DocumentWorkspace (Document document)
public bool ImageFitsInWindow {
get {
- Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.DrawingArea.Parent;
+ Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.Canvas.Parent;
int window_x = view.Allocation.Width;
int window_y = view.Children[0].Allocation.Height;
@@ -89,7 +89,7 @@ internal DocumentWorkspace (Document document)
}
public Cairo.PointD Offset {
- get { return new Cairo.PointD ((PintaCore.Chrome.DrawingArea.Allocation.Width - canvas_size.Width) / 2, (PintaCore.Chrome.DrawingArea.Allocation.Height - canvas_size.Height) / 2); }
+ get { return new Cairo.PointD ((PintaCore.Chrome.Canvas.Allocation.Width - canvas_size.Width) / 2, (PintaCore.Chrome.Canvas.Allocation.Height - canvas_size.Height) / 2); }
}
public double Scale {
@@ -132,7 +132,7 @@ public bool PointInCanvas (Cairo.PointD point)
public void RecenterView (double x, double y)
{
- Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.DrawingArea.Parent;
+ Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.Canvas.Parent;
view.Hadjustment.Value = Utility.Clamp (x * Scale - view.Hadjustment.PageSize / 2, view.Hadjustment.Lower, view.Hadjustment.Upper);
view.Vadjustment.Value = Utility.Clamp (y * Scale - view.Vadjustment.PageSize / 2, view.Vadjustment.Lower, view.Vadjustment.Upper);
@@ -140,7 +140,7 @@ public void RecenterView (double x, double y)
public void ScrollCanvas (int dx, int dy)
{
- Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.DrawingArea.Parent;
+ Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.Canvas.Parent;
view.Hadjustment.Value = Utility.Clamp (dx + view.Hadjustment.Value, view.Hadjustment.Lower, view.Hadjustment.Upper - view.Hadjustment.PageSize);
view.Vadjustment.Value = Utility.Clamp (dy + view.Vadjustment.Value, view.Vadjustment.Lower, view.Vadjustment.Upper - view.Vadjustment.PageSize);
@@ -201,10 +201,10 @@ private void ZoomAndRecenterView (ZoomType zoomType, Cairo.PointD point)
zoom = Math.Min (zoom, 3600);
- PintaCore.Chrome.DrawingArea.GdkWindow.FreezeUpdates ();
+ PintaCore.Chrome.Canvas.GdkWindow.FreezeUpdates ();
PintaCore.Actions.View.SuspendZoomUpdate ();
- Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.DrawingArea.Parent;
+ Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.Canvas.Parent;
bool adjustOnMousePosition = point.X >= 0.0 && point.Y >= 0.0;
@@ -263,7 +263,7 @@ private void ZoomAndRecenterView (ZoomType zoomType, Cairo.PointD point)
RecenterView (center_x, center_y);
PintaCore.Actions.View.ResumeZoomUpdate ();
- PintaCore.Chrome.DrawingArea.GdkWindow.ThawUpdates ();
+ PintaCore.Chrome.Canvas.GdkWindow.ThawUpdates ();
}
#endregion
}
View
15 Pinta.Core/Classes/IExtension.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Mono.Addins;
+
+namespace Pinta.Core
+{
+ [TypeExtensionPoint]
+ public interface IExtension
+ {
+ void Initialize ();
+ void Uninitialize ();
+ }
+}
View
4 Pinta.Core/EventArgs/DocumentCancelEventArgs.cs
@@ -32,10 +32,12 @@ namespace Pinta.Core
public class DocumentCancelEventArgs : CancelEventArgs
{
public Document Document { get; set; }
+ public bool SaveAs { get; private set; }
- public DocumentCancelEventArgs (Document document)
+ public DocumentCancelEventArgs (Document document, bool saveAs)
{
Document = document;
+ SaveAs = saveAs;
}
}
}
View
41 Pinta.Core/EventArgs/ToolEventArgs.cs
@@ -0,0 +1,41 @@
+//
+// ToolEventArgs.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.ComponentModel;
+
+namespace Pinta.Core
+{
+ public class ToolEventArgs : EventArgs
+ {
+ public BaseTool Tool { get; private set; }
+
+ public ToolEventArgs (BaseTool tool)
+ {
+ Tool = tool;
+ }
+ }
+}
View
56 Pinta.Core/Managers/ChromeManager.cs
@@ -37,30 +37,20 @@ public class ChromeManager
private IProgressDialog progress_dialog;
private bool main_window_busy;
private Gdk.Point last_canvas_cursor_point;
-
+ private MenuBar main_menu;
+ private Toolbar main_toolbar;
+
public Toolbar ToolToolBar { get { return tool_toolbar; } }
- public DrawingArea DrawingArea { get { return drawing_area; } }
+ public Toolbar MainToolBar { get { return main_toolbar; } }
+ public DrawingArea Canvas { get { return drawing_area; } }
public Window MainWindow { get { return main_window; } }
public IProgressDialog ProgressDialog { get { return progress_dialog; } }
+ public MenuBar MainMenu { get { return main_menu; } }
public ChromeManager ()
{
}
- public void Initialize (Toolbar toolToolBar,
- DrawingArea drawingArea,
- Window mainWindow,
- IProgressDialog progressDialog)
- {
- if (progressDialog == null)
- throw new ArgumentNullException ("progressDialog");
-
- tool_toolbar = toolToolBar;
- drawing_area = drawingArea;
- main_window = mainWindow;
- progress_dialog = progressDialog;
- }
-
#region Public Properties
public Gdk.Point LastCanvasCursorPoint {
get { return last_canvas_cursor_point; }
@@ -86,6 +76,40 @@ public ChromeManager ()
#endregion
#region Public Methods
+ public void InitializeToolToolBar (Toolbar toolToolBar)
+ {
+ tool_toolbar = toolToolBar;
+ }
+
+ public void InitializeMainToolBar (Toolbar mainToolBar)
+ {
+ main_toolbar = mainToolBar;
+ }
+
+ public void InitializeCanvas (DrawingArea canvas)
+ {
+ drawing_area = canvas;
+ }
+
+ public void InitializeWindowShell (Window shell)
+ {
+ main_window = shell;
+ }
+
+ public void InitializeMainMenu (MenuBar menu)
+ {
+ main_menu = menu;
+ }
+
+ public void InitializeProgessDialog (IProgressDialog progressDialog)
+ {
+ if (progressDialog == null)
+ throw new ArgumentNullException ("progressDialog");
+
+ progress_dialog = progressDialog;
+ }
+
+
public void SetStatusBarText (string text)
{
OnStatusBarTextChanged (text);
View
6 Pinta.Core/Managers/EffectsManager.cs
@@ -43,7 +43,7 @@ public EffectsManager ()
}
// TODO: Needs to keep menu sorted
- public Gtk.Action RegisterAdjustment (BaseEffect adjustment, MenuBar menu)
+ public Gtk.Action AddAdjustment (BaseEffect adjustment)
{
adjustments.Add (adjustment);
@@ -59,13 +59,13 @@ public Gtk.Action RegisterAdjustment (BaseEffect adjustment, MenuBar menu)
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));
+ ((Menu)((ImageMenuItem)PintaCore.Chrome.MainMenu.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)
+ public Gtk.Action AddEffect (BaseEffect effect)
{
effects.Add (effect);
View
2  Pinta.Core/Managers/LivePreviewManager.cs
@@ -382,7 +382,7 @@ private void LivePreview_RenderUpdated (object o, LivePreviewRenderUpdatedEventA
int height = (int)Math.Ceiling (y2) - y;
// Tell GTK to expose the drawing area.
- PintaCore.Chrome.DrawingArea.QueueDrawArea (x, y, width, height);
+ PintaCore.Chrome.Canvas.QueueDrawArea (x, y, width, height);
}
}
}
View
12 Pinta.Core/Managers/PaintBrushManager.cs
@@ -36,6 +36,7 @@ public class PaintBrushManager : IEnumerable<BasePaintBrush>
public void AddPaintBrush (BasePaintBrush paintBrush)
{
paint_brushes.Add (paintBrush);
+ paint_brushes.Sort (new BrushSorter ());
}
#region IEnumerable<BasePaintBrush> implementation
@@ -51,6 +52,17 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator ()
return paint_brushes.GetEnumerator ();
}
#endregion
+
+ class BrushSorter : Comparer<BasePaintBrush>
+ {
+ public override int Compare (BasePaintBrush x, BasePaintBrush y)
+ {
+ var xstr = x.Priority == 0 ? x.Name : x.Priority.ToString ();
+ var ystr = y.Priority == 0 ? y.Name : y.Priority.ToString ();
+
+ return string.Compare (xstr, ystr);
+ }
+ }
}
}
View
21 Pinta.Core/Managers/SystemManager.cs
@@ -31,6 +31,7 @@
using System.IO;
using System.Runtime.InteropServices;
using Mono.Addins;
+using Gtk;
namespace Pinta.Core
{
@@ -38,6 +39,9 @@ public class SystemManager
{
private static OS operating_system;
+ private string last_dialog_directory;
+ private RecentData recent_data;
+
public ImageConverterManager ImageFormats { get; private set; }
public FontManager Fonts { get; private set; }
public int RenderThreads { get; set; }
@@ -48,6 +52,13 @@ public SystemManager ()
ImageFormats = new ImageConverterManager ();
RenderThreads = Environment.ProcessorCount;
Fonts = new FontManager ();
+
+ last_dialog_directory = System.Environment.GetFolderPath (Environment.SpecialFolder.MyPictures);
+
+ recent_data = new RecentData ();
+ recent_data.AppName = "Pinta";
+ recent_data.AppExec = GetExecutablePathName ();
+ recent_data.MimeType = "image/*";
}
static SystemManager ()
@@ -62,6 +73,16 @@ static SystemManager ()
operating_system = OS.Other;
}
+ #region Public Properties
+ // TODO: Store in settings
+ public string LastDialogDirectory {
+ get { return last_dialog_directory; }
+ set { last_dialog_directory = value; }
+ }
+
+ public RecentData RecentData { get { return recent_data; } }
+ #endregion
+
public string GetExecutablePathName ()
{
string executablePathName = System.Environment.GetCommandLineArgs ()[0];
View
32 Pinta.Core/Managers/ToolManager.cs
@@ -26,6 +26,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using Gtk;
namespace Pinta.Core
@@ -37,6 +38,8 @@ public class ToolManager : IEnumerable<BaseTool>
private List<BaseTool> Tools;
+ public event EventHandler<ToolEventArgs> ToolAdded;
+
public ToolManager ()
{
Tools = new List<BaseTool> ();
@@ -47,7 +50,13 @@ public void AddTool (BaseTool tool)
tool.ToolItem.Clicked += HandlePbToolItemClicked;
tool.ToolItem.Sensitive = tool.Enabled;
- Tools.Add (tool);
+ Tools.Add (tool);
+ Tools.Sort (new ToolSorter ());
+
+ OnToolAdded (tool);
+
+ if (CurrentTool == null)
+ SetCurrentTool (tool);
}
void HandlePbToolItemClicked (object sender, EventArgs e)
@@ -57,7 +66,7 @@ void HandlePbToolItemClicked (object sender, EventArgs e)
BaseTool t = FindTool (tb.Label);
// Don't let the user unselect the current tool
- if (t.Name == CurrentTool.Name) {
+ if (CurrentTool != null && t.Name == CurrentTool.Name) {
if (prev_index != index)
tb.Active = true;
return;
@@ -80,7 +89,7 @@ private BaseTool FindTool (string name)
}
public BaseTool CurrentTool {
- get { return Tools[index]; }
+ get { if (index >= 0) return Tools[index]; return null; }
}
public BaseTool PreviousTool {
@@ -89,7 +98,8 @@ private BaseTool FindTool (string name)
public void Commit ()
{
- CurrentTool.DoCommit ();
+ if (CurrentTool != null)
+ CurrentTool.DoCommit ();
}
public void SetCurrentTool (BaseTool tool)
@@ -156,6 +166,12 @@ private BaseTool FindNextTool (Gdk.Key shortcut)
return null;
}
+ private void OnToolAdded (BaseTool tool)
+ {
+ if (ToolAdded != null)
+ ToolAdded (this, new ToolEventArgs (tool));
+ }
+
#region IEnumerable<BaseTool> implementation
public IEnumerator<BaseTool> GetEnumerator ()
{
@@ -169,5 +185,13 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator ()
return Tools.GetEnumerator ();
}
#endregion
+
+ class ToolSorter : Comparer<BaseTool>
+ {
+ public override int Compare (BaseTool x, BaseTool y)
+ {
+ return x.Priority - y.Priority;
+ }
+ }
}
}
View
2  Pinta.Core/Managers/WorkspaceManager.cs
@@ -164,6 +164,7 @@ public Document NewDocument (Gdk.Size imageSize, bool transparent)
return doc;
}
+ // TODO: Standardize add to recent files
public bool OpenFile (string file)
{
bool fileOpened = false;
@@ -176,6 +177,7 @@ public bool OpenFile (string file)
PintaCore.Workspace.ActiveDocument.PathAndFileName = file;
PintaCore.Workspace.ActiveWorkspace.History.PushNewItem (new BaseHistoryItem (Stock.Open, Catalog.GetString ("Open Image")));
PintaCore.Workspace.ActiveDocument.IsDirty = false;
+ PintaCore.Workspace.ActiveDocument.HasFile = true;
PintaCore.Actions.View.ZoomToWindow.Activate ();
PintaCore.Workspace.Invalidate ();
View
2  Pinta.Core/Pinta.Core.csproj
@@ -88,6 +88,7 @@
<Compile Include="Classes\DocumentWorkspaceHistory.cs" />
<Compile Include="Classes\Document.cs" />
<Compile Include="Classes\DocumentWorkspace.cs" />
+ <Compile Include="Classes\IExtension.cs" />
<Compile Include="Classes\ScaleFactor.cs" />
<Compile Include="Classes\Palette.cs" />
<Compile Include="Effects\BaseEffect.cs">
@@ -107,6 +108,7 @@
<Compile Include="Enumerations\EffectAdjustment.cs" />
<Compile Include="Enumerations\GradientColorMode.cs" />
<Compile Include="EventArgs\CanvasInvalidatedEventArgs.cs" />
+ <Compile Include="EventArgs\ToolEventArgs.cs" />
<Compile Include="EventArgs\DocumentCancelEventArgs.cs" />
<Compile Include="EventArgs\DocumentEventArgs.cs" />
<Compile Include="EventArgs\HistoryItemAddedEventArgs.cs" />
View
11 Pinta.Core/PintaCore.cs
@@ -63,17 +63,8 @@ static PintaCore ()
Effects = new EffectsManager ();
}
- public static void Initialize (Toolbar toolToolBar,
- DrawingArea drawingArea,
- Window mainWindow,
- IProgressDialog progressDialog)
+ public static void Initialize ()
{
- Chrome.Initialize (toolToolBar,
- drawingArea,
- mainWindow,
- progressDialog);
-
-
Actions.RegisterHandlers ();
}
}
View
1  Pinta.Effects/Adjustments/AutoLevelEffect.cs
@@ -13,7 +13,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class AutoLevelEffect : BaseEffect
{
UnaryPixelOps.Level op;
View
1  Pinta.Effects/Adjustments/BlackAndWhiteEffect.cs
@@ -13,7 +13,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class BlackAndWhiteEffect : BaseEffect
{
UnaryPixelOp op = new UnaryPixelOps.Desaturate ();
View
1  Pinta.Effects/Adjustments/BrightnessContrastEffect.cs
@@ -14,7 +14,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class BrightnessContrastEffect : BaseEffect
{
private int multiply;
View
1  Pinta.Effects/Adjustments/CurvesEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class CurvesEffect : BaseEffect
{
UnaryPixelOp op = null;
View
1  Pinta.Effects/Adjustments/HueSaturationEffect.cs
@@ -14,7 +14,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class HueSaturationEffect : BaseEffect
{
UnaryPixelOp op;
View
1  Pinta.Effects/Adjustments/InvertColorsEffect.cs
@@ -13,7 +13,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class InvertColorsEffect : BaseEffect
{
UnaryPixelOp op = new UnaryPixelOps.Invert ();
View
1  Pinta.Effects/Adjustments/LevelsEffect.cs
@@ -13,7 +13,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class LevelsEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Adjustments/PosterizeEffect.cs
@@ -13,7 +13,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class PosterizeEffect : BaseEffect
{
UnaryPixelOps.PosterizePixel op = null;
View
1  Pinta.Effects/Adjustments/SepiaEffect.cs
@@ -13,7 +13,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class SepiaEffect : BaseEffect
{
UnaryPixelOp desat = new UnaryPixelOps.Desaturate ();
View
65 Pinta.Effects/CoreEffectsExtension.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Pinta.Core;
+
+namespace Pinta.Effects
+{
+ [Mono.Addins.Extension]
+ class CoreEffectsExtension : IExtension
+ {
+ #region IExtension Members
+ public void Initialize ()
+ {
+ // Add the adjustments
+ PintaCore.Effects.AddAdjustment (new AutoLevelEffect ());
+ PintaCore.Effects.AddAdjustment (new BlackAndWhiteEffect ());
+ PintaCore.Effects.AddAdjustment (new BrightnessContrastEffect ());
+ PintaCore.Effects.AddAdjustment (new CurvesEffect ());
+ PintaCore.Effects.AddAdjustment (new HueSaturationEffect ());
+ PintaCore.Effects.AddAdjustment (new InvertColorsEffect ());
+ PintaCore.Effects.AddAdjustment (new LevelsEffect ());
+ PintaCore.Effects.AddAdjustment (new PosterizeEffect ());
+ PintaCore.Effects.AddAdjustment (new SepiaEffect ());
+
+ // Add the effects
+ // HACK: Have to add one from each submenu item in order
+ // until EffectsManager can keep the menus sorted
+ PintaCore.Effects.AddEffect (new InkSketchEffect ());
+ PintaCore.Effects.AddEffect (new FragmentEffect ());
+ PintaCore.Effects.AddEffect (new BulgeEffect ());
+ PintaCore.Effects.AddEffect (new AddNoiseEffect ());
+ PintaCore.Effects.AddEffect (new GlowEffect ());
+ PintaCore.Effects.AddEffect (new CloudsEffect ());
+ PintaCore.Effects.AddEffect (new EdgeDetectEffect ());
+
+ PintaCore.Effects.AddEffect (new EmbossEffect ());
+ PintaCore.Effects.AddEffect (new FrostedGlassEffect ());
+ PintaCore.Effects.AddEffect (new GaussianBlurEffect ());
+ PintaCore.Effects.AddEffect (new JuliaFractalEffect ());
+ PintaCore.Effects.AddEffect (new MandelbrotFractalEffect ());
+ PintaCore.Effects.AddEffect (new MedianEffect ());
+ PintaCore.Effects.AddEffect (new MotionBlurEffect ());
+ PintaCore.Effects.AddEffect (new OilPaintingEffect ());
+ PintaCore.Effects.AddEffect (new OutlineEffect ());
+ PintaCore.Effects.AddEffect (new PencilSketchEffect ());
+ PintaCore.Effects.AddEffect (new PixelateEffect ());
+ PintaCore.Effects.AddEffect (new PolarInversionEffect ());
+ PintaCore.Effects.AddEffect (new RadialBlurEffect ());
+ PintaCore.Effects.AddEffect (new RedEyeRemoveEffect ());
+ PintaCore.Effects.AddEffect (new ReduceNoiseEffect ());
+ PintaCore.Effects.AddEffect (new ReliefEffect ());
+ PintaCore.Effects.AddEffect (new SharpenEffect ());
+ PintaCore.Effects.AddEffect (new TileEffect ());
+ PintaCore.Effects.AddEffect (new TwistEffect ());
+ PintaCore.Effects.AddEffect (new UnfocusEffect ());
+ PintaCore.Effects.AddEffect (new ZoomBlurEffect ());
+ }
+
+ public void Uninitialize ()
+ {
+ }
+ #endregion
+ }
+}
View
1  Pinta.Effects/Effects/AddNoiseEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class AddNoiseEffect : BaseEffect
{
private int intensity;
View
1  Pinta.Effects/Effects/BulgeEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class BulgeEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/CloudsEffect.cs
@@ -16,7 +16,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class CloudsEffect : BaseEffect
{
// This is so that repetition of the effect with CTRL+F actually shows up differently.
View
1  Pinta.Effects/Effects/EdgeDetectEffect.cs
@@ -16,7 +16,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class EdgeDetectEffect : ColorDifferenceEffect
{
private double[][] weights;
View
1  Pinta.Effects/Effects/EmbossEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class EmbossEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/FragmentEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class FragmentEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/FrostedGlassEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class FrostedGlassEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/GaussianBlurEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class GaussianBlurEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/GlowEffect.cs
@@ -16,7 +16,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class GlowEffect : BaseEffect
{
private GaussianBlurEffect blurEffect;
View
1  Pinta.Effects/Effects/InkSketchEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class InkSketchEffect : BaseEffect
{
private static readonly int[][] conv;
View
1  Pinta.Effects/Effects/JuliaFractalEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class JuliaFractalEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/MandelbrotFractalEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class MandelbrotFractalEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/MedianEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class MedianEffect : LocalHistogramEffect
{
private int radius;
View
1  Pinta.Effects/Effects/MotionBlurEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class MotionBlurEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/OilPaintingEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class OilPaintingEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/OutlineEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class OutlineEffect : LocalHistogramEffect
{
private int thickness;
View
1  Pinta.Effects/Effects/PencilSketchEffect.cs
@@ -16,7 +16,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class PencilSketchEffect : BaseEffect
{
private GaussianBlurEffect blurEffect;
View
1  Pinta.Effects/Effects/PixelateEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class PixelateEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/PolarInversionEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class PolarInversionEffect : WarpEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/RadialBlurEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class RadialBlurEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/RedEyeRemoveEffect.cs
@@ -16,7 +16,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class RedEyeRemoveEffect : BaseEffect
{
private UnaryPixelOp op;
View
1  Pinta.Effects/Effects/ReduceNoiseEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class ReduceNoiseEffect : LocalHistogramEffect
{
private int radius;
View
1  Pinta.Effects/Effects/ReliefEffect.cs
@@ -14,7 +14,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class ReliefEffect : ColorDifferenceEffect
{
public ReliefEffect () {
View
1  Pinta.Effects/Effects/SharpenEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class SharpenEffect : LocalHistogramEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/SoftenPortraitEffect.cs
@@ -43,7 +43,6 @@ THE SOFTWARE.
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class SoftenPortraitEffect : BaseEffect
{
private GaussianBlurEffect blurEffect;
View
1  Pinta.Effects/Effects/TileEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class TileEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/TwistEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class TwistEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Effects/UnfocusEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class UnfocusEffect : LocalHistogramEffect
{
private int radius;
View
1  Pinta.Effects/Effects/ZoomBlurEffect.cs
@@ -15,7 +15,6 @@
namespace Pinta.Effects
{
- [Mono.Addins.Extension]
public class ZoomBlurEffect : BaseEffect
{
public override string Icon {
View
1  Pinta.Effects/Pinta.Effects.csproj
@@ -70,6 +70,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="CoreEffectsExtension.cs" />
<Compile Include="Dialogs\Effects.LevelsDialog.cs" />
<Compile Include="Dialogs\Effects.PosterizeDialog.cs" />
<Compile Include="Adjustments\AutoLevelEffect.cs" />
View
5 Pinta.Gui.Widgets/Widgets/Canvas/PintaCanvas.cs
@@ -77,8 +77,9 @@ public PintaCanvas ()
if (PintaCore.Workspace.ActiveWorkspace.PointInCanvas (point))
PintaCore.Chrome.LastCanvasCursorPoint = point.ToGdkPoint ();
-
- PintaCore.Tools.CurrentTool.DoMouseMove (sender, e, point);
+
+ if (PintaCore.Tools.CurrentTool != null)
+ PintaCore.Tools.CurrentTool.DoMouseMove (sender, e, point);
};
// Handle key press/release events
View
9 Pinta.Gui.Widgets/Widgets/ToolBoxWidget.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using Gtk;
+using Pinta.Core;
namespace Pinta.Gui.Widgets
{
@@ -36,9 +37,12 @@ public ToolBoxWidget ()
PackStart (tb2, false, false, 0);
+ PintaCore.Tools.ToolAdded += HandleToolAdded;
+
ShowAll ();
}
+ // TODO: This should handle sorting the items
public void AddItem (ToolButton item)
{
if (tb1.NItems <= tb2.NItems)
@@ -46,5 +50,10 @@ public void AddItem (ToolButton item)
else
tb2.Insert (item, tb2.NItems);
}
+
+ private void HandleToolAdded (object sender, ToolEventArgs e)
+ {
+ AddItem (e.Tool.ToolItem);
+ }
}
}
View
1  Pinta.Tools/Brushes/CircleBrush.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools.Brushes
{
- [Mono.Addins.Extension]
public class CircleBrush : PaintBrush
{
public override string Name {
View
1  Pinta.Tools/Brushes/GridBrush.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools.Brushes
{
- [Mono.Addins.Extension]
public class GridBrush : PaintBrush
{
public override string Name {
View
1  Pinta.Tools/Brushes/PlainBrush.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools.Brushes
{
- [Mono.Addins.Extension]
public class PlainBrush : PaintBrush
{
public override string Name {
View
1  Pinta.Tools/Brushes/SplatterBrush.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools.Brushes
{
- [Mono.Addins.Extension]
public class SplatterBrush : PaintBrush
{
public override string Name {
View
1  Pinta.Tools/Brushes/SquaresBrush.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools.Brushes
{
- [Mono.Addins.Extension]
public class SquaresBrush : PaintBrush
{
private static double theta = Math.PI / 2;
View
50 Pinta.Tools/CoreToolsExtension.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Pinta.Core;
+
+namespace Pinta.Tools
+{
+ [Mono.Addins.Extension]
+ class CoreToolsExtension : IExtension
+ {
+ #region IExtension Members
+ public void Initialize ()
+ {
+ PintaCore.PaintBrushes.AddPaintBrush (new Brushes.CircleBrush ());
+ PintaCore.PaintBrushes.AddPaintBrush (new Brushes.GridBrush ());
+ PintaCore.PaintBrushes.AddPaintBrush (new Brushes.PlainBrush ());
+ PintaCore.PaintBrushes.AddPaintBrush (new Brushes.SplatterBrush ());
+ PintaCore.PaintBrushes.AddPaintBrush (new Brushes.SquaresBrush ());
+
+ PintaCore.Tools.AddTool (new RectangleSelectTool ());
+ PintaCore.Tools.AddTool (new MoveSelectedTool ());
+ PintaCore.Tools.AddTool (new LassoSelectTool ());
+ PintaCore.Tools.AddTool (new MoveSelectionTool ());
+ PintaCore.Tools.AddTool (new EllipseSelectTool ());
+ PintaCore.Tools.AddTool (new ZoomTool ());
+ PintaCore.Tools.AddTool (new MagicWandTool ());
+ PintaCore.Tools.AddTool (new PanTool ());
+ PintaCore.Tools.AddTool (new PaintBucketTool ());
+ PintaCore.Tools.AddTool (new GradientTool ());
+ PintaCore.Tools.AddTool (new PaintBrushTool ());
+ PintaCore.Tools.AddTool (new EraserTool ());
+ PintaCore.Tools.AddTool (new PencilTool ());
+ PintaCore.Tools.AddTool (new ColorPickerTool ());
+ PintaCore.Tools.AddTool (new CloneStampTool ());
+ PintaCore.Tools.AddTool (new RecolorTool ());
+ PintaCore.Tools.AddTool (new TextTool ());
+ PintaCore.Tools.AddTool (new LineCurveTool ());
+ PintaCore.Tools.AddTool (new RectangleTool ());
+ PintaCore.Tools.AddTool (new RoundedRectangleTool ());
+ PintaCore.Tools.AddTool (new EllipseTool ());
+ PintaCore.Tools.AddTool (new FreeformShapeTool ());
+ }
+
+ public void Uninitialize ()
+ {
+ }
+ #endregion
+ }
+}
View
61 Pinta.Tools/Pinta.Tools.csproj
@@ -72,38 +72,39 @@
<Reference Include="Mono.Posix" />
</ItemGroup>
<ItemGroup>
- <Compile Include="BaseBrushTool.cs" />
+ <Compile Include="CoreToolsExtension.cs" />
+ <Compile Include="Tools\BaseBrushTool.cs" />
<Compile Include="Brushes\SplatterBrush.cs" />
- <Compile Include="ColorPickerTool.cs" />
- <Compile Include="EllipseSelectTool.cs" />
- <Compile Include="EllipseTool.cs" />
- <Compile Include="EraserTool.cs" />
- <Compile Include="FloodTool.cs" />
- <Compile Include="FreeformShapeTool.cs" />
- <Compile Include="GradientTool.cs" />
- <Compile Include="LassoSelectTool.cs" />
- <Compile Include="LineCurveTool.cs" />
- <Compile Include="MagicWandTool.cs" />
- <Compile Include="MoveSelectedTool.cs" />
- <Compile Include="MoveSelectionTool.cs" />
- <Compile Include="PaintBrushTool.cs" />
- <Compile Include="PaintBucketTool.cs" />
- <Compile Include="PanTool.cs" />
- <Compile Include="PencilTool.cs" />
+ <Compile Include="Tools\ColorPickerTool.cs" />
+ <Compile Include="Tools\EllipseSelectTool.cs" />
+ <Compile Include="Tools\EllipseTool.cs" />
+ <Compile Include="Tools\EraserTool.cs" />
+ <Compile Include="Tools\FloodTool.cs" />
+ <Compile Include="Tools\FreeformShapeTool.cs" />
+ <Compile Include="Tools\GradientTool.cs" />
+ <Compile Include="Tools\LassoSelectTool.cs" />
+ <Compile Include="Tools\LineCurveTool.cs" />
+ <Compile Include="Tools\MagicWandTool.cs" />
+ <Compile Include="Tools\MoveSelectedTool.cs" />
+ <Compile Include="Tools\MoveSelectionTool.cs" />
+ <Compile Include="Tools\PaintBrushTool.cs" />
+ <Compile Include="Tools\PaintBucketTool.cs" />
+ <Compile Include="Tools\PanTool.cs" />
+ <Compile Include="Tools\PencilTool.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="RecolorTool.cs" />
- <Compile Include="RectangleSelectTool.cs" />
- <Compile Include="RectangleTool.cs" />
- <Compile Include="RoundedRectangleTool.cs" />
- <Compile Include="SelectTool.cs" />
- <Compile Include="ShapeTool.cs" />
- <Compile Include="TextTool\Position.cs" />
- <Compile Include="TextTool\TextAlignment.cs" />
- <Compile Include="TextTool\EditingMode.cs" />
- <Compile Include="TextTool\TextEngine.cs" />
- <Compile Include="TextTool\TextTool.cs" />
- <Compile Include="CloneStampTool.cs" />
- <Compile Include="ZoomTool.cs" />
+ <Compile Include="Tools\RecolorTool.cs" />
+ <Compile Include="Tools\RectangleSelectTool.cs" />
+ <Compile Include="Tools\RectangleTool.cs" />
+ <Compile Include="Tools\RoundedRectangleTool.cs" />
+ <Compile Include="Tools\SelectTool.cs" />
+ <Compile Include="Tools\ShapeTool.cs" />
+ <Compile Include="Tools\TextTool\Position.cs" />
+ <Compile Include="Tools\TextTool\TextAlignment.cs" />
+ <Compile Include="Tools\TextTool\EditingMode.cs" />
+ <Compile Include="Tools\TextTool\TextEngine.cs" />
+ <Compile Include="Tools\TextTool\TextTool.cs" />
+ <Compile Include="Tools\CloneStampTool.cs" />
+ <Compile Include="Tools\ZoomTool.cs" />
<Compile Include="Brushes\PaintBrush.cs" />
<Compile Include="Brushes\GridBrush.cs" />
<Compile Include="Brushes\SquaresBrush.cs" />
View
0  Pinta.Tools/BaseBrushTool.cs → Pinta.Tools/Tools/BaseBrushTool.cs
File renamed without changes
View
1  Pinta.Tools/CloneStampTool.cs → Pinta.Tools/Tools/CloneStampTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class CloneStampTool : BaseBrushTool
{
private bool painting;
View
1  Pinta.Tools/ColorPickerTool.cs → Pinta.Tools/Tools/ColorPickerTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class ColorPickerTool : BaseTool
{
private int button_down = 0;
View
1  Pinta.Tools/EllipseSelectTool.cs → Pinta.Tools/Tools/EllipseSelectTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class EllipseSelectTool : SelectTool
{
public override string Name {
View
1  Pinta.Tools/EllipseTool.cs → Pinta.Tools/Tools/EllipseTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class EllipseTool : ShapeTool
{
public override string Name {
View
1  Pinta.Tools/EraserTool.cs → Pinta.Tools/Tools/EraserTool.cs
@@ -32,7 +32,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class EraserTool : BaseBrushTool
{
private Point last_point = point_empty;
View
0  Pinta.Tools/FloodTool.cs → Pinta.Tools/Tools/FloodTool.cs
File renamed without changes
View
1  Pinta.Tools/FreeformShapeTool.cs → Pinta.Tools/Tools/FreeformShapeTool.cs
@@ -32,7 +32,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class FreeformShapeTool : BaseBrushTool
{
private Point last_point = point_empty;
View
1  Pinta.Tools/GradientTool.cs → Pinta.Tools/Tools/GradientTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class GradientTool : BaseTool
{
Cairo.PointD startpoint;
View
1  Pinta.Tools/LassoSelectTool.cs → Pinta.Tools/Tools/LassoSelectTool.cs
@@ -32,7 +32,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class LassoSelectTool : SelectTool
{
private Path path;
View
1  Pinta.Tools/LineCurveTool.cs → Pinta.Tools/Tools/LineCurveTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class LineCurveTool : ShapeTool
{
public override string Name {
View
3  Pinta.Tools/MagicWandTool.cs → Pinta.Tools/Tools/MagicWandTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class MagicWandTool : FloodTool
{
private CombineMode combineMode;
@@ -55,7 +54,7 @@ public MagicWandTool ()
}
public override Gdk.Cursor DefaultCursor {
- get { return new Gdk.Cursor (PintaCore.Chrome.DrawingArea.Display, PintaCore.Resources.GetIcon ("Tools.MagicWand.png"), 0, 0); }
+ get { return new Gdk.Cursor (PintaCore.Chrome.Canvas.Display, PintaCore.Resources.GetIcon ("Tools.MagicWand.png"), 0, 0); }
}
public override int Priority { get { return 17; } }
View
3  Pinta.Tools/MoveSelectedTool.cs → Pinta.Tools/Tools/MoveSelectedTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class MoveSelectedTool : BaseTool
{
private PointD origin_offset;
@@ -48,7 +47,7 @@ public class MoveSelectedTool : BaseTool
get { return Catalog.GetString ("Drag the selection to move selected content."); }
}
public override Gdk.Cursor DefaultCursor {
- get { return new Gdk.Cursor (PintaCore.Chrome.DrawingArea.Display, PintaCore.Resources.GetIcon ("Tools.Move.png"), 0, 0); }
+ get { return new Gdk.Cursor (PintaCore.Chrome.Canvas.Display, PintaCore.Resources.GetIcon ("Tools.Move.png"), 0, 0); }
}
public override Gdk.Key ShortcutKey { get { return Gdk.Key.M; } }
public override int Priority { get { return 7; } }
View
3  Pinta.Tools/MoveSelectionTool.cs → Pinta.Tools/Tools/MoveSelectionTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class MoveSelectionTool : BaseTool
{
private PointD origin_offset;
@@ -48,7 +47,7 @@ public class MoveSelectionTool : BaseTool
get { return Catalog.GetString ("Drag the selection to move selection outline."); }
}
public override Gdk.Cursor DefaultCursor {
- get { return new Gdk.Cursor (PintaCore.Chrome.DrawingArea.Display, PintaCore.Resources.GetIcon ("Tools.MoveSelection.png"), 0, 0); }
+ get { return new Gdk.Cursor (PintaCore.Chrome.Canvas.Display, PintaCore.Resources.GetIcon ("Tools.MoveSelection.png"), 0, 0); }
}
public override Gdk.Key ShortcutKey { get { return Gdk.Key.M; } }
public override int Priority { get { return 11; } }
View
1  Pinta.Tools/PaintBrushTool.cs → Pinta.Tools/Tools/PaintBrushTool.cs
@@ -34,7 +34,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class PaintBrushTool : BaseBrushTool
{
#region Properties
View
1  Pinta.Tools/PaintBucketTool.cs → Pinta.Tools/Tools/PaintBucketTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class PaintBucketTool : FloodTool
{
private Color fill_color;
View
3  Pinta.Tools/PanTool.cs → Pinta.Tools/Tools/PanTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class PanTool : BaseTool
{
public override string Name {
@@ -44,7 +43,7 @@ public class PanTool : BaseTool
get { return Catalog.GetString ("Click and drag to navigate image."); }
}
public override Gdk.Cursor DefaultCursor {
- get { return new Gdk.Cursor (PintaCore.Chrome.DrawingArea.Display, PintaCore.Resources.GetIcon ("Tools.Pan.png"), 0, 0); }
+ get { return new Gdk.Cursor (PintaCore.Chrome.Canvas.Display, PintaCore.Resources.GetIcon ("Tools.Pan.png"), 0, 0); }
}
public override Gdk.Key ShortcutKey { get { return Gdk.Key.H; } }
public override int Priority { get { return 19; } }
View
1  Pinta.Tools/PencilTool.cs → Pinta.Tools/Tools/PencilTool.cs
@@ -32,7 +32,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class PencilTool : BaseTool
{
private Point last_point = point_empty;
View
1  Pinta.Tools/RecolorTool.cs → Pinta.Tools/Tools/RecolorTool.cs
@@ -41,7 +41,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class RecolorTool : BaseBrushTool
{
protected ToolBarLabel tolerance_label;
View
1  Pinta.Tools/RectangleSelectTool.cs → Pinta.Tools/Tools/RectangleSelectTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class RectangleSelectTool : SelectTool
{
public override string Name {
View
1  Pinta.Tools/RectangleTool.cs → Pinta.Tools/Tools/RectangleTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class RectangleTool : ShapeTool
{
public override string Name {
View
1  Pinta.Tools/RoundedRectangleTool.cs → Pinta.Tools/Tools/RoundedRectangleTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class RoundedRectangleTool : ShapeTool
{
protected ToolBarComboBox radius;
View
0  Pinta.Tools/SelectTool.cs → Pinta.Tools/Tools/SelectTool.cs
File renamed without changes
View
0  Pinta.Tools/ShapeTool.cs → Pinta.Tools/Tools/ShapeTool.cs
File renamed without changes
View
0  Pinta.Tools/TextTool/EditingMode.cs → Pinta.Tools/Tools/TextTool/EditingMode.cs
File renamed without changes
View
0  Pinta.Tools/TextTool/Position.cs → Pinta.Tools/Tools/TextTool/Position.cs
File renamed without changes
View
0  Pinta.Tools/TextTool/TextAlignment.cs → Pinta.Tools/Tools/TextTool/TextAlignment.cs
File renamed without changes
View
2  Pinta.Tools/TextTool/TextEngine.cs → Pinta.Tools/Tools/TextTool/TextEngine.cs
@@ -30,7 +30,7 @@ public TextEngine ()
{
lines = new List<string> ();
- layout = new Pango.Layout (PintaCore.Chrome.DrawingArea.PangoContext);
+ layout = new Pango.Layout (PintaCore.Chrome.Canvas.PangoContext);
}
#region Public Properties
View
11 Pinta.Tools/TextTool/TextTool.cs → Pinta.Tools/Tools/TextTool/TextTool.cs
@@ -17,7 +17,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class TextTool : BaseTool
{
// Variables for dragging
@@ -45,7 +44,7 @@ public class TextTool : BaseTool
#region Constructor
public TextTool ()
{
- cursor_hand = new Gdk.Cursor (PintaCore.Chrome.DrawingArea.Display, PintaCore.Resources.GetIcon ("Tools.Pan.png"), 0, 0);
+ cursor_hand = new Gdk.Cursor (PintaCore.Chrome.Canvas.Display, PintaCore.Resources.GetIcon ("Tools.Pan.png"), 0, 0);
engine = new TextEngine ();
}
#endregion
@@ -225,7 +224,7 @@ private void HandleFontSizeFocusOut (object o, FocusOutEventArgs args)
return;
}
- PintaCore.Chrome.DrawingArea.GrabFocus ();
+ PintaCore.Chrome.Canvas.GrabFocus ();
UpdateFont ();
@@ -234,7 +233,7 @@ private void HandleFontSizeFocusOut (object o, FocusOutEventArgs args)
private void HandleFontChanged (object sender, EventArgs e)
{
- PintaCore.Chrome.DrawingArea.GrabFocus ();
+ PintaCore.Chrome.Canvas.GrabFocus ();
UpdateFontSizes ();
UpdateFont ();
@@ -267,7 +266,7 @@ private void UpdateFontSizes ()
private void HandleSizeChanged (object sender, EventArgs e)
{
- PintaCore.Chrome.DrawingArea.GrabFocus ();
+ PintaCore.Chrome.Canvas.GrabFocus ();
UpdateFont ();
}
@@ -428,7 +427,7 @@ protected override void OnMouseDown (DrawingArea canvas, ButtonPressEventArgs ar
Point pt = point.ToGdkPoint ();
// Grab focus so we can get keystrokes
- PintaCore.Chrome.DrawingArea.GrabFocus ();
+ PintaCore.Chrome.Canvas.GrabFocus ();
// If we're in editing mode, a right click
// allows you to move the text around
View
9 Pinta.Tools/ZoomTool.cs → Pinta.Tools/Tools/ZoomTool.cs
@@ -31,7 +31,6 @@
namespace Pinta.Tools
{
- [Mono.Addins.Extension]
public class ZoomTool : BaseTool
{
private Gdk.Cursor cursorZoomIn;
@@ -64,10 +63,10 @@ public ZoomTool ()
{
this.mouseDown = 0;
- cursorZoomIn = new Gdk.Cursor (PintaCore.Chrome.DrawingArea.Display, PintaCore.Resources.GetIcon ("Menu.View.ZoomIn.png"), 0, 0);
- cursorZoomOut = new Gdk.Cursor (PintaCore.Chrome.DrawingArea.Display, PintaCore.Resources.GetIcon ("Menu.View.ZoomOut.png"), 0, 0);
- cursorZoom = new Gdk.Cursor (PintaCore.Chrome.DrawingArea.Display, PintaCore.Resources.GetIcon ("Tools.Zoom.png"), 0, 0);
- cursorZoomPan = new Gdk.Cursor (PintaCore.Chrome.DrawingArea.Display, PintaCore.Resources.GetIcon ("Tools.Pan.png"), 0, 0);
+ cursorZoomIn = new Gdk.Cursor (PintaCore.Chrome.Canvas.Display, PintaCore.Resources.GetIcon ("Menu.View.ZoomIn.png"), 0, 0);
+ cursorZoomOut = new Gdk.Cursor (PintaCore.Chrome.Canvas.Display, PintaCore.Resources.GetIcon ("Menu.View.ZoomOut.png"), 0, 0);
+ cursorZoom = new Gdk.Cursor (PintaCore.Chrome.Canvas.Display, PintaCore.Resources.GetIcon ("Tools.Zoom.png"), 0, 0);
+ cursorZoomPan = new Gdk.Cursor (PintaCore.Chrome.Canvas.Display, PintaCore.Resources.GetIcon ("Tools.Pan.png"), 0, 0);
}
protected void UpdateRectangle (PointD point)
View
80 Pinta/Actions/Edit/PasteIntoNewImageAction.cs
@@ -0,0 +1,80 @@
+//
+// PasteIntoNewImageAction.cs
+//
+// Author:
+// Jonathan Pobst <monkey@jpobst.com>
+//
+// Copyright (c) 2010 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 Gtk;
+using Mono.Unix;
+using Pinta.Core;
+
+namespace Pinta.Actions
+{
+ class PasteIntoNewImageAction : IActionHandler
+ {
+ #region IActionHandler Members
+ public void Initialize ()
+ {
+ PintaCore.Actions.Edit.PasteIntoNewImage.Activated += Activated;
+ }
+
+ public void Uninitialize ()
+ {
+ PintaCore.Actions.Edit.PasteIntoNewImage.Activated -= Activated;
+ }
+ #endregion
+
+ private void Activated (object sender, EventArgs e)
+ {
+ Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
+
+ if (cb.WaitIsImageAvailable ()) {
+ Gdk.Pixbuf image = cb.WaitForImage ();
+ Gdk.Size size = new Gdk.Size (image.Width, image.Height);
+
+ PintaCore.Workspace.NewDocument (size, true);
+ PintaCore.Actions.Edit.Paste.Activate ();
+ } else {
+ ClipboardEmptyError ();
+ }
+ }
+
+ private void ClipboardEmptyError ()
+ {
+ var primary = Catalog.GetString ("Paste cancelled");
+ var secondary = Catalog.GetString ("The clipboard does not contain an image");
+ var markup = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}\n";
+ markup = string.Format (markup, primary, secondary);
+
+ var md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal,
+ MessageType.Error, ButtonsType.None, true,
+ markup);
+
+ md.AddButton (Stock.Ok, ResponseType.Yes);
+
+ md.Run ();
+ md.Destroy ();
+ }
+ }
+}
View
91 Pinta/Actions/Edit/PasteIntoNewLayerAction.cs
@@ -0,0 +1,91 @@
+//
+// PasteIntoNewLayerAction.cs
+//
+// Author:
+// Jonathan Pobst <monkey@jpobst.com>
+//
+// Copyright (c) 2010 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 Gtk;
+using Mono.Unix;
+using Pinta.Core;
+
+namespace Pinta.Actions
+{
+ class PasteIntoNewLayerAction : IActionHandler
+ {
+ #region IActionHandler Members
+ public void Initialize ()
+ {
+ PintaCore.Actions.Edit.PasteIntoNewLayer.Activated += Activated;
+ }
+
+ public void Uninitialize ()
+ {
+ PintaCore.Actions.Edit.PasteIntoNewLayer.Activated -= Activated;
+ }
+ #endregion
+
+ private void Activated (object sender, EventArgs e)
+ {
+ Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
+
+ if (cb.WaitIsImageAvailable ()) {
+ PintaCore.Tools.Commit ();
+
+ Gdk.Pixbuf image = cb.WaitForImage ();
+
+ Layer l = PintaCore.Layers.AddNewLayer (string.Empty);
+
+ using (Cairo.Context g = new Cairo.Context (l.Surface))
+ g.DrawPixbuf (image, new Cairo.Point (0, 0));
+
+ // Make new layer the current layer
+ PintaCore.Layers.SetCurrentLayer (l);
+
+ PintaCore.Workspace.Invalidate ();
+
+ AddLayerHistoryItem hist = new AddLayerHistoryItem (Stock.Paste, Catalog.GetString ("Paste Into New Layer"), PintaCore.Layers.IndexOf (l));
+ PintaCore.History.PushNewItem (hist);
+ } else {
+ ClipboardEmptyError ();
+ }
+ }
+
+ private void ClipboardEmptyError ()
+ {
+ var primary = Catalog.GetString ("Paste cancelled");
+ var secondary = Catalog.GetString ("The clipboard does not contain an image");
+ var markup = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}\n";
+ markup = string.Format (markup, primary, secondary);
+
+ var md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal,
+ MessageType.Error, ButtonsType.None, true,
+ markup);
+
+ md.AddButton (Stock.Ok, ResponseType.Yes);
+
+ md.Run ();
+ md.Destroy ();
+ }
+ }
+}
View
61 Pinta/Actions/Edit/ResizePaletteAction.cs
@@ -0,0 +1,61 @@
+//
+// ResizePaletteAction.cs
+//
+// Author:
+// Jonathan Pobst <monkey@jpobst.com>
+//
+// Copyright (c) 2010 Jonathan Pobst
+//