[gimp] app: sanitize event->button checking in GimpNavigationView



commit f8a2644b13fb7ea279dd21cf32844c5f519b2133
Author: Michael Natterer <mitch gimp org>
Date:   Sun Sep 18 01:29:51 2011 +0200

    app: sanitize event->button checking in GimpNavigationView
    
    Use if() instead of switch() with one case:, and ignore
    double and triple clicks.

 app/widgets/gimpnavigationview.c |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)
---
diff --git a/app/widgets/gimpnavigationview.c b/app/widgets/gimpnavigationview.c
index 298898b..06bb08e 100644
--- a/app/widgets/gimpnavigationview.c
+++ b/app/widgets/gimpnavigationview.c
@@ -246,9 +246,8 @@ gimp_navigation_view_button_press (GtkWidget      *widget,
   tx = bevent->x;
   ty = bevent->y;
 
-  switch (bevent->button)
+  if (bevent->type == GDK_BUTTON_PRESS && bevent->button == 1)
     {
-    case 1:
       if (! (tx >  nav_view->p_x &&
              tx < (nav_view->p_x + nav_view->p_width) &&
              ty >  nav_view->p_y &&
@@ -276,10 +275,6 @@ gimp_navigation_view_button_press (GtkWidget      *widget,
         }
 
       gimp_navigation_view_grab_pointer (nav_view);
-      break;
-
-    default:
-      break;
     }
 
   return TRUE;
@@ -291,18 +286,13 @@ gimp_navigation_view_button_release (GtkWidget      *widget,
 {
   GimpNavigationView *nav_view = GIMP_NAVIGATION_VIEW (widget);
 
-  switch (bevent->button)
+  if (bevent->button == 1 && nav_view->has_grab)
     {
-    case 1:
       nav_view->has_grab = FALSE;
 
       gtk_grab_remove (widget);
       gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
                                   GDK_CURRENT_TIME);
-      break;
-
-    default:
-      break;
     }
 
   return TRUE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]