[longomatch] Propose better filenames in the media file chooser



commit f5f03d26d78e25ad6860e197ed34221e7bbb859c
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Feb 4 10:47:38 2015 +0100

    Propose better filenames in the media file chooser

 LongoMatch.GUI/Gui/Component/MediaFileChooser.cs   |   36 +++++++++++++++----
 LongoMatch.GUI/Gui/Dialog/VideoConversionTool.cs   |    2 +
 .../Gui/Dialog/VideoEditionProperties.cs           |   11 ++++++
 LongoMatch.GUI/Gui/GUIToolkit.cs                   |    1 +
 LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs        |    3 +-
 LongoMatch.GUI/gtk-gui/objects.xml                 |    2 +
 6 files changed, 46 insertions(+), 9 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/MediaFileChooser.cs 
b/LongoMatch.GUI/Gui/Component/MediaFileChooser.cs
index 38a28d1..14bf728 100644
--- a/LongoMatch.GUI/Gui/Component/MediaFileChooser.cs
+++ b/LongoMatch.GUI/Gui/Component/MediaFileChooser.cs
@@ -30,6 +30,8 @@ namespace LongoMatch.Gui.Component
 
                MediaFile mediaFile;
                string path;
+               string proposedFileName;
+               string proposedDirectoryName;
 
                public MediaFileChooser ()
                {
@@ -41,6 +43,8 @@ namespace LongoMatch.Gui.Component
                        FileChooserMode = FileChooserMode.MediaFile;
                        UpdateFile ();
                        addbutton.Clicked += HandleClicked;
+                       ProposedFileName = String.Format ("LongoMatch-{0}.mp4", 
DateTime.Now.ToShortDateString ());
+                       ProposedDirectoryName = String.Format ("LongoMatch-{0}", 
DateTime.Now.ToShortDateString ()); 
                }
 
                public FileChooserMode FileChooserMode {
@@ -48,6 +52,24 @@ namespace LongoMatch.Gui.Component
                        set;
                }
 
+               public string ProposedFileName {
+                       get {
+                               return proposedFileName;
+                       }
+                       set {
+                               proposedFileName = Utils.SanitizePath (value);
+                       }
+               }
+
+               public string ProposedDirectoryName {
+                       get {
+                               return proposedDirectoryName;
+                       }
+                       set {
+                               proposedDirectoryName = Utils.SanitizePath (value);
+                       }
+               }
+
                public string CurrentPath {
                        set {
                                path = value;
@@ -109,18 +131,16 @@ namespace LongoMatch.Gui.Component
                                }
                                MediaFile = file;
                        } else if (FileChooserMode == FileChooserMode.File) {
-                               string filename = String.Format ("LongoMatch-{0}.mp4",
-                                                                DateTime.Now.ToShortDateString ().Replace 
('/', '-'));
-                               CurrentPath = FileChooserHelper.SaveFile (this, Catalog.GetString ("Output 
file"), filename,
-                                                                         Config.LastRenderDir, FilterName, 
FilterExtensions);
+                               CurrentPath = FileChooserHelper.SaveFile (this, Catalog.GetString ("Output 
file"),
+                                                                         ProposedFileName, 
Config.LastRenderDir,
+                                                                         FilterName, FilterExtensions);
                                if (CurrentPath != null) {
                                        Config.LastRenderDir = System.IO.Path.GetDirectoryName (CurrentPath);
                                }
                        } else if (FileChooserMode == FileChooserMode.Directory) {
-                               string filename = String.Format ("LongoMatch-{0}",
-                                                                DateTime.Now.ToShortDateString ().Replace 
('/', '-'));
-                               CurrentPath = FileChooserHelper.SelectFolder (this, Catalog.GetString 
("Output folder"), filename,
-                                                                             Config.LastRenderDir, null, 
null);
+                               CurrentPath = FileChooserHelper.SelectFolder (this, Catalog.GetString 
("Output folder"),
+                                                                             ProposedDirectoryName, 
Config.LastRenderDir,
+                                                                             null, null);
                        }
                        if (ChangedEvent != null) {
                                ChangedEvent (this, null);
diff --git a/LongoMatch.GUI/Gui/Dialog/VideoConversionTool.cs 
b/LongoMatch.GUI/Gui/Dialog/VideoConversionTool.cs
index 0a82ae7..cc12950 100644
--- a/LongoMatch.GUI/Gui/Dialog/VideoConversionTool.cs
+++ b/LongoMatch.GUI/Gui/Dialog/VideoConversionTool.cs
@@ -47,6 +47,8 @@ namespace LongoMatch.Gui.Dialog
                        maxHeight = supportedVideoStandards [0].Height;
                        mediafilechooser1.FileChooserMode = FileChooserMode.File;
                        mediafilechooser1.ChangedEvent += HandleFileChanges;
+                       mediafilechooser1.ProposedFileName = String.Format ("LongoMatch-Video-{0}.mp4",
+                                                                           DateTime.Now.ToShortDateString 
().Replace ('/', '-')); 
                        FillStandards ();
                        FillBitrates ();
                        addbutton1.Clicked += OnAddbuttonClicked;
diff --git a/LongoMatch.GUI/Gui/Dialog/VideoEditionProperties.cs 
b/LongoMatch.GUI/Gui/Dialog/VideoEditionProperties.cs
index 5ab7471..c29c9aa 100644
--- a/LongoMatch.GUI/Gui/Dialog/VideoEditionProperties.cs
+++ b/LongoMatch.GUI/Gui/Dialog/VideoEditionProperties.cs
@@ -24,6 +24,7 @@ using Mono.Unix;
 using LongoMatch.Core.Common;
 using LongoMatch.Gui.Helpers;
 using Misc = LongoMatch.Gui.Helpers.Misc;
+using LongoMatch.Core.Store.Playlists;
 
 namespace LongoMatch.Gui.Dialog
 {
@@ -69,6 +70,16 @@ namespace LongoMatch.Gui.Dialog
                        get;
                        set;
                }
+
+               public Playlist Playlist {
+                       set {
+                               if (value.Name != null) {
+                                       mediafilechooser1.ProposedFileName = value.Name + ".mp4";
+                                       mediafilechooser1.ProposedDirectoryName = value.Name;
+                               }
+                       }
+               }
+               
                #endregion Properties
                #region Private Methods
                string GetExtension ()
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index 10ca6db..81d7b80 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -172,6 +172,7 @@ namespace LongoMatch.Gui
 
                        vep = new VideoEditionProperties ();
                        vep.TransientFor = mainWindow as Gtk.Window;
+                       vep.Playlist = playlist;
                        response = vep.Run ();
                        while (response == (int)ResponseType.Ok) {
                                if (!vep.SplitFiles && vep.EncodingSettings.OutputFile == "") {
diff --git a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
index 060ebfb..962168f 100644
--- a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
@@ -64,10 +64,11 @@ namespace LongoMatch.Gui.Panel
                        this.mtoolkit = Config.MultimediaToolkit;
                        this.gtoolkit = Config.GUIToolkit;
                        capturemediafilechooser.FileChooserMode = FileChooserMode.File;
+                       capturemediafilechooser.ProposedFileName = String.Format ("Live-LongoMatch-{0}.mp4",
+                                                                                 
DateTime.Now.ToShortDateString ());
                        notebook1.ShowTabs = false;
                        notebook1.ShowBorder = false;
                        
-                       
                        LoadIcons ();
                        ConnectSignals ();
                        FillCategories ();
diff --git a/LongoMatch.GUI/gtk-gui/objects.xml b/LongoMatch.GUI/gtk-gui/objects.xml
index 2bfd338..062a632 100644
--- a/LongoMatch.GUI/gtk-gui/objects.xml
+++ b/LongoMatch.GUI/gtk-gui/objects.xml
@@ -226,6 +226,8 @@
       <itemgroup label="MediaFileChooser Properties">
         <property name="CurrentPath" />
         <property name="FilterName" />
+        <property name="ProposedFileName" />
+        <property name="ProposedDirectoryName" />
       </itemgroup>
     </itemgroups>
     <signals>


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