From a96166710faf2447ed10194d1829db5564b0dff9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 4 May 2007 03:59:38 +0000 Subject: Made engine, serialisation, client library, and GUI all dynamically loaded modules. Combined all executables into a single "ingen" program which can do everything. git-svn-id: http://svn.drobilla.net/lad/ingen@493 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/gui/NewSubpatchWindow.cpp | 111 +++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/libs/gui/NewSubpatchWindow.cpp (limited to 'src/libs/gui/NewSubpatchWindow.cpp') diff --git a/src/libs/gui/NewSubpatchWindow.cpp b/src/libs/gui/NewSubpatchWindow.cpp new file mode 100644 index 00000000..f0bc7caa --- /dev/null +++ b/src/libs/gui/NewSubpatchWindow.cpp @@ -0,0 +1,111 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "App.h" +#include "interface/EngineInterface.h" +#include "client/NodeModel.h" +#include "client/PatchModel.h" +#include "NewSubpatchWindow.h" +#include "PatchView.h" + +namespace Ingen { +namespace GUI { + + +NewSubpatchWindow::NewSubpatchWindow(BaseObjectType* cobject, const Glib::RefPtr& xml) +: Gtk::Window(cobject) +{ + xml->get_widget("new_subpatch_name_entry", _name_entry); + xml->get_widget("new_subpatch_message_label", _message_label); + xml->get_widget("new_subpatch_polyphony_spinbutton", _poly_spinbutton); + xml->get_widget("new_subpatch_ok_button", _ok_button); + xml->get_widget("new_subpatch_cancel_button", _cancel_button); + + _name_entry->signal_changed().connect(sigc::mem_fun(this, &NewSubpatchWindow::name_changed)); + _ok_button->signal_clicked().connect(sigc::mem_fun(this, &NewSubpatchWindow::ok_clicked)); + _cancel_button->signal_clicked().connect(sigc::mem_fun(this, &NewSubpatchWindow::cancel_clicked)); + + _ok_button->property_sensitive() = false; +} + +void +NewSubpatchWindow::present(SharedPtr patch, MetadataMap data) +{ + set_patch(patch); + _initial_data = data; + Gtk::Window::present(); +} + +/** Sets the patch controller for this window and initializes everything. + * + * This function MUST be called before using the window in any way! + */ +void +NewSubpatchWindow::set_patch(SharedPtr patch) +{ + _patch = patch; +} + + +/** Called every time the user types into the name input box. + * Used to display warning messages, and enable/disable the OK button. + */ +void +NewSubpatchWindow::name_changed() +{ + string name = _name_entry->get_text(); + if (!Path::is_valid_name(name)) { + _message_label->set_text("Name contains invalid characters."); + _ok_button->property_sensitive() = false; + } else if (_patch->get_node(name)) { + _message_label->set_text("An object already exists with that name."); + _ok_button->property_sensitive() = false; + } else if (name.length() == 0) { + _message_label->set_text(""); + _ok_button->property_sensitive() = false; + } else { + _message_label->set_text(""); + _ok_button->property_sensitive() = true; + } +} + + +void +NewSubpatchWindow::ok_clicked() +{ + const Path path = _patch->path().base() + Path::nameify(_name_entry->get_text()); + const size_t poly = _poly_spinbutton->get_value_as_int(); + + App::instance().engine()->create_patch(path, poly); + for (MetadataMap::const_iterator i = _initial_data.begin(); i != _initial_data.end(); ++i) + App::instance().engine()->set_metadata(path, i->first, i->second); + + App::instance().engine()->enable_patch(path); + + hide(); +} + + +void +NewSubpatchWindow::cancel_clicked() +{ + hide(); +} + + +} // namespace GUI +} // namespace Ingen -- cgit v1.2.1