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:
Carlos Garnacho 2012-10-05 00:33:30 +02:00 committed by Simon Schampijer
parent b79a391902
commit 78ae2459e3
2 changed files with 22 additions and 0 deletions

View File

@ -34,6 +34,11 @@ enum {
PROP_TRIGGER_DELAY
};
enum {
PRESSED,
N_SIGNALS
};
struct _SugarLongPressControllerPriv
{
GdkDevice *device;
@ -52,6 +57,8 @@ struct _SugarLongPressControllerPriv
guint triggered : 1;
};
static guint signals[N_SIGNALS] = { 0 };
G_DEFINE_TYPE (SugarLongPressController,
sugar_long_press_controller,
SUGAR_TYPE_EVENT_CONTROLLER)
@ -321,6 +328,8 @@ _sugar_long_press_controller_timeout (gpointer user_data)
priv->triggered = TRUE;
g_signal_emit_by_name (controller, "began");
g_signal_emit (controller, signals[PRESSED], 0, priv->x, priv->y);
return FALSE;
}
@ -462,6 +471,15 @@ sugar_long_press_controller_class_init (SugarLongPressControllerClass *klass)
G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK |
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));
}

View File

@ -50,6 +50,10 @@ struct _SugarLongPressController
struct _SugarLongPressControllerClass
{
SugarEventControllerClass parent_class;
void (* pressed) (SugarLongPressController *controller,
gint x,
gint y);
};
GType sugar_long_press_controller_get_type (void) G_GNUC_CONST;