Code

Only load from preferences when really needed, which might help reducing the processo...
authordvlierop2 <dvlierop2@users.sourceforge.net>
Sun, 10 May 2009 20:55:40 +0000 (20:55 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Sun, 10 May 2009 20:55:40 +0000 (20:55 +0000)
src/event-context.cpp
src/select-context.cpp

index 2bbdcee0703eb90e824e0f7cfcf8c7ef3c37c7bb..b1cfac518ba87c801cf3aee994161ac1b33af4cb 100644 (file)
@@ -348,14 +348,6 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
     /// @todo REmove redundant /value in preference keys
     tolerance = prefs->getIntLimited(
             "/options/dragtolerance/value", 0, 0, 100);
-    double const zoom_inc = prefs->getDoubleLimited(
-            "/options/zoomincrement/value", M_SQRT2, 1.01, 10);
-    double const acceleration = prefs->getDoubleLimited(
-            "/options/scrollingacceleration/value", 0, 0, 6);
-    int const key_scroll = prefs->getIntLimited(
-            "/options/keyscroll/value", 10, 0, 1000);
-    int const wheel_scroll = prefs->getIntLimited(
-            "/options/wheelscroll/value", 40, 0, 1000);
 
     gint ret = FALSE;
 
@@ -486,6 +478,7 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
                 }
                 Geom::Point const event_w(event->button.x, event->button.y);
                 Geom::Point const event_dt(desktop->w2d(event_w));
+                double const zoom_inc = prefs->getDoubleLimited("/options/zoomincrement/value", M_SQRT2, 1.01, 10);
                 desktop->zoom_relative_keep_point(event_dt,
                           (event->button.state & GDK_SHIFT_MASK) ? 1/zoom_inc : zoom_inc);
                 desktop->updateNow();
@@ -515,7 +508,11 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
             }
             break;
         case GDK_KEY_PRESS:
-            switch (get_group0_keyval(&event->key)) {
+               {
+               double const acceleration = prefs->getDoubleLimited("/options/scrollingacceleration/value", 0, 0, 6);
+               int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", 10, 0, 1000);
+
+               switch (get_group0_keyval(&event->key)) {
                 // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets
                 // in the editing window). So we resteal them back and run our regular shortcut
                 // invoker on them.
@@ -629,6 +626,7 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
                 default:
                     break;
             }
+               }
             break;
         case GDK_KEY_RELEASE:
             switch (get_group0_keyval(&event->key)) {
@@ -660,6 +658,8 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
         {
             bool ctrl = (event->scroll.state & GDK_CONTROL_MASK);
             bool wheelzooms = prefs->getBool("/options/wheelzooms/value");
+            int const wheel_scroll = prefs->getIntLimited("/options/wheelscroll/value", 40, 0, 1000);
+
             /* shift + wheel, pan left--right */
             if (event->scroll.state & GDK_SHIFT_MASK) {
                 switch (event->scroll.direction) {
@@ -676,6 +676,7 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
                 /* ctrl + wheel, zoom in--out */
             } else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) {
                 double rel_zoom;
+                double const zoom_inc = prefs->getDoubleLimited("/options/zoomincrement/value", M_SQRT2, 1.01, 10);
                 switch (event->scroll.direction) {
                     case GDK_SCROLL_UP:
                         rel_zoom = zoom_inc;
index aedd3babc9f372e7abd41f7323c75f220c5eab66..f58c034bdb9165a3d75bae9f78988fa6ad4ca0ab 100644 (file)
@@ -410,11 +410,6 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
-    gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px
-    gdouble const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000);
-    tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
-    int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
-
     // make sure we still have valid objects to move around
     if (sc->item && SP_OBJECT_DOCUMENT( SP_OBJECT(sc->item))==NULL) {
         sp_select_context_abort(event_context);
@@ -482,7 +477,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
             break;
 
         case GDK_MOTION_NOTIFY:
-            if (event->motion.state & GDK_BUTTON1_MASK && !event_context->space_panning) {
+               tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
+               if (event->motion.state & GDK_BUTTON1_MASK && !event_context->space_panning) {
                 Geom::Point const motion_pt(event->motion.x, event->motion.y);
                 Geom::Point const p(desktop->w2d(motion_pt));
 
@@ -702,8 +698,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
 
         case GDK_KEY_PRESS: // keybindings for select context
 
-            {
-            guint keyval = get_group0_keyval(&event->key);
+                       {
+                       {
+               guint keyval = get_group0_keyval(&event->key);
             bool alt = ( MOD__ALT
                                     || (keyval == GDK_Alt_L)
                                     || (keyval == GDK_Alt_R)
@@ -737,9 +734,13 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     //*/
                     break;
             }
-            }
+                       }
+
+            gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px
+                       gdouble const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000);
+                       int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
 
-            switch (get_group0_keyval (&event->key)) {
+                       switch (get_group0_keyval (&event->key)) {
                 case GDK_Left: // move selection left
                 case GDK_KP_Left:
                 case GDK_KP_4:
@@ -930,7 +931,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     break;
             }
             break;
-
+                       }
         case GDK_KEY_RELEASE:
             {
             guint keyval = get_group0_keyval(&event->key);