LongPressController: add 'pressed' signal with x and y coordinates
The 'pressed' signal does emit the x and y coordinates of the position where the event occurred. This can be used for example in the Browser where we need to know at which exact position the long-press event occurred. Signed-off-by: Carlos Garnacho <carlos@lanedo.com> Acked-by: Simon Schampijer <simon@laptop.org>
This commit is contained in:
parent
b79a391902
commit
78ae2459e3
@ -34,6 +34,11 @@ enum {
|
|||||||
PROP_TRIGGER_DELAY
|
PROP_TRIGGER_DELAY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PRESSED,
|
||||||
|
N_SIGNALS
|
||||||
|
};
|
||||||
|
|
||||||
struct _SugarLongPressControllerPriv
|
struct _SugarLongPressControllerPriv
|
||||||
{
|
{
|
||||||
GdkDevice *device;
|
GdkDevice *device;
|
||||||
@ -52,6 +57,8 @@ struct _SugarLongPressControllerPriv
|
|||||||
guint triggered : 1;
|
guint triggered : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static guint signals[N_SIGNALS] = { 0 };
|
||||||
|
|
||||||
G_DEFINE_TYPE (SugarLongPressController,
|
G_DEFINE_TYPE (SugarLongPressController,
|
||||||
sugar_long_press_controller,
|
sugar_long_press_controller,
|
||||||
SUGAR_TYPE_EVENT_CONTROLLER)
|
SUGAR_TYPE_EVENT_CONTROLLER)
|
||||||
@ -321,6 +328,8 @@ _sugar_long_press_controller_timeout (gpointer user_data)
|
|||||||
priv->triggered = TRUE;
|
priv->triggered = TRUE;
|
||||||
g_signal_emit_by_name (controller, "began");
|
g_signal_emit_by_name (controller, "began");
|
||||||
|
|
||||||
|
g_signal_emit (controller, signals[PRESSED], 0, priv->x, priv->y);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,6 +471,15 @@ sugar_long_press_controller_class_init (SugarLongPressControllerClass *klass)
|
|||||||
G_PARAM_STATIC_NAME |
|
G_PARAM_STATIC_NAME |
|
||||||
G_PARAM_STATIC_NICK |
|
G_PARAM_STATIC_NICK |
|
||||||
G_PARAM_STATIC_BLURB));
|
G_PARAM_STATIC_BLURB));
|
||||||
|
signals[PRESSED] =
|
||||||
|
g_signal_new ("pressed",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (SugarLongPressControllerClass, pressed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_generic,
|
||||||
|
G_TYPE_NONE, 2,
|
||||||
|
G_TYPE_INT, G_TYPE_INT);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (SugarLongPressControllerPriv));
|
g_type_class_add_private (klass, sizeof (SugarLongPressControllerPriv));
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,10 @@ struct _SugarLongPressController
|
|||||||
struct _SugarLongPressControllerClass
|
struct _SugarLongPressControllerClass
|
||||||
{
|
{
|
||||||
SugarEventControllerClass parent_class;
|
SugarEventControllerClass parent_class;
|
||||||
|
|
||||||
|
void (* pressed) (SugarLongPressController *controller,
|
||||||
|
gint x,
|
||||||
|
gint y);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType sugar_long_press_controller_get_type (void) G_GNUC_CONST;
|
GType sugar_long_press_controller_get_type (void) G_GNUC_CONST;
|
||||||
|
Loading…
Reference in New Issue
Block a user