]> git.sesse.net Git - vlc/commitdiff
Added setScrollField: and resetScrollField to manage the scroll field.
authorJérome Decoodt <djc@videolan.org>
Sun, 13 Mar 2005 23:19:12 +0000 (23:19 +0000)
committerJérome Decoodt <djc@videolan.org>
Sun, 13 Mar 2005 23:19:12 +0000 (23:19 +0000)
modules/gui/macosx/controls.m
modules/gui/macosx/intf.h
modules/gui/macosx/intf.m

index 9e0b6ce18f5d57bc110f712c24f1206cea44c886..6f738d571d3d1ec888ee74b010dc17b616ca6067 100644 (file)
 {
     intf_thread_t * p_intf = VLCIntf;
     audio_volume_t i_volume = (audio_volume_t)[sender intValue];
-
     aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_STEP );
+    [self updateVolumeSlider];
 }
 
 - (void)updateVolumeSlider
 {
+    NSString * o_text;
+    char * psz_text;
     intf_thread_t * p_intf = VLCIntf;
     audio_volume_t i_volume;
 
     aout_VolumeGet( p_intf, &i_volume );
-
+    psz_text = malloc( 32 * sizeof( char ) );
+/*FIXME: do we really need to work with a char * before NSString ? */
+    if( psz_text )
+    {
+        sprintf( psz_text, "Volume: %d", i_volume * 200 / AOUT_VOLUME_MAX );
+        o_text = [[NSString alloc] initWithCString:psz_text];
+        [o_main setScrollField:o_text stopAfter:1000000];
+        free( psz_text );
+    }
     [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)];
 }
 
index d1f552a4174a89ad1bbb7c148720f843bb2838d4..d43771cc04c751f58efdb4216ed04540e2292380 100644 (file)
@@ -237,6 +237,7 @@ struct intf_sys_t
     
     bool b_small_window;
     
+    mtime_t i_end_scroll;
 }
 
 + (VLCMain *)sharedInstance;
@@ -258,6 +259,8 @@ struct intf_sys_t
 - (void)manage;
 - (void)manageIntf:(NSTimer *)o_timer;
 - (void)setupMenus;
+- (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
+- (void)resetScrollField;
 
 - (void)updateMessageArray;
 - (void)playStatusUpdated:(int) i_status;
index f4defeced0126e52d739c2b98fb3ff0a84787d82..d227969a953828909db74dd80dceb42e317bf130 100644 (file)
@@ -417,7 +417,7 @@ static VLCMain *_o_sharedMainInstance = nil;
 - (void)initStrings
 {
     [o_window setTitle: _NS("VLC - Controller")];
-    [o_scrollfield setStringValue: _NS("VLC media player")];
+    [self setScrollField:_NS("VLC media player") stopAfter:-1];
 
     /* button controls */
     [o_btn_prev setToolTip: _NS("Previous")];
@@ -755,7 +755,6 @@ static VLCMain *_o_sharedMainInstance = nil;
 {
     NSDate * o_sleep_date;
     playlist_t * p_playlist;
-    vlc_value_t val;
 
     /* new thread requires a new pool */
     NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
@@ -797,7 +796,7 @@ static VLCMain *_o_sharedMainInstance = nil;
             /* input stopped */
             p_intf->p_sys->b_intf_update = VLC_TRUE;
             p_intf->p_sys->i_play_status = END_S;
-            [o_scrollfield setStringValue: _NS("VLC media player") ];
+            [self setScrollField: _NS("VLC media player") stopAfter:-1];
             vlc_object_release( p_input );
             p_input = NULL;
         }
@@ -909,7 +908,7 @@ static VLCMain *_o_sharedMainInstance = nil;
             if( o_temp == NULL )
                 o_temp = [NSString stringWithCString:
                     p_playlist->status.p_item->input.psz_name];
-            [o_scrollfield setStringValue: o_temp ];
+            [self setScrollField: o_temp stopAfter:-1];
 
             p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
                                                     FIND_ANYWHERE );
@@ -978,6 +977,9 @@ static VLCMain *_o_sharedMainInstance = nil;
 
     [self updateMessageArray];
 
+    if( (i_end_scroll != -1) && (mdate() > i_end_scroll) )
+        [self resetScrollField];
+
     [NSTimer scheduledTimerWithTimeInterval: 0.3
         target: self selector: @selector(manageIntf:)
         userInfo: nil repeats: FALSE];
@@ -1052,6 +1054,41 @@ static VLCMain *_o_sharedMainInstance = nil;
 #undef p_input
 }
 
+- (void)setScrollField:(NSString *)o_string stopAfter:(int)timeout
+{
+    if( timeout != -1 )
+        i_end_scroll = mdate() + timeout;
+    else
+        i_end_scroll = -1;
+    [o_scrollfield setStringValue: o_string];
+}
+
+- (void)resetScrollField
+{
+    i_end_scroll = -1;
+#define p_input p_intf->p_sys->p_input
+    if( p_input && !p_input->b_die )
+    {
+        NSString *o_temp;
+        playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                                   FIND_ANYWHERE );
+        if( p_playlist == NULL )
+        {
+            return;
+        }
+        o_temp = [NSString stringWithUTF8String:
+                  p_playlist->status.p_item->input.psz_name];
+        if( o_temp == NULL )
+            o_temp = [NSString stringWithCString:
+                    p_playlist->status.p_item->input.psz_name];
+        [self setScrollField: o_temp stopAfter:-1];
+        vlc_object_release( p_playlist );
+        return;
+    }
+#undef p_input
+    [self setScrollField: _NS("VLC media player") stopAfter:-1];
+}
+
 - (void)updateMessageArray
 {
     int i_start, i_stop;