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 | [Gtk.Binding(Gdk.Key.F11, "ToggleFullScreen")] |
---|
23 | |
---|
24 | public partial class MainWindow: Gtk.Window |
---|
25 | { |
---|
26 | public MainWindow (): base (Gtk.WindowType.Toplevel) |
---|
27 | { |
---|
28 | Build (); |
---|
29 | vpaned1.Add1(new ToolBox()); |
---|
30 | } |
---|
31 | |
---|
32 | protected void OnDeleteEvent (object sender, DeleteEventArgs a) |
---|
33 | { |
---|
34 | Application.Quit (); |
---|
35 | a.RetVal = true; |
---|
36 | } |
---|
37 | |
---|
38 | protected virtual void OnOpenActionActivated (object sender, System.EventArgs e) |
---|
39 | { |
---|
40 | string s = OpenFile.GetChoice(); |
---|
41 | if(s == null) |
---|
42 | return; |
---|
43 | |
---|
44 | Pipi.Picture p = Pipi.Picture.Load(s); |
---|
45 | if(p == null) |
---|
46 | { |
---|
47 | new ErrorWindow("Could not open \"" + s + "\". Check the file format."); |
---|
48 | return; |
---|
49 | } |
---|
50 | |
---|
51 | while(notebook1.NPages > 0) |
---|
52 | notebook1.RemovePage(0); |
---|
53 | int n = notebook1.AppendPage(new PictureView(p), |
---|
54 | new Label(p.FileName)); |
---|
55 | notebook1.Page = n; |
---|
56 | } |
---|
57 | |
---|
58 | protected virtual void OnNewActionActivated (object sender, System.EventArgs e) |
---|
59 | { |
---|
60 | NewFile dialog = new NewFile(); |
---|
61 | |
---|
62 | string s = dialog.GetChoice(); |
---|
63 | dialog.Destroy(); |
---|
64 | if(s == null) |
---|
65 | return; |
---|
66 | |
---|
67 | Pipi.Picture p = Pipi.Picture.Load(s); |
---|
68 | if(p == null) |
---|
69 | { |
---|
70 | new ErrorWindow("Could not create image."); |
---|
71 | return; |
---|
72 | } |
---|
73 | |
---|
74 | while(notebook1.NPages > 0) |
---|
75 | notebook1.RemovePage(0); |
---|
76 | int n = notebook1.AppendPage(new PictureView(p), |
---|
77 | new Label(p.FileName)); |
---|
78 | notebook1.Page = n; |
---|
79 | } |
---|
80 | |
---|
81 | protected virtual void OnQuitActionActivated (object sender, System.EventArgs e) |
---|
82 | { |
---|
83 | Application.Quit (); |
---|
84 | } |
---|
85 | |
---|
86 | protected virtual void OnSaveAsActionActivated (object sender, System.EventArgs e) |
---|
87 | { |
---|
88 | if(notebook1.NPages <= 0) |
---|
89 | return; |
---|
90 | |
---|
91 | PictureView view = notebook1.CurrentPageWidget as PictureView; |
---|
92 | |
---|
93 | string s = OpenFile.GetChoice(); |
---|
94 | if(s == null) |
---|
95 | return; |
---|
96 | |
---|
97 | view.Picture.Save(s); |
---|
98 | } |
---|
99 | |
---|
100 | protected virtual void OnAboutActionActivated (object sender, System.EventArgs e) |
---|
101 | { |
---|
102 | new AboutWindow(); |
---|
103 | } |
---|
104 | |
---|
105 | protected virtual void OnSaveActionActivated (object sender, System.EventArgs e) |
---|
106 | { |
---|
107 | } |
---|
108 | |
---|
109 | private bool _fullscreen = false; |
---|
110 | protected virtual void ToggleFullScreen() |
---|
111 | { |
---|
112 | _fullscreen = !_fullscreen; |
---|
113 | |
---|
114 | if(_fullscreen) |
---|
115 | Fullscreen(); |
---|
116 | else |
---|
117 | Unfullscreen(); |
---|
118 | } |
---|
119 | |
---|
120 | protected virtual void OnFullscreenActionActivated (object sender, System.EventArgs e) |
---|
121 | { |
---|
122 | ToggleFullScreen(); |
---|
123 | } |
---|
124 | } |
---|
125 | } |
---|