[libchamplain] Use ClutterColor for memphis_map_source_{g, s}et_background_color
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libchamplain] Use ClutterColor for memphis_map_source_{g, s}et_background_color
- Date: Sun, 24 Jan 2010 20:13:31 +0000 (UTC)
commit df3d77689356998a69cfa16c539dfd5be3e1a2ed
Author: Simon Wenner <simon wenner ch>
Date: Mon Aug 10 22:35:48 2009 +0200
Use ClutterColor for memphis_map_source_{g,s}et_background_color
champlain/champlain-memphis-map-source.c | 33 ++++++++++++-----------------
champlain/champlain-memphis-map-source.h | 4 +-
demos/local-rendering.c | 29 ++++++++++++++++----------
3 files changed, 34 insertions(+), 32 deletions(-)
---
diff --git a/champlain/champlain-memphis-map-source.c b/champlain/champlain-memphis-map-source.c
index d85e8fc..90ba638 100644
--- a/champlain/champlain-memphis-map-source.c
+++ b/champlain/champlain-memphis-map-source.c
@@ -676,57 +676,52 @@ champlain_memphis_map_source_get_session_id (ChamplainMemphisMapSource *self)
* champlain_memphis_map_source_get_background_color:
* @map_source: a #ChamplainMemphisMapSource
*
- * Returns the background color of the map as a textual specification of
- * the color in the hexadecimal form #rrggbb, where r, g and b are hex
- * digits representing the red, green and blue components respectively.
- *
- * Returns a newly-allocated text string.
+ * Returns the background color of the map as a newly-allocated
+ * #ClutterColor.
*
* Since: 0.6
*/
-gchar * champlain_memphis_map_source_get_background_color (
+ClutterColor * champlain_memphis_map_source_get_background_color (
ChamplainMemphisMapSource *self)
{
g_return_val_if_fail (CHAMPLAIN_IS_MEMPHIS_MAP_SOURCE (self), NULL);
ChamplainMemphisMapSourcePrivate *priv = GET_PRIVATE (self);
- gchar *color;
+ ClutterColor color;
gint16 r, b, g;
g_static_rw_lock_reader_lock (&MemphisLock);
memphis_rule_set_get_bg_color (priv->rules, &r, &g, &b);
g_static_rw_lock_reader_unlock (&MemphisLock);
- color = g_strdup_printf ("#%02x%02x%02x", r, g, b);
- return color;
+ color.red = (guint8) r;
+ color.green = (guint8) g;
+ color.blue = (guint8) b;
+ color.alpha = 255;
+ return clutter_color_copy (&color);
}
/**
* champlain_memphis_map_source_set_background_color:
* @map_source: a #ChamplainMemphisMapSource
- * @color_spec: a color string
+ * @color: a #ClutterColor
*
- * Sets the background color of the map as a textual specification of
- * the color in the hexadecimal form #rrggbb, where r, g and b are hex
- * digits representing the red, green and blue components respectively.
+ * Sets the background color of the map from a #ClutterColor.
*
* Since: 0.6
*/
void
champlain_memphis_map_source_set_background_color (
ChamplainMemphisMapSource *self,
- const gchar *color_spec)
+ const ClutterColor *color)
{
g_return_if_fail (CHAMPLAIN_IS_MEMPHIS_MAP_SOURCE (self));
ChamplainMemphisMapSourcePrivate *priv = GET_PRIVATE (self);
- GdkColor color;
-
- gdk_color_parse (color_spec, &color);
g_static_rw_lock_writer_lock (&MemphisLock);
- memphis_rule_set_set_bg_color (priv->rules, (gint16) (color.red >> 8),
- (gint16) (color.green >> 8), (gint16) (color.blue >> 8));
+ memphis_rule_set_set_bg_color (priv->rules, (gint16) color->red,
+ (gint16) color->green, (gint16) color->blue);
g_static_rw_lock_writer_unlock (&MemphisLock);
if (!priv->persistent_cache)
diff --git a/champlain/champlain-memphis-map-source.h b/champlain/champlain-memphis-map-source.h
index 5068cb6..e49e45c 100644
--- a/champlain/champlain-memphis-map-source.h
+++ b/champlain/champlain-memphis-map-source.h
@@ -79,12 +79,12 @@ void champlain_memphis_map_source_set_session_id (
const gchar * champlain_memphis_map_source_get_session_id (
ChamplainMemphisMapSource *map_source);
-gchar * champlain_memphis_map_source_get_background_color (
+ClutterColor * champlain_memphis_map_source_get_background_color (
ChamplainMemphisMapSource *map_source);
void champlain_memphis_map_source_set_background_color (
ChamplainMemphisMapSource *map_source,
- const gchar *color_spec);
+ const ClutterColor *color);
GList * champlain_memphis_map_source_get_rule_ids (
ChamplainMemphisMapSource *map_source);
diff --git a/demos/local-rendering.c b/demos/local-rendering.c
index 215e540..06c75d0 100644
--- a/demos/local-rendering.c
+++ b/demos/local-rendering.c
@@ -109,17 +109,21 @@ load_rules_into_gui (ChamplainView *view)
GList* ids, *ptr;
GtkTreeModel *store;
GtkTreeIter iter;
- GdkColor color;
+ GdkColor gdk_color;
+ ClutterColor *clutter_color;
g_object_get (G_OBJECT (view), "map-source", &source, NULL);
ids = champlain_memphis_map_source_get_rule_ids (
CHAMPLAIN_MEMPHIS_MAP_SOURCE (source));
- gchar *colorstr = champlain_memphis_map_source_get_background_color (
+ clutter_color = champlain_memphis_map_source_get_background_color (
CHAMPLAIN_MEMPHIS_MAP_SOURCE (source));
- gdk_color_parse (colorstr, &color);
- g_free (colorstr);
- gtk_color_button_set_color (GTK_COLOR_BUTTON (bg_button), &color);
+ gdk_color.red = ((guint16) clutter_color->red) << 8;
+ gdk_color.green = ((guint16) clutter_color->green) << 8;
+ gdk_color.blue = ((guint16) clutter_color->blue) << 8;
+ clutter_color_free (clutter_color);
+
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (bg_button), &gdk_color);
store = gtk_tree_view_get_model (GTK_TREE_VIEW (rules_tree_view));
gtk_list_store_clear (GTK_LIST_STORE (store));
@@ -382,19 +386,22 @@ request_osm_data_cb (GtkWidget *widget, ChamplainView *view)
void
bg_color_set_cb (GtkColorButton *widget, ChamplainView *view)
{
- GdkColor color;
+ GdkColor gdk_color;
ChamplainMapSource *source;
- gtk_color_button_get_color (widget, &color);
+ gtk_color_button_get_color (widget, &gdk_color);
g_object_get (G_OBJECT (view), "map-source", &source, NULL);
if (strncmp (champlain_map_source_get_id (source), "memphis", 7) == 0)
{
- char *str = gdk_color_to_string (&color);
+ ClutterColor clutter_color;
+ clutter_color.red = CLAMP (((gdk_color.red / 65535.0) * 255), 0, 255);
+ clutter_color.green = CLAMP (((gdk_color.green / 65535.0) * 255), 0, 255);
+ clutter_color.blue = CLAMP (((gdk_color.blue / 65535.0) * 255), 0, 255);
+ clutter_color.alpha = 255;
+
champlain_memphis_map_source_set_background_color (
- CHAMPLAIN_MEMPHIS_MAP_SOURCE (source),
- str);
- g_free (str);
+ CHAMPLAIN_MEMPHIS_MAP_SOURCE (source), &clutter_color);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]