From 9da56fd916b26a1e05e1a7ae37f945c1ecc3ed98 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sun, 2 Jan 2011 18:44:45 +0000 Subject: [PATCH] Always compile basic scripting support --- CMakeLists.txt | 10 ++------ src/CMakeLists.txt | 60 +++++++++++++++++++------------------------ src/config.h.in | 1 - src/ui/mainwindow.cpp | 21 +++++---------- src/ui/mainwindow.h | 2 -- 5 files changed, 35 insertions(+), 59 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d08810de5..54370a42e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,6 @@ option(ENABLE_VISUALISATIONS "Use libprojectm visualisations" ON) option(BUNDLE_PROJECTM_PRESETS "Install Clementine's own copies of libprojectm presets - disable this if you want to use a system package instead" ON) option(ENABLE_SOUNDMENU "Add Clementine to the Gnome sound menu" ON) option(ENABLE_LIBLASTFM "Use liblastfm for fetching song info, scrobbling and radio streams" ON) -option(ENABLE_SCRIPTING "Enable scripting support" ON) option(ENABLE_SCRIPTING_PYTHON "Enable python scripting" ON) if(ENABLE_LIBGPOD AND LIBGPOD_FOUND) @@ -167,13 +166,9 @@ if(ENABLE_LIBLASTFM AND LASTFM_LIBRARIES AND LASTFM_INCLUDE_DIRS) set(HAVE_LIBLASTFM ON) endif(ENABLE_LIBLASTFM AND LASTFM_LIBRARIES AND LASTFM_INCLUDE_DIRS) -if(ENABLE_SCRIPTING) - set(HAVE_SCRIPTING ON) -endif(ENABLE_SCRIPTING) - -if(ENABLE_SCRIPTING_PYTHON AND ENABLE_SCRIPTING AND PYTHONLIBS_FOUND AND PYQT_SIP_DIR) +if(ENABLE_SCRIPTING_PYTHON AND PYTHONLIBS_FOUND AND PYQT_SIP_DIR) set(HAVE_SCRIPTING_PYTHON ON) -endif(ENABLE_SCRIPTING_PYTHON AND ENABLE_SCRIPTING AND PYTHONLIBS_FOUND AND PYQT_SIP_DIR) +endif(ENABLE_SCRIPTING_PYTHON AND PYTHONLIBS_FOUND AND PYQT_SIP_DIR) if(ENABLE_VISUALISATIONS) # When/if upstream accepts our patches then these options can be used to link @@ -290,7 +285,6 @@ summary_add("Gnome sound menu integration" HAVE_LIBINDICATE) summary_add("Wiimote support" ENABLE_WIIMOTEDEV) summary_add("Visualisations" ENABLE_VISUALISATIONS) summary_add("Last.fm support" HAVE_LIBLASTFM) -summary_add("Scripting support" HAVE_SCRIPTING) summary_add("Scripting support: Python" HAVE_SCRIPTING_PYTHON) summary_add("(Mac OS X) Sparkle integration" HAVE_SPARKLE) summary_show() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index af090560d..dccd76976 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -155,6 +155,14 @@ set(SOURCES remote/httpconnection.cpp remote/zeroconf.cpp + scripting/languageengine.cpp + scripting/script.cpp + scripting/scriptdialog.cpp + scripting/scriptdialogtabwidget.cpp + scripting/scriptinterface.cpp + scripting/scriptmanager.cpp + scripting/uiinterface.cpp + smartplaylists/generator.cpp smartplaylists/generatorinserter.cpp smartplaylists/querygenerator.cpp @@ -325,6 +333,12 @@ set(HEADERS remote/httpserver.h remote/httpconnection.h + scripting/scriptdialog.h + scripting/scriptdialogtabwidget.h + scripting/scriptinterface.h + scripting/scriptmanager.h + scripting/uiinterface.h + smartplaylists/generator.h smartplaylists/generatorinserter.h smartplaylists/generatormimedata.h @@ -411,6 +425,8 @@ set(UI radio/magnatunedownloaddialog.ui radio/radioviewcontainer.ui + scripting/scriptdialog.ui + smartplaylists/querysearchpage.ui smartplaylists/querysortpage.ui smartplaylists/searchpreview.ui @@ -688,42 +704,20 @@ if(APPLE) list(APPEND SOURCES core/mac_startup.mm) endif(APPLE) -if(HAVE_SCRIPTING) +if(HAVE_SCRIPTING_PYTHON) list(APPEND SOURCES - scripting/languageengine.cpp - scripting/script.cpp - scripting/scriptdialog.cpp - scripting/scriptdialogtabwidget.cpp - scripting/scriptinterface.cpp - scripting/scriptmanager.cpp - scripting/uiinterface.cpp - ) - list(APPEND HEADERS - scripting/scriptdialog.h - scripting/scriptdialogtabwidget.h - scripting/scriptinterface.h - scripting/scriptmanager.h - scripting/uiinterface.h - ) - list(APPEND UI - scripting/scriptdialog.ui + scripting/python/pythonengine.cpp + scripting/python/pythonscript.cpp ) - if(HAVE_SCRIPTING_PYTHON) - list(APPEND SOURCES - scripting/python/pythonengine.cpp - scripting/python/pythonscript.cpp - ) - - add_sip_binding(SOURCES - scripting/python/clementine.sip - ${CMAKE_CURRENT_BINARY_DIR}/sipclementinePlaylistItemOptions.cpp - ${CMAKE_CURRENT_BINARY_DIR}/sipclementinePlaylistItemPtr.cpp - ${CMAKE_CURRENT_BINARY_DIR}/sipclementineQList0100PlaylistItemPtr.cpp - ${CMAKE_CURRENT_BINARY_DIR}/sipclementineQList0100Song.cpp - ) - endif(HAVE_SCRIPTING_PYTHON) -endif(HAVE_SCRIPTING) + add_sip_binding(SOURCES + scripting/python/clementine.sip + ${CMAKE_CURRENT_BINARY_DIR}/sipclementinePlaylistItemOptions.cpp + ${CMAKE_CURRENT_BINARY_DIR}/sipclementinePlaylistItemPtr.cpp + ${CMAKE_CURRENT_BINARY_DIR}/sipclementineQList0100PlaylistItemPtr.cpp + ${CMAKE_CURRENT_BINARY_DIR}/sipclementineQList0100Song.cpp + ) +endif(HAVE_SCRIPTING_PYTHON) # OS-specific sources that should be searched for translatable strings even # if they're not compiled diff --git a/src/config.h.in b/src/config.h.in index 3710d52cf..0e27ef464 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -43,7 +43,6 @@ #cmakedefine HAVE_LIBLASTFM #cmakedefine HAVE_LIBMTP -#cmakedefine HAVE_SCRIPTING #cmakedefine HAVE_SCRIPTING_PYTHON #endif // CONFIG_H_IN diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index a254e4445..265653414 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -58,6 +58,9 @@ #include "radio/radioview.h" #include "radio/radioviewcontainer.h" #include "radio/savedradio.h" +#include "scripting/scriptdialog.h" +#include "scripting/scriptmanager.h" +#include "scripting/uiinterface.h" #include "smartplaylists/generator.h" #include "songinfo/artistinfoview.h" #include "songinfo/songinfoview.h" @@ -96,12 +99,6 @@ # include "visualisations/visualisationcontainer.h" #endif -#ifdef HAVE_SCRIPTING -# include "scripting/scriptdialog.h" -# include "scripting/scriptmanager.h" -# include "scripting/uiinterface.h" -#endif - #include #include #include @@ -173,9 +170,7 @@ MainWindow::MainWindow(QWidget* parent) #ifdef ENABLE_WIIMOTEDEV wiimotedev_shortcuts_(NULL), #endif -#ifdef HAVE_SCRIPTING scripts_(new ScriptManager(this)), -#endif playlist_menu_(new QMenu(this)), library_sort_model_(new QSortFilterProxyModel(this)), track_position_timer_(new QTimer(this)), @@ -584,6 +579,9 @@ MainWindow::MainWindow(QWidget* parent) connect(ui_->action_kittens, SIGNAL(toggled(bool)), ui_->now_playing, SLOT(EnableKittens(bool))); NowPlayingWidgetPositionChanged(ui_->now_playing->show_above_status_bar()); + // Add places where scripts can make actions + scripts_->ui()->RegisterActionLocation("help_menu", ui_->menu_help, NULL); + // Load theme StyleSheetLoader* css_loader = new StyleSheetLoader(this); css_loader->SetStyleSheet(this, ":mainwindow.css"); @@ -640,13 +638,8 @@ MainWindow::MainWindow(QWidget* parent) wiimotedev_shortcuts_.reset(new WiimotedevShortcuts(osd_, this, player_)); #endif -#ifdef HAVE_SCRIPTING - scripts_->ui()->RegisterActionLocation("help_menu", ui_->menu_help, NULL); scripts_->Init(ScriptManager::GlobalData(player_, playlists_)); connect(ui_->action_script_manager, SIGNAL(triggered()), SLOT(ShowScriptDialog())); -#else - ui_->action_script_manager->setEnabled(false); -#endif } MainWindow::~MainWindow() { @@ -1808,11 +1801,9 @@ void MainWindow::PlaylistCurrentChanged(const QModelIndex& proxy_current) { } void MainWindow::ShowScriptDialog() { -#ifdef HAVE_SCRIPTING if (!script_dialog_) { script_dialog_.reset(new ScriptDialog); script_dialog_->SetManager(scripts_); } script_dialog_->show(); -#endif } diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 961016daa..92e796e50 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -271,10 +271,8 @@ class MainWindow : public QMainWindow, public PlatformInterface { boost::scoped_ptr wiimotedev_shortcuts_; #endif -#ifdef HAVE_SCRIPTING ScriptManager* scripts_; boost::scoped_ptr script_dialog_; -#endif QMenu* playlist_menu_; QAction* playlist_play_pause_;