[vlc-commits] macOS: Add ability to copy bookmarks

Marvin Scholz git at videolan.org
Sat May 20 23:29:26 CEST 2017


vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Tue May 16 21:11:23 2017 +0200| [1f77da0ff22e654915341025993f6279c9155c00] | committer: Marvin Scholz

macOS: Add ability to copy bookmarks

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

 modules/gui/macosx/VLCBookmarksWindowController.m | 58 +++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/modules/gui/macosx/VLCBookmarksWindowController.m b/modules/gui/macosx/VLCBookmarksWindowController.m
index a1c22fd63c..e3043b56fb 100644
--- a/modules/gui/macosx/VLCBookmarksWindowController.m
+++ b/modules/gui/macosx/VLCBookmarksWindowController.m
@@ -427,4 +427,62 @@ clear:
     }
 }
 
+/* Called when the user hits CMD + C or copy is clicked in the edit menu
+ */
+- (void) copy:(id)sender {
+    NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
+    NSIndexSet *selectionIndices = [_dataTable selectedRowIndexes];
+
+
+    input_thread_t *p_input = pl_CurrentInput(getIntf());
+    int i_bookmarks;
+    seekpoint_t **pp_bookmarks;
+
+    if (input_Control(p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, &i_bookmarks) != VLC_SUCCESS)
+        return;
+
+    [pasteBoard clearContents];
+    NSUInteger index = [selectionIndices firstIndex];
+
+    while(index != NSNotFound) {
+        /* Get values */
+        if (index >= i_bookmarks)
+            break;
+        NSString *name = toNSStr(pp_bookmarks[index]->psz_name);
+        NSString *time = [self timeStringForBookmark:pp_bookmarks[index]];
+
+        NSString *message = [NSString stringWithFormat:@"%@ - %@", name, time];
+        [pasteBoard writeObjects:@[message]];
+
+        /* Get next index */
+        index = [selectionIndices indexGreaterThanIndex:index];
+    }
+
+    // Clear the bookmark list
+    for (int i = 0; i < i_bookmarks; i++)
+        vlc_seekpoint_Delete(pp_bookmarks[i]);
+    free(pp_bookmarks);
+}
+
+#pragma mark -
+#pragma mark UI validation
+
+/* Validate the copy menu item
+ */
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem
+{
+    SEL theAction = [anItem action];
+
+    if (theAction == @selector(copy:)) {
+        if ([[_dataTable selectedRowIndexes] count] > 0) {
+            return YES;
+        }
+        return NO;
+    }
+    /* Indicate that we handle the validation method,
+     * even if we don’t implement the action
+     */
+    return YES;
+}
+
 @end



More information about the vlc-commits mailing list