[gnome-games] Use signal connections for tap-and-hold instead of the class handlers
- From: Christian Persch <chpe src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games] Use signal connections for tap-and-hold instead of the class handlers
- Date: Tue, 2 Jun 2009 18:16:15 -0400 (EDT)
commit 21477276734adf0c1422d232839c5106793482f5
Author: Christian Persch <chpe gnome org>
Date: Tue Jun 2 23:45:40 2009 +0200
Use signal connections for tap-and-hold instead of the class handlers
Maemo5 removes these slots from GtkWidgetClass, so convert to using
callbacks with g_signal_connect().
---
aisleriot/board-noclutter.c | 34 +++++++++++++++++++---------------
aisleriot/board.c | 30 +++++++++++++++++++-----------
2 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/aisleriot/board-noclutter.c b/aisleriot/board-noclutter.c
index ca491f4..39209cb 100644
--- a/aisleriot/board-noclutter.c
+++ b/aisleriot/board-noclutter.c
@@ -2967,16 +2967,20 @@ aisleriot_board_key_press (GtkWidget *widget,
#ifdef HAVE_MAEMO
static gboolean
-aisleriot_board_tap_and_hold_query (GtkWidget *widget,
- GdkEvent *_event)
+aisleriot_board_tap_and_hold_query_cb (GtkWidget *widget,
+ GdkEvent *_event,
+ AisleriotBoard *board)
{
- AisleriotBoard *board = AISLERIOT_BOARD (widget);
AisleriotBoardPrivate *priv = board->priv;
/* BadDocs! should mention that this is a GdkEventButton! */
GdkEventButton *event = (GdkEventButton *) _event;
Slot *slot;
int card_id;
+ /* NOTE: Returning TRUE from this function means that tap-and-hold
+ * is disallowed here; FALSE means to allow tap-and-hold.
+ */
+
/* In click-to-move mode, we always reveal with just the left click */
if (priv->click_to_move)
return TRUE;
@@ -2990,21 +2994,21 @@ aisleriot_board_tap_and_hold_query (GtkWidget *widget,
priv->tap_and_hold_slot = slot;
priv->tap_and_hold_card_id = card_id;
-
- return GTK_WIDGET_CLASS (aisleriot_board_parent_class)->tap_and_hold_query (widget, _event);
+
+ return FALSE; /* chain up to the default handler */
}
static void
-aisleriot_board_tap_and_hold (GtkWidget *widget)
+aisleriot_board_tap_and_hold_cb (GtkWidget *widget,
+ AisleriotBoard *board)
{
- AisleriotBoard *board = AISLERIOT_BOARD (widget);
AisleriotBoardPrivate *priv = board->priv;
- g_assert (priv->tap_and_hold_slot != NULL && priv->tap_and_hold_card_id >= 0);
+ if (priv->tap_and_hold_slot == NULL ||
+ priv->tap_and_hold_card_id < 0)
+ return;
reveal_card (board, priv->tap_and_hold_slot, priv->tap_and_hold_card_id);
-
- GTK_WIDGET_CLASS (aisleriot_board_parent_class)->tap_and_hold (widget);
}
#endif /* HAVE_MAEMO */
@@ -3310,7 +3314,11 @@ aisleriot_board_init (AisleriotBoard *board)
#ifdef HAVE_MAEMO
gtk_widget_tap_and_hold_setup (widget, NULL, NULL, GTK_TAP_AND_HOLD_PASS_PRESS);
-#endif
+ g_signal_connect (widget, "tap-and-hold-query",
+ G_CALLBACK (aisleriot_board_tap_and_hold_query_cb), board);
+ g_signal_connect (widget, "tap-and-hold",
+ G_CALLBACK (aisleriot_board_tap_and_hold_cb), board);
+#endif /* HAVE_MAEMO */
}
static GObject *
@@ -3440,10 +3448,6 @@ aisleriot_board_class_init (AisleriotBoardClass *klass)
widget_class->motion_notify_event = aisleriot_board_motion_notify;
widget_class->key_press_event = aisleriot_board_key_press;
widget_class->expose_event = aisleriot_board_expose_event;
-#ifdef HAVE_MAEMO
- widget_class->tap_and_hold_query = aisleriot_board_tap_and_hold_query;
- widget_class->tap_and_hold = aisleriot_board_tap_and_hold;
-#endif /* HAVE_MAEMO */
#ifdef ENABLE_KEYNAV
klass->activate = aisleriot_board_activate;
diff --git a/aisleriot/board.c b/aisleriot/board.c
index c5ec129..f688349 100644
--- a/aisleriot/board.c
+++ b/aisleriot/board.c
@@ -3107,16 +3107,20 @@ aisleriot_board_key_press (GtkWidget *widget,
#ifdef HAVE_MAEMO
static gboolean
-aisleriot_board_tap_and_hold_query (GtkWidget *widget,
- GdkEvent *_event)
+aisleriot_board_tap_and_hold_query_cb (GtkWidget *widget,
+ GdkEvent *_event,
+ AisleriotBoard *board)
{
- AisleriotBoard *board = AISLERIOT_BOARD (widget);
AisleriotBoardPrivate *priv = board->priv;
/* BadDocs! should mention that this is a GdkEventButton! */
GdkEventButton *event = (GdkEventButton *) _event;
Slot *slot;
int card_id;
+ /* NOTE: Returning TRUE from this function means that tap-and-hold
+ * is disallowed here; FALSE means to allow tap-and-hold.
+ */
+
/* In click-to-move mode, we always reveal with just the left click */
if (priv->click_to_move)
return TRUE;
@@ -3130,21 +3134,21 @@ aisleriot_board_tap_and_hold_query (GtkWidget *widget,
priv->tap_and_hold_slot = slot;
priv->tap_and_hold_card_id = card_id;
-
- return GTK_WIDGET_CLASS (aisleriot_board_parent_class)->tap_and_hold_query (widget, _event);
+
+ return FALSE; /* chain up to the default handler */
}
static void
-aisleriot_board_tap_and_hold (GtkWidget *widget)
+aisleriot_board_tap_and_hold_cb (GtkWidget *widget,
+ AisleriotBoard *board)
{
- AisleriotBoard *board = AISLERIOT_BOARD (widget);
AisleriotBoardPrivate *priv = board->priv;
- g_assert (priv->tap_and_hold_slot != NULL && priv->tap_and_hold_card_id >= 0);
+ if (priv->tap_and_hold_slot == NULL ||
+ priv->tap_and_hold_card_id < 0)
+ return;
reveal_card (board, priv->tap_and_hold_slot, priv->tap_and_hold_card_id);
-
- GTK_WIDGET_CLASS (aisleriot_board_parent_class)->tap_and_hold (widget);
}
#endif /* HAVE_MAEMO */
@@ -3188,7 +3192,11 @@ aisleriot_board_init (AisleriotBoard *board)
#ifdef HAVE_MAEMO
gtk_widget_tap_and_hold_setup (widget, NULL, NULL, GTK_TAP_AND_HOLD_PASS_PRESS);
-#endif
+ g_signal_connect (widget, "tap-and-hold-query",
+ G_CALLBACK (aisleriot_board_tap_and_hold_query_cb), board);
+ g_signal_connect (widget, "tap-and-hold",
+ G_CALLBACK (aisleriot_board_tap_and_hold_cb), board);
+#endif /* HAVE_MAEMO */
stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (board));
priv->animation_layer = g_object_ref_sink (clutter_group_new ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]