Gtk Gestures

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Gtk Gestures

Prashant Kumar
Hello everyone,

I am trying to catch the gtk "rotate" and "zoom" gestures. I wrote a small program just to test how they work in gtk. However both callback functions for "zoom" and "rotate" gesture are getting called even if I make only one type of gesture, but this shouldn't be correct, Could anyone please explain me what am I missing here ?
Thank you very much

#include <gtk/gtk.h>
static void
zoom_gesture_update(GtkGestureZoom* gesture,GdkEventSequence *sequence,GtkWidget* window)
{
    static int i=1;
    g_print("\nzoom gesture update %d",i);
    i++;
}
static void
rotate_gesture_update(GtkGestureRotate* gesture, GdkEventSequence *sequence, GtkWidget* window)
{
    static int i=1;
    g_print("\nrotate_gesture_update %d",i);
    ++i;
}
int
main (int    argc,
      char **argv)
{
 
  GtkWidget *window;
  gtk_init(&argc,&argv);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Window");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
  GtkGesture* gesture_zoom = gtk_gesture_zoom_new(window);
 
  gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture_zoom), GTK_PHASE_BUBBLE);
  g_signal_connect(gesture_zoom,"update",G_CALLBACK(zoom_gesture_update),window);

  GtkGesture* gesture_rotate = gtk_gesture_rotate_new(window);

  gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture_rotate), GTK_PHASE_BUBBLE);
  g_signal_connect(gesture_rotate,"update",G_CALLBACK(rotate_gesture_update),window);

  gtk_widget_show_all (window);

  gtk_main();
}

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Gtk Gestures

Timm Bäder
On 04.07, Prashant Kumar wrote:
> Hello everyone,
>
> I am trying to catch the gtk "rotate" and "zoom" gestures. I wrote a small
> program just to test how they work in gtk. However both callback functions
> for "zoom" and "rotate" gesture are getting called even if I make only one
> type of gesture, but this shouldn't be correct, Could anyone please explain
> me what am I missing here ?
> Thank you very much

zoom and rotate gestures will basically always be triggered at the same
time. You can't use your fingers and do a zooming gesture while not
rotating in any way, or vice versa.

If you want to only trigger one of them, you'll have to make up criteria
(like only use the rotate gesture if the rotation is more than 5
degreee) on your own and set the state of the gesture you don't want
to DENIED.
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Loading...