From 55c6e4c46d388189e35329a6519b9afa86f029fa Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 15 Jun 2006 08:22:48 +0000 Subject: Switched patch "description" window into a properties window (hopefully to extend in the future) git-svn-id: http://svn.drobilla.net/lad/grauph@40 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/gtk/Makefile.am | 4 +- src/progs/gtk/NodeController.h | 2 +- src/progs/gtk/NodePropertiesWindow.cpp | 8 ++-- src/progs/gtk/PatchController.cpp | 34 +++++++++------ src/progs/gtk/PatchController.h | 6 ++- src/progs/gtk/PatchDescriptionWindow.cpp | 73 -------------------------------- src/progs/gtk/PatchDescriptionWindow.h | 60 -------------------------- src/progs/gtk/PatchPropertiesWindow.cpp | 73 ++++++++++++++++++++++++++++++++ src/progs/gtk/PatchPropertiesWindow.h | 60 ++++++++++++++++++++++++++ src/progs/gtk/PatchView.cpp | 2 +- src/progs/gtk/PatchWindow.cpp | 27 ++++++------ src/progs/gtk/PatchWindow.h | 7 ++- src/progs/gtk/om_gtk.glade | 14 +++--- src/progs/gtk/om_gtk.glade.bak | 2 +- 14 files changed, 192 insertions(+), 180 deletions(-) delete mode 100644 src/progs/gtk/PatchDescriptionWindow.cpp delete mode 100644 src/progs/gtk/PatchDescriptionWindow.h create mode 100644 src/progs/gtk/PatchPropertiesWindow.cpp create mode 100644 src/progs/gtk/PatchPropertiesWindow.h (limited to 'src') diff --git a/src/progs/gtk/Makefile.am b/src/progs/gtk/Makefile.am index 16c99949..3bf779a8 100644 --- a/src/progs/gtk/Makefile.am +++ b/src/progs/gtk/Makefile.am @@ -72,8 +72,8 @@ om_gtk_SOURCES = \ NewSubpatchWindow.cpp \ ConfigWindow.h \ ConfigWindow.cpp \ - PatchDescriptionWindow.h \ - PatchDescriptionWindow.cpp \ + PatchPropertiesWindow.h \ + PatchPropertiesWindow.cpp \ Loader.h \ Loader.cpp \ RenameWindow.h \ diff --git a/src/progs/gtk/NodeController.h b/src/progs/gtk/NodeController.h index 54c103b5..3168bc7b 100644 --- a/src/progs/gtk/NodeController.h +++ b/src/progs/gtk/NodeController.h @@ -77,8 +77,8 @@ public: void control_window(NodeControlWindow* cw) { m_control_window = cw; } virtual void show_control_window(); + virtual void show_properties_window(); void show_rename_window(); - void show_properties_window(); bool has_control_inputs(); diff --git a/src/progs/gtk/NodePropertiesWindow.cpp b/src/progs/gtk/NodePropertiesWindow.cpp index b0028864..abf5625c 100644 --- a/src/progs/gtk/NodePropertiesWindow.cpp +++ b/src/progs/gtk/NodePropertiesWindow.cpp @@ -53,9 +53,11 @@ NodePropertiesWindow::set_node(CountedPtr node_model) CountedPtr pm = node_model->plugin(); - m_plugin_type_label->set_text(pm->type_string()); - m_plugin_uri_label->set_text(pm->uri()); - m_plugin_name_label->set_text(pm->name()); + if (pm) { + m_plugin_type_label->set_text(pm->type_string()); + m_plugin_uri_label->set_text(pm->uri()); + m_plugin_name_label->set_text(pm->name()); + } } diff --git a/src/progs/gtk/PatchController.cpp b/src/progs/gtk/PatchController.cpp index 8246efa6..20dcc096 100644 --- a/src/progs/gtk/PatchController.cpp +++ b/src/progs/gtk/PatchController.cpp @@ -40,6 +40,7 @@ #include "PortController.h" #include "App.h" #include "PatchTreeWindow.h" +#include "PatchPropertiesWindow.h" #include "DSSIController.h" #include "PatchModel.h" #include "Store.h" @@ -53,6 +54,7 @@ namespace OmGtk { PatchController::PatchController(CountedPtr model) : NodeController(model), + m_properties_window(NULL), m_window(NULL), m_patch_view(NULL), m_patch_model(model), @@ -349,6 +351,20 @@ PatchController::create_view() } +void +PatchController::show_properties_window() +{ + if (!m_properties_window) { + Glib::RefPtr glade_xml = GladeFactory::new_glade_reference(); + glade_xml->get_widget_derived("patch_properties_win", m_properties_window); + m_properties_window->patch_model(patch_model()); + } + + m_properties_window->show(); + +} + + /** Create a connection in the view (canvas). */ void @@ -387,11 +403,14 @@ PatchController::create_connection(CountedPtr cm) } +/** Add a child node to this patch. + * + * This is for plugin nodes and patches, and is responsible for creating the + * GtkObjectController for @a object (and through that the View if necessary) + */ void PatchController::add_node(CountedPtr object) { - cerr << "ADD NODE\n"; - assert(object); assert(object->parent() == m_patch_model); assert(object->path().parent() == m_patch_model->path()); @@ -405,19 +424,15 @@ PatchController::add_node(CountedPtr object) CountedPtr node(object); if (node) { - cerr << "\tNode Child\n"; assert(node->parent() == m_patch_model); NodeController* nc = NULL; CountedPtr patch(node); if (patch) { - cerr << "\t.. is a Patch Child\n"; assert(patch->parent() == m_patch_model); - nc = new PatchController(patch); } else { - cerr << "\t... is a Plugin Node Child\n"; assert(node->plugin()); if (node->plugin()->type() == PluginModel::DSSI) nc = new DSSIController(node); @@ -465,13 +480,6 @@ PatchController::add_node(CountedPtr object) } } - - - /*CountedPtr port(object); - if (port) { - cerr << "\tPort Child??\n"; - //assert(port->parent() == m_patch_model); - }*/ } diff --git a/src/progs/gtk/PatchController.h b/src/progs/gtk/PatchController.h index 236fd0b6..eff525c8 100644 --- a/src/progs/gtk/PatchController.h +++ b/src/progs/gtk/PatchController.h @@ -41,6 +41,7 @@ class SubpatchModule; class Controller; class OmFlowCanvas; class NodeControlWindow; +class PatchPropertiesWindow; class ControlPanel; class PatchView; class NodeController; @@ -81,6 +82,7 @@ public: void get_new_module_location(int& x, int& y); void show_control_window(); + void show_properties_window(); void show_patch_window(); void claim_patch_view(); @@ -111,7 +113,9 @@ private: void create_connection(CountedPtr cm); - PatchWindow* m_window; ///< Window currently showing this patch + PatchPropertiesWindow* m_properties_window; + + PatchWindow* m_window; ///< Patch Window currently showing m_patch_view PatchView* m_patch_view; ///< View (canvas) of this patch CountedPtr m_patch_model; diff --git a/src/progs/gtk/PatchDescriptionWindow.cpp b/src/progs/gtk/PatchDescriptionWindow.cpp deleted file mode 100644 index 7ae154c3..00000000 --- a/src/progs/gtk/PatchDescriptionWindow.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* This file is part of Om. Copyright (C) 2006 Dave Robillard. - * - * Om 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. - * - * Om 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., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "PatchDescriptionWindow.h" -#include -#include "PatchModel.h" - -namespace OmGtk { -using std::string; - - -PatchDescriptionWindow::PatchDescriptionWindow(BaseObjectType* cobject, const Glib::RefPtr& glade_xml) -: Gtk::Window(cobject) -, m_patch_model(NULL) -{ - glade_xml->get_widget("description_author_entry", m_author_entry); - glade_xml->get_widget("description_description_textview", m_textview); - glade_xml->get_widget("description_cancel_button", m_cancel_button); - glade_xml->get_widget("description_ok_button", m_ok_button); - - m_cancel_button->signal_clicked().connect(sigc::mem_fun(this, &PatchDescriptionWindow::cancel_clicked)); - m_ok_button->signal_clicked().connect(sigc::mem_fun(this, &PatchDescriptionWindow::ok_clicked)); -} - - -/** Set the patch model this description is for. - * - * This function is a "post-constructor" - it MUST be called before using - * the window in any way. - */ -void -PatchDescriptionWindow::patch_model(CountedPtr patch_model) -{ - property_title() = patch_model->path() + " Properties"; - m_patch_model = patch_model; - m_author_entry->set_text(m_patch_model->get_metadata("author")); - m_textview->get_buffer()->set_text(m_patch_model->get_metadata("description")); -} - - -void -PatchDescriptionWindow::cancel_clicked() -{ - m_author_entry->set_text(m_patch_model->get_metadata("author")); - m_textview->get_buffer()->set_text(m_patch_model->get_metadata("description")); - hide(); -} - - -void -PatchDescriptionWindow::ok_clicked() -{ - m_patch_model->set_metadata("author", m_author_entry->get_text()); - m_patch_model->set_metadata("description", m_textview->get_buffer()->get_text()); - hide(); -} - - - -} // namespace OmGtk diff --git a/src/progs/gtk/PatchDescriptionWindow.h b/src/progs/gtk/PatchDescriptionWindow.h deleted file mode 100644 index 0ad8b286..00000000 --- a/src/progs/gtk/PatchDescriptionWindow.h +++ /dev/null @@ -1,60 +0,0 @@ -/* This file is part of Om. Copyright (C) 2006 Dave Robillard. - * - * Om 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. - * - * Om 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., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PATCHDESCRIPTIONWINDOW_H -#define PATCHDESCRIPTIONWINDOW_H - -#include -#include -#include -#include "util/CountedPtr.h" -using std::string; - -namespace LibOmClient { class PatchModel; } -using LibOmClient::PatchModel; - -namespace OmGtk { - - -/** Patch Description Window. - * - * Loaded by libglade as a derived object. - * - * \ingroup OmGtk - */ -class PatchDescriptionWindow : public Gtk::Window -{ -public: - PatchDescriptionWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - - void patch_model(CountedPtr patch_model); - - void cancel_clicked(); - void ok_clicked(); - -private: - CountedPtr m_patch_model; - - Gtk::Entry* m_author_entry; - Gtk::TextView* m_textview; - Gtk::Button* m_cancel_button; - Gtk::Button* m_ok_button; -}; - - -} // namespace OmGtk - -#endif // PATCHDESCRIPTIONWINDOW_H diff --git a/src/progs/gtk/PatchPropertiesWindow.cpp b/src/progs/gtk/PatchPropertiesWindow.cpp new file mode 100644 index 00000000..6e17a1f7 --- /dev/null +++ b/src/progs/gtk/PatchPropertiesWindow.cpp @@ -0,0 +1,73 @@ +/* This file is part of Om. Copyright (C) 2006 Dave Robillard. + * + * Om 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. + * + * Om 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., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "PatchPropertiesWindow.h" +#include +#include "PatchModel.h" + +namespace OmGtk { +using std::string; + + +PatchPropertiesWindow::PatchPropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr& glade_xml) +: Gtk::Window(cobject) +, m_patch_model(NULL) +{ + glade_xml->get_widget("properties_author_entry", m_author_entry); + glade_xml->get_widget("properties_description_textview", m_textview); + glade_xml->get_widget("properties_cancel_button", m_cancel_button); + glade_xml->get_widget("properties_ok_button", m_ok_button); + + m_cancel_button->signal_clicked().connect(sigc::mem_fun(this, &PatchPropertiesWindow::cancel_clicked)); + m_ok_button->signal_clicked().connect(sigc::mem_fun(this, &PatchPropertiesWindow::ok_clicked)); +} + + +/** Set the patch model this description is for. + * + * This function is a "post-constructor" - it MUST be called before using + * the window in any way. + */ +void +PatchPropertiesWindow::patch_model(CountedPtr patch_model) +{ + property_title() = patch_model->path() + " Properties"; + m_patch_model = patch_model; + m_author_entry->set_text(m_patch_model->get_metadata("author")); + m_textview->get_buffer()->set_text(m_patch_model->get_metadata("description")); +} + + +void +PatchPropertiesWindow::cancel_clicked() +{ + m_author_entry->set_text(m_patch_model->get_metadata("author")); + m_textview->get_buffer()->set_text(m_patch_model->get_metadata("description")); + hide(); +} + + +void +PatchPropertiesWindow::ok_clicked() +{ + m_patch_model->set_metadata("author", m_author_entry->get_text()); + m_patch_model->set_metadata("description", m_textview->get_buffer()->get_text()); + hide(); +} + + + +} // namespace OmGtk diff --git a/src/progs/gtk/PatchPropertiesWindow.h b/src/progs/gtk/PatchPropertiesWindow.h new file mode 100644 index 00000000..adca6e75 --- /dev/null +++ b/src/progs/gtk/PatchPropertiesWindow.h @@ -0,0 +1,60 @@ +/* This file is part of Om. Copyright (C) 2006 Dave Robillard. + * + * Om 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. + * + * Om 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., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PATCHPROPERTIESWINDOW_H +#define PATCHPROPERTIESWINDOW_H + +#include +#include +#include +#include "util/CountedPtr.h" +using std::string; + +namespace LibOmClient { class PatchModel; } +using LibOmClient::PatchModel; + +namespace OmGtk { + + +/** Patch Properties Window. + * + * Loaded by libglade as a derived object. + * + * \ingroup OmGtk + */ +class PatchPropertiesWindow : public Gtk::Window +{ +public: + PatchPropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + + void patch_model(CountedPtr patch_model); + + void cancel_clicked(); + void ok_clicked(); + +private: + CountedPtr m_patch_model; + + Gtk::Entry* m_author_entry; + Gtk::TextView* m_textview; + Gtk::Button* m_cancel_button; + Gtk::Button* m_ok_button; +}; + + +} // namespace OmGtk + +#endif // PATCHPROPERTIESWINDOW_H diff --git a/src/progs/gtk/PatchView.cpp b/src/progs/gtk/PatchView.cpp index e89428e9..4d421979 100644 --- a/src/progs/gtk/PatchView.cpp +++ b/src/progs/gtk/PatchView.cpp @@ -26,7 +26,7 @@ #include "NewSubpatchWindow.h" #include "LoadSubpatchWindow.h" #include "NodeControlWindow.h" -#include "PatchDescriptionWindow.h" +#include "PatchPropertiesWindow.h" #include "PatchTreeWindow.h" #include "Controller.h" diff --git a/src/progs/gtk/PatchWindow.cpp b/src/progs/gtk/PatchWindow.cpp index 9387257f..8211e653 100644 --- a/src/progs/gtk/PatchWindow.cpp +++ b/src/progs/gtk/PatchWindow.cpp @@ -28,7 +28,7 @@ #include "LoadPatchWindow.h" #include "LoadSubpatchWindow.h" #include "NodeControlWindow.h" -#include "PatchDescriptionWindow.h" +#include "PatchPropertiesWindow.h" #include "ConfigWindow.h" #include "MessagesWindow.h" #include "PatchTreeWindow.h" @@ -79,13 +79,11 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget_derived("new_subpatch_win", m_new_subpatch_window); xml->get_widget_derived("load_patch_win", m_load_patch_window); xml->get_widget_derived("load_subpatch_win", m_load_subpatch_window); - xml->get_widget_derived("patch_description_win", m_description_window); //m_load_plugin_window->set_transient_for(*this); m_new_subpatch_window->set_transient_for(*this); m_load_patch_window->set_transient_for(*this); m_load_subpatch_window->set_transient_for(*this); - m_description_window->set_transient_for(*this); m_menu_view_control_window->property_sensitive() = false; //m_status_bar->push(Controller::instance().engine_url()); @@ -110,9 +108,9 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtrsignal_toggled().connect( sigc::mem_fun(this, &PatchWindow::event_fullscreen_toggled)); m_menu_view_control_window->signal_activate().connect( - sigc::mem_fun(this, &PatchWindow::show_control_window)); + sigc::mem_fun(this, &PatchWindow::event_show_controls)); m_menu_view_patch_description->signal_activate().connect( - sigc::mem_fun(this, &PatchWindow::show_description_window)); + sigc::mem_fun(this, &PatchWindow::event_show_properties)); m_menu_destroy_patch->signal_activate().connect( sigc::mem_fun(this, &PatchWindow::event_destroy)); m_menu_clear->signal_activate().connect( @@ -201,7 +199,7 @@ PatchWindow::patch_controller(PatchController* pc) set_title(m_patch->model()->path()); - m_description_window->patch_model(pc->patch_model()); + //m_properties_window->patch_model(pc->patch_model()); // Setup breadcrumbs box @@ -283,10 +281,11 @@ PatchWindow::rebuild_breadcrumbs() void PatchWindow::breadcrumb_clicked(BreadCrumb* crumb) { - cerr << "FIXME: crumb\n"; - /* if (m_enable_signal) { - PatchController* const pc = crumb->patch(); + // FIXME: check to be sure PatchModel exists, then controller - maybe + // even make a controller if there isn't one? + PatchController* const pc = dynamic_cast( + Store::instance().patch(crumb->path())->controller()); assert(pc != NULL); if (pc == m_patch) { @@ -298,22 +297,22 @@ PatchWindow::breadcrumb_clicked(BreadCrumb* crumb) patch_controller(pc); } } - */ } void -PatchWindow::show_control_window() +PatchWindow::event_show_controls() { - if (m_patch != NULL) + if (m_patch) m_patch->show_control_window(); } void -PatchWindow::show_description_window() +PatchWindow::event_show_properties() { - m_description_window->show(); + if (m_patch) + m_patch->show_properties_window(); } diff --git a/src/progs/gtk/PatchWindow.h b/src/progs/gtk/PatchWindow.h index 54ea11ef..42fba478 100644 --- a/src/progs/gtk/PatchWindow.h +++ b/src/progs/gtk/PatchWindow.h @@ -69,9 +69,6 @@ public: LoadSubpatchWindow* load_subpatch_window() const { return m_load_subpatch_window; } NewSubpatchWindow* new_subpatch_window() const { return m_new_subpatch_window; } - void show_control_window(); - void show_description_window(); - // Breadcrumb management void node_removed(const string& name); void node_renamed(const string& old_path, const string& new_path); @@ -96,13 +93,15 @@ private: void event_destroy(); void event_clear(); void event_fullscreen_toggled(); + void event_show_properties(); + void event_show_controls(); + PatchController* m_patch; LoadPluginWindow* m_load_plugin_window; LoadPatchWindow* m_load_patch_window; NewSubpatchWindow* m_new_subpatch_window; LoadSubpatchWindow* m_load_subpatch_window; - PatchDescriptionWindow* m_description_window; bool m_enable_signal; bool m_position_stored; diff --git a/src/progs/gtk/om_gtk.glade b/src/progs/gtk/om_gtk.glade index abe5f254..bbf98197 100644 --- a/src/progs/gtk/om_gtk.glade +++ b/src/progs/gtk/om_gtk.glade @@ -1252,7 +1252,7 @@ True False - 10 + 24 @@ -1606,7 +1606,7 @@ False - 8 + 24 @@ -2476,7 +2476,7 @@ - + 8 400 200 @@ -2533,7 +2533,7 @@ - + True True True @@ -2568,7 +2568,7 @@ GTK_CORNER_TOP_LEFT - + True A short description of the patch to be included in the patch file True @@ -2602,7 +2602,7 @@ 5 - + True True True @@ -2614,7 +2614,7 @@ - + True Apply these changes to be saved the next time the patch is saved True diff --git a/src/progs/gtk/om_gtk.glade.bak b/src/progs/gtk/om_gtk.glade.bak index 7714d1f3..508ee6b1 100644 --- a/src/progs/gtk/om_gtk.glade.bak +++ b/src/progs/gtk/om_gtk.glade.bak @@ -2476,7 +2476,7 @@ - + 8 400 200 -- cgit v1.2.1