From 5caa6ff4dfb7b538555d60fa2732272bf8b9828b Mon Sep 17 00:00:00 2001 From: gustav_b Date: Thu, 22 Nov 2007 00:14:41 +0000 Subject: 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) --- src/dialogs/iconpreview.cpp | 18 +++++++++--------- src/dialogs/iconpreview.h | 8 ++++---- src/dialogs/layers-panel.cpp | 18 +++++++++--------- src/dialogs/layers-panel.h | 10 +++++----- src/dialogs/swatches.cpp | 3 +-- src/dialogs/tiledialog.cpp | 12 +++++------- src/dialogs/tiledialog.h | 9 ++++----- 7 files changed, 37 insertions(+), 41 deletions(-) (limited to 'src/dialogs') diff --git a/src/dialogs/iconpreview.cpp b/src/dialogs/iconpreview.cpp index d0b8b4a8f..c36414705 100644 --- a/src/dialogs/iconpreview.cpp +++ b/src/dialogs/iconpreview.cpp @@ -49,16 +49,16 @@ namespace Dialogs { IconPreviewPanel* IconPreviewPanel::instance = 0; -IconPreviewPanel* -IconPreviewPanel::create(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavior_factory) +IconPreviewPanel& +IconPreviewPanel::getInstance() { if ( !instance ) { - instance = new IconPreviewPanel(behavior_factory); + instance = new IconPreviewPanel(); } instance->refreshPreview(); - return instance; + return *instance; } //######################################################################### @@ -72,7 +72,7 @@ void IconPreviewPanel::on_button_clicked(int which) hot = which; updateMagnify(); - get_vbox()->queue_draw(); + _getContents()->queue_draw(); } } @@ -85,8 +85,8 @@ void IconPreviewPanel::on_button_clicked(int which) /** * Constructor */ -IconPreviewPanel::IconPreviewPanel(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavior_factory) : - Inkscape::UI::Dialog::Dialog(behavior_factory, "dialogs.iconpreview", SP_VERB_VIEW_ICON_PREVIEW), +IconPreviewPanel::IconPreviewPanel() : + UI::Widget::Panel("", "dialogs.iconpreview", SP_VERB_VIEW_ICON_PREVIEW), hot(1), refreshButton(0), selectionButton(0) @@ -186,7 +186,7 @@ IconPreviewPanel::IconPreviewPanel(Inkscape::UI::Dialog::Behavior::BehaviorFacto Gtk::HButtonBox* holder = new Gtk::HButtonBox( Gtk::BUTTONBOX_END ); - get_vbox()->pack_end( *holder, false, false ); + _getContents()->pack_end(*holder, false, false); selectionButton = new Gtk::ToggleButton(_("Selection")); // , GTK_RESPONSE_APPLY holder->pack_start( *selectionButton, false, false ); @@ -202,7 +202,7 @@ IconPreviewPanel::IconPreviewPanel(Inkscape::UI::Dialog::Behavior::BehaviorFacto refreshButton->signal_clicked().connect( sigc::mem_fun(*this, &IconPreviewPanel::refreshPreview) ); - get_vbox()->pack_start(iconBox, Gtk::PACK_EXPAND_WIDGET); + _getContents()->pack_start(iconBox, Gtk::PACK_EXPAND_WIDGET); show_all_children(); } diff --git a/src/dialogs/iconpreview.h b/src/dialogs/iconpreview.h index 9cfe81b11..0f34dda4e 100644 --- a/src/dialogs/iconpreview.h +++ b/src/dialogs/iconpreview.h @@ -21,7 +21,7 @@ #include #include -#include "ui/dialog/dialog.h" +#include "ui/widget/panel.h" struct SPObject; @@ -33,13 +33,13 @@ namespace Dialogs { /** * A panel that displays an icon preview */ -class IconPreviewPanel : public Inkscape::UI::Dialog::Dialog +class IconPreviewPanel : public UI::Widget::Panel { public: - IconPreviewPanel(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavior_factory); + IconPreviewPanel(); //IconPreviewPanel(Glib::ustring const &label); - static IconPreviewPanel *create(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavior_factory); + static IconPreviewPanel& getInstance(); void refreshPreview(); void modeToggled(); diff --git a/src/dialogs/layers-panel.cpp b/src/dialogs/layers-panel.cpp index 34bb5101c..ff18c82b4 100644 --- a/src/dialogs/layers-panel.cpp +++ b/src/dialogs/layers-panel.cpp @@ -46,14 +46,14 @@ namespace Dialogs { LayersPanel* LayersPanel::instance = 0; -LayersPanel* -LayersPanel::create(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavior_factory) +LayersPanel& +LayersPanel::getInstance() { if ( !instance ) { - instance = new LayersPanel(behavior_factory); + instance = new LayersPanel(); } - return instance; + return *instance; } enum { @@ -708,8 +708,8 @@ void LayersPanel::_opacityChanged() /** * Constructor */ -LayersPanel::LayersPanel(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavior_factory) : - Inkscape::UI::Dialog::Dialog(behavior_factory, "dialogs.layers", SP_VERB_DIALOG_LAYERS), +LayersPanel::LayersPanel() : + UI::Widget::Panel("", "dialogs.layers", SP_VERB_DIALOG_LAYERS), _maxNestDepth(20), _mgr(0), _desktop(0), @@ -776,10 +776,10 @@ LayersPanel::LayersPanel(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavio _opacityBox.pack_end( _spinBtn, Gtk::PACK_SHRINK ); _watching.push_back( &_opacityBox ); - get_vbox()->pack_start( _scroller, Gtk::PACK_EXPAND_WIDGET ); + _getContents()->pack_start( _scroller, Gtk::PACK_EXPAND_WIDGET ); - get_vbox()->pack_end(_opacityBox, Gtk::PACK_SHRINK); - get_vbox()->pack_end(_buttonsRow, Gtk::PACK_SHRINK); + _getContents()->pack_end(_opacityBox, Gtk::PACK_SHRINK); + _getContents()->pack_end(_buttonsRow, Gtk::PACK_SHRINK); _opacityConnection = _opacity.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &LayersPanel::_opacityChanged) ); diff --git a/src/dialogs/layers-panel.h b/src/dialogs/layers-panel.h index 83c5089fc..981d32027 100644 --- a/src/dialogs/layers-panel.h +++ b/src/dialogs/layers-panel.h @@ -1,4 +1,3 @@ - #ifndef SEEN_LAYERS_PANEL_H #define SEEN_LAYERS_PANEL_H /* @@ -22,7 +21,7 @@ #include //#include "ui/previewholder.h" -#include "ui/dialog/dialog.h" +#include "ui/widget/panel.h" class SPObject; @@ -37,14 +36,15 @@ namespace Dialogs { /** * A panel that displays layers. */ -class LayersPanel : public Inkscape::UI::Dialog::Dialog +class LayersPanel : public UI::Widget::Panel { public: - LayersPanel(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavior_factory); + LayersPanel(); virtual ~LayersPanel(); //virtual void setOrientation( Gtk::AnchorType how ); - static LayersPanel *create(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavior_factory); + + static LayersPanel& getInstance(); void setDesktop( SPDesktop* desktop ); diff --git a/src/dialogs/swatches.cpp b/src/dialogs/swatches.cpp index 6607657e5..829b06cb6 100644 --- a/src/dialogs/swatches.cpp +++ b/src/dialogs/swatches.cpp @@ -997,12 +997,11 @@ SwatchesPanel& SwatchesPanel::getInstance() } - /** * Constructor */ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : - Inkscape::UI::Widget::Panel( Glib::ustring(), prefsPath, true ), + Inkscape::UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_SWATCHES, "", true), _holder(0) { Gtk::RadioMenuItem* hotItem = 0; diff --git a/src/dialogs/tiledialog.cpp b/src/dialogs/tiledialog.cpp index 86661efe3..4a60d4413 100644 --- a/src/dialogs/tiledialog.cpp +++ b/src/dialogs/tiledialog.cpp @@ -593,8 +593,6 @@ void TileDialog::updateSelection() - - /*########################## ## Experimental ##########################*/ @@ -612,8 +610,8 @@ static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscap /** * Constructor */ -TileDialog::TileDialog(Behavior::BehaviorFactory behavior_factory) - : Dialog (behavior_factory, "dialogs.gridtiler", SP_VERB_SELECTION_GRIDTILE) +TileDialog::TileDialog() + : UI::Widget::Panel("", "dialogs.gridtiler", SP_VERB_SELECTION_GRIDTILE) { // bool used by spin button callbacks to stop loops where they change each other. updating = false; @@ -628,7 +626,7 @@ TileDialog::TileDialog(Behavior::BehaviorFactory behavior_factory) g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); } - Gtk::VBox *mainVBox = get_vbox(); + Gtk::Box *contents = _getContents(); #define MARGIN 2 @@ -851,7 +849,7 @@ TileDialog::TileDialog(Behavior::BehaviorFactory behavior_factory) TileBox.pack_start(SizesHBox, false, false, MARGIN); - mainVBox->pack_start(TileBox); + contents->pack_start(TileBox); double SpacingType = prefs_get_double_attribute ("dialogs.gridtiler", "SpacingType", 15); if (SpacingType>0) { @@ -864,7 +862,7 @@ TileDialog::TileDialog(Behavior::BehaviorFactory behavior_factory) SizesHBox.set_sensitive (ManualSpacing); //## The OK button - TileOkButton = add_button(Gtk::Stock::APPLY, GTK_RESPONSE_APPLY); + TileOkButton = addResponseButton(Gtk::Stock::APPLY, GTK_RESPONSE_APPLY); tips.set_tip((*TileOkButton), _("Arrange selected objects")); show_all_children(); diff --git a/src/dialogs/tiledialog.h b/src/dialogs/tiledialog.h index 5fe114d83..a1201956a 100644 --- a/src/dialogs/tiledialog.h +++ b/src/dialogs/tiledialog.h @@ -23,7 +23,7 @@ #include #include -#include "ui/dialog/dialog.h" +#include "ui/widget/panel.h" namespace Inkscape { namespace UI { @@ -33,20 +33,19 @@ namespace Dialog { /** * A dialog that displays log messages */ -class TileDialog : public Dialog { +class TileDialog : public UI::Widget::Panel { public: /** * Constructor */ - TileDialog(Behavior::BehaviorFactory behavior_factory) ; + TileDialog() ; /** * Factory method */ - static TileDialog *create(Behavior::BehaviorFactory behavior_factory) - { return new TileDialog(behavior_factory); } + static TileDialog& getInstance() { return *new TileDialog(); } /** * Destructor -- cgit v1.2.3