Always compile basic scripting support

This commit is contained in:
David Sansome 2011-01-02 18:44:45 +00:00
parent 45caf3b6f4
commit 9da56fd916
5 changed files with 35 additions and 59 deletions

View File

@ -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()

View File

@ -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

View File

@ -43,7 +43,6 @@
#cmakedefine HAVE_LIBLASTFM
#cmakedefine HAVE_LIBMTP
#cmakedefine HAVE_SCRIPTING
#cmakedefine HAVE_SCRIPTING_PYTHON
#endif // CONFIG_H_IN

View File

@ -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 <QCloseEvent>
#include <QDir>
#include <QFileDialog>
@ -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
}

View File

@ -271,10 +271,8 @@ class MainWindow : public QMainWindow, public PlatformInterface {
boost::scoped_ptr<WiimotedevShortcuts> wiimotedev_shortcuts_;
#endif
#ifdef HAVE_SCRIPTING
ScriptManager* scripts_;
boost::scoped_ptr<ScriptDialog> script_dialog_;
#endif
QMenu* playlist_menu_;
QAction* playlist_play_pause_;