[longomatch] GUIToolkit: add a new function to open several files



commit a1e2622199fe8e4d0c6fb4d47fbd4a2a72bad048
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Mar 24 11:18:00 2013 +0100

    GUIToolkit: add a new function to open several files

 LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs |    2 +
 LongoMatch.GUI/Gui/GUIToolkit.cs              |   32 ++++++++++++++++++++----
 2 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
index ceb8510..61d6019 100644
--- a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
@@ -41,6 +41,8 @@ namespace LongoMatch.Interfaces.GUI
                        string filterName, string extensionFilter);
                string OpenFile(string title, string defaultName, string defaultFolder,
                        string filterName, string extensionFilter);
+               List<string> OpenFiles(string title, string defaultName, string defaultFolder,
+                       string filterName, string extensionFilter);
                string SelectFolder(string title, string defaultName, string defaultFolder,
                        string filterName, string extensionFilter);
                        
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index a474030..28905d2 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -107,6 +107,13 @@ namespace LongoMatch.Gui
                                extensionFilter, FileChooserAction.Open);
                }
                
+               public List<string> OpenFiles(string title, string defaultName, string defaultFolder,
+                       string filterName, string extensionFilter)
+               {
+                       return MultiFileChooser(title, defaultName, defaultFolder, filterName,
+                               extensionFilter, FileChooserAction.Open);
+               }
+               
                public List<EditionJob> ConfigureRenderingJob (IPlayList playlist)
                {
                        VideoEditionProperties vep;
@@ -325,12 +332,24 @@ namespace LongoMatch.Gui
                }
                
                string  FileChooser(string title, string defaultName,
-                       string defaultFolder, string filterName, string extensionFilter,
-                       FileChooserAction action)
+                                   string defaultFolder, string filterName, string extensionFilter,
+                                   FileChooserAction action)
+               {
+                       List<string> res = MultiFileChooser(title, defaultName, defaultFolder, filterName,
+                                                     extensionFilter, action, false);
+                       if (res.Count == 1)
+                               return res[0];
+                       return null;
+               }
+               
+               List<string>  MultiFileChooser(string title, string defaultName,
+                                              string defaultFolder, string filterName, string 
extensionFilter,
+                                              FileChooserAction action, bool allowMultiple=true)
                {
                        FileChooserDialog fChooser;
                        FileFilter filter;
-                       string button, path;
+                       string button;
+                       List<string> path;
                        
                        if (action == FileChooserAction.Save)
                                button = "gtk-save";
@@ -339,7 +358,8 @@ namespace LongoMatch.Gui
                        
                        fChooser = new FileChooserDialog(title, mainWindow as Gtk.Window, action,
                                "gtk-cancel",ResponseType.Cancel, button, ResponseType.Accept);
-                       
+                               
+                       fChooser.SelectMultiple = allowMultiple;
                        if (defaultFolder != null)
                                fChooser.SetCurrentFolder(defaultFolder);
                        if (defaultName != null)
@@ -352,9 +372,9 @@ namespace LongoMatch.Gui
                        }
                        
                        if (fChooser.Run() != (int)ResponseType.Accept) 
-                               path = null;
+                               path = new List<string>();
                        else
-                               path = fChooser.Filename;
+                               path =  new List<string>(fChooser.Filenames);
                        
                        fChooser.Destroy();
                        return path;


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