diff options
Diffstat (limited to 'src/gui/GraphTreeWindow.cpp')
-rw-r--r-- | src/gui/GraphTreeWindow.cpp | 87 |
1 files changed, 46 insertions, 41 deletions
diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp index e1ef158f..1d141271 100644 --- a/src/gui/GraphTreeWindow.cpp +++ b/src/gui/GraphTreeWindow.cpp @@ -14,23 +14,25 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include "App.hpp" #include "GraphTreeWindow.hpp" + +#include "App.hpp" #include "Window.hpp" #include "WindowFactory.hpp" -#include "ingen/Atom.hpp" -#include "ingen/Forge.hpp" -#include "ingen/Interface.hpp" -#include "ingen/Log.hpp" -#include "ingen/URIs.hpp" -#include "ingen/client/ClientStore.hpp" -#include "ingen/client/GraphModel.hpp" -#include "raul/Path.hpp" -#include "raul/Symbol.hpp" +#include <ingen/Atom.hpp> +#include <ingen/Forge.hpp> +#include <ingen/Interface.hpp> +#include <ingen/Log.hpp> +#include <ingen/URI.hpp> +#include <ingen/URIs.hpp> +#include <ingen/client/ClientStore.hpp> +#include <ingen/client/GraphModel.hpp> +#include <ingen/client/ObjectModel.hpp> +#include <raul/Path.hpp> +#include <raul/Symbol.hpp> #include <glibmm/propertyproxy.h> -#include <glibmm/signalproxy.h> #include <gtkmm/builder.h> #include <gtkmm/cellrenderer.h> #include <gtkmm/cellrenderertoggle.h> @@ -45,6 +47,7 @@ #include <cassert> #include <cstdint> #include <memory> +#include <string> namespace ingen { @@ -56,8 +59,6 @@ namespace gui { GraphTreeWindow::GraphTreeWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& xml) : Window(cobject) - , _graphs_treeview(nullptr) - , _enable_signal(true) { xml->get_widget_derived("graphs_treeview", _graphs_treeview); @@ -108,8 +109,8 @@ void GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm) { if (!pm->parent()) { - Gtk::TreeModel::iterator iter = _graph_treestore->append(); - Gtk::TreeModel::Row row = *iter; + const auto iter = _graph_treestore->append(); + auto row = *iter; if (pm->path().is_root()) { row[_graph_tree_columns.name_col] = _app->interface()->uri().string(); } else { @@ -119,12 +120,13 @@ GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm) row[_graph_tree_columns.graph_model_col] = pm; _graphs_treeview->expand_row(_graph_treestore->get_path(iter), true); } else { - Gtk::TreeModel::Children children = _graph_treestore->children(); - Gtk::TreeModel::iterator c = find_graph(children, pm->parent()); + const auto& children = _graph_treestore->children(); + auto c = find_graph(children, pm->parent()); if (c != children.end()) { - Gtk::TreeModel::iterator iter = _graph_treestore->append(c->children()); - Gtk::TreeModel::Row row = *iter; + const auto iter = _graph_treestore->append(c->children()); + auto row = *iter; + row[_graph_tree_columns.name_col] = pm->symbol().c_str(); row[_graph_tree_columns.enabled_col] = pm->enabled(); row[_graph_tree_columns.graph_model_col] = pm; @@ -148,7 +150,7 @@ GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm) void GraphTreeWindow::remove_graph(const std::shared_ptr<GraphModel>& pm) { - Gtk::TreeModel::iterator i = find_graph(_graph_treestore->children(), pm); + const auto i = find_graph(_graph_treestore->children(), pm); if (i != _graph_treestore->children().end()) { _graph_treestore->erase(i); } @@ -158,12 +160,14 @@ Gtk::TreeModel::iterator GraphTreeWindow::find_graph(Gtk::TreeModel::Children root, const std::shared_ptr<client::ObjectModel>& graph) { - for (Gtk::TreeModel::iterator c = root.begin(); c != root.end(); ++c) { - std::shared_ptr<GraphModel> pm = (*c)[_graph_tree_columns.graph_model_col]; + for (auto c = root.begin(); c != root.end(); ++c) { + const std::shared_ptr<GraphModel> pm = (*c)[_graph_tree_columns.graph_model_col]; if (graph == pm) { return c; - } else if (!(*c)->children().empty()) { - Gtk::TreeModel::iterator ret = find_graph(c->children(), graph); + } + + if (!(*c)->children().empty()) { + auto ret = find_graph(c->children(), graph); if (ret != c->children().end()) { return ret; } @@ -177,10 +181,12 @@ GraphTreeWindow::find_graph(Gtk::TreeModel::Children root, void GraphTreeWindow::show_graph_menu(GdkEventButton* ev) { - Gtk::TreeModel::iterator active = _graph_tree_selection->get_selected(); + const auto active = _graph_tree_selection->get_selected(); if (active) { - Gtk::TreeModel::Row row = *active; - std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; + auto row = *active; + auto col = _graph_tree_columns.graph_model_col; + + const std::shared_ptr<GraphModel>& pm = row[col]; if (pm) { _app->log().warn("TODO: graph menu from tree window"); } @@ -191,9 +197,10 @@ void GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path, Gtk::TreeView::Column* col) { - Gtk::TreeModel::iterator active = _graph_treestore->get_iter(path); - Gtk::TreeModel::Row row = *active; - std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; + const auto active = _graph_treestore->get_iter(path); + auto row = *active; + + const std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; _app->window_factory()->present_graph(pm); } @@ -201,17 +208,17 @@ GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path, void GraphTreeWindow::event_graph_enabled_toggled(const Glib::ustring& path_str) { - Gtk::TreeModel::Path path(path_str); - Gtk::TreeModel::iterator active = _graph_treestore->get_iter(path); - Gtk::TreeModel::Row row = *active; + const Gtk::TreeModel::Path path{path_str}; + auto active = _graph_treestore->get_iter(path); + auto row = *active; - std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; + const std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; assert(pm); if (_enable_signal) { _app->set_property(pm->uri(), _app->uris().ingen_enabled, - _app->forge().make(static_cast<bool>(!pm->enabled()))); + _app->forge().make(!pm->enabled())); } } @@ -224,9 +231,9 @@ GraphTreeWindow::graph_property_changed( const URIs& uris = _app->uris(); _enable_signal = false; if (key == uris.ingen_enabled && value.type() == uris.forge.Bool) { - Gtk::TreeModel::iterator i = find_graph(_graph_treestore->children(), graph); + const auto i = find_graph(_graph_treestore->children(), graph); if (i != _graph_treestore->children().end()) { - Gtk::TreeModel::Row row = *i; + auto row = *i; row[_graph_tree_columns.enabled_col] = value.get<int32_t>(); } else { _app->log().error("Unable to find graph %1%\n", graph->path()); @@ -240,11 +247,9 @@ GraphTreeWindow::graph_moved(const std::shared_ptr<GraphModel>& graph) { _enable_signal = false; - Gtk::TreeModel::iterator i - = find_graph(_graph_treestore->children(), graph); - + auto i = find_graph(_graph_treestore->children(), graph); if (i != _graph_treestore->children().end()) { - Gtk::TreeModel::Row row = *i; + auto row = *i; row[_graph_tree_columns.name_col] = graph->symbol().c_str(); } else { _app->log().error("Unable to find graph %1%\n", graph->path()); |