mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
gesture-action: add n-touch-points property
https://bugzilla.gnome.org/show_bug.cgi?id=698668
This commit is contained in:
parent
ed92f63f30
commit
2b25b056ad
@ -126,6 +126,15 @@ struct _ClutterGestureActionPrivate
|
||||
guint in_gesture : 1;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_N_TOUCH_POINTS,
|
||||
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GESTURE_BEGIN,
|
||||
@ -136,6 +145,7 @@ enum
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static GParamSpec *gesture_props[PROP_LAST];
|
||||
static guint gesture_signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
G_DEFINE_TYPE (ClutterGestureAction, clutter_gesture_action, CLUTTER_TYPE_ACTION);
|
||||
@ -515,19 +525,92 @@ _clutter_gesture_action_set_threshold_trigger_edge (ClutterGestureAction *a
|
||||
action->priv->edge = edge;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_gesture_action_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterGestureAction *self = CLUTTER_GESTURE_ACTION (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_N_TOUCH_POINTS:
|
||||
clutter_gesture_action_set_n_touch_points (self, g_value_get_int (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_gesture_action_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterGestureAction *self = CLUTTER_GESTURE_ACTION (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_N_TOUCH_POINTS:
|
||||
g_value_set_int (value, self->priv->requested_nb_points);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_gesture_action_finalize (GObject *gobject)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv = CLUTTER_GESTURE_ACTION (gobject)->priv;
|
||||
|
||||
g_array_unref (priv->points);
|
||||
|
||||
G_OBJECT_CLASS (clutter_gesture_action_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_gesture_action_class_init (ClutterGestureActionClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorMetaClass *meta_class = CLUTTER_ACTOR_META_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (ClutterGestureActionPrivate));
|
||||
|
||||
gobject_class->finalize = clutter_gesture_action_finalize;
|
||||
gobject_class->set_property = clutter_gesture_action_set_property;
|
||||
gobject_class->get_property = clutter_gesture_action_get_property;
|
||||
|
||||
meta_class->set_actor = clutter_gesture_action_set_actor;
|
||||
|
||||
klass->gesture_begin = default_event_handler;
|
||||
klass->gesture_progress = default_event_handler;
|
||||
klass->gesture_prepare = default_event_handler;
|
||||
|
||||
/**
|
||||
* ClutterGestureAction:n-touch-points:
|
||||
*
|
||||
* Number of touch points to trigger a gesture action.
|
||||
*
|
||||
* Since: 1.16
|
||||
*/
|
||||
gesture_props[PROP_N_TOUCH_POINTS] =
|
||||
g_param_spec_int ("n-touch-points",
|
||||
P_("Number touch points"),
|
||||
P_("Number of touch points"),
|
||||
1, G_MAXINT, 1,
|
||||
CLUTTER_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (gobject_class,
|
||||
PROP_LAST,
|
||||
gesture_props);
|
||||
|
||||
/**
|
||||
* ClutterGestureAction::gesture-begin:
|
||||
* @action: the #ClutterGestureAction that emitted the signal
|
||||
@ -876,6 +959,9 @@ clutter_gesture_action_set_n_touch_points (ClutterGestureAction *action,
|
||||
|
||||
priv = action->priv;
|
||||
|
||||
if (priv->requested_nb_points == nb_points)
|
||||
return;
|
||||
|
||||
priv->requested_nb_points = nb_points;
|
||||
|
||||
if (priv->in_gesture)
|
||||
@ -906,6 +992,9 @@ clutter_gesture_action_set_n_touch_points (ClutterGestureAction *action,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (action),
|
||||
gesture_props[PROP_N_TOUCH_POINTS]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user