};
struct _ChamplainTilePrivate {
- gint x;
- gint y;
- gint size;
- gint zoom_level;
-
- gchar * uri;
- gpointer data;
- ChamplainState state;
- gchar *filename;
- ClutterActor *actor;
- ClutterActor *content_actor;
- ClutterAnimation *animation;
-
- GTimeVal *modified_time;
- gchar* etag;
+ gint x; /* The x position on the map (in pixels) */
+ gint y; /* The y position on the map (in pixels) */
+ gint size; /* The tile's width and height (only support square tiles */
+ gint zoom_level; /* The tile's zoom level */
+
+ gchar *uri; /* The URI where to find the tile */
+ ChamplainState state; /* The tile state: loading, validation, done */
+ gchar *filename; /* The tile's cache filename */
+ ClutterActor *actor; /* An actor grouping all content actors */
+ ClutterActor *content_actor; /* The actual tile actor */
+ ClutterAnimation *animation; /* The fade in animation */
+
+ GTimeVal *modified_time; /* The last modified time of the cache */
+ gchar* etag; /* The HTTP ETag sent by the server */
};
static void
object_class->dispose = champlain_tile_dispose;
object_class->finalize = champlain_tile_finalize;
-
/**
* ChamplainTile:x:
*
g_object_class_install_property (object_class,
PROP_X,
g_param_spec_int ("x",
- "x",
- "The X position of the tile",
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ "x",
+ "The X position of the tile",
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
/**
* ChamplainTile:y:
g_object_class_install_property (object_class,
PROP_Y,
g_param_spec_int ("y",
- "y",
- "The Y position of the tile",
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ "y",
+ "The Y position of the tile",
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
/**
* ChamplainTile:zoom-level:
g_object_class_install_property (object_class,
PROP_ZOOM_LEVEL,
g_param_spec_int ("zoom-level",
- "Zoom Level",
- "The zoom level of the tile",
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ "Zoom Level",
+ "The zoom level of the tile",
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
/**
* ChamplainTile:size:
g_object_class_install_property (object_class,
PROP_SIZE,
g_param_spec_uint ("size",
- "Size",
- "The size of the tile",
- 0,
- G_MAXINT,
- 256,
- G_PARAM_READWRITE));
+ "Size",
+ "The size of the tile",
+ 0,
+ G_MAXINT,
+ 256,
+ G_PARAM_READWRITE));
/**
* ChamplainTile:state:
g_object_class_install_property (object_class,
PROP_STATE,
g_param_spec_enum ("state",
- "State",
- "The state of the tile",
- CHAMPLAIN_TYPE_STATE,
- CHAMPLAIN_STATE_NONE,
- G_PARAM_READWRITE));
+ "State",
+ "The state of the tile",
+ CHAMPLAIN_TYPE_STATE,
+ CHAMPLAIN_STATE_NONE,
+ G_PARAM_READWRITE));
/**
* ChamplainTile:uri:
g_object_class_install_property (object_class,
PROP_URI,
g_param_spec_string ("uri",
- "URI",
- "The URI of the tile",
- "",
- G_PARAM_READWRITE));
+ "URI",
+ "The URI of the tile",
+ "",
+ G_PARAM_READWRITE));
/**
* ChamplainTile:filename:
g_object_class_install_property (object_class,
PROP_FILENAME,
g_param_spec_string ("filename",
- "Filename",
- "The filename of the tile",
- "",
- G_PARAM_READWRITE));
+ "Filename",
+ "The filename of the tile",
+ "",
+ G_PARAM_READWRITE));
/**
* ChamplainTile:actor:
g_object_class_install_property (object_class,
PROP_ACTOR,
g_param_spec_object ("actor",
- "Actor",
- "The tile's actor",
- CLUTTER_TYPE_ACTOR,
- G_PARAM_READABLE));
+ "Actor",
+ "The tile's actor",
+ CLUTTER_TYPE_ACTOR,
+ G_PARAM_READABLE));
/**
* ChamplainTile:content:
g_object_class_install_property (object_class,
PROP_CONTENT,
g_param_spec_object ("content",
- "Content",
- "The tile's content",
- CLUTTER_TYPE_ACTOR,
- G_PARAM_READWRITE));
+ "Content",
+ "The tile's content",
+ CLUTTER_TYPE_ACTOR,
+ G_PARAM_READWRITE));
/**
* ChamplainTile:etag:
g_object_class_install_property (object_class,
PROP_ETAG,
g_param_spec_string ("etag",
- "Entity Tag",
- "The entity tag of the tile",
- NULL,
- G_PARAM_READWRITE));
+ "Entity Tag",
+ "The entity tag of the tile",
+ NULL,
+ G_PARAM_READWRITE));
}
priv->y = 0;
priv->zoom_level = 0;
priv->size = 0;
- priv->uri = g_strdup ("");
- priv->filename = g_strdup ("");
+ priv->uri = NULL;
+ priv->filename = NULL;
priv->modified_time = NULL;
priv->etag = NULL;
gint
champlain_tile_get_x (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), 0);
-
- ChamplainTilePrivate *priv = self->priv;
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), 0);
- return priv->x;
+ return self->priv->x;
}
/**
gint
champlain_tile_get_y (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), 0);
-
- ChamplainTilePrivate *priv = self->priv;
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), 0);
- return priv->y;
+ return self->priv->y;
}
/**
gint
champlain_tile_get_zoom_level (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), 0);
-
- ChamplainTilePrivate *priv = self->priv;
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), 0);
- return priv->zoom_level;
+ return self->priv->zoom_level;
}
/**
guint
champlain_tile_get_size (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), 0);
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), 0);
- ChamplainTilePrivate *priv = self->priv;
-
- return priv->size;
+ return self->priv->size;
}
/**
ChamplainState
champlain_tile_get_state (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), CHAMPLAIN_STATE_NONE);
-
- ChamplainTilePrivate *priv = self->priv;
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), CHAMPLAIN_STATE_NONE);
- return priv->state;
+ return self->priv->state;
}
/**
G_CONST_RETURN gchar *
champlain_tile_get_uri (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), NULL);
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), NULL);
- ChamplainTilePrivate *priv = self->priv;
-
- return priv->uri;
+ return self->priv->uri;
}
/**
G_CONST_RETURN gchar *
champlain_tile_get_filename (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), NULL);
-
- ChamplainTilePrivate *priv = self->priv;
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), NULL);
- return priv->filename;
+ return self->priv->filename;
}
/**
* @self: the #ChamplainTile
*
* Returns the tile's actor. This actor should not change during the tile's
- * lifetime.
+ * lifetime. You should not unref this actor, it is owned by the tile.
*
* Since: 0.4
*/
ClutterActor *
champlain_tile_get_actor (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), NULL);
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), NULL);
return self->priv->actor;
}
champlain_tile_set_x (ChamplainTile *self,
gint x)
{
- g_return_if_fail(CHAMPLAIN_TILE(self));
+ g_return_if_fail (CHAMPLAIN_TILE (self));
ChamplainTilePrivate *priv = self->priv;
priv->x = x;
if (priv->actor != NULL)
- clutter_actor_set_position (priv->actor, priv->x * priv->size,
+ clutter_actor_set_position (priv->actor,
+ priv->x * priv->size,
priv->y * priv->size);
g_object_notify (G_OBJECT (self), "x");
champlain_tile_set_y (ChamplainTile *self,
gint y)
{
- g_return_if_fail(CHAMPLAIN_TILE(self));
+ g_return_if_fail (CHAMPLAIN_TILE (self));
ChamplainTilePrivate *priv = self->priv;
priv->y = y;
if (priv->actor != NULL)
- clutter_actor_set_position (priv->actor, priv->x * priv->size,
+ clutter_actor_set_position (priv->actor,
+ priv->x * priv->size,
priv->y * priv->size);
+
g_object_notify (G_OBJECT (self), "y");
}
champlain_tile_set_zoom_level (ChamplainTile *self,
gint zoom_level)
{
- g_return_if_fail(CHAMPLAIN_TILE(self));
+ g_return_if_fail (CHAMPLAIN_TILE (self));
- ChamplainTilePrivate *priv = self->priv;
+ self->priv->zoom_level = zoom_level;
- priv->zoom_level = zoom_level;
g_object_notify (G_OBJECT (self), "zoom-level");
}
* @self: the #ChamplainTile
* @size: the size in pixels
*
- * Sets the tile's zoom level
+ * Sets the tile's size
*
* Since: 0.4
*/
champlain_tile_set_size (ChamplainTile *self,
guint size)
{
- g_return_if_fail(CHAMPLAIN_TILE(self));
+ g_return_if_fail (CHAMPLAIN_TILE (self));
ChamplainTilePrivate *priv = self->priv;
priv->size = size;
if (priv->actor != NULL)
- clutter_actor_set_position (priv->actor, priv->x * priv->size,
+ clutter_actor_set_position (priv->actor,
+ priv->x * priv->size,
priv->y * priv->size);
+
g_object_notify (G_OBJECT (self), "size");
}
champlain_tile_set_state (ChamplainTile *self,
ChamplainState state)
{
- g_return_if_fail(CHAMPLAIN_TILE(self));
+ g_return_if_fail (CHAMPLAIN_TILE (self));
- ChamplainTilePrivate *priv = self->priv;
+ self->priv->state = state;
- priv->state = state;
g_object_notify (G_OBJECT (self), "state");
}
champlain_tile_set_uri (ChamplainTile *self,
const gchar *uri)
{
- g_return_if_fail(CHAMPLAIN_TILE(self));
- g_return_if_fail(uri != NULL);
+ g_return_if_fail (CHAMPLAIN_TILE (self));
+ g_return_if_fail (uri != NULL);
ChamplainTilePrivate *priv = self->priv;
g_free (priv->uri);
priv->uri = g_strdup (uri);
+
g_object_notify (G_OBJECT (self), "uri");
}
champlain_tile_set_filename (ChamplainTile *self,
const gchar *filename)
{
- g_return_if_fail(CHAMPLAIN_TILE(self));
- g_return_if_fail(filename != NULL);
+ g_return_if_fail (CHAMPLAIN_TILE (self));
+ g_return_if_fail (filename != NULL);
ChamplainTilePrivate *priv = self->priv;
g_free (priv->filename);
priv->filename = g_strdup (filename);
+
g_object_notify (G_OBJECT (self), "filename");
}
*
* Since: 0.4
*/
-const GTimeVal *
+G_CONST_RETURN GTimeVal *
champlain_tile_get_modified_time (ChamplainTile *self)
{
- g_return_val_if_fail (CHAMPLAIN_TILE(self), NULL);
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), NULL);
- ChamplainTilePrivate *priv = self->priv;
-
- return priv->modified_time;
+ return self->priv->modified_time;
}
/**
champlain_tile_set_modified_time (ChamplainTile *self,
const GTimeVal *time_)
{
- g_return_if_fail (CHAMPLAIN_TILE(self));
+ g_return_if_fail (CHAMPLAIN_TILE (self));
g_return_if_fail (time != NULL);
ChamplainTilePrivate *priv = self->priv;
* champlain_tile_get_modified_time_string:
* @self: the #ChamplainTile
*
- * Returns the tile's modified time as a string
+ * Returns the tile's modified time as a string (formated as per RFC 1123)
*
* Since: 0.4
*/
gchar *
champlain_tile_get_modified_time_string (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), NULL);
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), NULL);
+
ChamplainTilePrivate *priv = self->priv;
if (priv->modified_time == NULL)
*
* Since: 0.4
*/
-const gchar *
+G_CONST_RETURN gchar *
champlain_tile_get_etag (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), "");
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), "");
return self->priv->etag;
}
champlain_tile_set_etag (ChamplainTile *self,
const gchar *etag)
{
- g_return_if_fail(CHAMPLAIN_TILE(self));
+ g_return_if_fail (CHAMPLAIN_TILE (self));
ChamplainTilePrivate *priv = self->priv;
{
if (priv->actor != NULL)
clutter_container_remove (CLUTTER_CONTAINER (priv->actor), ctx->old_actor, NULL);
+
g_object_unref (ctx->old_actor);
}
g_free (ctx);
}
-
/**
* champlain_tile_set_content:
* @self: the #ChamplainTile
* @actor: the new content
* @fade_in: if the new content should be faded in
*
- * Returns the tile's content
+ * Sets the tile's content
*
* Since: 0.4
*/
ClutterActor *actor,
gboolean fade_in)
{
- g_return_if_fail(CHAMPLAIN_TILE(self));
- g_return_if_fail(actor != NULL);
+ g_return_if_fail (CHAMPLAIN_TILE (self));
+ g_return_if_fail (actor != NULL);
ChamplainTilePrivate *priv = self->priv;
ClutterActor *old_actor = NULL;
old_actor = g_object_ref (priv->content_actor);
else
clutter_container_remove (CLUTTER_CONTAINER (priv->actor), priv->content_actor, NULL);
+
g_object_unref (priv->content_actor);
}
if (priv->actor != NULL)
clutter_container_add (CLUTTER_CONTAINER (priv->actor), actor, NULL);
- if (fade_in == TRUE && priv->actor != NULL)
+ if (fade_in == TRUE && priv->actor != NULL)
{
clutter_actor_set_opacity (actor, 0);
}
priv->content_actor = g_object_ref (actor);
+
g_object_notify (G_OBJECT (self), "content");
}
/**
* champlain_tile_get_content:
*
- * Returns the tile's content
+ * Returns the tile's content, this actor will change each time the tile's content changes.
+ * You should not unref this content, it is owned by the tile.
*
* Since: 0.4
*/
ClutterActor *
champlain_tile_get_content (ChamplainTile *self)
{
- g_return_val_if_fail(CHAMPLAIN_TILE(self), NULL);
+ g_return_val_if_fail (CHAMPLAIN_TILE (self), NULL);
return self->priv->content_actor;
}