~siretart/vlc/debian-packaging

« back to all changes in this revision

Viewing changes to modules/gui/macosx/playlist.m

  • Committer: Sebastian Ramacher
  • Date: 2016-01-31 20:58:37 UTC
  • mfrom: (1.2.39)
  • Revision ID: git-v1:b7ac1de93ecf7cd3d86898544433974ce0af7086
Merge tag 'upstream/2.2.2'

Upstream version 2.2.2

# gpg: Signature made Sun 31 Jan 2016 21:57:53 CET using RSA key ID 6EA71993
# gpg: Good signature from "Sebastian Ramacher <sebastian@ramacher.at>"
# gpg:                 aka "Sebastian Ramacher <s.ramacher@gmail.com>"
# gpg:                 aka "Sebastian Ramacher <s.ramacher@gmx.at>"
# gpg:                 aka "Sebastian Ramacher <s.ramacher@student.tugraz.at>"
# gpg:                 aka "Sebastian Ramacher <sramacher@debian.org>"
# gpg:                 aka "Sebastian Ramacher <sebastian.ramacher@iaik.tugraz.at>"

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * playlist.m: MacOS X interface module
3
3
 *****************************************************************************
4
4
* Copyright (C) 2002-2014 VLC authors and VideoLAN
5
 
 * $Id: a59298b9c23de6c8487fd6ad928129d3806460c4 $
 
5
 * $Id: 2b652c6d886f71c2068c72f4e45a4f6a01ee218d $
6
6
 *
7
7
 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8
8
 *          Derk-Jan Hartman <hartman at videola/n dot org>
51
51
#import "open.h"
52
52
#import "MainMenu.h"
53
53
#import "CoreInteraction.h"
 
54
#import "ResumeDialogController.h"
54
55
 
55
56
#include <vlc_keys.h>
56
57
#import <vlc_interface.h>
1505
1506
    return YES;
1506
1507
}
1507
1508
 
1508
 
- (void)updateAlertWindow:(NSTimer *)timer
1509
 
{
1510
 
    NSAlert *alert = [timer userInfo];
1511
 
 
1512
 
    --currentResumeTimeout;
1513
 
    if (currentResumeTimeout <= 0) {
1514
 
        [[alert window] close];
1515
 
        [NSApp abortModal];
1516
 
    }
1517
 
 
1518
 
    NSString *buttonLabel = _NS("Restart playback");
1519
 
    buttonLabel = [buttonLabel stringByAppendingFormat:@" (%d)", currentResumeTimeout];
1520
 
 
1521
 
    [[[alert buttons] objectAtIndex:2] setTitle:buttonLabel];
1522
 
}
1523
 
 
1524
1509
- (void)continuePlaybackWhereYouLeftOff:(input_thread_t *)p_input_thread
1525
1510
{
1526
1511
    NSDictionary *recentlyPlayedFiles = [[NSUserDefaults standardUserDefaults] objectForKey:@"recentlyPlayedMedia"];
1556
1541
    if (settingValue == 2) // never resume
1557
1542
        return;
1558
1543
 
1559
 
    NSInteger returnValue = NSAlertErrorReturn;
1560
 
    if (settingValue == 0) { // ask
1561
 
 
1562
 
        currentResumeTimeout = 6;
1563
 
        NSString *o_restartButtonLabel = _NS("Restart playback");
1564
 
        o_restartButtonLabel = [o_restartButtonLabel stringByAppendingFormat:@" (%d)", currentResumeTimeout];
1565
 
        NSAlert *theAlert = [NSAlert alertWithMessageText:_NS("Continue playback?") defaultButton:_NS("Continue") alternateButton:o_restartButtonLabel otherButton:_NS("Always continue") informativeTextWithFormat:_NS("Playback of \"%@\" will continue at %@"), [NSString stringWithUTF8String:input_item_GetTitleFbName(p_item)], [[VLCStringUtility sharedInstance] stringForTime:lastPosition.intValue]];
1566
 
 
1567
 
        NSTimer *timer = [NSTimer timerWithTimeInterval:1
1568
 
                                                 target:self
1569
 
                                               selector:@selector(updateAlertWindow:)
1570
 
                                               userInfo:theAlert
1571
 
                                                repeats:YES];
1572
 
 
1573
 
        [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSModalPanelRunLoopMode];
1574
 
 
1575
 
        returnValue = [theAlert runModal];
1576
 
        [timer invalidate];
1577
 
 
1578
 
        // restart button was pressed or timeout happened
1579
 
        if (returnValue == NSAlertAlternateReturn ||
1580
 
            returnValue == NSRunAbortedResponse)
 
1544
    CompletionBlock completionBlock = ^(enum ResumeResult result) {
 
1545
 
 
1546
        if (result == RESUME_RESTART)
1581
1547
            return;
 
1548
 
 
1549
        mtime_t lastPos = (mtime_t)lastPosition.intValue * 1000000;
 
1550
        msg_Dbg(VLCIntf, "continuing playback at %lld", lastPos);
 
1551
        var_SetTime(p_input_thread, "time", lastPos);
 
1552
 
 
1553
        if (result == RESUME_ALWAYS)
 
1554
            config_PutInt(VLCIntf, "macosx-continue-playback", 1);
 
1555
    };
 
1556
 
 
1557
    if (settingValue == 1) { // always
 
1558
        completionBlock(RESUME_NOW);
 
1559
        return;
1582
1560
    }
1583
1561
 
1584
 
    mtime_t lastPos = (mtime_t)lastPosition.intValue * 1000000;
1585
 
    msg_Dbg(VLCIntf, "continuing playback at %lld", lastPos);
1586
 
    var_SetTime(p_input_thread, "time", lastPos);
1587
 
 
1588
 
    if (returnValue == NSAlertOtherReturn)
1589
 
        config_PutInt(VLCIntf, "macosx-continue-playback", 1);
 
1562
    [[[VLCMain sharedInstance] resumeDialog] showWindowWithItem:p_item
 
1563
                                               withLastPosition:lastPosition.intValue
 
1564
                                                completionBlock:completionBlock];
1590
1565
}
1591
1566
 
1592
1567
- (void)storePlaybackPositionForItem:(input_thread_t *)p_input_thread