[libchamplain] Get rid of public privates for good
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Get rid of public privates for good
- Date: Tue, 23 Mar 2010 14:43:37 +0000 (UTC)
commit ea5778c17b82c1b214f7fdd2689bcd64c7993d03
Author: JiÅ?Ã Techet <techet gmail com>
Date: Sat Mar 20 17:27:18 2010 +0100
Get rid of public privates for good
Gets rid of shared private in ChamplainBaseMarker and corrects variable
naming conventions in CHamplainBaseMarker.
Signed-off-by: JiÅ?Ã Techet <techet gmail com>
champlain/champlain-base-marker.c | 67 ++++++++++++++++++++++++++++--------
champlain/champlain-base-marker.h | 3 +-
champlain/champlain-marker.c | 8 ++--
champlain/champlain-private.h | 12 ++----
champlain/champlain-view.c | 8 +++--
5 files changed, 67 insertions(+), 31 deletions(-)
---
diff --git a/champlain/champlain-base-marker.c b/champlain/champlain-base-marker.c
index 69f86d7..2af08ba 100644
--- a/champlain/champlain-base-marker.c
+++ b/champlain/champlain-base-marker.c
@@ -69,6 +69,13 @@ G_DEFINE_TYPE (ChamplainBaseMarker, champlain_base_marker, CLUTTER_TYPE_GROUP);
#define CHAMPLAIN_BASE_MARKER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_BASE_MARKER, ChamplainBaseMarkerPrivate))
+struct _ChamplainBaseMarkerPrivate
+{
+ gdouble lon;
+ gdouble lat;
+ gboolean highlighted;
+};
+
static void
champlain_base_marker_get_property (GObject *object,
guint prop_id,
@@ -135,11 +142,11 @@ champlain_base_marker_finalize (GObject *object)
}
static void
-champlain_base_marker_class_init (ChamplainBaseMarkerClass *champlainBaseMarkerClass)
+champlain_base_marker_class_init (ChamplainBaseMarkerClass *marker_class)
{
- g_type_class_add_private (champlainBaseMarkerClass, sizeof (ChamplainBaseMarkerPrivate));
+ g_type_class_add_private (marker_class, sizeof (ChamplainBaseMarkerPrivate));
- GObjectClass *object_class = G_OBJECT_CLASS (champlainBaseMarkerClass);
+ GObjectClass *object_class = G_OBJECT_CLASS (marker_class);
object_class->finalize = champlain_base_marker_finalize;
object_class->get_property = champlain_base_marker_get_property;
object_class->set_property = champlain_base_marker_set_property;
@@ -222,19 +229,49 @@ champlain_base_marker_new (void)
* Since: 0.4
*/
void
-champlain_base_marker_set_position (ChamplainBaseMarker *champlainBaseMarker,
+champlain_base_marker_set_position (ChamplainBaseMarker *marker,
gdouble latitude,
gdouble longitude)
{
- g_return_if_fail (CHAMPLAIN_IS_BASE_MARKER (champlainBaseMarker));
+ g_return_if_fail (CHAMPLAIN_IS_BASE_MARKER (marker));
- ChamplainBaseMarkerPrivate *priv = champlainBaseMarker->priv;
+ ChamplainBaseMarkerPrivate *priv = marker->priv;
priv->lon = longitude;
priv->lat = latitude;
- g_object_notify (G_OBJECT (champlainBaseMarker), "latitude");
- g_object_notify (G_OBJECT (champlainBaseMarker), "longitude");
+ g_object_notify (G_OBJECT (marker), "latitude");
+ g_object_notify (G_OBJECT (marker), "longitude");
+}
+
+/**
+ * champlain_base_marker_get_latitude:
+ * @marker: a #ChamplainBaseMarker
+ *
+ * Returns: the latitude of the marker.
+ *
+ * Since: 0.6
+ */
+gdouble champlain_base_marker_get_latitude (ChamplainBaseMarker *marker)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_BASE_MARKER (marker), 0.0);
+
+ return marker->priv->lat;
+}
+
+/**
+ * champlain_base_marker_get_longitude:
+ * @marker: a #ChamplainBaseMarker
+ *
+ * Returns: the longitude of the marker.
+ *
+ * Since: 0.6
+ */
+gdouble champlain_base_marker_get_longitude (ChamplainBaseMarker *marker)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_BASE_MARKER (marker), 0.0);
+
+ return marker->priv->lon;
}
/**
@@ -248,14 +285,14 @@ champlain_base_marker_set_position (ChamplainBaseMarker *champlainBaseMarker,
* Since: 0.4
*/
void
-champlain_base_marker_set_highlighted (ChamplainBaseMarker *champlainBaseMarker,
+champlain_base_marker_set_highlighted (ChamplainBaseMarker *marker,
gboolean value)
{
- g_return_if_fail (CHAMPLAIN_IS_BASE_MARKER (champlainBaseMarker));
+ g_return_if_fail (CHAMPLAIN_IS_BASE_MARKER (marker));
- champlainBaseMarker->priv->highlighted = value;
+ marker->priv->highlighted = value;
- g_object_notify (G_OBJECT (champlainBaseMarker), "highlighted");
+ g_object_notify (G_OBJECT (marker), "highlighted");
}
/**
@@ -267,11 +304,11 @@ champlain_base_marker_set_highlighted (ChamplainBaseMarker *champlainBaseMarker,
* Since: 0.4
*/
gboolean
-champlain_base_marker_get_highlighted (ChamplainBaseMarker *champlainBaseMarker)
+champlain_base_marker_get_highlighted (ChamplainBaseMarker *marker)
{
- g_return_val_if_fail (CHAMPLAIN_IS_BASE_MARKER (champlainBaseMarker), FALSE);
+ g_return_val_if_fail (CHAMPLAIN_IS_BASE_MARKER (marker), FALSE);
- return champlainBaseMarker->priv->highlighted;
+ return marker->priv->highlighted;
}
/**
diff --git a/champlain/champlain-base-marker.h b/champlain/champlain-base-marker.h
index d27677b..83adb14 100644
--- a/champlain/champlain-base-marker.h
+++ b/champlain/champlain-base-marker.h
@@ -53,7 +53,6 @@ struct _ChamplainBaseMarker
struct _ChamplainBaseMarkerClass
{
ClutterGroupClass parent_class;
-
};
GType champlain_base_marker_get_type (void);
@@ -62,6 +61,8 @@ ClutterActor *champlain_base_marker_new (void);
void champlain_base_marker_set_position (ChamplainBaseMarker *marker,
gdouble longitude, gdouble latitude);
+gdouble champlain_base_marker_get_latitude (ChamplainBaseMarker *marker);
+gdouble champlain_base_marker_get_longitude (ChamplainBaseMarker *marker);
void champlain_base_marker_set_highlighted (ChamplainBaseMarker *marker,
gboolean value);
gboolean champlain_base_marker_get_highlighted (ChamplainBaseMarker *marker);
diff --git a/champlain/champlain-marker.c b/champlain/champlain-marker.c
index 533e3f6..116562f 100644
--- a/champlain/champlain-marker.c
+++ b/champlain/champlain-marker.c
@@ -597,7 +597,7 @@ draw_background (ChamplainMarker *marker,
gint point)
{
ChamplainMarkerPrivate *priv = marker->priv;
- ChamplainBaseMarkerPrivate *base_priv = CHAMPLAIN_BASE_MARKER (marker)->priv;
+ ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (marker);
ClutterActor *bg = NULL;
ClutterColor *color;
ClutterColor darker_color;
@@ -607,7 +607,7 @@ draw_background (ChamplainMarker *marker,
cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));
/* If selected, add the selection color to the marker's color */
- if (base_priv->highlighted)
+ if (champlain_base_marker_get_highlighted (base_marker))
color = &SELECTED_COLOR;
else
color = priv->color;
@@ -649,7 +649,7 @@ static void
draw_marker (ChamplainMarker *marker)
{
ChamplainMarkerPrivate *priv = marker->priv;
- ChamplainBaseMarkerPrivate *base_priv = CHAMPLAIN_BASE_MARKER (marker)->priv;
+ ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (marker);
guint height = 0, point = 0;
guint total_width = 0, total_height = 0;
@@ -698,7 +698,7 @@ draw_marker (ChamplainMarker *marker)
total_height = height;
clutter_text_set_color (CLUTTER_TEXT (priv->text_actor),
- (base_priv->highlighted ? &SELECTED_TEXT_COLOR : priv->text_color));
+ (champlain_base_marker_get_highlighted (base_marker) ? &SELECTED_TEXT_COLOR : priv->text_color));
if (clutter_actor_get_parent (priv->text_actor) == NULL)
clutter_container_add_actor (CLUTTER_CONTAINER (marker), priv->text_actor);
}
diff --git a/champlain/champlain-private.h b/champlain/champlain-private.h
index 66739e0..d26d3c0 100644
--- a/champlain/champlain-private.h
+++ b/champlain/champlain-private.h
@@ -22,7 +22,10 @@
#include <glib.h>
#include <clutter/clutter.h>
-typedef struct _Map Map;
+/*
+ * WARNING - NEVER put class private declarations here - add accessor methods
+ * to the classes instead. Object encapsulation should be sacred.
+ */
typedef struct
{
@@ -31,13 +34,6 @@ typedef struct
gfloat z;
} ChamplainFloatPoint;
-struct _ChamplainBaseMarkerPrivate
-{
- gdouble lon;
- gdouble lat;
- gboolean highlighted;
-};
-
typedef struct
{
gfloat x;
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 7ec2b9c..0853384 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -387,12 +387,14 @@ marker_reposition_cb (ChamplainMarker *marker,
ChamplainView *view)
{
ChamplainViewPrivate *priv = view->priv;
- ChamplainBaseMarkerPrivate *marker_priv = CHAMPLAIN_BASE_MARKER(marker)->priv;
+ ChamplainBaseMarker *base_marker = CHAMPLAIN_BASE_MARKER (marker);
gint x, y;
- x = champlain_map_source_get_x (priv->map_source, priv->zoom_level, marker_priv->lon);
- y = champlain_map_source_get_y (priv->map_source, priv->zoom_level, marker_priv->lat);
+ x = champlain_map_source_get_x (priv->map_source, priv->zoom_level,
+ champlain_base_marker_get_longitude (base_marker));
+ y = champlain_map_source_get_y (priv->map_source, priv->zoom_level,
+ champlain_base_marker_get_latitude (base_marker));
clutter_actor_set_position (CLUTTER_ACTOR (marker),
x - priv->anchor.x,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]