]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/intf.m
* added a note about the update-checker to the news and updated the copyright dates...
[vlc] / modules / gui / macosx / intf.m
index 37417ec1da958f65ddc0b63fcb8614acb3bd1075..7205bd75caf52d32c59ac4546e574debb55fd93f 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * intf.m: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2002-2005 the VideoLAN team
+ * Copyright (C) 2002-2006 the VideoLAN team
  * $Id$
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
@@ -20,7 +20,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -41,6 +41,9 @@
 #include "wizard.h"
 #include "extended.h"
 #include "bookmarks.h"
+#include "sfilters.h"
+#include "interaction.h"
+#include "embeddedwindow.h"
 #include "update.h"
 
 /*****************************************************************************
@@ -72,7 +75,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
     [NSThread detachNewThreadSelector:@selector(self) toTarget:[NSString string] withObject:nil];
 
     p_intf->p_sys->o_sendport = [[NSPort port] retain];
-    p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
+    p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
     p_intf->b_play = VLC_TRUE;
     p_intf->pf_run = Run;
 
@@ -177,7 +180,7 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
  * playlistChanged: Callback triggered by the intf-change playlist
  * variable, to let the intf update the playlist.
  *****************************************************************************/
-int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
+static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
                      vlc_value_t old_val, vlc_value_t new_val, void *param )
 {
     intf_thread_t * p_intf = VLCIntf;
@@ -191,7 +194,7 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
  * FullscreenChanged: Callback triggered by the fullscreen-change playlist
  * variable, to let the intf update the controller.
  *****************************************************************************/
-int FullscreenChanged( vlc_object_t *p_this, const char *psz_variable,
+static int FullscreenChanged( vlc_object_t *p_this, const char *psz_variable,
                      vlc_value_t old_val, vlc_value_t new_val, void *param )
 {
     intf_thread_t * p_intf = VLCIntf;
@@ -199,6 +202,24 @@ int FullscreenChanged( vlc_object_t *p_this, const char *psz_variable,
     return VLC_SUCCESS;
 }
 
+/*****************************************************************************
+ * InteractCallback: Callback triggered by the interaction
+ * variable, to let the intf display error and interaction dialogs
+ *****************************************************************************/
+static int InteractCallback( vlc_object_t *p_this, const char *psz_variable,
+                     vlc_value_t old_val, vlc_value_t new_val, void *param )
+{
+    NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
+    VLCMain *interface = (VLCMain *)param;
+    interaction_dialog_t *p_dialog = (interaction_dialog_t *)(new_val.p_address);
+    NSValue *o_value = [NSValue valueWithPointer:p_dialog];
+    
+    [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCNewInteractionEventNotification" object:[interface getInteractionList]
+     userInfo:[NSDictionary dictionaryWithObject:o_value forKey:@"VLCDialogPointer"]];
+    
+    [o_pool release];
+    return VLC_SUCCESS;
+}
 
 static struct
 {
@@ -301,8 +322,11 @@ static VLCMain *_o_sharedMainInstance = nil;
     o_prefs = nil;
     o_open = [[VLCOpen alloc] init];
     o_wizard = [[VLCWizard alloc] init];
-    o_extended = [[VLCExtended alloc] init];
+    o_extended = nil;
     o_bookmarks = [[VLCBookmarks alloc] init];
+    o_embedded_list = [[VLCEmbeddedList alloc] init];
+    o_interaction_list = [[VLCInteractionList alloc] init];
+    o_sfilters = nil;
     o_update = [[VLCUpdate alloc] init];
 
     i_lastShownVolume = -1;
@@ -352,22 +376,22 @@ static VLCMain *_o_sharedMainInstance = nil;
     i_key = config_GetInt( p_intf, "key-next" );
     [o_mi_next setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
     [o_mi_next setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
-    i_key = config_GetInt( p_intf, "key-jump+10sec" );
+    i_key = config_GetInt( p_intf, "key-jump+short" );
     [o_mi_fwd setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
     [o_mi_fwd setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
-    i_key = config_GetInt( p_intf, "key-jump-10sec" );
+    i_key = config_GetInt( p_intf, "key-jump-short" );
     [o_mi_bwd setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
     [o_mi_bwd setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
-    i_key = config_GetInt( p_intf, "key-jump+1min" );
+    i_key = config_GetInt( p_intf, "key-jump+medium" );
     [o_mi_fwd1m setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
     [o_mi_fwd1m setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
-    i_key = config_GetInt( p_intf, "key-jump-1min" );
+    i_key = config_GetInt( p_intf, "key-jump-medium" );
     [o_mi_bwd1m setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
     [o_mi_bwd1m setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
-    i_key = config_GetInt( p_intf, "key-jump+5min" );
+    i_key = config_GetInt( p_intf, "key-jump+long" );
     [o_mi_fwd5m setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
     [o_mi_fwd5m setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
-    i_key = config_GetInt( p_intf, "key-jump-5min" );
+    i_key = config_GetInt( p_intf, "key-jump-long" );
     [o_mi_bwd5m setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
     [o_mi_bwd5m setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
     i_key = config_GetInt( p_intf, "key-vol-up" );
@@ -419,28 +443,23 @@ static VLCMain *_o_sharedMainInstance = nil;
         /* Check if we need to start playing */
         if( p_intf->b_play )
         {
-            playlist_Play( p_playlist );
+            playlist_LockControl( p_playlist, PLAYLIST_AUTOPLAY );
         }
         var_Create( p_playlist, "fullscreen", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
         val.b_bool = VLC_FALSE;
 
         var_AddCallback( p_playlist, "fullscreen", FullscreenChanged, self);
 
-        [o_btn_fullscreen setState: ( var_Get( p_playlist, "fullscreen", &val )>=0 && val.b_bool )];
+        [o_embedded_window setFullscreen: var_GetBool( p_playlist,
+                                                            "fullscreen" )];
         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];
+    var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
+    var_AddCallback( p_intf, "interaction", InteractCallback, self );
+    p_intf->b_interaction = VLC_TRUE;
+    
+    nib_main_loaded = TRUE;
 }
 
 - (void)initStrings
@@ -813,9 +832,26 @@ static VLCMain *_o_sharedMainInstance = nil;
     return nil;
 }
 
+- (id)getEmbeddedList
+{
+    if( o_embedded_list )
+    {
+        return o_embedded_list;
+    }
+    return nil;
+}
+
+- (id)getInteractionList
+{
+    if( o_interaction_list )
+    {
+        return o_interaction_list;
+    }
+    return nil;
+}
+
 - (void)manage
 {
-    NSDate * o_sleep_date;
     playlist_t * p_playlist;
 
     /* new thread requires a new pool */
@@ -861,6 +897,7 @@ static VLCMain *_o_sharedMainInstance = nil;
             p_intf->p_sys->b_intf_update = VLC_TRUE;
             p_intf->p_sys->i_play_status = END_S;
             [self setScrollField: _NS("VLC media player") stopAfter:-1];
+            msg_Dbg( p_intf, "input has stopped, refreshing interface" );
             vlc_object_release( p_input );
             p_input = NULL;
         }
@@ -870,12 +907,8 @@ static VLCMain *_o_sharedMainInstance = nil;
         [self manageVolumeSlider];
 
         vlc_mutex_unlock( &p_intf->change_lock );
-
-        o_sleep_date = [NSDate dateWithTimeIntervalSinceNow: .1];
-        [NSThread sleepUntilDate: o_sleep_date];
+        msleep( 100000 );
     }
-
-    [self terminate];
     [o_pool release];
 }
 
@@ -934,6 +967,8 @@ static VLCMain *_o_sharedMainInstance = nil;
         [o_timeslider setEnabled: b_seekable];
         [o_timefield setStringValue: @"0:00:00"];
 
+        [o_embedded_window setSeekable: b_seekable];
+
         p_intf->p_sys->b_intf_update = VLC_FALSE;
     }
 
@@ -953,7 +988,7 @@ static VLCMain *_o_sharedMainInstance = nil;
         playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                    FIND_ANYWHERE );
         var_Get( p_playlist, "fullscreen", &val );
-        [o_btn_fullscreen setState: val.b_bool];
+        [o_embedded_window setFullscreen: val.b_bool];
         vlc_object_release( p_playlist );
 
         p_intf->p_sys->b_fullscreen_update = VLC_FALSE;
@@ -981,8 +1016,8 @@ static VLCMain *_o_sharedMainInstance = nil;
                     p_playlist->status.p_item->input.psz_name];
             [self setScrollField: o_temp stopAfter:-1];
 
-            p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
-                                                    FIND_ANYWHERE );
+            p_vout = vlc_object_find( p_input, VLC_OBJECT_VOUT,
+                                                    FIND_PARENT );
             if( p_vout != NULL )
             {
                 id o_vout_wnd;
@@ -990,9 +1025,12 @@ static VLCMain *_o_sharedMainInstance = nil;
 
                 while( ( o_vout_wnd = [o_enum nextObject] ) )
                 {
-                    if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] )
+                    if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"]
+                        || [[[VLCMain sharedInstance] getEmbeddedList]
+                                            windowContainsEmbedded: o_vout_wnd] )
                     {
-                        [o_vout_wnd updateTitle];
+                        msg_Dbg( p_intf, "updateTitle call getVoutView" );
+                        [[o_vout_wnd getVoutView] updateTitle];
                     }
                 }
                 vlc_object_release( (vlc_object_t *)p_vout );
@@ -1023,8 +1061,9 @@ static VLCMain *_o_sharedMainInstance = nil;
                             (int) (i_seconds / 60 % 60),
                             (int) (i_seconds % 60)];
             [o_timefield setStringValue: o_time];
+            [o_embedded_window setTime: o_time position: f_updated];
         }
-        
+
         if( p_intf->p_sys->b_volume_update )
         {
             NSString *o_text;
@@ -1045,6 +1084,7 @@ static VLCMain *_o_sharedMainInstance = nil;
         {
             p_intf->p_sys->i_play_status = val.i_int;
             [self playStatusUpdated: p_intf->p_sys->i_play_status];
+            [o_embedded_window playStatusUpdated: p_intf->p_sys->i_play_status];
         }
     }
     else
@@ -1052,6 +1092,7 @@ static VLCMain *_o_sharedMainInstance = nil;
         p_intf->p_sys->i_play_status = END_S;
         p_intf->p_sys->b_intf_update = VLC_TRUE;
         [self playStatusUpdated: p_intf->p_sys->i_play_status];
+        [o_embedded_window playStatusUpdated: p_intf->p_sys->i_play_status];
         [self setSubmenusEnabled: FALSE];
     }
 
@@ -1338,6 +1379,7 @@ static VLCMain *_o_sharedMainInstance = nil;
                         (int) (i_seconds / 60 % 60),
                         (int) (i_seconds % 60)];
         [o_timefield setStringValue: o_time];
+        [o_embedded_window setTime: o_time position: f_updated];
     }
 #undef p_input
 }
@@ -1376,6 +1418,41 @@ static VLCMain *_o_sharedMainInstance = nil;
     }
     msleep( 500000 );
 
+    /* save the prefs if they were changed in the extended panel */
+    if (o_extended && [o_extended getConfigChanged])
+    {
+        [o_extended savePrefs];
+    }
+    
+    p_intf->b_interaction = VLC_FALSE;
+    var_DelCallback( p_intf, "interaction", InteractCallback, self );
+
+    /* release some other objects here, because it isn't sure whether dealloc
+     * will be called later on -- FK (10/6/05) */
+    if( nib_about_loaded && o_about )
+        [o_about release];
+    
+    if( nib_open_loaded && o_open )
+        [o_open release];
+    
+    if( nib_extended_loaded && o_extended )
+    {
+        [o_extended collapsAll];
+        [o_extended release];
+    }
+    
+    if( nib_bookmarks_loaded && o_bookmarks )
+        [o_bookmarks release];
+
+    if( nib_wizard_loaded && o_wizard )
+        [o_wizard release];
+        
+    if( o_embedded_list != nil )
+        [o_embedded_list release];
+
+    if( o_interaction_list != nil )
+        [o_interaction_list release];
+
     if( o_img_pause_pressed != nil )
     {
         [o_img_pause_pressed release];
@@ -1417,7 +1494,6 @@ static VLCMain *_o_sharedMainInstance = nil;
     [[NSUserDefaults standardUserDefaults] synchronize];
 
     p_intf->b_die = VLC_TRUE;
-    [NSApp stop:NULL];
 }
 
 - (IBAction)clearRecentItems:(id)sender
@@ -1495,6 +1571,10 @@ static VLCMain *_o_sharedMainInstance = nil;
 
 - (IBAction)showExtended:(id)sender
 {
+    if ( o_extended == nil )
+    {
+        o_extended = [[VLCExtended alloc] init];
+    }
     if (!nib_extended_loaded)
     {
         nib_extended_loaded = [NSBundle loadNibNamed:@"Extended" owner:self];
@@ -1505,12 +1585,29 @@ static VLCMain *_o_sharedMainInstance = nil;
     }
 }
 
+- (IBAction)showSFilters:(id)sender
+{
+    if ( o_sfilters == nil )
+    {
+        o_sfilters = [[VLCsFilters alloc] init];
+    }
+    if (!nib_sfilters_loaded)
+    {
+        nib_sfilters_loaded = [NSBundle loadNibNamed:@"SFilters" owner:self];
+        [o_sfilters initStrings];
+        [o_sfilters showAsPanel];
+    } else {
+        [o_sfilters showAsPanel];
+    }
+}
+
 - (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];
+        [o_wizard initStrings];
     }
     
     if (!nib_bookmarks_loaded)