summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgustav_b <gustav_b@users.sourceforge.net>2007-09-19 00:35:12 +0000
committergustav_b <gustav_b@users.sourceforge.net>2007-09-19 00:35:12 +0000
commitf8ae53cbc77f8fd913b2119e96d8fab494025df7 (patch)
tree0fd56c1e72567a13ef356f3cb40d6133e2a482e1 /src
parentImprove snapping of newly created guides (diff)
downloadinkscape-f8ae53cbc77f8fd913b2119e96d8fab494025df7.tar.gz
inkscape-f8ae53cbc77f8fd913b2119e96d8fab494025df7.zip
Cleaned up Dialog class, coding style, unused code, etc. (only
estethical changes) --This line, and those below, will be ignored-- M src/ui/dialog/dialog.h M src/ui/dialog/tree-editor.cpp M src/ui/dialog/dialog.cpp M src/ui/dialog/dock-behavior.cpp M src/ui/dialog/floating-behavior.cpp M src/ui/dialog/tree-editor.h (bzr r3766)
Diffstat (limited to 'src')
-rw-r--r--src/ui/dialog/dialog.cpp257
-rw-r--r--src/ui/dialog/dialog.h11
-rw-r--r--src/ui/dialog/dock-behavior.cpp2
-rw-r--r--src/ui/dialog/floating-behavior.cpp4
-rw-r--r--src/ui/dialog/tree-editor.cpp4
-rw-r--r--src/ui/dialog/tree-editor.h2
6 files changed, 138 insertions, 142 deletions
diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp
index fe1a43e22..e7f1a7e13 100644
--- a/src/ui/dialog/dialog.cpp
+++ b/src/ui/dialog/dialog.cpp
@@ -62,25 +62,6 @@ sp_dialog_shutdown (GtkObject *object, gpointer dlgPtr)
dlg->onShutdown();
}
-void
-Dialog::save_geometry()
-{
- int y, x, w, h;
-
- get_position(x, y);
- get_size(w, h);
-
- // g_print ("write %d %d %d %d\n", x, y, w, h);
-
- if (x<0) x=0;
- if (y<0) y=0;
-
- prefs_set_int_attribute (_prefs_path, "x", x);
- prefs_set_int_attribute (_prefs_path, "y", y);
- prefs_set_int_attribute (_prefs_path, "w", w);
- prefs_set_int_attribute (_prefs_path, "h", h);
-
-}
void hideCallback(GtkObject *object, gpointer dlgPtr)
{
@@ -99,77 +80,6 @@ void unhideCallback(GtkObject *object, gpointer dlgPtr)
}
-
-void
-Dialog::read_geometry()
-{
- _user_hidden = false;
-
- int x = prefs_get_int_attribute (_prefs_path, "x", -1000);
- int y = prefs_get_int_attribute (_prefs_path, "y", -1000);
- int w = prefs_get_int_attribute (_prefs_path, "w", 0);
- int h = prefs_get_int_attribute (_prefs_path, "h", 0);
-
- // g_print ("read %d %d %d %d\n", x, y, w, h);
-
- // If there are stored height and width values for the dialog,
- // resize the window to match; otherwise we leave it at its default
- if (w != 0 && h != 0) {
- resize(w, h);
- }
-
- // If there are stored values for where the dialog should be
- // located, then restore the dialog to that position.
- // also check if (x,y) is actually onscreen with the current screen dimensions
- if ( (x >= 0) && (y >= 0) && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE)) ) {
- move(x, y);
- } else {
- // ...otherwise just put it in the middle of the screen
- set_position(Gtk::WIN_POS_CENTER);
- }
-
-}
-
-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(); }
-inline void Dialog::show_all_children() { _behavior->show_all_children(); }
-inline void Dialog::hide() { _behavior->hide(); }
-inline void Dialog::show() { _behavior->show(); }
-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::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); }
-
-Dialog::Dialog(const char *prefs_path, int verb_num, const char *apply_label)
-{
-
-}
-
//=====================================================================
/**
@@ -182,6 +92,7 @@ Dialog::Dialog(const char *prefs_path, int verb_num, const char *apply_label)
* It also provides some general purpose signal handlers for things like
* showing and hiding all dialogs.
*/
+
Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path, int verb_num,
const char *apply_label)
: _hiddenF12 (false),
@@ -197,22 +108,19 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat
_title = title;
_behavior = behavior_factory(*this);
-
+
gtk_signal_connect( GTK_OBJECT (gobj()), "event", GTK_SIGNAL_FUNC(sp_dialog_event_handler), gobj() );
- if (Inkscape::NSApplication::Application::getNewGui())
- {
+ if (Inkscape::NSApplication::Application::getNewGui()) {
_desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::mem_fun (*this, &Dialog::onDesktopActivated));
_dialogs_hidden_connection = Inkscape::NSApplication::Editor::connectDialogsHidden (sigc::mem_fun (*this, &Dialog::onHideF12));
_dialogs_unhidden_connection = Inkscape::NSApplication::Editor::connectDialogsUnhidden (sigc::mem_fun (*this, &Dialog::onShowF12));
_shutdown_connection = Inkscape::NSApplication::Editor::connectShutdown (sigc::mem_fun (*this, &Dialog::onShutdown));
- }
- else
- {
- g_signal_connect (G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_retransientize), (void *)this);
- g_signal_connect ( G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this );
- g_signal_connect ( G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this );
- g_signal_connect (G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_dialog_shutdown), (void *)this);
+ } else {
+ g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_retransientize), (void *)this);
+ g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this);
+ g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this);
+ g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_dialog_shutdown), (void *)this);
}
Glib::wrap(gobj())->signal_key_press_event().connect(sigc::ptr_fun(&windowKeyPress));
@@ -244,6 +152,9 @@ Dialog::~Dialog()
}
+//---------------------------------------------------------------------
+
+
bool Dialog::windowKeyPress(GdkEventKey *event)
{
unsigned int shortcut = 0;
@@ -254,34 +165,22 @@ bool Dialog::windowKeyPress(GdkEventKey *event)
SP_SHORTCUT_CONTROL_MASK : 0 ) |
( event->state & GDK_MOD1_MASK ?
SP_SHORTCUT_ALT_MASK : 0 );
-
return sp_shortcut_invoke( shortcut, SP_ACTIVE_DESKTOP );
-}
-//---------------------------------------------------------------------
+}
void
-Dialog::on_response(int response_id)
+Dialog::onDesktopActivated(SPDesktop *desktop)
{
- switch (response_id) {
- case Gtk::RESPONSE_APPLY: {
- _apply();
- break;
- }
- case Gtk::RESPONSE_CLOSE: {
- _close();
- break;
- }
- }
+ _behavior->onDesktopActivated(desktop);
}
-bool
-Dialog::on_delete_event (GdkEventAny *event)
+void
+Dialog::onShutdown()
{
save_geometry();
_user_hidden = true;
-
- return false;
+ _behavior->onShutdown();
}
void
@@ -304,24 +203,116 @@ Dialog::onShowF12()
_hiddenF12 = false;
}
-void
-Dialog::onShutdown()
+
+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(); }
+inline void Dialog::hide() { _behavior->hide(); }
+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::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); }
+
+
+void
+Dialog::read_geometry()
{
- save_geometry();
- _user_hidden = true;
- _behavior->onShutdown();
+ _user_hidden = false;
+
+ int x = prefs_get_int_attribute (_prefs_path, "x", -1000);
+ int y = prefs_get_int_attribute (_prefs_path, "y", -1000);
+ int w = prefs_get_int_attribute (_prefs_path, "w", 0);
+ int h = prefs_get_int_attribute (_prefs_path, "h", 0);
+
+ // g_print ("read %d %d %d %d\n", x, y, w, h);
+
+ // If there are stored height and width values for the dialog,
+ // resize the window to match; otherwise we leave it at its default
+ if (w != 0 && h != 0) {
+ resize(w, h);
+ }
+
+ // If there are stored values for where the dialog should be
+ // located, then restore the dialog to that position.
+ // also check if (x,y) is actually onscreen with the current screen dimensions
+ if ( (x >= 0) && (y >= 0) && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE)) ) {
+ move(x, y);
+ } else {
+ // ...otherwise just put it in the middle of the screen
+ set_position(Gtk::WIN_POS_CENTER);
+ }
+
}
+
void
-Dialog::onDesktopActivated(SPDesktop *desktop)
+Dialog::save_geometry()
{
- _behavior->onDesktopActivated(desktop);
+ int y, x, w, h;
+
+ get_position(x, y);
+ get_size(w, h);
+
+ // g_print ("write %d %d %d %d\n", x, y, w, h);
+
+ if (x<0) x=0;
+ if (y<0) y=0;
+
+ prefs_set_int_attribute (_prefs_path, "x", x);
+ prefs_set_int_attribute (_prefs_path, "y", y);
+ prefs_set_int_attribute (_prefs_path, "w", w);
+ prefs_set_int_attribute (_prefs_path, "h", h);
+
}
-Inkscape::Selection*
-Dialog::_getSelection()
+void
+Dialog::_onResponse(int response_id)
{
- return sp_desktop_selection(SP_ACTIVE_DESKTOP);
+ switch (response_id) {
+ case Gtk::RESPONSE_APPLY: {
+ _apply();
+ break;
+ }
+ case Gtk::RESPONSE_CLOSE: {
+ _close();
+ break;
+ }
+ }
+}
+
+bool
+Dialog::_onDeleteEvent(GdkEventAny *event)
+{
+ save_geometry();
+ _user_hidden = true;
+
+ return false;
}
void
@@ -347,12 +338,18 @@ Dialog::_close()
event.send_event = TRUE;
if (event.window)
- g_object_ref (G_OBJECT (event.window));
+ g_object_ref(G_OBJECT(event.window));
gtk_main_do_event ((GdkEvent*)&event);
if (event.window)
- g_object_unref (G_OBJECT (event.window));
+ g_object_unref(G_OBJECT(event.window));
+}
+
+Inkscape::Selection*
+Dialog::_getSelection()
+{
+ return sp_desktop_selection(SP_ACTIVE_DESKTOP);
}
} // namespace Dialog
diff --git a/src/ui/dialog/dialog.h b/src/ui/dialog/dialog.h
index 50b69caa4..2d1ef7af3 100644
--- a/src/ui/dialog/dialog.h
+++ b/src/ui/dialog/dialog.h
@@ -39,9 +39,8 @@ gboolean sp_retransientize_again(gpointer dlgPtr);
void sp_dialog_shutdown(GtkObject *object, gpointer dlgPtr);
class Dialog {
-public:
- Dialog(const char *prefs_path = NULL, int verb_num = 0, const char *apply_label = NULL);
+public:
Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path = NULL,
int verb_num = 0, const char *apply_label = NULL);
@@ -51,14 +50,13 @@ public:
virtual void onDesktopActivated (SPDesktop*);
virtual void onShutdown();
- virtual void present();
-
/** Hide and show dialogs */
virtual void onHideF12();
virtual void onShowF12();
virtual operator Gtk::Widget&();
virtual GtkWidget *gobj();
+ virtual void present();
virtual Gtk::VBox *get_vbox();
virtual void show();
virtual void hide();
@@ -104,8 +102,9 @@ protected:
*/
Gtk::Tooltips tooltips;
- virtual void on_response(int response_id);
- virtual bool on_delete_event (GdkEventAny*);
+ virtual void _onResponse(int response_id);
+ virtual bool _onDeleteEvent (GdkEventAny*);
+
virtual void _apply();
virtual void _close();
diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp
index ad9b19a56..afa921e85 100644
--- a/src/ui/dialog/dock-behavior.cpp
+++ b/src/ui/dialog/dock-behavior.cpp
@@ -49,7 +49,7 @@ 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::on_response));
+ 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) {
diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp
index 55daf772b..7d321b21b 100644
--- a/src/ui/dialog/floating-behavior.cpp
+++ b/src/ui/dialog/floating-behavior.cpp
@@ -36,8 +36,8 @@ FloatingBehavior::FloatingBehavior(Dialog& dialog) :
hide();
_d->set_has_separator(false);
- signal_response().connect(sigc::mem_fun(_dialog, &Inkscape::UI::Dialog::Dialog::on_response));
- signal_delete_event().connect(sigc::mem_fun(_dialog, &Inkscape::UI::Dialog::Dialog::on_delete_event));
+ 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()));
_dialog.retransientize_suppress = false;
diff --git a/src/ui/dialog/tree-editor.cpp b/src/ui/dialog/tree-editor.cpp
index 4d982d3e3..6da5c486b 100644
--- a/src/ui/dialog/tree-editor.cpp
+++ b/src/ui/dialog/tree-editor.cpp
@@ -21,8 +21,8 @@ namespace Inkscape {
namespace UI {
namespace Dialog {
-TreeEditor::TreeEditor()
- : Dialog ("dialogs.treeeditor", SP_VERB_NONE /*FIXME*/)
+TreeEditor::TreeEditor(Behavior::BehaviorFactory behavior_factory)
+ : Dialog (behavior_factory, "dialogs.treeeditor", SP_VERB_NONE /*FIXME*/)
{
get_vbox()->pack_start(_hbox);
diff --git a/src/ui/dialog/tree-editor.h b/src/ui/dialog/tree-editor.h
index 9355e04d7..18bdfe974 100644
--- a/src/ui/dialog/tree-editor.h
+++ b/src/ui/dialog/tree-editor.h
@@ -26,7 +26,7 @@ namespace Dialog {
class TreeEditor : public Dialog {
public:
- TreeEditor();
+ TreeEditor(Behavior::BehaviorFactory behavior_factory);
virtual ~TreeEditor();
protected: