Dear Vikings,

Here is a series of patches that fix a couple of issues that I've come
across. They can be found in the sourceforge tracker as well, but I was
informed that putting patches there wasn't very effective...

Patch 1 filters out irrelevant modifiers when using the scroll wheel so
that users can have num lock or caps lock turned on and still have
working zoom functionality.

Patch 2 is a minor refactoring of the zooming code.

Patch 3 stops Viking from crashing when background jobs (map downloads)
fail or are cancelled. I'm not really sure that this is the right
solution (I haven't dived that deep in the code), but it seems to work.

(and next time I'll set up a GitHub repo. Promise!)

Jonas

-- 
Jonas Norling <norl...@lysator.liu.se>
>From 13fa49cb9c3c17e89b4734de2651382e160ee843 Mon Sep 17 00:00:00 2001
From: Jonas Norling <norl...@lysator.liu.se>
Date: Tue, 26 May 2009 20:06:06 +0200
Subject: Don't crash when jobs are cancelled via the background jobs dialog.

---
 src/background.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/background.c b/src/background.c
index a7c4a3c..d1d0c9b 100644
--- a/src/background.c
+++ b/src/background.c
@@ -62,9 +62,11 @@ int a_background_thread_progress ( gpointer callbackdata, gdouble fraction )
 {
   gpointer *args = (gpointer *) callbackdata;
   int res = a_background_testcancel ( callbackdata );
-  gdk_threads_enter();
-  gtk_list_store_set( GTK_LIST_STORE(bgstore), (GtkTreeIter *) args[5], PROGRESS_COLUMN, fraction*100, -1 );
-  gdk_threads_leave();
+  if (args[5] != NULL) {
+    gdk_threads_enter();
+    gtk_list_store_set( GTK_LIST_STORE(bgstore), (GtkTreeIter *) args[5], PROGRESS_COLUMN, fraction*100, -1 );
+    gdk_threads_leave();
+  }
 
   args[6] = GINT_TO_POINTER(GPOINTER_TO_INT(args[6])-1);
   bgitemcount--;
@@ -166,6 +168,7 @@ static void cancel_job_with_iter ( GtkTreeIter *piter )
     args[0] = GINT_TO_POINTER(1); /* set killswitch */
 
     gtk_list_store_remove ( bgstore, piter );
+    args[5] = NULL;
 }
 
 static void bgwindow_response (GtkDialog *dialog, gint arg1 )
-- 
1.6.0.6


 	  	 
>From e2b3e9e12b9b9c8b10f9120df4e228ac6f4d45f2 Mon Sep 17 00:00:00 2001
From: Jonas Norling <norl...@lysator.liu.se>
Date: Mon, 25 May 2009 21:28:54 +0200
Subject: Join common code in zoom in and zoom out cases.

---
 src/vikwindow.c |   32 +++++++++++---------------------
 1 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/src/vikwindow.c b/src/vikwindow.c
index 5c07371..0f30dd2 100644
--- a/src/vikwindow.c
+++ b/src/vikwindow.c
@@ -576,29 +576,19 @@ static void draw_scroll (VikWindow *vw, GdkEventScroll *event)
     else
       vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)*2/3, vik_viewport_get_height(vw->viking_vvp)/2 );
   } else if ( modifiers == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) ) {
-    if ( event->direction == GDK_SCROLL_UP ) {
-      /* make sure mouse is still over the same point on the map when we zoom */
-      VikCoord coord;
-      gint x, y;
-      gint center_x = vik_viewport_get_width ( vw->viking_vvp ) / 2;
-      gint center_y = vik_viewport_get_height ( vw->viking_vvp ) / 2;
-      vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
+    /* control+shift == make sure mouse is still over the same point on the map when we zoom */
+    VikCoord coord;
+    gint x, y;
+    gint center_x = vik_viewport_get_width ( vw->viking_vvp ) / 2;
+    gint center_y = vik_viewport_get_height ( vw->viking_vvp ) / 2;
+    vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
+    if ( event->direction == GDK_SCROLL_UP )
       vik_viewport_zoom_in (vw->viking_vvp);
-      vik_viewport_coord_to_screen ( vw->viking_vvp, &coord, &x, &y );
-      vik_viewport_set_center_screen ( vw->viking_vvp, center_x + (x - event->x),
-				center_y + (y - event->y) );
-    }
-    else {
-      VikCoord coord;
-      gint x, y;
-      gint center_x = vik_viewport_get_width ( vw->viking_vvp ) / 2;
-      gint center_y = vik_viewport_get_height ( vw->viking_vvp ) / 2;
-      vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
+    else
       vik_viewport_zoom_out(vw->viking_vvp);
-      vik_viewport_coord_to_screen ( vw->viking_vvp, &coord, &x, &y );
-      vik_viewport_set_center_screen ( vw->viking_vvp, center_x + (x - event->x),
-				center_y + (y - event->y) );
-    }
+    vik_viewport_coord_to_screen ( vw->viking_vvp, &coord, &x, &y );
+    vik_viewport_set_center_screen ( vw->viking_vvp, center_x + (x - event->x),
+                                     center_y + (y - event->y) );
   } else {
     if ( event->direction == GDK_SCROLL_UP )
       vik_viewport_zoom_in (vw->viking_vvp);
-- 
1.6.0.6


 	  	 
>From 2f77db4ce96392ca6bac1c5d26a6d81c90076889 Mon Sep 17 00:00:00 2001
From: Jonas Norling <norl...@lysator.liu.se>
Date: Mon, 25 May 2009 21:24:32 +0200
Subject: Filter out irrelevant modifiers.

---
 src/vikwindow.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/vikwindow.c b/src/vikwindow.c
index 1f9309d..5c07371 100644
--- a/src/vikwindow.c
+++ b/src/vikwindow.c
@@ -562,19 +562,20 @@ static void draw_release ( VikWindow *vw, GdkEventButton *event )
 
 static void draw_scroll (VikWindow *vw, GdkEventScroll *event)
 {
-  if ( event->state == GDK_CONTROL_MASK ) {
+  guint modifiers = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK);
+  if ( modifiers == GDK_CONTROL_MASK ) {
     /* control == pan up & down */
     if ( event->direction == GDK_SCROLL_UP )
       vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)/2, vik_viewport_get_height(vw->viking_vvp)/3 );
     else
       vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)/2, vik_viewport_get_height(vw->viking_vvp)*2/3 );
-  } else if ( event->state == GDK_SHIFT_MASK ) {
-    /* control-shift == pan left & right */
+  } else if ( modifiers == GDK_SHIFT_MASK ) {
+    /* shift == pan left & right */
     if ( event->direction == GDK_SCROLL_UP )
       vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)/3, vik_viewport_get_height(vw->viking_vvp)/2 );
     else
       vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)*2/3, vik_viewport_get_height(vw->viking_vvp)/2 );
-  } else if ( event->state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) ) {
+  } else if ( modifiers == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) ) {
     if ( event->direction == GDK_SCROLL_UP ) {
       /* make sure mouse is still over the same point on the map when we zoom */
       VikCoord coord;
-- 
1.6.0.6


 	  	 
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Viking-devel mailing list
Viking-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viking-devel
Viking home page: http://viking.sf.net/

Reply via email to