From 8abb9ecd4bddcb7659d746b019bc4315590d829c Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 15 Apr 2010 15:23:12 +0000 Subject: [PATCH] Most of the work to use Sparkle on OS X. Updates issue #210. --- CMakeLists.txt | 1 + dist/Info.plist | 38 +++++++++++++++++++++++++++++++ src/CMakeLists.txt | 2 ++ src/mac_startup.h | 1 + src/mac_startup.mm | 16 +++++++++++-- src/mainwindow.cpp | 13 ++++++++++- src/mainwindow.h | 2 ++ src/translations/translations.pot | 3 +++ 8 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 dist/Info.plist diff --git a/CMakeLists.txt b/CMakeLists.txt index 49d906a88..6d0a58f1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ find_path(LASTFM_INCLUDE_DIRS lastfm/ws.h) if (APPLE) find_library(GROWL Growl) + find_library(SPARKLE Sparkle) endif (APPLE) if(${CMAKE_BUILD_TYPE} MATCHES "Release") diff --git a/dist/Info.plist b/dist/Info.plist new file mode 100644 index 000000000..66285e8df --- /dev/null +++ b/dist/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + clementine + CFBundleGetInfoString + Clementine 0.3 beta 2 + CFBundleIconFile + clementine + CFBundleIdentifier + com.davidsansome.clementine + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + 0.3 beta 3 + CFBundleName + + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.3_beta3 + CFBundleSignature + ???? + CFBundleVersion + 123 + CSResourcesFileMapped + + LSRequiresCarbon + + NSHumanReadableCopyright + + SUFeedURL + http://clementine-player.appspot.com/sparkle + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c7124a065..5374af9f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -356,11 +356,13 @@ target_link_libraries(clementine_lib if (APPLE) target_link_libraries(clementine_lib ${GROWL} + ${SPARKLE} /System/Library/Frameworks/Carbon.framework /System/Library/Frameworks/Foundation.framework /System/Library/Frameworks/AppKit.framework ) include_directories(${GROWL}/Headers) + include_directories(${SPARKLE}/Headers) else (APPLE) target_link_libraries(clementine_lib qxt) endif (APPLE) diff --git a/src/mac_startup.h b/src/mac_startup.h index 3f8b6eebc..69aae7a04 100644 --- a/src/mac_startup.h +++ b/src/mac_startup.h @@ -9,6 +9,7 @@ namespace mac { void MacMain(); void SetShortcutHandler(GlobalShortcuts* handler); void SetApplicationHandler(QObject* handler); +void CheckForUpdates(); } // namespace mac diff --git a/src/mac_startup.mm b/src/mac_startup.mm index 4b8109c9d..432cc276a 100644 --- a/src/mac_startup.mm +++ b/src/mac_startup.mm @@ -1,18 +1,24 @@ #import -#import #import +#import +#import +#import +#import +#import + #include "globalshortcuts/globalshortcuts.h" #include "mac_startup.h" #include #include #include +#import // Capture global media keys on Mac (Cocoa only!) // See: http://www.rogueamoeba.com/utm/2007/09/29/apple-keyboard-media-key-event-handling/ -@interface MacApplication :NSApplication { +@interface MacApplication :NSApplication { // { //, SUUpdaterDelegateInformalProtocol> { GlobalShortcuts* shortcut_handler_; QObject* application_handler_; } @@ -107,6 +113,8 @@ namespace mac { void MacMain() { // Creates and sets the magic global variable so QApplication will find it. [MacApplication sharedApplication]; + // Creates and sets the magic global variable for Sparkle. + [[SUUpdater sharedUpdater] setDelegate: NSApp]; } void SetShortcutHandler(GlobalShortcuts* handler) { @@ -117,4 +125,8 @@ void SetApplicationHandler(QObject* handler) { [NSApp SetApplicationHandler: handler]; } +void CheckForUpdates() { + [[SUUpdater sharedUpdater] checkForUpdates: NSApp]; +} + } // namespace mac diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 960fdf12a..e0e0e6747 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -41,6 +41,7 @@ #include "engines/gstengine.h" #include "equalizer.h" #include "commandlineoptions.h" +#include "mac_startup.h" #include "globalshortcuts/globalshortcuts.h" @@ -343,8 +344,12 @@ MainWindow::MainWindow(QNetworkAccessManager* network, Engine::Type engine, QWid tray_menu->addSeparator(); tray_menu->addAction(ui_.action_quit); - // We use the dock instead of the system tray on mac. #ifdef Q_OS_DARWIN + // Add check for updates item to application menu. + QAction* check_updates = ui_.menuSettings->addAction(tr("Check for updates...")); + check_updates->setMenuRole(QAction::ApplicationSpecificRole); + connect(check_updates, SIGNAL(triggered(bool)), SLOT(CheckForUpdates())); + // We use the dock instead of the system tray on mac. qt_mac_set_dock_menu(tray_menu); #else tray_icon_->setContextMenu(tray_menu); @@ -999,3 +1004,9 @@ bool MainWindow::event(QEvent* event) { } return QMainWindow::event(event); } + +void MainWindow::CheckForUpdates() { +#ifdef Q_OS_DARWIN + mac::CheckForUpdates(); +#endif +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 74795d54d..9911304e4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -127,6 +127,8 @@ class MainWindow : public QMainWindow { void CommandlineOptionsReceived(const QByteArray& serialized_options); + void CheckForUpdates(); + private: void SaveGeometry(); diff --git a/src/translations/translations.pot b/src/translations/translations.pot index 5b43c82fd..89b342f66 100644 --- a/src/translations/translations.pot +++ b/src/translations/translations.pot @@ -17,6 +17,9 @@ msgstr "" msgid "Stop after this track" msgstr "" +msgid "Check for updates..." +msgstr "" + msgid "Pause" msgstr ""