1 | // |
---|
2 | // The Pimp The Pathetic Image Manipulation Program |
---|
3 | // Copyright (c) 2008 Sam Hocevar <sam@zoy.org> |
---|
4 | // All Rights Reserved |
---|
5 | // |
---|
6 | // $Id$ |
---|
7 | // |
---|
8 | // This library is free software. It comes without any warranty, to |
---|
9 | // the extent permitted by applicable law. You can redistribute it |
---|
10 | // and/or modify it under the terms of the Do What The Fuck You Want |
---|
11 | // To Public License, Version 2, as published by Sam Hocevar. See |
---|
12 | // http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
13 | // |
---|
14 | |
---|
15 | using System; |
---|
16 | using Gtk; |
---|
17 | using Pipi; |
---|
18 | using ThePimp; |
---|
19 | |
---|
20 | namespace ThePimp |
---|
21 | { |
---|
22 | public partial class MainWindow: Gtk.Window |
---|
23 | { |
---|
24 | public MainWindow (): base (Gtk.WindowType.Toplevel) |
---|
25 | { |
---|
26 | Build (); |
---|
27 | vpaned1.Add1(new ToolBox()); |
---|
28 | } |
---|
29 | |
---|
30 | protected void OnDeleteEvent (object sender, DeleteEventArgs a) |
---|
31 | { |
---|
32 | Application.Quit (); |
---|
33 | a.RetVal = true; |
---|
34 | } |
---|
35 | |
---|
36 | protected virtual void OnOpenActionActivated (object sender, System.EventArgs e) |
---|
37 | { |
---|
38 | OpenFile dialog = new OpenFile(); |
---|
39 | |
---|
40 | string s = dialog.GetChoice(); |
---|
41 | dialog.Destroy(); |
---|
42 | if(s == null) |
---|
43 | return; |
---|
44 | |
---|
45 | Pipi.Picture p = Pipi.Picture.Load(s); |
---|
46 | if(p == null) |
---|
47 | { |
---|
48 | new ErrorWindow("Could not open \"" + s + "\". Check the file format."); |
---|
49 | return; |
---|
50 | } |
---|
51 | |
---|
52 | while(notebook1.NPages > 0) |
---|
53 | notebook1.RemovePage(0); |
---|
54 | int n = notebook1.AppendPage(new PictureView(p), |
---|
55 | new Label(p.FileName)); |
---|
56 | notebook1.Page = n; |
---|
57 | } |
---|
58 | |
---|
59 | protected virtual void OnNewActionActivated (object sender, System.EventArgs e) |
---|
60 | { |
---|
61 | NewFile dialog = new NewFile(); |
---|
62 | |
---|
63 | string s = dialog.GetChoice(); |
---|
64 | dialog.Destroy(); |
---|
65 | if(s == null) |
---|
66 | return; |
---|
67 | |
---|
68 | Pipi.Picture p = Pipi.Picture.Load(s); |
---|
69 | if(p == null) |
---|
70 | { |
---|
71 | new ErrorWindow("Could not create image."); |
---|
72 | return; |
---|
73 | } |
---|
74 | |
---|
75 | while(notebook1.NPages > 0) |
---|
76 | notebook1.RemovePage(0); |
---|
77 | int n = notebook1.AppendPage(new PictureView(p), |
---|
78 | new Label(p.FileName)); |
---|
79 | notebook1.Page = n; |
---|
80 | } |
---|
81 | |
---|
82 | protected virtual void OnQuitActionActivated (object sender, System.EventArgs e) |
---|
83 | { |
---|
84 | Application.Quit (); |
---|
85 | } |
---|
86 | |
---|
87 | protected virtual void OnSaveAsActionActivated (object sender, System.EventArgs e) |
---|
88 | { |
---|
89 | if(notebook1.NPages <= 0) |
---|
90 | return; |
---|
91 | SaveFile save = new SaveFile(); |
---|
92 | PictureView view = notebook1.CurrentPageWidget as PictureView; |
---|
93 | save.Save(view.Picture); |
---|
94 | save.Destroy(); |
---|
95 | } |
---|
96 | |
---|
97 | protected virtual void OnAboutActionActivated (object sender, System.EventArgs e) |
---|
98 | { |
---|
99 | new AboutWindow(); |
---|
100 | } |
---|
101 | |
---|
102 | protected virtual void OnSaveActionActivated (object sender, System.EventArgs e) |
---|
103 | { |
---|
104 | } |
---|
105 | } |
---|
106 | } |
---|