Pārlūkot izejas kodu

ThePimp: make file dialogs singletons so that they retain their properties

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-862c8a59935f
master
sam pirms 16 gadiem
vecāks
revīzija
ee94ff9fa6
3 mainītis faili ar 31 papildinājumiem un 18 dzēšanām
  1. +8
    -7
      ThePimp/src/MainWindow.cs
  2. +11
    -5
      ThePimp/src/OpenFile.cs
  3. +12
    -6
      ThePimp/src/SaveFile.cs

+ 8
- 7
ThePimp/src/MainWindow.cs Parādīt failu

@@ -37,10 +37,7 @@ namespace ThePimp

protected virtual void OnOpenActionActivated (object sender, System.EventArgs e)
{
OpenFile dialog = new OpenFile();

string s = dialog.GetChoice();
dialog.Destroy();
string s = OpenFile.GetChoice();
if(s == null)
return;

@@ -90,10 +87,14 @@ namespace ThePimp
{
if(notebook1.NPages <= 0)
return;
SaveFile save = new SaveFile();
PictureView view = notebook1.CurrentPageWidget as PictureView;
save.Save(view.Picture);
save.Destroy();

string s = OpenFile.GetChoice();
if(s == null)
return;

view.Picture.Save(s);
}

protected virtual void OnAboutActionActivated (object sender, System.EventArgs e)


+ 11
- 5
ThePimp/src/OpenFile.cs Parādīt failu

@@ -19,18 +19,24 @@ namespace ThePimp
{
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();
}

public string GetChoice()
public static string GetChoice()
{
ResponseType rsp = (ResponseType)Run();
Hide();
instance.ShowAll();
ResponseType rsp = (ResponseType)instance.Run();
instance.Hide();
if(rsp != ResponseType.Ok)
return null;
return filechooserwidget1.Filename;
return instance.filechooserwidget1.Filename;
}

protected virtual void OnFilechooserwidget1FileActivated (object sender, System.EventArgs e)


+ 12
- 6
ThePimp/src/SaveFile.cs Parādīt failu

@@ -19,18 +19,24 @@ namespace ThePimp
{
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();
}

public void Save(Pipi.Picture p)
public static string GetChoice()
{
ResponseType rsp = (ResponseType)Run();
Hide();
instance.ShowAll();
ResponseType rsp = (ResponseType)instance.Run();
instance.Hide();
if(rsp != ResponseType.Ok)
return;
p.Save(filechooserwidget1.Filename);
return null;
return instance.filechooserwidget1.Filename;
}

protected virtual void OnFilechooserwidget1FileActivated (object sender, System.EventArgs e)


Notiek ielāde…
Atcelt
Saglabāt