[vlc-commits] macosx: playlist: catch update events for metadata and info

David Fuhrmann git at videolan.org
Sun Mar 8 17:49:19 CET 2015


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sun Mar  8 17:14:53 2015 +0100| [5472238d245bc0aed7a61526108617a66fca5eae] | committer: David Fuhrmann

macosx: playlist: catch update events for metadata and info

Playlist view gets updated to display new information.
Info dialog gets updates (shows only information about currently
played input at the moment).

close #13729

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

 modules/gui/macosx/PLModel.h  |    5 ++++-
 modules/gui/macosx/PLModel.m  |   30 ++++++++++++++++++++++++++++++
 modules/gui/macosx/intf.h     |    2 +-
 modules/gui/macosx/intf.m     |   18 +++++++++++++-----
 modules/gui/macosx/playlist.m |    2 --
 5 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/modules/gui/macosx/PLModel.h b/modules/gui/macosx/PLModel.h
index d6584ae..d4b1a7e 100644
--- a/modules/gui/macosx/PLModel.h
+++ b/modules/gui/macosx/PLModel.h
@@ -76,12 +76,15 @@ typedef enum {
 - (PLRootType)currentRootType;
 
 - (BOOL)editAllowed;
-
+// updates from core
 - (void)addItem:(int)i_item withParentNode:(int)i_node;
 - (void)removeItem:(int)i_item;
 
+- (void)updateItem:(input_item_t *)p_input_item;
+
 - (PLItem *)currentlyPlayingItem;
 
+// sorting / searching
 - (void)sortForColumn:(NSString *)o_column withMode:(int)i_mode;
 
 - (void)searchUpdate:(NSString *)o_search;
diff --git a/modules/gui/macosx/PLModel.m b/modules/gui/macosx/PLModel.m
index 9503e70..7aa8036 100644
--- a/modules/gui/macosx/PLModel.m
+++ b/modules/gui/macosx/PLModel.m
@@ -43,6 +43,8 @@
 @synthesize rootItem=_rootItem;
 @synthesize draggedItems=_draggedItems;
 
+#pragma mark -
+#pragma mark Init and Stuff
 
 - (id)initWithOutlineView:(NSOutlineView *)outlineView playlist:(playlist_t *)pl rootItem:(playlist_item_t *)root playlistObject:(id)plObj;
 {
@@ -147,6 +149,8 @@
     return nil;
 }
 
+#pragma mark -
+#pragma mark Core events
 
 - (void)addItem:(int)i_item withParentNode:(int)i_node
 {
@@ -201,6 +205,29 @@
         [_outlineView reloadItem:o_parent reloadChildren:YES];
 }
 
+- (void)updateItem:(input_item_t *)p_input_item
+{
+    PL_LOCK;
+    playlist_item_t *pl_item = playlist_ItemGetByInput(p_playlist, p_input_item);
+    if (!pl_item) {
+        PL_UNLOCK;
+        return;
+    }
+    PLItem *item = [self findItemByPlaylistId:pl_item->i_id];
+    PL_UNLOCK;
+
+    if (!item)
+        return;
+
+    NSInteger row = [_outlineView rowForItem:item];
+    if (row == -1)
+        return;
+
+    [_outlineView reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:row]
+                            columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[_outlineView tableColumns] count])]];
+
+}
+
 - (PLItem *)currentlyPlayingItem
 {
     PLItem *item = nil;
@@ -213,6 +240,9 @@
     return item;
 }
 
+#pragma mark -
+#pragma mark Sorting / Searching
+
 - (void)sortForColumn:(NSString *)o_column withMode:(int)i_mode
 {
     int i_column = 0;
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 4109e62..bbb5283 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -159,7 +159,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
 - (void)updatePlaybackPosition;
 - (void)updateName;
 - (void)updateRecordState: (BOOL)b_value;
-- (void)updateInfoandMetaPanel;
+- (void)updateMetaAndInfo;
 - (void)updateMainMenu;
 - (void)updateMainWindow;
 - (void)showMainWindow;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 49f32bf..851f229 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -344,7 +344,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
         case INPUT_EVENT_ITEM_INFO:
             [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(updateMainMenu) withObject: nil waitUntilDone:NO];
             [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(updateName) withObject: nil waitUntilDone:NO];
-            [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(updateInfoandMetaPanel) withObject: nil waitUntilDone:NO];
+            [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(updateMetaAndInfo) withObject: nil waitUntilDone:NO];
             break;
         case INPUT_EVENT_BOOKMARK:
             break;
@@ -361,8 +361,6 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
 
         case INPUT_EVENT_ITEM_NAME:
             [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(updateName) withObject: nil waitUntilDone:NO];
-            // TODO update playlist item with new name
-//            [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(playlistUpdated) withObject: nil waitUntilDone:NO];
             break;
 
         case INPUT_EVENT_AUDIO_DELAY:
@@ -1355,6 +1353,8 @@ static bool f_appExit = false;
         }
     }
 
+    [self updateMetaAndInfo];
+
     [o_mainwindow updateWindow];
     [self updateDelays];
     [self updateMainMenu];
@@ -1429,9 +1429,17 @@ static bool f_appExit = false;
     [o_mainmenu updateRecordState:b_value];
 }
 
-- (void)updateInfoandMetaPanel
+- (void)updateMetaAndInfo
 {
-    [o_playlist outlineViewSelectionDidChange:nil];
+    if (!p_current_input) {
+        [[self info] updatePanelWithItem:nil];
+        return;
+    }
+
+    input_item_t *p_input_item = input_GetItem(p_current_input);
+
+    [[[self playlist] model] updateItem:p_input_item];
+    [[self info] updatePanelWithItem:p_input_item];
 }
 
 - (void)resumeItunesPlayback:(id)sender
diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index ddd1d68..825f1c2 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -346,8 +346,6 @@
     if (!item)
         return;
 
-    [[[VLCMain sharedInstance] info] updatePanelWithItem: [item input]];
-
     // select item
     NSInteger itemIndex = [o_outline_view rowForItem:item];
     if (itemIndex < 0) {



More information about the vlc-commits mailing list