diff --git a/ThePimp/ErrorWindow.cs b/ThePimp/ErrorWindow.cs new file mode 100644 index 0000000..f99d1a3 --- /dev/null +++ b/ThePimp/ErrorWindow.cs @@ -0,0 +1,33 @@ +// +// The Pimp The Pathetic Image Manipulation Program +// Copyright (c) 2004-2008 Sam Hocevar +// All Rights Reserved +// +// $Id$ +// +// This library is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What The Fuck You Want +// To Public License, Version 2, as published by Sam Hocevar. See +// http://sam.zoy.org/wtfpl/COPYING for more details. +// + +using System; + +namespace ThePimp +{ + public partial class ErrorWindow : Gtk.Dialog + { + public ErrorWindow(string message) + { + this.Build(); + this.message.Text = message; + this.Run(); + } + + protected virtual void OnButtonOkClicked (object sender, System.EventArgs e) + { + this.Destroy(); + } + } +} diff --git a/ThePimp/Main.cs b/ThePimp/Main.cs index 97f23f3..dee024d 100644 --- a/ThePimp/Main.cs +++ b/ThePimp/Main.cs @@ -14,6 +14,7 @@ using System; using Gtk; +using Pipi; namespace ThePimp { @@ -21,6 +22,8 @@ namespace ThePimp { public static void Main (string[] args) { + Libpipi.getVersion(); + Application.Init (); MainWindow win = new MainWindow (); win.Show (); diff --git a/ThePimp/MainWindow.cs b/ThePimp/MainWindow.cs index f03ac24..e8d27d9 100644 --- a/ThePimp/MainWindow.cs +++ b/ThePimp/MainWindow.cs @@ -24,7 +24,6 @@ namespace ThePimp public MainWindow (): base (Gtk.WindowType.Toplevel) { Build (); - Title += " v" + Libpipi.getVersion(); vpaned1.Add1(new ToolBox()); } @@ -36,32 +35,48 @@ namespace ThePimp protected virtual void OnOpenActionActivated (object sender, System.EventArgs e) { - OpenFile open = new OpenFile(); - Pipi.Picture p = open.Load(); - open.Destroy(); - if(p != null) + OpenFile dialog = new OpenFile(); + + string s = dialog.GetChoice(); + dialog.Destroy(); + if(s == null) + return; + + Pipi.Picture p = Pipi.Picture.Load(s); + if(p == null) { - while(notebook1.NPages > 0) - notebook1.RemovePage(0); - int n = notebook1.AppendPage(new PictureView(p), - new Label(p.FileName)); - notebook1.Page = n; + new ErrorWindow("Could not open \"" + s + "\". Check the file format."); + return; } + + while(notebook1.NPages > 0) + notebook1.RemovePage(0); + int n = notebook1.AppendPage(new PictureView(p), + new Label(p.FileName)); + notebook1.Page = n; } protected virtual void OnNewActionActivated (object sender, System.EventArgs e) { NewFile dialog = new NewFile(); - Pipi.Picture p = dialog.New(); + + string s = dialog.GetChoice(); dialog.Destroy(); - if(p != null) + if(s == null) + return; + + Pipi.Picture p = Pipi.Picture.Load(s); + if(p == null) { - while(notebook1.NPages > 0) - notebook1.RemovePage(0); - int n = notebook1.AppendPage(new PictureView(p), - new Label(p.FileName)); - notebook1.Page = n; + new ErrorWindow("Could not create image."); + return; } + + while(notebook1.NPages > 0) + notebook1.RemovePage(0); + int n = notebook1.AppendPage(new PictureView(p), + new Label(p.FileName)); + notebook1.Page = n; } protected virtual void OnQuitActionActivated (object sender, System.EventArgs e) diff --git a/ThePimp/Makefile.am b/ThePimp/Makefile.am index b61b22c..ecdde5e 100644 --- a/ThePimp/Makefile.am +++ b/ThePimp/Makefile.am @@ -4,6 +4,7 @@ pimp_sources = \ AssemblyInfo.cs \ Main.cs \ AboutWindow.cs \ + ErrorWindow.cs \ MainWindow.cs \ OpenFile.cs \ NewFile.cs \ @@ -12,6 +13,7 @@ pimp_sources = \ ToolBox.cs \ gtk-gui/generated.cs \ gtk-gui/ThePimp.AboutWindow.cs \ + gtk-gui/ThePimp.ErrorWindow.cs \ gtk-gui/ThePimp.MainWindow.cs \ gtk-gui/ThePimp.OpenFile.cs \ gtk-gui/ThePimp.NewFile.cs \ diff --git a/ThePimp/NewFile.cs b/ThePimp/NewFile.cs index d799be6..c0dac79 100644 --- a/ThePimp/NewFile.cs +++ b/ThePimp/NewFile.cs @@ -24,7 +24,7 @@ namespace ThePimp this.Build(); } - public Pipi.Picture New() + public string GetChoice() { ResponseType rsp = (ResponseType)Run(); Hide(); @@ -42,8 +42,7 @@ namespace ThePimp break; } - Pipi.Picture p = new Pipi.Picture(type + ":" + entry1.Text + "x" + entry2.Text); - return p; + return type + ":" + entry1.Text + "x" + entry2.Text; } } } diff --git a/ThePimp/OpenFile.cs b/ThePimp/OpenFile.cs index c8c89d5..b430bcc 100644 --- a/ThePimp/OpenFile.cs +++ b/ThePimp/OpenFile.cs @@ -23,15 +23,15 @@ namespace ThePimp { this.Build(); } - - public Pipi.Picture Load() + + public string GetChoice() { ResponseType rsp = (ResponseType)Run(); Hide(); if(rsp != ResponseType.Ok) return null; - Pipi.Picture p = new Pipi.Picture(filechooserwidget1.Filename); - return p; + + return filechooserwidget1.Filename; } } } diff --git a/ThePimp/ThePimp.csproj b/ThePimp/ThePimp.csproj index ee2f152..ae99bb0 100644 --- a/ThePimp/ThePimp.csproj +++ b/ThePimp/ThePimp.csproj @@ -14,7 +14,7 @@ true full false - .\bin + bin\ DEBUG;TRACE prompt 4 @@ -27,7 +27,7 @@ pdbonly true - .\bin + bin\ TRACE prompt 4 @@ -92,6 +92,8 @@ + + @@ -100,9 +102,9 @@ + -