app: sanitize event->button checking in GimpNavigationView

Use if() instead of switch() with one case:, and ignore
double and triple clicks.
This commit is contained in:
Michael Natterer
2011-09-18 01:29:51 +02:00
parent 7afa8665c1
commit f8a2644b13

View File

@ -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;