Code

fix range, make integer, remove unnecessary document_done, fix 1635388
[inkscape.git] / src / dialogs / input.cpp
index 501a4a21bea616eb3bc1bd97ab87e79d94cf5a05..21a6ea4a7d40a7c519c33f314c59cd0abc3b6b45 100644 (file)
@@ -5,8 +5,9 @@
  *
  * Authors:
  *   Nicklas Lindgren <nili@lysator.liu.se>
+ *   Johan Engelen <goejendaagh@zonnet.nl>
  *
- * Copyright (C) 2005 Authors
+ * Copyright (C) 2005-2006 Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
@@ -27,6 +28,7 @@
 #include "dialog-events.h"
 #include "../prefs-utils.h"
 
+#define MIN_ONSCREEN_DISTANCE 50
 
 static GtkWidget *dlg = NULL;
 static win_data wd;
@@ -49,6 +51,9 @@ sp_input_dialog_delete (GtkObject *object, GdkEvent *event, gpointer data)
     gtk_window_get_position ((GtkWindow *) dlg, &x, &y);
     gtk_window_get_size ((GtkWindow *) dlg, &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);
@@ -160,7 +165,7 @@ sp_input_save_to_preferences (void)
 
         repr = sp_repr_lookup_child(devices, "id", device->name);
         if (repr == NULL) {
-            repr = sp_repr_new("group");
+            repr = devices->document()->createElement("group");
             repr->setAttribute("id", device->name);
             devices->appendChild(repr);
             Inkscape::GC::release(repr);
@@ -218,8 +223,8 @@ sp_input_dialog (void)
         dlg = gtk_input_dialog_new();
 
         if (x == -1000 || y == -1000) {
-            x = prefs_get_int_attribute (prefs_path, "x", 0);
-            y = prefs_get_int_attribute (prefs_path, "y", 0);
+            x = prefs_get_int_attribute (prefs_path, "x", -1000);
+            y = prefs_get_int_attribute (prefs_path, "y", -1000);
         }
 
         if (w ==0 || h == 0) {
@@ -227,15 +232,18 @@ sp_input_dialog (void)
             h = prefs_get_int_attribute (prefs_path, "h", 0);
         }
 
-        if (x != 0 || y != 0) {
+//        if (x<0) x=0;
+//        if (y<0) y=0;
+
+        if (w && h) {
+            gtk_window_resize ((GtkWindow *) dlg, w, h);
+        }
+        if (x >= 0 && y >= 0 && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE))) {
             gtk_window_move ((GtkWindow *) dlg, x, y);
         } else {
             gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
         }
 
-        if (w && h) {
-            gtk_window_resize ((GtkWindow *) dlg, w, h);
-        }
 
         sp_transientize (dlg);
         wd.win = dlg;