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

« back to all changes in this revision

Viewing changes to champlain/champlain-map.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:
27
27
Map*
28
28
map_new (void)
29
29
{
30
 
  Map *map = g_new0(Map, 1);
 
30
  Map *map = g_new0 (Map, 1);
31
31
 
32
32
  map->previous_level = NULL;
33
33
  map->current_level = NULL;
36
36
}
37
37
 
38
38
void
39
 
map_load_level(Map *map,
 
39
map_load_level (Map *map,
40
40
    ChamplainMapSource *map_source,
41
41
    gint zoom_level)
42
42
{
43
 
  if (map->previous_level)
44
 
    g_object_unref (map->previous_level);
 
43
  if (map->previous_level != NULL)
 
44
    {
 
45
      if (champlain_zoom_level_get_zoom_level (map->previous_level) == zoom_level)
 
46
        {
 
47
          /* Swap current and previous, instead of reloading it */
 
48
          ChamplainZoomLevel *tmp = map->previous_level;
 
49
 
 
50
          map->previous_level = map->current_level;
 
51
          map->current_level = tmp;
 
52
 
 
53
          return;
 
54
        }
 
55
      else
 
56
        g_object_unref (map->previous_level);
 
57
    }
 
58
 
45
59
  map->previous_level = map->current_level;
46
60
 
47
61
  guint row_count = champlain_map_source_get_row_count (map_source, zoom_level);
60
74
    ChamplainMapSource *source)
61
75
{
62
76
  guint new_level = champlain_zoom_level_get_zoom_level (map->current_level) + 1;
 
77
 
63
78
  if(new_level <= champlain_map_source_get_max_zoom_level (source))
64
79
    {
65
 
      map_load_level(map, source, new_level);
 
80
      map_load_level (map, source, new_level);
66
81
      return TRUE;
67
82
    }
 
83
 
68
84
  return FALSE;
69
85
}
70
86
 
73
89
    ChamplainMapSource *source)
74
90
{
75
91
  gint new_level = champlain_zoom_level_get_zoom_level (map->current_level) - 1;
 
92
 
76
93
  if(new_level >= champlain_map_source_get_min_zoom_level (source))
77
94
    {
78
 
      map_load_level(map, source, new_level);
 
95
      map_load_level (map, source, new_level);
79
96
      return TRUE;
80
97
    }
 
98
 
81
99
  return FALSE;
82
100
}
83
101
 
86
104
{
87
105
  if (map->previous_level != NULL)
88
106
    g_object_unref (map->previous_level);
 
107
 
89
108
  if (map->current_level != NULL)
90
109
    g_object_unref (map->current_level);
 
110
 
91
111
  g_free (map);
92
112
}
93
113
 
96
116
    ChamplainMapSource *source,
97
117
    guint zoomLevel)
98
118
{
99
 
  if (zoomLevel<= champlain_map_source_get_max_zoom_level (source))
 
119
  if (zoomLevel <= champlain_map_source_get_max_zoom_level (source))
100
120
    {
101
 
      map_load_level(map, source, zoomLevel);
 
121
      map_load_level (map, source, zoomLevel);
102
122
      return TRUE;
103
123
    }
 
124
 
104
125
  return FALSE;
105
126
}