44
44
public FileActions ()
46
New = new Gtk.Action ("New", Mono.Unix.Catalog.GetString ("New"), null, "gtk-new");
47
Open = new Gtk.Action ("Open", Mono.Unix.Catalog.GetString ("Open"), null, "gtk-open");
46
New = new Gtk.Action ("New", Mono.Unix.Catalog.GetString ("New..."), null, "gtk-new");
47
Open = new Gtk.Action ("Open", Mono.Unix.Catalog.GetString ("Open..."), null, "gtk-open");
48
48
OpenRecent = new Gtk.Action ("OpenRecent", Mono.Unix.Catalog.GetString ("Open Recent"), null, "gtk-open");
49
49
Close = new Gtk.Action ("Close", Mono.Unix.Catalog.GetString ("Close"), null, "gtk-close");
50
50
Save = new Gtk.Action ("Save", Mono.Unix.Catalog.GetString ("Save"), null, "gtk-save");
51
SaveAs = new Gtk.Action ("SaveAs", Mono.Unix.Catalog.GetString ("Save As"), null, "gtk-save-as");
51
SaveAs = new Gtk.Action ("SaveAs", Mono.Unix.Catalog.GetString ("Save As..."), null, "gtk-save-as");
52
52
Print = new Gtk.Action ("Print", Mono.Unix.Catalog.GetString ("Print"), null, "gtk-print");
53
Exit = new Gtk.Action ("Exit", Mono.Unix.Catalog.GetString ("Exit"), null, "gtk-quit");
53
Exit = new Gtk.Action ("Exit", Mono.Unix.Catalog.GetString ("Quit"), null, "gtk-quit");
55
55
OpenRecent.Sensitive = false;
56
56
Close.Sensitive = false;
87
#region Action Handlers
88
private void HandlePintaCoreActionsFileOpenActivated (object sender, EventArgs e)
87
#region Public Methods
88
public void OpenFile (string file)
90
Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Open Image File", PintaCore.Chrome.MainWindow, FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Open, Gtk.ResponseType.Ok);
92
int response = fcd.Run ();
94
if (response == (int)Gtk.ResponseType.Ok) {
96
string file = fcd.Filename;
91
// Open the image and add it to the layers
92
Pixbuf bg = new Pixbuf (file);
98
94
PintaCore.Layers.Clear ();
99
95
PintaCore.History.Clear ();
100
96
PintaCore.Layers.DestroySelectionLayer ();
102
// Open the image and add it to the layers
103
Pixbuf bg = new Pixbuf (file);
105
PintaCore.Workspace.ImageSize = new Cairo.PointD (bg.Width, bg.Height);
106
PintaCore.Workspace.CanvasSize = new Cairo.PointD (bg.Width, bg.Height);
98
PintaCore.Workspace.ImageSize = new Cairo.Point (bg.Width, bg.Height);
99
PintaCore.Workspace.CanvasSize = new Cairo.Point (bg.Width, bg.Height);
108
101
PintaCore.Layers.ResetSelectionPath ();
110
103
Layer layer = PintaCore.Layers.AddNewLayer (System.IO.Path.GetFileName (file));
112
105
using (Cairo.Context g = new Cairo.Context (layer.Surface)) {
113
106
CairoHelper.SetSourcePixbuf (g, bg, 0, 0);
119
112
PintaCore.Workspace.Filename = System.IO.Path.GetFileName (file);
113
PintaCore.History.PushNewItem (new BaseHistoryItem ("gtk-open", "Open Image"));
120
114
PintaCore.Workspace.IsDirty = false;
115
PintaCore.Actions.View.ZoomToWindow.Activate ();
122
116
PintaCore.Workspace.Invalidate ();
123
PintaCore.Actions.View.ZoomToWindow.Activate ();
118
MessageDialog md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Could not open file: {0}", file);
127
#region Action Handlers
128
private void HandlePintaCoreActionsFileOpenActivated (object sender, EventArgs e)
130
Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Open Image File", PintaCore.Chrome.MainWindow, FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Open, Gtk.ResponseType.Ok);
132
int response = fcd.Run ();
134
if (response == (int)Gtk.ResponseType.Ok)
135
OpenFile (fcd.Filename);