diff options
| author | gustav_b <gustav_b@users.sourceforge.net> | 2007-11-22 00:14:41 +0000 |
|---|---|---|
| committer | gustav_b <gustav_b@users.sourceforge.net> | 2007-11-22 00:14:41 +0000 |
| commit | 5caa6ff4dfb7b538555d60fa2732272bf8b9828b (patch) | |
| tree | 65c6fb0232f8621fa6cecdcdf68d0790bd955777 /src/ui/dialog | |
| parent | Fix ordering of LPE parameters (no longer use map, just use vector) (diff) | |
| download | inkscape-5caa6ff4dfb7b538555d60fa2732272bf8b9828b.tar.gz inkscape-5caa6ff4dfb7b538555d60fa2732272bf8b9828b.zip | |
The dialog to panel refactoring:
* Made the current dialogs subclass the Panel class instead of the
Dialog class.
* Extended the Panel class with some functionality that the dialogs
relied on.
* Added a PanelDialog class which is a dialog container for a
single panel with the dialog behavior as a template parameter.
(* Fixed coding style for the Panel and Dialog class)
For details, see
http://www.nabble.com/Re%3A-Dockable-dialogs%2C-todo-list-p12728194.html
http://www.nabble.com/Re%3A-Inkscape-overcomes-Xara-in-Google-Trends-p13126622.html
(bzr r4126)
Diffstat (limited to 'src/ui/dialog')
48 files changed, 435 insertions, 477 deletions
diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 6679e99de..e4b3f3062 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -10,6 +10,7 @@ ui_dialog_libuidialog_a_SOURCES = \ ui/dialog/dialog-manager.h \ ui/dialog/dialog.cpp \ ui/dialog/dialog.h \ + ui/dialog/panel-dialog.h \ ui/dialog/behavior.h \ ui/dialog/dock-behavior.h \ ui/dialog/dock-behavior.cpp \ diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 924a98790..7b616fe18 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -774,8 +774,8 @@ void on_selection_changed(Inkscape::Application *inkscape, Inkscape::Selection * -AlignAndDistribute::AlignAndDistribute(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.align", SP_VERB_DIALOG_ALIGN_DISTRIBUTE), +AlignAndDistribute::AlignAndDistribute() + : UI::Widget::Panel ("", "dialogs.align", SP_VERB_DIALOG_ALIGN_DISTRIBUTE), randomize_bbox(NR::Nothing()), _alignFrame(_("Align")), _distributeFrame(_("Distribute")), @@ -923,17 +923,16 @@ AlignAndDistribute::AlignAndDistribute(Behavior::BehaviorFactory behavior_factor _graphLayoutFrame.add(_graphLayoutTable); _nodesFrame.add(_nodesTable); - // Top level vbox - Gtk::VBox *vbox = get_vbox(); - vbox->set_spacing(4); + Gtk::Box *contents = _getContents(); + contents->set_spacing(4); // Notebook for individual transformations - vbox->pack_start(_alignFrame, true, true); - vbox->pack_start(_distributeFrame, true, true); - vbox->pack_start(_removeOverlapFrame, true, true); - vbox->pack_start(_graphLayoutFrame, true, true); - vbox->pack_start(_nodesFrame, true, true); + contents->pack_start(_alignFrame, true, true); + contents->pack_start(_distributeFrame, true, true); + contents->pack_start(_removeOverlapFrame, true, true); + contents->pack_start(_graphLayoutFrame, true, true); + contents->pack_start(_nodesFrame, true, true); //Connect to the global tool change signal g_signal_connect (G_OBJECT (INKSCAPE), "set_eventcontext", G_CALLBACK (on_tool_changed), this); diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index 0559a11e9..a54ac781e 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -29,7 +29,7 @@ #include "libnr/nr-rect.h" -#include "dialog.h" +#include "ui/widget/panel.h" #include "ui/widget/notebook-page.h" using namespace Inkscape::UI::Widget; @@ -44,13 +44,12 @@ namespace Dialog { class Action; -class AlignAndDistribute : public Dialog { +class AlignAndDistribute : public Widget::Panel { public: - AlignAndDistribute(Behavior::BehaviorFactory behavior_factory); + AlignAndDistribute(); virtual ~AlignAndDistribute(); - static AlignAndDistribute *create(Behavior::BehaviorFactory behavior_factory) - { return new AlignAndDistribute(behavior_factory); } + static AlignAndDistribute &getInstance() { return *new AlignAndDistribute(); } enum AlignTarget { LAST=0, FIRST, BIGGEST, SMALLEST, PAGE, DRAWING, SELECTION }; diff --git a/src/ui/dialog/behavior.h b/src/ui/dialog/behavior.h index b7455bbe5..4b5fe06b8 100644 --- a/src/ui/dialog/behavior.h +++ b/src/ui/dialog/behavior.h @@ -27,10 +27,10 @@ namespace Behavior { class Behavior; -typedef Behavior *(*BehaviorFactory)(Dialog& dialog); +typedef Behavior *(*BehaviorFactory)(Dialog &dialog); template <typename T> -Behavior *create(Dialog& dialog) +Behavior *create(Dialog &dialog) { return T::create(dialog); } @@ -53,21 +53,16 @@ public: virtual void move(int x, int y) =0; virtual void set_position(Gtk::WindowPosition) =0; virtual void set_size_request(int width, int height) =0; - virtual void size_request(Gtk::Requisition& requisition) =0; - virtual void get_position(int& x, int& y) =0; - virtual void get_size(int& width, int& height) =0; + virtual void size_request(Gtk::Requisition &requisition) =0; + virtual void get_position(int &x, int &y) =0; + virtual void get_size(int &width, int &height) =0; virtual void set_title(Glib::ustring title) =0; - virtual void set_response_sensitive(int response_id, bool setting) =0; virtual void set_sensitive(bool sensitive) =0; - virtual Gtk::Button *add_button(const Glib::ustring& button_text, int response_id) =0; - virtual Gtk::Button *add_button(const Gtk::StockID& stock_id, int response_id) =0; - virtual void set_default_response(int response_id) =0; /** Gtk::Dialog signal proxies */ virtual Glib::SignalProxy0<void> signal_show() =0; virtual Glib::SignalProxy0<void> signal_hide() =0; virtual Glib::SignalProxy1<bool, GdkEventAny *> signal_delete_event() =0; - virtual Glib::SignalProxy1<void, int> signal_response() =0; /** Custom signal handlers */ virtual void onHideF12() =0; @@ -76,7 +71,7 @@ public: virtual void onDesktopActivated(SPDesktop *desktop) =0; protected: - Behavior(Dialog& dialog) + Behavior(Dialog &dialog) : _dialog (dialog) { } @@ -84,8 +79,8 @@ protected: private: Behavior(); // no constructor without params - Behavior(const Behavior&); // no copy - Behavior& operator=(const Behavior&); // no assign + Behavior(const Behavior &); // no copy + Behavior &operator=(const Behavior &); // no assign }; } // namespace Behavior diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index e5d326efe..f8c07cf53 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -37,6 +37,7 @@ #include "ui/dialog/transformation.h" #include "ui/dialog/undo-history.h" #include "ui/dialog/xml-editor.h" +#include "ui/dialog/panel-dialog.h" #include "dialogs/layers-panel.h" #include "dialogs/tiledialog.h" @@ -51,8 +52,10 @@ namespace Dialog { namespace { +using namespace Behavior; + template <typename T, typename B> -inline Dialog *create() { return T::create(&B::create); } +inline Dialog *create() { return PanelDialog<B>::template create<T>(); } } @@ -101,6 +104,7 @@ DialogManager::DialogManager() { registerFactory("Memory", &create<Memory, FloatingBehavior>); registerFactory("Messages", &create<Messages, FloatingBehavior>); registerFactory("Script", &create<ScriptDialog, FloatingBehavior>); + registerFactory("Swatches", &create<SwatchesPanel, FloatingBehavior>); registerFactory("TextProperties", &create<TextProperties, FloatingBehavior>); registerFactory("TileDialog", &create<TileDialog, FloatingBehavior>); registerFactory("Trace", &create<TraceDialog, FloatingBehavior>); @@ -126,6 +130,7 @@ DialogManager::DialogManager() { registerFactory("Memory", &create<Memory, DockBehavior>); registerFactory("Messages", &create<Messages, DockBehavior>); registerFactory("Script", &create<ScriptDialog, DockBehavior>); + registerFactory("Swatches", &create<SwatchesPanel, DockBehavior>); registerFactory("TextProperties", &create<TextProperties, DockBehavior>); registerFactory("TileDialog", &create<TileDialog, DockBehavior>); registerFactory("Trace", &create<TraceDialog, DockBehavior>); diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 4fbc217ab..7d2242802 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -42,14 +42,14 @@ namespace UI { namespace Dialog { void -sp_retransientize (Inkscape::Application *inkscape, SPDesktop *desktop, gpointer dlgPtr) +sp_retransientize(Inkscape::Application *inkscape, SPDesktop *desktop, gpointer dlgPtr) { Dialog *dlg = (Dialog *)dlgPtr; dlg->onDesktopActivated (desktop); } gboolean -sp_retransientize_again (gpointer dlgPtr) +sp_retransientize_again(gpointer dlgPtr) { Dialog *dlg = (Dialog *)dlgPtr; dlg->retransientize_suppress = false; @@ -57,7 +57,7 @@ sp_retransientize_again (gpointer dlgPtr) } void -sp_dialog_shutdown (GtkObject *object, gpointer dlgPtr) +sp_dialog_shutdown(GtkObject *object, gpointer dlgPtr) { Dialog *dlg = (Dialog *)dlgPtr; dlg->onShutdown(); @@ -95,7 +95,7 @@ void unhideCallback(GtkObject *object, gpointer dlgPtr) */ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path, int verb_num, - const char *apply_label) + Glib::ustring const &apply_label) : _hiddenF12 (false), _prefs_path (prefs_path), _verb_num(verb_num), @@ -125,15 +125,6 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat Glib::wrap(gobj())->signal_event().connect(sigc::mem_fun(*this, &Dialog::_onEvent)); Glib::wrap(gobj())->signal_key_press_event().connect(sigc::mem_fun(*this, &Dialog::_onKeyPress)); - if (prefs_get_int_attribute ("dialogs", "showclose", 0) || apply_label) { - // TODO: make the order of buttons obey the global preference - if (apply_label) { - add_button(Glib::ustring(apply_label), Gtk::RESPONSE_APPLY); - set_default_response(Gtk::RESPONSE_APPLY); - } - add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE); - } - read_geometry(); } @@ -190,7 +181,7 @@ Dialog::onShowF12() } -inline Dialog::operator Gtk::Widget&() { return *_behavior; } +inline Dialog::operator Gtk::Widget &() { return *_behavior; } inline GtkWidget *Dialog::gobj() { return _behavior->gobj(); } inline void Dialog::present() { _behavior->present(); } inline Gtk::VBox *Dialog::get_vbox() { return _behavior->get_vbox(); } @@ -198,33 +189,17 @@ inline void Dialog::hide() { _behavior->hi inline void Dialog::show() { _behavior->show(); } inline void Dialog::show_all_children() { _behavior->show_all_children(); } inline void Dialog::set_size_request(int width, int height) { _behavior->set_size_request(width, height); } -inline void Dialog::size_request(Gtk::Requisition& requisition) { _behavior->size_request(requisition); } -inline void Dialog::get_position(int& x, int& y) { _behavior->get_position(x, y); } -inline void Dialog::get_size(int& width, int& height) { _behavior->get_size(width, height); } +inline void Dialog::size_request(Gtk::Requisition &requisition) { _behavior->size_request(requisition); } +inline void Dialog::get_position(int &x, int &y) { _behavior->get_position(x, y); } +inline void Dialog::get_size(int &width, int &height) { _behavior->get_size(width, height); } inline void Dialog::resize(int width, int height) { _behavior->resize(width, height); } inline void Dialog::move(int x, int y) { _behavior->move(x, y); } inline void Dialog::set_position(Gtk::WindowPosition position) { _behavior->set_position(position); } inline void Dialog::set_title(Glib::ustring title) { _behavior->set_title(title); } inline void Dialog::set_sensitive(bool sensitive) { _behavior->set_sensitive(sensitive); } -inline void Dialog::set_response_sensitive(int response_id, bool setting) -{ _behavior->set_response_sensitive(response_id, setting); } - -void Dialog::set_resizable(bool) { } -void Dialog::set_default(Gtk::Widget&) { } - -inline void Dialog::set_default_response(int response_id) { _behavior->set_default_response(response_id); } - -Glib::SignalProxy0<void> Dialog::signal_show () { return _behavior->signal_show(); } -Glib::SignalProxy0<void> Dialog::signal_hide () { return _behavior->signal_hide(); } -Glib::SignalProxy1<void, int> Dialog::signal_response () { return _behavior->signal_response(); } - -Gtk::Button* Dialog::add_button (const Glib::ustring& button_text, int response_id) -{ return _behavior->add_button(button_text, response_id); } - -Gtk::Button* Dialog::add_button (const Gtk::StockID& stock_id, int response_id) -{ return _behavior->add_button(stock_id, response_id); } - +Glib::SignalProxy0<void> Dialog::signal_show() { return _behavior->signal_show(); } +Glib::SignalProxy0<void> Dialog::signal_hide() { return _behavior->signal_hide(); } void Dialog::read_geometry() @@ -278,13 +253,9 @@ Dialog::save_geometry() } void -Dialog::_onResponse(int response_id) +Dialog::_handleResponse(int response_id) { switch (response_id) { - case Gtk::RESPONSE_APPLY: { - _apply(); - break; - } case Gtk::RESPONSE_CLOSE: { _close(); break; diff --git a/src/ui/dialog/dialog.h b/src/ui/dialog/dialog.h index 5a9e65645..a1229fb94 100644 --- a/src/ui/dialog/dialog.h +++ b/src/ui/dialog/dialog.h @@ -43,45 +43,36 @@ class Dialog { public: Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path = NULL, - int verb_num = 0, const char *apply_label = NULL); + int verb_num = 0, Glib::ustring const &apply_label = ""); virtual ~Dialog(); - virtual void onDesktopActivated (SPDesktop*); + virtual void onDesktopActivated(SPDesktop*); virtual void onShutdown(); /** Hide and show dialogs */ virtual void onHideF12(); virtual void onShowF12(); - virtual operator Gtk::Widget&(); + virtual operator Gtk::Widget &(); virtual GtkWidget *gobj(); virtual void present(); virtual Gtk::VBox *get_vbox(); virtual void show(); virtual void hide(); virtual void show_all_children(); - virtual void set_resizable(bool); - virtual void set_sensitive(bool sensitive=true); - virtual void set_default(Gtk::Widget&); virtual void set_size_request(int, int); - virtual void size_request(Gtk::Requisition&); - virtual void get_position(int& x, int& y); - virtual void get_size(int& width, int& height); + virtual void size_request(Gtk::Requisition &); + virtual void get_position(int &x, int &y); + virtual void get_size(int &width, int &height); virtual void resize(int width, int height); virtual void move(int x, int y); virtual void set_position(Gtk::WindowPosition position); virtual void set_title(Glib::ustring title); + virtual void set_sensitive(bool sensitive=true); - virtual void set_response_sensitive(int response_id, bool setting); virtual Glib::SignalProxy0<void> signal_show(); virtual Glib::SignalProxy0<void> signal_hide(); - virtual Glib::SignalProxy1<void, int> signal_response(); - - virtual Gtk::Button* add_button (const Glib::ustring& button_text, int response_id); - virtual Gtk::Button* add_button (const Gtk::StockID& stock_id, int response_id); - - virtual void set_default_response(int response_id); bool _user_hidden; // when it is closed by the user, to prevent repopping on f12 bool _hiddenF12; @@ -95,14 +86,15 @@ protected: const char *_prefs_path; int _verb_num; Glib::ustring _title; - const char *_apply_label; + Glib::ustring _apply_label; /** * Tooltips object for all descendants to use */ Gtk::Tooltips tooltips; - virtual void _onResponse(int response_id); + virtual void _handleResponse(int response_id); + virtual bool _onDeleteEvent (GdkEventAny*); virtual bool _onEvent(GdkEvent *event); virtual bool _onKeyPress(GdkEventKey *event); diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp index afa921e85..13ce20abe 100644 --- a/src/ui/dialog/dock-behavior.cpp +++ b/src/ui/dialog/dock-behavior.cpp @@ -37,7 +37,7 @@ namespace Dialog { namespace Behavior { -DockBehavior::DockBehavior(Dialog& dialog) : +DockBehavior::DockBehavior(Dialog &dialog) : Behavior(dialog), _dock_item(*SP_ACTIVE_DESKTOP->getDock(), Inkscape::Verb::get(dialog._verb_num)->get_id(), dialog._title.c_str(), @@ -49,7 +49,6 @@ DockBehavior::DockBehavior(Dialog& dialog) : { // Connect signals _signal_hide_connection = signal_hide().connect(sigc::mem_fun(*this, &Inkscape::UI::Dialog::Behavior::DockBehavior::_onHide)); - signal_response().connect(sigc::mem_fun(_dialog, &Inkscape::UI::Dialog::Dialog::_onResponse)); _dock_item.signal_state_changed().connect(sigc::mem_fun(*this, &Inkscape::UI::Dialog::Behavior::DockBehavior::_onStateChanged)); if (_dock_item.getState() == Widget::DockItem::FLOATING_STATE) { @@ -64,13 +63,13 @@ DockBehavior::~DockBehavior() Behavior * -DockBehavior::create(Dialog& dialog) +DockBehavior::create(Dialog &dialog) { return new DockBehavior(dialog); } -DockBehavior::operator Gtk::Widget&() +DockBehavior::operator Gtk::Widget &() { return _dock_item.getWidget(); } @@ -119,13 +118,13 @@ DockBehavior::show_all_children() } void -DockBehavior::get_position(int& x, int& y) +DockBehavior::get_position(int &x, int &y) { _dock_item.get_position(x, y); } void -DockBehavior::get_size(int& width, int& height) +DockBehavior::get_size(int &width, int &height) { _dock_item.get_size(width, height); } @@ -155,7 +154,7 @@ DockBehavior::set_size_request(int width, int height) } void -DockBehavior::size_request(Gtk::Requisition& requisition) +DockBehavior::size_request(Gtk::Requisition &requisition) { _dock_item.size_request(requisition); } @@ -167,66 +166,11 @@ DockBehavior::set_title(Glib::ustring title) } void -DockBehavior::set_response_sensitive(int response_id, bool setting) -{ - if (_response_map[response_id]) - _response_map[response_id]->set_sensitive(setting); -} - -void DockBehavior::set_sensitive(bool sensitive) { get_vbox()->set_sensitive(); } -Gtk::Button * -DockBehavior::add_button(const Glib::ustring& button_text, int response_id) -{ - Gtk::Button *button = new Gtk::Button(button_text); - _addButton(button, response_id); - return button; -} - -Gtk::Button * -DockBehavior::add_button(const Gtk::StockID& stock_id, int response_id) -{ - Gtk::Button *button = new Gtk::Button(stock_id); - _addButton(button, response_id); - return button; -} - -void -DockBehavior::_addButton(Gtk::Button *button, int response_id) -{ - _dock_item.addButton(button, response_id); - - if (response_id != 0) { - - /* Pass the signal_clicked signals onto a our own signal handler that can re-emit them as - * signal_response signals - */ - button->signal_clicked().connect( - sigc::bind<int>(sigc::mem_fun(*this, - &Inkscape::UI::Dialog::Behavior::DockBehavior::_onResponse), - response_id)); - - _response_map[response_id] = button; - } -} - -void -DockBehavior::set_default_response(int response_id) -{ - ResponseMap::iterator widget_found; - widget_found = _response_map.find(response_id); - - if (widget_found != _response_map.end()) { - widget_found->second->activate(); - widget_found->second->property_can_default() = true; - widget_found->second->grab_default(); - } -} - void DockBehavior::_onHide() @@ -249,12 +193,6 @@ DockBehavior::_onStateChanged(Widget::DockItem::State prev_state, } void -DockBehavior::_onResponse(int response_id) -{ - g_signal_emit_by_name (_dock_item.gobj(), "signal_response", response_id); -} - -void DockBehavior::onHideF12() { _dialog.save_geometry(); @@ -335,9 +273,6 @@ DockBehavior::signal_show() { return _dock_item.signal_show(); } Glib::SignalProxy0<void> DockBehavior::signal_hide() { return _dock_item.signal_hide(); } -Glib::SignalProxy1<void, int> -DockBehavior::signal_response() { return _dock_item.signal_response(); } - Glib::SignalProxy1<bool, GdkEventAny *> DockBehavior::signal_delete_event() { return _dock_item.signal_delete_event(); } diff --git a/src/ui/dialog/dock-behavior.h b/src/ui/dialog/dock-behavior.h index 01d95dd8c..d873bfb0a 100644 --- a/src/ui/dialog/dock-behavior.h +++ b/src/ui/dialog/dock-behavior.h @@ -53,11 +53,7 @@ public: void get_position(int& x, int& y); void get_size(int& width, int& height); void set_title(Glib::ustring title); - void set_response_sensitive(int response_id, bool setting); void set_sensitive(bool sensitive); - Gtk::Button *add_button(const Glib::ustring& button_text, int response_id); - Gtk::Button *add_button(const Gtk::StockID& stock_id, int response_id); - void set_default_response(int response_id); /** Gtk::Dialog signal proxies */ Glib::SignalProxy0<void> signal_show(); @@ -65,7 +61,6 @@ public: Glib::SignalProxy1<bool, GdkEventAny *> signal_delete_event(); Glib::SignalProxy0<void> signal_drag_begin(); Glib::SignalProxy1<void, bool> signal_drag_end(); - Glib::SignalProxy1<void, int> signal_response(); /** Custom signal handlers */ void onHideF12(); @@ -78,19 +73,13 @@ private: DockBehavior(Dialog& dialog); - /** A map to store which widget that emits a certain response signal */ - typedef std::map<int, Gtk::Widget *> ResponseMap; - ResponseMap _response_map; - /** Internal helpers */ - void _addButton(Gtk::Button *button, int response_id); Gtk::Paned *_getPaned(); //< gives the parent pane, if the dock item has one void _requestHeight(int height); //< tries to resize the dock item to the requested hieght /** Internal signal handlers */ void _onHide(); bool _onDeleteEvent(GdkEventAny *event); - void _onResponse(int response_id); void _onStateChanged(Widget::DockItem::State prev_state, Widget::DockItem::State new_state); bool _onKeyPress(GdkEventKey *event); diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index 22f6f64be..5671e08fe 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -62,13 +62,13 @@ static Inkscape::XML::NodeEventVector const _repr_events = { }; -DocumentMetadata* -DocumentMetadata::create(Behavior::BehaviorFactory behavior_factory) +DocumentMetadata & +DocumentMetadata::getInstance() { - if (_instance) return _instance; - _instance = new DocumentMetadata(behavior_factory); + if (_instance) return *_instance; + _instance = new DocumentMetadata(); _instance->init(); - return _instance; + return *_instance; } void @@ -81,16 +81,15 @@ DocumentMetadata::destroy() } } -DocumentMetadata::DocumentMetadata(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.documentmetadata", SP_VERB_DIALOG_METADATA), +DocumentMetadata::DocumentMetadata() + : UI::Widget::Panel ("", "dialogs.documentmetadata", SP_VERB_DIALOG_METADATA), _page_metadata1(1, 1), _page_metadata2(1, 1), _prefs_path("dialogs.documentmetadata") { hide(); - set_resizable (true); _tt.enable(); - get_vbox()->set_spacing (4); - get_vbox()->pack_start (_notebook, true, true); + _getContents()->set_spacing (4); + _getContents()->pack_start(_notebook, true, true); _notebook.append_page(_page_metadata1, _("Metadata")); _notebook.append_page(_page_metadata2, _("License")); @@ -115,7 +114,6 @@ DocumentMetadata::init() G_CALLBACK(on_deactivate_desktop), 0); show_all_children(); - present(); } DocumentMetadata::~DocumentMetadata() @@ -236,12 +234,6 @@ DocumentMetadata::update() //-------------------------------------------------------------------- -void -DocumentMetadata::on_response (int id) -{ - if (id == Gtk::RESPONSE_CLOSE) - hide(); -} /** * Called when XML node attribute changed; updates dialog widgets. diff --git a/src/ui/dialog/document-metadata.h b/src/ui/dialog/document-metadata.h index 3f1fb9e57..7ee2ee216 100644 --- a/src/ui/dialog/document-metadata.h +++ b/src/ui/dialog/document-metadata.h @@ -18,10 +18,10 @@ #include <gtkmm/notebook.h> #include <glibmm/i18n.h> +#include "ui/widget/panel.h" #include "ui/widget/licensor.h" #include "ui/widget/notebook-page.h" #include "ui/widget/registry.h" -#include "dialog.h" using namespace Inkscape::UI::Widget; @@ -37,17 +37,18 @@ namespace Inkscape { typedef std::list<EntityEntry*> RDElist; -class DocumentMetadata : public Inkscape::UI::Dialog::Dialog { +class DocumentMetadata : public Inkscape::UI::Widget::Panel { public: void update(); - static DocumentMetadata *create(Behavior::BehaviorFactory behavior_factory); + + static DocumentMetadata &getInstance(); + static void destroy(); sigc::connection _doc_replaced_connection; protected: void build_metadata(); void init(); - virtual void on_response (int); Gtk::Tooltips _tt; Gtk::Notebook _notebook; @@ -62,8 +63,8 @@ protected: Registry _wr; private: - DocumentMetadata(Behavior::BehaviorFactory behavior_factory); virtual ~DocumentMetadata(); + DocumentMetadata(); }; } // namespace Dialog diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 7e71a0e3e..7528b463f 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -71,13 +71,13 @@ static Inkscape::XML::NodeEventVector const _repr_events = { }; -DocumentProperties* -DocumentProperties::create(Behavior::BehaviorFactory behavior_factory) +DocumentProperties & +DocumentProperties::getInstance() { - if (_instance) return _instance; - _instance = new DocumentProperties(behavior_factory); + if (_instance) return *_instance; + _instance = new DocumentProperties(); _instance->init(); - return _instance; + return *_instance; } void @@ -90,18 +90,17 @@ DocumentProperties::destroy() } } -DocumentProperties::DocumentProperties(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.documentoptions", SP_VERB_DIALOG_NAMEDVIEW), +DocumentProperties::DocumentProperties() + : UI::Widget::Panel ("", "dialogs.documentoptions", SP_VERB_DIALOG_NAMEDVIEW), _page_page(1, 1), _page_guides(1, 1), _page_snap(1, 1), _page_snap_dtls(1, 1), _page_grids(1, 1), _grids_button_new(_("_New"), _("Create new grid.")), _grids_button_remove(_("_Remove"), _("Remove selected grid.")), _prefs_path("dialogs.documentoptions") { - set_resizable (false); _tt.enable(); - get_vbox()->set_spacing (4); - get_vbox()->pack_start (_notebook, true, true); + _getContents()->set_spacing (4); + _getContents()->pack_start(_notebook, true, true); _notebook.append_page(_page_page, _("Page")); _notebook.append_page(_page_guides, _("Guides")); @@ -138,8 +137,6 @@ DocumentProperties::init() G_CALLBACK(on_deactivate_desktop), 0); show_all_children(); - - present(); } DocumentProperties::~DocumentProperties() diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 07382d524..b4e303325 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -24,7 +24,7 @@ #include "ui/widget/registered-widget.h" #include "ui/widget/registry.h" #include "ui/widget/tolerance-slider.h" -#include "dialog.h" +#include "ui/widget/panel.h" using namespace Inkscape::UI::Widget; @@ -35,10 +35,10 @@ namespace Inkscape { namespace UI { namespace Dialog { -class DocumentProperties : public Inkscape::UI::Dialog::Dialog { +class DocumentProperties : public UI::Widget::Panel { public: void update(); - static DocumentProperties *create(Behavior::BehaviorFactory behavior_factory); + static DocumentProperties &getInstance(); static void destroy(); sigc::connection _doc_replaced_connection; @@ -93,7 +93,7 @@ protected: Registry _wr; private: - DocumentProperties(Behavior::BehaviorFactory behavior_factory); + DocumentProperties(); virtual ~DocumentProperties(); // callback methods for buttons on grids page. diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 4e4efafb5..f95944c30 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -20,16 +20,14 @@ namespace Inkscape { namespace UI { namespace Dialog { -Export::Export(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.export", SP_VERB_FILE_EXPORT), +Export::Export() + : UI::Widget::Panel("", "dialogs.export", SP_VERB_FILE_EXPORT), _page_export(1, 1) { - // Top level vbox - Gtk::VBox *vbox = get_vbox(); - vbox->set_spacing(4); + _getContents()->set_spacing(4); // Notebook for individual transformations - vbox->pack_start(_notebook, true, true); + _getContents()->pack_start(_notebook, true, true); _notebook.append_page(_page_export, _("Export")); diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index c47c7c8cc..5d83ae5df 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -15,7 +15,7 @@ #include <gtkmm/notebook.h> #include <glibmm/i18n.h> -#include "dialog.h" +#include "ui/widget/panel.h" #include "ui/widget/notebook-page.h" using namespace Inkscape::UI::Widget; @@ -24,13 +24,12 @@ namespace Inkscape { namespace UI { namespace Dialog { -class Export : public Dialog { +class Export : public UI::Widget::Panel { public: - Export(Behavior::BehaviorFactory behavior_factory); + Export(); virtual ~Export(); - static Export *create(Behavior::BehaviorFactory behavior_factory) - { return new Export(behavior_factory); } + static Export& getInstance() { return *new Export(); } protected: Gtk::Notebook _notebook; diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp index 3a62cb144..d26e05f07 100644 --- a/src/ui/dialog/extension-editor.cpp +++ b/src/ui/dialog/extension-editor.cpp @@ -42,8 +42,8 @@ namespace Dialog { about the selected extension. A handler is set up so that when a new extension is selected, the notebooks are changed appropriately. */ -ExtensionEditor::ExtensionEditor(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.extensioneditor", SP_VERB_DIALOG_EXTENSIONEDITOR) +ExtensionEditor::ExtensionEditor() + : UI::Widget::Panel ("", "dialogs.extensioneditor", SP_VERB_DIALOG_EXTENSIONEDITOR) { _notebook_info.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); _notebook_help.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); @@ -53,7 +53,7 @@ ExtensionEditor::ExtensionEditor(Behavior::BehaviorFactory behavior_factory) Gtk::HBox* hbox_list_page = Gtk::manage(new Gtk::HBox()); hbox_list_page->set_border_width(12); hbox_list_page->set_spacing(12); - this->get_vbox()->add(*hbox_list_page); + _getContents()->add(*hbox_list_page); //Pagelist @@ -141,7 +141,7 @@ ExtensionEditor::on_pagelist_selection_changed (void) gchar title[500]; sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_EXTENSIONEDITOR), title); Glib::ustring utitle(title); - set_title(utitle + ": " + name); + // set_title(utitle + ": " + name); /* Clear the notbook pages */ _notebook_info.remove(); diff --git a/src/ui/dialog/extension-editor.h b/src/ui/dialog/extension-editor.h index 284a3651d..cfda36856 100644 --- a/src/ui/dialog/extension-editor.h +++ b/src/ui/dialog/extension-editor.h @@ -13,7 +13,7 @@ #ifndef INKSCAPE_UI_DIALOG_EXTENSION_EDITOR_H #define INKSCAPE_UI_DIALOG_EXTENSION_EDITOR_H -#include "dialog.h" +#include "ui/widget/panel.h" #include <glibmm/i18n.h> @@ -29,13 +29,12 @@ namespace Inkscape { namespace UI { namespace Dialog { -class ExtensionEditor : public Dialog { +class ExtensionEditor : public UI::Widget::Panel { public: - ExtensionEditor(Behavior::BehaviorFactory behavior_factory); + ExtensionEditor(); virtual ~ExtensionEditor(); - static ExtensionEditor *create(Behavior::BehaviorFactory behavior_factory) - { return new ExtensionEditor(behavior_factory); } + static ExtensionEditor &getInstance() { return *new ExtensionEditor(); } static void show_help (gchar const * extension_id); diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 85dc05c55..4f32d3d91 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -55,8 +55,8 @@ void on_selection_modified(Inkscape::Application *inkscape, } -FillAndStroke::FillAndStroke(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.fillstroke", SP_VERB_DIALOG_FILL_STROKE), +FillAndStroke::FillAndStroke() + : UI::Widget::Panel ("", "dialogs.fillstroke", SP_VERB_DIALOG_FILL_STROKE), _page_fill(1, 1, true, true), _page_stroke_paint(1, 1, true, true), _page_stroke_style(1, 1, true, true), @@ -70,10 +70,10 @@ FillAndStroke::FillAndStroke(Behavior::BehaviorFactory behavior_factory) _opacity_spin_button(_opacity_adjustment, 0.01, 1), _blocked(false) { - Gtk::VBox *vbox = get_vbox(); - vbox->set_spacing(0); + Gtk::Box *contents = _getContents(); + contents->set_spacing(0); - vbox->pack_start(_notebook, true, true); + contents->pack_start(_notebook, true, true); _notebook.append_page(_page_fill, _createPageTabLabel(_("Fill"), INKSCAPE_STOCK_PROPERTIES_FILL_PAGE)); _notebook.append_page(_page_stroke_paint, _createPageTabLabel(_("Stroke _paint"), INKSCAPE_STOCK_PROPERTIES_STROKE_PAINT_PAGE)); @@ -84,7 +84,7 @@ FillAndStroke::FillAndStroke(Behavior::BehaviorFactory behavior_factory) _layoutPageStrokeStyle(); // Filter Effects - vbox->pack_start(_fe_vbox, false, false, 2); + contents->pack_start(_fe_vbox, false, false, 2); _fe_alignment.set_padding(0, 0, 4, 0); _fe_alignment.add(_fe_cb); _fe_vbox.pack_start(_fe_alignment, false, false, 0); @@ -92,7 +92,7 @@ FillAndStroke::FillAndStroke(Behavior::BehaviorFactory behavior_factory) _fe_cb.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &Inkscape::UI::Dialog::FillAndStroke::_blendBlurValueChanged)); // Opacity - vbox->pack_start(_opacity_vbox, false, false, 2); + contents->pack_start(_opacity_vbox, false, false, 2); _opacity_label_box.pack_start(_opacity_label, false, false, 4); _opacity_vbox.pack_start(_opacity_label_box, false, false, 0); _opacity_vbox.pack_start(_opacity_hbox, false, false, 0); diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h index 8c27d6d0a..f2313adae 100644 --- a/src/ui/dialog/fill-and-stroke.h +++ b/src/ui/dialog/fill-and-stroke.h @@ -21,7 +21,7 @@ #include <gtkmm/spinbutton.h> #include <glibmm/i18n.h> -#include "dialog.h" +#include "ui/widget/panel.h" #include "ui/widget/notebook-page.h" #include "ui/widget/filter-effect-chooser.h" @@ -31,13 +31,12 @@ namespace Inkscape { namespace UI { namespace Dialog { -class FillAndStroke : public Dialog { +class FillAndStroke : public UI::Widget::Panel { public: - FillAndStroke(Behavior::BehaviorFactory behavior_factory); + FillAndStroke(); virtual ~FillAndStroke(); - static FillAndStroke *create(Behavior::BehaviorFactory behavior_factory) - { return new FillAndStroke(behavior_factory); } + static FillAndStroke &getInstance() { return *new FillAndStroke(); } void selectionChanged(Inkscape::Application *inkscape, Inkscape::Selection *selection); @@ -64,7 +63,7 @@ protected: Gtk::HScale _opacity_hscale; Gtk::SpinButton _opacity_spin_button; - Gtk::HBox& _createPageTabLabel(const Glib::ustring& label, + Gtk::HBox &_createPageTabLabel(const Glib::ustring &label, const char *label_image); SimpleFilterModifier _fe_cb; diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index ecaf3a11b..721a9e27e 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1840,8 +1840,8 @@ int FilterEffectsDialog::PrimitiveList::primitive_count() const /*** FilterEffectsDialog ***/ -FilterEffectsDialog::FilterEffectsDialog(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.filtereffects", SP_VERB_DIALOG_FILTER_EFFECTS), +FilterEffectsDialog::FilterEffectsDialog() + : UI::Widget::Panel("", "dialogs.filtereffects", SP_VERB_DIALOG_FILTER_EFFECTS), _filter_modifier(*this), _primitive_list(*this), _add_primitive_type(FPConverter), @@ -1861,7 +1861,7 @@ FilterEffectsDialog::FilterEffectsDialog(Behavior::BehaviorFactory behavior_fact Gtk::HBox* hb_prims = Gtk::manage(new Gtk::HBox); Gtk::Frame* fr_settings = Gtk::manage(new Gtk::Frame(_("<b>Effect parameters</b>"))); Gtk::Alignment* al_settings = Gtk::manage(new Gtk::Alignment); - get_vbox()->add(*hpaned); + _getContents()->add(*hpaned); hpaned->pack1(_filter_modifier); hpaned->pack2(_primitive_box); _primitive_box.pack_start(*sw_prims); @@ -1869,7 +1869,7 @@ FilterEffectsDialog::FilterEffectsDialog(Behavior::BehaviorFactory behavior_fact sw_prims->add(_primitive_list); hb_prims->pack_end(_add_primitive_type, false, false); hb_prims->pack_end(_add_primitive, false, false); - get_vbox()->pack_start(*fr_settings, false, false); + _getContents()->pack_start(*fr_settings, false, false); fr_settings->add(*al_settings); al_settings->add(_settings_box); diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index d1a5039e3..2cbd90f5f 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -25,7 +25,7 @@ #include <gtkmm/treeview.h> #include "attributes.h" -#include "dialog.h" +#include "ui/widget/panel.h" #include "sp-filter.h" #include "ui/widget/combo-enums.h" #include "ui/widget/spin-slider.h" @@ -38,14 +38,14 @@ namespace Dialog { class DualSpinButton; class MultiSpinButton; -class FilterEffectsDialog : public Dialog { +class FilterEffectsDialog : public UI::Widget::Panel { public: - FilterEffectsDialog(Behavior::BehaviorFactory behavior_factory); + FilterEffectsDialog(); ~FilterEffectsDialog(); - static FilterEffectsDialog *create(Behavior::BehaviorFactory behavior_factory) - { return new FilterEffectsDialog(behavior_factory); } + static FilterEffectsDialog &getInstance() + { return *new FilterEffectsDialog(); } void set_attrs_locked(const bool); private: @@ -198,7 +198,6 @@ private: std::auto_ptr<SignalObserver> _observer; }; - FilterEffectsDialog(); void init_settings_widgets(); // Handlers diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 0a0538c30..cfc1bfeb2 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -56,8 +56,8 @@ namespace Inkscape { namespace UI { namespace Dialog { -Find::Find(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.find", SP_VERB_DIALOG_FIND), +Find::Find() + : UI::Widget::Panel("", "dialogs.find", SP_VERB_DIALOG_FIND), _entry_text(_("_Text: "), _("Find objects by their text content (exact or partial match)")), _entry_id(_("_ID: "), _("Find objects by the value of the id attribute (exact or partial match)")), _entry_style(_("_Style: "), _("Find objects by the value of the style attribute (exact or partial match)")), @@ -83,35 +83,34 @@ Find::Find(Behavior::BehaviorFactory behavior_factory) _button_clear(_("_Clear"), _("Clear values")), _button_find(_("_Find"), _("Select objects matching all of the fields you filled in")) { - // Top level vbox - Gtk::VBox *vbox = get_vbox(); - vbox->set_spacing(4); + Gtk::Box *contents = _getContents(); + contents->set_spacing(4); - vbox->pack_start(_entry_text, true, true); - vbox->pack_start(_entry_id, true, true); - vbox->pack_start(_entry_style, true, true); - vbox->pack_start(_entry_attribute, true, true); - - vbox->pack_start(_check_all, true, true); - vbox->pack_start(_check_all_shapes, true, true); - vbox->pack_start(_check_rects, true, true); - vbox->pack_start(_check_ellipses, true, true); - vbox->pack_start(_check_stars, true, true); - vbox->pack_start(_check_spirals, true, true); - vbox->pack_start(_check_paths, true, true); - vbox->pack_start(_check_texts, true, true); - vbox->pack_start(_check_groups, true, true); - vbox->pack_start(_check_clones, true, true); - vbox->pack_start(_check_images, true, true); - vbox->pack_start(_check_offsets, true, true); - - vbox->pack_start(_check_search_selection, true, true); - vbox->pack_start(_check_search_layer, true, true); - vbox->pack_start(_check_include_hidden, true, true); - vbox->pack_start(_check_include_locked, true, true); - - vbox->pack_start(_button_clear, true, true); - vbox->pack_start(_button_find, true, true); + contents->pack_start(_entry_text, true, true); + contents->pack_start(_entry_id, true, true); + contents->pack_start(_entry_style, true, true); + contents->pack_start(_entry_attribute, true, true); + + contents->pack_start(_check_all, true, true); + contents->pack_start(_check_all_shapes, true, true); + contents->pack_start(_check_rects, true, true); + contents->pack_start(_check_ellipses, true, true); + contents->pack_start(_check_stars, true, true); + contents->pack_start(_check_spirals, true, true); + contents->pack_start(_check_paths, true, true); + contents->pack_start(_check_texts, true, true); + contents->pack_start(_check_groups, true, true); + contents->pack_start(_check_clones, true, true); + contents->pack_start(_check_images, true, true); + contents->pack_start(_check_offsets, true, true); + + contents->pack_start(_check_search_selection, true, true); + contents->pack_start(_check_search_layer, true, true); + contents->pack_start(_check_include_hidden, true, true); + contents->pack_start(_check_include_locked, true, true); + + contents->pack_start(_button_clear, true, true); + contents->pack_start(_button_find, true, true); // set signals to handle clicks _check_all.signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleAlltypes)); @@ -120,7 +119,7 @@ Find::Find(Behavior::BehaviorFactory behavior_factory) _button_find.signal_clicked().connect(sigc::mem_fun(*this, &Find::onFind)); _button_find.set_flags(Gtk::CAN_DEFAULT); - set_default (_button_find); // activatable by Enter + // set_default (_button_find); // activatable by Enter _entry_text.getEntry()->grab_focus(); show_all_children(); diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h index fb52b2c8e..2d79b37ad 100644 --- a/src/ui/dialog/find.h +++ b/src/ui/dialog/find.h @@ -14,7 +14,7 @@ #include <glibmm/i18n.h> -#include "dialog.h" +#include "ui/widget/panel.h" #include "ui/widget/button.h" #include "ui/widget/entry.h" #include <gtkmm/separator.h> @@ -57,13 +57,12 @@ namespace Inkscape { namespace UI { namespace Dialog { -class Find : public Dialog { +class Find : public UI::Widget::Panel { public: - Find(Behavior::BehaviorFactory behavior_factory); + Find(); virtual ~Find(); - static Find *create(Behavior::BehaviorFactory behavior_factory) - { return new Find(behavior_factory); } + static Find &getInstance() { return *new Find(); } protected: // Widgets: diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index 7d321b21b..7e76b5211 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -29,14 +29,13 @@ namespace UI { namespace Dialog { namespace Behavior { -FloatingBehavior::FloatingBehavior(Dialog& dialog) : +FloatingBehavior::FloatingBehavior(Dialog &dialog) : Behavior(dialog), _d (new Gtk::Dialog(_dialog._title)) { hide(); _d->set_has_separator(false); - signal_response().connect(sigc::mem_fun(_dialog, &Inkscape::UI::Dialog::Dialog::_onResponse)); signal_delete_event().connect(sigc::mem_fun(_dialog, &Inkscape::UI::Dialog::Dialog::_onDeleteEvent)); sp_transientize(GTK_WIDGET(_d->gobj())); @@ -49,12 +48,12 @@ FloatingBehavior::~FloatingBehavior() } Behavior * -FloatingBehavior::create(Dialog& dialog) +FloatingBehavior::create(Dialog &dialog) { return new FloatingBehavior(dialog); } -inline FloatingBehavior::operator Gtk::Widget&() { return *_d; } +inline FloatingBehavior::operator Gtk::Widget &() { return *_d; } inline GtkWidget *FloatingBehavior::gobj() { return GTK_WIDGET(_d->gobj()); } inline Gtk::VBox* FloatingBehavior::get_vbox() { return _d->get_vbox(); } inline void FloatingBehavior::present() { _d->present(); } @@ -65,27 +64,15 @@ inline void FloatingBehavior::resize(int width, int height) { _d-> inline void FloatingBehavior::move(int x, int y) { _d->move(x, y); } inline void FloatingBehavior::set_position(Gtk::WindowPosition position) { _d->set_position(position); } inline void FloatingBehavior::set_size_request(int width, int height) { _d->set_size_request(width, height); } -inline void FloatingBehavior::size_request(Gtk::Requisition& requisition) { _d->size_request(requisition); } -inline void FloatingBehavior::get_position(int& x, int& y) { _d->get_position(x, y); } -inline void FloatingBehavior::get_size(int& width, int& height) { _d->get_size(width, height); } +inline void FloatingBehavior::size_request(Gtk::Requisition &requisition) { _d->size_request(requisition); } +inline void FloatingBehavior::get_position(int &x, int &y) { _d->get_position(x, y); } +inline void FloatingBehavior::get_size(int &width, int &height) { _d->get_size(width, height); } inline void FloatingBehavior::set_title(Glib::ustring title) { _d->set_title(title); } inline void FloatingBehavior::set_sensitive(bool sensitive) { _d->set_sensitive(sensitive); } -void FloatingBehavior::set_response_sensitive(int response_id, bool setting) -{ _d->set_response_sensitive(response_id, setting); } - -Gtk::Button *FloatingBehavior::add_button(const Glib::ustring& button_text, int response_id) -{ return _d->add_button(button_text, response_id); } - -Gtk::Button *FloatingBehavior::add_button(const Gtk::StockID& stock_id, int response_id) -{ return _d->add_button(stock_id, response_id); } - -inline void FloatingBehavior::set_default_response(int response_id) { _d->set_default_response(response_id); } - Glib::SignalProxy0<void> FloatingBehavior::signal_show() { return _d->signal_show(); } Glib::SignalProxy0<void> FloatingBehavior::signal_hide() { return _d->signal_hide(); } Glib::SignalProxy1<bool, GdkEventAny *> FloatingBehavior::signal_delete_event () { return _d->signal_delete_event(); } -Glib::SignalProxy1<void, int> FloatingBehavior::signal_response () { return _d->signal_response(); } void diff --git a/src/ui/dialog/floating-behavior.h b/src/ui/dialog/floating-behavior.h index 354987dde..a7e6ef3a0 100644 --- a/src/ui/dialog/floating-behavior.h +++ b/src/ui/dialog/floating-behavior.h @@ -24,12 +24,12 @@ namespace Behavior { class FloatingBehavior : public Behavior { public: - static Behavior *create(Dialog& dialog); + static Behavior *create(Dialog &dialog); ~FloatingBehavior(); /** Gtk::Dialog methods */ - operator Gtk::Widget&(); + operator Gtk::Widget &(); GtkWidget *gobj(); void present(); Gtk::VBox *get_vbox(); @@ -40,21 +40,16 @@ public: void move(int x, int y); void set_position(Gtk::WindowPosition); void set_size_request(int width, int height); - void size_request(Gtk::Requisition& requisition); - void get_position(int& x, int& y); - void get_size(int& width, int& height); + void size_request(Gtk::Requisition &requisition); + void get_position(int &x, int &y); + void get_size(int& width, int &height); void set_title(Glib::ustring title); - void set_response_sensitive(int response_id, bool setting); void set_sensitive(bool sensitive); - Gtk::Button *add_button(const Glib::ustring& button_text, int response_id); - Gtk::Button *add_button(const Gtk::StockID& stock_id, int response_id); - void set_default_response(int response_id); /** Gtk::Dialog signal proxies */ Glib::SignalProxy0<void> signal_show(); Glib::SignalProxy0<void> signal_hide(); Glib::SignalProxy1<bool, GdkEventAny *> signal_delete_event(); - Glib::SignalProxy1<void, int> signal_response(); /** Custom signal handlers */ void onHideF12(); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 5d747807b..df2952f20 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -43,8 +43,8 @@ namespace Inkscape { namespace UI { namespace Dialog { -InkscapePreferences::InkscapePreferences(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.preferences", SP_VERB_DIALOG_DISPLAY), +InkscapePreferences::InkscapePreferences() + : UI::Widget::Panel ("", "dialogs.preferences", SP_VERB_DIALOG_DISPLAY), _max_dialog_width(0), _max_dialog_height(0), _current_page(0) @@ -52,19 +52,19 @@ InkscapePreferences::InkscapePreferences(Behavior::BehaviorFactory behavior_fact //get the width of a spinbutton Gtk::SpinButton* sb = new Gtk::SpinButton; sb->set_width_chars(6); - this->get_vbox()->add(*sb); - this->show_all_children(); - Gtk:: Requisition sreq; + _getContents()->add(*sb); + show_all_children(); + Gtk::Requisition sreq; sb->size_request(sreq); _sb_width = sreq.width; - this->get_vbox()->remove(*sb); + _getContents()->remove(*sb); delete sb; //Main HBox Gtk::HBox* hbox_list_page = Gtk::manage(new Gtk::HBox()); hbox_list_page->set_border_width(12); hbox_list_page->set_spacing(12); - this->get_vbox()->add(*hbox_list_page); + _getContents()->add(*hbox_list_page); //Pagelist Gtk::Frame* list_frame = Gtk::manage(new Gtk::Frame()); @@ -106,11 +106,13 @@ InkscapePreferences::InkscapePreferences(Behavior::BehaviorFactory behavior_fact initPageCMS(); initPageMisc(); + signalPresent().connect(sigc::mem_fun(*this, &InkscapePreferences::_presentPages)); + //calculate the size request for this dialog this->show_all_children(); _page_list.expand_all(); _page_list_model->foreach_iter(sigc::mem_fun(*this, &InkscapePreferences::SetMaxDialogSize)); - this->set_size_request(_max_dialog_width, _max_dialog_height); + _getContents()->set_size_request(_max_dialog_width, _max_dialog_height); _page_list.collapse_all(); } @@ -118,12 +120,6 @@ InkscapePreferences::~InkscapePreferences() { } -void InkscapePreferences::present() -{ - _page_list_model->foreach_iter(sigc::mem_fun(*this, &InkscapePreferences::PresentPage)); - Dialog::present(); -} - Gtk::TreeModel::iterator InkscapePreferences::AddPage(DialogPage& p, Glib::ustring title, int id) { return AddPage(p, title, Gtk::TreeModel::iterator() , id); @@ -871,6 +867,11 @@ void InkscapePreferences::on_pagelist_selection_changed() } } +void InkscapePreferences::_presentPages() +{ + _page_list_model->foreach_iter(sigc::mem_fun(*this, &InkscapePreferences::PresentPage)); +} + } // namespace Dialog } // namespace UI } // namespace Inkscape diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 12a73d017..f5853c38b 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -29,7 +29,7 @@ #include <sigc++/sigc++.h> #include <glibmm/i18n.h> -#include "dialog.h" +#include "ui/widget/panel.h" // UPDATE THIS IF YOU'RE ADDING PREFS PAGES. // Otherwise the commands that open the dialog with the new page will fail. @@ -74,14 +74,11 @@ namespace Inkscape { namespace UI { namespace Dialog { -class InkscapePreferences : public Dialog { +class InkscapePreferences : public UI::Widget::Panel { public: virtual ~InkscapePreferences(); - static InkscapePreferences *create(Behavior::BehaviorFactory behavior_factory) - { return new InkscapePreferences(behavior_factory); } - - void present(); + static InkscapePreferences &getInstance() { return *new InkscapePreferences(); } protected: Gtk::Frame _page_frame; @@ -209,8 +206,10 @@ protected: void initPageCMS(); void initPageMisc(); + void _presentPages(); + private: - InkscapePreferences(Behavior::BehaviorFactory behavior_factory); + InkscapePreferences(); InkscapePreferences(InkscapePreferences const &d); InkscapePreferences operator=(InkscapePreferences const &d); }; diff --git a/src/ui/dialog/layer-editor.cpp b/src/ui/dialog/layer-editor.cpp index cb4b8a0b4..2b596e821 100644 --- a/src/ui/dialog/layer-editor.cpp +++ b/src/ui/dialog/layer-editor.cpp @@ -20,8 +20,9 @@ namespace Inkscape { namespace UI { namespace Dialog { -LayerEditor::LayerEditor(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.layers", SP_VERB_NONE /*FIXME*/) + +LayerEditor::LayerEditor() + : UI::Widget::Panel("", "dialogs.layers", SP_VERB_NONE) { // TODO: Insert widgets diff --git a/src/ui/dialog/layer-editor.h b/src/ui/dialog/layer-editor.h index 3c25c7bc0..0bb98dabf 100644 --- a/src/ui/dialog/layer-editor.h +++ b/src/ui/dialog/layer-editor.h @@ -12,7 +12,7 @@ #ifndef INKSCAPE_UI_DIALOG_LAYER_EDITOR_H #define INKSCAPE_UI_DIALOG_LAYER_EDITOR_H -#include "dialog.h" +#include "ui/widget/panel.h" #include <glibmm/i18n.h> @@ -20,13 +20,14 @@ namespace Inkscape { namespace UI { namespace Dialog { -class LayerEditor : public Dialog { +class LayerEditor : public UI::Widget::Panel { public: - LayerEditor(Behavior::BehaviorFactory behavior_factory); + LayerEditor(); virtual ~LayerEditor(); - static LayerEditor *create(Behavior::BehaviorFactory behavior_factory) - { return new LayerEditor(behavior_factory); } + static int get_verb(); + + static LayerEditor &getInstance() { return *new LayerEditor(); } protected: diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index ee12e652a..6ec078ce0 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -62,12 +62,12 @@ static void lpeeditor_desktop_change(Inkscape::Application*, SPDesktop* desktop, } - /*####################### * LivePathEffectEditor */ -LivePathEffectEditor::LivePathEffectEditor(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT), + +LivePathEffectEditor::LivePathEffectEditor() + : UI::Widget::Panel("", "dialogs.livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT), combo_effecttype(Inkscape::LivePathEffect::LPETypeConverter), button_apply(_("_Apply"), _("Apply chosen effect to selection")), button_remove(_("_Remove"), _("Remove effect from selection")), @@ -77,9 +77,8 @@ LivePathEffectEditor::LivePathEffectEditor(Behavior::BehaviorFactory behavior_fa effectcontrol_frame(_("Current effect")), current_desktop(NULL) { - // Top level vbox - Gtk::VBox *vbox = get_vbox(); - vbox->set_spacing(4); + Gtk::Box *contents = _getContents(); + contents->set_spacing(4); effectapplication_hbox.set_spacing(4); effectcontrol_vbox.set_spacing(4); @@ -92,8 +91,8 @@ LivePathEffectEditor::LivePathEffectEditor(Behavior::BehaviorFactory behavior_fa effectcontrol_vbox.pack_end(button_remove, true, true); effectcontrol_frame.add(effectcontrol_vbox); - vbox->pack_start(effectapplication_frame, true, true); - vbox->pack_start(effectcontrol_frame, true, true); + contents->pack_start(effectapplication_frame, true, true); + contents->pack_start(effectcontrol_frame, true, true); // connect callback functions to buttons button_apply.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onApply)); diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index 5a40cfd30..2ec1f9d14 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -12,7 +12,7 @@ #ifndef INKSCAPE_UI_DIALOG_LIVE_PATH_EFFECT_H #define INKSCAPE_UI_DIALOG_LIVE_PATH_EFFECT_H -#include "dialog.h" +#include "ui/widget/panel.h" #include "ui/widget/button.h" #include <gtkmm/label.h> @@ -28,13 +28,12 @@ namespace Inkscape { namespace UI { namespace Dialog { -class LivePathEffectEditor : public Dialog { +class LivePathEffectEditor : public UI::Widget::Panel { public: - LivePathEffectEditor(Behavior::BehaviorFactory behavior_factory); + LivePathEffectEditor(); virtual ~LivePathEffectEditor(); - static LivePathEffectEditor *create(Behavior::BehaviorFactory behavior_factory) - { return new LivePathEffectEditor(behavior_factory); } + static LivePathEffectEditor &getInstance() { return *new LivePathEffectEditor(); } void onSelectionChanged(Inkscape::Selection *sel); void setDesktop(SPDesktop *desktop); diff --git a/src/ui/dialog/memory.cpp b/src/ui/dialog/memory.cpp index eb61aaf9f..1931976d6 100644 --- a/src/ui/dialog/memory.cpp +++ b/src/ui/dialog/memory.cpp @@ -203,11 +203,11 @@ void Memory::Private::stop_update_task() { update_task.disconnect(); } -Memory::Memory(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.memory", SP_VERB_HELP_MEMORY, _("Recalculate")), +Memory::Memory() + : UI::Widget::Panel ("", "dialogs.memory", SP_VERB_HELP_MEMORY, _("Recalculate")), _private(*(new Memory::Private())) { - get_vbox()->add(_private.view); + _getContents()->add(_private.view); _private.update(); diff --git a/src/ui/dialog/memory.h b/src/ui/dialog/memory.h index 0fe7f87c5..6f832f3e1 100644 --- a/src/ui/dialog/memory.h +++ b/src/ui/dialog/memory.h @@ -12,19 +12,18 @@ #ifndef SEEN_INKSCAPE_UI_DIALOG_MEMORY_H #define SEEN_INKSCAPE_UI_DIALOG_MEMORY_H -#include "dialog.h" +#include "ui/widget/panel.h" namespace Inkscape { namespace UI { namespace Dialog { -class Memory : public Dialog { +class Memory : public UI::Widget::Panel { public: - Memory(Behavior::BehaviorFactory behavior_factory); + Memory(); ~Memory(); - static Memory *create(Behavior::BehaviorFactory behavior_factory) - { return new Memory(behavior_factory); } + static Memory &getInstance() { return *new Memory(); } protected: void _apply(); diff --git a/src/ui/dialog/messages.cpp b/src/ui/dialog/messages.cpp index 9e78903c9..43f80ab65 100644 --- a/src/ui/dialog/messages.cpp +++ b/src/ui/dialog/messages.cpp @@ -45,10 +45,10 @@ void Messages::clear() /** * Constructor */ -Messages::Messages(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.messages", SP_VERB_DIALOG_DEBUG) +Messages::Messages() + : UI::Widget::Panel("", "dialogs.messages", SP_VERB_DIALOG_DEBUG) { - Gtk::VBox *mainVBox = get_vbox(); + Gtk::Box *contents = _getContents(); //## Add a menu for clear() menuBar.items().push_back( Gtk::Menu_Helpers::MenuElem(_("_File"), fileMenu) ); @@ -58,14 +58,14 @@ Messages::Messages(Behavior::BehaviorFactory behavior_factory) sigc::mem_fun(*this, &Messages::captureLogMessages) ) ); fileMenu.items().push_back( Gtk::Menu_Helpers::MenuElem(_("Release log messages"), sigc::mem_fun(*this, &Messages::releaseLogMessages) ) ); - mainVBox->pack_start(menuBar, Gtk::PACK_SHRINK); + contents->pack_start(menuBar, Gtk::PACK_SHRINK); //### Set up the text widget messageText.set_editable(false); textScroll.add(messageText); textScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - mainVBox->pack_start(textScroll); + contents->pack_start(textScroll); // sick of this thing shrinking too much set_size_request(400, 300); diff --git a/src/ui/dialog/messages.h b/src/ui/dialog/messages.h index 85a7c4f0f..8dcb718cc 100644 --- a/src/ui/dialog/messages.h +++ b/src/ui/dialog/messages.h @@ -18,7 +18,6 @@ #define INKSCAPE_UI_DIALOG_MESSAGES_H #include <gtkmm/box.h> -#include <gtkmm/dialog.h> #include <gtkmm/textview.h> #include <gtkmm/button.h> #include <gtkmm/menubar.h> @@ -27,19 +26,18 @@ #include <glibmm/i18n.h> -#include "dialog.h" +#include "ui/widget/panel.h" namespace Inkscape { namespace UI { namespace Dialog { -class Messages : public Dialog { +class Messages : public UI::Widget::Panel { public: - Messages(Behavior::BehaviorFactory behavior_factory); + Messages(); virtual ~Messages(); - static Messages *create(Behavior::BehaviorFactory behavior_factory) - { return new Messages(behavior_factory); } + static Messages &getInstance() { return *new Messages(); } /** * Clear all information from the dialog diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h new file mode 100644 index 000000000..7416e96cc --- /dev/null +++ b/src/ui/dialog/panel-dialog.h @@ -0,0 +1,116 @@ +/** + * \brief A panel holding dialog + * + * Authors: + * Gustav Broberg <broberg@kth.se> + * + * Copyright (C) 2007 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_PANEL_DIALOG_H +#define INKSCAPE_PANEL_DIALOG_H + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "verbs.h" + +#include "dialog.h" +#include "dialogs/swatches.h" +#include "ui/dialog/undo-history.h" +#include "prefs-utils.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +struct PanelDialogBase { + virtual void present() =0; + virtual Panel &getPanel() =0; + virtual ~PanelDialogBase() {} +}; + +template <typename Behavior> +class PanelDialog : public PanelDialogBase, public Inkscape::UI::Dialog::Dialog { + +public: + PanelDialog(Panel &contents, char const *prefs_path, int const verb_num, + Glib::ustring const &apply_label); + + virtual ~PanelDialog() {} + + template <typename T> + static PanelDialog<Behavior> *create(); + + virtual void present(); + + Panel &getPanel() { return _panel; } + +private: + Panel &_panel; + + PanelDialog(); // no constructor without params + PanelDialog(PanelDialog<Behavior> const &d); // no copy + PanelDialog<Behavior>& operator=(PanelDialog<Behavior> const &d); // no assign +}; + + + +template <typename B> +PanelDialog<B>::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) +{ + 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); + + 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(); +} + +template <typename B> template <typename P> +PanelDialog<B> * +PanelDialog<B>::create() +{ + Panel &panel = P::getInstance(); + return new PanelDialog<B>(panel, panel.getPrefsPath(), + panel.getVerb(), panel.getApplyLabel()); +} + +template <typename B> +void +PanelDialog<B>::present() +{ + Dialog::present(); +} + +} // namespace Dialog +} // namespace UI +} // namespace Inkscape + +#endif //INKSCAPE_PANEL_DIALOG_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/scriptdialog.cpp b/src/ui/dialog/scriptdialog.cpp index 304362f60..a56e74df3 100644 --- a/src/ui/dialog/scriptdialog.cpp +++ b/src/ui/dialog/scriptdialog.cpp @@ -43,7 +43,7 @@ class ScriptDialogImpl : public ScriptDialog /** * Constructor */ - ScriptDialogImpl(Behavior::BehaviorFactory behavior_factory); + ScriptDialogImpl(); /** * Destructor @@ -192,10 +192,10 @@ void ScriptDialogImpl::executePerl() /** * Constructor */ -ScriptDialogImpl::ScriptDialogImpl(Behavior::BehaviorFactory behavior_factory) : - ScriptDialog(behavior_factory) +ScriptDialogImpl::ScriptDialogImpl() : + ScriptDialog() { - Gtk::VBox *mainVBox = get_vbox(); + Gtk::Box *contents = _getContents(); //## Add a menu for clear() menuBar.items().push_back( Gtk::Menu_Helpers::MenuElem(_("_File"), fileMenu) ); @@ -209,7 +209,7 @@ ScriptDialogImpl::ScriptDialogImpl(Behavior::BehaviorFactory behavior_factory) : fileMenu.items().push_back( Gtk::Menu_Helpers::MenuElem(_("_Execute Perl"), sigc::mem_fun(*this, &ScriptDialogImpl::executePerl) ) ); #endif - mainVBox->pack_start(menuBar, Gtk::PACK_SHRINK); + contents->pack_start(menuBar, Gtk::PACK_SHRINK); //### Set up the script field scriptText.set_editable(true); @@ -219,7 +219,7 @@ ScriptDialogImpl::ScriptDialogImpl(Behavior::BehaviorFactory behavior_factory) : scriptTextFrame.set_label(_("Script")); scriptTextFrame.set_shadow_type(Gtk::SHADOW_NONE); scriptTextFrame.add(scriptTextScroll); - mainVBox->pack_start(scriptTextFrame); + contents->pack_start(scriptTextFrame); //### Set up the output field outputText.set_editable(true); @@ -229,7 +229,7 @@ ScriptDialogImpl::ScriptDialogImpl(Behavior::BehaviorFactory behavior_factory) : outputTextFrame.set_label(_("Output")); outputTextFrame.set_shadow_type(Gtk::SHADOW_NONE); outputTextFrame.add(outputTextScroll); - mainVBox->pack_start(outputTextFrame); + contents->pack_start(outputTextFrame); //### Set up the error field errorText.set_editable(true); @@ -239,7 +239,7 @@ ScriptDialogImpl::ScriptDialogImpl(Behavior::BehaviorFactory behavior_factory) : errorTextFrame.set_label(_("Errors")); errorTextFrame.set_shadow_type(Gtk::SHADOW_NONE); errorTextFrame.add(errorTextScroll); - mainVBox->pack_start(errorTextFrame); + contents->pack_start(errorTextFrame); // sick of this thing shrinking too much set_size_request(350, 400); @@ -250,10 +250,10 @@ ScriptDialogImpl::ScriptDialogImpl(Behavior::BehaviorFactory behavior_factory) : /** * Factory method. Use this to create a new ScriptDialog */ -ScriptDialog *ScriptDialog::create(Behavior::BehaviorFactory behavior_factory) +ScriptDialog &ScriptDialog::getInstance() { - ScriptDialog *dialog = new ScriptDialogImpl(behavior_factory); - return dialog; + ScriptDialog *dialog = new ScriptDialogImpl(); + return *dialog; } diff --git a/src/ui/dialog/scriptdialog.h b/src/ui/dialog/scriptdialog.h index 00680d431..780d44a92 100644 --- a/src/ui/dialog/scriptdialog.h +++ b/src/ui/dialog/scriptdialog.h @@ -14,7 +14,7 @@ */ -#include "dialog.h" +#include "ui/widget/panel.h" #include "verbs.h" namespace Inkscape { @@ -25,7 +25,7 @@ namespace Dialog { /** * A script editor, loader, and executor */ -class ScriptDialog : public Dialog +class ScriptDialog : public UI::Widget::Panel { public: @@ -34,15 +34,15 @@ class ScriptDialog : public Dialog /** * Constructor */ - ScriptDialog(Behavior::BehaviorFactory behavior_factory) : - Dialog (behavior_factory, "dialogs.script", SP_VERB_DIALOG_SCRIPT) + ScriptDialog() : + UI::Widget::Panel("", "dialogs.script", SP_VERB_DIALOG_SCRIPT) {} /** * Factory method */ - static ScriptDialog *create(Behavior::BehaviorFactory behavior_factory); + static ScriptDialog &getInstance(); /** * Destructor diff --git a/src/ui/dialog/text-properties.cpp b/src/ui/dialog/text-properties.cpp index e6194ab56..5ad08f01f 100644 --- a/src/ui/dialog/text-properties.cpp +++ b/src/ui/dialog/text-properties.cpp @@ -20,23 +20,22 @@ namespace Inkscape { namespace UI { namespace Dialog { -TextProperties::TextProperties(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.textandfont", SP_VERB_DIALOG_TEXT), +TextProperties::TextProperties() + : UI::Widget::Panel("", "dialogs.textandfont", SP_VERB_DIALOG_TEXT), _page_font(1, 1), _page_text(1, 1) { - // Top level vbox - Gtk::VBox *vbox = get_vbox(); - vbox->set_spacing(4); + Gtk::Box *contents = _getContents(); + + contents->set_spacing(4); // Notebook for individual transformations - vbox->pack_start(_notebook, true, true); + contents->pack_start(_notebook, true, true); // TODO: Insert widgets _notebook.append_page(_page_font, _("Font")); _notebook.append_page(_page_text, _("Text")); - set_resizable (true); set_size_request(450, 300); show_all_children(); diff --git a/src/ui/dialog/text-properties.h b/src/ui/dialog/text-properties.h index 393ca63b2..f6ef0d861 100644 --- a/src/ui/dialog/text-properties.h +++ b/src/ui/dialog/text-properties.h @@ -15,7 +15,7 @@ #include <gtkmm/notebook.h> #include <glibmm/i18n.h> -#include "dialog.h" +#include "ui/widget/panel.h" #include "ui/widget/notebook-page.h" using namespace Inkscape::UI::Widget; @@ -24,13 +24,14 @@ namespace Inkscape { namespace UI { namespace Dialog { -class TextProperties : public Dialog { +class TextProperties : public UI::Widget::Panel { public: - TextProperties(Behavior::BehaviorFactory behavior_factory); + TextProperties(); virtual ~TextProperties(); - static TextProperties *create(Behavior::BehaviorFactory behavior_factory) - { return new TextProperties(behavior_factory); } + static int get_verb(); + + static TextProperties &getInstance() { return *new TextProperties(); } protected: Gtk::Notebook _notebook; diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index b7602b36a..84d7978fb 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -50,7 +50,7 @@ class TraceDialogImpl : public TraceDialog /** * Constructor */ - TraceDialogImpl(Behavior::BehaviorFactory behavior_factory); + TraceDialogImpl(); /** * Destructor @@ -376,11 +376,11 @@ void TraceDialogImpl::responseCallback(int response_id) /** * Constructor */ -TraceDialogImpl::TraceDialogImpl(Behavior::BehaviorFactory behavior_factory) : - TraceDialog(behavior_factory) +TraceDialogImpl::TraceDialogImpl() : + TraceDialog() { - Gtk::VBox *mainVBox = get_vbox(); + Gtk::Box *contents = _getContents(); #define MARGIN 2 //#### begin left panel @@ -664,32 +664,31 @@ TraceDialogImpl::TraceDialogImpl(Behavior::BehaviorFactory behavior_factory) : //#### Global stuff - mainVBox->pack_start(mainHBox); + contents->pack_start(mainHBox); //## The OK button - mainCancelButton = add_button(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL); - if (mainCancelButton) - { - tips.set_tip((*mainCancelButton), _("Abort a trace in progress")); - mainCancelButton->set_sensitive(false); - } - mainOkButton = add_button(Gtk::Stock::OK, GTK_RESPONSE_OK); + mainCancelButton = addResponseButton(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL); + if (mainCancelButton) { + tips.set_tip((*mainCancelButton), _("Abort a trace in progress")); + mainCancelButton->set_sensitive(false); + } + mainOkButton = addResponseButton(Gtk::Stock::OK, GTK_RESPONSE_OK); tips.set_tip((*mainOkButton), _("Execute the trace")); show_all_children(); //## Connect the signal - signal_response().connect( - sigc::mem_fun(*this, &TraceDialogImpl::responseCallback) ); + signalResponse().connect( + sigc::mem_fun(*this, &TraceDialogImpl::responseCallback)); } /** * Factory method. Use this to create a new TraceDialog */ -TraceDialog *TraceDialog::create(Behavior::BehaviorFactory behavior_factory) +TraceDialog &TraceDialog::getInstance() { - TraceDialog *dialog = new TraceDialogImpl(behavior_factory); - return dialog; + TraceDialog *dialog = new TraceDialogImpl(); + return *dialog; } diff --git a/src/ui/dialog/tracedialog.h b/src/ui/dialog/tracedialog.h index 0e352ce10..0933aee3b 100644 --- a/src/ui/dialog/tracedialog.h +++ b/src/ui/dialog/tracedialog.h @@ -15,7 +15,7 @@ #include "verbs.h" -#include "dialog.h" +#include "ui/widget/panel.h" namespace Inkscape { namespace UI { @@ -25,24 +25,23 @@ namespace Dialog { /** * A dialog that displays log messages */ -class TraceDialog : public Dialog +class TraceDialog : public UI::Widget::Panel { public: - /** * Constructor */ - TraceDialog(Behavior::BehaviorFactory behavior_factory) : - Dialog (behavior_factory, "dialogs.trace", SP_VERB_SELECTION_TRACE) - {} + TraceDialog() : + UI::Widget::Panel("", "dialogs.trace", SP_VERB_SELECTION_TRACE) + {} /** * Factory method */ - static TraceDialog *create(Behavior::BehaviorFactory behavior_factory); + static TraceDialog &getInstance(); /** * Destructor diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 3110289d2..9e6cd7f50 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -15,6 +15,7 @@ #endif #include <gtkmm/stock.h> +#include <gtkmm/dialog.h> #include "document.h" #include "desktop-handles.h" @@ -70,8 +71,8 @@ void on_selection_modified( Inkscape::Application */*inkscape*/, * we use the ScalarUnit class for this. * */ -Transformation::Transformation(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.transformation", SP_VERB_DIALOG_TRANSFORM), +Transformation::Transformation() + : UI::Widget::Panel ("", "dialogs.transformation", SP_VERB_DIALOG_TRANSFORM), _page_move (4, 2), _page_scale (4, 2), _page_rotate (4, 2), @@ -105,12 +106,12 @@ Transformation::Transformation(Behavior::BehaviorFactory behavior_factory) _check_replace_matrix (_("Edit c_urrent matrix"), _("Edit the current transform= matrix; otherwise, post-multiply transform= by this matrix")) { - // Top level vbox - Gtk::VBox *vbox = get_vbox(); - vbox->set_spacing(0); + Gtk::Box *contents = _getContents(); + + contents->set_spacing(0); // Notebook for individual transformations - vbox->pack_start(_notebook, true, true); + contents->pack_start(_notebook, true, true); _notebook.append_page(_page_move, _("_Move"), true); layoutPageMove(); @@ -130,7 +131,7 @@ Transformation::Transformation(Behavior::BehaviorFactory behavior_factory) _notebook.signal_switch_page().connect(sigc::mem_fun(*this, &Transformation::onSwitchPage)); // Apply separately - vbox->pack_start(_check_apply_separately, true, true); + contents->pack_start(_check_apply_separately, true, true); _check_apply_separately.set_active(prefs_get_int_attribute_limited ("dialogs.transformation", "applyseparately", 0, 0, 1)); _check_apply_separately.signal_toggled().connect(sigc::mem_fun(*this, &Transformation::onApplySeparatelyToggled)); @@ -145,18 +146,17 @@ Transformation::Transformation(Behavior::BehaviorFactory behavior_factory) updateSelection(PAGE_MOVE, _getSelection()); - resetButton = add_button(Gtk::Stock::CLEAR, 0); + resetButton = addResponseButton(Gtk::Stock::CLEAR, 0); if (resetButton) { - tooltips.set_tip((*resetButton), _("Reset the values on the current tab to defaults")); + _tooltips.set_tip((*resetButton), _("Reset the values on the current tab to defaults")); resetButton->set_sensitive(true); resetButton->signal_clicked().connect(sigc::mem_fun(*this, &Transformation::onClear)); } - applyButton = add_button(Gtk::Stock::APPLY, Gtk::RESPONSE_APPLY); + applyButton = addResponseButton(Gtk::Stock::APPLY, Gtk::RESPONSE_APPLY); if (applyButton) { - tooltips.set_tip((*applyButton), _("Apply transformation to selection")); + _tooltips.set_tip((*applyButton), _("Apply transformation to selection")); applyButton->set_sensitive(false); - set_default (*applyButton); // activable by Enter in spinbuttons } // Connect to the global selection changed & modified signals @@ -172,7 +172,6 @@ Transformation::~Transformation() } - /*######################################################################## # U T I L I T Y ########################################################################*/ @@ -439,8 +438,8 @@ Transformation::updateSelection(PageType page, Inkscape::Selection *selection) } } - set_response_sensitive(Gtk::RESPONSE_APPLY, - selection && !selection->isEmpty()); + setResponseSensitive(Gtk::RESPONSE_APPLY, + selection && !selection->isEmpty()); } void @@ -579,7 +578,7 @@ Transformation::_apply() } //Let's play with never turning this off - //set_response_sensitive(Gtk::RESPONSE_APPLY, false); + //setResponseSensitive(Gtk::RESPONSE_APPLY, false); } void @@ -775,7 +774,7 @@ Transformation::applyPageTransform(Inkscape::Selection *selection) void Transformation::onMoveValueChanged() { - set_response_sensitive(Gtk::RESPONSE_APPLY, true); + setResponseSensitive(Gtk::RESPONSE_APPLY, true); } void @@ -805,7 +804,7 @@ Transformation::onMoveRelativeToggled() } } - set_response_sensitive(Gtk::RESPONSE_APPLY, true); + setResponseSensitive(Gtk::RESPONSE_APPLY, true); } void @@ -816,7 +815,7 @@ Transformation::onScaleXValueChanged() return; } - set_response_sensitive(Gtk::RESPONSE_APPLY, true); + setResponseSensitive(Gtk::RESPONSE_APPLY, true); if (_check_scale_proportional.get_active()) { if (!_units_scale.isAbsolute()) { // percentage, just copy over @@ -836,7 +835,7 @@ Transformation::onScaleYValueChanged() return; } - set_response_sensitive(Gtk::RESPONSE_APPLY, true); + setResponseSensitive(Gtk::RESPONSE_APPLY, true); if (_check_scale_proportional.get_active()) { if (!_units_scale.isAbsolute()) { // percentage, just copy over @@ -851,13 +850,13 @@ Transformation::onScaleYValueChanged() void Transformation::onRotateValueChanged() { - set_response_sensitive(Gtk::RESPONSE_APPLY, true); + setResponseSensitive(Gtk::RESPONSE_APPLY, true); } void Transformation::onSkewValueChanged() { - set_response_sensitive(Gtk::RESPONSE_APPLY, true); + setResponseSensitive(Gtk::RESPONSE_APPLY, true); } void @@ -876,7 +875,7 @@ Transformation::onTransformValueChanged() // a, b, c, d, e ,f); */ - set_response_sensitive(Gtk::RESPONSE_APPLY, true); + setResponseSensitive(Gtk::RESPONSE_APPLY, true); } void diff --git a/src/ui/dialog/transformation.h b/src/ui/dialog/transformation.h index 361b30a04..e64353f5a 100644 --- a/src/ui/dialog/transformation.h +++ b/src/ui/dialog/transformation.h @@ -19,7 +19,7 @@ -#include "dialog.h" +#include "ui/widget/panel.h" #include "application/application.h" #include "ui/widget/notebook-page.h" #include "ui/widget/scalar-unit.h" @@ -38,7 +38,7 @@ namespace Dialog { -class Transformation : public Dialog +class Transformation : public UI::Widget::Panel { public: @@ -46,19 +46,18 @@ public: /** * Create a new transform */ - Transformation(Behavior::BehaviorFactory behavior_factory); + Transformation(); /** * Cleanup */ virtual ~Transformation(); - /** * Factory method. Create an instance of this class/interface */ - static Transformation *create(Behavior::BehaviorFactory behavior_factory) - { return new Transformation(behavior_factory); } + static Transformation &getInstance() + { return *new Transformation(); } /** diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index 344c446e0..b808e57de 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -102,12 +102,12 @@ static void on_document_replaced(SPDesktop* desktop, SPDocument*); static void on_activate_desktop(Inkscape::Application*, SPDesktop* desktop, void*); static void on_deactivate_desktop(Inkscape::Application*, SPDesktop* desktop, void*); -UndoHistory* -UndoHistory::create(Behavior::BehaviorFactory behavior_factory) +UndoHistory& UndoHistory::getInstance() { - if (_instance) return _instance; - _instance = new UndoHistory(behavior_factory); - return _instance; + if (!_instance) + _instance = new UndoHistory(); + + return *_instance; } void @@ -131,19 +131,19 @@ UndoHistory::setDesktop(SPDesktop* desktop) _callback_connections[EventLog::CALLB_SELECTION_CHANGE].block(false); } -UndoHistory::UndoHistory(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.undo-history", SP_VERB_DIALOG_UNDO_HISTORY), +UndoHistory::UndoHistory() + : UI::Widget::Panel ("", "dialogs.undo-history", SP_VERB_DIALOG_UNDO_HISTORY), _desktop (SP_ACTIVE_DESKTOP), _document (SP_ACTIVE_DOCUMENT), _event_log (_desktop ? _desktop->event_log : NULL), _columns (_event_log ? &_event_log->getColumns() : NULL), _event_list_selection (_event_list_view.get_selection()) { - if( !_document || !_event_log || !_columns ) return; + if ( !_document || !_event_log || !_columns ) return; set_size_request(300, 200); - get_vbox()->pack_start(_scrolled_window); + _getContents()->pack_start(_scrolled_window); _scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); _event_list_store = _event_log->getEventListStore(); diff --git a/src/ui/dialog/undo-history.h b/src/ui/dialog/undo-history.h index 7d7426675..e883ec49c 100644 --- a/src/ui/dialog/undo-history.h +++ b/src/ui/dialog/undo-history.h @@ -2,7 +2,7 @@ * Undo History dialog * * \brief A dialog for presenting an event log of commited, undone and redone events. Allows the - * user to undo and redo multiple events in a more convinient way than repateaded ctrl-z, + * user to undo and redo multiple events in a more convenient way than repateaded ctrl-z, * ctrl-shift-z. * * @@ -30,9 +30,9 @@ #include <sstream> #include "desktop.h" -#include "dialog.h" #include "event-log.h" +#include "ui/widget/panel.h" #include "widgets/icon.h" namespace Inkscape { @@ -116,11 +116,11 @@ private: * */ -class UndoHistory : public Dialog { +class UndoHistory : public Widget::Panel { public: virtual ~UndoHistory(); - static UndoHistory *create(Behavior::BehaviorFactory behavior_factory); + static UndoHistory &getInstance(); void setDesktop(SPDesktop* desktop); sigc::connection _document_replaced_connection; @@ -146,7 +146,7 @@ protected: void _onCollapseEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path); private: - UndoHistory(Behavior::BehaviorFactory behavior_factory); + UndoHistory(); // no default constructor, noncopyable, nonassignable UndoHistory(UndoHistory const &d); diff --git a/src/ui/dialog/xml-editor.cpp b/src/ui/dialog/xml-editor.cpp index 53f3b4c2c..7411bc7dc 100644 --- a/src/ui/dialog/xml-editor.cpp +++ b/src/ui/dialog/xml-editor.cpp @@ -20,8 +20,8 @@ namespace Inkscape { namespace UI { namespace Dialog { -XmlEditor::XmlEditor(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.xml", SP_VERB_DIALOG_XML_EDITOR) +XmlEditor::XmlEditor() + : UI::Widget::Panel("", "dialogs.xml", SP_VERB_DIALOG_XML_EDITOR) { // TODO: Insert widgets diff --git a/src/ui/dialog/xml-editor.h b/src/ui/dialog/xml-editor.h index 65f25423f..89df6fbc1 100644 --- a/src/ui/dialog/xml-editor.h +++ b/src/ui/dialog/xml-editor.h @@ -12,7 +12,7 @@ #ifndef INKSCAPE_DIALOG_XML_EDITOR_H #define INKSCAPE_DIALOG_XML_EDITOR_H -#include "dialog.h" +#include "ui/widget/panel.h" #include <glibmm/i18n.h> @@ -20,13 +20,12 @@ namespace Inkscape { namespace UI { namespace Dialog { -class XmlEditor : public Dialog { +class XmlEditor : public UI::Widget::Panel { public: - XmlEditor(Behavior::BehaviorFactory behavior_factory); + XmlEditor(); virtual ~XmlEditor(); - static XmlEditor *create(Behavior::BehaviorFactory behavior_factory) - { return new XmlEditor(behavior_factory); } + static XmlEditor &getInstance() { return *new XmlEditor(); } protected: |
