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