]> git.sesse.net Git - vlc/commitdiff
skins2: improve $N text variable
authorErwan Tulou <erwan10@videolan.org>
Sat, 30 Mar 2013 18:38:32 +0000 (19:38 +0100)
committerErwan Tulou <erwan10@videolan.org>
Sat, 30 Mar 2013 19:15:01 +0000 (20:15 +0100)
Instead of hardcoding what we think the name of the current item is, make it
configurable via the --input-title-format parameter.

This change makes skins2 more consistent with qt4 that already uses this
means to set the title of the main window.

Default display will now be "artist + title" instead of just "title".
Users who would still prefer the previous behaviour can get it with
--input-title-format '$t'

This fixes a request described at http://forum.videolan.org/viewtopic.php?f=15&t=108976

modules/gui/skins2/src/vlcproc.cpp

index d5d17f5e90f1653da503170da86e7066fdd5081b..c15943580c99c41792be6a4cbc3401dae0c6bdc1 100644 (file)
@@ -32,6 +32,7 @@
 #include <vlc_vout.h>
 #include <vlc_playlist.h>
 #include <vlc_url.h>
+#include <vlc_strings.h>
 
 #include "vlcproc.hpp"
 #include "os_factory.hpp"
@@ -789,6 +790,7 @@ void VlcProc::init_variables()
 
 void VlcProc::update_current_input()
 {
+    playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
     input_thread_t* pInput = getIntf()->p_sys->p_input;
     if( !pInput )
         return;
@@ -796,16 +798,11 @@ void VlcProc::update_current_input()
     input_item_t *pItem = input_GetItem( pInput );
     if( pItem )
     {
-        // Update short name
-        char *psz_name = input_item_GetTitle( pItem );
-        if( EMPTY_STR( psz_name ) )
-        {
-            free( psz_name );
-            psz_name = input_item_GetName( pItem );
-        }
-        if( !psz_name )
-            psz_name = strdup ( "" );
+        // Update short name (as defined by --input-title-format)
+        char *psz_fmt = var_InheritString( getIntf(), "input-title-format" );
+        char *psz_name = str_format_meta( pPlaylist, psz_fmt );
         SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
+        free( psz_fmt );
         free( psz_name );
 
         // Update local path (if possible) or full uri