Fix 1836848: if the window positions and sizes seem to be corrupted, give them sensib...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 27 Nov 2007 01:16:48 +0000 (01:16 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 27 Nov 2007 01:16:48 +0000 (01:16 +0000)
git-svn-id: http://svn.voria.com/code@1167 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/dialogsettings.cpp
synfig-studio/trunk/src/gtkmm/dockmanager.cpp

index c11ef4e..e325dd9 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "dialogsettings.h"
 #include <synfigapp/main.h>
+#include <gdkmm/general.h>
 
 #include "general.h"
 
@@ -116,6 +117,9 @@ DialogSettings::get_value(const synfig::String& key, synfig::String& value)const
 bool
 DialogSettings::set_value(const synfig::String& key,const synfig::String& value)
 {
+       int screen_w(Gdk::screen_width());
+       int screen_h(Gdk::screen_height());
+
        if(value.empty())
                return false;
 
@@ -124,6 +128,10 @@ DialogSettings::set_value(const synfig::String& key,const synfig::String& value)
                int x,y;
                if(!strscanf(value,"%d %d",&x, &y))
                        return false;
+
+               if (x > screen_w) x = screen_w - 150; if (x < 0) x = 0;
+               if (y > screen_h) y = screen_h - 150; if (y < 0) y = 0;
+
                window->move(x,y);
                return true;
        }
@@ -132,6 +140,10 @@ DialogSettings::set_value(const synfig::String& key,const synfig::String& value)
                int x,y;
                if(!strscanf(value,"%d %d",&x, &y))
                        return false;
+
+               if (x > screen_w) x = 150; if (x < 0) x = 0;
+               if (y > screen_h) y = 150; if (y < 0) y = 0;
+
                window->set_default_size(x,y);
                return true;
        }
index 0da07eb..7b5e204 100644 (file)
@@ -145,6 +145,8 @@ public:
                                        int size;
                                        if(!strscanf(value_,"%d",&size))
                                                break;
+                                       if (size > SCALE_FACTOR) size = SCALE_FACTOR - 150;
+                                       if (size < 0) size = 0;
                                        size=size*screen_h/SCALE_FACTOR;
 
                                        // prevent errors like this, by allowing space for at least the dockable's icon:
@@ -172,6 +174,8 @@ public:
                                int x,y;
                                if(!strscanf(value,"%d %d",&x, &y))
                                        return false;
+                               if (x > SCALE_FACTOR) x = SCALE_FACTOR - 150; if (x < 0) x = 0;
+                               if (y > SCALE_FACTOR) y = SCALE_FACTOR - 150; if (y < 0) y = 0;
                                x=x*screen_w/SCALE_FACTOR;
                                y=y*screen_h/SCALE_FACTOR;
                                dock_dialog.move(x,y);
@@ -182,6 +186,8 @@ public:
                                int x,y;
                                if(!strscanf(value,"%d %d",&x, &y))
                                        return false;
+                               if (x > SCALE_FACTOR) x = 150; if (x < 0) x = 0;
+                               if (y > SCALE_FACTOR) y = 150; if (y < 0) y = 0;
                                x=x*screen_w/SCALE_FACTOR;
                                y=y*screen_h/SCALE_FACTOR;
                                dock_dialog.set_default_size(x,y);