[gnome-games] aisleriot: Implement status messages for the clutter board too
- From: Christian Persch <chpe src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games] aisleriot: Implement status messages for the clutter board too
- Date: Sun, 10 Jan 2010 20:45:46 +0000 (UTC)
commit 159a989330df74a4ff19fb99b71899b315fe119c
Author: Christian Persch <chpe gnome org>
Date: Sun Jan 10 21:44:42 2010 +0100
aisleriot: Implement status messages for the clutter board too
aisleriot/board-noclutter.c | 2 +-
aisleriot/board.c | 68 +++++++++++++++++++++++++++++++++++++++++++
aisleriot/board.h | 3 ++
aisleriot/window.c | 6 ++++
4 files changed, 78 insertions(+), 1 deletions(-)
---
diff --git a/aisleriot/board-noclutter.c b/aisleriot/board-noclutter.c
index f5441ac..af50210 100644
--- a/aisleriot/board-noclutter.c
+++ b/aisleriot/board-noclutter.c
@@ -2562,7 +2562,7 @@ aisleriot_board_sync_style (ArStyle *style,
}
}
}
-#endif
+#endif /* !HAVE_HILDON */
if (update_geometry && GTK_WIDGET_REALIZED (widget)) {
aisleriot_board_setup_geometry (board);
diff --git a/aisleriot/board.c b/aisleriot/board.c
index cfaa475..8a87e66 100644
--- a/aisleriot/board.c
+++ b/aisleriot/board.c
@@ -177,6 +177,9 @@ struct _AisleriotBoardPrivate
trigger animations */
guint check_animations_handler;
+ /* Status message */
+ const char *status_message; /* interned */
+
/* Bit field */
guint droppable_supported : 1;
guint touchscreen_mode : 1;
@@ -194,6 +197,7 @@ struct _AisleriotBoardPrivate
guint show_selection : 1;
guint show_highlight : 1;
+ guint show_status_messages : 1;
guint force_geometry_update : 1;
};
@@ -220,6 +224,7 @@ enum
{
REQUEST_CURSOR,
ERROR_BELL,
+ STATUS_MESSAGE,
FOCUS,
#ifdef ENABLE_KEYNAV
ACTIVATE,
@@ -302,6 +307,22 @@ set_cursor_by_location (AisleriotBoard *board,
#endif /* !HAVE_HILDON */
}
+/* status message */
+
+static void
+set_status_message (AisleriotBoard *board,
+ const char *message)
+{
+ AisleriotBoardPrivate *priv = board->priv;
+
+ if (g_strcmp0 (priv->status_message, message) == 0)
+ return;
+
+ priv->status_message = g_intern_string (message);
+
+ g_signal_emit (board, signals[STATUS_MESSAGE], 0, priv->status_message);
+}
+
/* Slot helpers */
static void
@@ -2229,6 +2250,23 @@ aisleriot_board_sync_style (ArStyle *style,
}
}
+#ifndef HAVE_HILDON
+ if (pspec_name == NULL || pspec_name == I_(AR_STYLE_PROP_SHOW_STATUS_MESSAGES)) {
+ gboolean show_status_messages;
+
+ show_status_messages = ar_style_get_show_status_messages (priv->style);
+
+ if (show_status_messages != priv->show_status_messages) {
+ priv->show_status_messages = show_status_messages;
+
+ if (!show_status_messages) {
+ /* Clear message */
+ set_status_message (board, NULL);
+ }
+ }
+ }
+#endif /* !HAVE_HILDON */
+
/* FIXMEchpe: queue a relayout instead? */
if (update_geometry) {
aisleriot_board_setup_geometry (board);
@@ -2965,6 +3003,24 @@ aisleriot_board_motion (ClutterActor *actor,
* parent classes have no class closure for this event.
*/
+#ifndef HAVE_HILDON
+ if (priv->show_status_messages) {
+ ArSlot *slot = NULL;
+ int cardid = -1;
+
+ get_slot_and_card_from_point (board, event->x, event->y, &slot, &cardid);
+ if (slot != NULL && ar_slot_get_slot_type (slot) != AR_SLOT_UNKNOWN) {
+ char *text;
+
+ text = ar_slot_get_hint_string (slot, cardid);
+ set_status_message (board, text);
+ g_free (text);
+ } else {
+ set_status_message (board, NULL);
+ }
+ }
+#endif /* !HAVE_HILDON */
+
if (priv->click_status == STATUS_IS_DRAG) {
ArSlot *slot;
int x, y;
@@ -3062,6 +3118,7 @@ aisleriot_board_init (AisleriotBoard *board)
priv->click_to_move = FALSE;
priv->show_selection = FALSE;
+ priv->show_status_messages = FALSE;
priv->show_card_id = -1;
@@ -3227,6 +3284,17 @@ aisleriot_board_class_init (AisleriotBoardClass *klass)
G_TYPE_NONE,
0);
+ signals[STATUS_MESSAGE] =
+ g_signal_new (I_("status-message"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (AisleriotBoardClass, status_message),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+
signals[ERROR_BELL] =
g_signal_new (I_("focus"),
G_TYPE_FROM_CLASS (gobject_class),
diff --git a/aisleriot/board.h b/aisleriot/board.h
index 908fceb..9af01df 100644
--- a/aisleriot/board.h
+++ b/aisleriot/board.h
@@ -57,6 +57,9 @@ struct _AisleriotBoardClass {
void (* error_bell) (AisleriotBoard *board);
+ void (* status_message) (AisleriotBoard *board,
+ const char *message);
+
/* Focus */
gboolean (* focus) (AisleriotBoard *,
int direction);
diff --git a/aisleriot/window.c b/aisleriot/window.c
index e6fbb6b..1f49c0f 100644
--- a/aisleriot/window.c
+++ b/aisleriot/window.c
@@ -2582,8 +2582,14 @@ aisleriot_window_init (AisleriotWindow *window)
GTK_WIDGET (priv->statusbar));
priv->game_message_id = gtk_statusbar_get_context_id (priv->statusbar, "board-message");
+
+#ifdef HAVE_CLUTTER
+ g_signal_connect (priv->board_actor, "status-message",
+ G_CALLBACK (board_status_message_cb), window);
+#else
g_signal_connect (priv->board, "status-message",
G_CALLBACK (board_status_message_cb), window);
+#endif
#if GTK_CHECK_VERSION (2, 11, 0)
gtk_statusbar_set_has_resize_grip (priv->statusbar, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]