and do not take ages to build. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3145 92316355-f0b4-4df1-b90c-862c8a59935fmaster
@@ -37,10 +37,7 @@ namespace ThePimp | |||||
protected virtual void OnOpenActionActivated (object sender, System.EventArgs e) | protected virtual void OnOpenActionActivated (object sender, System.EventArgs e) | ||||
{ | { | ||||
OpenFile dialog = new OpenFile(); | string s = OpenFile.GetChoice(); | ||||
string s = dialog.GetChoice(); | |||||
dialog.Destroy(); | |||||
if(s == null) | if(s == null) | ||||
return; | return; | ||||
@@ -90,10 +87,14 @@ namespace ThePimp | |||||
{ | { | ||||
if(notebook1.NPages <= 0) | if(notebook1.NPages <= 0) | ||||
return; | return; | ||||
SaveFile save = new SaveFile(); | |||||
PictureView view = notebook1.CurrentPageWidget as PictureView; | PictureView view = notebook1.CurrentPageWidget as PictureView; | ||||
save.Save(view.Picture); | string s = OpenFile.GetChoice(); | ||||
save.Destroy(); | if(s == null) | ||||
return; | |||||
view.Picture.Save(s); | |||||
} | } | ||||
protected virtual void OnAboutActionActivated (object sender, System.EventArgs e) | protected virtual void OnAboutActionActivated (object sender, System.EventArgs e) | ||||
@@ -19,18 +19,24 @@ namespace ThePimp | |||||
{ | { | ||||
public partial class OpenFile : Gtk.Dialog | public partial class OpenFile : Gtk.Dialog | ||||
{ | { | ||||
public OpenFile() | private static readonly OpenFile instance = new OpenFile(); | ||||
// Do not mark type as beforefieldinit | |||||
static OpenFile() {} | |||||
private OpenFile() | |||||
{ | { | ||||
this.Build(); | this.Build(); | ||||
} | } | ||||
public string GetChoice() | public static string GetChoice() | ||||
{ | { | ||||
ResponseType rsp = (ResponseType)Run(); | instance.ShowAll(); | ||||
Hide(); | ResponseType rsp = (ResponseType)instance.Run(); | ||||
instance.Hide(); | |||||
if(rsp != ResponseType.Ok) | if(rsp != ResponseType.Ok) | ||||
return null; | return null; | ||||
return filechooserwidget1.Filename; | return instance.filechooserwidget1.Filename; | ||||
} | } | ||||
protected virtual void OnFilechooserwidget1FileActivated (object sender, System.EventArgs e) | protected virtual void OnFilechooserwidget1FileActivated (object sender, System.EventArgs e) | ||||
@@ -19,18 +19,24 @@ namespace ThePimp | |||||
{ | { | ||||
public partial class SaveFile : Gtk.Dialog | public partial class SaveFile : Gtk.Dialog | ||||
{ | { | ||||
public SaveFile() | private static readonly SaveFile instance = new SaveFile(); | ||||
// Do not mark type as beforefieldinit | |||||
static SaveFile() {} | |||||
private SaveFile() | |||||
{ | { | ||||
this.Build(); | this.Build(); | ||||
} | } | ||||
public void Save(Pipi.Picture p) | public static string GetChoice() | ||||
{ | { | ||||
ResponseType rsp = (ResponseType)Run(); | instance.ShowAll(); | ||||
Hide(); | ResponseType rsp = (ResponseType)instance.Run(); | ||||
instance.Hide(); | |||||
if(rsp != ResponseType.Ok) | if(rsp != ResponseType.Ok) | ||||
return; | return null; | ||||
p.Save(filechooserwidget1.Filename); | return instance.filechooserwidget1.Filename; | ||||
} | } | ||||
protected virtual void OnFilechooserwidget1FileActivated (object sender, System.EventArgs e) | protected virtual void OnFilechooserwidget1FileActivated (object sender, System.EventArgs e) | ||||