Commit d276418d authored by Goran Dokic's avatar Goran Dokic Committed by Felix Paul Kühne

macosx: add status bar menu

Signed-off-by: default avatarFelix Paul Kühne <fkuehne@videolan.org>
parent e08420e5
......@@ -160,6 +160,7 @@ EXTRA_DIST += \
extras/package/macosx/Resources/English.lproj/TextfieldPanel.xib \
extras/package/macosx/Resources/English.lproj/TimeSelectionPanel.xib \
extras/package/macosx/Resources/English.lproj/VideoEffects.xib \
extras/package/macosx/Resources/English.lproj/VLCStatusBarIconMainMenu.xib \
extras/package/macosx/Resources/fspanel/fs_background.png \
extras/package/macosx/Resources/fspanel/fs_background@2x.png \
extras/package/macosx/Resources/fspanel/fs_exit_fullscreen.png \
......@@ -855,6 +856,14 @@ EXTRA_DIST += \
extras/package/macosx/Resources/sidebar-icons_yosemite/ys-sidebar-playlist@2x.png \
extras/package/macosx/Resources/sidebar-icons_yosemite/ys-sidebar-podcast.png \
extras/package/macosx/Resources/sidebar-icons_yosemite/ys-sidebar-podcast@2x.png \
extras/package/macosx/Resources/vlcmenubaricon/pauseIcon.png \
extras/package/macosx/Resources/vlcmenubaricon/pauseIcon@2x.png \
extras/package/macosx/Resources/vlcmenubaricon/playIcon.png \
extras/package/macosx/Resources/vlcmenubaricon/playIcon@2x.png \
extras/package/macosx/Resources/vlcmenubaricon/statusBarIcon.png \
extras/package/macosx/Resources/vlcmenubaricon/statusBarIcon@2x.png \
extras/package/macosx/Resources/vlcmenubaricon/stopIcon.png \
extras/package/macosx/Resources/vlcmenubaricon/stopIcon@2x.png \
extras/package/macosx/Resources/vlc.scriptSuite \
extras/package/macosx/Resources/vlc.scriptTerminology \
extras/package/macosx/ub.sh \
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="14F1509" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="VLCStatusBarIcon">
<connections>
<outlet property="vlcStatusBarIconMenu" destination="534" id="O0F-8Q-FgA"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="420" customClass="NSFontManager"/>
<menu id="534" userLabel="vlcStatusBarIconMenu">
<items>
<menuItem title="Show Main WIndow" toolTip="Restore main window" id="08C-TA-yqu">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="restoreMainWindow:" target="-2" id="2Uq-Pa-toi"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="t2X-zn-Z4x"/>
<menuItem title="Play" tag="74747" toolTip="Start/Pause playback" id="9kC-yJ-Gy5">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="statusBarIconTogglePlayPause:" target="-2" id="py3-sd-ST2"/>
</connections>
</menuItem>
<menuItem title="Stop" tag="83838" toolTip="Stop playback" id="4Sh-MJ-bSf">
<connections>
<action selector="statusBarIconStop:" target="-2" id="unT-d5-vlC"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="b5S-aL-b79"/>
<menuItem title="Next" toolTip="Next track in playlist" id="GhQ-VQ-jtu">
<connections>
<action selector="statusBarIconNext:" target="-2" id="VZh-xB-5IC"/>
</connections>
</menuItem>
<menuItem title="Previous" toolTip="Previous track in playlist" id="iHu-rd-8KL">
<connections>
<action selector="statusBarIconPrevious:" target="-2" id="rNU-Dq-Sot"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="Dn5-wA-WfF"/>
<menuItem title="Random" tag="63636" toolTip="Randomize play order" id="lPi-EL-hoN">
<connections>
<action selector="statusBarIconToggleRandom:" target="-2" id="DyP-Hd-KHG"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="p96-c8-lBM"/>
<menuItem title="Quit" toolTip="Quit VLC" id="539">
<connections>
<action selector="quitAction:" target="-2" id="OJL-0Y-e8i"/>
</connections>
</menuItem>
</items>
<point key="canvasLocation" x="328.5" y="267.5"/>
</menu>
</objects>
</document>
......@@ -465,6 +465,16 @@
7D8BB0B71830311300FAE9B7 /* DebugMessageVisualizer.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B51830311300FAE9B7 /* DebugMessageVisualizer.xib */; };
7D8BB0BA1830367200FAE9B7 /* PlaylistMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B81830367200FAE9B7 /* PlaylistMenu.xib */; };
7D8BB0C01830393300FAE9B7 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0BE1830393300FAE9B7 /* MainWindow.xib */; };
7D9516B71C60B69200D14E1A /* VLCStatusBarIconMainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D9516B51C60B69200D14E1A /* VLCStatusBarIconMainMenu.xib */; };
7D9516BA1C60B6AB00D14E1A /* VLCStatusBarIcon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D9516B91C60B6AB00D14E1A /* VLCStatusBarIcon.m */; };
7D9516C41C60B6DB00D14E1A /* pauseIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D9516BC1C60B6DB00D14E1A /* pauseIcon.png */; };
7D9516C51C60B6DB00D14E1A /* pauseIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D9516BD1C60B6DB00D14E1A /* pauseIcon@2x.png */; };
7D9516C61C60B6DB00D14E1A /* playIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D9516BE1C60B6DB00D14E1A /* playIcon.png */; };
7D9516C71C60B6DB00D14E1A /* playIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D9516BF1C60B6DB00D14E1A /* playIcon@2x.png */; };
7D9516C81C60B6DB00D14E1A /* statusBarIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D9516C01C60B6DB00D14E1A /* statusBarIcon.png */; };
7D9516C91C60B6DB00D14E1A /* statusBarIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D9516C11C60B6DB00D14E1A /* statusBarIcon@2x.png */; };
7D9516CA1C60B6DB00D14E1A /* stopIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D9516C21C60B6DB00D14E1A /* stopIcon.png */; };
7D9516CB1C60B6DB00D14E1A /* stopIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D9516C31C60B6DB00D14E1A /* stopIcon@2x.png */; };
7DB65D5618ABD6490053B874 /* AddonManager.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7DB65D5418ABD6490053B874 /* AddonManager.xib */; };
7DD6EC101B58136D0047CF5C /* SimplePreferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7DD6EC0E1B58136D0047CF5C /* SimplePreferences.xib */; };
7DE78AC61B5D0A360019454C /* StreamOutput.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7DE78AC41B5D0A360019454C /* StreamOutput.xib */; };
......@@ -1257,6 +1267,17 @@
7D8BB0B61830311300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/DebugMessageVisualizer.xib; sourceTree = "<group>"; };
7D8BB0B91830367200FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/PlaylistMenu.xib; sourceTree = "<group>"; };
7D8BB0BF1830393300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/MainWindow.xib; sourceTree = "<group>"; };
7D9516B61C60B69200D14E1A /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/VLCStatusBarIconMainMenu.xib; sourceTree = "<group>"; };
7D9516B81C60B6AB00D14E1A /* VLCStatusBarIcon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCStatusBarIcon.h; path = ../../../modules/gui/macosx/VLCStatusBarIcon.h; sourceTree = "<group>"; };
7D9516B91C60B6AB00D14E1A /* VLCStatusBarIcon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCStatusBarIcon.m; path = ../../../modules/gui/macosx/VLCStatusBarIcon.m; sourceTree = "<group>"; };
7D9516BC1C60B6DB00D14E1A /* pauseIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = pauseIcon.png; path = Resources/vlcmenubaricon/pauseIcon.png; sourceTree = "<group>"; };
7D9516BD1C60B6DB00D14E1A /* pauseIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "pauseIcon@2x.png"; path = "Resources/vlcmenubaricon/pauseIcon@2x.png"; sourceTree = "<group>"; };
7D9516BE1C60B6DB00D14E1A /* playIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = playIcon.png; path = Resources/vlcmenubaricon/playIcon.png; sourceTree = "<group>"; };
7D9516BF1C60B6DB00D14E1A /* playIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "playIcon@2x.png"; path = "Resources/vlcmenubaricon/playIcon@2x.png"; sourceTree = "<group>"; };
7D9516C01C60B6DB00D14E1A /* statusBarIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = statusBarIcon.png; path = Resources/vlcmenubaricon/statusBarIcon.png; sourceTree = "<group>"; };
7D9516C11C60B6DB00D14E1A /* statusBarIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "statusBarIcon@2x.png"; path = "Resources/vlcmenubaricon/statusBarIcon@2x.png"; sourceTree = "<group>"; };
7D9516C21C60B6DB00D14E1A /* stopIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = stopIcon.png; path = Resources/vlcmenubaricon/stopIcon.png; sourceTree = "<group>"; };
7D9516C31C60B6DB00D14E1A /* stopIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "stopIcon@2x.png"; path = "Resources/vlcmenubaricon/stopIcon@2x.png"; sourceTree = "<group>"; };
7DA481221B5FC13700917FD7 /* VLCPlaylistView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCPlaylistView.h; path = ../../../modules/gui/macosx/VLCPlaylistView.h; sourceTree = "<group>"; };
7DA481231B5FC13700917FD7 /* VLCPlaylistView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = VLCPlaylistView.m; path = ../../../modules/gui/macosx/VLCPlaylistView.m; sourceTree = "<group>"; };
7DB65D5218ABD6380053B874 /* AddonsWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AddonsWindowController.h; path = ../../../modules/gui/macosx/AddonsWindowController.h; sourceTree = SOURCE_ROOT; };
......@@ -1902,6 +1923,8 @@
7DA481231B5FC13700917FD7 /* VLCPlaylistView.m */,
6B13E2A61BC67678001AD24A /* VLCScrollingClipView.h */,
6B13E2A71BC67678001AD24A /* VLCScrollingClipView.m */,
7D9516B81C60B6AB00D14E1A /* VLCStatusBarIcon.h */,
7D9516B91C60B6AB00D14E1A /* VLCStatusBarIcon.m */,
1CD366791B7A242E0054E39F /* VLCTimeSelectionPanelController.h */,
1CD3667A1B7A242E0054E39F /* VLCTimeSelectionPanelController.m */,
5CCED71414C0D4A90057F8D1 /* VLCUIWidgets.h */,
......@@ -2343,6 +2366,21 @@
name = QuincyKit;
sourceTree = "<group>";
};
7D9516BB1C60B6C700D14E1A /* status bar item */ = {
isa = PBXGroup;
children = (
7D9516BC1C60B6DB00D14E1A /* pauseIcon.png */,
7D9516BD1C60B6DB00D14E1A /* pauseIcon@2x.png */,
7D9516BE1C60B6DB00D14E1A /* playIcon.png */,
7D9516BF1C60B6DB00D14E1A /* playIcon@2x.png */,
7D9516C01C60B6DB00D14E1A /* statusBarIcon.png */,
7D9516C11C60B6DB00D14E1A /* statusBarIcon@2x.png */,
7D9516C21C60B6DB00D14E1A /* stopIcon.png */,
7D9516C31C60B6DB00D14E1A /* stopIcon@2x.png */,
);
name = "status bar item";
sourceTree = "<group>";
};
8E445F86047289E50059A3A7 /* fileicons */ = {
isa = PBXGroup;
children = (
......@@ -2375,6 +2413,7 @@
CC0430EE13B2461A00D7D52E /* ui graphics */ = {
isa = PBXGroup;
children = (
7D9516BB1C60B6C700D14E1A /* status bar item */,
1C88BC5719DC7CB300645190 /* fspanel-yosemite */,
CCCB86BF0ACFDE4A00CF1E10 /* fspanel */,
1C88BA9D19DC7C7800645190 /* mainwindow_yosemite */,
......@@ -2909,6 +2948,7 @@
7D3F6523188051F2005776C4 /* BWQuincyMain.xib */,
7DB65D5418ABD6490053B874 /* AddonManager.xib */,
7DE78AC41B5D0A360019454C /* StreamOutput.xib */,
7D9516B51C60B69200D14E1A /* VLCStatusBarIconMainMenu.xib */,
);
name = xibs;
sourceTree = "<group>";
......@@ -3158,6 +3198,7 @@
1C88BA7C19DC7B2200645190 /* yosemite-window-zoom-on.png in Resources */,
CC04331713B28B2900D7D52E /* fs_play_highlight.png in Resources */,
CC04331813B28B2900D7D52E /* fs_play.png in Resources */,
7D9516C81C60B6DB00D14E1A /* statusBarIcon.png in Resources */,
CC04331913B28B2900D7D52E /* fs_rewind_highlight.png in Resources */,
CC04331A13B28B2900D7D52E /* fs_rewind.png in Resources */,
CC04331B13B28B2900D7D52E /* fs_skip_next_highlight.png in Resources */,
......@@ -3171,6 +3212,7 @@
CC04332013B28B2900D7D52E /* fs_stop.png in Resources */,
CC04332113B28B2900D7D52E /* fs_time_slider_knob_highlight.png in Resources */,
CC04332213B28B2900D7D52E /* fs_time_slider_knob.png in Resources */,
7D9516C91C60B6DB00D14E1A /* statusBarIcon@2x.png in Resources */,
1C88BC0919DC7C8100645190 /* ys-fullscreen-one-button_dark.png in Resources */,
CC04332313B28B2900D7D52E /* fs_time_slider.png in Resources */,
1C51BDE51B7A221B0056B9AA /* TimeSelectionPanel.xib in Resources */,
......@@ -3357,6 +3399,7 @@
CCD83E4A13FEA143004F1652 /* Open.xib in Resources */,
CCD83E4B13FEA143004F1652 /* Preferences.xib in Resources */,
1C88BA7419DC7B2200645190 /* yosemite-window-minimize-over.png in Resources */,
7D9516B71C60B69200D14E1A /* VLCStatusBarIconMainMenu.xib in Resources */,
CCD83E4C13FEA143004F1652 /* SyncTracks.xib in Resources */,
CCD83E4D13FEA143004F1652 /* VideoEffects.xib in Resources */,
1C88BA9519DC7C5D00645190 /* ys-sidebar-music.png in Resources */,
......@@ -3472,6 +3515,7 @@
1C88BB6319DC7C7800645190 /* ys-shuffle-pressed@2x.png in Resources */,
CC9E5D9B15975F5B00D14E83 /* fs_background@2x.png in Resources */,
1C88BC3E19DC7C8100645190 /* ys-shuffle-blue-pressed_dark@2x.png in Resources */,
7D9516C51C60B6DB00D14E1A /* pauseIcon@2x.png in Resources */,
1C88BC2119DC7C8100645190 /* ys-previous-6btns-dark.png in Resources */,
CC9E5D9C15975F5B00D14E83 /* fs_exit_fullscreen@2x.png in Resources */,
CC9E5D9D15975F5B00D14E83 /* fs_forward_highlight@2x.png in Resources */,
......@@ -3494,9 +3538,11 @@
1C88BA7519DC7B2200645190 /* yosemite-window-minimize-over@2x.png in Resources */,
CC9E5DA815975F5B00D14E83 /* fs_skip_previous@2x.png in Resources */,
1C88BC4319DC7C8100645190 /* ys-shuffle_dark.png in Resources */,
7D9516C71C60B6DB00D14E1A /* playIcon@2x.png in Resources */,
CC9E5DA915975F5B00D14E83 /* fs_stop_highlight@2x.png in Resources */,
CC9E5DAA15975F5B00D14E83 /* fs_stop@2x.png in Resources */,
CC9E5DAB15975F5B00D14E83 /* fs_time_slider_knob_highlight@2x.png in Resources */,
7D9516C41C60B6DB00D14E1A /* pauseIcon.png in Resources */,
1CE5ED2619DD6AB700FCEFD3 /* lion-window-fullscreen@2x.png in Resources */,
1C88BB3E19DC7C7800645190 /* ys-playlist-btn.png in Resources */,
1C88BBEB19DC7C8100645190 /* ys-backward-6btns-dark.png in Resources */,
......@@ -3588,6 +3634,7 @@
CC9E5E08159760B100D14E83 /* stop@2x.png in Resources */,
CC9E5E09159760B100D14E83 /* volume-high@2x.png in Resources */,
1C88BCB719DC7CB300645190 /* ys-fs_volume_max@2x.png in Resources */,
7D9516CB1C60B6DB00D14E1A /* stopIcon@2x.png in Resources */,
1C88BB3019DC7C7800645190 /* ys-pause-pressed.png in Resources */,
CC9E5E0A159760B100D14E83 /* volume-low@2x.png in Resources */,
1C88BCBD19DC7CB300645190 /* ys-fs_volume_mute_highlight@2x.png in Resources */,
......@@ -3720,6 +3767,7 @@
1C88BA6019DC7B2200645190 /* yosemite-window-fullscreen-graphite.png in Resources */,
CC166FB415F511CC0088201B /* backward-3btns-dark.png in Resources */,
CC166FB515F511CC0088201B /* backward-3btns-dark@2x.png in Resources */,
7D9516CA1C60B6DB00D14E1A /* stopIcon.png in Resources */,
CC166FBA15F511DB0088201B /* backward-3btns-pressed.png in Resources */,
1C88BB3C19DC7C7800645190 /* ys-playlist-btn-pressed.png in Resources */,
CC166FBB15F511DB0088201B /* backward-3btns-pressed@2x.png in Resources */,
......@@ -3756,6 +3804,7 @@
CC166FE415F5136B0088201B /* previous-6btns-dark@2x.png in Resources */,
1C88BB1E19DC7C7800645190 /* ys-forward-3btns.png in Resources */,
CC166FE915F517660088201B /* backward-6btns-pressed.png in Resources */,
7D9516C61C60B6DB00D14E1A /* playIcon.png in Resources */,
1C88BB6819DC7C7800645190 /* ys-stop.png in Resources */,
CC166FEA15F517660088201B /* backward-6btns-pressed@2x.png in Resources */,
1C88BBF719DC7C8100645190 /* ys-effects-one-button-pressed-dark.png in Resources */,
......@@ -3855,6 +3904,7 @@
1CCB5F581A62A724004C3E90 /* applescript.m in Sources */,
1CCB5F591A62A724004C3E90 /* AudioEffects.h in Sources */,
1CCB5F5A1A62A724004C3E90 /* AudioEffects.m in Sources */,
7D9516BA1C60B6AB00D14E1A /* VLCStatusBarIcon.m in Sources */,
1CCB5F5B1A62A724004C3E90 /* bookmarks.h in Sources */,
1CCB5F5C1A62A724004C3E90 /* bookmarks.m in Sources */,
1CCB5F5D1A62A724004C3E90 /* CompatibilityFixes.h in Sources */,
......@@ -4022,6 +4072,14 @@
name = MainWindow.xib;
sourceTree = "<group>";
};
7D9516B51C60B69200D14E1A /* VLCStatusBarIconMainMenu.xib */ = {
isa = PBXVariantGroup;
children = (
7D9516B61C60B69200D14E1A /* English */,
);
name = VLCStatusBarIconMainMenu.xib;
sourceTree = "<group>";
};
7DB65D5418ABD6490053B874 /* AddonManager.xib */ = {
isa = PBXVariantGroup;
children = (
......
......@@ -74,5 +74,6 @@ libmacosx_plugin_la_SOURCES = \
VLCTimeSelectionPanelController.h VLCTimeSelectionPanelController.m \
VLCUIWidgets.h VLCUIWidgets.m \
VLCScrollingClipView.h VLCScrollingClipView.m \
VLCStatusBarIcon.h VLCStatusBarIcon.m \
VLCVoutWindowController.h VLCVoutWindowController.m \
Windows.h Windows.m
/*****************************************************************************
* VLCStatusBarIcon.h: Mac OS X module for vlc
*****************************************************************************
* Copyright (C) 2001-2016 VLC authors and VideoLAN
* $Id$
*
* Authors: Goran Dokic <vlc at 8hz dot com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <cocoa/cocoa.h>
@interface VLCStatusBarIcon : NSObject <NSMenuDelegate>
{
NSMenuItem *_vlcStatusBarMenuItem;
NSString *_nameToDisplay;
NSString *_timeToDisplay;
NSString *_durationToDisplay;
NSString *_urlToDisplay;
NSImage *_menuImagePlay;
NSImage *_menuImagePause;
NSImage *_menuImageStop;
}
@property NSStatusItem *statusItem;
@property NSTimer *dataRefreshUpdateTimer;
@property (readwrite, strong) IBOutlet NSMenu *vlcStatusBarIconMenu;
// get data from VLC and update the little status menu
- (void) updateMenuItemRandom;
- (void) updateMenuItemPlayPause;
- (void) setDataUpdateTimer:(float) interval;
- (IBAction) updateMenuItemContent:(id)sender;
- (IBAction) restoreMainWindow:(id)sender;
- (IBAction) statusBarIconTogglePlayPause:(id)sender;
- (IBAction) statusBarIconStop:(id)sender;
- (IBAction) statusBarIconNext:(id)sender;
- (IBAction) statusBarIconPrevious:(id)sender;
- (IBAction) statusBarIconToggleRandom:(id)sender;
@end
/*****************************************************************************
* VLCStatusBarIcon.m: Mac OS X module for vlc
*****************************************************************************
* Copyright (C) 2001-2016 VLC authors and VideoLAN
* $Id$
*
* Authors: Goran Dokic <vlc at 8hz dot com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "VLCStatusBarIcon.h"
#import "MainMenu.h"
#import "intf.h"
#import <vlc_common.h>
#import <vlc_playlist.h>
#import <vlc_input.h>
#import <CoreInteraction.h>
#import <StringUtility.h>
#pragma mark -
#pragma mark Defines
#define playPauseMenuItemTag 74747
#define stopMenuItemTag 83838
#define randomMenuItemTag 63636
#define dataUpdateTimerInterval 1.0
#define NSInitialToolTipDelayIn_ms 20
// #define showURLInToolTip 1
#pragma mark -
#pragma mark Implementation
//--
@implementation VLCStatusBarIcon {
//
}
#pragma mark -
#pragma mark Init
//--
//
//
+(id)alloc
{
return [super alloc];
}
//--
//
//
- (id) init
{
self = [super init];
if (self)
{
// Do some init if needed
}
return self;
}
//--
// Cleanup on isle 6
//
- (void) dealloc
{
if (self)
{
// cleanup
[self.dataRefreshUpdateTimer invalidate];
}
// [super dealloc];
}
// fire it up
//
//
- (void) awakeFromNib
{
[super awakeFromNib];
[self enableMenuIcon];
// add the top menu item for dynamic data
_vlcStatusBarMenuItem = [[NSMenuItem alloc] initWithTitle:@"URL/Path Options" action:@selector(updateMenuItemContent:) keyEquivalent:@""];
[_vlcStatusBarMenuItem setToolTip:@"Misc functions with media URL or Path"];
[_vlcStatusBarMenuItem setTarget:self];
[_vlcStatusBarIconMenu insertItem:_vlcStatusBarMenuItem atIndex:0];
// Set our selves up as delegate, to receive menuNeedsUpdate messages, so
// we can update our menu as needed/before it's drawn
[_vlcStatusBarIconMenu setDelegate:self];
// Disable custom menu item initially
// needs to be done with validateMenuItem (see below)
[_vlcStatusBarMenuItem setEnabled:NO];
// Increase toolTip speed, improves status usability
// Tweak delay above, with '#define NSInitialToolTipDelayIn_ms x'
[[NSUserDefaults standardUserDefaults] setObject: [NSNumber numberWithInt: NSInitialToolTipDelayIn_ms] forKey: @"NSInitialToolTipDelay"];
// init _urlToDisplay
_urlToDisplay = nil;
// Load the menu icons
_menuImagePlay = [NSImage imageNamed:@"playIcon"];
_menuImagePause = [NSImage imageNamed:@"pauseIcon"];
_menuImageStop = [NSImage imageNamed:@"stopIcon"];
NSMenuItem *menuItemToChange = [_vlcStatusBarIconMenu itemWithTag:stopMenuItemTag];
[menuItemToChange setImage:_menuImageStop];
// I'd rather not use a timer and only update when mouse comes near
// status icon in bar. But one can't tell without evil sourcery :(
// Tweak update frequency above (#define)
[self setDataUpdateTimer:dataUpdateTimerInterval];
}
#pragma mark -
#pragma mark Various callback functions
//---
// Menu delegate/callback for cocoa - called before menu is opened/displayed
// fire off menu item updates (dynamic item 0, play/pause, random)
- (void)menuNeedsUpdate:(NSMenu *)menu
{
// update dynamic menu 'item 0' (follows data gathered by timer handler)
[self updateDynamicMenuItemText];
// update play/pause status in status bar menu
[self updateMenuItemPlayPause];
// update random status in status bar menu
[self updateMenuItemRandom];
}
//---
// Make sure we can enable/disable menu items (in our case index 0)
// override class method. Called every time before menu is drawn.
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
SEL action = menuItem.action;
// disable the URL/Path options menu if there is no meaningful data
if ((action == @selector(updateMenuItemContent:)) && (!_urlToDisplay))
{
return NO;
}
return YES;
}
//---
// callback for tooltip update timer
//
- (void) dataRefreshTimeHandler:(NSTimer *)timer
{
[self gatherDataToDisplay];
[self updateToolTipText];
}
#pragma mark -
#pragma mark Various functions
//---
// enables menu icon/status item, sets proporties like image, attach menu
//
- (void) enableMenuIcon
{
_statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[_statusItem setHighlightMode:YES];
[_statusItem setEnabled:YES];
[_statusItem setTarget:self];
NSImage *menuIcon;
// set black/white icon (or color, like originally)
menuIcon = [NSImage imageNamed:@"statusBarIcon"];
// Make sure the b/w statusItem icon is inverted on dark/light mode
menuIcon.template = YES;
[_statusItem setImage:menuIcon];
// Attach pull-down menu
[_statusItem setMenu:_vlcStatusBarIconMenu];
}
//---
// Make sure data is fresh, before displaying
//
- (void) gatherDataToDisplay
{
mtime_t pos;
// get name of current item - clear first!
_nameToDisplay = nil;
_nameToDisplay = [[VLCCoreInteraction sharedInstance] nameOfCurrentPlaylistItem];
// If status is 'stopped' there is no useful data
// Otherwise could have used 'if (_nameToDisplay == nil)'
if ([self vlcPlayingStatus] == PLAYLIST_STOPPED)
{
_urlToDisplay = nil;
} else {
input_thread_t * p_input;
p_input = pl_CurrentInput(getIntf());
if (p_input)
{
pos = var_GetInteger(p_input, "time") / CLOCK_FREQ;
vlc_object_release(p_input); // must release or get segfault on quit
}
// update our time counter
_timeToDisplay = [[VLCStringUtility sharedInstance] stringForTime:(long long) pos];
// get the duration (if it's there)
int duration = [[VLCCoreInteraction sharedInstance] durationOfCurrentPlaylistItem];
_durationToDisplay = [[VLCStringUtility sharedInstance] stringForTime:(long long) duration];
// update the playing item's URL/Path
_urlToDisplay = [[[VLCCoreInteraction sharedInstance] URLOfCurrentPlaylistItem] absoluteString];
}
}
//---
// Call for periodic updates of tooltip text
//
- (void) updateToolTipText
{
NSString *toolTipText = nil;
// craft the multiline string, for the tooltip, depending on play status
if ([self vlcPlayingStatus] == PLAYLIST_STOPPED)
{
// nothing playing
toolTipText = @"VLC media player\nNothing playing";
} else {
#ifdef showURLInToolTip
toolTipText = [NSString stringWithFormat:@"VLC media player\nName: %@\nDuration: %@\nTime: %@\nURL/Path: %@", _nameToDisplay, _durationToDisplay, _timeToDisplay, _urlToDisplay];
#else
toolTipText = [NSString stringWithFormat:@"VLC media player\nName: %@\nDuration: %@\nTime: %@", _nameToDisplay, _durationToDisplay, _timeToDisplay];
#endif
}
[_statusItem setToolTip:toolTipText];
}
//---
// Call for updating of dynamic menu item
//
- (void) updateDynamicMenuItemText
{
NSString *menuString = nil;
// create string for dynamic menu bit (sync?)
if ([self vlcPlayingStatus] == PLAYLIST_STOPPED)
{
// put back our disabled menu item text.
menuString = @"URL/Path Options";
} else {
if ([_urlToDisplay hasPrefix:@"file://"])
{
// offer to show 'file://' in finder
menuString = [NSString stringWithFormat:@"Select File In Finder"];
} else {
// offer to copy URL to clipboard
menuString = [NSString stringWithFormat:@"Copy URL to clipboard"];
}
}
[_vlcStatusBarMenuItem setTitle:menuString];
}
//---
// set timer for tooltips updates and flee
//
- (void) setDataUpdateTimer:(float) interval
{
self.dataRefreshUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:interval
target:self
selector:@selector(dataRefreshTimeHandler:)
userInfo:nil
repeats:YES];
}
//---
//
//
- (void) updateMenuItemRandom
{
// get current random status
bool b_value;
playlist_t *p_playlist = pl_Get(getIntf());
b_value = var_GetBool(p_playlist, "random");
// get menuitem 'Random'
NSMenuItem* menuItemToChange = [_vlcStatusBarIconMenu itemWithTag:randomMenuItemTag];
if (b_value)
{
[menuItemToChange setState:NSOnState];
} else {
[menuItemToChange setState:NSOffState];
}
}
//---
//
//
- (void) updateMenuItemPlayPause
{
NSMenuItem* menuItemToChange = [_vlcStatusBarIconMenu itemWithTag:playPauseMenuItemTag];
if ([self vlcPlayingStatus] == PLAYLIST_RUNNING)
{
[menuItemToChange setTitle:@"Pause"];
[menuItemToChange setImage:_menuImagePause];
} else {
[menuItemToChange setTitle:@"Play"];
[menuItemToChange setImage:_menuImagePlay];
}
}
#pragma mark -
#pragma mark Utility functions
//---
// Returns VLC playlist status
// Check for: constants PLAYLIST_RUNNING, PLAYLIST_STOPPED, PLAYLIST_PAUSED.
- (int) vlcPlayingStatus
{
int res;
// get the playlist 'playing' status
playlist_t *p_playlist = pl_Get(getIntf());
PL_LOCK;
res = playlist_Status( p_playlist );
PL_UNLOCK;
return res;
}
//---
// Returns true if playing, false in all other cases.
//
- (BOOL) isVLCPlaying
{
bool vlcPlaying = false;
// get the playlist 'playing' status
playlist_t *p_playlist = pl_Get(getIntf());
PL_LOCK;
switch( playlist_Status( p_playlist ) )
{
case PLAYLIST_RUNNING:
vlcPlaying = true;
break;
case PLAYLIST_STOPPED:
case PLAYLIST_PAUSED:
default:
break;
}
PL_UNLOCK;
return vlcPlaying;
}
#pragma mark -
#pragma mark Menu item Actions
//-- action for dynamic menu index 0
- (IBAction) updateMenuItemContent:(id)sender
{
// Here we offer to copy the url to the clipboard or
// select/show a local file in the finder..(useful imo ;-)
if ([self vlcPlayingStatus] == PLAYLIST_STOPPED)
{
// Don't do anything, as the 'URL/path' is emtpy
} else {
if ([_urlToDisplay hasPrefix:@"file://"])
{
// show local file in finder
NSString *path=[_urlToDisplay substringFromIndex:7];
[[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:path];
} else {
// copy remote URL to clipboard
[[NSPasteboard generalPasteboard] clearContents];
[[NSPasteboard generalPasteboard] setString:_urlToDisplay forType:NSStringPboardType];
}
}
}
//-- action for 'main window'
- (IBAction)restoreMainWindow:(id)sender
{
// force our window to go to front (huzzah) and restore window
[[VLCApplication sharedApplication] activateIgnoringOtherApps:YES];
[[[VLCMain sharedInstance] mainWindow] makeKeyAndOrderFront:sender];
}
//-- action for 'toggle play/pause'
- (IBAction)statusBarIconTogglePlayPause:(id)sender
{
[[VLCCoreInteraction sharedInstance] playOrPause];
}
//-- action for 'stop'
- (IBAction)statusBarIconStop:(id)sender
{
[[VLCCoreInteraction sharedInstance] stop];
}
//-- action for 'Next track'
- (IBAction)statusBarIconNext:(id)sender
{
[[VLCCoreInteraction sharedInstance] next];
}
//-- action for 'previous track'
- (IBAction)statusBarIconPrevious:(id)sender
{
[[VLCCoreInteraction sharedInstance] previous];
}
//-- action to actually 'toggle VLC randomize playorder status'
- (IBAction)statusBarIconToggleRandom:(id)sender
{
[[VLCCoreInteraction sharedInstance] shuffle];
}
//-- action voor 'quit'
- (IBAction)quitAction:(id)sender
{
// clean timer, quit
[self.dataRefreshUpdateTimer invalidate];
[[NSApplication sharedApplication] terminate:nil];
}
@end
......@@ -41,6 +41,7 @@
#import "misc.h"
#import "MainWindow.h"
#import "VLCVoutWindowController.h"
#import "VLCStatusBarIcon.h"
#import "StringUtility.h"
/*****************************************************************************
......@@ -72,6 +73,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@class VLCConvertAndSave;
@class ExtensionsManager;
@class VLCInfo;
@class VLCStatusBarIcon;
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
......@@ -93,6 +95,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
- (ResumeDialogController *)resumeDialog;
- (VLCInputManager *)inputManager;
- (ExtensionsManager *)extensionsManager;
- (VLCStatusBarIcon *)statusBarIcon;
- (VLCDebugMessageVisualizer *)debugMsgPanel;
......
......@@ -95,6 +95,11 @@ int OpenIntf (vlc_object_t *p_this)
[VLCMain sharedInstance];
[NSBundle loadNibNamed:@"MainMenu" owner:[[VLCMain sharedInstance] mainMenu]];
// if statusbar enabled in preferences
if (config_GetInt(p_intf, "macosx-statusicon"))
{
[NSBundle loadNibNamed:@"VLCStatusBarIconMainMenu" owner:[[VLCMain sharedInstance] statusBarIcon]];
}
[[[VLCMain sharedInstance] mainWindow] makeKeyAndOrderFront:nil];
msg_Dbg(p_intf, "Finished loading macosx interface");
......@@ -173,6 +178,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
VLCInputManager *_input_manager;
VLCPlaylist *_playlist;
VLCDebugMessageVisualizer *_messagePanelController;
VLCStatusBarIcon *_statusBarIcon;
VLCTrackSynchronization *_trackSyncPanel;
VLCAudioEffects *_audioEffectsPanel;
VLCVideoEffects *_videoEffectsPanel;
......@@ -226,6 +232,12 @@ static VLCMain *sharedInstance = nil;
_coredialogs = [[VLCCoreDialogProvider alloc] init];
_mainmenu = [[VLCMainMenu alloc] init];
// if statusbar enabled in preferences
if (config_GetInt(p_intf, "macosx-statusicon")) {
_statusBarIcon = [[VLCStatusBarIcon alloc] init];
}
_voutController = [[VLCVoutWindowController alloc] init];
_playlist = [[VLCPlaylist alloc] init];
......@@ -507,6 +519,11 @@ static VLCMain *sharedInstance = nil;
return _mainmenu;
}
- (VLCStatusBarIcon *)statusBarIcon
{
return _statusBarIcon;
}
- (VLCMainWindow *)mainWindow
{
return (VLCMainWindow *)[_mainWindowController window];
......
......@@ -79,6 +79,9 @@ void WindowClose (vout_window_t *);
#define USE_APPLE_REMOTE_VOLUME_TEXT N_("Control system volume with the Apple Remote")
#define USE_APPLE_REMOTE_VOLUME_LONGTEXT N_("By default, VLC will control its own volume with the Apple Remote. However, you can choose to control the global system volume instead.")
#define DISPLAY_STATUS_ICONMENU_TEXT N_("Display VLC status menu icon")
#define DISPLAY_STATUS_ICONMENU_LONGTEXT N_("By default, VLC will show the statusbar icon menu. However, you can choose to disable it (restart required).")
#define USE_APPLE_REMOTE_PREVNEXT_TEXT N_("Control playlist items with the Apple Remote")
#define USE_APPLE_REMOTE_PREVNEXT_LONGTEXT N_("By default, VLC will allow you to switch to the next or previous item with the Apple Remote. You can disable this behavior with this option.")
......@@ -156,6 +159,7 @@ vlc_module_begin()
set_section(N_("Appearance"), 0)
add_bool("macosx-interfacestyle", false, INTERFACE_STYLE_TEXT, INTERFACE_STYLE_LONGTEXT, false)
add_bool("macosx-nativefullscreenmode", false, NATIVE_FULLSCREEN_MODE_ON_LION_TEXT, NATIVE_FULLSCREEN_MODE_ON_LION_LONGTEXT, false)
add_bool("macosx-statusicon", true, DISPLAY_STATUS_ICONMENU_TEXT, DISPLAY_STATUS_ICONMENU_LONGTEXT, false)
add_bool("macosx-icon-change", true, ICONCHANGE_TEXT, ICONCHANGE_LONGTEXT, true)
add_bool("macosx-show-playback-buttons", false, JUMPBUTTONS_TEXT, JUMPBUTTONS_LONGTEXT, false)
add_bool("macosx-show-playmode-buttons", false, PLAYMODEBUTTONS_TEXT, PLAYMODEBUTTONS_LONGTEXT, false)
......
......@@ -101,6 +101,7 @@
@property (readwrite, weak) IBOutlet NSButton *intf_appleremoteCheckbox;
@property (readwrite, weak) IBOutlet NSButton *intf_mediakeysCheckbox;
@property (readwrite, weak) IBOutlet NSButton *intf_appleremote_sysvolCheckbox;
@property (readwrite, weak) IBOutlet NSButton *intf_statusIconCheckbox;
// intf pane - behaviour box
@property (readwrite, weak) IBOutlet NSBox *intf_playbackBehaviourBox;
......
......@@ -373,6 +373,7 @@ create_toolbar_item(NSString *itemIdent, NSString *name, NSString *desc, NSStrin
[_intf_appleremoteCheckbox setTitle: _NS("Control playback with the Apple Remote")];
[_intf_mediakeysCheckbox setTitle: _NS("Control playback with media keys")];
[_intf_appleremote_sysvolCheckbox setTitle: _NS("Control system volume with the Apple Remote")];
[_intf_statusIconCheckbox setTitle: _NS("Display VLC status menu icon")];
[_intf_playbackBehaviourBox setTitle:_NS("Playback behaviour")];
[_intf_enableNotificationsCheckbox setTitle: _NS("Enable notifications on playlist item change")];
......@@ -577,6 +578,7 @@ static inline char * __config_GetLabel(vlc_object_t *p_this, const char *psz_nam
[self setupButton:_intf_continueplaybackPopup forIntList: "macosx-continue-playback"];
[self setupButton:_intf_appleremoteCheckbox forBoolValue: "macosx-appleremote"];
[self setupButton:_intf_appleremote_sysvolCheckbox forBoolValue: "macosx-appleremote-sysvol"];
[self setupButton:_intf_statusIconCheckbox forBoolValue: "macosx-statusicon"];
[self setupButton:_intf_mediakeysCheckbox forBoolValue: "macosx-mediakeys"];
[self setupButton:_video_nativeFullscreenCheckbox forBoolValue: "macosx-nativefullscreenmode"];
......@@ -918,9 +920,9 @@ static inline void save_string_list(intf_thread_t * p_intf, id object, const cha
config_PutInt(p_intf, "metadata-network-access", [_intf_artCheckbox state]);
config_PutInt(p_intf, "macosx-appleremote", [_intf_appleremoteCheckbox state]);
config_PutInt(p_intf, "macosx-appleremote-sysvol", [_intf_appleremote_sysvolCheckbox state]);
config_PutInt(p_intf, "macosx-statusicon", [_intf_statusIconCheckbox state]);
config_PutInt(p_intf, "macosx-mediakeys", [_intf_mediakeysCheckbox state]);
config_PutInt(p_intf, "macosx-interfacestyle", [_intf_style_darkButtonCell state]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment