~ubuntu-branches/ubuntu/lucid/gnome-subtitles/lucid

« back to all changes in this revision

Viewing changes to src/GnomeSubtitles/Core/GUI.cs

  • Committer: Bazaar Package Importer
  • Author(s): Tiago Bortoletto Vaz
  • Date: 2007-12-03 20:52:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071203205252-2y6uuv4gcw9mi9n5
Tags: 0.7-1
* New upstream release;
* Add libxml-parser-perl to Build-Depends-Indep. Thanks to Lucas Nussbaum.
  (Closes: #445799);
* Fixes manpage issue with dpatch

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
        dialog.Show();
149
149
                bool toOpen = dialog.WaitForResponse();
150
150
                if (toOpen) {
151
 
                        string filename = dialog.Filename;
152
 
                        OpenVideo(filename);
 
151
                        string videoUri = dialog.Uri;
 
152
                        OpenVideo(videoUri);
153
153
                }
154
154
    }
155
155
    
290
290
        /// <remarks>An error dialog is presented if an exception is caught during open.</remarks>
291
291
    private void Open (string path, int codePage, string videoFilename) {
292
292
        try {
293
 
                Encoding encoding = (codePage == -1 ? null : Encoding.GetEncoding(codePage));
 
293
                Encoding encoding =  CodePageToEncoding(codePage);
294
294
                Global.CreateDocument(path, encoding);
295
295
                        view.Selection.SelectFirst(); //TODO is this needed?
296
296
                
306
306
                }
307
307
    }
308
308
    
 
309
    /// <summary>Creates an <see cref="Encoding" /> from a code page.</summary>
 
310
    /// <param name="codePage">The code page.</param>
 
311
    /// <returns>The respective <see cref="Encoding" />, or null if codePage == -1.</returns>
 
312
    /// <exception cref="EncodingNotSupportedException">Thrown if a detected encoding is not supported by the platform.</exception>
 
313
    private Encoding CodePageToEncoding (int codePage) {
 
314
        if (codePage == -1)
 
315
                return null;
 
316
 
 
317
        try {
 
318
                return Encoding.GetEncoding(codePage);
 
319
        }
 
320
        catch (NotSupportedException) {
 
321
                throw new EncodingNotSupportedException();
 
322
        }
 
323
    }
 
324
 
309
325
    /// <summary>Opens a translation file, given its filename and code page.</summary>
310
326
        /// <param name="path">The path of the translation file to open.</param>
311
327
        /// <param name="codePage">The code page of the filename. To use autodetection, set it to -1.</param>
324
340
                }
325
341
    }
326
342
    
327
 
    private void OpenVideo (string path) {
 
343
    private void OpenVideo (string videoUriString) {
328
344
        Menus.SetViewVideoActivity(true);
 
345
        Uri videoUri = null;
329
346
                try {
330
 
                        Video.Open(path);
 
347
                        videoUri = new Uri(videoUriString);
 
348
                        Video.Open(videoUri);
331
349
                        Menus.SetVideoSensitivity(true);
332
350
                }
333
351
                catch (Exception exception) {
334
352
                        Video.Close();
335
 
                        VideoFileOpenErrorDialog errorDialog = new VideoFileOpenErrorDialog(path, exception);
 
353
                        VideoFileOpenErrorDialog errorDialog = new VideoFileOpenErrorDialog(videoUri, exception);
336
354
                        errorDialog.Show();
337
355
                        bool toOpenAgain = errorDialog.WaitForResponse();
338
356
                if (toOpenAgain)