From 017055768d952bd55cbe9e25f9c3c7919485ecd0 Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Sat, 2 Mar 2019 15:35:03 +0100 Subject: refactor PanelDialog eliminates class duplication, only overloads specialized methods --- src/ui/dialog/panel-dialog.h | 63 ++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h index d644d0577..eb7d9f37e 100644 --- a/src/ui/dialog/panel-dialog.h +++ b/src/ui/dialog/panel-dialog.h @@ -82,6 +82,9 @@ public: inline void present() override; private: + template + static PanelDialog *_create(); + inline void _presentDialog(); PanelDialog() = delete; @@ -90,29 +93,6 @@ private: }; -template <> -class PanelDialog : - public PanelDialogBase, public Inkscape::UI::Dialog::Dialog { - -public: - inline PanelDialog(UI::Widget::Panel &contents, char const *prefs_path, int const verb_num); - - ~PanelDialog() override = default; - - template - static PanelDialog *create(); - - inline void present() override; - -private: - PanelDialog() = delete; - PanelDialog(PanelDialog const &d) = delete; // no copy - PanelDialog& - operator=(PanelDialog const &d) = delete; // no assign -}; - - - void PanelDialogBase::_propagateDocumentReplaced(SPDesktop *desktop, SPDocument *document) { _panel.signalDocumentReplaced().emit(desktop, document); @@ -155,6 +135,12 @@ PanelDialog::PanelDialog(Widget::Panel &panel, char const *prefs_path, int co template template PanelDialog *PanelDialog::create() +{ + return _create

(); +} + +template template +PanelDialog *PanelDialog::_create() { UI::Widget::Panel &panel = P::getInstance(); return new PanelDialog(panel, panel.getPrefsPath(), panel.getVerb()); @@ -172,42 +158,27 @@ void PanelDialog::_presentDialog() Dialog::present(); } -PanelDialog::PanelDialog(UI::Widget::Panel &panel, char const *prefs_path, - int const verb_num) : - PanelDialogBase(panel, prefs_path, verb_num), - Dialog(&Behavior::FloatingBehavior::create, prefs_path, verb_num) -{ - Gtk::Box *vbox = get_vbox(); - _panel.signalResponse().connect(sigc::mem_fun(*this, &PanelDialog::_handleResponse)); - - vbox->pack_start(_panel, true, true, 0); - - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - - _propagateDesktopActivated(desktop); - - _document_replaced_connection = - desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced)); - - show_all_children(); -} - +template <> inline void PanelDialog::present() { Dialog::present(); _panel.present(); } +template <> inline +void PanelDialog::_presentDialog() +{ +} + /** * Specialized factory method for panel dialogs with floating behavior in order to make them work as * singletons, i.e. allow them track the current active desktop. */ +template <> template PanelDialog *PanelDialog::create() { - UI::Widget::Panel &panel = P::getInstance(); - PanelDialog *instance = - new PanelDialog(panel, panel.getPrefsPath(), panel.getVerb()); + auto instance = _create

(); INKSCAPE.signal_activate_desktop.connect( sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopActivated) -- cgit v1.2.3