private void AddNewPlay(Time start, Time stop, Category category)
        {
            Pixbuf miniature;

            Log.Debug(String.Format("New play created start:{0} stop:{1} category:{2}",
                                    start, stop, category));
            /* Get the current frame and get a thumbnail from it */
            if (projectType == ProjectType.CaptureProject)
            {
                if (!capturer.Capturing)
                {
                    MessagePopup.PopupMessage(capturer, MessageType.Info,
                                              Catalog.GetString("You can't create a new play if the capturer " +
                                                                "is not recording."));
                    return;
                }
                miniature = capturer.CurrentMiniatureFrame;
            }
            else if (projectType == ProjectType.FileProject)
            {
                miniature = player.CurrentMiniatureFrame;
            }
            else
            {
                miniature = null;
            }

            /* Add the new created play to the project and update the GUI*/
            var play = openedProject.AddPlay(category, start, stop, miniature);

            mainWindow.AddPlay(play);
            /* Tag subcategories of the new play */
            LaunchPlayTagger(play);
        }
        protected virtual void OnDeleteButtonPressed(object sender, System.EventArgs e)
        {
            List <ProjectDescription> deletedProjects = new List <ProjectDescription>();

            if (selectedProjects == null)
            {
                return;
            }

            foreach (ProjectDescription selectedProject in selectedProjects)
            {
                if (openedProject != null &&
                    selectedProject.File.FilePath == openedProject.Description.File.FilePath)
                {
                    MessagePopup.PopupMessage(this, MessageType.Warning,
                                              Catalog.GetString("This Project is actually in use.") + "\n" +
                                              Catalog.GetString("Close it first to allow its removal from the database"));
                    continue;
                }
                MessageDialog md = new MessageDialog(this, DialogFlags.Modal,
                                                     MessageType.Question,
                                                     ButtonsType.YesNo,
                                                     Catalog.GetString("Do you really want to delete:") +
                                                     "\n" + selectedProject.Title);
                if (md.Run() == (int)ResponseType.Yes)
                {
                    DB.RemoveProject(selectedProject.UUID);
                    deletedProjects.Add(selectedProject);
                }
                md.Destroy();
            }
            projectlistwidget1.RemoveProjects(deletedProjects);
            Clear();
        }
        public virtual void OnNewPlayStop(Category category)
        {
            int  diff;
            Time stopTime = new Time {
                MSeconds = (int)player.CurrentTime
            };

            Log.Debug("New play stop time: " + stopTime);
            diff = stopTime.MSeconds - startTime.MSeconds;

            if (diff < 0)
            {
                MessagePopup.PopupMessage(mainWindow, MessageType.Warning,
                                          Catalog.GetString("The stop time is smaller than the start time. " +
                                                            "The play will not be added."));
                return;
            }
            if (diff < 500)
            {
                int correction = 500 - diff;
                if (startTime.MSeconds - correction > 0)
                {
                    startTime = startTime - correction;
                }
                else
                {
                    stopTime = stopTime + correction;
                }
            }
            AddNewPlay(startTime, stopTime, category);
        }
Exemple #4
0
        private static void ProcessExecutionError(Exception ex)
        {
            string logFile = Constants.SOFTWARE_NAME + "-" + DateTime.Now + ".log";
            string message;

            logFile = logFile.Replace("/", "-");
            logFile = logFile.Replace(" ", "-");
            logFile = logFile.Replace(":", "-");
            logFile = System.IO.Path.Combine(Config.HomeDir(), logFile);

            if (ex.InnerException != null)
            {
                message = String.Format("{0}\n{1}\n{2}\n{3}\n{4}", ex.Message, ex.InnerException.Message, ex.Source, ex.StackTrace, ex.InnerException.StackTrace);
            }
            else
            {
                message = String.Format("{0}\n{1}\n{2}", ex.Message, ex.Source, ex.StackTrace);
            }

            using (StreamWriter s = new StreamWriter(logFile)) {
                s.WriteLine(message);
                s.WriteLine("\n\n\nStackTrace:");
                s.WriteLine(System.Environment.StackTrace);
            }
            Log.Exception(ex);
            //TODO Add bug reports link
            MessagePopup.PopupMessage(null, MessageType.Error,
                                      Catalog.GetString("The application has finished with an unexpected error.") + "\n" +
                                      Catalog.GetString("A log has been saved at: ") + logFile + "\n" +
                                      Catalog.GetString("Please, fill a bug report "));

            Application.Quit();
        }
        private bool Next()
        {
            if (openedProject != null)
            {
                MessagePopup.PopupMessage(playlistWidget as Gtk.Widget, MessageType.Error,
                                          Catalog.GetString("Please, close the opened project to play the playlist."));
                Stop();
                return(false);
            }

            if (!playlist.HasNext())
            {
                Stop();
                return(false);
            }

            var plNode = playlist.Next();

            playlistWidget.SetActivePlay(plNode, playlist.GetCurrentIndex());

            if (!plNode.Valid)
            {
                return(Next());
            }

            LoadPlaylistPlay(plNode);
            return(true);
        }
Exemple #6
0
        private void SaveCaptureProject(Project project)
        {
            MessageDialog md;
            string        filePath = project.Description.File.FilePath;

            Log.Debug("Saving capture project: " + project);
            md = new MessageDialog(mainWindow as Gtk.Window, 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 {
                Log.Debug("Reloading saved file: " + filePath);
                project.Description.File = PreviewMediaFile.DiscoverFile(filePath);
                Core.DB.AddProject(project);
            } catch (Exception ex) {
                Log.Exception(ex);
                Log.Debug("Backing up project to file");
                string projectFile = filePath + "-" + DateTime.Now;
                projectFile = projectFile.Replace("-", "_").Replace(" ", "_").Replace(":", "_");
                Project.Export(OpenedProject, projectFile);
                MessagePopup.PopupMessage(mainWindow, 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() */
            /* FIXME: */
            //project = null;
            SetProject(project, ProjectType.FileProject, new CaptureSettings());
            md.Destroy();
        }
Exemple #7
0
        private bool SetProject(Project project, ProjectType projectType, CaptureSettings props)
        {
            if (OpenedProject != null)
            {
                CloseOpenedProject(true);
            }

            if (projectType == ProjectType.FileProject)
            {
                // Check if the file associated to the project exists
                if (!File.Exists(project.Description.File.FilePath))
                {
                    MessagePopup.PopupMessage(mainWindow, MessageType.Warning,
                                              Catalog.GetString("The file associated to this project doesn't exist.") + "\n"
                                              + Catalog.GetString("If the location of the file has changed try to edit it with the database manager."));
                    CloseOpenedProject(true);
                    return(false);
                }
                try {
                    Player.Open(project.Description.File.FilePath);
                }
                catch (GLib.GException ex) {
                    MessagePopup.PopupMessage(mainWindow, MessageType.Error,
                                              Catalog.GetString("An error occurred opening this project:") + "\n" + ex.Message);
                    CloseOpenedProject(true);
                    return(false);
                }
            }
            else
            {
                if (projectType == ProjectType.CaptureProject)
                {
                    Capturer.CaptureProperties = props;
                    try {
                        Capturer.Type = CapturerType.Live;
                    } catch (Exception ex) {
                        MessagePopup.PopupMessage(mainWindow, MessageType.Error, ex.Message);
                        CloseOpenedProject(false);
                        return(false);
                    }
                }
                else
                {
                    Capturer.Type = CapturerType.Fake;
                }
                Capturer.Run();
            }

            OpenedProject     = project;
            OpenedProjectType = projectType;
            mainWindow.SetProject(project, projectType, props);
            EmitProjectChanged();
            return(true);
        }
 public void Load(string filePath)
 {
     try {
         playlist = PlayList.Load(filePath);
         playlistWidget.Load(playlist);
     } catch (Exception e) {
         Log.Exception(e);
         MessagePopup.PopupMessage(playlistWidget as Gtk.Widget, MessageType.Error,
                                   Catalog.GetString("The file you are trying to load is not a playlist or it's not compatible with the current version"));
     }
 }
 protected virtual void OnHotKeyChanged(HotKey prevHotKey, Category category)
 {
     if (hkList.Contains(category.HotKey))
     {
         MessagePopup.PopupMessage(this, MessageType.Warning,
                                   Catalog.GetString("This hotkey is already in use."));
         category.HotKey = prevHotKey;
         timenodeproperties2.Category = category;                 //Update Gui
     }
     else if (category.HotKey.Defined)
     {
         hkList.Remove(prevHotKey);
         hkList.Add(category.HotKey);
     }
 }
 protected virtual void OnSubcategoriesDeleted(List <ISubCategory> subcats)
 {
     if (Project != null)
     {
         int ret = MessagePopup.PopupMessage(this, MessageType.Question,
                                             Catalog.GetString("If you delete this subcategory you will loose" +
                                                               "all the tags associated with it. Do you want to proceed?"));
         if (ret == (int)ResponseType.No)
         {
             return;
         }
         Project.DeleteSubcategoryTags(Category, subcats);
     }
     Category.SubCategories.RemoveAll(s => subcats.Contains(s));
 }
        protected virtual void OnProjectlistwidget1ProjectsSelected(List <ProjectDescription> projects)
        {
            ProjectDescription project;

            /* prompt tp save the opened project if has changes */
            if (projectdetails.Edited)
            {
                PromptToSaveEditedProject();
            }

            selectedProjects = projects;

            /* if no projects are selected clear everything */
            if (projects.Count == 0)
            {
                Clear();
                return;

                /* if more than one project is selected clear everything but keep
                 * the delete button and the export button sensitives */
            }
            else if (projects.Count > 1)
            {
                Clear();
                deleteButton.Sensitive = true;
                exportbutton.Sensitive = true;
                return;
            }

            /* if only one project is selected try to load it in the editor */
            project = projects[0];

            if (openedProject != null &&
                project.File.FilePath == openedProject.Description.File.FilePath)
            {
                MessagePopup.PopupMessage(this, MessageType.Warning,
                                          Catalog.GetString("The Project you are trying to load is actually in use.") + "\n" + Catalog.GetString("Close it first to edit it"));
                Clear();
            }
            else
            {
                projectdetails.Sensitive = true;
                projectdetails.SetProject(DB.GetProject(project.UUID));
                saveButton.Sensitive   = false;
                deleteButton.Sensitive = true;
                exportbutton.Sensitive = true;
            }
        }
        private void MainLoopOnProgress(float progress)
        {
            if (progress > (float)EditorState.START && progress <= (float)EditorState.FINISHED &&
                progress > stateBar.Fraction)
            {
                UpdateProgress(progress);
            }

            if (progress == (float)EditorState.CANCELED)
            {
                Log.Debug("Job was cancelled");
                currentJob.State = JobState.Cancelled;
                CloseAndNext();
            }

            else if (progress == (float)EditorState.START)
            {
                Log.Debug("Job started");
                currentJob.State    = JobState.Running;
                stateBar.JobRunning = true;
                UpdateProgress(progress);
            }

            else if (progress == (float)EditorState.FINISHED)
            {
                Log.Debug("Job finished successfully");
                videoEditor.Progress -= OnProgress;
                UpdateProgress(progress);
                currentJob.State = JobState.Finished;
                CloseAndNext();
            }

            else if (progress == (float)EditorState.ERROR)
            {
                Log.Debug("Job finished with errors");
                MessagePopup.PopupMessage(stateBar, MessageType.Error,
                                          Catalog.GetString("An error has occurred in the video editor.")
                                          + Catalog.GetString("Please, try again."));
                currentJob.State = JobState.Error;
                CloseAndNext();
            }
        }
        public static Job ConfigureRenderingJob(IPlayList playlist, Gtk.Widget parent)
        {
            VideoEditionProperties vep;
            Job job = null;
            int response;

            vep = new VideoEditionProperties();
            vep.TransientFor = (Gtk.Window)parent.Toplevel;
            response         = vep.Run();
            while (response == (int)ResponseType.Ok && vep.EncodingSettings.OutputFile == "")
            {
                MessagePopup.PopupMessage(parent, MessageType.Warning,
                                          Catalog.GetString("Please, select a video file."));
                response = vep.Run();
            }
            if (response == (int)ResponseType.Ok)
            {
                job = new Job(playlist, vep.EncodingSettings, vep.EnableAudio, vep.TitleOverlay);
            }
            vep.Destroy();
            return(job);
        }
        protected override void OnExportbuttonClicked(object sender, System.EventArgs e)
        {
            EntryDialog dialog = new EntryDialog();

            dialog.TransientFor = (Gtk.Window) this.Toplevel;
            dialog.ShowCount    = false;
            dialog.Text         = Catalog.GetString("New template");
            if (dialog.Run() == (int)ResponseType.Ok)
            {
                if (dialog.Text == "")
                {
                    MessagePopup.PopupMessage(dialog, MessageType.Error,
                                              Catalog.GetString("The template name is void."));
                }
                else if (provider.Exists(dialog.Text))
                {
                    MessageDialog md = new MessageDialog(null,
                                                         DialogFlags.Modal,
                                                         MessageType.Question,
                                                         Gtk.ButtonsType.YesNo,
                                                         Catalog.GetString("The template already exists. " +
                                                                           "Do you want to overwrite it ?")
                                                         );
                    if (md.Run() == (int)ResponseType.Yes)
                    {
                        Template.Name = dialog.Text;
                        provider.Update(Template);
                    }
                    md.Destroy();
                }
                else
                {
                    Template.Name = dialog.Text;
                    provider.Save(Template);
                }
            }
            dialog.Destroy();
        }
Exemple #15
0
 protected override void RemoveSelected()
 {
     if (Project != null)
     {
         MessageDialog dialog = new MessageDialog((Gtk.Window) this.Toplevel, DialogFlags.Modal, MessageType.Question,
                                                  ButtonsType.YesNo, true,
                                                  Catalog.GetString("You are about to delete a category and all the plays added to this category. Do you want to proceed?"));
         if (dialog.Run() == (int)ResponseType.Yes)
         {
             try {
                 foreach (var cat in selected)
                 {
                     Project.RemoveCategory(cat);
                 }
             } catch {
                 MessagePopup.PopupMessage(this, MessageType.Warning,
                                           Catalog.GetString("A template needs at least one category"));
             }
         }
         dialog.Destroy();
     }
     else
     {
         foreach (Category cat in selected)
         {
             if (template.Count == 1)
             {
                 MessagePopup.PopupMessage(this, MessageType.Warning,
                                           Catalog.GetString("A template needs at least one category"));
             }
             else
             {
                 template.Remove(cat);
             }
         }
     }
     base.RemoveSelected();
 }
Exemple #16
0
        private void SaveFakeLiveProject(Project project)
        {
            int               response;
            MessageDialog     md;
            FileFilter        filter;
            FileChooserDialog fChooser;

            Log.Debug("Saving fake live project " + project);
            md = new MessageDialog(mainWindow, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok,
                                   Catalog.GetString("The project will be saved to a file. " +
                                                     "You can insert it later into the database using the " +
                                                     "\"Import project\" function once you copied the video file " +
                                                     "to your computer"));
            response = md.Run();
            md.Destroy();
            if (response == (int)ResponseType.Cancel)
            {
                return;
            }

            fChooser = new FileChooserDialog(Catalog.GetString("Save Project"),
                                             mainWindow, FileChooserAction.Save,
                                             "gtk-cancel", ResponseType.Cancel,
                                             "gtk-save", ResponseType.Accept);
            fChooser.SetCurrentFolder(Config.HomeDir());
            filter      = new FileFilter();
            filter.Name = Constants.PROJECT_NAME;
            filter.AddPattern("*.lpr");
            fChooser.AddFilter(filter);
            if (fChooser.Run() == (int)ResponseType.Accept)
            {
                Project.Export(project, fChooser.Filename);
                MessagePopup.PopupMessage(mainWindow, MessageType.Info,
                                          Catalog.GetString("Project saved successfully."));
            }
            fChooser.Destroy();
        }
Exemple #17
0
 protected override void RemoveSelected()
 {
     if (Project != null)
     {
         MessageDialog dialog = new MessageDialog((Gtk.Window) this.Toplevel, DialogFlags.Modal, MessageType.Question,
                                                  ButtonsType.YesNo, true,
                                                  Catalog.GetString("You are about to delete a player and all " +
                                                                    "its tags. Do you want to proceed?"));
         if (dialog.Run() == (int)ResponseType.Yes)
         {
             try {
                 foreach (var player in selected)
                 {
                     Project.RemovePlayer(template, player);
                 }
             } catch {
                 MessagePopup.PopupMessage(this, MessageType.Warning,
                                           Catalog.GetString("A template needs at least one category"));
             }
         }
         dialog.Destroy();
     }
     else
     {
         try {
             foreach (var player in selected)
             {
                 Template.Remove(player);
             }
         } catch {
             MessagePopup.PopupMessage(this, MessageType.Warning,
                                       Catalog.GetString("A template needs at least one category"));
         }
     }
     base.RemoveSelected();
 }
        protected virtual void OnOpenbuttonClicked(object sender, System.EventArgs e)
        {
            FileChooserDialog fChooser = null;

            if (useType == ProjectType.CaptureProject)
            {
                fChooser = new FileChooserDialog(Catalog.GetString("Output file"),
                                                 (Gtk.Window) this.Toplevel,
                                                 FileChooserAction.Save,
                                                 "gtk-cancel", ResponseType.Cancel,
                                                 "gtk-save", ResponseType.Accept);
                fChooser.SetCurrentFolder(Config.VideosDir());
                fChooser.DoOverwriteConfirmation = true;
                if (fChooser.Run() == (int)ResponseType.Accept)
                {
                    fileEntry.Text = fChooser.Filename;
                }
                fChooser.Destroy();
            }
            else
            {
                fChooser = new FileChooserDialog(Catalog.GetString("Open file..."),
                                                 (Gtk.Window) this.Toplevel,
                                                 FileChooserAction.Open,
                                                 "gtk-cancel", ResponseType.Cancel,
                                                 "gtk-open", ResponseType.Accept);

                fChooser.SetCurrentFolder(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal));

                if (fChooser.Run() == (int)ResponseType.Accept)
                {
                    MessageDialog md       = null;
                    string        filename = fChooser.Filename;
                    fChooser.Destroy();

                    if (MpegRemuxer.FileIsMpeg(filename) &&
                        MpegRemuxer.AskForConversion(this.Toplevel as Gtk.Window))
                    {
                        var remux       = new MpegRemuxer(filename);
                        var newFilename = remux.Remux(this.Toplevel as Gtk.Window);
                        if (newFilename != null)
                        {
                            filename = newFilename;
                        }
                    }

                    try {
                        md = new MessageDialog((Gtk.Window) this.Toplevel,
                                               DialogFlags.Modal,
                                               MessageType.Info,
                                               Gtk.ButtonsType.None,
                                               Catalog.GetString("Analyzing video file:") + "\n" + filename);
                        md.Icon = Stetic.IconLoader.LoadIcon(this, "longomatch", Gtk.IconSize.Dialog);
                        md.Show();
                        mFile = PreviewMediaFile.DiscoverFile(filename);
                        if (!mFile.HasVideo || mFile.VideoCodec == "")
                        {
                            throw new Exception(Catalog.GetString("This file doesn't contain a video stream."));
                        }
                        if (mFile.HasVideo && mFile.Length == 0)
                        {
                            throw new Exception(Catalog.GetString("This file contains a video stream but its length is 0."));
                        }


                        fileEntry.Text = filename;
                    }
                    catch (Exception ex) {
                        MessagePopup.PopupMessage(this, MessageType.Error,
                                                  ex.Message);
                    }
                    finally {
                        md.Destroy();
                    }
                }
                fChooser.Destroy();
            }
        }
Exemple #19
0
        private void CreateNewProject(out Project project, out ProjectType projectType,
                                      out CaptureSettings captureSettings)
        {
            ProjectSelectionDialog psd;
            NewProjectDialog       npd;
            List <Device>          devices = null;
            int response;

            Log.Debug("Creating new project");
            /* The out parameters must be set before leaving the method */
            project         = null;
            projectType     = ProjectType.None;
            captureSettings = new CaptureSettings();

            /* Show the project selection dialog */
            psd = new ProjectSelectionDialog();
            psd.TransientFor = mainWindow;
            response         = psd.Run();
            psd.Destroy();
            if (response != (int)ResponseType.Ok)
            {
                return;
            }
            projectType = psd.ProjectType;

            if (projectType == ProjectType.CaptureProject)
            {
                devices = VideoDevice.ListVideoDevices();
                if (devices.Count == 0)
                {
                    MessagePopup.PopupMessage(mainWindow, MessageType.Error,
                                              Catalog.GetString("No capture devices were found."));
                    return;
                }
            }

            /* Show the new project dialog and wait to get a valid project
             * or quit if the user cancel it.*/
            npd = new NewProjectDialog();
            npd.TransientFor     = mainWindow;
            npd.Use              = projectType;
            npd.TemplatesService = Core.TemplatesService;
            if (projectType == ProjectType.CaptureProject)
            {
                npd.Devices = devices;
            }
            response = npd.Run();

            while (true)
            {
                /* User cancelled: quit */
                if (response != (int)ResponseType.Ok)
                {
                    npd.Destroy();
                    return;
                }
                /* No file chosen: display the dialog again */
                if (npd.Project == null)
                {
                    MessagePopup.PopupMessage(mainWindow, MessageType.Info,
                                              Catalog.GetString("Please, select a video file."));
                }
                /* If a project with the same file path exists show a warning */
                else if (Core.DB.Exists(npd.Project))
                {
                    MessagePopup.PopupMessage(mainWindow, MessageType.Error,
                                              Catalog.GetString("This file is already used in another Project.") + "\n" +
                                              Catalog.GetString("Select a different one to continue."));
                }

                else
                {
                    /* We are now ready to create the new project */
                    project = npd.Project;
                    if (projectType == ProjectType.CaptureProject)
                    {
                        captureSettings = npd.CaptureSettings;
                    }
                    npd.Destroy();
                    break;
                }
                response = npd.Run();
            }
            if (projectType == ProjectType.FileProject)
            {
                /* We can safelly add the project since we already checked if
                 * it can can added */
                Core.DB.AddProject(project);
            }
        }
Exemple #20
0
        private void ImportProject()
        {
            Project           project;
            bool              isFake, exists;
            int               res;
            string            fileName;
            FileFilter        filter;
            NewProjectDialog  npd;
            FileChooserDialog fChooser;

            Log.Debug("Importing project");
            /* Show a file chooser dialog to select the file to import */
            fChooser = new FileChooserDialog(Catalog.GetString("Import Project"),
                                             mainWindow,
                                             FileChooserAction.Open,
                                             "gtk-cancel", ResponseType.Cancel,
                                             "gtk-open", ResponseType.Accept);
            fChooser.SetCurrentFolder(Config.HomeDir());
            filter      = new FileFilter();
            filter.Name = Constants.PROJECT_NAME;
            filter.AddPattern("*.lpr");
            fChooser.AddFilter(filter);


            res      = fChooser.Run();
            fileName = fChooser.Filename;
            fChooser.Destroy();
            /* return if the user cancelled */
            if (res != (int)ResponseType.Accept)
            {
                return;
            }

            /* try to import the project and show a message error is the file
             * is not a valid project */
            try {
                project = Project.Import(fileName);
            }
            catch (Exception ex) {
                MessagePopup.PopupMessage(mainWindow, MessageType.Error,
                                          Catalog.GetString("Error importing project:") +
                                          "\n" + ex.Message);
                Log.Exception(ex);
                return;
            }

            isFake = (project.Description.File.FilePath == Constants.FAKE_PROJECT);

            /* If it's a fake live project prompt for a video file and
             * create a new PreviewMediaFile for this project */
            if (isFake)
            {
                Log.Debug("Importing fake live project");
                project.Description.File = null;
                npd = new NewProjectDialog();
                npd.TransientFor = mainWindow;
                npd.Use          = ProjectType.EditProject;
                npd.Project      = project;
                int response = npd.Run();
                while (true)
                {
                    if (response != (int)ResponseType.Ok)
                    {
                        npd.Destroy();
                        return;
                    }
                    else if (npd.Project == null)
                    {
                        MessagePopup.PopupMessage(mainWindow, MessageType.Info,
                                                  Catalog.GetString("Please, select a video file."));
                        response = npd.Run();
                    }
                    else
                    {
                        project = npd.Project;
                        npd.Destroy();
                        break;
                    }
                }
            }

            /* If the project exists ask if we want to overwrite it */
            if (Core.DB.Exists(project))
            {
                MessageDialog md = new MessageDialog(mainWindow,
                                                     DialogFlags.Modal,
                                                     MessageType.Question,
                                                     Gtk.ButtonsType.YesNo,
                                                     Catalog.GetString("A project already exists for the file:") +
                                                     project.Description.File.FilePath + "\n" +
                                                     Catalog.GetString("Do you want to overwrite it?"));
                md.Icon = Gtk.IconTheme.Default.LoadIcon("longomatch", 48, 0);
                res     = md.Run();
                md.Destroy();
                if (res != (int)ResponseType.Yes)
                {
                    return;
                }
                exists = true;
            }
            else
            {
                exists = false;
            }

            if (isFake)
            {
                CreateThumbnails(project);
            }
            if (exists)
            {
                Core.DB.UpdateProject(project);
            }
            else
            {
                Core.DB.AddProject(project);
            }


            MessagePopup.PopupMessage(mainWindow, MessageType.Info,
                                      Catalog.GetString("Project successfully imported."));
        }