[longomatch/livecapturemerged: 73/84] Save project capture after closing an load the newly created project
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/livecapturemerged: 73/84] Save project capture after closing an load the newly created project
- Date: Tue, 11 May 2010 00:54:07 +0000 (UTC)
commit c16d2fa076402345d372040b4c53f94a380bf0d0
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sat May 8 11:49:42 2010 +0200
Save project capture after closing an load the newly created project
CesarPlayer/Gui/CapturerBin.cs | 11 +++++++-
LongoMatch/Gui/MainWindow.cs | 47 ++++++++++++++++++++++++++++++++++-----
2 files changed, 50 insertions(+), 8 deletions(-)
---
diff --git a/CesarPlayer/Gui/CapturerBin.cs b/CesarPlayer/Gui/CapturerBin.cs
index 45fc96f..23e757c 100644
--- a/CesarPlayer/Gui/CapturerBin.cs
+++ b/CesarPlayer/Gui/CapturerBin.cs
@@ -256,18 +256,25 @@ namespace LongoMatch.Gui
protected virtual void OnStopbuttonClicked (object sender, System.EventArgs e)
{
+ int res;
+
MessageDialog md = new MessageDialog((Gtk.Window)this.Toplevel, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo,
Catalog.GetString("You are going to stop and finish the current capture."+"\n"+
"Do you want to proceed?"));
- if (md.Run() == (int)ResponseType.Yes){
+ res = md.Run();
+ md.Destroy();
+ if (res == (int)ResponseType.Yes){
+ md = new MessageDialog((Gtk.Window)this.Toplevel, DialogFlags.Modal, MessageType.Info, ButtonsType.None,
+ Catalog.GetString("Finalizing file. This can take a while"));
+ md.Show();
Stop();
+ md.Destroy();
recbutton.Visible = true;
pausebutton.Visible = false;
stopbutton.Visible = false;
if (CaptureFinished != null)
CaptureFinished(this, new EventArgs());
}
- md.Destroy();
}
protected virtual void OnTick (int ellapsedTime){
diff --git a/LongoMatch/Gui/MainWindow.cs b/LongoMatch/Gui/MainWindow.cs
index 92538dc..e2b0b72 100644
--- a/LongoMatch/Gui/MainWindow.cs
+++ b/LongoMatch/Gui/MainWindow.cs
@@ -28,6 +28,7 @@ using LongoMatch.Handlers;
using LongoMatch.TimeNodes;
using LongoMatch.Utils;
using LongoMatch.Video.Capturer;
+using LongoMatch.Video.Utils;
using Mono.Unix;
using System;
using System.IO;
@@ -93,6 +94,8 @@ namespace LongoMatch.Gui
playerbin1.LogoMode = true;
capturerBin.Visible = false;
+ capturerBin.CaptureFinished += delegate {
+ CloseOpenedProject (true);};
buttonswidget1.Mode = TagMode.Predifined;
@@ -107,7 +110,9 @@ namespace LongoMatch.Gui
#region Private Methods
private void SetProject (Project project, ProjectType projectType, CapturePropertiesStruct props)
{
- CloseOpenedProject (true);
+ if (openedProject != null)
+ CloseOpenedProject (true);
+
openedProject = project;
this.projectType = projectType;
eManager.OpenedProject = project;
@@ -145,9 +150,6 @@ namespace LongoMatch.Gui
}
} else {
Title = "LongoMatch";
- capturerBin.CaptureFinished += delegate {
- CloseOpenedProject (true);
- };
if (projectType == ProjectType.CaptureProject) {
capturerBin.OutputFile = project.File.FilePath;
capturerBin.CaptureProperties = props;
@@ -182,17 +184,50 @@ namespace LongoMatch.Gui
KeyPressEvent += hotkeysListener;
}
}
+
+ private void SaveCaptureProject(){
+ PreviewMediaFile file;
+ Project newProject = openedProject;
+ string filePath = openedProject.File.FilePath;
+
+ MessageDialog md = new MessageDialog((Gtk.Window)this.Toplevel, DialogFlags.Modal, MessageType.Info, ButtonsType.None,
+ Catalog.GetString("Loading newly created project..."));
+ md.Show();
+
+ /* scan the new file to build a new PreviewMediaFile with all the metadata */
+ try{
+ file = PreviewMediaFile.GetMediaFile(filePath);
+ openedProject.File = file;
+ MainClass.DB.AddProject(openedProject);
+ } catch (Exception ex){
+ string projectFile = filePath + "-" + DateTime.Now;
+ Project.Export(openedProject, projectFile);
+ MessagePopup.PopupMessage(this, MessageType.Error,
+ Catalog.GetString("An error occured saving the project:\n")+ex.Message+ "\n\n"+
+ Catalog.GetString("The video file and a backup of the project has been "+
+ "saved. Try to import it later:\n")+
+ filePath+"\n"+projectFile);
+ }
+ /* we need to set the opened project to null to avoid calling again CloseOpendProject() */
+ openedProject = null;
+ SetProject(newProject, ProjectType.FileProject, new CapturePropertiesStruct());
+ md.Destroy();
+ }
private void CloseOpenedProject(bool save) {
- bool playlistVisible = playlistwidget2.Visible;
+ bool playlistVisible = playlistwidget2.Visible;
if (save)
SaveProject();
if (projectType != ProjectType.FileProject){
- playerbin1.Visible = true;
capturerBin.Close();
+ playerbin1.Visible = true;
capturerBin.Visible = false;
+ if (projectType != ProjectType.FileProject && openedProject != null){
+ SaveCaptureProject();
+ return;
+ }
} else {
playerbin1.Close();
playerbin1.LogoMode = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]