]> 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 a9fc616f8001fda426953e60f42b81de8accd95c..94fa5ac467833223a8081cd9d4f12635d16e7bf8 100644 (file)
@@ -39,6 +39,9 @@
 #include "about.h"
 #include "open.h"
 #include "wizard.h"
+#include "extended.h"
+#include "bookmarks.h"
+#include "update.h"
 
 /*****************************************************************************
  * Local prototypes.
@@ -298,6 +301,9 @@ static VLCMain *_o_sharedMainInstance = nil;
     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;
@@ -317,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];
@@ -420,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
@@ -445,6 +466,7 @@ static VLCMain *_o_sharedMainInstance = nil;
 
     /* main menu */
     [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")];
@@ -527,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")];
@@ -549,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")];
@@ -716,7 +742,6 @@ static VLCMain *_o_sharedMainInstance = nil;
         case NSDeleteFunctionKey:
         case NSDeleteCharFunctionKey:
         case NSBackspaceCharacter:
-            return YES;
         case NSUpArrowFunctionKey:
         case NSDownArrowFunctionKey:
         case NSRightArrowFunctionKey:
@@ -776,6 +801,15 @@ static VLCMain *_o_sharedMainInstance = nil;
     return nil;
 }
 
+- (id)getBookmarks
+{
+    if ( o_bookmarks )
+    {
+        return o_bookmarks;
+    }
+    return nil;
+}
+
 - (void)manage
 {
     NSDate * o_sleep_date;
@@ -991,11 +1025,12 @@ static VLCMain *_o_sharedMainInstance = nil;
         if( p_intf->p_sys->b_volume_update )
         {
             NSString *o_text;
-            o_text = [NSString stringWithFormat: _NS("Volume: %d"), i_lastShownVolume * 200 / AOUT_VOLUME_MAX];
+            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];
-
-            [o_volumeslider setFloatValue: (float)i_lastShownVolume / AOUT_VOLUME_STEP];
+            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;
@@ -1309,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 ) ) )
@@ -1439,12 +1482,43 @@ static VLCMain *_o_sharedMainInstance = nil;
     {
         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
 {
     if (!nib_about_loaded)
@@ -1464,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;