]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/intf.m
* loadNibNamed:withOwner calls awakeFromNib on owner. Therefore opening panels result...
[vlc] / modules / gui / macosx / intf.m
index 72ababd32fc089aac149e981aa17e978282ce565..94fa5ac467833223a8081cd9d4f12635d16e7bf8 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * intf.m: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2002-2005 VideoLAN
+ * Copyright (C) 2002-2005 the VideoLAN team
  * $Id$
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
 #include "controls.h"
 #include "about.h"
 #include "open.h"
+#include "wizard.h"
+#include "extended.h"
+#include "bookmarks.h"
+#include "update.h"
 
 /*****************************************************************************
  * Local prototypes.
@@ -296,6 +300,10 @@ static VLCMain *_o_sharedMainInstance = nil;
     o_about = [[VLAboutBox alloc] init];
     o_prefs = nil;
     o_open = [[VLCOpen alloc] init];
+    o_wizard = [[VLCWizard alloc] init];
+    o_extended = [[VLCExtended alloc] init];
+    o_bookmarks = [[VLCBookmarks alloc] init];
+    o_update = [[VLCUpdate alloc] init];
 
     i_lastShownVolume = -1;
     return _o_sharedMainInstance;
@@ -315,6 +323,9 @@ static VLCMain *_o_sharedMainInstance = nil;
     playlist_t *p_playlist;
     vlc_value_t val;
 
+    /* Check if we already did this once. Opening the other nibs calls it too, because VLCMain is the owner */
+    if( nib_main_loaded ) return;
+
     [self initStrings];
     [o_window setExcludedFromWindowsMenu: TRUE];
     [o_msgs_panel setExcludedFromWindowsMenu: TRUE];
@@ -418,6 +429,18 @@ static VLCMain *_o_sharedMainInstance = nil;
         [o_btn_fullscreen setState: ( var_Get( p_playlist, "fullscreen", &val )>=0 && val.b_bool )];
         vlc_object_release( p_playlist );
     }
+    nib_main_loaded = TRUE;
+}
+
+- (void)dealloc
+{
+    [o_about release];
+    [o_prefs release];
+    [o_open release];
+    [o_extended release];
+    [o_bookmarks release];
+    
+    [super dealloc];
 }
 
 - (void)initStrings
@@ -442,7 +465,8 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_msgs_btn_crashlog setTitle: _NS("Open CrashLog")];
 
     /* main menu */
-    [o_mi_about setTitle: _NS("About VLC media player")];
+    [o_mi_about setTitle: _NS("About VLC media player...")];
+    [o_mi_checkForUpdate setTitle: _NS("Check for update...")];
     [o_mi_prefs setTitle: _NS("Preferences...")];
     [o_mi_add_intf setTitle: _NS("Add Interface")];
     [o_mu_add_intf setTitle: _NS("Add Interface")];
@@ -459,6 +483,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_mi_open_net setTitle: _NS("Open Network...")];
     [o_mi_open_recent setTitle: _NS("Open Recent")];
     [o_mi_open_recent_cm setTitle: _NS("Clear Menu")];
+    [o_mi_open_wizard setTitle: _NS("Wizard...")];
 
     [o_mu_edit setTitle: _NS("Edit")];
     [o_mi_cut setTitle: _NS("Cut")];
@@ -524,6 +549,8 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_mi_close_window setTitle: _NS("Close Window")];
     [o_mi_controller setTitle: _NS("Controller")];
     [o_mi_equalizer setTitle: _NS("Equalizer")];
+    [o_mi_extended setTitle: _NS("Extended controls")];
+    [o_mi_bookmarks setTitle: _NS("Bookmarks")];
     [o_mi_playlist setTitle: _NS("Playlist")];
     [o_mi_info setTitle: _NS("Info")];
     [o_mi_messages setTitle: _NS("Messages")];
@@ -546,8 +573,10 @@ static VLCMain *_o_sharedMainInstance = nil;
 
     /* error panel */
     [o_error setTitle: _NS("Error")];
-    [o_err_lbl setStringValue: _NS("An error has occurred which probably prevented the execution of your request:")];
-    [o_err_bug_lbl setStringValue: _NS("If you believe that it is a bug, please follow the instructions at:")];
+    [o_err_lbl setStringValue: _NS("An error has occurred which probably " \
+        "prevented the execution of your request:")];
+    [o_err_bug_lbl setStringValue: _NS("If you believe that it is a bug, " \
+        "please follow the instructions at:")];
     [o_err_btn_msgs setTitle: _NS("Open Messages Window")];
     [o_err_btn_dismiss setTitle: _NS("Dismiss")];
     [o_err_ckbk_surpress setTitle: _NS("Suppress further errors")];
@@ -713,7 +742,13 @@ static VLCMain *_o_sharedMainInstance = nil;
         case NSDeleteFunctionKey:
         case NSDeleteCharFunctionKey:
         case NSBackspaceCharacter:
-            return YES;
+        case NSUpArrowFunctionKey:
+        case NSDownArrowFunctionKey:
+        case NSRightArrowFunctionKey:
+        case NSLeftArrowFunctionKey:
+        case NSEnterCharacter:
+        case NSCarriageReturnCharacter:
+            return NO;
     }
 
     val.i_int |= CocoaKeyToVLC( key );
@@ -754,7 +789,25 @@ static VLCMain *_o_sharedMainInstance = nil;
     {
         return o_info;
     }
-    return  nil;
+    return nil;
+}
+
+- (id)getWizard
+{
+    if ( o_wizard )
+    {
+        return o_wizard;
+    }
+    return nil;
+}
+
+- (id)getBookmarks
+{
+    if ( o_bookmarks )
+    {
+        return o_bookmarks;
+    }
+    return nil;
 }
 
 - (void)manage
@@ -810,6 +863,9 @@ static VLCMain *_o_sharedMainInstance = nil;
         }
 #undef p_input
 
+        /* Manage volume status */
+        [self manageVolumeSlider];
+
         vlc_mutex_unlock( &p_intf->change_lock );
 
         o_sleep_date = [NSDate dateWithTimeIntervalSinceNow: .1];
@@ -965,6 +1021,20 @@ static VLCMain *_o_sharedMainInstance = nil;
                             (int) (i_seconds % 60)];
             [o_timefield setStringValue: o_time];
         }
+        
+        if( p_intf->p_sys->b_volume_update )
+        {
+            NSString *o_text;
+            int i_volume_step = 0;
+            o_text = [NSString stringWithFormat: _NS("Volume: %d%%"), i_lastShownVolume * 400 / AOUT_VOLUME_MAX];
+            if( i_lastShownVolume != -1 )
+            [self setScrollField:o_text stopAfter:1000000];
+            i_volume_step = config_GetInt( p_intf->p_vlc, "volume-step" );
+            [o_volumeslider setFloatValue: (float)i_lastShownVolume / i_volume_step];
+            [o_volumeslider setEnabled: TRUE];
+            p_intf->p_sys->b_mute = ( i_lastShownVolume == 0 );
+            p_intf->p_sys->b_volume_update = FALSE;
+        }
 
         /* Manage Playing status */
         var_Get( p_input, "state", &val );
@@ -989,8 +1059,6 @@ static VLCMain *_o_sharedMainInstance = nil;
     if( (i_end_scroll != -1) && (mdate() > i_end_scroll) )
         [self resetScrollField];
 
-    /* Manage volume status */
-    [self manageVolumeSlider];
 
     [NSTimer scheduledTimerWithTimeInterval: 0.3
         target: self selector: @selector(manageIntf:)
@@ -1226,17 +1294,9 @@ static VLCMain *_o_sharedMainInstance = nil;
 
     if( i_volume != i_lastShownVolume )
     {
-        NSString *o_text;
-        o_text = [NSString stringWithFormat: _NS("Volume: %d"), i_volume * 200 / AOUT_VOLUME_MAX];
-        if( i_lastShownVolume != -1 )
-            [self setScrollField:o_text stopAfter:1000000];
-    
-        [o_volumeslider setFloatValue: (float)i_volume / AOUT_VOLUME_STEP];
-        [o_volumeslider setEnabled: TRUE];
         i_lastShownVolume = i_volume;
+        p_intf->p_sys->b_volume_update = TRUE;
     }
-
-    p_intf->p_sys->b_mute = ( i_volume == 0 );
 }
 
 - (IBAction)timesliderUpdate:(id)sender
@@ -1284,6 +1344,14 @@ static VLCMain *_o_sharedMainInstance = nil;
     playlist_t * p_playlist;
     vout_thread_t * p_vout;
 
+#define p_input p_intf->p_sys->p_input
+    if( p_input )
+    {
+        vlc_object_release( p_input );
+        p_input = NULL;
+    }
+#undef p_input
+
     /* Stop playback */
     if( ( p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                         FIND_ANYWHERE ) ) )
@@ -1408,9 +1476,58 @@ static VLCMain *_o_sharedMainInstance = nil;
     }
 }
 
+- (IBAction)showWizard:(id)sender
+{
+    if (!nib_wizard_loaded)
+    {
+        nib_wizard_loaded = [NSBundle loadNibNamed:@"Wizard" owner:self];
+        [o_wizard initStrings];
+        [o_wizard resetWizard];
+        [o_wizard showWizard];
+    } else {
+        [o_wizard resetWizard];
+        [o_wizard showWizard];
+    }
+}
+
+- (IBAction)showExtended:(id)sender
+{
+    if (!nib_extended_loaded)
+    {
+        nib_extended_loaded = [NSBundle loadNibNamed:@"Extended" owner:self];
+        [o_extended initStrings];
+        [o_extended showPanel];
+    } else {
+        [o_extended showPanel];
+    }
+}
+
+- (IBAction)showBookmarks:(id)sender
+{
+    /* we need the wizard-nib for the bookmarks's extract functionality */
+    if (!nib_wizard_loaded)
+    {
+        nib_wizard_loaded = [NSBundle loadNibNamed:@"Wizard" owner:self];
+    }
+    
+    if (!nib_bookmarks_loaded)
+    {
+        nib_bookmarks_loaded = [NSBundle loadNibNamed:@"Bookmarks" owner:self];
+        [o_bookmarks showBookmarks];
+    } else {
+        [o_bookmarks showBookmarks];
+    }
+}
+
 - (IBAction)viewAbout:(id)sender
 {
-    [o_about showPanel];
+    if (!nib_about_loaded)
+    {
+        nib_about_loaded = [NSBundle loadNibNamed:@"About" owner:self];
+        [o_about showPanel];
+    } else {
+        [o_about showPanel];
+    }
 }
 
 - (IBAction)viewPreferences:(id)sender
@@ -1421,6 +1538,17 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_prefs showPrefs];
 }
 
+- (IBAction)checkForUpdate:(id)sender
+{
+    if (!nib_update_loaded)
+    {
+        nib_update_loaded = [NSBundle loadNibNamed:@"Update" owner:self];
+        [o_update showUpdateWindow];
+    } else {
+        [o_update showUpdateWindow];
+    }
+}
+
 - (IBAction)closeError:(id)sender
 {
     vlc_value_t val;
@@ -1502,7 +1630,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     }
     else
     {
-        NSBeginInformationalAlertSheet(_NS("No CrashLog found"), @"Continue", nil, nil, o_msgs_panel, self, NULL, NULL, nil, _NS("Either you are running Mac OS X pre 10.2 or you haven't experienced any heavy crashes yet.") );
+        NSBeginInformationalAlertSheet(_NS("No CrashLog found"), @"Continue", nil, nil, o_msgs_panel, self, NULL, NULL, nil, _NS("You haven't experienced any heavy crashes yet.") );
 
     }
 }
@@ -1540,16 +1668,17 @@ static VLCMain *_o_sharedMainInstance = nil;
         if ( o_size_with_playlist.height > 200 )
         {
             o_rect.size.height = o_size_with_playlist.height;
+        } else {
+            o_rect.size.height = 500;
         }
-        else
+        
+        if ( o_size_with_playlist.width > [o_window minSize].width )
         {
-            o_rect.size.height = 500;
-            if ( o_rect.size.width == [o_window minSize].width )
-            {
-                o_rect.size.width = 500;
-            }
-
+            o_rect.size.width = o_size_with_playlist.width;
+        } else {
+            o_rect.size.width = 500;
         }
+        
         o_rect.size.height = (o_size_with_playlist.height > 200) ?
             o_size_with_playlist.height : 500;
         o_rect.origin.x = [o_window frame].origin.x;
@@ -1561,6 +1690,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     {
         /* make small */
         o_rect.size.height = [o_window minSize].height;
+        o_rect.size.width = [o_window minSize].width;
         o_rect.origin.x = [o_window frame].origin.x;
         /* Calculate the position of the lower right corner after resize */
         o_rect.origin.y = [o_window frame].origin.y +