[vlc-commits] Show OSD when drag-n-dropping subtitles

Jean-Baptiste Kempf git at videolan.org
Sun Feb 9 23:58:36 CET 2014


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Feb  9 23:57:50 2014 +0100| [511888ee37892959a45e35a9f3d4d386f13419c2] | committer: Jean-Baptiste Kempf

Show OSD when drag-n-dropping subtitles

And when it was successfully added

Close #8395

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=511888ee37892959a45e35a9f3d4d386f13419c2
---

 include/vlc_input.h                   |   31 +++++++++++++++++++++++--------
 modules/gui/macosx/CoreInteraction.m  |    2 +-
 modules/gui/macosx/intf.m             |    2 +-
 modules/gui/macosx/playlist.m         |    2 +-
 modules/gui/qt4/dialogs_provider.cpp  |    4 ++--
 modules/gui/qt4/main_interface.cpp    |    4 ++--
 modules/gui/skins2/src/top_window.cpp |    2 +-
 7 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 53e22b6..4098e6b 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -36,6 +36,7 @@
 #include <vlc_epg.h>
 #include <vlc_events.h>
 #include <vlc_input_item.h>
+#include <vlc_vout_osd.h>
 
 #include <string.h>
 
@@ -526,14 +527,6 @@ static inline input_state_e input_GetState( input_thread_t * p_input )
     input_Control( p_input, INPUT_GET_STATE, &state );
     return state;
 }
-/**
- * It will add a new subtitle source to the input.
- * Provided for convenience.
- */
-static inline int input_AddSubtitle( input_thread_t *p_input, const char *psz_url, bool b_check_extension )
-{
-    return input_Control( p_input, INPUT_ADD_SUBTITLE, psz_url, b_check_extension );
-}
 
 /**
  * Return one of the video output (if any). If possible, you should use
@@ -559,6 +552,28 @@ static inline vout_thread_t *input_GetVout( input_thread_t *p_input )
 }
 
 /**
+ * It will add a new subtitle source to the input.
+ * Provided for convenience.
+ */
+static inline int input_AddSubtitleOSD( input_thread_t *p_input, const char *psz_url,
+        bool b_check_extension, bool b_osd )
+{
+    int i_result = input_Control( p_input, INPUT_ADD_SUBTITLE, psz_url, b_check_extension );
+    if( i_result != VLC_SUCCESS || !b_osd )
+        return i_result;
+
+    vout_thread_t *p_vout = input_GetVout( p_input );
+    if( p_vout )
+    {
+        vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, _("Subtitle track added") );
+        vlc_object_release( (vlc_object_t *)p_vout );
+    }
+    return i_result;
+}
+#define input_AddSubtitle(a, b, c) input_AddSubtitleOSD(a, b, c, false)
+
+
+/**
  * Return the audio output (if any) associated with an input.
  * @param p_input an input thread
  * @return NULL on error, or the audio output (which needs to be
diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m
index 8990268..22f6700 100644
--- a/modules/gui/macosx/CoreInteraction.m
+++ b/modules/gui/macosx/CoreInteraction.m
@@ -576,7 +576,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
             BOOL b_returned = NO;
 
             if (count == 1 && p_input) {
-                b_returned = input_AddSubtitle(p_input, [[o_values objectAtIndex:0] UTF8String], true);
+                b_returned = input_AddSubtitleOSD(p_input, [[o_values objectAtIndex:0] UTF8String], true, true);
                 vlc_object_release(p_input);
                 if (!b_returned)
                     return YES;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index a844243..5ed847d 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1046,7 +1046,7 @@ static VLCMain *_o_sharedMainInstance = nil;
         input_thread_t * p_input = pl_CurrentInput(VLCIntf);
         if (p_input) {
             BOOL b_returned = NO;
-            b_returned = input_AddSubtitle(p_input, [[o_names objectAtIndex:0] UTF8String], true);
+            b_returned = input_AddSubtitleOSD(p_input, [[o_names objectAtIndex:0] UTF8String], true, true);
             vlc_object_release(p_input);
             if (!b_returned) {
                 free(psz_uri);
diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index ada48d1..4918b59 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -1597,7 +1597,7 @@
         BOOL b_returned = NO;
 
         if (count == 1 && p_input) {
-            b_returned = input_AddSubtitle(p_input, vlc_path2uri([[o_values objectAtIndex:0] UTF8String], NULL), true);
+            b_returned = input_AddSubtitleOSD(p_input, vlc_path2uri([[o_values objectAtIndex:0] UTF8String], NULL), true, true);
             vlc_object_release(p_input);
             if (!b_returned)
                 return YES;
diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 91055e9..eb31cf7 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -781,8 +781,8 @@ void DialogsProvider::loadSubtitlesFile()
     free( path2 );
     foreach( const QString &qsFile, qsl )
     {
-        if( input_AddSubtitle( p_input, qtu( toNativeSeparators( qsFile ) ),
-                    true ) )
+        if( input_AddSubtitleOSD( p_input, qtu( toNativeSeparators( qsFile ) ),
+                    true, true ) )
             msg_Warn( p_intf, "unable to load subtitles from '%s'",
                       qtu( qsFile ) );
     }
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 60f0a4f..7034fc5 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -1276,9 +1276,9 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playli
     /* D&D of a subtitles file, add it on the fly */
     if( mimeData->urls().count() == 1 && THEMIM->getIM()->hasInput() )
     {
-        if( !input_AddSubtitle( THEMIM->getInput(),
+        if( !input_AddSubtitleOSD( THEMIM->getInput(),
                  qtu( toNativeSeparators( mimeData->urls()[0].toLocalFile() ) ),
-                 true ) )
+                 true, true ) )
         {
             event->accept();
             return;
diff --git a/modules/gui/skins2/src/top_window.cpp b/modules/gui/skins2/src/top_window.cpp
index 1e88b9b..d65a80e 100644
--- a/modules/gui/skins2/src/top_window.cpp
+++ b/modules/gui/skins2/src/top_window.cpp
@@ -288,7 +288,7 @@ void TopWindow::processEvent( EvtDragDrop &rEvtDragDrop )
             char* psz_file = make_path( it->c_str() );
             if( psz_file )
             {
-                is_subtitle = !input_AddSubtitle( pInput, psz_file, true );
+                is_subtitle = !input_AddSubtitleOSD( pInput, psz_file, true, true );
                 free( psz_file );
             }
         }



More information about the vlc-commits mailing list