Code

The dialog to panel refactoring:
authorgustav_b <gustav_b@users.sourceforge.net>
Thu, 22 Nov 2007 00:14:41 +0000 (00:14 +0000)
committergustav_b <gustav_b@users.sourceforge.net>
Thu, 22 Nov 2007 00:14:41 +0000 (00:14 +0000)
 * 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

62 files changed:
src/dialogs/iconpreview.cpp
src/dialogs/iconpreview.h
src/dialogs/layers-panel.cpp
src/dialogs/layers-panel.h
src/dialogs/swatches.cpp
src/dialogs/tiledialog.cpp
src/dialogs/tiledialog.h
src/ui/dialog/Makefile_insert
src/ui/dialog/align-and-distribute.cpp
src/ui/dialog/align-and-distribute.h
src/ui/dialog/behavior.h
src/ui/dialog/dialog-manager.cpp
src/ui/dialog/dialog.cpp
src/ui/dialog/dialog.h
src/ui/dialog/dock-behavior.cpp
src/ui/dialog/dock-behavior.h
src/ui/dialog/document-metadata.cpp
src/ui/dialog/document-metadata.h
src/ui/dialog/document-properties.cpp
src/ui/dialog/document-properties.h
src/ui/dialog/export.cpp
src/ui/dialog/export.h
src/ui/dialog/extension-editor.cpp
src/ui/dialog/extension-editor.h
src/ui/dialog/fill-and-stroke.cpp
src/ui/dialog/fill-and-stroke.h
src/ui/dialog/filter-effects-dialog.cpp
src/ui/dialog/filter-effects-dialog.h
src/ui/dialog/find.cpp
src/ui/dialog/find.h
src/ui/dialog/floating-behavior.cpp
src/ui/dialog/floating-behavior.h
src/ui/dialog/inkscape-preferences.cpp
src/ui/dialog/inkscape-preferences.h
src/ui/dialog/layer-editor.cpp
src/ui/dialog/layer-editor.h
src/ui/dialog/livepatheffect-editor.cpp
src/ui/dialog/livepatheffect-editor.h
src/ui/dialog/memory.cpp
src/ui/dialog/memory.h
src/ui/dialog/messages.cpp
src/ui/dialog/messages.h
src/ui/dialog/panel-dialog.h [new file with mode: 0644]
src/ui/dialog/scriptdialog.cpp
src/ui/dialog/scriptdialog.h
src/ui/dialog/text-properties.cpp
src/ui/dialog/text-properties.h
src/ui/dialog/tracedialog.cpp
src/ui/dialog/tracedialog.h
src/ui/dialog/transformation.cpp
src/ui/dialog/transformation.h
src/ui/dialog/undo-history.cpp
src/ui/dialog/undo-history.h
src/ui/dialog/xml-editor.cpp
src/ui/dialog/xml-editor.h
src/ui/widget/dock-item.cpp
src/ui/widget/dock-item.h
src/ui/widget/panel.cpp
src/ui/widget/panel.h
src/ui/widget/selected-style.cpp
src/verbs.cpp
src/widgets/desktop-widget.cpp

index d0b8b4a8fff87510715f38e8c9b195346085dd9d..c364147053bbce60b8dfbf937c8e7c0d4771154e 100644 (file)
@@ -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();
 }
index 9cfe81b117bcf90dc8124c0e2e4ab927b49342e6..0f34dda4e156fd273f265c9fa08104601ec3629e 100644 (file)
@@ -21,7 +21,7 @@
 #include <gtkmm/togglebutton.h>
 #include <gtkmm/toggletoolbutton.h>
 
-#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();
index 34bb5101c39d3dfe9be15ba3aabb06fcd203f417..ff18c82b463d0b678357d8f7fe6c3b2735c14cb9 100644 (file)
@@ -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) );
 
index 83c5089fc8a434726caa00a02c9dae7de4718957..981d320279346231d823c2ade5bd6957a98291c7 100644 (file)
@@ -1,4 +1,3 @@
-
 #ifndef SEEN_LAYERS_PANEL_H
 #define SEEN_LAYERS_PANEL_H
 /*
@@ -22,7 +21,7 @@
 #include <gtkmm/spinbutton.h>
 
 //#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 );
 
index 6607657e58f7e6ca7c95e5e24d39d98e76bd15b6..829b06cb6009a88f71c7b07eb007f76c6b4b34c2 100644 (file)
@@ -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;
index 86661efe379073c06a189439260220ea5de42e72..4a60d4413d4d6a8bd19bcd891007851355dbdacb 100644 (file)
@@ -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();
index 5fe114d8351edf6ac3a55648cdcce652728dbbbb..a1201956ab55440f37781fe95d857adc574192d5 100644 (file)
@@ -23,7 +23,7 @@
 #include <gtkmm/checkbutton.h>
 #include <gtkmm/radiobutton.h>
 
-#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
index 6679e99deca0f8725a7b99cb3b91d40b893b6644..e4b3f3062dc5d37fb146928764b96c95c945bd18 100644 (file)
@@ -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             \
index 924a987907a6591dd8d664e291845dcc3c134ae8..7b616fe18fb196334a5301f3e9f319a65a31a619 100644 (file)
@@ -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);
index 0559a11e92a0a6b713af85c7a0dfd6860a6d311b..a54ac781ef8752cff85c91a4b5377e5faa3c469d 100644 (file)
@@ -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 };
 
index b7455bbe50c9279b9b42ac6397374206507c78ce..4b5fe06b84005bd34280e23bdafaab964e4ee8c8 100644 (file)
@@ -27,10 +27,10 @@ namespace Behavior {
 
 class Behavior;
 
-typedef Behavior *(*BehaviorFactory)(Dialogdialog);
+typedef Behavior *(*BehaviorFactory)(Dialog &dialog);
 
 template <typename T>
-Behavior *create(Dialogdialog)
+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::Requisitionrequisition) =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(Dialogdialog)
+    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
index e5d326efe9a87e1c051bbc5beb0ab056138ad1d0..f8c07cf535c16e4bd99c7687a8ae86e02f93f31d 100644 (file)
@@ -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>);
index 4fbc217abefb59b856b14195cf219dfc75db7d88..7d2242802ed4f07d955f8c7be03288a1c66a4a90 100644 (file)
@@ -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::Requisitionrequisition)  { _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;
index 5a9e656457e3b7138231cf17dbb1d2098dae2165..a1229fb9475088b353dd6edeba99f3f50b250016 100644 (file)
@@ -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);
index afa921e8530b17bc06ac458e3f91b850e8cbb3eb..13ce20abe8fcd453e330ac08327b9445b1251474 100644 (file)
@@ -37,7 +37,7 @@ namespace Dialog {
 namespace Behavior {
 
 
-DockBehavior::DockBehavior(Dialogdialog) :
+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(Dialogdialog)
+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::Requisitionrequisition)
+DockBehavior::size_request(Gtk::Requisition &requisition)
 { 
     _dock_item.size_request(requisition);
 }
@@ -166,67 +165,12 @@ DockBehavior::set_title(Glib::ustring title)
     _dock_item.set_title(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()
@@ -248,12 +192,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()
 {
@@ -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(); }
 
index 01d95dd8ca9b76a242f31557d5f27033d88dbb4a..d873bfb0af522608202fd0d6d34537b0d929c0c9 100644 (file)
@@ -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);
 
index 22f6f64bed2d15c44846ab53f063f559875d34eb..5671e08fe5631c16bb36508a9c74faba17935165 100644 (file)
@@ -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.
index 3f1fb9e572118c366402c7d996a1a421130379ad..7ee2ee2167b93d3f2c5609fb4fc91a86661560b8 100644 (file)
 #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
index 7e71a0e3e1db6a727fec147ee39a2813fbbc68d3..7528b463f7010e66ef94c70ed9f691a8dd7ef054 100644 (file)
@@ -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()
index 07382d524a492f02c6b721508e38f8405ffcffb7..b4e303325828bf3567d11d52f896a2a8be89ed01 100644 (file)
@@ -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.
index 4e4efafb5755f1a399b289db0e1595ae2a503d70..f95944c30aa89635033d0d355bc293b6052e07da 100644 (file)
@@ -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"));
 
index c47c7c8cc81d68d64d89ca2afad614cfa4b83022..5d83ae5df9cf56ac97684048eacb4ed8a0eac973 100644 (file)
@@ -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;
index 3a62cb14481b317edda67427a18685b570c273f0..d26e05f0795b00f1938c467250fc8bc84b9072b2 100644 (file)
@@ -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();
index 284a3651dac06c30a7eec54013ae2515dc8987f6..cfda36856b5ea11233f89f44b75759c0fb9b9caf 100644 (file)
@@ -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);
 
index 85dc05c556226eafd9040c1f845cdcf18b5fb920..4f32d3d91df7be99afff404d479597fffba13737 100644 (file)
@@ -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);
index 8c27d6d0a1d835a917f895e951865b807354e664..f2313adae6124914432d7c8d500333ca30d10492 100644 (file)
@@ -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;
 
index ecaf3a11b267d2a48530dde0d4dbc0b8b664d36e..721a9e27e792047327b94193229b650e859be584 100644 (file)
@@ -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);
 
index d1a5039e3ed708a7cb8703279a7af2962e5497fe..2cbd90f5f7a08a5838373eb53f97109dab7552f0 100644 (file)
@@ -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
index 0a0538c30ab4efcf512b455bcd9af609dd2cc79c..cfc1bfeb256da45dd1e0dffa90636a656c484625 100644 (file)
@@ -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();
index fb52b2c8e2ebc19a730af7ae1a7eff0acffb7d2b..2d79b37adae510e0f7835f7fca456509dff33999 100644 (file)
@@ -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:
index 7d321b21b9e7494a7aefe6a7c154b8ef11f7f28b..7e76b521175de5baca86bd0a8e6bbf33a82d9bb5 100644 (file)
@@ -29,14 +29,13 @@ namespace UI {
 namespace Dialog {
 namespace Behavior {
 
-FloatingBehavior::FloatingBehavior(Dialogdialog) :
+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(Dialogdialog)
+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::Requisitionrequisition) { _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
index 354987dde1265732ff8c38a968c41146e299adf5..a7e6ef3a047bac0fb495c29382e1c010290a6e5d 100644 (file)
@@ -24,12 +24,12 @@ namespace Behavior {
 class FloatingBehavior : public Behavior {
 
 public:
-    static Behavior *create(Dialogdialog);
+    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::Requisitionrequisition);
-    void get_position(int& x, int& y);
-    void get_size(int& width, intheight);
+    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();
index 5d747807ba91474bf09d88a66d2100857d567b2f..df2952f20c41d90373c7ab632ba88b2327d2e118 100644 (file)
@@ -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
index 12a73d017f85ff53f1f3f2ef476441a03612cefb..f5853c38ba44ee6bc55e4c7e65326de2a21cb411 100644 (file)
@@ -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);
 };
index cb4b8a0b4122680e972896f07c56557f599bbeec..2b596e821446a427c603326fad324dbe7fb9ef7c 100644 (file)
@@ -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
 
index 3c25c7bc081b81129930a96be7dee4d4bd2905f5..0bb98dabf4f18e2f289d0016a95bad565f7b1559 100644 (file)
@@ -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:
 
index ee12e652abe5b11e387c228143a7022abc2c1111..6ec078ce034ad940a313b642b1a70b838e9d7ba4 100644 (file)
@@ -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));
index 5a40cfd307403fd2b5e6548a9fa45e770d9720b8..2ec1f9d1474a31d34926131e0fdb09466e91efbe 100644 (file)
@@ -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);
index eb61aaf9f67ee47d7c746dae8c47d65552adc2bd..1931976d6b2c106098b459a076dd7cbe719bf537 100644 (file)
@@ -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();
 
index 0fe7f87c575da149ac5c7e2f4e4494f2844c37cc..6f832f3e1c4f64f67a7af8d84eee4cc18892a878 100644 (file)
 #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();
index 9e78903c9ea5347ba142083faa217939bb642681..43f80ab65482fc86af6646469b32650e4390ed2a 100644 (file)
@@ -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);
index 85a7c4f0ffa08b03aae49c30bd98da45b5779797..8dcb718cca1da996a8ac2100c48b1226d923404b 100644 (file)
@@ -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>
 
 #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 (file)
index 0000000..7416e96
--- /dev/null
@@ -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 :
index 304362f60b3d2b84583c3ac07de8da11a1d5b0ac..a56e74df33a1905aa3a2d055d9d124f506887dd3 100644 (file)
@@ -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;
 }
 
 
index 00680d4312330410d134e3e775c6777b35ee65c0..780d44a92500accee5f45332eed6ff0a503fe24e 100644 (file)
@@ -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
index e6194ab564fb885726ede53d12ca91ffa6a3be75..5ad08f01f9dd9a3726f667809fe6e8151aebd0e8 100644 (file)
@@ -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();
index 393ca63b2db72a3e8f52c2f28cd2bf6ecf3ea24b..f6ef0d861e97d1e3797b67dd8dbb9ddd19ebe870 100644 (file)
@@ -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;
index b7602b36a4efd29af196d0797a57a3323eb40569..84d7978fb317b9d1717547265f5540a413ab9f56 100644 (file)
@@ -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;
 }
 
 
index 0e352ce10be751a51f136af3c53265c3cf2fb537..0933aee3be52d5ebc15b095800e33844579a15d6 100644 (file)
@@ -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
index 3110289d2c82dd396ff1bfe7f21983c1cd321f2b..9e6cd7f50f3dae59ceedf0cfa4569f95b89d6a1b 100644 (file)
@@ -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
index 361b30a04c088cb8e71b37c46e371e41a81fa35a..e64353f5a1e6bde0e5fb904b8177703a7dbef503 100644 (file)
@@ -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(); }
 
 
     /**
index 344c446e09991908b4bf4fa3ee885e7e3041df1f..b808e57dee7076d7bcdba25d20f26b418eafef88 100644 (file)
@@ -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();
index 7d7426675e436ad44dda4acad8ddc4decd0b76f9..e883ec49c546b3150496d50cbd08b19d4b3ded91 100644 (file)
@@ -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);
index 53f3b4c2cc76cb12ce3e39fd0d15f13ba0c4d01b..7411bc7dced5e0c4f0eeaa680124a1830578b31b 100644 (file)
@@ -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
 
index 65f25423f54de6ade15352b164601bc77b07d710..89df6fbc190ae912bf6f0c2866e17c03d7af8ba7 100644 (file)
@@ -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:
 
index f3fba93bffe925fb1113522e7786f7fd6f99e354..6390eca504ebb2cf020a72a9c40e6b3f11993c37 100644 (file)
@@ -32,21 +32,6 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l
     _window (NULL),
     _dock_item_action_area (NULL)
 {
-    /* Add a "signal_response" signal to the GdlDockItem, make sure it is
-     * only done once for the class.
-     */
-    static guint response_signal = 0;
-
-    if (response_signal == 0) {
-        response_signal = g_signal_new ("signal_response",
-                                        GDL_TYPE_DOCK_ITEM,
-                                        G_SIGNAL_RUN_FIRST,
-                                        0,
-                                        NULL, NULL,
-                                        g_cclosure_marshal_VOID__INT,
-                                        G_TYPE_NONE, 1, G_TYPE_INT);
-    }
-
 
     GdlDockItemBehavior gdl_dock_behavior =
         (prefs_get_int_attribute_limited ("options.dock", "cancenterdock", 1, 0, 1) == 0 ?
@@ -228,20 +213,6 @@ DockItem::getPlacement() const
     return (Placement)placement;
 }
 
-
-void
-DockItem::addButton(Gtk::Button* button, int /*response_id*/)
-{
-    // Create a button box for the response buttons if it's the first button to be added
-    if (!_dock_item_action_area) {
-        _dock_item_action_area = new Gtk::HButtonBox(Gtk::BUTTONBOX_END, 6);
-        _dock_item_box.pack_end(*_dock_item_action_area, Gtk::PACK_SHRINK, 0);
-        _dock_item_action_area->set_border_width(6);
-    }
-
-    _dock_item_action_area->pack_start(*button);
-}
-
 void
 DockItem::hide()
 {
@@ -326,13 +297,6 @@ DockItem::signal_delete_event()
                                                   &_signal_delete_event_proxy);
 }
 
-Glib::SignalProxy1<void, int>
-DockItem::signal_response()
-{
-    return Glib::SignalProxy1<void, int>(Glib::wrap(GTK_WIDGET(_gdl_dock_item)),
-                                         &_signal_response_proxy);
-}
-
 Glib::SignalProxy0<void>
 DockItem::signal_drag_begin()
 {
@@ -476,14 +440,6 @@ DockItem::_signal_delete_event_proxy =
 };
 
 
-const Glib::SignalProxyInfo
-DockItem::_signal_response_proxy =
-{
-    "signal_response",
-    (GCallback) &_signal_response_callback,
-    (GCallback) &_signal_response_callback
-};
-
 const Glib::SignalProxyInfo
 DockItem::_signal_drag_begin_proxy =
 {
@@ -530,22 +486,6 @@ DockItem::_signal_delete_event_callback(GtkWidget *self, GdkEventAny *event, voi
     return RType();
 }
 
-void
-DockItem::_signal_response_callback(GtkWidget *self, gint response_id, void *data)
-{
-    using namespace Gtk;
-    typedef sigc::slot<void, int> SlotType;
-
-    if (Glib::ObjectBase::_get_current_wrapper((GObject *) self)) {
-        try {
-            if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
-                (*static_cast<SlotType *>(slot))(response_id);
-        } catch(...) {
-            Glib::exception_handlers_invoke();
-        }
-    }
-}
-
 void
 DockItem::_signal_drag_end_callback(GtkWidget *self, gboolean cancelled, void *data)
 {
index af2f3ac7022b21e4e73b5af5c47eb0c22735d4c5..c0f52a77a6735337904a5d1e6cea289eba900e62 100644 (file)
@@ -75,8 +75,6 @@ public:
 
     Gtk::Window *getWindow();   //< gives the parent window, if the dock item has one (i.e. it's floating)
 
-    void addButton(Gtk::Button *button, int response_id);
-
     void hide();
     void show();
     void show_all();
@@ -88,7 +86,6 @@ public:
     Glib::SignalProxy0<void> signal_show();
     Glib::SignalProxy0<void> signal_hide();
     Glib::SignalProxy1<bool, GdkEventAny *> signal_delete_event();
-    Glib::SignalProxy1<void, int> signal_response();
     Glib::SignalProxy0<void> signal_drag_begin();
     Glib::SignalProxy1<void, bool> signal_drag_end();
     Glib::SignalProxy0<void> signal_realize();
@@ -121,7 +118,6 @@ private:
     void _onHide();
     void _onHideWindow();
     void _onShow();
-    void _onResponse(int response_id);
     void _onDragBegin();
     void _onDragEnd(bool cancelled);
     void _onRealize();
@@ -136,7 +132,7 @@ private:
     static const Glib::SignalProxyInfo _signal_show_proxy;
     static const Glib::SignalProxyInfo _signal_hide_proxy;
     static const Glib::SignalProxyInfo _signal_delete_event_proxy;
-    static const Glib::SignalProxyInfo _signal_response_proxy;
+
     static const Glib::SignalProxyInfo _signal_drag_begin_proxy;
     static const Glib::SignalProxyInfo _signal_drag_end_proxy;
     static const Glib::SignalProxyInfo _signal_realize_proxy;
@@ -144,12 +140,6 @@ private:
     static gboolean _signal_delete_event_callback(GtkWidget *self, GdkEventAny *event, void *data);
     static void _signal_drag_end_callback(GtkWidget* self, gboolean p0, void* data);
 
-    /** In order to emulate a signal_response signal like the one for Gtk::Dialog we inject a new
-     * signal into GdlDockItem. This signal will be emitted when a button in the dock item added
-     * through the addButton(..., response_id) method, is clicked. 
-     */
-    static void _signal_response_callback(GtkWidget* self, gint p0, void* data);
-
     sigc::signal<void, State, State> _signal_state_changed;
 
     DockItem();
index 8be563828dadf6a84db35f15d5471ba947f7507f..1e868191d80eee02bf7070acb842048adcb45280 100644 (file)
 
 #include <glibmm/i18n.h>
 
+#include <gtkmm/dialog.h> // for Gtk::RESPONSE_*
+#include <gtkmm/stock.h>
+
 #include "panel.h"
-#include "../../icon-size.h"
-#include "../../prefs-utils.h"
+#include "icon-size.h"
+#include "prefs-utils.h"
+#include "desktop-handles.h"
+#include "inkscape.h"
 
 namespace Inkscape {
 namespace UI {
@@ -32,50 +37,42 @@ static const int PANEL_SETTING_NEXTFREE = 3;
 
 /**
  *    Construct a Panel
- *
- *    \param label Label.
  */
 
-Panel::Panel() :
-    _prefs_path(NULL),
-    _menuDesired(false),
-    _tempArrow( Gtk::ARROW_LEFT, Gtk::SHADOW_ETCHED_OUT ),
-    menu(0),
-    _fillable(0)
-{
-    init();
-}
-
-Panel::Panel( Glib::ustring const &label, gchar const* prefs_path, bool menuDesired ) :
+Panel::Panel(Glib::ustring const &label, gchar const *prefs_path, 
+             int verb_num, Glib::ustring const &apply_label,
+             bool menu_desired) :
     _prefs_path(prefs_path),
-    _menuDesired(menuDesired),
-    label(label),
-    _tempArrow( Gtk::ARROW_LEFT, Gtk::SHADOW_ETCHED_OUT ),
-    menu(0),
+    _menu_desired(menu_desired),
+    _label(label),
+    _apply_label(apply_label),
+    _verb_num(verb_num),
+    _temp_arrow(Gtk::ARROW_LEFT, Gtk::SHADOW_ETCHED_OUT),
+    _menu(0),
+    _action_area(0),
     _fillable(0)
 {
-    init();
+    _init();
 }
 
 Panel::~Panel()
 {
-    delete menu;
+    delete _menu;
 }
 
 void Panel::_popper(GdkEventButton* event)
 {
     if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 3 || event->button == 1) ) {
-        if (menu) {
-            menu->popup( event->button, event->time );
+        if (_menu) {
+            _menu->popup(event->button, event->time);
         }
     }
 }
 
-void Panel::init()
+void Panel::_init()
 {
     Glib::ustring tmp("<");
     _anchor = Gtk::ANCHOR_CENTER;
-    tabTitle.set_label(this->label);
 
     guint panel_size = 0;
     if (_prefs_path) {
@@ -92,7 +89,7 @@ void Panel::init()
         panel_wrap = prefs_get_int_attribute_limited( _prefs_path, "panel_wrap", 0, 0, 1 );
     }
 
-    menu = new Gtk::Menu();
+    _menu = new Gtk::Menu();
     {
         const char *things[] = {
             N_("tiny"),
@@ -102,22 +99,22 @@ void Panel::init()
             N_("huge")
         };
         Gtk::RadioMenuItem::Group groupOne;
-        for ( unsigned int i = 0; i < G_N_ELEMENTS(things); i++ ) {
+        for (unsigned int i = 0; i < G_N_ELEMENTS(things); i++) {
             Glib::ustring foo(gettext(things[i]));
             Gtk::RadioMenuItem* single = manage(new Gtk::RadioMenuItem(groupOne, foo));
-            menu->append(*single);
-            if ( i == panel_size ) {
+            _menu->append(*single);
+            if (i == panel_size) {
                 single->set_active(true);
             }
-            single->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), PANEL_SETTING_SIZE, i) );
+            single->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_SIZE, i));
        }
     }
-    menu->append( *manage(new Gtk::SeparatorMenuItem()) );
+    _menu->append(*manage(new Gtk::SeparatorMenuItem()));
     Gtk::RadioMenuItem::Group group;
-    Glib::ustring oneLab(_("List"));
-    Glib::ustring twoLab(_("Grid"));
-    Gtk::RadioMenuItem *one = manage(new Gtk::RadioMenuItem(group, oneLab));
-    Gtk::RadioMenuItem *two = manage(new Gtk::RadioMenuItem(group, twoLab));
+    Glib::ustring one_label(_("List"));
+    Glib::ustring two_label(_("Grid"));
+    Gtk::RadioMenuItem *one = manage(new Gtk::RadioMenuItem(group, one_label));
+    Gtk::RadioMenuItem *two = manage(new Gtk::RadioMenuItem(group, two_label));
 
     if (panel_mode == 0) {
         one->set_active(true);
@@ -125,109 +122,118 @@ void Panel::init()
         two->set_active(true);
     }
 
-    menu->append( *one );
-    nonHorizontal.push_back( one );
-    menu->append( *two );
-    nonHorizontal.push_back( two );
-    Gtk::MenuItem* sep = manage( new Gtk::SeparatorMenuItem());
-    menu->append( *sep );
-    nonHorizontal.push_back( sep );
-    one->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), PANEL_SETTING_MODE, 0) );
-    two->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), PANEL_SETTING_MODE, 1) );
+    _menu->append(*one);
+    _non_horizontal.push_back(one);
+    _menu->append(*two);
+    _non_horizontal.push_back(two);
+    Gtk::MenuItem* sep = manage(new Gtk::SeparatorMenuItem());
+    _menu->append(*sep);
+    _non_horizontal.push_back(sep);
+    one->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_MODE, 0));
+    two->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_MODE, 1));
 
     {
-        Glib::ustring wrapLab(_("Wrap"));
-        Gtk::CheckMenuItem *check = manage(new Gtk::CheckMenuItem(wrapLab));
-        check->set_active( panel_wrap );
-        menu->append( *check );
-        nonVertical.push_back(check);
+        Glib::ustring wrap_label(_("Wrap"));
+        Gtk::CheckMenuItem *check = manage(new Gtk::CheckMenuItem(wrap_label));
+        check->set_active(panel_wrap);
+        _menu->append(*check);
+        _non_vertical.push_back(check);
 
-        check->signal_toggled().connect( sigc::bind<Gtk::CheckMenuItem*>(sigc::mem_fun(*this, &Panel::_wrapToggled), check) );
+        check->signal_toggled().connect(sigc::bind<Gtk::CheckMenuItem*>(sigc::mem_fun(*this, &Panel::_wrapToggled), check));
 
-        sep = manage( new Gtk::SeparatorMenuItem());
-        menu->append( *sep );
-        nonVertical.push_back( sep );
+        sep = manage(new Gtk::SeparatorMenuItem());
+        _menu->append(*sep);
+        _non_vertical.push_back(sep);
     }
 
-    menu->show_all_children();
-    for ( std::vector<Gtk::Widget*>::iterator iter = nonVertical.begin(); iter != nonVertical.end(); ++iter ) {
+    _menu->show_all_children();
+    for ( std::vector<Gtk::Widget*>::iterator iter = _non_vertical.begin(); iter != _non_vertical.end(); ++iter ) {
         (*iter)->hide();
     }
 
-    //closeButton.set_label("X");
+    // _close_button.set_label("X");
 
-    topBar.pack_start(tabTitle);
+    if (!_label.empty()) {
+        _tab_title.set_label(_label);
+        _top_bar.pack_start(_tab_title);
+    }
 
-    //topBar.pack_end(closeButton, false, false);
+    // _top_bar.pack_end(_close_button, false, false);
 
 
-    if ( _menuDesired ) {
-        topBar.pack_end(menuPopper, false, false);
+    if ( _menu_desired ) {
+        _top_bar.pack_end(_menu_popper, false, false);
         Gtk::Frame* outliner = manage(new Gtk::Frame());
-        outliner->set_shadow_type( Gtk::SHADOW_ETCHED_IN );
-        outliner->add( _tempArrow );
-        menuPopper.add( *outliner );
-        menuPopper.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &Panel::_popper) );
+        outliner->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+        outliner->add(_temp_arrow);
+        _menu_popper.add(*outliner);
+        _menu_popper.signal_button_press_event().connect_notify(sigc::mem_fun(*this, &Panel::_popper));
     }
 
-    pack_start( topBar, false, false );
+    pack_start(_top_bar, false, false);
 
-    Gtk::HBox* boxy = manage( new Gtk::HBox() );
+    Gtk::HBox* boxy = manage(new Gtk::HBox());
 
-    boxy->pack_start( contents, true, true );
-    boxy->pack_start( rightBar, false, true );
+    boxy->pack_start(_contents, true, true);
+    boxy->pack_start(_right_bar, false, true);
 
-    pack_start( *boxy, true, true );
+    pack_start(*boxy, true, true);
+
+    signalResponse().connect(sigc::mem_fun(*this, &Panel::_handleResponse));
 
     show_all_children();
 
-    bounceCall( PANEL_SETTING_SIZE, panel_size );
-    bounceCall( PANEL_SETTING_MODE, panel_mode );
-    bounceCall( PANEL_SETTING_WRAP, panel_wrap );
+    _bounceCall(PANEL_SETTING_SIZE, panel_size);
+    _bounceCall(PANEL_SETTING_MODE, panel_mode);
+    _bounceCall(PANEL_SETTING_WRAP, panel_wrap);
 }
 
 void Panel::setLabel(Glib::ustring const &label)
 {
-    this->label = label;
-    tabTitle.set_label(this->label);
+    if (_label.empty() && !label.empty())
+        _top_bar.pack_start(_tab_title);
+    else if (!_label.empty() && label.empty())
+        _top_bar.remove(_tab_title);
+
+    _label = label;
+    _tab_title.set_label(_label);
 }
 
-void Panel::setOrientation( Gtk::AnchorType how )
+void Panel::setOrientation(Gtk::AnchorType how)
 {
-    if ( _anchor != how )
-    {
+    if (_anchor != how) {
         _anchor = how;
-        switch ( _anchor )
-        {
+        switch (_anchor) {
             case Gtk::ANCHOR_NORTH:
             case Gtk::ANCHOR_SOUTH:
             {
-                if ( _menuDesired ) {
-                    menuPopper.reference();
-                    topBar.remove(menuPopper);
-                    rightBar.pack_start(menuPopper, false, false);
-                    menuPopper.unreference();
+                if (_menu_desired) {
+                    _menu_popper.reference();
+                    _top_bar.remove(_menu_popper);
+                    _right_bar.pack_start(_menu_popper, false, false);
+                    _menu_popper.unreference();
 
-                    for ( std::vector<Gtk::Widget*>::iterator iter = nonHorizontal.begin(); iter != nonHorizontal.end(); ++iter ) {
+                    for (std::vector<Gtk::Widget*>::iterator iter = _non_horizontal.begin(); iter != _non_horizontal.end(); ++iter) {
                         (*iter)->hide();
                     }
-                    for ( std::vector<Gtk::Widget*>::iterator iter = nonVertical.begin(); iter != nonVertical.end(); ++iter ) {
+                    for (std::vector<Gtk::Widget*>::iterator iter = _non_vertical.begin(); iter != _non_vertical.end(); ++iter) {
                         (*iter)->show();
                     }
                 }
                 // Ensure we are not in "list" mode
-                bounceCall( PANEL_SETTING_MODE, 1 );
-                topBar.remove(tabTitle);
+                _bounceCall(PANEL_SETTING_MODE, 1);
+                if (!_label.empty())
+                    _top_bar.remove(_tab_title);
             }
             break;
 
             default:
             {
-                if ( _menuDesired ) {
-                    for ( std::vector<Gtk::Widget*>::iterator iter = nonHorizontal.begin(); iter != nonHorizontal.end(); ++iter ) {
+                if ( _menu_desired ) {
+                    for (std::vector<Gtk::Widget*>::iterator iter = _non_horizontal.begin(); iter != _non_horizontal.end(); ++iter) {
                         (*iter)->show();
                     }
-                    for ( std::vector<Gtk::Widget*>::iterator iter = nonVertical.begin(); iter != nonVertical.end(); ++iter ) {
+                    for (std::vector<Gtk::Widget*>::iterator iter = _non_vertical.begin(); iter != _non_vertical.end(); ++iter) {
                         (*iter)->hide();
                     }
                 }
@@ -236,66 +242,77 @@ void Panel::setOrientation( Gtk::AnchorType how )
     }
 }
 
-void Panel::_regItem( Gtk::MenuItem* item, int group, int id )
+void Panel::present()
 {
-    menu->append( *item );
-    item->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), group + PANEL_SETTING_NEXTFREE, id) );
-    item->show();
+    _signal_present.emit();
 }
 
+
 void Panel::restorePanelPrefs()
 {
     guint panel_size = 0;
     if (_prefs_path) {
-        panel_size = prefs_get_int_attribute_limited (_prefs_path, "panel_size", 1, 0, 10);
+        panel_size = prefs_get_int_attribute_limited(_prefs_path, "panel_size", 1, 0, 10);
     }
     guint panel_mode = 0;
     if (_prefs_path) {
-        panel_mode = prefs_get_int_attribute_limited (_prefs_path, "panel_mode", 1, 0, 10);
+        panel_mode = prefs_get_int_attribute_limited(_prefs_path, "panel_mode", 1, 0, 10);
     }
     guint panel_wrap = 0;
     if (_prefs_path) {
-        panel_wrap = prefs_get_int_attribute_limited( _prefs_path, "panel_wrap", 0, 0, 1 );
+        panel_wrap = prefs_get_int_attribute_limited(_prefs_path, "panel_wrap", 0, 0, 1 );
     }
-    bounceCall( PANEL_SETTING_SIZE, panel_size );
-    bounceCall( PANEL_SETTING_MODE, panel_mode );
-    bounceCall( PANEL_SETTING_WRAP, panel_wrap );
+    _bounceCall(PANEL_SETTING_SIZE, panel_size);
+    _bounceCall(PANEL_SETTING_MODE, panel_mode);
+    _bounceCall(PANEL_SETTING_WRAP, panel_wrap);
+}
+
+sigc::signal<void, int> &
+Panel::signalResponse()
+{
+    return _signal_response;
+}
+
+sigc::signal<void> &
+Panel::signalPresent()
+{
+    return _signal_present;
 }
 
-void Panel::bounceCall(int i, int j)
+void Panel::_bounceCall(int i, int j)
 {
-    menu->set_active(0);
-    switch ( i ) {
+    _menu->set_active(0);
+    switch (i) {
     case PANEL_SETTING_SIZE:
         if (_prefs_path) {
-            prefs_set_int_attribute( _prefs_path, "panel_size", j );
+            prefs_set_int_attribute(_prefs_path, "panel_size", j);
         }
-        if ( _fillable ) {
-            ViewType currType = _fillable->getPreviewType();
-            switch ( j ) {
+        if (_fillable) {
+            ViewType curr_type = _fillable->getPreviewType();
+            switch (j) {
             case 0:
             {
-                _fillable->setStyle(Inkscape::ICON_SIZE_DECORATION, currType);
+                _fillable->setStyle(Inkscape::ICON_SIZE_DECORATION, curr_type);
             }
             break;
             case 1:
             {
-                _fillable->setStyle(Inkscape::ICON_SIZE_MENU, currType);
+                _fillable->setStyle(Inkscape::ICON_SIZE_MENU, curr_type);
             }
             break;
             case 2:
             {
-                _fillable->setStyle(Inkscape::ICON_SIZE_SMALL_TOOLBAR, currType);
+                _fillable->setStyle(Inkscape::ICON_SIZE_SMALL_TOOLBAR, curr_type);
             }
             break;
             case 3:
             {
-                _fillable->setStyle(Inkscape::ICON_SIZE_BUTTON, currType);
+                _fillable->setStyle(Inkscape::ICON_SIZE_BUTTON, curr_type);
             }
             break;
             case 4:
             {
-                _fillable->setStyle(Inkscape::ICON_SIZE_DIALOG, currType);
+                _fillable->setStyle(Inkscape::ICON_SIZE_DIALOG, curr_type);
             }
             break;
             default:
@@ -307,17 +324,17 @@ void Panel::bounceCall(int i, int j)
         if (_prefs_path) {
             prefs_set_int_attribute (_prefs_path, "panel_mode", j);
         }
-        if ( _fillable ) {
-            Inkscape::IconSize currSize = _fillable->getPreviewSize();
-            switch ( j ) {
+        if (_fillable) {
+            Inkscape::IconSize curr_size = _fillable->getPreviewSize();
+            switch (j) {
             case 0:
             {
-                _fillable->setStyle(currSize, VIEW_TYPE_LIST);
+                _fillable->setStyle(curr_size, VIEW_TYPE_LIST);
             }
             break;
             case 1:
             {
-                _fillable->setStyle(currSize, VIEW_TYPE_GRID);
+                _fillable->setStyle(curr_size, VIEW_TYPE_GRID);
             }
             break;
             default:
@@ -330,41 +347,136 @@ void Panel::bounceCall(int i, int j)
             prefs_set_int_attribute (_prefs_path, "panel_wrap", j ? 1 : 0);
         }
         if ( _fillable ) {
-            _fillable->setWrap( j );
+            _fillable->setWrap(j);
         }
         break;
     default:
-        _handleAction( i - PANEL_SETTING_NEXTFREE, j );
+        _handleAction(i - PANEL_SETTING_NEXTFREE, j);
     }
 }
 
 
 void Panel::_wrapToggled(Gtk::CheckMenuItem* toggler)
 {
-    if ( toggler ) {
-        bounceCall( PANEL_SETTING_WRAP, toggler->get_active() ? 1 : 0 );
+    if (toggler) {
+        _bounceCall(PANEL_SETTING_WRAP, toggler->get_active() ? 1 : 0);
     }
 }
 
+gchar const *Panel::getPrefsPath() const
+{
+    return _prefs_path;
+}
 
+Glib::ustring const &Panel::getLabel() const
+{
+    return _label;
+}
 
+int const &Panel::getVerb() const
+{
+    return _verb_num;
+}
 
-
-Glib::ustring const &Panel::getLabel() const
+Glib::ustring const &Panel::getApplyLabel() const
 {
-    return label;
+    return _apply_label;
 }
 
-void Panel::_setTargetFillable( PreviewFillable *target )
+void Panel::_setTargetFillable(PreviewFillable *target)
 {
     _fillable = target;
 }
 
-void Panel::_handleAction( int setId, int itemId )
+void Panel::_regItem(Gtk::MenuItem* item, int group, int id)
+{
+    _menu->append(*item);
+    item->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), group + PANEL_SETTING_NEXTFREE, id));
+    item->show();
+}
+
+void Panel::_handleAction(int set_id, int item_id)
 {
 // for subclasses to override
 }
 
+void
+Panel::_apply()
+{
+    g_warning("Apply button clicked for panel [Panel::_apply()]");
+}
+
+Gtk::Button * 
+Panel::addResponseButton(const Glib::ustring &button_text, int response_id)
+{
+    Gtk::Button *button = new Gtk::Button(button_text);
+    _addResponseButton(button, response_id);
+    return button;
+}
+
+Gtk::Button *
+Panel::addResponseButton(const Gtk::StockID &stock_id, int response_id)
+{
+    Gtk::Button *button = new Gtk::Button(stock_id);
+    _addResponseButton(button, response_id);
+    return button;
+}
+
+void
+Panel::_addResponseButton(Gtk::Button *button, int response_id)
+{
+    // Create a button box for the response buttons if it's the first button to be added
+    if (!_action_area) {
+        _action_area = new Gtk::HButtonBox(Gtk::BUTTONBOX_END, 6);
+        _action_area->set_border_width(4);
+        pack_end(*_action_area, Gtk::PACK_SHRINK, 0);
+    }
+
+    _action_area->pack_end(*button);
+
+    if (response_id != 0) {
+        // Re-emit clicked signals as response signals
+        button->signal_clicked().connect(sigc::bind(_signal_response.make_slot(), response_id));
+        _response_map[response_id] = button;
+    }
+}
+
+void
+Panel::setDefaultResponse(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
+Panel::setResponseSensitive(int response_id, bool setting)
+{
+    if (_response_map[response_id])
+        _response_map[response_id]->set_sensitive(setting);
+}
+
+void
+Panel::_handleResponse(int response_id)
+{
+    switch (response_id) {
+        case Gtk::RESPONSE_APPLY: {
+            _apply();
+            break;
+        }
+    }
+}
+
+Inkscape::Selection *Panel::_getSelection()
+{
+    return sp_desktop_selection(SP_ACTIVE_DESKTOP);
+}
+
 } // namespace Widget
 } // namespace UI
 } // namespace Inkscape
index e091c82a12b65c87560207381aba6cc8127bc3ce..10f74cf2b3f571eed61c3db0916faf93740bbce5 100644 (file)
 #include <vector>
 #include <gtkmm/arrow.h>
 #include <gtkmm/box.h>
+#include <gtkmm/button.h>
+#include <gtkmm/buttonbox.h>
 #include <gtkmm/eventbox.h>
 #include <gtkmm/frame.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
 #include <gtkmm/label.h>
 #include <gtkmm/menu.h>
 #include <gtkmm/optionmenu.h>
-#include "../previewfillable.h"
+#include <gtkmm/table.h>
+#include <gtkmm/tooltips.h>
+
+#include "ui/previewfillable.h"
+#include "selection.h"
 
 namespace Inkscape {
 namespace UI {
 namespace Widget {
 
-class Panel : public Gtk::VBox
-{
+class Panel : public Gtk::VBox {
+
 public:
-    Panel();
     virtual ~Panel();
-    Panel(Glib::ustring const &label, gchar const *prefs_path = 0, bool menuDesired = false );
+    Panel(Glib::ustring const &label = "", gchar const *prefs_path = 0, 
+          int verb_num = 0, Glib::ustring const &apply_label = "",
+          bool menu_desired = false);
 
+    gchar const *getPrefsPath() const;
     void setLabel(Glib::ustring const &label);
     Glib::ustring const &getLabel() const;
+    int const &getVerb() const;
+    Glib::ustring const &getApplyLabel() const;
 
-    virtual void setOrientation( Gtk::AnchorType how );
+    virtual void setOrientation(Gtk::AnchorType how);
+
+    virtual void present();  //< request to be present
 
-    const gchar *_prefs_path;
     void restorePanelPrefs();
 
+    /** Signal accessors */
+    virtual sigc::signal<void, int> &signalResponse();
+    virtual sigc::signal<void> &signalPresent();
+
+    /** Methods providing a Gtk::Dialog like interface for adding buttons that emit Gtk::RESPONSE
+     *  signals on click. */
+    Gtk::Button* addResponseButton (const Glib::ustring &button_text, int response_id);
+    Gtk::Button* addResponseButton (const Gtk::StockID &stock_id, int response_id);
+    void setDefaultResponse(int response_id);
+    void setResponseSensitive(int response_id, bool setting);
+
 protected:
-    Gtk::Box* _getContents() { return &contents; }
-    void _setTargetFillable( PreviewFillable *target );
-    void _regItem( Gtk::MenuItem* item, int group, int id );
+    Gtk::Box *_getContents() { return &_contents; }
+    void _setTargetFillable(PreviewFillable *target);
+    void _regItem(Gtk::MenuItem* item, int group, int id);
+
+    virtual void _handleAction(int set_id, int item_id);
+    virtual void _apply();
+
+    virtual void _handleResponse(int response_id);
+
+    /** Helper methods */
+    void _addResponseButton(Gtk::Button *button, int response_id);
+    Inkscape::Selection *_getSelection();
 
-    virtual void _handleAction( int setId, int itemId );
-    bool _menuDesired;
+    /** Tooltips object for all descendants to use */
+    Gtk::Tooltips _tooltips;
 
+    const gchar *_prefs_path;
+
+    bool _menu_desired;
     Gtk::AnchorType _anchor;
 
+    /** Signals */
+    sigc::signal<void, int> _signal_response;
+    sigc::signal<void>      _signal_present;
+
 private:
-    void init();
-    void bounceCall(int i, int j);
-
-    void _popper(GdkEventButton* btn);
-    void _wrapToggled(Gtk::CheckMenuItem* toggler);
-
-    Glib::ustring   label;
-
-    Gtk::HBox       topBar;
-    Gtk::VBox       rightBar;
-    Gtk::VBox       contents;
-    Gtk::Label      tabTitle;
-    Gtk::Arrow      _tempArrow;
-    Gtk::EventBox   menuPopper;
-    Gtk::Button     closeButton;
-    Gtk::Menu*       menu;
-    std::vector<Gtk::Widget*> nonHorizontal;
-    std::vector<Gtk::Widget*> nonVertical;
+    void _init();
+    void _bounceCall(int i, int j);
+
+    void _popper(GdkEventButton *btn);
+    void _wrapToggled(Gtk::CheckMenuItem *toggler);
+
+    Glib::ustring    _label;
+    Glib::ustring    _apply_label;
+    int              _verb_num;
+
+    Gtk::HBox        _top_bar;
+    Gtk::VBox        _right_bar;
+    Gtk::VBox        _contents;
+    Gtk::Label       _tab_title;
+    Gtk::Arrow       _temp_arrow;
+    Gtk::EventBox    _menu_popper;
+    Gtk::Button      _close_button;
+    Gtk::Menu       *_menu;
+    Gtk::HButtonBox *_action_area;  //< stores response buttons
+    std::vector<Gtk::Widget *> _non_horizontal;
+    std::vector<Gtk::Widget *> _non_vertical;
     PreviewFillable *_fillable;
+
+    /** A map to store which widget that emits a certain response signal */
+    typedef std::map<int, Gtk::Widget *> ResponseMap;
+    ResponseMap _response_map;
 };
 
 } // namespace Widget
index cbba0b1e8e908b946d770ee354e8876ab0002a7f..20838ee22ba8d0d12d2ba9ece042db14363b35cc 100644 (file)
@@ -29,6 +29,7 @@
 #include "sp-pattern.h"
 #include "ui/dialog/dialog-manager.h"
 #include "ui/dialog/fill-and-stroke.h"
+#include "ui/dialog/panel-dialog.h"
 #include "xml/repr.h"
 #include "document.h"
 #include "widgets/widget-sizes.h"
@@ -92,6 +93,8 @@ static GtkTargetEntry ui_drop_target_entries [] = {
 #define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0])
 static guint nui_drop_target_entries = ENTRIES_SIZE(ui_drop_target_entries);
 
+/* convenience function */
+static Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop);
 
 SelectedStyle::SelectedStyle(bool /*layout*/)
     : _desktop (NULL),
@@ -773,15 +776,13 @@ void SelectedStyle::on_fillstroke_swap() {
 }
 
 void SelectedStyle::on_fill_edit() {
-    if (Dialog::FillAndStroke *dialog = dynamic_cast<Dialog::FillAndStroke *>(
-            _desktop->_dlg_mgr->getDialog("FillAndStroke")))
-        dialog->showPageFill();
+    if (Dialog::FillAndStroke *fs = get_fill_and_stroke_panel(_desktop))
+        fs->showPageFill();
 }
 
 void SelectedStyle::on_stroke_edit() {
-    if (Dialog::FillAndStroke *dialog = dynamic_cast<Dialog::FillAndStroke *>(
-            _desktop->_dlg_mgr->getDialog("FillAndStroke")))
-        dialog->showPageStrokePaint();
+    if (Dialog::FillAndStroke *fs = get_fill_and_stroke_panel(_desktop))
+        fs->showPageStrokePaint();
 }
 
 bool
@@ -789,9 +790,8 @@ SelectedStyle::on_fill_click(GdkEventButton *event)
 {
     if (event->button == 1) { // click, open fill&stroke
 
-        if (Dialog::FillAndStroke *dialog = dynamic_cast<Dialog::FillAndStroke *>(
-                _desktop->_dlg_mgr->getDialog("FillAndStroke")))
-            dialog->showPageFill();
+        if (Dialog::FillAndStroke *fs = get_fill_and_stroke_panel(_desktop))
+            fs->showPageFill();
 
     } else if (event->button == 3) { // right-click, popup menu
         _popup[SS_FILL].popup(event->button, event->time);
@@ -809,9 +809,8 @@ bool
 SelectedStyle::on_stroke_click(GdkEventButton *event)
 {
     if (event->button == 1) { // click, open fill&stroke
-        if (Dialog::FillAndStroke *dialog = dynamic_cast<Dialog::FillAndStroke *>(
-                _desktop->_dlg_mgr->getDialog("FillAndStroke")))
-            dialog->showPageStrokePaint();
+        if (Dialog::FillAndStroke *fs = get_fill_and_stroke_panel(_desktop))
+            fs->showPageStrokePaint();
     } else if (event->button == 3) { // right-click, popup menu
         _popup[SS_STROKE].popup(event->button, event->time);
     } else if (event->button == 2) { // middle click, toggle none/lastcolor
@@ -828,9 +827,8 @@ bool
 SelectedStyle::on_sw_click(GdkEventButton *event)
 {
     if (event->button == 1) { // click, open fill&stroke
-        if (Dialog::FillAndStroke *dialog = dynamic_cast<Dialog::FillAndStroke *>(
-                _desktop->_dlg_mgr->getDialog("FillAndStroke")))
-            dialog->showPageStrokeStyle();
+        if (Dialog::FillAndStroke *fs = get_fill_and_stroke_panel(_desktop))
+            fs->showPageStrokeStyle();
     } else if (event->button == 3) { // right-click, popup menu
         _popup_sw.popup(event->button, event->time);
     } else if (event->button == 2) { // middle click, toggle none/lastwidth?
@@ -1322,6 +1320,19 @@ RotateableSwatch::do_release(double by, guint modifier) {
     startcolor_set = false;
 }
 
+Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop)
+{
+    if (Dialog::PanelDialogBase *panel_dialog = 
+        dynamic_cast<Dialog::PanelDialogBase *>(desktop->_dlg_mgr->getDialog("FillAndStroke"))) {
+        try {
+            Dialog::FillAndStroke &fill_and_stroke = 
+                dynamic_cast<Dialog::FillAndStroke &>(panel_dialog->getPanel());
+            return &fill_and_stroke;
+        } catch (std::exception e) { }
+    }        
+
+    return 0;
+}
 
 } // namespace Widget
 } // namespace UI
index b893240efdc36e93f4fd249a25cdba2be655def6..a1947fb97e0a2e4be1afe60fd5781dc00de8f467 100644 (file)
@@ -109,48 +109,6 @@ sp_action_get_title(SPAction const *action)
 
 namespace Inkscape {
 
-/// \todo !!!FIXME:: kill this, use DialogManager instead!!!
-
-class PanelDialog : public Inkscape::UI::Dialog::Dialog
-{
-public:
-    PanelDialog(char const *prefs_path, int const verb_num) :
-        Dialog(
-            (prefs_get_int_attribute_limited ("options.dialogtype", "value", UI::Dialog::DOCK, 0, 1) == UI::Dialog::FLOATING ?
-             &UI::Dialog::Behavior::FloatingBehavior::create :
-             &UI::Dialog::Behavior::DockBehavior::create),
-            prefs_path, verb_num) {}
-/*
-    virtual Glib::ustring getName() const {return "foo";}
-    virtual Glib::ustring getDesc() const {return "bar";}
-*/
-};
-
-/** \brief Utility function to get a panel displayed. */
-static void show_panel( Inkscape::UI::Widget::Panel &panel, char const *prefs_path, int const verb_num )
-{
-    Gtk::Container *container = panel.get_toplevel();
-    if ( &panel == container ) { // safe check?
-        //g_message("Creating new dialog to hold it");
-        PanelDialog *dia = new PanelDialog(prefs_path, verb_num);
-        Gtk::VBox *mainVBox = dia->get_vbox();
-        mainVBox->pack_start(panel);
-        dia->show_all_children();
-        dia->read_geometry();
-        dia->present();
-    } else {
-        PanelDialog *dia = dynamic_cast<PanelDialog*>(container);
-        if ( dia ) {
-            //g_message("Found an existing dialog");
-            dia->read_geometry();
-            dia->present();
-        } else {
-            g_message("Failed to find an existing dialog");
-        }
-    }
-}
-
-
 /** \brief A class to encompass all of the verbs which deal with
            file operations. */
 class FileVerb : public Verb {
@@ -1713,8 +1671,8 @@ DialogVerb::perform(SPAction *action, void *data, void */*pdata*/)
             dt->_dlg_mgr->showDialog("FillAndStroke");
             break;
         case SP_VERB_DIALOG_SWATCHES:
-            show_panel( Inkscape::UI::Dialogs::SwatchesPanel::getInstance(), "dialogs.swatches", SP_VERB_DIALOG_SWATCHES);
-             break;
+            dt->_dlg_mgr->showDialog("Swatches");
+            break;
         case SP_VERB_DIALOG_TRANSFORM:
             dt->_dlg_mgr->showDialog("Transformation");
             break;
@@ -1789,9 +1747,9 @@ HelpVerb::perform(SPAction *action, void *data, void */*pdata*/)
             sp_help_about();
             break;
         case SP_VERB_HELP_ABOUT_EXTENSIONS: {
-            Inkscape::UI::Dialogs::ExtensionsPanel *panel = new Inkscape::UI::Dialogs::ExtensionsPanel();
-            panel->set_full(true);
-            show_panel( *panel, "dialogs.aboutextensions", SP_VERB_HELP_ABOUT_EXTENSIONS );
+            // Inkscape::UI::Dialogs::ExtensionsPanel *panel = new Inkscape::UI::Dialogs::ExtensionsPanel();
+            // panel->set_full(true);
+            // show_panel( *panel, "dialogs.aboutextensions", SP_VERB_HELP_ABOUT_EXTENSIONS );
             break;
         }
 
index 1494d3c2401542a043fadd76921833b30df71b6a..d7b8ac1702390150476d0249a7ef0e009cc54218 100644 (file)
@@ -418,8 +418,7 @@ sp_desktop_widget_init (SPDesktopWidget *dtw)
         prefs_get_int_attribute_limited ("options.dialogtype", "value", Inkscape::UI::Dialog::FLOATING, 0, 1) ==
         Inkscape::UI::Dialog::DOCK;
 
-    if (create_dock)
-    {
+    if (create_dock) {
         dtw->dock = new Inkscape::UI::Widget::Dock();
 
         Gtk::HPaned *paned = new Gtk::HPaned();