2 Copyright (C) 2010 Paul Davis
3 Author: Johannes Mueller
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __gtk2_ardour_template_dialog_h__
22 #define __gtk2_ardour_template_dialog_h__
26 #include <gtkmm/liststore.h>
27 #include <gtkmm/progressbar.h>
28 #include <gtkmm/textview.h>
29 #include <gtkmm/treeview.h>
31 #include "ardour_dialog.h"
32 #include "progress_reporter.h"
41 class TemplateDialog : public ArdourDialog,
42 public PBD::ScopedConnectionList
49 class TemplateManager : public Gtk::HBox,
50 public ProgressReporter
52 friend class TemplateDialog;
54 virtual ~TemplateManager () {}
55 virtual void init () = 0;
57 PBD::Signal0<void> TemplatesImported;
62 void setup_model (const std::vector<ARDOUR::TemplateInfo>& templates);
64 void row_selection_changed ();
65 void render_template_names (Gtk::CellRenderer* rnd, const Gtk::TreeModel::iterator& it);
66 void validate_edit (const Glib::ustring& path_string, const Glib::ustring& new_name);
69 void set_desc_dirty ();
71 bool key_event (GdkEventKey* ev);
73 virtual void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name) = 0;
74 virtual void delete_selected_template () = 0;
76 void handle_dirty_description ();
77 virtual void save_template_desc ();
79 void export_all_templates ();
80 void import_template_set ();
82 virtual std::string templates_dir () const = 0;
83 virtual std::string template_file (const Gtk::TreeModel::const_iterator& item) const = 0;
85 virtual bool adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const = 0;
87 bool adjust_plugin_paths (XMLNode* node, const std::string& name, const std::string& new_name) const;
89 struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
90 SessionTemplateColumns () {
96 Gtk::TreeModelColumn<std::string> name;
97 Gtk::TreeModelColumn<std::string> path;
98 Gtk::TreeModelColumn<std::string> description;
101 SessionTemplateColumns _template_columns;
102 Glib::RefPtr<Gtk::ListStore> _template_model;
104 Gtk::TreeModel::const_iterator _current_selection;
106 Gtk::TreeView _template_treeview;
107 Gtk::CellRendererText _validating_cellrenderer;
108 Gtk::TreeView::Column _validated_column;
110 Gtk::TextView _description_editor;
111 Gtk::Button _save_desc;
114 Gtk::Button _remove_button;
115 Gtk::Button _rename_button;
117 Gtk::Button _export_all_templates_button;
118 Gtk::Button _import_template_set_button;
120 Gtk::ProgressBar _progress_bar;
121 std::string _current_action;
123 void update_progress_gui (float p);
126 class SessionTemplateManager : public TemplateManager
129 SessionTemplateManager () : TemplateManager () {}
130 ~SessionTemplateManager () {}
135 void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name);
136 void delete_selected_template ();
138 std::string templates_dir () const;
139 std::string template_file (const Gtk::TreeModel::const_iterator& item) const;
141 bool adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const;
145 class RouteTemplateManager : public TemplateManager
148 RouteTemplateManager () : TemplateManager () {}
149 ~RouteTemplateManager () {}
154 void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name);
155 void delete_selected_template ();
157 std::string templates_dir () const;
158 std::string template_file (const Gtk::TreeModel::const_iterator& item) const;
160 bool adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const;
164 #endif /* __gtk2_ardour_template_dialog_h__ */