~ubuntu-branches/ubuntu/natty/libchamplain/natty

« back to all changes in this revision

Viewing changes to champlain/champlain-view.c

  • Committer: Bazaar Package Importer
  • Author(s): Sjoerd Simons, Laurent Bigonville, Sjoerd Simons
  • Date: 2009-09-15 00:01:41 UTC
  • mfrom: (1.1.3 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090915000141-i8fg5n1t02zxo79m
Tags: 0.4.0-1
[ Laurent Bigonville ]
* debian/control: Add libchamplain-0.3-dev dependency to
  libchamplain-gtk-0.3-dev

[ Sjoerd Simons ]
* New upstream release (0.4.0)

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
#include "champlain-zoom-level.h"
66
66
 
67
67
#include <clutter/clutter.h>
68
 
#include <clutter-cairo/clutter-cairo.h>
69
68
#include <glib.h>
70
69
#include <glib-object.h>
71
70
#include <math.h>
136
135
  gdouble latitude;
137
136
 
138
137
  /* Hack to get smaller x,y coordinates as the clutter limit is G_MAXINT16 */
139
 
  ChamplainIntPoint anchor;
 
138
  ChamplainFloatPoint anchor;
 
139
 
140
140
  gdouble anchor_zoom_level; /* the zoom_level for which the current anchor has
141
141
                                been computed for */
142
142
 
190
190
static void champlain_view_dispose (GObject *object);
191
191
static void champlain_view_class_init (ChamplainViewClass *champlainViewClass);
192
192
static void champlain_view_init (ChamplainView *view);
193
 
static void viewport_x_changed_cb (GObject *gobject, GParamSpec *arg1,
 
193
static void viewport_pos_changed_cb (GObject *gobject, GParamSpec *arg1,
194
194
    ChamplainView *view);
195
195
static void notify_marker_reposition_cb (ChamplainMarker *marker,
196
196
    GParamSpec *arg1, ChamplainView *view);
215
215
    GParamSpec *pspec,
216
216
    gpointer data);
217
217
static void view_update_polygons (ChamplainView *view);
 
218
static gboolean finger_scroll_key_press_cb (ClutterActor *actor,
 
219
    ClutterKeyEvent *event,
 
220
    ChamplainView *view);
 
221
static void champlain_view_go_to_with_duration (ChamplainView *view,
 
222
    gdouble latitude,
 
223
    gdouble longitude,
 
224
    guint duration);
218
225
 
219
226
static gdouble
220
227
viewport_get_longitude_at (ChamplainViewPrivate *priv, gint x)
362
369
license_set_position (ChamplainView *view)
363
370
{
364
371
  ChamplainViewPrivate *priv = view->priv;
365
 
  guint width, height;
 
372
  gfloat width, height;
366
373
 
367
374
  if (!priv->license_actor)
368
375
    return;
381
388
  if (polygon->priv->visible == FALSE)
382
389
    return;
383
390
 
384
 
  cr = clutter_cairo_create (CLUTTER_CAIRO (polygon->priv->actor));
 
391
  cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (polygon->priv->actor));
385
392
 
386
393
  /* Clear the drawing area */
387
394
  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
395
402
  while (list != NULL)
396
403
    {
397
404
      ChamplainPoint *point = (ChamplainPoint*) list->data;
398
 
      gint x, y;
 
405
      gfloat x, y;
399
406
 
400
407
      x = champlain_map_source_get_x (priv->map_source, priv->zoom_level,
401
408
          point->lon);
529
536
              polygon->priv->actor);
530
537
        }
531
538
 
532
 
      polygon->priv->actor = g_object_ref (clutter_cairo_new (
 
539
      polygon->priv->actor = g_object_ref (clutter_cairo_texture_new (
533
540
          view->priv->viewport_size.width,
534
541
          view->priv->viewport_size.height));
535
542
      g_object_set (G_OBJECT (polygon->priv->actor), "visible",
715
722
  polygons = priv->polygons;
716
723
  while (polygons != NULL)
717
724
    {
718
 
      ChamplainPolygon *polygon;
719
 
 
720
 
      polygon = CHAMPLAIN_POLYGON (polygons->data);
 
725
      g_object_unref (G_OBJECT (polygons->data));
721
726
      polygons = polygons->next;
722
 
      g_object_unref (polygon);
723
 
      priv->polygons = g_list_remove (polygons, polygon);
724
727
    }
 
728
  g_list_free (priv->polygons);
 
729
  priv->polygons = NULL;
725
730
 
726
731
  if (priv->goto_context != NULL)
727
732
    champlain_view_stop_go_to (view);
918
923
 
919
924
  /**
920
925
  * ChamplainView::animation-completed:
921
 
  * @view: the #ChamplainView that received the signal
922
926
  *
923
927
  * The ::animation-completed signal is emitted when any animation in the view
924
928
  * ends.  This is a detailed signal.  For example, if you want to be signaled
934
938
 
935
939
}
936
940
 
 
941
static gboolean
 
942
button_release_cb (ClutterActor *actor,
 
943
    ClutterEvent *event,
 
944
    ChamplainView *view)
 
945
{
 
946
  GList *children = NULL;
 
947
  gboolean found = FALSE;
 
948
  ChamplainViewPrivate *priv = view->priv;
 
949
 
 
950
  children = clutter_container_get_children (CLUTTER_CONTAINER (priv->user_layers));
 
951
  for (;children != NULL; children = g_list_next (children))
 
952
    {
 
953
      if (CHAMPLAIN_IS_SELECTION_LAYER (children->data))
 
954
        {
 
955
          champlain_selection_layer_unselect_all (CHAMPLAIN_SELECTION_LAYER (children->data));
 
956
          found = TRUE;
 
957
        }
 
958
    }
 
959
 
 
960
  g_list_free (children);
 
961
 
 
962
  return found;
 
963
}
 
964
 
 
965
 
937
966
static void
938
967
champlain_view_init (ChamplainView *view)
939
968
{
973
1002
  g_object_set (G_OBJECT (priv->viewport), "sync-adjustments", FALSE, NULL);
974
1003
 
975
1004
  g_signal_connect (priv->viewport, "notify::x-origin",
976
 
      G_CALLBACK (viewport_x_changed_cb), view);
 
1005
      G_CALLBACK (viewport_pos_changed_cb), view);
 
1006
  g_signal_connect (priv->viewport, "notify::y-origin",
 
1007
      G_CALLBACK (viewport_pos_changed_cb), view);
977
1008
 
978
1009
  /* Setup finger scroll */
979
1010
  priv->finger_scroll = g_object_ref (tidy_finger_scroll_new (priv->scroll_mode));
995
1026
 
996
1027
  g_signal_connect (priv->finger_scroll, "button-press-event",
997
1028
      G_CALLBACK (finger_scroll_button_press_cb), view);
 
1029
  g_signal_connect_after (priv->finger_scroll, "button-release-event",
 
1030
      G_CALLBACK (button_release_cb), view);
 
1031
 
 
1032
  clutter_stage_set_key_focus (CLUTTER_STAGE (clutter_stage_get_default()),
 
1033
      priv->finger_scroll);
 
1034
  g_signal_connect (priv->finger_scroll, "key-press-event",
 
1035
      G_CALLBACK (finger_scroll_key_press_cb), view);
998
1036
 
999
1037
  /* Setup user_layers */
1000
1038
  priv->user_layers = g_object_ref (clutter_group_new ());
1022
1060
}
1023
1061
 
1024
1062
static void
1025
 
viewport_x_changed_cb (GObject *gobject,
 
1063
viewport_pos_changed_cb (GObject *gobject,
1026
1064
    GParamSpec *arg1,
1027
1065
    ChamplainView *view)
1028
1066
{
1029
1067
  ChamplainViewPrivate *priv = view->priv;
1030
1068
 
1031
 
  ChamplainIntPoint rect;
1032
 
  ChamplainIntPoint old_anchor;
 
1069
  ChamplainFloatPoint rect;
 
1070
  ChamplainFloatPoint old_anchor;
1033
1071
 
1034
1072
  tidy_viewport_get_origin (TIDY_VIEWPORT (priv->viewport), &rect.x, &rect.y,
1035
1073
      NULL);
1047
1085
 
1048
1086
  if (priv->anchor.x - old_anchor.x != 0)
1049
1087
    {
1050
 
      ChamplainIntPoint diff;
 
1088
      ChamplainFloatPoint diff;
1051
1089
 
1052
1090
      diff.x = priv->anchor.x - old_anchor.x;
1053
1091
      diff.y = priv->anchor.y - old_anchor.y;
1054
1092
 
1055
 
      DEBUG("Relocating the viewport by %d, %d", diff.x, diff.y);
 
1093
      DEBUG("Relocating the viewport by %f, %f", diff.x, diff.y);
1056
1094
      tidy_viewport_set_origin (TIDY_VIEWPORT (priv->viewport),
1057
1095
          rect.x - diff.x, rect.y - diff.y, 0);
1058
1096
      return;
1073
1111
  g_object_notify (G_OBJECT (view), "latitude");
1074
1112
}
1075
1113
 
 
1114
/**
 
1115
 * champlain_view_set_size:
 
1116
 * @view: a #ChamplainView
 
1117
 * @width: the width in pixels
 
1118
 * @height: the height in pixels
 
1119
 *
 
1120
 * Sets the size of the view.  This function will most probably be deprecated in
 
1121
 * future versions in favor of #clutter_actor_set_size.  In the mean time, you need
 
1122
 * to call both.
 
1123
 *
 
1124
 * Since: 0.1
 
1125
 */
1076
1126
//FIXME: move to an handler of actor size change
1077
1127
void
1078
1128
champlain_view_set_size (ChamplainView *view,
1110
1160
 
1111
1161
  if (priv->show_license)
1112
1162
    {
1113
 
      priv->license_actor = g_object_ref (clutter_label_new_with_text ("sans 8",
 
1163
      priv->license_actor = g_object_ref (clutter_text_new_with_text ("sans 8",
1114
1164
          champlain_map_source_get_license (priv->map_source)));
1115
1165
      clutter_actor_set_opacity (priv->license_actor, 128);
1116
1166
      clutter_actor_show (priv->license_actor);
1136
1186
  return FALSE; /* Propagate the event */
1137
1187
}
1138
1188
 
 
1189
static void
 
1190
scroll_to (ChamplainView *view,
 
1191
    gint x,
 
1192
    gint y)
 
1193
{
 
1194
 
 
1195
  ChamplainViewPrivate *priv = view->priv;
 
1196
 
 
1197
  if (priv->scroll_mode == CHAMPLAIN_SCROLL_MODE_KINETIC)
 
1198
    {
 
1199
      gfloat lat, lon;
 
1200
 
 
1201
      lat = champlain_map_source_get_latitude (priv->map_source, priv->zoom_level, y);
 
1202
      lon = champlain_map_source_get_longitude (priv->map_source, priv->zoom_level, x);
 
1203
 
 
1204
      champlain_view_go_to_with_duration (view, lat, lon, 300);
 
1205
    }
 
1206
  else if (priv->scroll_mode == CHAMPLAIN_SCROLL_MODE_PUSH)
 
1207
    {
 
1208
      tidy_viewport_set_origin (TIDY_VIEWPORT (priv->viewport),
 
1209
        x - priv->viewport_size.width / 2.0,
 
1210
        y - priv->viewport_size.height / 2.0,
 
1211
        0);
 
1212
    }
 
1213
}
 
1214
 
 
1215
/* These functions should be exposed in the next API break */
 
1216
static void
 
1217
champlain_view_scroll_left (ChamplainView* view)
 
1218
{
 
1219
  g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
 
1220
 
 
1221
  gint x, y;
 
1222
  ChamplainViewPrivate *priv = view->priv;
 
1223
 
 
1224
  x = champlain_map_source_get_x (priv->map_source, priv->zoom_level, priv->longitude);
 
1225
  y = champlain_map_source_get_y (priv->map_source, priv->zoom_level, priv->latitude);
 
1226
 
 
1227
  x -= priv->viewport_size.width / 4.0;
 
1228
 
 
1229
  scroll_to (view, x, y);
 
1230
}
 
1231
 
 
1232
static void
 
1233
champlain_view_scroll_right (ChamplainView* view)
 
1234
{
 
1235
  g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
 
1236
 
 
1237
  gint x, y;
 
1238
  ChamplainViewPrivate *priv = view->priv;
 
1239
 
 
1240
  x = champlain_map_source_get_x (priv->map_source, priv->zoom_level, priv->longitude);
 
1241
  y = champlain_map_source_get_y (priv->map_source, priv->zoom_level, priv->latitude);
 
1242
 
 
1243
  x += priv->viewport_size.width / 4.0;
 
1244
 
 
1245
  scroll_to (view, x, y);
 
1246
}
 
1247
 
 
1248
static void
 
1249
champlain_view_scroll_up (ChamplainView* view)
 
1250
{
 
1251
  g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
 
1252
 
 
1253
  gint x, y;
 
1254
  ChamplainViewPrivate *priv = view->priv;
 
1255
 
 
1256
  x = champlain_map_source_get_x (priv->map_source, priv->zoom_level, priv->longitude);
 
1257
  y = champlain_map_source_get_y (priv->map_source, priv->zoom_level, priv->latitude);
 
1258
 
 
1259
  y -= priv->viewport_size.width / 4.0;
 
1260
 
 
1261
  scroll_to (view, x, y);
 
1262
}
 
1263
 
 
1264
static void
 
1265
champlain_view_scroll_down (ChamplainView* view)
 
1266
{
 
1267
  g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
 
1268
 
 
1269
  gint x, y;
 
1270
  ChamplainViewPrivate *priv = view->priv;
 
1271
 
 
1272
  x = champlain_map_source_get_x (priv->map_source, priv->zoom_level, priv->longitude);
 
1273
  y = champlain_map_source_get_y (priv->map_source, priv->zoom_level, priv->latitude);
 
1274
 
 
1275
  y += priv->viewport_size.width / 4.0;
 
1276
 
 
1277
  scroll_to (view, x, y);
 
1278
}
 
1279
 
 
1280
 
 
1281
static gboolean
 
1282
finger_scroll_key_press_cb (ClutterActor *actor,
 
1283
    ClutterKeyEvent *event,
 
1284
    ChamplainView *view)
 
1285
{
 
1286
 
 
1287
  switch (event->keyval)
 
1288
  {
 
1289
    case 65361: // Left
 
1290
      champlain_view_scroll_left (view);
 
1291
      return TRUE;
 
1292
      break;
 
1293
    case 65362: // Up
 
1294
      if (event->modifier_state & CLUTTER_CONTROL_MASK)
 
1295
        champlain_view_zoom_in (view);
 
1296
      else
 
1297
        champlain_view_scroll_up (view);
 
1298
      return TRUE;
 
1299
      break;
 
1300
    case 65363: // Right
 
1301
      champlain_view_scroll_right (view);
 
1302
      return TRUE;
 
1303
      break;
 
1304
    case 65364: // Down
 
1305
      if (event->modifier_state & CLUTTER_CONTROL_MASK)
 
1306
        champlain_view_zoom_out (view);
 
1307
      else
 
1308
        champlain_view_scroll_down (view);
 
1309
      return TRUE;
 
1310
      break;
 
1311
    default:
 
1312
      return FALSE; /* Propagate the event */
 
1313
  }
 
1314
  return FALSE; /* Propagate the event */
 
1315
}
 
1316
 
1139
1317
/**
1140
1318
 * champlain_view_new:
1141
 
 * Returns a new #ChamplainView ready to be used as a #ClutterActor.
 
1319
 *
 
1320
 * Returns: a new #ChamplainView ready to be used as a #ClutterActor.
1142
1321
 *
1143
1322
 * Since: 0.4
1144
1323
 */
1150
1329
 
1151
1330
static void
1152
1331
view_update_anchor (ChamplainView *view,
1153
 
    gint x,
1154
 
    gint y)
 
1332
    gint x,  /* Absolute x */
 
1333
    gint y)  /* Absolute y */
1155
1334
{
1156
1335
  ChamplainViewPrivate *priv = view->priv;
1157
1336
  gboolean need_anchor = FALSE;
1162
1341
 
1163
1342
  if (priv->anchor_zoom_level != priv->zoom_level ||
1164
1343
      x - priv->anchor.x + priv->viewport_size.width >= G_MAXINT16 ||
1165
 
      y - priv->anchor.y + priv->viewport_size.height >= G_MAXINT16)
 
1344
      y - priv->anchor.y + priv->viewport_size.height >= G_MAXINT16 ||
 
1345
      x - priv->anchor.x + priv->viewport_size.width <= 0 ||
 
1346
      y - priv->anchor.y + priv->viewport_size.height <= 0 )
1166
1347
    need_update = TRUE;
1167
1348
 
1168
1349
  if (need_anchor && need_update)
1186
1367
        priv->anchor.y = max;
1187
1368
 
1188
1369
      priv->anchor_zoom_level = priv->zoom_level;
 
1370
      DEBUG ("New Anchor (%f, %f) at (%d, %d)", priv->anchor.x, priv->anchor.y, x, y);
1189
1371
    }
1190
1372
 
1191
1373
  if (need_anchor == FALSE)
1193
1375
      priv->anchor.x = 0;
1194
1376
      priv->anchor.y = 0;
1195
1377
      priv->anchor_zoom_level = priv->zoom_level;
 
1378
      DEBUG ("Clear Anchor at (%d, %d)", x, y);
1196
1379
    }
1197
 
  DEBUG ("New Anchor (%d, %d) for (%d, %d)", priv->anchor.x, priv->anchor.y, x, y);
1198
1380
}
1199
1381
 
1200
1382
/**
1228
1410
  x = champlain_map_source_get_x (priv->map_source, priv->zoom_level, longitude);
1229
1411
  y = champlain_map_source_get_y (priv->map_source, priv->zoom_level, latitude);
1230
1412
 
 
1413
  DEBUG ("Centering on %f, %f (%d, %d)", latitude, longitude, x, y);
 
1414
 
1231
1415
  view_update_anchor (view, x, y);
1232
1416
 
1233
1417
  x -= priv->anchor.x;
1256
1440
  gdouble lat;
1257
1441
  gdouble lon;
1258
1442
 
1259
 
  alpha = (double) clutter_alpha_get_alpha (ctx->alpha) / CLUTTER_ALPHA_MAX_ALPHA;
 
1443
  alpha = clutter_alpha_get_alpha (ctx->alpha);
1260
1444
  lat = ctx->to_latitude - ctx->from_latitude;
1261
1445
  lon = ctx->to_longitude - ctx->from_longitude;
1262
1446
 
1318
1502
    gdouble latitude,
1319
1503
    gdouble longitude)
1320
1504
{
 
1505
  guint duration;
 
1506
 
 
1507
  duration = 500 * view->priv->zoom_level / 2.0;
 
1508
  champlain_view_go_to_with_duration (view, latitude, longitude, duration);
 
1509
}
 
1510
 
 
1511
/* FIXME: make public after API freeze */
 
1512
static void
 
1513
champlain_view_go_to_with_duration (ChamplainView *view,
 
1514
    gdouble latitude,
 
1515
    gdouble longitude,
 
1516
    guint duration) /* In ms */
 
1517
{
1321
1518
  g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
1322
1519
 
1323
 
  gint duration;
 
1520
  if (duration == 0)
 
1521
    {
 
1522
      champlain_view_center_on (view, latitude, longitude);
 
1523
      return;
 
1524
    }
 
1525
 
1324
1526
  GoToContext *ctx;
1325
1527
 
1326
1528
  ChamplainViewPrivate *priv = view->priv;
1345
1547
   * To have a nice animation, the duration should be longer if the zoom level
1346
1548
   * is higher and if the points are far away
1347
1549
   */
1348
 
  duration = 500 * priv->zoom_level / 2.0;
1349
 
  ctx->timeline = clutter_timeline_new_for_duration (duration);
1350
 
  ctx->alpha = clutter_alpha_new_full (ctx->timeline, CLUTTER_ALPHA_SINE_INC, NULL,
1351
 
      NULL);
 
1550
  ctx->timeline = clutter_timeline_new (duration);
 
1551
  ctx->alpha = clutter_alpha_new_full (ctx->timeline, CLUTTER_EASE_IN_OUT_CIRC);
1352
1552
 
1353
1553
  g_signal_connect (ctx->timeline, "new-frame", G_CALLBACK (timeline_new_frame),
1354
1554
      ctx);
1425
1625
  if (!map_zoom_to (priv->map, priv->map_source, zoom_level))
1426
1626
    return;
1427
1627
 
 
1628
  DEBUG ("Zooming to %d", zoom_level);
 
1629
 
1428
1630
  priv->zoom_level = zoom_level;
1429
1631
  /* Fix to bug 575133: keep the lat,lon as it gets set to a wrong value
1430
1632
   * when resizing the viewport, when passing from zoom_level 7 to 6
1445
1647
/**
1446
1648
 * champlain_view_set_min_zoom_level:
1447
1649
 * @view: a #ChamplainView
1448
 
 * @min_zoom_level: a gint
 
1650
 * @zoom_level: a gint
1449
1651
 *
1450
1652
 * Changes the lowest allowed zoom level
1451
1653
 *
1473
1675
/**
1474
1676
 * champlain_view_set_max_zoom_level:
1475
1677
 * @view: a #ChamplainView
1476
 
 * @max_zoom_level: a gint
 
1678
 * @zoom_level: a gint
1477
1679
 *
1478
1680
 * Changes the highest allowed zoom level
1479
1681
 *
1533
1735
 * champlain_view_get_coords_from_event:
1534
1736
 * @view: a #ChamplainView
1535
1737
 * @event: a #ClutterEvent
1536
 
 * @latitude: a variable where to put the latitude of the event
1537
 
 * @longitude: a variable where to put the longitude of the event
 
1738
 * @lat: a variable where to put the latitude of the event
 
1739
 * @lon: a variable where to put the longitude of the event
1538
1740
 *
1539
 
 * Returns the latitude, longitude coordinates for the given ClutterEvent.
 
1741
 * Returns: the latitude, longitude coordinates for the given ClutterEvent.
1540
1742
 *
1541
1743
 * Since: 0.2.8
1542
1744
 */
1596
1798
 * @view: a #ChamplainView
1597
1799
 * @x: the x position in the view
1598
1800
 * @y: the y position in the view
1599
 
 * @latitude: a variable where to put the latitude of the event
1600
 
 * @longitude: a variable where to put the longitude of the event
 
1801
 * @lat: a variable where to put the latitude of the event
 
1802
 * @lon: a variable where to put the longitude of the event
1601
1803
 *
1602
 
 * Returns the latitude, longitude coordinates for the given x, y position in
 
1804
 * Returns: the latitude, longitude coordinates for the given x, y position in
1603
1805
 * the view.  Use if you get coordinates from GtkEvents for example.
1604
1806
 *
1605
1807
 * Since: 0.4
1612
1814
{
1613
1815
  g_return_val_if_fail (CHAMPLAIN_IS_VIEW (view), FALSE);
1614
1816
  ChamplainViewPrivate *priv = view->priv;
1615
 
  gint actor_x, actor_y;
1616
 
  gint rel_x, rel_y;
 
1817
  gfloat actor_x, actor_y;
 
1818
  gdouble rel_x, rel_y;
1617
1819
 
1618
1820
  clutter_actor_get_transformed_position (priv->finger_scroll, &actor_x, &actor_y);
1619
1821
 
1691
1893
          {
1692
1894
            actor = champlain_tile_get_actor (tile);
1693
1895
            group = champlain_zoom_level_get_actor (level);
1694
 
            clutter_container_remove_actor (CLUTTER_CONTAINER (group), actor);
 
1896
            if (actor != NULL)
 
1897
              clutter_container_remove_actor (CLUTTER_CONTAINER (group), actor);
1695
1898
          }
1696
1899
        champlain_zoom_level_remove_tile (level, tile);
1697
1900
        count = champlain_zoom_level_tile_count (level);
1752
1955
  guint size;
1753
1956
 
1754
1957
  actor = champlain_tile_get_actor (tile);
 
1958
 
 
1959
  if (actor == NULL)
 
1960
    return;
 
1961
 
1755
1962
  x = champlain_tile_get_x (tile);
1756
1963
  y = champlain_tile_get_y (tile);
1757
1964
  size = champlain_tile_get_size (tile);
1816
2023
/**
1817
2024
 * champlain_view_set_map_source:
1818
2025
 * @view: a #ChamplainView
1819
 
 * @source: a #ChamplainMapSource
 
2026
 * @map_source: a #ChamplainMapSource
1820
2027
 *
1821
2028
 * Changes the currently used map source.  #g_object_unref will be called on
1822
2029
 * the previous one.
1991
2198
 * @lon1: the longitude of position 1
1992
2199
 * @lat2: the latitude of position 2
1993
2200
 * @lon2: the longitude of position 2
 
2201
 * @animate: a #gboolean
1994
2202
 *
1995
2203
 * Changes the map's zoom level and center to make sure the two given
1996
2204
 * positions are visible
2078
2286
 * champlain_view_ensure_markers_visible:
2079
2287
 * @view: a #ChamplainView
2080
2288
 * @markers: a NULL terminated array of #ChamplainMarkers
 
2289
 * @animate: a #gboolean
2081
2290
 *
2082
2291
 * Changes the map's zoom level and center to make sure those markers are
2083
2292
 * visible.
2134
2343
  ClutterActor *group, *new_group;
2135
2344
  gdouble lon, lat;
2136
2345
  gint x_diff, y_diff;
2137
 
  gint actor_x, actor_y;
2138
 
  gint rel_x, rel_y;
2139
 
  gint x2, y2;
 
2346
  gfloat actor_x, actor_y;
 
2347
  gdouble rel_x, rel_y;
 
2348
  gfloat x2, y2;
2140
2349
  gdouble lat2, lon2;
2141
2350
 
2142
2351
  if (zoom_level == priv->zoom_level || ZOOM_LEVEL_OUT_OF_RANGE(priv, zoom_level))
2190
2399
 * champlain_view_get_zoom_level:
2191
2400
 * @view: The view
2192
2401
 *
2193
 
 * Returns the view's current zoom level.
 
2402
 * Returns: the view's current zoom level.
2194
2403
 *
2195
2404
 * Since: 0.4
2196
2405
 */
2208
2417
 * champlain_view_get_min_zoom_level:
2209
2418
 * @view: The view
2210
2419
 *
2211
 
 * Returns the view's minimal zoom level allowed.
 
2420
 * Returns: the view's minimal zoom level allowed.
2212
2421
 *
2213
2422
 * Since: 0.4
2214
2423
 */
2226
2435
 * champlain_view_get_max_zoom_level:
2227
2436
 * @view: The view
2228
2437
 *
2229
 
 * Returns the view's maximal zoom level allowed.
 
2438
 * Returns: the view's maximal zoom level allowed.
2230
2439
 *
2231
2440
 * Since: 0.4
2232
2441
 */
2244
2453
 * champlain_view_get_map_source:
2245
2454
 * @view: The view
2246
2455
 *
2247
 
 * Returns the view's current map source. If you need to keep a reference to the
 
2456
 * Returns: the view's current map source. If you need to keep a reference to the
2248
2457
 * map source then you have to call #g_object_ref.
2249
2458
 *
2250
2459
 * Since: 0.4
2263
2472
 * champlain_view_get_decel_rate:
2264
2473
 * @view: The view
2265
2474
 *
2266
 
 * Returns the view's deceleration rate.
 
2475
 * Returns: the view's deceleration rate.
2267
2476
 *
2268
2477
 * Since: 0.4
2269
2478
 */
2282
2491
 * champlain_view_get_scroll_mode:
2283
2492
 * @view: The view
2284
2493
 *
2285
 
 * Returns the view's scroll mode behaviour.
 
2494
 * Returns: the view's scroll mode behaviour.
2286
2495
 *
2287
2496
 * Since: 0.4
2288
2497
 */
2299
2508
 * champlain_view_get_keep_center_on_resize:
2300
2509
 * @view: The view
2301
2510
 *
2302
 
 * Returns TRUE if the view keeps the center or resize.
 
2511
 * Returns: TRUE if the view keeps the center or resize, FALSE otherwise.
2303
2512
 *
2304
2513
 * Since: 0.4
2305
2514
 */
2313
2522
}
2314
2523
 
2315
2524
/**
2316
 
 * champlain_view_get_keep_center_on_resize:
 
2525
 * champlain_view_get_show_license:
2317
2526
 * @view: The view
2318
2527
 *
2319
 
 * Returns TRUE if the view displays the license.
 
2528
 * Returns: TRUE if the view displays the license, FALSE otherwise.
2320
2529
 *
2321
2530
 * Since: 0.4
2322
2531
 */
2333
2542
 * champlain_view_get_zoom_on_double_click:
2334
2543
 * @view: The view
2335
2544
 *
2336
 
 * Returns TRUE if the view zooms on double click.
 
2545
 * Returns: TRUE if the view zooms on double click, FALSE otherwise.
2337
2546
 *
2338
2547
 * Since: 0.4
2339
2548
 */
2351
2560
{
2352
2561
  ChamplainViewPrivate *priv = view->priv;
2353
2562
  GList *polygons;
2354
 
  gint x, y;
 
2563
  gfloat x, y;
2355
2564
 
2356
2565
  if (priv->polygons == NULL)
2357
2566
    return;
2389
2598
  g_return_if_fail (CHAMPLAIN_IS_VIEW (view));
2390
2599
  g_return_if_fail (CHAMPLAIN_IS_POLYGON (polygon));
2391
2600
 
2392
 
  view->priv->polygons = g_list_append (view->priv->polygons, g_object_ref (polygon));
 
2601
  view->priv->polygons = g_list_append (view->priv->polygons, g_object_ref_sink (polygon));
2393
2602
 
2394
2603
  g_signal_connect (polygon, "notify",
2395
2604
      G_CALLBACK (notify_polygon_cb), view);
2401
2610
    return;
2402
2611
  }
2403
2612
 
2404
 
  polygon->priv->actor = g_object_ref (clutter_cairo_new (
 
2613
  polygon->priv->actor = g_object_ref (clutter_cairo_texture_new (
2405
2614
      view->priv->viewport_size.width,
2406
2615
      view->priv->viewport_size.height));
2407
2616
  g_object_set (G_OBJECT (polygon->priv->actor), "visible",