[longomatch] Store last dir openning images



commit b8ff2d1db357b8e74050e370b5f880f2ef04d139
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu May 29 15:37:47 2014 +0200

    Store last dir openning images

 LongoMatch.GUI.Helpers/Misc.cs |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch.GUI.Helpers/Misc.cs b/LongoMatch.GUI.Helpers/Misc.cs
index e0fb908..8bcbd6f 100644
--- a/LongoMatch.GUI.Helpers/Misc.cs
+++ b/LongoMatch.GUI.Helpers/Misc.cs
@@ -29,6 +29,8 @@ namespace LongoMatch.Gui.Helpers
 {
        public class Misc
        {
+               public static string lastFilename;
+               
                public static FileFilter GetFileFilter() {
                        FileFilter filter = new FileFilter();
                        filter.Name = "Images";
@@ -43,16 +45,25 @@ namespace LongoMatch.Gui.Helpers
                        Pixbuf pimage = null;
                        StreamReader file;
                        FileChooserDialog fChooser;
+                       string lastDir;
+                       
+                        if (lastFilename != null) {
+                               lastDir = Path.GetDirectoryName (lastFilename);
+                        } else {
+                               lastDir = Config.HomeDir;
+                        }
                        
                        fChooser = new FileChooserDialog(Catalog.GetString("Choose an image"),
                                                         toplevel, FileChooserAction.Open,
                                                         "gtk-cancel",ResponseType.Cancel,
                                                         "gtk-open",ResponseType.Accept);
                        fChooser.AddFilter(GetFileFilter());
+                       fChooser.SetCurrentFolder (lastDir);
                        if(fChooser.Run() == (int)ResponseType.Accept)  {
                                // For Win32 compatibility we need to open the image file
                                // using a StreamReader. Gdk.Pixbuf(string filePath) uses GLib to open the
                                // input file and doesn't support Win32 files path encoding
+                               lastFilename = fChooser.Filename;
                                file = new StreamReader(fChooser.Filename);
                                pimage= new Gdk.Pixbuf(file.BaseStream);
                                file.Close();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]