[gnome-games] aisleriot: Add baize colour property to ArStyle



commit 1a7288684e906cb46d431800159e030c971ad33d
Author: Christian Persch <chpe gnome org>
Date:   Fri May 21 21:48:23 2010 +0200

    aisleriot: Add baize colour property to ArStyle

 aisleriot/ar-style-private.h |    3 ++
 aisleriot/ar-style.c         |   71 ++++++++++++++++++++++++++++++++++++++++++
 aisleriot/ar-style.h         |    5 +++
 3 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/aisleriot/ar-style-private.h b/aisleriot/ar-style-private.h
index b933c88..b61c26c 100644
--- a/aisleriot/ar-style-private.h
+++ b/aisleriot/ar-style-private.h
@@ -21,6 +21,7 @@
 G_BEGIN_DECLS
 
 static const GdkColor default_selection_color = { 0, 0 /* red */, 0 /* green */, 0xaa00 /* blue */ };
+static const GdkColor default_baize_color = { 0, 0 /* red */, 0x5000 /* green */, 0x1000 /* blue */ };
 
 /* The proportion of a slot dedicated to the card (horiz or vert). */
 #ifdef HAVE_HILDON
@@ -50,8 +51,10 @@ struct _ArStylePrivate
 
 #ifdef HAVE_CLUTTER
   ClutterColor selection_color;
+  ClutterColor baize_color;
 #else
   GdkColor selection_color;
+  GdkColor baize_color;
 #endif
 
   double card_slot_ratio;
diff --git a/aisleriot/ar-style.c b/aisleriot/ar-style.c
index beaa488..3a074df 100644
--- a/aisleriot/ar-style.c
+++ b/aisleriot/ar-style.c
@@ -26,6 +26,7 @@
 enum
 {
   PROP_0,
+  PROP_BAIZE_COLOR,
   PROP_CARD_OVERHANG,
   PROP_CARD_SLOT_RATIO,
   PROP_CARD_STEP,
@@ -63,8 +64,10 @@ ar_style_init (ArStyle *style)
 
 #ifdef HAVE_CLUTTER
   _ar_clutter_color_from_gdk_color (&priv->selection_color, &default_selection_color);
+  _ar_clutter_color_from_gdk_color (&priv->baize_color, &default_baize_color);
 #else
   priv->selection_color = default_selection_color;
+  priv->baize_color = default_baize_color;
 #endif
 
   priv->card_slot_ratio = DEFAULT_CARD_SLOT_RATIO;
@@ -130,6 +133,10 @@ ar_style_get_property (GObject    *object,
   ArStylePrivate *priv = style->priv;
 
   switch (property_id) {
+    case PROP_BAIZE_COLOR:
+      g_value_set_boxed (value, &priv->baize_color);
+      break;
+
     case PROP_CARD_OVERHANG:
       g_value_set_double (value, ar_style_get_card_overhang (style));
       break;
@@ -219,6 +226,27 @@ ar_style_set_property (GObject      *object,
   ArStylePrivate *priv = style->priv;
 
   switch (property_id) {
+    case PROP_BAIZE_COLOR: {
+#ifdef HAVE_CLUTTER
+      ClutterColor *color;
+
+      if ((color = g_value_get_boxed (value)) != NULL) {
+        priv->baize_color = *color;
+      } else {
+        _ar_clutter_color_from_gdk_color (&priv->baize_color, &default_baize_color);
+      }
+#else
+      GdkColor *color;
+
+      if ((color = g_value_get_boxed (value)) != NULL) {
+        priv->baize_color = *color;
+      } else {
+        priv->baize_color = default_baize_color;
+      }
+#endif
+      break;
+    }
+
     case PROP_CARD_OVERHANG:
       priv->card_overhang = g_value_get_double (value);
       break;
@@ -328,6 +356,30 @@ ar_style_class_init (ArStyleClass *klass)
   object_class->get_property = ar_style_get_property;
   object_class->finalize     = ar_style_finalize;
 
+  /**
+   * ArStyle:baize-color:
+   *
+   * The board baize color.
+   */
+#ifdef HAVE_CLUTTER
+  _ar_clutter_color_from_gdk_color (&color, &default_baize_color);
+  g_object_class_install_property
+    (object_class,
+     PROP_BAIZE_COLOR,
+     clutter_param_spec_color (AR_STYLE_PROP_BAIZE_COLOR, NULL, NULL,
+                               &color,
+                               G_PARAM_READWRITE |
+                               G_PARAM_STATIC_STRINGS));
+#else
+  g_object_class_install_property
+    (object_class,
+     PROP_BAIZE_COLOR,
+     g_param_spec_boxed (AR_STYLE_PROP_BAIZE_COLOR, NULL, NULL,
+                         GDK_TYPE_COLOR,
+                         G_PARAM_READWRITE |
+                         G_PARAM_STATIC_STRINGS));
+#endif /* HAVE_CLUTTER */
+
   g_object_class_install_property
     (object_class,
      PROP_CARD_SLOT_RATIO,
@@ -857,6 +909,25 @@ ar_style_get_selection_color (ArStyle *style,
 }
 
 /**
+ * ar_style_get_baize_color:
+ * @style: an #ArStyle
+ * @color: location to store the color
+ *
+ */
+void
+ar_style_get_baize_color (ArStyle *style,
+#ifdef HAVE_CLUTTER
+                               ClutterColor * const color)
+#else
+                               GdkColor * const color)
+#endif
+{
+  ArStylePrivate *priv = style->priv;
+
+  *color = priv->baize_color;
+}
+
+/**
  * ar_style_check_dnd_drag_threshold:
  * @style:
  * @x1:
diff --git a/aisleriot/ar-style.h b/aisleriot/ar-style.h
index d054779..db7dec8 100644
--- a/aisleriot/ar-style.h
+++ b/aisleriot/ar-style.h
@@ -58,6 +58,7 @@ GType ar_style_get_type (void);
 
 ArStyle* ar_style_new (void);
 
+#define AR_STYLE_PROP_BAIZE_COLOR         "baize-color"
 #define AR_STYLE_PROP_CARD_SLOT_RATIO     "card-slot-prop"
 #define AR_STYLE_PROP_CARD_THEME          "card-theme"
 #define AR_STYLE_PROP_CARD_OVERHANG       "card-overhang"
@@ -110,9 +111,13 @@ double ar_style_get_card_step       (ArStyle *style);
 #ifdef HAVE_CLUTTER
 void ar_style_get_selection_color  (ArStyle *style,
                                     ClutterColor * const color);
+void ar_style_get_baize_color (ArStyle *style,
+                                    ClutterColor * const color);
 #else
 void ar_style_get_selection_color  (ArStyle *style,
                                     GdkColor * const color);
+void ar_style_get_baize_color (ArStyle *style,
+                                    GdkColor * const color);
 #endif
 
 gboolean ar_style_check_dnd_drag_threshold (ArStyle *style,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]