[vlc-devel] [PATCH] Added a hotkey for clearing the playlist.

Martin Zeman dileptor at gmail.com
Thu Apr 4 15:38:11 CEST 2013


---
 include/vlc_keys.h        |    1 +
 modules/control/hotkeys.c |   14 +++++++++++++-
 src/config/keys.c         |    1 +
 src/libvlc-module.c       |   11 +++++++++++
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index 141e4b9..90d5d85 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -159,6 +159,7 @@ typedef enum vlc_action {
     ACTIONID_PLAY_BOOKMARK9,
     ACTIONID_PLAY_BOOKMARK10,
     /* end of contiguous zone */
+    ACTIONID_PLAY_CLEAR,
     ACTIONID_SUBDELAY_UP,
     ACTIONID_SUBDELAY_DOWN,
     ACTIONID_SUBPOS_UP,
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 95bc0d0..fb95c2d 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -59,6 +59,7 @@ static int  ActionEvent( vlc_object_t *, char const *,
                          vlc_value_t, vlc_value_t, void * );
 static void PlayBookmark( intf_thread_t *, int );
 static void SetBookmark ( intf_thread_t *, int );
+static void ClearPlaylist ( intf_thread_t * );
 static void DisplayPosition( intf_thread_t *, vout_thread_t *, input_thread_t * );
 static void DisplayVolume( intf_thread_t *, vout_thread_t *, float );
 static void DisplayRate ( vout_thread_t *, float );
@@ -242,6 +243,11 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
             SetBookmark( p_intf, i_action - ACTIONID_SET_BOOKMARK1 + 1 );
             break;
 
+        case ACTIONID_PLAY_CLEAR:
+        {
+            ClearPlaylist( p_intf );
+            break;
+        }
         case ACTIONID_VOL_UP:
         {
             float vol;
@@ -931,7 +937,7 @@ static void PlayBookmark( intf_thread_t *p_intf, int i_num )
     char *psz_bookmark_name;
     if( asprintf( &psz_bookmark_name, "bookmark%i", i_num ) == -1 )
         return;
-
+    msg_Info( p_intf, "Play Bookmark");
     playlist_t *p_playlist = pl_Get( p_intf );
     char *psz_bookmark = var_CreateGetString( p_intf, psz_bookmark_name );
 
@@ -980,6 +986,12 @@ static void SetBookmark( intf_thread_t *p_intf, int i_num )
     free( psz_bookmark_name );
 }
 
+static void ClearPlaylist( intf_thread_t *p_intf )
+{
+    playlist_t *p_playlist = pl_Get( p_intf );
+    playlist_Clear( p_playlist, pl_Unlocked );
+}
+
 static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout,
                              input_thread_t *p_input )
 {
diff --git a/src/config/keys.c b/src/config/keys.c
index ee3c382..07dd6ec 100644
--- a/src/config/keys.c
+++ b/src/config/keys.c
@@ -275,6 +275,7 @@ static const struct action actions[] =
     { "audiodevice-cycle", ACTIONID_AUDIODEVICE_CYCLE, },
     { "chapter-next", ACTIONID_CHAPTER_NEXT, },
     { "chapter-prev", ACTIONID_CHAPTER_PREV, },
+    { "clear-playlist", ACTIONID_PLAY_CLEAR, },
     { "crop", ACTIONID_CROP, },
     { "crop-bottom", ACTIONID_CROP_BOTTOM, },
     { "crop-left", ACTIONID_CROP_LEFT, },
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 34a229e..c794be3 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1334,6 +1334,8 @@ static const char *const mouse_wheel_texts[] =
 #define PLAY_BOOKMARK8_KEY_TEXT N_("Play playlist bookmark 8")
 #define PLAY_BOOKMARK9_KEY_TEXT N_("Play playlist bookmark 9")
 #define PLAY_BOOKMARK10_KEY_TEXT N_("Play playlist bookmark 10")
+#define PLAY_CLEAR_KEY_TEXT N_("Clear the playlist")
+#define PLAY_CLEAR_KEY_LONGTEXT N_("Select the key to clear the current playlist.")
 #define PLAY_BOOKMARK_KEY_LONGTEXT N_("Select the key to play this bookmark.")
 #define SET_BOOKMARK1_KEY_TEXT N_("Set playlist bookmark 1")
 #define SET_BOOKMARK2_KEY_TEXT N_("Set playlist bookmark 2")
@@ -1360,6 +1362,8 @@ static const char *const mouse_wheel_texts[] =
 #define BOOKMARK_LONGTEXT N_( \
       "This allows you to define playlist bookmarks.")
 
+#define CLEAR_PLAYLIST_TEXT N_("Clear playlist")
+#define CLEAR_PLAYLIST_LONGTEXT N_("This allows you to clear the playlist.")
 #define AUDIO_TRACK_KEY_TEXT N_("Cycle audio track")
 #define AUDIO_TRACK_KEY_LONGTEXT N_("Cycle through the available audio tracks(languages).")
 #define SUBTITLE_TRACK_KEY_TEXT N_("Cycle subtitle track")
@@ -2242,6 +2246,7 @@ vlc_module_begin ()
 #   define KEY_PLAY_BOOKMARK8     "F8"
 #   define KEY_PLAY_BOOKMARK9     NULL
 #   define KEY_PLAY_BOOKMARK10    NULL
+#   define KEY_PLAY_CLEAR    	   "Ctrl+w"
 #   define KEY_RECORD             "Command+Shift+r"
 #   define KEY_WALLPAPER          "w"
 #   define KEY_AUDIODEVICE_CYCLE  "Shift+a"
@@ -2361,6 +2366,9 @@ vlc_module_begin ()
 #   define KEY_PLAY_BOOKMARK8     "F8"
 #   define KEY_PLAY_BOOKMARK9     "F9"
 #   define KEY_PLAY_BOOKMARK10    "F10"
+
+/* Playlist clear */
+#   define KEY_PLAY_CLEAR    	   "Ctrl+w"
 #endif
 
     add_key( "key-toggle-fullscreen", KEY_TOGGLE_FULLSCREEN, TOGGLE_FULLSCREEN_KEY_TEXT,
@@ -2577,6 +2585,8 @@ vlc_module_begin ()
              PLAY_BOOKMARK9_KEY_TEXT, PLAY_BOOKMARK_KEY_LONGTEXT, true )
     add_key( "key-play-bookmark10", KEY_PLAY_BOOKMARK10,
              PLAY_BOOKMARK10_KEY_TEXT, PLAY_BOOKMARK_KEY_LONGTEXT, true )
+    add_key( "key-clear-playlist", KEY_PLAY_CLEAR,
+             PLAY_CLEAR_KEY_TEXT, PLAY_CLEAR_KEY_LONGTEXT, true )
 
 
     add_string( "bookmark1", NULL,
@@ -2600,6 +2610,7 @@ vlc_module_begin ()
     add_string( "bookmark10", NULL,
               BOOKMARK10_TEXT, BOOKMARK_LONGTEXT, false )
 
+
 #define HELP_TEXT \
     N_("print help for VLC (can be combined with --advanced and " \
        "--help-verbose)")
-- 
1.7.9.5




More information about the vlc-devel mailing list