Skip to content
Browse files

[Fix bug #992699] Use correct parent for the Jpeg Compression dialog.

The parent window is now passed to the file exporter, which will also
allow custom file format exporters from addins to properly create
dialogs if needed.
  • Loading branch information...
1 parent 3cf18ee commit 0b56adc0239e16da42264b4205bbb36eca737fe2 @cameronwhite cameronwhite committed May 2, 2013
View
4 Pinta.Core/Actions/FileActions.cs
@@ -117,9 +117,9 @@ internal bool RaiseSaveDocument (Document document, bool saveAs)
return !e.Cancel;
}
- internal int RaiseModifyCompression (int defaultCompression)
+ internal int RaiseModifyCompression (int defaultCompression, Gtk.Window parent)
{
- ModifyCompressionEventArgs e = new ModifyCompressionEventArgs (defaultCompression);
+ ModifyCompressionEventArgs e = new ModifyCompressionEventArgs (defaultCompression, parent);
if (ModifyCompression != null)
ModifyCompression (this, e);
View
4 Pinta.Core/EventArgs/ModifyCompressionEventArgs.cs
@@ -32,11 +32,13 @@ public class ModifyCompressionEventArgs: EventArgs
{
public int Quality { get; set; }
public bool Cancel { get; set; }
+ public Gtk.Window ParentWindow { get; set; }
- public ModifyCompressionEventArgs (int quality)
+ public ModifyCompressionEventArgs (int quality, Gtk.Window parent)
{
this.Quality = quality;
this.Cancel = false;
+ this.ParentWindow = parent;
}
}
}
View
6 Pinta.Core/ImageFormats/GdkPixbufFormat.cs
@@ -94,17 +94,17 @@ public Pixbuf LoadThumbnail (string filename, int maxWidth, int maxHeight)
#endregion
- protected virtual void DoSave (Pixbuf pb, string fileName, string fileType)
+ protected virtual void DoSave (Pixbuf pb, string fileName, string fileType, Gtk.Window parent)
{
pb.SaveUtf8(fileName, fileType);
}
- public void Export (Document document, string fileName)
+ public void Export (Document document, string fileName, Gtk.Window parent)
{
Cairo.ImageSurface surf = document.GetFlattenedImage ();
Pixbuf pb = surf.ToPixbuf ();
- DoSave(pb, fileName, filetype);
+ DoSave(pb, fileName, filetype, parent);
(pb as IDisposable).Dispose ();
(surf as IDisposable).Dispose ();
View
11 Pinta.Core/ImageFormats/IImageExporter.cs
@@ -35,6 +35,15 @@ public interface IImageExporter
/// <summary>
/// Exports a document to a file.
/// </summary>
- void Export (Document document, string fileName);
+ /// <param name='document'>
+ /// The document to be saved.
+ /// </param>
+ /// <param name='fileName'>
+ /// File name to save to.
+ /// </param>
+ /// <param name='parent'>
+ /// Window to be used as a parent for any dialogs that are shown.
+ /// </param>
+ void Export (Document document, string fileName, Gtk.Window parent);
}
}
View
4 Pinta.Core/ImageFormats/JpegFormat.cs
@@ -46,7 +46,7 @@ public JpegFormat()
{
}
- protected override void DoSave(Pixbuf pb, string fileName, string fileType)
+ protected override void DoSave(Pixbuf pb, string fileName, string fileType, Gtk.Window parent)
{
//Load the JPG compression quality, but use the default value if there is no saved value.
int level = PintaCore.Settings.GetSetting<int>(JpgCompressionQualitySetting, defaultQuality);
@@ -56,7 +56,7 @@ protected override void DoSave(Pixbuf pb, string fileName, string fileType)
{
//Show the user the JPG export compression quality dialog, with the default
//value being the one loaded in (or the default value if it was not saved).
- level = PintaCore.Actions.File.RaiseModifyCompression(level);
+ level = PintaCore.Actions.File.RaiseModifyCompression(level, parent);
}
if (level != -1)
View
2 Pinta.Core/ImageFormats/OraFormat.cs
@@ -186,7 +186,7 @@ private byte[] GetLayerXmlData(List<UserLayer> layers)
return ms.ToArray ();
}
- public void Export (Document document, string fileName)
+ public void Export (Document document, string fileName, Gtk.Window parent)
{
ZipOutputStream stream = new ZipOutputStream (new FileStream (fileName, FileMode.Create));
ZipEntry mimetype = new ZipEntry ("mimetype");
View
2 Pinta.Core/ImageFormats/TgaExporter.cs
@@ -89,7 +89,7 @@ public void WriteTo (BinaryWriter output)
// For now, we only export in uncompressed ARGB32 format. If someone requests this functionality,
// we can always add more through an export dialog.
- public void Export (Document document, string fileName) {
+ public void Export (Document document, string fileName, Gtk.Window parent) {
ImageSurface surf = document.GetFlattenedImage (); // Assumes the surface is in ARGB32 format
BinaryWriter writer = new BinaryWriter (new FileStream (fileName, FileMode.Create, FileAccess.Write));
View
2 Pinta/Actions/File/ModifyCompressionAction.cs
@@ -47,7 +47,7 @@ public void Uninitialize ()
private void Activated (object sender, ModifyCompressionEventArgs e)
{
- JpegCompressionDialog dlg = new JpegCompressionDialog (e.Quality);
+ JpegCompressionDialog dlg = new JpegCompressionDialog (e.Quality, e.ParentWindow);
try {
if (dlg.Run () == (int)Gtk.ResponseType.Ok)
View
2 Pinta/Actions/File/SaveDocumentImplementationAction.cs
@@ -207,7 +207,7 @@ private bool SaveFile (Document document, string file, FormatDescriptor format,
PintaCore.Tools.Commit ();
try {
- format.Exporter.Export (document, file);
+ format.Exporter.Export (document, file, parent);
} catch (GLib.GException e) { // Errors from GDK
if (e.Message == "Image too large to be saved as ICO") {
string primary = Catalog.GetString ("Image too large");
View
5 Pinta/Dialogs/JpegCompressionDialog.cs
@@ -34,8 +34,8 @@ public class JpegCompressionDialog : Dialog
{
private HScale compressionLevel;
- public JpegCompressionDialog (int defaultQuality)
- : base (Catalog.GetString ("JPEG Quality"), Pinta.Core.PintaCore.Chrome.MainWindow, DialogFlags.Modal | DialogFlags.DestroyWithParent,
+ public JpegCompressionDialog (int defaultQuality, Gtk.Window parent)
+ : base (Catalog.GetString ("JPEG Quality"), parent, DialogFlags.Modal | DialogFlags.DestroyWithParent,
Stock.Cancel, ResponseType.Cancel, Stock.Ok, ResponseType.Ok)
{
this.BorderWidth = 6;
@@ -44,7 +44,6 @@ public JpegCompressionDialog (int defaultQuality)
content.Spacing = 5;
DefaultResponse = ResponseType.Ok;
- TransientFor = (Gtk.Window)Parent;
Label label = new Label (Catalog.GetString ("Quality: "));
label.Xalign = 0;

0 comments on commit 0b56adc

Please sign in to comment.
Something went wrong with that request. Please try again.