From: joncruz Date: Sat, 8 Dec 2007 07:03:33 +0000 (+0000) Subject: Fixes for gcc versions before 4.1.x X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=115638a6039fe16a8568151fc5286408ce3f06b0;p=inkscape.git Fixes for gcc versions before 4.1.x --- diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h index 4efc88622..3eeea6d95 100644 --- a/src/ui/dialog/panel-dialog.h +++ b/src/ui/dialog/panel-dialog.h @@ -29,29 +29,41 @@ namespace Inkscape { namespace UI { namespace Dialog { -/* local desktop event handlers */ -static void handle_activate_desktop(Inkscape::Application *, SPDesktop *, void *); -static void handle_deactivate_desktop(Inkscape::Application *, SPDesktop *, void *); +class PanelDialogBase { +public: + PanelDialogBase(Panel &panel, char const */*prefs_path*/, int const /*verb_num*/, + Glib::ustring const &/*apply_label*/) : + _panel (panel) { } -struct PanelDialogBase { - virtual void present() =0; - virtual Panel &getPanel() =0; + virtual void present() = 0; virtual ~PanelDialogBase() {} -private: - virtual void _propagateDocumentReplaced(SPDesktop* desktop, SPDocument *document) =0; - virtual void _propagateDesktopActivated(Inkscape::Application *, SPDesktop *) =0; - virtual void _propagateDesktopDeactivated(Inkscape::Application *, SPDesktop *) =0; + virtual Panel &getPanel() { return _panel; } + +protected: + static void handle_deactivate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) { + g_return_if_fail(data != NULL); + static_cast(data)->_propagateDesktopDeactivated(application, desktop); + } + + static void _handle_activate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) { + g_return_if_fail(data != NULL); + static_cast(data)->_propagateDesktopActivated(application, desktop); + } + + inline virtual void _propagateDocumentReplaced(SPDesktop* desktop, SPDocument *document); + inline virtual void _propagateDesktopActivated(Inkscape::Application *, SPDesktop *); + inline virtual void _propagateDesktopDeactivated(Inkscape::Application *, SPDesktop *); - friend void handle_activate_desktop(Inkscape::Application *, SPDesktop *, void *); - friend void handle_deactivate_desktop(Inkscape::Application *, SPDesktop *, void *); + Panel &_panel; + sigc::connection _document_replaced_connection; }; template class PanelDialog : public PanelDialogBase, public Inkscape::UI::Dialog::Dialog { public: - PanelDialog(Panel &contents, char const *prefs_path, int const verb_num, + PanelDialog(Panel &contents, char const *prefs_path, int const verb_num, Glib::ustring const &apply_label); virtual ~PanelDialog() {} @@ -59,28 +71,66 @@ public: template static PanelDialog *create(); - virtual void present(); - - Panel &getPanel() { return _panel; } + virtual void present() { Dialog::present(); } private: - void _propagateDocumentReplaced(SPDesktop* desktop, SPDocument *document); - void _propagateDesktopActivated(Inkscape::Application *, SPDesktop *); - void _propagateDesktopDeactivated(Inkscape::Application *, SPDesktop *); - - Panel &_panel; - sigc::connection _document_replaced_connection; - PanelDialog(); // no constructor without params PanelDialog(PanelDialog const &d); // no copy PanelDialog& operator=(PanelDialog const &d); // no assign +}; + + +template <> +class PanelDialog : + public PanelDialogBase, public Inkscape::UI::Dialog::Dialog { +public: + inline PanelDialog(Panel &contents, char const *prefs_path, int const verb_num, + Glib::ustring const &apply_label); + + virtual ~PanelDialog() {} + + template + static PanelDialog *create(); + + virtual void present() { Dialog::present(); } + +private: + PanelDialog(); // no constructor without params + PanelDialog(PanelDialog const &d); // no copy + PanelDialog& + operator=(PanelDialog const &d); // no assign }; + + +void +PanelDialogBase::_propagateDocumentReplaced(SPDesktop *desktop, SPDocument *document) +{ + _panel.signalDocumentReplaced().emit(desktop, document); +} + +void +PanelDialogBase::_propagateDesktopActivated(Inkscape::Application *application, SPDesktop *desktop) +{ + _document_replaced_connection = + desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialogBase::_propagateDocumentReplaced)); + _panel.signalActivateDesktop().emit(application, desktop); +} + +void +PanelDialogBase::_propagateDesktopDeactivated(Inkscape::Application *application, SPDesktop *desktop) +{ + _document_replaced_connection.disconnect(); + _panel.signalDeactiveDesktop().emit(application, desktop); +} + + template -PanelDialog::PanelDialog(Panel &panel, char const *prefs_path, int const verb_num, Glib::ustring const &apply_label) : - Dialog(&B::create, prefs_path, verb_num, apply_label), - _panel (panel) +PanelDialog::PanelDialog(Panel &panel, char const *prefs_path, int const verb_num, + Glib::ustring const &apply_label) : + PanelDialogBase(panel, prefs_path, verb_num, apply_label), + Dialog(&B::create, prefs_path, verb_num, apply_label) { Gtk::VBox *vbox = get_vbox(); _panel.signalResponse().connect(sigc::mem_fun(*this, &PanelDialog::_handleResponse)); @@ -92,7 +142,7 @@ PanelDialog::PanelDialog(Panel &panel, char const *prefs_path, int const verb _propagateDesktopActivated(INKSCAPE, desktop); - _document_replaced_connection = + _document_replaced_connection = desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced)); if (prefs_get_int_attribute ("dialogs", "showclose", 0) || !apply_label.empty()) { @@ -115,71 +165,56 @@ PanelDialog::create() return new PanelDialog(panel, panel.getPrefsPath(), panel.getVerb(), panel.getApplyLabel()); } -/** + +PanelDialog::PanelDialog(Panel &panel, char const *prefs_path, + int const verb_num, Glib::ustring const &apply_label) : + PanelDialogBase(panel, prefs_path, verb_num, apply_label), + Dialog(&Behavior::FloatingBehavior::create, prefs_path, verb_num, apply_label) +{ + Gtk::VBox *vbox = get_vbox(); + _panel.signalResponse().connect(sigc::mem_fun(*this, &PanelDialog::_handleResponse)); + _panel.signalPresent().connect(sigc::mem_fun(*this, &PanelDialog::present)); + + vbox->pack_start(_panel, true, true, 0); + + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + + _propagateDesktopActivated(INKSCAPE, desktop); + + _document_replaced_connection = + desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced)); + + if (prefs_get_int_attribute ("dialogs", "showclose", 0) || !apply_label.empty()) { + // TODO: make the order of buttons obey the global preference + if (!apply_label.empty()) { + panel.addResponseButton(apply_label, Gtk::RESPONSE_APPLY); + panel.setDefaultResponse(Gtk::RESPONSE_APPLY); + } + panel.addResponseButton(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE); + } + + show_all_children(); +} + +/** * Specialize 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 +template PanelDialog * PanelDialog::create() { Panel &panel = P::getInstance(); - PanelDialog *instance = - new PanelDialog(panel, panel.getPrefsPath(), + PanelDialog *instance = + new PanelDialog(panel, panel.getPrefsPath(), panel.getVerb(), panel.getApplyLabel()); - g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(handle_activate_desktop), instance); + g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(_handle_activate_desktop), instance); g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK(handle_deactivate_desktop), instance); return instance; } -template -void -PanelDialog::present() -{ - Dialog::present(); -} - -template -void -PanelDialog::_propagateDocumentReplaced(SPDesktop *desktop, SPDocument *document) -{ - _panel.signalDocumentReplaced().emit(desktop, document); -} - -template -void -PanelDialog::_propagateDesktopActivated(Inkscape::Application *application, SPDesktop *desktop) -{ - _document_replaced_connection = - desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced)); - _panel.signalActivateDesktop().emit(application, desktop); -} - -template -void -PanelDialog::_propagateDesktopDeactivated(Inkscape::Application *application, SPDesktop *desktop) -{ - _document_replaced_connection.disconnect(); - _panel.signalDeactiveDesktop().emit(application, desktop); -} - - -static void -handle_activate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) -{ - g_return_if_fail(data != NULL); - static_cast(data)->_propagateDesktopActivated(application, desktop); -} - -static void -handle_deactivate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) -{ - g_return_if_fail(data != NULL); - static_cast(data)->_propagateDesktopDeactivated(application, desktop); -} - } // namespace Dialog } // namespace UI } // namespace Inkscape