[longomatch] Fix new project panel for projects imports



commit c97788b50a385c728f4e22cf1d8a85fb73e5c532
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Jul 7 12:44:53 2014 +0200

    Fix new project panel for projects imports

 LongoMatch.Core/Common/EventsBroker.cs          |    4 +-
 LongoMatch.Core/Handlers/Handlers.cs            |    2 +-
 LongoMatch.GUI/Gui/MainWindow.cs                |    2 +-
 LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs     |   77 ++++++++++++++---------
 LongoMatch.Services/Services/PlaylistManager.cs |   10 +--
 LongoMatch.Services/Services/ProjectsManager.cs |    4 +-
 6 files changed, 57 insertions(+), 42 deletions(-)
---
diff --git a/LongoMatch.Core/Common/EventsBroker.cs b/LongoMatch.Core/Common/EventsBroker.cs
index 6ee7bbb..ed48c8f 100644
--- a/LongoMatch.Core/Common/EventsBroker.cs
+++ b/LongoMatch.Core/Common/EventsBroker.cs
@@ -221,9 +221,9 @@ namespace LongoMatch.Common
                                SaveProjectEvent (project, projectType);
                }
                
-               public void EmitNewProject () {
+               public void EmitNewProject (Project project) {
                        if (NewProjectEvent != null)
-                               NewProjectEvent();
+                               NewProjectEvent(project);
                }
                
                public void EmitOpenProject () {
diff --git a/LongoMatch.Core/Handlers/Handlers.cs b/LongoMatch.Core/Handlers/Handlers.cs
index 282f929..0c1432f 100644
--- a/LongoMatch.Core/Handlers/Handlers.cs
+++ b/LongoMatch.Core/Handlers/Handlers.cs
@@ -63,7 +63,7 @@ namespace LongoMatch.Handlers
        public delegate void OpenProjectIDHandler(Guid project_id);
        public delegate void OpenProjectHandler();
        public delegate void CloseOpenendProjectHandler();
-       public delegate void NewProjectHandler();
+       public delegate void NewProjectHandler(Project project);
        public delegate void OpenNewProjectHandler(Project project, ProjectType projectType, CaptureSettings 
captureSettings);
        public delegate void ImportProjectHandler ();
        public delegate void ExportProjectHandler (Project project);
diff --git a/LongoMatch.GUI/Gui/MainWindow.cs b/LongoMatch.GUI/Gui/MainWindow.cs
index 253e908..b8bdd29 100644
--- a/LongoMatch.GUI/Gui/MainWindow.cs
+++ b/LongoMatch.GUI/Gui/MainWindow.cs
@@ -183,7 +183,7 @@ namespace LongoMatch.Gui
                                Config.EventsBroker.EmitSaveProject (openedProject, projectType);
                                Config.EventsBroker.EmitOpenProject ();};
                        NewPojectAction.Activated += (sender, e) => {
-                               Config.EventsBroker.EmitNewProject ();
+                               Config.EventsBroker.EmitNewProject (null);
                        };
                        TagSubcategoriesAction.Activated += (sender, e) => {
                                Config.EventsBroker.EmitTagSubcategories (TagSubcategoriesAction.Active);
diff --git a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
index ac05d4e..77a7c80 100644
--- a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
@@ -76,20 +76,20 @@ namespace LongoMatch.Gui.Panel
                        backgroundwidget.WidthRequest = 200;
                        nextbutton.Clicked += HandleNextClicked;
                        backbutton.Clicked += HandleBackClicked;
+                       ConnectSignals ();
+                       FillCategories ();
+                       FillFormats ();
+                       FillDevices (mtoolkit.VideoDevices);
+                       LoadTeams ();
                        if (project == null) {
                                notebook1.Page = 0;
                                datelabel.Text = DateTime.Now.ToShortDateString();
                        } else {
                                notebook1.Page = 1;
                                this.project = project;
+                               projectType = ProjectType.EditProject;
                                FillProjectDetails ();
                        }
-                       
-                       ConnectSignals ();
-                       FillCategories ();
-                       FillFormats ();
-                       FillDevices (mtoolkit.VideoDevices);
-                       LoadTeams ();
                        Color.Parse ("red", ref red);
                        outputfilelabel.ModifyFg (StateType.Normal, red);
                        Color.Parse ("red", ref red);
@@ -137,6 +137,14 @@ namespace LongoMatch.Gui.Panel
                        datelabel.Text = project.Description.MatchDate.ToShortDateString();
                        localSpinButton.Value = project.Description.LocalGoals;
                        visitorSpinButton.Value = project.Description.VisitorGoals;
+                       hometeamscombobox.Sensitive = false;
+                       awayteamscombobox.Sensitive = false;
+                       tagscombobox.Visible = false;
+                       label9.Visible = false;
+                       filetable.Visible = true;
+                       analysisTemplate = project.Categories;
+                       LoadTemplate (project.LocalTeamTemplate, Team.LOCAL);
+                       LoadTemplate (project.VisitorTeamTemplate, Team.VISITOR);
                }
                
                void FillCategories() {
@@ -207,45 +215,52 @@ namespace LongoMatch.Gui.Panel
                }
                
                
-               public void LoadTemplate (string name, Team team) {
+               void LoadTemplate (string name, Team team) {
                        TeamTemplate template;
                        if (name != null) {
                                template = Config.TeamTemplatesProvider.Load (name);
-                               if (team == Team.LOCAL) {
-                                       if (template.Shield != null) {
-                                               homeshieldimage.Pixbuf = template.Shield.Value;
-                                       } else {
-                                               homeshieldimage.Pixbuf = Gdk.Pixbuf.LoadFromResource 
("logo.svg");                                              
-                                       }
-                                       homelabel.Text = template.TeamName;
-                                       hometemplate = template;
+                               LoadTemplate (template, team);
+                       }
+               }
+               
+               void LoadTemplate (TeamTemplate template, Team team) {
+                       if (team == Team.LOCAL) {
+                               if (template.Shield != null) {
+                                       homeshieldimage.Pixbuf = template.Shield.Value;
                                } else {
-                                       if (template.Shield != null) {
-                                               awayshieldimage.Pixbuf = template.Shield.Value;
-                                       } else {
-                                               awayshieldimage.Pixbuf = Gdk.Pixbuf.LoadFromResource 
("logo.svg");                                              
-                                       }
-                                       awaylabel.Text = template.TeamName;
-                                       awaytemplate = template;
+                                       homeshieldimage.Pixbuf = Gdk.Pixbuf.LoadFromResource ("logo.svg");    
                                          
+                               }
+                               homelabel.Text = template.TeamName;
+                               hometemplate = template;
+                       } else {
+                               if (template.Shield != null) {
+                                       awayshieldimage.Pixbuf = template.Shield.Value;
+                               } else {
+                                       awayshieldimage.Pixbuf = Gdk.Pixbuf.LoadFromResource ("logo.svg");    
                                          
                                }
-                               teamtagger.LoadTeams (hometemplate, awaytemplate,
-                                                     analysisTemplate.FieldBackground);
+                               awaylabel.Text = template.TeamName;
+                               awaytemplate = template;
                        }
+                       teamtagger.LoadTeams (hometemplate, awaytemplate,
+                                             analysisTemplate.FieldBackground);
                }
                
                bool CreateProject () {
                        TreeIter iter;
                        
-                       if (project != null) {
-                               return true;
-                       }
-                       
-                       if (projectType == ProjectType.FileProject) {
+                       if (projectType == ProjectType.FileProject ||
+                           projectType == ProjectType.EditProject) {
                                if (fileEntry.Text == "") {
                                        gtoolkit.WarningMessage (Catalog.GetString ("No input video file"));
                                        return false;
                                }
                        }
+
+                       if (project != null) {
+                               project.Description.File = mediaFile;
+                               return true;
+                       }
+                       
                        if (projectType == ProjectType.CaptureProject ||
                            projectType == ProjectType.URICaptureProject) {
                                if (outfileEntry.Text == "") {
@@ -371,6 +386,10 @@ namespace LongoMatch.Gui.Panel
                void HandleCreateProject (object sender, EventArgs e)
                {
                        if (CreateProject ()) {
+                               if (projectType == ProjectType.EditProject) {
+                                       projectType = ProjectType.FileProject;
+                                       Config.EventsBroker.EmitCreateThumbnails (project);
+                               }
                                Config.EventsBroker.EmitOpenNewProject (project, projectType, 
captureSettings);
                        }
                }
diff --git a/LongoMatch.Services/Services/PlaylistManager.cs b/LongoMatch.Services/Services/PlaylistManager.cs
index 8638205..6f65d1b 100644
--- a/LongoMatch.Services/Services/PlaylistManager.cs
+++ b/LongoMatch.Services/Services/PlaylistManager.cs
@@ -37,7 +37,6 @@ namespace LongoMatch.Services
                IPlayList playlist;
                IPlayerBin player;
                IRenderingJobsManager videoRenderer;
-               IAnalysisWindow analysisWindow;
                /* FIXME */
                TimeNode selectedTimeNode;
                
@@ -49,7 +48,7 @@ namespace LongoMatch.Services
                {
                        this.videoRenderer = videoRenderer;
                        this.guiToolkit = guiToolkit;
-                       Config.EventsBroker.OpenedProjectChanged += HandleOpenedProjectChanged;
+                       BindEvents();
                }
 
                void HandleOpenedProjectChanged (Project project, ProjectType projectType,
@@ -58,10 +57,6 @@ namespace LongoMatch.Services
                        openedProject = project;
                        if (project != null) {
                                player = analysisWindow.Player;
-                               if (this.analysisWindow != analysisWindow) {
-                                       BindEvents(analysisWindow);
-                                       this.analysisWindow = analysisWindow;
-                               }
                        }
                }
                
@@ -80,7 +75,8 @@ namespace LongoMatch.Services
                        }
                }
                
-               private void BindEvents(IAnalysisWindow analysisWindow) {
+               private void BindEvents() {
+                       Config.EventsBroker.OpenedProjectChanged += HandleOpenedProjectChanged;
                        Config.EventsBroker.PlaySelected += (p) => {selectedTimeNode = p;};
                        Config.EventsBroker.OpenPlaylistEvent += OnOpenPlaylist;
                        Config.EventsBroker.NewPlaylistEvent += OnNewPlaylist;
diff --git a/LongoMatch.Services/Services/ProjectsManager.cs b/LongoMatch.Services/Services/ProjectsManager.cs
index d19721d..1fb65f7 100644
--- a/LongoMatch.Services/Services/ProjectsManager.cs
+++ b/LongoMatch.Services/Services/ProjectsManager.cs
@@ -326,14 +326,14 @@ namespace LongoMatch.Services
                        }
                }
                
-               protected virtual void NewProject() {
+               protected virtual void NewProject(Project project) {
                        Log.Debug("Creating new project");
                        
                        if (!PromptCloseProject ()) {
                                return;
                        }
                        
-                       guiToolkit.CreateNewProject ();
+                       guiToolkit.CreateNewProject (project);
                }
                
                void OpenNewProject (Project project, ProjectType projectType,


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