Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ add_library(glight-object OBJECT
${THEATREFILES} ${SYSTEMFILES} ${GUIFILES} ${EXTERNALFILES})

add_executable(glight $<TARGET_OBJECTS:glight-object> glight.cpp)
add_executable(glight-cli $<TARGET_OBJECTS:glight-object> glight-cli.cpp)

target_link_directories(glight PRIVATE ${GTKMM_LIBDIR} ${LIBOLA_LIBDIR})
target_link_directories(glight-cli PRIVATE ${GTKMM_LIBDIR} ${LIBOLA_LIBDIR})

set(GLIGHT_LIBRARIES
${FLACPP_LIBRARIES}
Expand All @@ -192,6 +194,7 @@ set(GLIGHT_LIBRARIES
${CMAKE_THREAD_LIBS_INIT})

target_link_libraries(glight ${GLIGHT_LIBRARIES})
target_link_libraries(glight-cli ${GLIGHT_LIBRARIES})

if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30")
cmake_policy(SET CMP0167 NEW)
Expand Down Expand Up @@ -265,5 +268,5 @@ set(CPACK_DEBIAN_PACKAGE_SECTION misc)

include(CPack)

install(TARGETS glight RUNTIME DESTINATION bin)
install(TARGETS glight glight-cli RUNTIME DESTINATION bin)
install(DIRECTORY data/icons data/applications DESTINATION share )
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Glight is specifically aimed at shows or events in which the lighting is control
## Installation
The source of Glight can be downloaded from Github, currently from https://github.com/aroffringa/glight/. Glight has a few dependencies. Fortunately, these are all available as precompiled packages in Debian, Ubuntu and most other distributions. Apart from system tools such as cmake, these are the important dependencies:

- [Gtkmm](https://www.gtkmm.org/), the C++ interface to GTK+. `libgtkmm-3.0-dev` on Debian and Ubuntu.
- [Gtkmm](https://www.gtkmm.org/), the C++ interface to GTK+. `libgtkmm-4.0-dev` on Debian and Ubuntu.
- [Aubio](https://aubio.org/). `libaubio-dev` on Debian and Ubuntu.
- [Flac++](https://xiph.org/flac/). `libflac++-dev` on Debian and Ubuntu.
- [Alsa library](https://www.alsa-project.org/). `libasound2-dev` on Debian and Ubuntu.
Expand Down
35 changes: 35 additions & 0 deletions glight-cli.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
#include <string>

#include "system/reader.h"
#include "system/settings.h"
#include "theatre/management.h"

namespace glight {

void RunCli(const std::string filename) {
const glight::system::Settings settings = glight::system::LoadSettings();
glight::theatre::Management management(settings);
glight::system::Read(filename, management);
management.GetUniverses().Open();
management.Run();
std::cout << "Press enter to exit.\n";
std::cin.get();
management.BlackOut(false, 0.0f);
std::cout << "Stopping...\n";
// There is some time required for the black out to take effect.
usleep(400000);
}

} // namespace glight

int main(int argc, char* argv[]) {
if (argc <= 1) {
std::cout << "Syntax: glight-cli <show-file>\n\n"
"glight-cli can output a previously created gshow file "
"without requiring a graphical desktop.\n";
return 0;
}

glight::RunCli(argv[1]);
}
3 changes: 3 additions & 0 deletions glight.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#include <cstdlib>
#include <iostream>

#include <glibmm/init.h>

#include "gui/application.h"

#include "system/writer.h"

int main(int argc, char *argv[]) {
Glib::set_init_to_users_preferred_locale(false);
glight::gui::Application application;
application.Run(argc, argv);

Expand Down
3 changes: 3 additions & 0 deletions gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace glight::gui {

Application::Application()
: Gtk::Application("org.glight", Gio::Application::Flags::HANDLES_OPEN) {}

void Application::Run(int argc, char *argv[]) {
MainWindow window;
if (argc > 1) {
Expand Down
3 changes: 1 addition & 2 deletions gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ namespace glight::gui {

class Application : public Gtk::Application {
public:
Application()
: Gtk::Application("org.glight", Gio::Application::Flags::HANDLES_OPEN) {}
Application();
void Run(int argc, char *argv[]);
};

Expand Down
2 changes: 1 addition & 1 deletion gui/components/colorsequencewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ ColorSequenceWidget::ColorSequenceWidget(Gtk::Window *parent,

_widgets.emplace_back(std::make_unique<ColorSelectWidget>(_parent, true));
_box.append(*_widgets.back());
_widgets.back()->set_hexpand(true);
_widgets.back()->SignalColorChanged().connect([&]() { OnColorChange(0); });
_widgets.back()->show();

_scrolledWindow.set_expand(true);
_scrolledWindow.set_child(_box);
Expand Down
1 change: 1 addition & 0 deletions gui/windows/addfixturewindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ AddFixtureWindow::AddFixtureWindow() {
grid_.set_column_spacing(2);

stock_or_project_box_.append(stock_button_);
stock_button_.set_active(true);
stock_button_.set_hexpand(true);
stock_button_.signal_toggled().connect([&]() { onStockProjectToggled(); });

Expand Down
12 changes: 9 additions & 3 deletions gui/windows/effectpropertieswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ EffectPropertiesWindow::EffectPropertiesWindow(theatre::Effect& effect)
_addConnectionButton.set_image_from_icon_name("list-add");
_addConnectionButton.signal_clicked().connect(
sigc::mem_fun(*this, &EffectPropertiesWindow::onAddConnectionClicked));
_connectionsButtonBox.set_homogeneous(true);
_connectionsButtonBox.set_orientation(Gtk::Orientation::VERTICAL);
_connectionsButtonBox.append(_addConnectionButton);

Expand Down Expand Up @@ -58,12 +57,15 @@ EffectPropertiesWindow::EffectPropertiesWindow(theatre::Effect& effect)

_connectionsScrolledWindow.set_policy(Gtk::PolicyType::NEVER,
Gtk::PolicyType::AUTOMATIC);
_connectionsScrolledWindow.set_expand(true);
_connectionsBox.append(_connectionsScrolledWindow);
_connectionsBox.set_expand(true);
_connectionsFrame.set_child(_connectionsBox);
_connectionsFrame.set_expand(true);
_mainHBox.append(_connectionsFrame);

_propertiesFrame.set_child(_propertiesBox);

_propertiesFrame.set_expand(true);
_mainHBox.append(_propertiesFrame);

_topBox.append(_mainHBox);
Expand Down Expand Up @@ -107,10 +109,12 @@ void EffectPropertiesWindow::onAddConnectionClicked() {
InputSelectDialog& dialog = static_cast<InputSelectDialog&>(*dialog_);
onInputsSelected({dialog.SelectedSourceValue()});
const bool stay_open = dialog.StayOpenRequested();
if (!stay_open) dialog_.reset();
} else {
dialog_.reset();
if (stay_open) onAddConnectionClicked();
}
});
dialog_->show();
}

void EffectPropertiesWindow::onConnectControllableClicked() {
Expand All @@ -133,7 +137,9 @@ void EffectPropertiesWindow::onConnectControllableClicked() {
}
onInputsSelected(sources);
}
dialog_.reset();
});
dialog_->show();
}

void EffectPropertiesWindow::onRemoveConnectionClicked() {
Expand Down
9 changes: 5 additions & 4 deletions gui/windows/fixturelistwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ void FixtureListWindow::onSetChannelButtonClicked() {
GetSelection();
if (selection.size() == 1) {
const system::ObservingPtr<theatre::Fixture> &fixture = selection[0];
dialog_ = Gtk::MessageDialog(*this, "Set DMX channel", false,
Gtk::MessageType::QUESTION,
Gtk::ButtonsType::OK_CANCEL);
Gtk::MessageDialog &dialog = static_cast<Gtk::MessageDialog &>(dialog_);
dialog_ = std::make_unique<Gtk::MessageDialog>(
*this, "Set DMX channel", false, Gtk::MessageType::QUESTION,
Gtk::ButtonsType::OK_CANCEL);
Gtk::MessageDialog &dialog = static_cast<Gtk::MessageDialog &>(*dialog_);
dialog_entry_ = Gtk::Entry();
dialog_entry_.set_text(std::to_string(
fixture->Functions().front()->MainChannel().Channel() + 1));
Expand All @@ -206,6 +206,7 @@ void FixtureListWindow::onSetChannelButtonClicked() {
}
}
}
dialog_.reset();
});
dialog.show();
}
Expand Down
2 changes: 1 addition & 1 deletion gui/windows/fixturelistwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class FixtureListWindow : public ChildWindow {
Gtk::Button up_button_;
Gtk::Button down_button_;
Gtk::Button reassign_button_{"Reassign"};
Gtk::Dialog dialog_;
std::unique_ptr<Gtk::Dialog> dialog_;
Gtk::Entry dialog_entry_;
};

Expand Down
12 changes: 11 additions & 1 deletion system/jsonreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,17 @@ std::unique_ptr<Node> ParseObject(std::istream& stream) {
throw std::runtime_error("Extra trailing comma in object");
}
} else {
throw std::runtime_error("Expecting name or '}' in object");
std::string str(0, t);
if (t == 0) str = "null";
std::string follows;
std::string line;
std::getline(stream, follows);
std::getline(stream, line);
follows += "\n" + line;
std::getline(stream, line);
follows += "\n" + line;
throw std::runtime_error("Expecting name or '}' in object, got '" + str +
"', before:\n" + follows);
}
}
return result;
Expand Down
5 changes: 4 additions & 1 deletion tests/system/tjsonwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ BOOST_AUTO_TEST_CASE(number) {
writer.Number(5);
writer.Name("day");
writer.Number(8.3);
writer.Name("thousand");
writer.Number(1000.0);
writer.EndObject();
BOOST_CHECK_EQUAL(s.str(), R"("date": {
"year": 1982,
"month": 5,
"day": 8.3
"day": 8.3,
"thousand": 1000
})");
}

Expand Down