[libchamplain/libchamplain-0-4] 580372: Get rid of champlain_view_set_size
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libchamplain/libchamplain-0-4] 580372: Get rid of champlain_view_set_size
- Date: Fri, 15 Jan 2010 03:25:39 +0000 (UTC)
commit fbefd7cc5aa42aadd3cd089e84af3e0b2de2ee99
Author: Pierre-Luc Beaudoin <pierre-luc pierlux com>
Date: Thu Jan 14 15:20:33 2010 -0500
580372: Get rid of champlain_view_set_size
champlain_view_set_size is now deprecated, the size
of ChamplainView should be set with
clutter_actor_set_size. champlain_view_set_size just
calls it.
champlain-gtk/gtk-champlain-embed.c | 4 +-
champlain/champlain-view.c | 100 +++++++++++++++++++----------------
champlain/champlain-view.h | 3 +-
demos/animated-marker.c | 2 +-
demos/launcher.c | 2 +-
demos/polygons.c | 2 +-
6 files changed, 61 insertions(+), 52 deletions(-)
---
diff --git a/champlain-gtk/gtk-champlain-embed.c b/champlain-gtk/gtk-champlain-embed.c
index ea7193d..5e22f4a 100644
--- a/champlain-gtk/gtk-champlain-embed.c
+++ b/champlain-gtk/gtk-champlain-embed.c
@@ -199,7 +199,7 @@ set_view (GtkChamplainEmbed* embed,
}
priv->view = g_object_ref (view);
- champlain_view_set_size (priv->view, priv->width, priv->height);
+ clutter_actor_set_size (CLUTTER_ACTOR (priv->view), priv->width, priv->height);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (priv->view));
}
@@ -274,7 +274,7 @@ view_size_allocated_cb (GtkWidget *widget,
GtkChamplainEmbedPrivate *priv = view->priv;
if (priv->view != NULL)
- champlain_view_set_size (priv->view, allocation->width, allocation->height);
+ clutter_actor_set_size (CLUTTER_ACTOR (priv->view), allocation->width, allocation->height);
priv->width = allocation->width;
priv->height = allocation->height;
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index c5b08e8..3afdcfe 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -211,7 +211,6 @@ static void connect_marker_notify_cb (ChamplainMarker *marker,
static gboolean finger_scroll_button_press_cb (ClutterActor *actor,
ClutterButtonEvent *event, ChamplainView *view);
static void update_license (ChamplainView *view);
-static void license_set_position (ChamplainView *view);
static void view_load_visible_tiles (ChamplainView *view);
static void view_position_tile (ChamplainView* view, ChamplainTile* tile);
static void view_tiles_reposition (ChamplainView* view);
@@ -375,25 +374,13 @@ create_initial_map (ChamplainView *view)
g_idle_add (marker_reposition, view);
view_tiles_reposition (view);
update_license (view);
+ resize_viewport (view);
g_object_notify (G_OBJECT (view), "zoom-level");
g_object_notify (G_OBJECT (view), "map-source");
}
static void
-license_set_position (ChamplainView *view)
-{
- ChamplainViewPrivate *priv = view->priv;
-
- if (!priv->license_actor)
- return;
-
- clutter_actor_set_position (priv->license_actor,
- priv->viewport_size.width - PADDING,
- priv->viewport_size.height - PADDING);
-}
-
-static void
draw_polygon (ChamplainView *view, ChamplainPolygon *polygon)
{
cairo_t *cr;
@@ -524,9 +511,6 @@ resize_viewport (ChamplainView *view)
if (!priv->map)
return;
- clutter_actor_set_size (priv->finger_scroll, priv->viewport_size.width,
- priv->viewport_size.height);
-
tidy_scrollable_get_adjustments (TIDY_SCROLLABLE (priv->viewport), &hadjust,
&vadjust);
@@ -804,6 +788,47 @@ champlain_view_dispose (GObject *object)
}
static void
+champlain_view_allocate (ClutterActor *actor,
+ const ClutterActorBox *box,
+ ClutterAllocationFlags flags)
+{
+ ChamplainView *view = CHAMPLAIN_VIEW (actor);
+ ChamplainViewPrivate *priv = view->priv;
+ guint width, height;
+
+ /* Chain up */
+ CLUTTER_ACTOR_CLASS (champlain_view_parent_class)->allocate (actor, box, flags);
+
+ if (flags != CLUTTER_ALLOCATION_NONE)
+ return;
+
+ width = box->x2 - box->x1;
+ height = box->y2 - box->y1;
+
+ if (priv->viewport_size.width == width && priv->viewport_size.height == height)
+ return;
+
+ priv->viewport_size.width = width;
+ priv->viewport_size.height = height;
+
+ clutter_actor_set_size (priv->finger_scroll, width, height);
+
+ clutter_actor_set_position (priv->license_actor,
+ priv->viewport_size.width - PADDING,
+ priv->viewport_size.height - PADDING);
+ clutter_actor_set_position (priv->scale_actor,
+ SCALE_PADDING,
+ height - SCALE_HEIGHT - SCALE_PADDING);
+
+ resize_viewport (view);
+
+ if (priv->keep_center_on_resize)
+ champlain_view_center_on (view, priv->latitude, priv->longitude);
+ else
+ view_load_visible_tiles (view);
+}
+
+static void
champlain_view_class_init (ChamplainViewClass *champlainViewClass)
{
g_type_class_add_private (champlainViewClass, sizeof (ChamplainViewPrivate));
@@ -813,6 +838,9 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
object_class->get_property = champlain_view_get_property;
object_class->set_property = champlain_view_set_property;
+ ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (champlainViewClass);
+ actor_class->allocate = champlain_view_allocate;
+
/**
* ChamplainView:longitude:
*
@@ -1374,9 +1402,6 @@ champlain_view_init (ChamplainView *view)
priv->polygon_layer);
clutter_actor_raise (priv->polygon_layer, priv->map_layer);
- champlain_view_set_size (view, priv->viewport_size.width,
- priv->viewport_size.height);
-
clutter_actor_raise_top (priv->scale_actor);
resize_viewport (view);
@@ -1443,9 +1468,8 @@ viewport_pos_changed_cb (GObject *gobject,
* @width: the width in pixels
* @height: the height in pixels
*
- * Sets the size of the view. This function will most probably be deprecated in
- * future versions in favor of #clutter_actor_set_size. In the mean time, you need
- * to call both.
+ * Sets the size of the view. This function is deprecated and should not be used in new code
+ * Use #clutter_actor_set_size instead.
*
* Since: 0.1
*/
@@ -1455,24 +1479,10 @@ champlain_view_set_size (ChamplainView *view,
guint width,
guint height)
{
- g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
-
- ChamplainViewPrivate *priv = view->priv;
-
- priv->viewport_size.width = width;
- priv->viewport_size.height = height;
-
- license_set_position (view);
- clutter_actor_set_position (priv->scale_actor, SCALE_PADDING,
- priv->viewport_size.height - SCALE_HEIGHT - SCALE_PADDING);
- resize_viewport (view);
-
- if (priv->keep_center_on_resize)
- champlain_view_center_on (view, priv->latitude, priv->longitude);
- else
- view_load_visible_tiles (view);
+ clutter_actor_set_size (CLUTTER_ACTOR (view), width, height);
}
+
static void
update_license (ChamplainView *view)
{
@@ -1502,10 +1512,7 @@ update_license (ChamplainView *view)
clutter_text_set_text (CLUTTER_TEXT (priv->license_actor), license);
if (priv->show_license)
- {
- clutter_actor_show (priv->license_actor);
- license_set_position (view);
- }
+ clutter_actor_show (priv->license_actor);
else
clutter_actor_hide (priv->license_actor);
@@ -1954,10 +1961,12 @@ champlain_view_set_zoom_level (ChamplainView *view,
gdouble longitude;
gdouble latitude;
- if (priv->map == NULL)
+ if (zoom_level == priv->zoom_level || ZOOM_LEVEL_OUT_OF_RANGE(priv, zoom_level))
return;
- if (zoom_level == priv->zoom_level || ZOOM_LEVEL_OUT_OF_RANGE(priv, zoom_level))
+ priv->zoom_level = zoom_level;
+
+ if (priv->map == NULL)
return;
champlain_view_stop_go_to (view);
@@ -1968,7 +1977,6 @@ champlain_view_set_zoom_level (ChamplainView *view,
DEBUG ("Zooming to %d", zoom_level);
- priv->zoom_level = zoom_level;
/* Fix to bug 575133: keep the lat,lon as it gets set to a wrong value
* when resizing the viewport, when passing from zoom_level 7 to 6
* (or more precisely when anchor is set to 0).
diff --git a/champlain/champlain-view.h b/champlain/champlain-view.h
index 89005f1..2479fcf 100644
--- a/champlain/champlain-view.h
+++ b/champlain/champlain-view.h
@@ -105,7 +105,8 @@ void champlain_view_set_map_source (ChamplainView *view,
ChamplainMapSource *map_source);
void champlain_view_set_size (ChamplainView *view,
guint width,
- guint height);
+ guint height)
+ CHAMPLAIN_OBSOLETE_API;
void champlain_view_set_decel_rate (ChamplainView *view,
gdouble rate);
void champlain_view_set_scroll_mode (ChamplainView *view,
diff --git a/demos/animated-marker.c b/demos/animated-marker.c
index 0ebddd4..ed44228 100644
--- a/demos/animated-marker.c
+++ b/demos/animated-marker.c
@@ -113,7 +113,7 @@ main (int argc, char *argv[])
/* Create the map view */
actor = champlain_view_new ();
- champlain_view_set_size (CHAMPLAIN_VIEW (actor), 800, 600);
+ clutter_actor_set_size (CLUTTER_ACTOR (actor), 800, 600);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
/* Create the marker layer */
diff --git a/demos/launcher.c b/demos/launcher.c
index 51a5e31..35879ff 100644
--- a/demos/launcher.c
+++ b/demos/launcher.c
@@ -97,7 +97,7 @@ main (int argc,
/* Create the map view */
actor = champlain_view_new ();
- champlain_view_set_size (CHAMPLAIN_VIEW (actor), 800, 600);
+ clutter_actor_set_size (CLUTTER_ACTOR (actor), 800, 600);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
/* Create the buttons */
diff --git a/demos/polygons.c b/demos/polygons.c
index 6184b60..acd944b 100644
--- a/demos/polygons.c
+++ b/demos/polygons.c
@@ -79,7 +79,7 @@ main (int argc,
/* Create the map view */
actor = champlain_view_new ();
- champlain_view_set_size (CHAMPLAIN_VIEW (actor), 800, 600);
+ clutter_actor_set_size (CLUTTER_ACTOR (actor), 800, 600);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
/* Create the buttons */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]