Пример #1
0
static void
gtk_gesture_multi_press_cancel (GtkGesture       *gesture,
                                GdkEventSequence *sequence)
{
    _gtk_gesture_multi_press_stop (GTK_GESTURE_MULTI_PRESS (gesture));
    GTK_GESTURE_CLASS (gtk_gesture_multi_press_parent_class)->cancel (gesture, sequence);
}
Пример #2
0
static void
gtk_gesture_long_press_class_init (GtkGestureLongPressClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
  GtkGestureClass *gesture_class = GTK_GESTURE_CLASS (klass);

  object_class->finalize = gtk_gesture_long_press_finalize;
  object_class->get_property = gtk_gesture_long_press_get_property;
  object_class->set_property = gtk_gesture_long_press_set_property;

  gesture_class->check = gtk_gesture_long_press_check;
  gesture_class->begin = gtk_gesture_long_press_begin;
  gesture_class->update = gtk_gesture_long_press_update;
  gesture_class->end = gtk_gesture_long_press_end;
  gesture_class->cancel = gtk_gesture_long_press_cancel;
  gesture_class->sequence_state_changed = gtk_gesture_long_press_sequence_state_changed;

  g_object_class_install_property (object_class,
                                   PROP_DELAY_FACTOR,
                                   g_param_spec_double ("delay-factor",
                                                        P_("Delay factor"),
                                                        P_("Factor by which to modify the default timeout"),
                                                        0.5, 2.0, 1.0,
                                                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

  /**
   * GtkGestureLongPress::pressed:
   * @gesture: the object which received the signal
   * @x: the X coordinate where the press happened, relative to the widget allocation
   * @y: the Y coordinate where the press happened, relative to the widget allocation
   *
   * This signal is emitted whenever a press goes unmoved/unreleased longer than
   * what the GTK+ defaults tell.
   *
   * Since: 3.14
   */
  signals[PRESSED] =
    g_signal_new (I_("pressed"),
                  G_TYPE_FROM_CLASS (klass),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GtkGestureLongPressClass, pressed),
                  NULL, NULL, NULL,
                  G_TYPE_NONE, 2, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
  /**
   * GtkGestureLongPress::cancelled:
   * @gesture: the object which received the signal
   *
   * This signal is emitted whenever a press moved too far, or was released
   * before #GtkGestureLongPress::pressed happened.
   *
   * Since: 3.14
   */
  signals[CANCELLED] =
    g_signal_new (I_("cancelled"),
                  G_TYPE_FROM_CLASS (klass),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GtkGestureLongPressClass, cancelled),
                  NULL, NULL, NULL,
                  G_TYPE_NONE, 0);
}
Пример #3
0
static void
gtk_gesture_long_press_cancel (GtkGesture       *gesture,
                               GdkEventSequence *sequence)
{
  gtk_gesture_long_press_end (gesture, sequence);
  GTK_GESTURE_CLASS (gtk_gesture_long_press_parent_class)->cancel (gesture, sequence);
}
Пример #4
0
static gboolean
gtk_gesture_long_press_check (GtkGesture *gesture)
{
  GtkGestureLongPressPrivate *priv;

  priv = gtk_gesture_long_press_get_instance_private (GTK_GESTURE_LONG_PRESS (gesture));

  if (priv->cancelled)
    return FALSE;

  return GTK_GESTURE_CLASS (gtk_gesture_long_press_parent_class)->check (gesture);
}
Пример #5
0
static void
gtk_gesture_multi_press_class_init (GtkGestureMultiPressClass *klass)
{
    GtkEventControllerClass *controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
    GObjectClass *object_class = G_OBJECT_CLASS (klass);
    GtkGestureClass *gesture_class = GTK_GESTURE_CLASS (klass);

    object_class->finalize = gtk_gesture_multi_press_finalize;

    gesture_class->check = gtk_gesture_multi_press_check;
    gesture_class->begin = gtk_gesture_multi_press_begin;
    gesture_class->update = gtk_gesture_multi_press_update;
    gesture_class->end = gtk_gesture_multi_press_end;
    gesture_class->cancel = gtk_gesture_multi_press_cancel;

    controller_class->reset = gtk_gesture_multi_press_reset;

    /**
     * GtkGestureMultiPress::pressed:
     * @gesture: the object which received the signal
     * @n_press: how many touch/button presses happened with this one
     * @x: The X coordinate, in widget allocation coordinates
     * @y: The Y coordinate, in widget allocation coordinates
     *
     * This signal is emitted whenever a button or touch press happens.
     *
     * Since: 3.14
     */
    signals[PRESSED] =
        g_signal_new (I_("pressed"),
                      G_TYPE_FROM_CLASS (klass),
                      G_SIGNAL_RUN_LAST,
                      G_STRUCT_OFFSET (GtkGestureMultiPressClass, pressed),
                      NULL, NULL, NULL,
                      G_TYPE_NONE, 3, G_TYPE_INT,
                      G_TYPE_DOUBLE, G_TYPE_DOUBLE);

    /**
     * GtkGestureMultiPress::released:
     * @gesture: the object which received the signal
     * @n_press: number of press that is paired with this release
     * @x: The X coordinate, in widget allocation coordinates
     * @y: The Y coordinate, in widget allocation coordinates
     *
     * This signal is emitted when a button or touch is released. @n_press
     * will report the number of press that is paired to this event, note
     * that #GtkGestureMultiPress::stopped may have been emitted between the
     * press and its release, @n_press will only start over at the next press.
     *
     * Since: 3.14
     */
    signals[RELEASED] =
        g_signal_new (I_("released"),
                      G_TYPE_FROM_CLASS (klass),
                      G_SIGNAL_RUN_LAST,
                      G_STRUCT_OFFSET (GtkGestureMultiPressClass, released),
                      NULL, NULL, NULL,
                      G_TYPE_NONE, 3, G_TYPE_INT,
                      G_TYPE_DOUBLE, G_TYPE_DOUBLE);
    /**
     * GtkGestureMultiPress::stopped:
     * @gesture: the object which received the signal
     *
     * This signal is emitted whenever any time/distance threshold has
     * been exceeded.
     *
     * Since: 3.14
     */
    signals[STOPPED] =
        g_signal_new (I_("stopped"),
                      G_TYPE_FROM_CLASS (klass),
                      G_SIGNAL_RUN_LAST,
                      G_STRUCT_OFFSET (GtkGestureMultiPressClass, stopped),
                      NULL, NULL, NULL,
                      G_TYPE_NONE, 0);
}
Пример #6
0
static void
gtk_gesture_single_class_init (GtkGestureSingleClass *klass)
{
  GtkEventControllerClass *controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
  GtkGestureClass *gesture_class = GTK_GESTURE_CLASS (klass);
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  object_class->get_property = gtk_gesture_single_get_property;
  object_class->set_property = gtk_gesture_single_set_property;

  controller_class->handle_event = gtk_gesture_single_handle_event;

  gesture_class->cancel = gtk_gesture_single_cancel;

  /**
   * GtkGestureSingle:touch-only:
   *
   * Whether the gesture handles only touch events.
   *
   * Since: 3.14
   */
  g_object_class_install_property (object_class,
                                   PROP_TOUCH_ONLY,
                                   g_param_spec_boolean ("touch-only",
                                                         P_("Handle only touch events"),
                                                         P_("Whether the gesture handles"
                                                            " only touch events"),
                                                         FALSE,
                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));

  /**
   * GtkGestureSingle:exclusive:
   *
   * Whether the gesture is exclusive. Exclusive gestures only listen to pointer
   * and pointer emulated events.
   *
   * Since: 3.14
   */
  g_object_class_install_property (object_class,
                                   PROP_EXCLUSIVE,
                                   g_param_spec_boolean ("exclusive",
                                                         P_("Whether the gesture is exclusive"),
                                                         P_("Whether the gesture is exclusive"),
                                                         FALSE,
                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));

  /**
   * GtkGestureSingle:button:
   *
   * Mouse button number to listen to, or 0 to listen for any button.
   *
   * Since: 3.14
   */
  g_object_class_install_property (object_class,
                                   PROP_BUTTON,
                                   g_param_spec_uint ("button",
                                                      P_("Button number"),
                                                      P_("Button number to listen to"),
                                                      0, G_MAXUINT, GDK_BUTTON_PRIMARY,
                                                      GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
}