From 7997c83b0134bd55ffade0ec9e26c0b525994421 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 30 Aug 2023 23:04:39 +0200 Subject: [PATCH] Allow to edit arrangement label in sidebar --- gtk2_ardour/editor_sections.cc | 21 ++++++++++++++++++++- gtk2_ardour/editor_sections.h | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/editor_sections.cc b/gtk2_ardour/editor_sections.cc index 6a21b1711a..53cea3f4c3 100644 --- a/gtk2_ardour/editor_sections.cc +++ b/gtk2_ardour/editor_sections.cc @@ -44,7 +44,16 @@ EditorSections::EditorSections () { _model = ListStore::create (_columns); _view.set_model (_model); - _view.append_column (_("Name"), _columns.name); + + Gtk::TreeViewColumn* c = manage (new Gtk::TreeViewColumn (_("Name"), _columns.name)); + _view.append_column (*c); + c->set_resizable (true); + c->set_data ("mouse-edits-require-mod1", (gpointer)0x1); + + CellRendererText* section_name_cell = dynamic_cast (c->get_first_cell ()); + section_name_cell->property_editable () = true; + section_name_cell->signal_edited ().connect (sigc::mem_fun (*this, &EditorSections::name_edited)); + _view.append_column (_("Start"), _columns.s_start); _view.append_column (_("End"), _columns.s_end); _view.set_headers_visible (true); @@ -414,6 +423,16 @@ EditorSections::button_press (GdkEventButton* ev) return false; } +void +EditorSections::name_edited (const std::string& path, const std::string& new_text) +{ + TreeIter i; + if ((i = _model->get_iter (path))) { + Location* l = (*i)[_columns.location]; + l->set_name (new_text); + } +} + bool EditorSections::enter_notify (GdkEventCrossing*) { diff --git a/gtk2_ardour/editor_sections.h b/gtk2_ardour/editor_sections.h index 0d9a6d5ef1..1852949453 100644 --- a/gtk2_ardour/editor_sections.h +++ b/gtk2_ardour/editor_sections.h @@ -60,6 +60,8 @@ private: void drag_data_received (Glib::RefPtr const&, int, int, Gtk::SelectionData const&, guint, guint); void drag_leave (Glib::RefPtr const&, guint); + void name_edited (const std::string&, const std::string&); + struct Section { Section () : location (NULL)