[gnome-maps/wip/gtk4-and-libshumate] WIP: Port to GTK 4 and libshumate




commit 3930d9ad5051c6342a70b7ac2442fb6b7b1d5245
Author: Marcus Lundblad <ml dfupdate se>
Date:   Thu Jun 30 23:11:19 2022 +0200

    WIP: Port to GTK 4 and libshumate

 lib/maps-file-tile-source.c           | 289 +++++++++++++++-------------------
 lib/maps-file-tile-source.h           |   8 +-
 lib/maps-sync-map-source.c            |  96 +++++++++++
 lib/maps-sync-map-source.h            |  73 +++++++++
 lib/meson.build                       |  10 +-
 meson.build                           |   6 +-
 org.gnome.Maps.json                   |  47 +-----
 src/application.js                    |  10 +-
 src/contextMenu.js                    |   2 +-
 src/epaf.js                           |   4 +-
 src/geoJSONSource.js                  |  49 ++----
 src/graphHopperTransit.js             |  10 +-
 src/layersPopover.js                  |   4 +-
 src/main.js                           |  12 +-
 src/mainWindow.js                     |   2 +-
 src/mapBubble.js                      |  33 +++-
 src/mapMarker.js                      |  24 +--
 src/mapSource.js                      |   2 +-
 src/mapView.js                        |  84 +++++-----
 src/mapWalker.js                      |   5 -
 src/placeBar.js                       |   2 +-
 src/placeViewImage.js                 |  28 +++-
 src/printLayout.js                    |  15 +-
 src/shapeLayer.js                     |   7 +-
 src/storedRoute.js                    |  10 +-
 src/transitBoardMarker.js             |   1 -
 src/transitPrintLayout.js             |  12 +-
 src/transitplugins/openTripPlanner.js |   6 +-
 src/transitplugins/opendataCH.js      |  14 +-
 src/transitplugins/resrobot.js        |  14 +-
 src/turnPointMarker.js                |   2 -
 src/userLocationMarker.js             |  15 +-
 32 files changed, 489 insertions(+), 407 deletions(-)
---
diff --git a/lib/maps-file-tile-source.c b/lib/maps-file-tile-source.c
index 61e5f060..fdabbd60 100644
--- a/lib/maps-file-tile-source.c
+++ b/lib/maps-file-tile-source.c
@@ -17,7 +17,7 @@
  * Author: Jonas Danielsson <jonas threetimestwo org>
  */
 
-#include <champlain/champlain.h>
+#include <shumate/shumate.h>
 #include <gio/gio.h>
 #include <glib.h>
 #include <glib-object.h>
@@ -41,8 +41,10 @@ enum {
   PROP_PATH,
   PROP_MAX_ZOOM,
   PROP_MIN_ZOOM,
-  PROP_WORLD
-
+  PROP_WORLD_LEFT,
+  PROP_WORLD_TOP,
+  PROP_WORLD_RIGHT,
+  PROP_WORLD_BOTTOM
 };
 
 struct _MapsFileTileSourcePrivate
@@ -51,7 +53,10 @@ struct _MapsFileTileSourcePrivate
   gchar *extension;
   gint max_zoom;
   gint min_zoom;
-  ChamplainBoundingBox *world;
+  double world_left;
+  double world_top;
+  double world_right;
+  double world_bottom;
 
   long min_x;
   long min_y;
@@ -59,17 +64,7 @@ struct _MapsFileTileSourcePrivate
   long max_y;
 };
 
-typedef struct
-{
-  ChamplainMapSource *map_source;
-  ChamplainTile *tile;
-} CallbackData;
-
-G_DEFINE_TYPE_WITH_PRIVATE (MapsFileTileSource, maps_file_tile_source, CHAMPLAIN_TYPE_TILE_SOURCE)
-
-static void fill_tile (ChamplainMapSource *map_source,
-    ChamplainTile *tile);
-
+G_DEFINE_TYPE_WITH_PRIVATE (MapsFileTileSource, maps_file_tile_source, SHUMATE_TYPE_MAP_SOURCE)
 
 static void
 maps_file_tile_source_set_property (GObject      *object,
@@ -112,8 +107,20 @@ maps_file_tile_source_get_property (GObject *object,
       g_value_set_uint (value, tile_source->priv->max_zoom);
       break;
 
-    case PROP_WORLD:
-      g_value_set_boxed (value, tile_source->priv->world);
+    case PROP_WORLD_LEFT:
+      g_value_set_double (value, tile_source->priv->world_left);
+      break;
+
+    case PROP_WORLD_TOP:
+      g_value_set_double (value, tile_source->priv->world_top);
+      break;
+
+    case PROP_WORLD_RIGHT:
+      g_value_set_double (value, tile_source->priv->world_right);
+      break;
+
+    case PROP_WORLD_BOTTOM:
+      g_value_set_double (value, tile_source->priv->world_bottom);
       break;
 
     default:
@@ -141,26 +148,22 @@ maps_file_tile_source_finalize (GObject *object)
   G_OBJECT_CLASS (maps_file_tile_source_parent_class)->finalize (object);
 }
 
-static guint
-get_max_zoom_level (ChamplainMapSource *source)
-{
-  MapsFileTileSource *tile_source = (MapsFileTileSource *) source;
-
-  return tile_source->priv->max_zoom;
-}
-
-static guint
-get_min_zoom_level (ChamplainMapSource *source)
-{
-  MapsFileTileSource *tile_source = (MapsFileTileSource *) source;
+static void
+fill_tile_async (ShumateMapSource     *source,
+                 ShumateTile          *tile,
+                 GCancellable         *cancellable,
+                 GAsyncReadyCallback   callback,
+                 gpointer              user_data);
 
-  return tile_source->priv->min_zoom;
-}
+static gboolean
+fill_tile_finish (ShumateMapSource *map_source,
+                  GAsyncResult *result,
+                  GError **error);
 
 static void
 maps_file_tile_source_class_init (MapsFileTileSourceClass *klass)
 {
-  ChamplainMapSourceClass *map_source_class = CHAMPLAIN_MAP_SOURCE_CLASS (klass);
+  ShumateMapSourceClass *map_source_class = SHUMATE_MAP_SOURCE_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GParamSpec *pspec;
 
@@ -168,9 +171,8 @@ maps_file_tile_source_class_init (MapsFileTileSourceClass *klass)
   object_class->dispose = maps_file_tile_source_dispose;
   object_class->get_property = maps_file_tile_source_get_property;
   object_class->set_property = maps_file_tile_source_set_property;
-  map_source_class->get_max_zoom_level = get_max_zoom_level;
-  map_source_class->get_min_zoom_level = get_min_zoom_level;
-  map_source_class->fill_tile = fill_tile;
+  map_source_class->fill_tile_async = fill_tile_async;
+  map_source_class->fill_tile_finish = fill_tile_finish;
 
   /**
    * MapsFileTileSource:path:
@@ -216,19 +218,59 @@ maps_file_tile_source_class_init (MapsFileTileSourceClass *klass)
   g_object_class_install_property (object_class, PROP_MAX_ZOOM, pspec);
 
   /**
-   * MapsFileTileSource:world:
+   * MapsFileTileSource:world_left:
    *
-   * Set a bounding box to limit the world to. No tiles will be loaded
-   * outside of this bounding box. It will not be possible to scroll outside
-   * of this bounding box.
+   * The leftmost of the world bounding box.
    *
    */
-  pspec = g_param_spec_boxed ("world",
-                              "The world",
-                              "The bounding box to limit the #ChamplainView to",
-                              CHAMPLAIN_TYPE_BOUNDING_BOX,
-                              G_PARAM_READABLE);
-  g_object_class_install_property (object_class, PROP_WORLD, pspec);
+  pspec = g_param_spec_double ("worl-left",
+                               "Boundingbox left",
+                               "The leftmost coordinate of the world boundingbox",
+                               -180,
+                               180,
+                               -180,
+                               G_PARAM_READABLE);
+
+  /**
+   * MapsFileTileSource:world_top:
+   *
+   * The top of the world bounding box.
+   *
+   */
+  pspec = g_param_spec_double ("worl-top",
+                               "Boundingbox top",
+                               "The topmost coordinate of the world boundingbox",
+                               -90,
+                               90,
+                               90,
+                               G_PARAM_READABLE);
+  /**
+   * MapsFileTileSource:world_right:
+   *
+   * The rightmost of the world bounding box.
+   *
+   */
+  pspec = g_param_spec_double ("worl-right",
+                               "Boundingbox right",
+                               "The rightmost coordinate of the world boundingbox",
+                               -180,
+                               180,
+                               180,
+                               G_PARAM_READABLE);
+
+  /**
+   * MapsFileTileSource:world_bottom:
+   *
+   * The bottommost of the world bounding box.
+   *
+   */
+  pspec = g_param_spec_double ("worl-bottom",
+                               "Boundingbox bottom",
+                               "The bottommost coordinate of the world boundingbox",
+                               -90,
+                               90,
+                               -90,
+                               G_PARAM_READABLE);
 }
 
 static void
@@ -239,11 +281,14 @@ maps_file_tile_source_init (MapsFileTileSource *tile_source)
   tile_source->priv->extension = NULL;
   tile_source->priv->max_zoom = -1;
   tile_source->priv->min_zoom = 21;
-  tile_source->priv->world = NULL;
   tile_source->priv->min_x = G_MAXLONG;
   tile_source->priv->min_y = G_MAXLONG;
   tile_source->priv->max_x = 0;
   tile_source->priv->max_y = 0;
+  tile_source->priv->world_left = -180;
+  tile_source->priv->world_top = 90;
+  tile_source->priv->world_right = 180;
+  tile_source->priv->world_bottom = -90;
 }
 
 static gboolean
@@ -474,9 +519,9 @@ maps_file_tile_source_prepare (MapsFileTileSource *tile_source,
   g_return_val_if_fail (MAPS_IS_FILE_TILE_SOURCE (tile_source), FALSE);
   g_return_val_if_fail (tile_source->priv->path != NULL, FALSE);
 
-  ChamplainMapSource *source = (ChamplainMapSource *) tile_source;
+  ShumateMapSource *source = (ShumateMapSource *) tile_source;
   gboolean ret = TRUE;
-  guint tile_size = champlain_map_source_get_tile_size (source);
+  guint tile_size = shumate_map_source_get_tile_size (source);
 
   if (!get_zoom_levels (tile_source, error)) {
     ret = FALSE;
@@ -488,20 +533,19 @@ maps_file_tile_source_prepare (MapsFileTileSource *tile_source,
     goto out;
   }
 
-  tile_source->priv->world = champlain_bounding_box_new ();
-  tile_source->priv->world->left = champlain_map_source_get_longitude (source,
+  tile_source->priv->world_left = shumate_map_source_get_longitude (source,
                                                     tile_source->priv->min_zoom,
                                                     tile_source->priv->min_x *
                                                     tile_size);
-  tile_source->priv->world->right = champlain_map_source_get_longitude (source,
+  tile_source->priv->world_right = shumate_map_source_get_longitude (source,
                                                      tile_source->priv->min_zoom,
                                                      (tile_source->priv->max_x + 1) *
                                                      tile_size);
-  tile_source->priv->world->top = champlain_map_source_get_latitude (source,
+  tile_source->priv->world_top = shumate_map_source_get_latitude (source,
                                                      tile_source->priv->min_zoom,
                                                      tile_source->priv->min_y *
                                                      tile_size);
-  tile_source->priv->world->bottom = champlain_map_source_get_latitude (source,
+  tile_source->priv->world_bottom = shumate_map_source_get_latitude (source,
                                                   tile_source->priv->min_zoom,
                                                   (tile_source->priv->max_y + 1) *
                                                   tile_size);
@@ -510,131 +554,56 @@ maps_file_tile_source_prepare (MapsFileTileSource *tile_source,
 }
 
 static void
-tile_rendered_cb (ChamplainTile    *tile,
-                  gpointer          data,
-                  guint             size,
-                  gboolean          error,
-                  CallbackData     *user_data)
-{
-  ChamplainMapSource *map_source = user_data->map_source;
-  ChamplainMapSource *next_source;
-
-  g_signal_handlers_disconnect_by_func (tile, tile_rendered_cb, user_data);
-  g_slice_free (CallbackData, user_data);
-
-  next_source = champlain_map_source_get_next_source (map_source);
-
-  if (!error)
-    {
-      ChamplainTileSource *tile_source = CHAMPLAIN_TILE_SOURCE (map_source);
-      ChamplainTileCache *tile_cache = champlain_tile_source_get_cache (tile_source);
-
-      if (tile_cache && data)
-        champlain_tile_cache_store_tile (tile_cache, tile, data, size);
-
-      champlain_tile_set_fade_in (tile, TRUE);
-      champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
-      champlain_tile_display_content (tile);
-    }
-  else if (next_source)
-    champlain_map_source_fill_tile (next_source, tile);
-
-  g_object_unref (map_source);
-  g_object_unref (tile);
-}
-
-static void
-tile_loaded_cb (GFile        *file,
-                GAsyncResult *res,
-                CallbackData *user_data)
+fill_tile_async (ShumateMapSource     *source,
+                 ShumateTile          *tile,
+                 GCancellable         *cancellable,
+                 GAsyncReadyCallback   callback,
+                 gpointer              user_data)
 {
-  ChamplainMapSource *map_source = user_data->map_source;
-  ChamplainMapSource *next_source = champlain_map_source_get_next_source (map_source);
-  ChamplainTile *tile = user_data->tile;
-  CallbackData *data;
-  ChamplainRenderer *renderer;
-  guint8 *content;
-  gsize length;
-
-  g_slice_free (CallbackData, user_data);
-
-  if (!g_file_load_contents_finish (file, res, (char **) &content, &length, NULL, NULL))
-    {
-      goto load_next;
-    }
-
-  renderer = champlain_map_source_get_renderer (map_source);
-  g_return_if_fail (CHAMPLAIN_IS_RENDERER (renderer));
-
-  data = g_slice_new (CallbackData);
-  data->map_source = map_source;
-
-  g_signal_connect (tile, "render-complete", G_CALLBACK (tile_rendered_cb), data);
-
-  champlain_renderer_set_data (renderer, content, length);
-  champlain_renderer_render (renderer, tile);
-
-  return;
-
-load_next:
-  if (next_source)
-    champlain_map_source_fill_tile (next_source, tile);
-
-  goto cleanup;
+  g_return_if_fail (MAPS_IS_FILE_TILE_SOURCE (source));
 
-  champlain_tile_set_fade_in (tile, TRUE);
-  champlain_tile_set_state (tile, CHAMPLAIN_STATE_DONE);
-  champlain_tile_display_content (tile);
-
-cleanup:
-  g_object_unref (tile);
-  g_object_unref (map_source);
-}
-
-static void
-fill_tile (ChamplainMapSource *map_source,
-           ChamplainTile      *tile)
-{
-  g_return_if_fail (MAPS_IS_FILE_TILE_SOURCE (map_source));
-  g_return_if_fail (CHAMPLAIN_IS_TILE (tile));
-
-  MapsFileTileSource *tile_source = MAPS_FILE_TILE_SOURCE (map_source);
-  CallbackData *callback_data;
+  MapsFileTileSource *tile_source = MAPS_FILE_TILE_SOURCE (source);
   GFile *file;
   gchar *path = NULL;
-
-  if (champlain_tile_get_state (tile) == CHAMPLAIN_STATE_DONE)
-    return;
+  g_autoptr(GTask) task = NULL;
 
   path = g_strdup_printf("%s/%d/%d/%d.%s",
                          tile_source->priv->path,
-                         champlain_tile_get_zoom_level (tile),
-                         champlain_tile_get_x (tile),
-                         champlain_tile_get_y (tile),
+                         shumate_tile_get_zoom_level (tile),
+                         shumate_tile_get_x (tile),
+                         shumate_tile_get_y (tile),
                          tile_source->priv->extension);
   file = g_file_new_for_path (path);
 
+  task = g_task_new (source, cancellable, callback, user_data);
+  g_task_set_source_tag (task, fill_tile_async);
+
   if (g_file_query_exists(file, NULL))
     {
-      callback_data = g_slice_new (CallbackData);
-      callback_data->tile = tile;
-      callback_data->map_source = map_source;
-
-      g_object_ref (map_source);
-      g_object_ref (tile);
-
       g_file_load_contents_async (file, NULL,
-                                  (GAsyncReadyCallback) tile_loaded_cb,
-                                  callback_data);
+                                  callback,
+                                  user_data);
+
+      g_task_return_boolean (task, TRUE);
     }
   else
     {
-      ChamplainMapSource *next_source = champlain_map_source_get_next_source (map_source);
-
-      if (CHAMPLAIN_IS_MAP_SOURCE (next_source))
-        champlain_map_source_fill_tile (next_source, tile);
+      g_task_return_boolean (task, FALSE);
     }
 
   g_object_unref (file);
   g_free (path);
 }
+
+static gboolean
+fill_tile_finish (ShumateMapSource *map_source,
+                                        GAsyncResult *result,
+                                        GError **error)
+{
+  MapsFileTileSource *self = (MapsFileTileSource *) map_source;
+
+  g_return_val_if_fail (MAPS_IS_FILE_TILE_SOURCE (self), FALSE);
+  g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
+
+  return g_task_propagate_boolean (G_TASK (result), error);
+}
diff --git a/lib/maps-file-tile-source.h b/lib/maps-file-tile-source.h
index 9b432e04..f7c88e15 100644
--- a/lib/maps-file-tile-source.h
+++ b/lib/maps-file-tile-source.h
@@ -20,7 +20,7 @@
 #ifndef _MAPS_FILE_TILE_SOURCE_H_
 #define _MAPS_FILE_TILE_SOURCE_H_
 
-#include <champlain/champlain.h>
+#include <shumate/shumate.h>
 
 G_BEGIN_DECLS
 
@@ -55,19 +55,19 @@ typedef struct _MapsFileTileSourceClass MapsFileTileSourceClass;
  */
 struct _MapsFileTileSource
 {
-  ChamplainTileSource parent_instance;
+  ShumateMapSource parent_instance;
 
   MapsFileTileSourcePrivate *priv;
 };
 
 struct _MapsFileTileSourceClass
 {
-  ChamplainTileSourceClass parent_class;
+  ShumateMapSourceClass parent_class;
 };
 
 GType maps_file_tile_source_get_type (void);
 
-gboolean maps_file_tile_source_prepare (MapsFileTileSource *tile_source, GError **error);
+gboolean maps_file_tile_source_prepare (MapsFileTileSource *data_source, GError **error);
 G_END_DECLS
 
 #endif /* _MAPS_FILE_TILE_SOURCE_H_ */
diff --git a/lib/maps-sync-map-source.c b/lib/maps-sync-map-source.c
new file mode 100644
index 00000000..5955f6c6
--- /dev/null
+++ b/lib/maps-sync-map-source.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2022 Marcus Lundblad
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marcus Lundblad <ml dfupdate se>
+ */
+
+#include <shumate/shumate.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+
+#include "maps-sync-map-source.h"
+
+/*
+struct _MapsFileTileSourcePrivate
+{
+};
+*/
+
+G_DEFINE_ABSTRACT_TYPE (MapsSyncMapSource, maps_sync_map_source, SHUMATE_TYPE_MAP_SOURCE)
+
+static void
+fill_tile_async (ShumateMapSource     *source,
+                 ShumateTile          *tile,
+                 GCancellable         *cancellable,
+                 GAsyncReadyCallback   callback,
+                 gpointer              user_data);
+
+static gboolean
+fill_tile_finish (ShumateMapSource *map_source,
+                  GAsyncResult *result,
+                  GError **error);
+
+static void
+maps_sync_map_source_class_init (MapsSyncMapSourceClass *klass)
+{
+  ShumateMapSourceClass *map_source_class = SHUMATE_MAP_SOURCE_CLASS (klass);
+
+  map_source_class->fill_tile_async = fill_tile_async;
+  map_source_class->fill_tile_finish = fill_tile_finish;
+
+  klass->fill_tile = NULL;
+}
+
+static void
+maps_sync_map_source_init (MapsSyncMapSource *map_source)
+{
+  map_source->priv = maps_sync_map_source_get_instance_private (map_source);
+}
+
+static void
+fill_tile_async (ShumateMapSource     *source,
+                 ShumateTile          *tile,
+                 GCancellable         *cancellable,
+                 GAsyncReadyCallback   callback,
+                 gpointer              user_data)
+{
+  MapsSyncMapSource *self = (MapsSyncMapSource *) source;
+  g_return_if_fail (MAPS_IS_SYNC_MAP_SOURCE (source));
+
+  g_autoptr(GTask) task = NULL;
+
+  MAPS_SYNC_MAP_SOURCE_CLASS (self)->fill_tile (self, tile);
+
+  task = g_task_new (source, cancellable, callback, user_data);
+  g_task_set_source_tag (task, fill_tile_async);
+
+
+  g_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+fill_tile_finish (ShumateMapSource *map_source,
+                                        GAsyncResult *result,
+                                        GError **error)
+{
+  MapsSyncMapSource *self = (MapsSyncMapSource *) map_source;
+
+  g_return_val_if_fail (MAPS_IS_SYNC_MAP_SOURCE (self), FALSE);
+  g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
+
+  return g_task_propagate_boolean (G_TASK (result), error);
+}
diff --git a/lib/maps-sync-map-source.h b/lib/maps-sync-map-source.h
new file mode 100644
index 00000000..443ed39d
--- /dev/null
+++ b/lib/maps-sync-map-source.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2022 Marcus Lundblad
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marcus Lundblad <ml dfupdate se>
+ */
+
+#ifndef _MAPS_SYNC_MAP_SOURCE_H_
+#define _MAPS_SYNC_MAP_SOURCE_H_
+
+#include <shumate/shumate.h>
+
+G_BEGIN_DECLS
+
+#define MAPS_TYPE_SYNC_MAP_SOURCE maps_sync_map_source_get_type ()
+
+#define MAPS_SYNC_MAP_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAPS_TYPE_SYNC_MAP_SOURCE, MapsSyncMapSource))
+
+#define MAPS_SYNC_MAP_SOURCE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), MAPS_TYPE_SYNC_MAP_SOURCE, MapsSyncMapSourceClass))
+
+#define MAPS_IS_SYNC_MAP_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAPS_TYPE_SYNC_MAP_SOURCE))
+
+#define MAPS_IS_SYNC_MAP_SOURCE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), MAPS_TYPE_SYNC_MAP_SOURCE))
+
+#define MAPS_SYNC_MAP_SOURCE_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), MAPS_TYPE_SYNC_MAP_SOURCE, MapsSyncMapSourceClass))
+
+typedef struct _MapsSyncMapSourcePrivate MapsSyncMapSourcePrivate;
+
+typedef struct _MapsSyncMapSource MapsSyncMapSource;
+typedef struct _MapsSyncMapSourceClass MapsSyncMapSourceClass;
+
+/**
+ * MapsSyncMapSource:
+ *
+ * The #MapsSyncMapSource structure contains only private data
+ * and should be accessed using the provided API
+ *
+ */
+struct _MapsSyncMapSource
+{
+  ShumateMapSource parent_instance;
+
+  MapsSyncMapSourcePrivate *priv;
+};
+
+struct _MapsSyncMapSourceClass
+{
+  ShumateMapSourceClass parent_class;
+
+  void (*fill_tile)  (MapsSyncMapSource     *self,
+                      ShumateTile              *tile);
+};
+
+GType maps_sync_map_source_get_type (void);
+
+#endif /* _MAPS_SYNC_MAP_SOURCE_H_ */
diff --git a/lib/meson.build b/lib/meson.build
index 8de63691..ba6251a9 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -6,7 +6,8 @@ headers_private = files(
        'maps-osm-object.h',
        'maps-osm-way.h',
        'maps-osm-relation.h',
-       'maps-osm-oauth-proxy-call.h'
+       'maps-osm-oauth-proxy-call.h',
+       'maps-sync-map-source.h'
 )
 
 sources = files(
@@ -17,7 +18,8 @@ sources = files(
        'maps-osm-object.c',
        'maps-osm-way.c',
        'maps-osm-relation.c',
-       'maps-osm-oauth-proxy-call.c'
+       'maps-osm-oauth-proxy-call.c',
+       'maps-sync-map-source.c'
 )
 
 cflags = [
@@ -47,8 +49,8 @@ gnome.generate_gir(
        includes: [
                'GLib-2.0',
                'GObject-2.0',
-               'Champlain-0.12',
-               'Rest-0.7'
+               'Rest-0.7',
+               'Shumate-1.0'
        ],
        install: true,
        install_dir_gir: join_paths(pkgdatadir, 'gir-' + maps_gir_version),
diff --git a/meson.build b/meson.build
index a9e018f3..2380f1c8 100644
--- a/meson.build
+++ b/meson.build
@@ -34,13 +34,13 @@ glib = dependency('glib-2.0', version: '>= 2.66.0')
 gio = dependency('gio-2.0', version: '>= 2.44.0')
 gjs = dependency('gjs-1.0', version: '>= 1.69.2')
 girepository = dependency('gobject-introspection-1.0', version: '>= 0.10.1')
-gtk3 = dependency('gtk+-3.0', version: '>= 3.22.0')
+gtk4 = dependency('gtk4')
 geoclue2 = dependency('geoclue-2.0', version: '>= 0.12.99')
-handy = dependency('libhandy-1', version: '>= 1.5.0')
+libadwaita = dependency('libadwaita-1')
 gweather = dependency('gweather4', version: '>= 3.90.0')
 
 libmaps_deps = [
-       dependency('champlain-0.12', version: '>= 0.12.14'),
+       dependency('shumate-1.0'),
        dependency('libxml-2.0'),
        dependency('rest-0.7', version: '>= 0.7.90')
 ]
diff --git a/org.gnome.Maps.json b/org.gnome.Maps.json
index bb2e1196..be095983 100644
--- a/org.gnome.Maps.json
+++ b/org.gnome.Maps.json
@@ -90,51 +90,18 @@
             ]
         },
         {
-            "name": "cogl",
-            "config-opts": [
-                "--disable-cogl-gst",
-                "--enable-xlib-egl-platform",
-                "--enable-wayland-egl-platform"
-            ],
-            "sources": [
-                {
-                    "type": "archive",
-                    "url": "https://download.gnome.org/sources/cogl/1.22/cogl-1.22.8.tar.xz";,
-                    "sha256": "a805b2b019184710ff53d0496f9f0ce6dcca420c141a0f4f6fcc02131581d759"
-                }
-            ]
-        },
-        {
-            "name": "clutter",
+            "name" : "libshumate",
+            "buildsystem": "meson",
             "config-opts": [
-                "--enable-egl-backend",
-                "--enable-wayland-backend"
+                "-Ddemos=false",
+                "-Dgtk_doc=false",
+                "-Dvapi=false"
             ],
-            "sources": [
-                {
-                    "type": "archive",
-                    "url": "https://download.gnome.org/sources/clutter/1.26/clutter-1.26.4.tar.xz";,
-                    "sha256": "8b48fac159843f556d0a6be3dbfc6b083fc6d9c58a20a49a6b4919ab4263c4e6"
-                }
-            ]
-        },
-        {
-            "name": "clutter-gtk",
-            "sources": [
-                {
-                    "type": "archive",
-                    "url": "https://download.gnome.org/sources/clutter-gtk/1.8/clutter-gtk-1.8.4.tar.xz";,
-                    "sha256": "521493ec038973c77edcb8bc5eac23eed41645117894aaee7300b2487cb42b06"
-                }
-            ]
-        },
-        {
-            "name" : "libchamplain",
-            "buildsystem": "meson",
             "sources" : [
                 {
                     "type" : "git",
-                    "url" : "https://gitlab.gnome.org/GNOME/libchamplain.git";
+                    "url" : "https://gitlab.gnome.org/GNOME/libshumate.git";,
+                    "branch" : "main"
                 }
             ]
         },
diff --git a/src/application.js b/src/application.js
index e45a2d93..3856699e 100644
--- a/src/application.js
+++ b/src/application.js
@@ -25,8 +25,7 @@ import GObject from 'gi://GObject';
 import Geocode from 'gi://GeocodeGlib';
 import Gio from 'gi://Gio';
 import Gtk from 'gi://Gtk';
-import GtkClutter from 'gi://GtkClutter';
-import Hdy from 'gi://Handy';
+import Adw from 'gi://Adw';
 
 import {Geoclue} from './geoclue.js';
 import * as GeocodeFactory from './geocode.js';
@@ -140,9 +139,6 @@ export class Application extends Gtk.Application {
     vfunc_startup() {
         super.vfunc_startup();
 
-        GtkClutter.init(null);
-        Hdy.init();
-
         Utils.loadStyleSheet(Gio.file_new_for_uri('resource:///org/gnome/Maps/application.css'));
 
         Application.application = this;
@@ -163,8 +159,8 @@ export class Application extends Gtk.Application {
         }, Application.settings);
 
 
-        this._styleManager = Hdy.StyleManager.get_default();
-        this._styleManager.set_color_scheme(Hdy.ColorScheme.PREFER_LIGHT);
+        this._styleManager = Adw.StyleManager.get_default();
+        this._styleManager.set_color_scheme(Adw.ColorScheme.PREFER_LIGHT);
 
         Gtk.IconTheme.get_default().append_search_path(GLib.build_filenamev([pkg.pkgdatadir,
                                                                              'icons']));
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 0b71b08e..e4d406ea 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -36,7 +36,7 @@ import {RouteQuery} from './routeQuery.js';
 import * as Utils from './utils.js';
 import {ZoomInDialog} from './zoomInDialog.js';
 
-export class ContextMenu extends Gtk.Menu {
+export class ContextMenu extends Gtk.PopoverMenu {
     constructor(params) {
         let mapView = params.mapView;
         delete params.mapView;
diff --git a/src/epaf.js b/src/epaf.js
index 8235e8f5..93254328 100644
--- a/src/epaf.js
+++ b/src/epaf.js
@@ -23,7 +23,7 @@
 // Google encoded polyline decoder
 // https://developers.google.com/maps/documentation/utilities/polylinealgorithm
 
-import Champlain from 'gi://Champlain';
+import Shumate from 'gi://Shumate';
 
 function _decodeValue(data, index) {
     let b;
@@ -61,7 +61,7 @@ export function decode(data) {
         // first value is absolute, rest are relative to previous value
         lat += latdelta;
         lon += londelta;
-        polyline.push(new Champlain.Coordinate({
+        polyline.push(new Shumate.Coordinate({
             latitude:  lat * 1e-5,
             longitude: lon * 1e-5
         }));
diff --git a/src/geoJSONSource.js b/src/geoJSONSource.js
index f0b6e5ef..ef998a38 100644
--- a/src/geoJSONSource.js
+++ b/src/geoJSONSource.js
@@ -19,10 +19,11 @@
  */
 
 import Cairo from 'cairo';
-import Champlain from 'gi://Champlain';
-import Clutter from 'gi://Clutter';
 import GLib from 'gi://GLib';
 import GObject from 'gi://GObject';
+import Shumate from 'gi://Shumate';
+
+import GnomeMaps from 'gi://GnomeMaps';
 
 import {BoundingBox} from './boundingBox.js';
 import * as Geojsonvt from './geojsonvt/geojsonvt.js';
@@ -38,7 +39,7 @@ const TileFeature = { POINT: 1,
                       LINESTRING: 2,
                       POLYGON: 3 };
 
-export class GeoJSONSource extends Champlain.TileSource {
+export class GeoJSONSource extends GnomeMaps.SyncMapSource {
 
     constructor(params) {
         super();
@@ -46,46 +47,21 @@ export class GeoJSONSource extends Champlain.TileSource {
         this._mapView = params.mapView;
         this._markerLayer = params.markerLayer;
         this._bbox = new BoundingBox();
-        this._tileSize = Service.getService().tiles.street.tile_size;
+        this.tile_size = Service.getService().tiles.street.tile_size;
+        this.max_zoom_level = 20;
+        this.min_zoom_level = 0;
     }
 
     get bbox() {
         return this._bbox;
     }
 
-    vfunc_get_tile_size() {
-        return this._tileSize;
-    }
-
-    vfunc_get_max_zoom_level() {
-        return 20;
-    }
-
-    vfunc_get_min_zoom_level() {
-        return 0;
-    }
-
-    vfunc_get_id() {
-        return 'GeoJSONSource';
-    }
-
-    vfunc_get_name() {
-        return 'GeoJSONSource';
-    }
-
     vfunc_fill_tile(tile) {
-        if (tile.get_state() === Champlain.State.DONE)
+        if (tile.get_state() === Shumate.State.DONE)
             return;
 
-        tile.connect('render-complete', (tile, data, size, error) => {
-            if(!error) {
-                tile.set_state(Champlain.State.DONE);
-                tile.display_content();
-            } else if(this.next_source)
-                this.next_source.fill_tile(tile);
-        });
-
-        GLib.idle_add(tile, () => this._renderTile(tile));
+        tile.set_state(Shumate.State.DONE);
+        this._renderTile(tile);
     }
 
     _validate([lon, lat]) {
@@ -206,11 +182,12 @@ export class GeoJSONSource extends Champlain.TileSource {
 
     parse(json) {
         this._parseInternal(json);
-        this._tileIndex = Geojsonvt.geojsonvt(json, { extent: this._tileSize,
-                                                      maxZoom: 20 });
+        this._tileIndex = Geojsonvt.geojsonvt(json, { extent: this.tile_size,
+                                                      maxZoom: this.max_zoom_level });
         this._clampBBox();
     }
 
+    // TODO: render to a GdkTexture and set it on the tile
     _renderTile(tile) {
         let tileJSON = this._tileIndex.getTile(tile.zoom_level, tile.x, tile.y);
         let content = new Clutter.Canvas({ width: this._tileSize,
diff --git a/src/graphHopperTransit.js b/src/graphHopperTransit.js
index e60aff80..76d6411b 100644
--- a/src/graphHopperTransit.js
+++ b/src/graphHopperTransit.js
@@ -25,7 +25,7 @@
  * routing for walking legs
  */
 
-import Champlain from 'gi://Champlain';
+import Shumate from 'gi://Shumate';
 
 import {Application} from './application.js';
 import {Location} from './location.js';
@@ -64,10 +64,10 @@ export function createWalkingLeg(from, to, fromName, toName, route) {
 
 // create a straight-line "as the crow flies" polyline between two places
 function createStraightPolyline(fromLoc, toLoc) {
-    return [new Champlain.Coordinate({ latitude: fromLoc.latitude,
-                                       longitude: fromLoc.longitude }),
-            new Champlain.Coordinate({ latitude: toLoc.latitude,
-                                       longitude: toLoc.longitude })];
+    return [new Shumate.Coordinate({ latitude: fromLoc.latitude,
+                                     longitude: fromLoc.longitude }),
+            new Shumate.Coordinate({ latitude: toLoc.latitude,
+                                     longitude: toLoc.longitude })];
 }
 
 var _walkingRoutes = [];
diff --git a/src/layersPopover.js b/src/layersPopover.js
index 9297b152..80e4dbd9 100644
--- a/src/layersPopover.js
+++ b/src/layersPopover.js
@@ -17,11 +17,11 @@
  * Author: Dario Di Nucci <linkin88mail gmail com>
  */
 
-import Champlain from 'gi://Champlain';
+import Adw from 'gi://Adw';
 import GObject from 'gi://GObject';
 import Gtk from 'gi://Gtk';
 import Gdk from 'gi://Gdk';
-import Handy from 'gi://Handy';
+import Shumate from 'gi://Shumate';
 
 import {Application} from './application.js';
 import * as MapSource from './mapSource.js';
diff --git a/src/main.js b/src/main.js
index d46faa94..b7f0b87b 100644
--- a/src/main.js
+++ b/src/main.js
@@ -20,21 +20,17 @@
  *         Zeeshan Ali (Khattak) <zeeshanak gnome org>
  */
 
-import 'gi://Champlain?version=0.12';
-import 'gi://Clutter?version=1.0';
-import 'gi://Cogl?version=1.0';
+import 'gi://Adw?version=1';
 import 'gi://GeocodeGlib?version=1.0';
-import 'gi://Gdk?version=3.0';
+import 'gi://Gdk?version=4.0';
 import 'gi://GdkPixbuf?version=2.0';
 import 'gi://Gio?version=2.0';
 import 'gi://GLib?version=2.0';
 import 'gi://GObject?version=2.0';
-import 'gi://Gtk?version=3.0';
-import 'gi://GtkChamplain?version=0.12';
-import 'gi://GtkClutter?version=1.0';
+import 'gi://Gtk?version=4.0';
 import 'gi://GWeather?version=4.0';
-import 'gi://Handy?version=1';
 import 'gi://Rest?version=0.7';
+import 'gi://Shumate?version=1.0';
 import 'gi://Soup?version=2.4';
 
 import * as system from 'system';
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 6429dbc1..a35cc087 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -22,12 +22,12 @@
 
 import gettext from 'gettext';
 
-import Champlain from 'gi://Champlain';
 import GLib from 'gi://GLib';
 import GObject from 'gi://GObject';
 import Gdk from 'gi://Gdk';
 import Gio from 'gi://Gio';
 import Gtk from 'gi://Gtk';
+import Shumate from 'gi://Shumate';
 
 import {Application} from './application.js';
 import {ContextMenu} from './contextMenu.js';
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 88f29775..bc5e4118 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -22,6 +22,7 @@
 import Gio from 'gi://Gio';
 import GLib from 'gi://GLib';
 import GObject from 'gi://GObject';
+import Graphene from 'gi://Graphene';
 import Gtk from 'gi://Gtk';
 
 import {Application} from './application.js';
@@ -70,6 +71,26 @@ export class MapBubble extends Gtk.Popover {
 GObject.registerClass(MapBubble);
 
 export class MapBubbleScrolledWindow extends Gtk.ScrolledWindow {
+    vfunc_get_request_mode() {
+        return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH;
+    }
+
+    vfunc_measure(orientation, forSize) {
+        if (orientation === Gtk.Orientation.HORIZONTAL) {
+            let windowHeight = this.get_toplevel().get_allocated_height() - HEIGHT_MARGIN;
+            let [min, nat] = this.get_child().get_preferred_height_for_width(width);
+            min = Math.min(min, windowHeight);
+            nat = Math.min(nat, windowHeight);
+            return [min, nat, 0, 0];
+        } else {
+            let [min, nat] = this.get_child().get_preferred_width();
+            min = Math.min(min, MAX_CONTENT_WIDTH);
+            nat = Math.min(nat, MAX_CONTENT_WIDTH);
+            return [min, nat, 0, 0];
+        }
+    }
+
+    /*
     vfunc_get_preferred_width() {
         let [min, nat] = this.get_child().get_preferred_width();
         min = Math.min(min, MAX_CONTENT_WIDTH);
@@ -84,12 +105,17 @@ export class MapBubbleScrolledWindow extends Gtk.ScrolledWindow {
         nat = Math.min(nat, windowHeight);
         return [min, nat];
     }
+    */
 
-    vfunc_draw(cr) {
+    vfunc_snapshot(snapshot) {
         let popover = this.get_ancestor(Gtk.Popover);
         if (popover) {
-            let [{x, y, width, height}, baseline] = this.get_allocated_size();
+            let {x, y, width, height} = this.get_allocation();
+            let rect = new Graphene.Rect();
+
+            rect.init(x, y, width, height);
 
+            let cr = snapshot.append_cairo(rect);
             // clip the top corners to the rounded corner
             let radius = popover.get_style_context()
                                 .get_property(Gtk.STYLE_PROPERTY_BORDER_RADIUS, popover.get_state_flags())
@@ -103,9 +129,10 @@ export class MapBubbleScrolledWindow extends Gtk.ScrolledWindow {
             cr.lineTo(width, height);
 
             cr.clip();
+            cr.$dispose();
         }
 
-        return super.vfunc_draw(cr);
+        super.vfunc_snapshot(snapshot);
     }
 }
 
diff --git a/src/mapMarker.js b/src/mapMarker.js
index 8e3842cc..becaba10 100644
--- a/src/mapMarker.js
+++ b/src/mapMarker.js
@@ -20,19 +20,18 @@
  */
 
 import Cairo from 'cairo';
-import Champlain from 'gi://Champlain';
-import Clutter from 'gi://Clutter';
 import Gdk from 'gi://Gdk';
 import GLib from 'gi://GLib';
 import GObject from 'gi://GObject';
 import Gtk from 'gi://Gtk';
+import Shumate from 'gi://Shumate';
 
 import {Application} from './application.js';
 import {MapBubble} from './mapBubble.js';
 import {MapWalker} from './mapWalker.js';
 import * as Utils from './utils.js';
 
-export class MapMarker extends Champlain.Marker {
+export class MapMarker extends Shumate.Marker {
 
     constructor(params) {
         let place = params.place;
@@ -84,22 +83,6 @@ export class MapMarker extends Champlain.Marker {
         Application.application.connect('notify::adaptive-mode', this._onAdaptiveModeChanged.bind(this));
     }
 
-    get surface() {
-        return this._surface;
-    }
-
-    set surface(v) {
-        this._surface = v;
-    }
-
-    vfunc_get_surface() {
-        return this._surface;
-    }
-
-    vfunc_set_surface(surface) {
-        this._surface = surface;
-    }
-
     _actorFromIconName(name, size, color) {
         try {
             let theme = Gtk.IconTheme.get_default();
@@ -396,14 +379,11 @@ export class MapMarker extends Champlain.Marker {
 }
 
 GObject.registerClass({
-    Implements: [Champlain.Exportable],
     Abstract: true,
     Signals: {
         'gone-to': { }
     },
     Properties: {
-        'surface': GObject.ParamSpec.override('surface',
-                                              Champlain.Exportable),
         'view-latitude': GObject.ParamSpec.double('view-latitude', '', '',
                                                   GObject.ParamFlags.READABLE |
                                                   GObject.ParamFlags.WRITABLE,
diff --git a/src/mapSource.js b/src/mapSource.js
index 55c12a33..fe7f2c6c 100644
--- a/src/mapSource.js
+++ b/src/mapSource.js
@@ -17,7 +17,7 @@
  * Author: Jonas Danielsson <jonas threetimestwo org>
  */
 
-import Champlain from 'gi://Champlain';
+import Shumate from 'gi://Shumate';
 
 import * as Service from './service.js';
 import * as Utils from './utils.js';
diff --git a/src/mapView.js b/src/mapView.js
index 5aa43155..dae5b0ee 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -19,15 +19,13 @@
  * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
  */
 
-import Champlain from 'gi://Champlain';
-import Clutter from 'gi://Clutter';
 import GObject from 'gi://GObject';
+import Gdk from 'gi://Gdk';
 import GeocodeGlib from 'gi://GeocodeGlib';
 import Gio from 'gi://Gio';
 import GLib from 'gi://GLib';
 import Gtk from 'gi://Gtk';
-import GtkChamplain from 'gi://GtkChamplain';
-import Handy from 'gi://Handy';
+import Shumate from 'gi://Shumate';
 
 import GnomeMaps from 'gi://GnomeMaps';
 
@@ -77,7 +75,7 @@ const DASHED_ROUTE_LINE_GAP_LENGTH = 5;
 // Maximum limit of file size (20 MB) that can be loaded without user confirmation
 const FILE_SIZE_LIMIT_MB = 20;
 
-export class MapView extends GtkChamplain.Embed {
+export class MapView extends Gtk.Overlay {
 
     static MapType = {
         LOCAL: 'MapsLocalSource',
@@ -148,18 +146,14 @@ export class MapView extends GtkChamplain.Embed {
     _initScale(view) {
         let showScale = Application.settings.get('show-scale');
 
-        this._scale = new Champlain.Scale({ visible: showScale });
+        this._scale = new Shumate.Scale({ visible: showScale });
         this._scale.connect_view(view);
 
         if (Utils.getMeasurementSystem() === Utils.METRIC_SYSTEM)
-            this._scale.unit = Champlain.Unit.KM;
+            this._scale.unit = Shumate.Unit.KM;
         else
-            this._scale.unit = Champlain.Unit.MILES;
+            this._scale.unit = Shumate.Unit.MILES;
 
-        this._scale.set_x_expand(true);
-        this._scale.set_y_expand(true);
-        this._scale.set_x_align(Clutter.ActorAlign.START);
-        this._scale.set_y_align(Clutter.ActorAlign.END);
         view.add_child(this._scale);
     }
 
@@ -167,10 +161,6 @@ export class MapView extends GtkChamplain.Embed {
         let view = this.get_view();
 
         view.min_zoom_level = MapMinZoom;
-        view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_OUT_CUBIC;
-        view.reactive = true;
-        view.kinetic_mode = true;
-        view.horizontal_wrap = true;
 
         view.connect('notify::latitude', this._onViewMoved.bind(this));
         // switching map type will set view min-zoom-level from map source
@@ -188,21 +178,28 @@ export class MapView extends GtkChamplain.Embed {
     }
 
     /* create and store a route layer, pass true to get a dashed line */
-    _createRouteLayer(dashed, lineColor, width) {
-        let red = Color.parseColor(lineColor, 0);
-        let green = Color.parseColor(lineColor, 1);
-        let blue = Color.parseColor(lineColor, 2);
-        // Clutter uses a 0-255 range for color components
-        let strokeColor = new Clutter.Color({ red: red * 255,
-                                              blue: blue * 255,
-                                              green: green * 255,
-                                              alpha: 255 });
-        let routeLayer = new Champlain.PathLayer({ stroke_width: width,
-                                                   stroke_color: strokeColor });
+    _createRouteLayer(dashed, lineColor, outlineColor, width) {
+        let strokeColor = new Gdk.RGBA({ red:   Color.parseColor(lineColor, 0),
+                                         blue:  Color.parseColor(lineColor, 1),
+                                         green: Color.parseColor(lineColor, 2),
+                                         alpha: 1.0 });
+        let routeLayer = new Shumate.PathLayer({ stroke_width: width,
+                                                 stroke_color: strokeColor });
         if (dashed)
             routeLayer.set_dash([DASHED_ROUTE_LINE_FILLED_LENGTH,
                                  DASHED_ROUTE_LINE_GAP_LENGTH]);
 
+        if (outlineColor) {
+            let outlineStrokeColor =
+                new Gdk.RGBA({ red:   Color.parseColor(outlineColor, 0),
+                               green: Color.parseColor(outlineColor, 1),
+                               blue:  Color.parseColor(outlineColor, 2),
+                               alpha: 1.0 });
+
+            routeLayer.outline_color = outlineStrokeColor;
+            routeLayer.outline_width = 1.0;
+        }
+
         this._routeLayers.push(routeLayer);
         this.view.add_layer(routeLayer);
 
@@ -220,15 +217,15 @@ export class MapView extends GtkChamplain.Embed {
     }
 
     _initLayers() {
-        let mode = Champlain.SelectionMode.SINGLE;
+        let mode = Gtk.SelectionMode.SINGLE;
 
-        this._userLocationLayer = new Champlain.MarkerLayer({ selection_mode: mode });
+        this._userLocationLayer = new Shumate.MarkerLayer({ selection_mode: mode });
         this.view.add_layer(this._userLocationLayer);
 
-        this._placeLayer = new Champlain.MarkerLayer({ selection_mode: mode });
+        this._placeLayer = new Shumate.MarkerLayer({ selection_mode: mode });
         this.view.add_layer(this._placeLayer);
 
-        this._instructionMarkerLayer = new Champlain.MarkerLayer({ selection_mode: mode });
+        this._instructionMarkerLayer = new Shumate.MarkerLayer({ selection_mode: mode });
         this.view.add_layer(this._instructionMarkerLayer);
 
         ShapeLayer.SUPPORTED_TYPES.push(GeoJSONShapeLayer);
@@ -314,7 +311,7 @@ export class MapView extends GtkChamplain.Embed {
 
             Application.settings.set('map-type', mapType);
         } else {
-            let renderer = new Champlain.ImageRenderer();
+            let renderer = new Shumate.RasterRenderer();
             let source = new GnomeMaps.FileTileSource({
                 path: Utils.getBufferText(Application.application.local_tile_path),
                 renderer: renderer,
@@ -525,7 +522,7 @@ export class MapView extends GtkChamplain.Embed {
         let zoom = this.view.zoom_level;
         let location = [this.view.latitude, this.view.longitude];
 
-        /* protect agains situations where the Champlain view was already
+        /* protect agains situations where the map view was already
          * disposed, in this case zoom will be set to the GObject property
          * getter
          */
@@ -686,7 +683,7 @@ export class MapView extends GtkChamplain.Embed {
         this._placeLayer.remove_all();
 
         routeLayer = this._createRouteLayer(false, TURN_BY_TURN_ROUTE_COLOR,
-                                            ROUTE_LINE_WIDTH);
+                                            null, ROUTE_LINE_WIDTH);
         route.path.forEach((polyline) => routeLayer.add_node(polyline));
         this.routingOpen = true;
 
@@ -729,15 +726,11 @@ export class MapView extends GtkChamplain.Embed {
             let hasOutline = Color.relativeLuminance(color) >
                              OUTLINE_LUMINANCE_THREASHHOLD;
             let routeLayer;
-            let outlineRouteLayer;
+            let lineWidth = ROUTE_LINE_WIDTH + hasOutline ? 2 : 0;
 
-            /* draw an outline by drawing a background path layer if needed
-             * TODO: maybe we should add support for outlined path layers in
-             * libchamplain */
-            if (hasOutline)
-                outlineRouteLayer = this._createRouteLayer(dashed, outlineColor,
-                                                           ROUTE_LINE_WIDTH + 2);
-            routeLayer = this._createRouteLayer(dashed, color, ROUTE_LINE_WIDTH);
+            routeLayer = this._createRouteLayer(dashed, color,
+                                                hasOutline ? outlineColor : null,
+                                                lineWidth);
 
             /* if this is a walking leg and not at the start, "stitch" it
              * together with the end point of the previous leg, as the walk
@@ -749,11 +742,6 @@ export class MapView extends GtkChamplain.Embed {
                 routeLayer.add_node(lastPoint);
             }
 
-            if (hasOutline) {
-                leg.polyline.forEach((function (polyline) {
-                    outlineRouteLayer.add_node(polyline);
-                }));
-            }
             leg.polyline.forEach((function (polyline) {
                 routeLayer.add_node(polyline);
             }));
@@ -839,7 +827,7 @@ GObject.registerClass({
         'going-to-user-location': {},
         'gone-to-user-location': {},
         'view-moved': {},
-        'marker-selected': { param_types: [Champlain.Marker] },
+        'marker-selected': { param_types: [Shumate.Marker] },
         'map-type-changed': { param_types: [GObject.TYPE_STRING] }
     },
 }, MapView);
diff --git a/src/mapWalker.js b/src/mapWalker.js
index 925ea5bb..811fc6c9 100644
--- a/src/mapWalker.js
+++ b/src/mapWalker.js
@@ -21,7 +21,6 @@
  *         Damián Nohales <damiannohales gmail com>
  */
 
-import Clutter from 'gi://Clutter';
 import GObject from 'gi://GObject';
 
 import {BoundingBox} from './boundingBox.js';
@@ -101,7 +100,6 @@ export class MapWalker extends GObject.Object {
         this._updateGoToDuration(fromLocation);
 
         if (linear) {
-            this._view.goto_animation_mode = Clutter.AnimationMode.LINEAR;
             Utils.once(this._view, 'animation-completed',
                        this.zoomToFit.bind(this));
             this._view.go_to(this.place.location.latitude,
@@ -114,17 +112,14 @@ export class MapWalker extends GObject.Object {
              * also give user a good idea of where the destination is compared to current
              * location.
              */
-            this._view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_CUBIC;
             this._ensureVisible(fromLocation);
 
             Utils.once(this._view, 'animation-completed', () => {
-                this._view.goto_animation_mode = Clutter.AnimationMode.EASE_OUT_CUBIC;
                 this._view.go_to(this.place.location.latitude,
                                  this.place.location.longitude);
 
                 Utils.once(this._view, 'animation-completed::go-to', () => {
                     this.zoomToFit();
-                    this._view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_OUT_CUBIC;
                     this.emit('gone-to');
                 });
             });
diff --git a/src/placeBar.js b/src/placeBar.js
index 6db74564..f1beab25 100644
--- a/src/placeBar.js
+++ b/src/placeBar.js
@@ -19,7 +19,6 @@
  * Author: James Westman <james flyingpimonster net>
  */
 
-import Clutter from 'gi://Clutter';
 import Gdk from 'gi://Gdk';
 import GeocodeGlib from 'gi://GeocodeGlib';
 import GObject from 'gi://GObject';
@@ -147,3 +146,4 @@ GObject.registerClass({
                                           GeocodeGlib.Place)
     },
 }, PlaceBar);
+
diff --git a/src/placeViewImage.js b/src/placeViewImage.js
index 44670d59..cc50cf09 100644
--- a/src/placeViewImage.js
+++ b/src/placeViewImage.js
@@ -22,6 +22,7 @@
 import Cairo from 'cairo';
 import Gdk from 'gi://Gdk';
 import GObject from 'gi://GObject';
+import Graphene from 'gi://Graphene';
 import Gtk from 'gi://Gtk';
 
 /* The maximum aspect ratio, after which the image will be cropped vertically */
@@ -50,13 +51,19 @@ export class PlaceViewImage extends Gtk.DrawingArea {
         this.queue_resize();
     }
 
-    vfunc_draw(cr) {
-        let [{x, y, width, height}, baseline] = this.get_allocated_size();
+    vfunc_snapshot(snapshot) {
+        let {x, y, width, height} = this.get_allocation();
 
         if (this._pixbuf === null || width === 0 || height === 0) {
             return;
         }
 
+        let rect = new Graphene.Rect();
+
+        rect.init(x, y, width, height);
+
+        let cr = snapshot.append_cairo(rect);
+
         width *= this.scale_factor;
         height *= this.scale_factor;
 
@@ -82,13 +89,27 @@ export class PlaceViewImage extends Gtk.DrawingArea {
         cr.paint();
         cr.restore();
 
-        return false;
+        super.vfunc_snapshot(snapshot);
+        cr.$dispose();
     }
 
     vfunc_get_request_mode() {
         return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH;
     }
 
+    vfunc_measure(orientation, forSize) {
+        if (orientation === Gtk.Orientation.VERTICAL) {
+            if (this._pixbuf) {
+                let height = (this._pixbuf.height / this._pixbuf.width) * forSize;
+                return [height, height, 0, 0];
+            } else {
+                return [0, 0, 0, 0];
+            }
+        } else {
+            return [forSize, forSize, 0, 0];
+        }
+    }
+    /*
     vfunc_get_preferred_height_for_width(width) {
         if (this._pixbuf) {
             let height = (this._pixbuf.height / this._pixbuf.width) * width;
@@ -97,6 +118,7 @@ export class PlaceViewImage extends Gtk.DrawingArea {
             return [0, 0];
         }
     }
+    */
 }
 
 GObject.registerClass(PlaceViewImage);
diff --git a/src/printLayout.js b/src/printLayout.js
index 858e174f..4a7245a9 100644
--- a/src/printLayout.js
+++ b/src/printLayout.js
@@ -18,13 +18,12 @@
  */
 
 import Cairo from 'cairo';
-import Champlain from 'gi://Champlain';
-import Clutter from 'gi://Clutter';
 import Gdk from 'gi://Gdk';
 import GObject from 'gi://GObject';
 import Gtk from 'gi://Gtk';
 import Pango from 'gi://Pango';
 import PangoCairo from 'gi://PangoCairo';
+import Shumate from 'gi://Shumate';
 
 import {Application} from './application.js';
 import * as Color from './color.js';
@@ -33,10 +32,10 @@ import * as MapSource from './mapSource.js';
 import {TurnPointMarker} from './turnPointMarker.js';
 import * as Utils from './utils.js';
 
-const _STROKE_COLOR = new Clutter.Color({ red: 0,
-                                          blue: 255,
-                                          green: 0,
-                                          alpha: 255 });
+const _STROKE_COLOR = new Gdk.RGBA({ red:   0.0,
+                                     blue:  1.0,
+                                     green: 0.0,
+                                     alpha: 1.0 });
 const _STROKE_WIDTH = 5.0;
 
 /* All following constants are ratios of surface size to page size */
@@ -177,8 +176,8 @@ export class PrintLayout extends GObject.Object {
     }
 
     _addRouteLayer(view) {
-        let routeLayer = new Champlain.PathLayer({ stroke_width: _STROKE_WIDTH,
-                                                   stroke_color: _STROKE_COLOR });
+        let routeLayer = new Shumate.PathLayer({ stroke_width: _STROKE_WIDTH,
+                                                 stroke_color: _STROKE_COLOR });
         view.add_layer(routeLayer);
         this._route.path.forEach((node) => routeLayer.add_node(node));
     }
diff --git a/src/shapeLayer.js b/src/shapeLayer.js
index 18ac5170..ef793094 100644
--- a/src/shapeLayer.js
+++ b/src/shapeLayer.js
@@ -17,9 +17,10 @@
  * Author: Hashem Nasarat <hashem riseup net>
  */
 
-import Champlain from 'gi://Champlain';
 import Gio from 'gi://Gio';
 import GObject from 'gi://GObject';
+import Gtk from 'gi://Gtk';
+import Shumate from 'gi://Shumate';
 
 import {GeoJSONShapeLayer} from './geoJSONShapeLayer.js';
 import * as Utils from './utils.js';
@@ -53,8 +54,8 @@ export class ShapeLayer extends GObject.Object {
             null
         ).get_attribute_string(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
 
-        this._markerLayer = new Champlain.MarkerLayer({
-            selection_mode: Champlain.SelectionMode.SINGLE
+        this._markerLayer = new Shumate.MarkerLayer({
+            selection_mode: Gtk.SelectionMode.SINGLE
         });
         this._mapSource = null;
     }
diff --git a/src/storedRoute.js b/src/storedRoute.js
index 1fbfef3f..094657d0 100644
--- a/src/storedRoute.js
+++ b/src/storedRoute.js
@@ -20,9 +20,9 @@
  * Author: Jonas Danielsson <jonas threetimestwo org>
  */
 
-import Champlain from 'gi://Champlain';
 import GObject from 'gi://GObject';
 import Gtk from 'gi://Gtk';
+import Shumate from 'gi://Shumate';
 
 import {Place} from './place.js';
 import {Route, TurnPoint} from './route.js';
@@ -175,15 +175,15 @@ export class StoredRoute extends Place {
                 prop.path = prop.path.map((coordinate) => {
                     let lat = coordinate.latitude;
                     let lon = coordinate.longitude;
-                    return new Champlain.Coordinate({ latitude: lat,
-                                                      longitude: lon });
+                    return new Shumate.Coordinate({ latitude: lat,
+                                                    longitude: lon });
                 });
                 prop.turnPoints = prop.turnPoints.map((turnPoint) => {
                     let lat = turnPoint.coordinate.latitude;
                     let lon = turnPoint.coordinate.longitude;
 
-                    let coordinate = new Champlain.Coordinate({ latitude: lat,
-                                                                longitude: lon });
+                    let coordinate = new Shumate.Coordinate({ latitude: lat,
+                                                              longitude: lon });
 
                     return new TurnPoint({
                         coordinate: coordinate,
diff --git a/src/transitBoardMarker.js b/src/transitBoardMarker.js
index 462727c4..3894025b 100644
--- a/src/transitBoardMarker.js
+++ b/src/transitBoardMarker.js
@@ -20,7 +20,6 @@
  */
 
 import Cairo from 'cairo';
-import Clutter from 'gi://Clutter';
 import Gdk from 'gi://Gdk';
 import GObject from 'gi://GObject';
 import Gtk from 'gi://Gtk';
diff --git a/src/transitPrintLayout.js b/src/transitPrintLayout.js
index 1339b62e..cd05a505 100644
--- a/src/transitPrintLayout.js
+++ b/src/transitPrintLayout.js
@@ -20,10 +20,10 @@
  */
 
 import Cairo from 'cairo';
-import Champlain from 'gi://Champlain';
-import Clutter from 'gi://Clutter';
+import Gdk from 'gi://Gdk';
 import GObject from 'gi://GObject';
 import Pango from 'gi://Pango';
+import Shumate from 'gi://Shumate';
 
 import * as Color from './color.js';
 import * as Gfx from './gfx.js';
@@ -35,10 +35,10 @@ import {TransitBoardMarker} from './transitBoardMarker.js';
 import {TransitWalkMarker} from './transitWalkMarker.js';
 
 // stroke color for walking paths
-const _STROKE_COLOR = new Clutter.Color({ red: 0,
-                                          blue: 0,
-                                          green: 0,
-                                          alpha: 255 });
+const _STROKE_COLOR = new Gdk.RGBA({ red: 0.0,
+                                     blue: 0.0,
+                                     green: 0.0,
+                                     alpha: 1.0 });
 const _STROKE_WIDTH = 5.0;
 
 // All following constants are ratios of surface size to page size
diff --git a/src/transitplugins/openTripPlanner.js b/src/transitplugins/openTripPlanner.js
index 9c80e910..ad2160fc 100644
--- a/src/transitplugins/openTripPlanner.js
+++ b/src/transitplugins/openTripPlanner.js
@@ -21,8 +21,8 @@
 
 import gettext from 'gettext';
 
-import Champlain from 'gi://Champlain';
 import GLib from 'gi://GLib';
+import Shumate from 'gi://Shumate';
 import Soup from 'gi://Soup';
 
 import {Application} from '../application.js';
@@ -1140,8 +1140,8 @@ export class OpenTripPlanner {
     }
 
     _createTurnpoint(step) {
-        let coordinate = new Champlain.Coordinate({ latitude: step.lat,
-                                                    longitude: step.lon });
+        let coordinate = new Shumate.Coordinate({ latitude: step.lat,
+                                                  longitude: step.lon });
         let turnpoint = new TurnPoint({
             coordinate: coordinate,
             type: this._getTurnpointType(step),
diff --git a/src/transitplugins/opendataCH.js b/src/transitplugins/opendataCH.js
index e9431005..6ccab174 100644
--- a/src/transitplugins/opendataCH.js
+++ b/src/transitplugins/opendataCH.js
@@ -27,8 +27,8 @@
  * https://transport.opendata.ch/docs.html
  */
 
-import Champlain from 'gi://Champlain';
 import GLib from 'gi://GLib';
+import Shumate from 'gi://Shumate';
 import Soup from 'gi://Soup';
 
 import {Application} from '../application.js';
@@ -391,18 +391,18 @@ export class OpendataCH {
 
             section.journey.passList.forEach((pass) => {
                 let coordinate = pass.location.coordinate;
-                polyline.push(new Champlain.Coordinate({ latitude:  coordinate.x,
-                                                         longitude: coordinate.y }));
+                polyline.push(new Shumate.Coordinate({ latitude:  coordinate.x,
+                                                       longitude: coordinate.y }));
             });
         } else {
             let [departureX, departureY, arrivalX, arrivalY] =
                 this._getCoordsForSection(section, index, sections);
 
             polyline =
-                [new Champlain.Coordinate({ latitude:  departureX,
-                                            longitude: departureY }),
-                 new Champlain.Coordinate({ latitude:  arrivalX,
-                                            longitude: arrivalY })];
+                [new Shumate.Coordinate({ latitude:  departureX,
+                                          longitude: departureY }),
+                 new Shumate.Coordinate({ latitude:  arrivalX,
+                                          longitude: arrivalY })];
         }
 
         return polyline;
diff --git a/src/transitplugins/resrobot.js b/src/transitplugins/resrobot.js
index d019640e..57931818 100644
--- a/src/transitplugins/resrobot.js
+++ b/src/transitplugins/resrobot.js
@@ -27,8 +27,8 @@
  * https://www.trafiklab.se/api/resrobot-reseplanerare/dokumentation/sokresa
  */
 
-import Champlain from 'gi://Champlain';
 import GLib from 'gi://GLib';
+import Shumate from 'gi://Shumate';
 import Soup from 'gi://Soup';
 
 import {Application} from '../application.js';
@@ -487,15 +487,15 @@ export class Resrobot {
             polyline = [];
 
             leg.Stops.Stop.forEach((stop) => {
-                polyline.push(new Champlain.Coordinate({ latitude:  stop.lat,
-                                                         longitude: stop.lon }));
+                polyline.push(new Shumate.Coordinate({ latitude:  stop.lat,
+                                                       longitude: stop.lon }));
             });
         } else {
             polyline =
-                [new Champlain.Coordinate({ latitude:  leg.Origin.lat,
-                                            longitude: leg.Origin.lon }),
-                 new Champlain.Coordinate({ latitude:  leg.Destination.lat,
-                                            longitude: leg.Destination.lon })];
+                [new Shumate.Coordinate({ latitude:  leg.Origin.lat,
+                                          longitude: leg.Origin.lon }),
+                 new Shumate.Coordinate({ latitude:  leg.Destination.lat,
+                                          longitude: leg.Destination.lon })];
         }
 
         return polyline;
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index 5f0d9fda..a722fd1a 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -19,7 +19,6 @@
  * Author: Dario Di Nucci <linkin88mail gmail com>
  */
 
-import Clutter from 'gi://Clutter';
 import Gdk from 'gi://Gdk';
 import GObject from 'gi://GObject';
 
@@ -102,7 +101,6 @@ export class TurnPointMarker extends MapMarker {
         let latitude = this.latitude;
         let longitude = this.longitude;
 
-        view.goto_animation_mode = Clutter.AnimationMode.LINEAR;
         view.goto_duration = 0;
 
         Utils.once(view, 'animation-completed', () => {
diff --git a/src/userLocationMarker.js b/src/userLocationMarker.js
index 55d9d85f..8672a0f0 100644
--- a/src/userLocationMarker.js
+++ b/src/userLocationMarker.js
@@ -19,25 +19,27 @@
  * Author: Damián Nohales <damiannohales gmail com>
  */
 
-import Champlain from 'gi://Champlain';
-import Clutter from 'gi://Clutter';
 import GObject from 'gi://GObject';
+import Shumate from 'gi://Shumate';
 
 import {MapMarker} from './mapMarker.js';
 
-export class AccuracyCircleMarker extends Champlain.Point {
+export class AccuracyCircleMarker extends Shumate.Point {
 
     constructor(params) {
         let place = params.place;
         delete params.place;
 
+        // TODO: set color using CSS...
+        /*
         params.color = new Clutter.Color({ red: 0,
                                            blue: 255,
                                            green: 0,
                                            alpha: 25 });
+        */
         params.latitude = place.location.latitude;
         params.longitude = place.location.longitude;
-        params.reactive = false;
+        params.draggable = false;
 
         super(params);
 
@@ -101,11 +103,6 @@ export class UserLocationMarker extends MapMarker {
     }
 
     _updateLocation() {
-        if (this._actor) {
-            this._actor.destroy();
-            delete this._actor;
-        }
-
         if (this.place.location.heading > -1) {
             this._actor = this._actorFromIconName('user-location-compass', 0);
             this._actor.set_pivot_point(0.5, 0.5);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]