From 2e5daf2eeb0d89c135da285fcb6ed2d02a739b32 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 8 Mar 2019 01:53:55 +0100 Subject: [PATCH] Reduce #includes - avoid ardour_ui.h --- gtk2_ardour/automation_controller.cc | 6 +++--- gtk2_ardour/context_menu_helper.h | 30 ++++++++++++++++++++++++++++ gtk2_ardour/editor_summary.cc | 4 ++-- gtk2_ardour/meter_strip.cc | 6 +++--- gtk2_ardour/mixer_strip.cc | 4 ++-- gtk2_ardour/utils.cc | 7 +++++++ gtk2_ardour/visibility_group.cc | 4 ++-- 7 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 gtk2_ardour/context_menu_helper.h diff --git a/gtk2_ardour/automation_controller.cc b/gtk2_ardour/automation_controller.cc index aa37feabb3..3d9fc18675 100644 --- a/gtk2_ardour/automation_controller.cc +++ b/gtk2_ardour/automation_controller.cc @@ -32,8 +32,8 @@ #include "widgets/ardour_button.h" #include "widgets/ardour_knob.h" -#include "ardour_ui.h" #include "automation_controller.h" +#include "context_menu_helper.h" #include "gui_thread.h" #include "note_select_dialog.h" #include "timers.h" @@ -303,14 +303,14 @@ AutomationController::on_button_release(GdkEventButton* ev) const ARDOUR::ParameterDescriptor& desc = _controllable->desc(); if (desc.unit == ARDOUR::ParameterDescriptor::MIDI_NOTE) { - Gtk::Menu* menu = ARDOUR_UI::instance()->shared_popup_menu (); + Gtk::Menu* menu = ARDOUR_UI_UTILS::shared_popup_menu (); MenuList& items = menu->items(); items.push_back(MenuElem(_("Select Note..."), sigc::mem_fun(*this, &AutomationController::run_note_select_dialog))); menu->popup(1, ev->time); return true; } else if (desc.unit == ARDOUR::ParameterDescriptor::HZ) { - Gtk::Menu* menu = ARDOUR_UI::instance()->shared_popup_menu (); + Gtk::Menu* menu = ARDOUR_UI_UTILS::shared_popup_menu (); MenuList& items = menu->items(); items.push_back(MenuElem(_("Halve"), sigc::bind(sigc::mem_fun(*this, &AutomationController::set_ratio), diff --git a/gtk2_ardour/context_menu_helper.h b/gtk2_ardour/context_menu_helper.h new file mode 100644 index 0000000000..7d8f5ffe92 --- /dev/null +++ b/gtk2_ardour/context_menu_helper.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2019 Robin Gareus + * + * This program 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. + * + * This program 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 more 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _gtkardour_context_menu_helper_h_ +#define _gtkardour_context_menu_helper_h_ + +namespace Gtk { + class Menu; +} + +namespace ARDOUR_UI_UTILS { + Gtk::Menu* shared_popup_menu (); +} + +#endif diff --git a/gtk2_ardour/editor_summary.cc b/gtk2_ardour/editor_summary.cc index ab80917229..ac86e884c2 100644 --- a/gtk2_ardour/editor_summary.cc +++ b/gtk2_ardour/editor_summary.cc @@ -24,7 +24,7 @@ #include #include -#include "ardour_ui.h" +#include "context_menu_helper.h" #include "time_axis_view.h" #include "streamview.h" #include "editor_summary.h" @@ -462,7 +462,7 @@ EditorSummary::on_button_press_event (GdkEventButton* ev) if (ev->button == 3) { // right-click: show the reset menu action using namespace Gtk::Menu_Helpers; - Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu (); + Gtk::Menu* m = ARDOUR_UI_UTILS::shared_popup_menu (); MenuList& items = m->items (); items.push_back(MenuElem(_("Reset Summary to Extents"), sigc::mem_fun(*this, &EditorSummary::reset_to_extents))); diff --git a/gtk2_ardour/meter_strip.cc b/gtk2_ardour/meter_strip.cc index ea6ace2af1..079d6c00f0 100644 --- a/gtk2_ardour/meter_strip.cc +++ b/gtk2_ardour/meter_strip.cc @@ -40,8 +40,8 @@ #include "widgets/tooltips.h" #include "gui_thread.h" -#include "ardour_ui.h" #include "ardour_window.h" +#include "context_menu_helper.h" #include "ui_config.h" #include "utils.h" @@ -838,7 +838,7 @@ MeterStrip::popup_level_meter_menu (GdkEventButton* ev) { using namespace Gtk::Menu_Helpers; - Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu (); + Gtk::Menu* m = ARDOUR_UI_UTILS::shared_popup_menu (); MenuList& items = m->items (); RadioMenuItem::Group group; @@ -889,7 +889,7 @@ MeterStrip::popup_name_label_menu (GdkEventButton* ev) { using namespace Gtk::Menu_Helpers; - Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu (); + Gtk::Menu* m = ARDOUR_UI_UTILS::shared_popup_menu (); MenuList& items = m->items (); RadioMenuItem::Group group; diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 052f08204e..de4551940a 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -59,8 +59,8 @@ #include "widgets/tooltips.h" -#include "ardour_ui.h" #include "ardour_window.h" +#include "context_menu_helper.h" #include "enums_convert.h" #include "mixer_strip.h" #include "mixer_ui.h" @@ -2521,7 +2521,7 @@ MixerStrip::popup_level_meter_menu (GdkEventButton* ev) { using namespace Gtk::Menu_Helpers; - Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu (); + Gtk::Menu* m = ARDOUR_UI_UTILS::shared_popup_menu (); MenuList& items = m->items (); RadioMenuItem::Group group; diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index a4578494d1..098b2c9892 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -53,6 +53,7 @@ #include "canvas/item.h" #include "actions.h" +#include "context_menu_helper.h" #include "debug.h" #include "public_editor.h" #include "keyboard.h" @@ -816,3 +817,9 @@ ARDOUR_UI_UTILS::running_from_source_tree () gchar const *x = g_getenv ("ARDOUR_THEMES_PATH"); return x && (string (x).find ("gtk2_ardour") != string::npos); } + +Gtk::Menu* +ARDOUR_UI_UTILS::shared_popup_menu () +{ + return ARDOUR_UI::instance()->shared_popup_menu (); +} diff --git a/gtk2_ardour/visibility_group.cc b/gtk2_ardour/visibility_group.cc index 0090e39019..c6aae3244b 100644 --- a/gtk2_ardour/visibility_group.cc +++ b/gtk2_ardour/visibility_group.cc @@ -25,7 +25,7 @@ #include "pbd/strsplit.h" #include "pbd/xml++.h" -#include "ardour_ui.h" +#include "context_menu_helper.h" #include "visibility_group.h" #include "pbd/i18n.h" @@ -72,7 +72,7 @@ VisibilityGroup::button_press_event (GdkEventButton* ev) using namespace Gtk::Menu_Helpers; - Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu (); + Gtk::Menu* m = ARDOUR_UI_UTILS::shared_popup_menu (); MenuList& items = m->items (); for (vector::iterator i = _members.begin(); i != _members.end(); ++i) {