Code

Sync to release 0.48 branch
[inkscape.git] / src / ui / dialog / dialog.cpp
index 7d2242802ed4f07d955f8c7be03288a1c66a4a90..2483dc50e6b20388ad600baf92086bf2d89e8e96 100644 (file)
@@ -1,10 +1,9 @@
-/**
- * \brief Base class for dialogs in Inkscape.  This class provides certain
- *        common behaviors and styles wanted of all dialogs in the application.
- *
- * Authors:
+/** @file
+ * @brief Base class for dialogs in Inkscape - implementation
+ */
+/* Authors:
  *   Bryce W. Harrington <bryce@bryceharrington.org>
- *   buliabyak@gmail.com 
+ *   buliabyak@gmail.com
  *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
  *   Gustav Broberg <broberg@kth.se>
  *
@@ -30,7 +29,7 @@
 #include "dialog-manager.h"
 #include "modifier-fns.h"
 #include "shortcuts.h"
-#include "prefs-utils.h"
+#include "preferences.h"
 #include "interface.h"
 #include "verbs.h"
 
@@ -42,7 +41,7 @@ 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);
@@ -57,14 +56,14 @@ 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();
 }
 
 
-void hideCallback(GtkObject *object, gpointer dlgPtr)
+void hideCallback(GtkObject */*object*/, gpointer dlgPtr)
 {
     g_return_if_fail( dlgPtr != NULL );
 
@@ -72,7 +71,7 @@ void hideCallback(GtkObject *object, gpointer dlgPtr)
     dlg->onHideF12();
 }
 
-void unhideCallback(GtkObject *object, gpointer dlgPtr)
+void unhideCallback(GtkObject */*object*/, gpointer dlgPtr)
 {
     g_return_if_fail( dlgPtr != NULL );
 
@@ -95,7 +94,7 @@ void unhideCallback(GtkObject *object, gpointer dlgPtr)
  */
 
 Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path, int verb_num,
-               Glib::ustring const &apply_label) 
+               Glib::ustring const &apply_label)
     : _hiddenF12 (false),
       _prefs_path (prefs_path),
       _verb_num(verb_num),
@@ -109,7 +108,7 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat
     _title = title;
 
     _behavior = behavior_factory(*this);
-    
+
     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));
@@ -137,9 +136,10 @@ Dialog::~Dialog()
         _dialogs_unhidden_connection.disconnect();
         _shutdown_connection.disconnect();
     }
-    
+
     save_geometry();
     delete _behavior;
+    _behavior = 0;
 }
 
 
@@ -152,7 +152,7 @@ Dialog::onDesktopActivated(SPDesktop *desktop)
     _behavior->onDesktopActivated(desktop);
 }
 
-void 
+void
 Dialog::onShutdown()
 {
     save_geometry();
@@ -206,10 +206,11 @@ 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);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    int x = prefs->getInt(_prefs_path + "/x", -1000);
+    int y = prefs->getInt(_prefs_path + "/y", -1000);
+    int w = prefs->getInt(_prefs_path + "/w", 0);
+    int h = prefs->getInt(_prefs_path + "/h", 0);
 
     // g_print ("read %d %d %d %d\n", x, y, w, h);
 
@@ -218,7 +219,7 @@ Dialog::read_geometry()
     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
@@ -245,10 +246,11 @@ Dialog::save_geometry()
     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::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->setInt(_prefs_path + "/x", x);
+    prefs->setInt(_prefs_path + "/y", y);
+    prefs->setInt(_prefs_path + "/w", w);
+    prefs->setInt(_prefs_path + "/h", h);
 
 }
 
@@ -264,7 +266,7 @@ Dialog::_handleResponse(int response_id)
 }
 
 bool
-Dialog::_onDeleteEvent(GdkEventAny *event)
+Dialog::_onDeleteEvent(GdkEventAny */*event*/)
 {
     save_geometry();
     _user_hidden = true;
@@ -342,12 +344,12 @@ Dialog::_close()
     event.window = dlg->window;
     event.send_event = TRUE;
 
-    if (event.window) 
+    if (event.window)
         g_object_ref(G_OBJECT(event.window));
 
     gtk_main_do_event ((GdkEvent*)&event);
 
-    if (event.window) 
+    if (event.window)
         g_object_unref(G_OBJECT(event.window));
 }