summaryrefslogtreecommitdiffstats
path: root/src/gui/GraphBox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/GraphBox.cpp')
-rw-r--r--src/gui/GraphBox.cpp91
1 files changed, 46 insertions, 45 deletions
diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp
index 14258a5a..47c567e3 100644
--- a/src/gui/GraphBox.cpp
+++ b/src/gui/GraphBox.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2017 David Robillard <http://drobilla.net/>
+ Copyright 2007-2024 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -29,34 +29,34 @@
#include "WindowFactory.hpp"
#include "ingen_config.h"
-#include "ganv/canvas.h"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "ingen/fmt.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ganv/canvas.h>
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <ingen/fmt.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <gdk/gdk.h>
+#include <glib.h>
#include <glib/gstdio.h>
#include <glibmm/convert.h>
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include <glibmm/propertyproxy.h>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
#include <gtkmm/alignment.h>
#include <gtkmm/box.h>
@@ -92,6 +92,7 @@
# include <webkit/webkit.h>
#endif
+#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdio>
@@ -101,7 +102,6 @@
#include <sstream>
#include <string>
#include <utility>
-#include <vector>
namespace ingen {
@@ -228,7 +228,7 @@ GraphBox::GraphBox(BaseObjectType* cobject,
_menu_view_graph_properties->signal_activate().connect(
sigc::mem_fun(this, &GraphBox::event_show_properties));
- Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
+ const Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
clipboard->signal_owner_change().connect(
sigc::mem_fun(this, &GraphBox::event_clipboard_changed));
@@ -250,8 +250,12 @@ std::shared_ptr<GraphBox>
GraphBox::create(App& app, const std::shared_ptr<const GraphModel>& graph)
{
GraphBox* result = nullptr;
- Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("graph_win");
+ const Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("graph_win");
xml->get_widget_derived("graph_win_vbox", result);
+ if (!result) {
+ return {};
+ }
+
result->init_box(app);
result->set_graph(graph, nullptr);
@@ -379,14 +383,14 @@ GraphBox::set_graph(const std::shared_ptr<const GraphModel>& graph,
_menu_view_control_window->property_sensitive() = false;
- for (const auto& p : graph->ports()) {
- if (_app->can_control(p.get())) {
- _menu_view_control_window->property_sensitive() = true;
- break;
- }
- }
+ _menu_view_control_window->property_sensitive() =
+ std::any_of(graph->ports().begin(),
+ graph->ports().end(),
+ [this](const auto& p) {
+ return _app->can_control(p.get());
+ });
- _menu_parent->property_sensitive() = bool(graph->parent());
+ _menu_parent->property_sensitive() = !!graph->parent();
new_port_connection = graph->signal_new_port().connect(
sigc::mem_fun(this, &GraphBox::graph_port_added));
@@ -422,14 +426,12 @@ GraphBox::graph_port_removed(const std::shared_ptr<const PortModel>& port)
return;
}
- for (const auto& p : _graph->ports()) {
- if (p->is_input() && _app->can_control(p.get())) {
- _menu_view_control_window->property_sensitive() = true;
- return;
- }
- }
-
- _menu_view_control_window->property_sensitive() = false;
+ _menu_view_control_window->property_sensitive() =
+ std::any_of(_graph->ports().begin(),
+ _graph->ports().end(),
+ [this](const auto& p) {
+ return p->is_input() && _app->can_control(p.get());
+ });
}
void
@@ -535,7 +537,7 @@ GraphBox::event_show_engine()
void
GraphBox::event_clipboard_changed(GdkEventOwnerChange* ev)
{
- Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
+ const Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
_menu_paste->set_sensitive(clipboard->wait_is_text_available());
}
@@ -882,10 +884,10 @@ GraphBox::event_refresh_activated()
void
GraphBox::event_fullscreen_toggled()
{
- // FIXME: ugh, use GTK signals to track state and know for sure
- static bool is_fullscreen = false;
-
if (_window) {
+ // FIXME: ugh, use GTK signals to track state and know for sure
+ static bool is_fullscreen = false;
+
if (!is_fullscreen) {
_window->fullscreen();
is_fullscreen = true;
@@ -927,8 +929,7 @@ GraphBox::event_animate_signals_toggled()
_app->interface()->set_property(
URI("ingen:/clients/this"),
_app->uris().ingen_broadcast,
- _app->forge().make(
- static_cast<bool>(_menu_animate_signals->get_active())));
+ _app->forge().make(_menu_animate_signals->get_active()));
}
void