[gnome-maps/wip/gtk4-and-libshumate] WIP: Port to GTK 4 and libshumate
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/gtk4-and-libshumate] WIP: Port to GTK 4 and libshumate
- Date: Sat, 23 Jul 2022 21:35:19 +0000 (UTC)
commit 8b6fa9bb232203e8e24f9cca56198d1bd3c80836
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/meson.build | 4 +-
meson.build | 6 +-
org.gnome.Maps.json | 47 ++-----
src/application.js | 10 +-
src/contextMenu.js | 2 +-
src/epaf.js | 4 +-
src/geoJSONSource.js | 13 +-
src/graphHopperTransit.js | 10 +-
src/layersPopover.js | 4 +-
src/main.js | 12 +-
src/mainWindow.js | 2 +-
src/mapMarker.js | 3 +-
src/mapSource.js | 2 +-
src/mapView.js | 84 ++++++-------
src/placeViewImage.js | 19 ++-
src/storedRoute.js | 10 +-
18 files changed, 224 insertions(+), 305 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/meson.build b/lib/meson.build
index 8de63691..67df8459 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -47,8 +47,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..2cac7568 100644
--- a/src/geoJSONSource.js
+++ b/src/geoJSONSource.js
@@ -19,10 +19,9 @@
*/
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 {BoundingBox} from './boundingBox.js';
import * as Geojsonvt from './geojsonvt/geojsonvt.js';
@@ -38,7 +37,7 @@ const TileFeature = { POINT: 1,
LINESTRING: 2,
POLYGON: 3 };
-export class GeoJSONSource extends Champlain.TileSource {
+export class GeoJSONSource extends Shumate.MapSource {
constructor(params) {
super();
@@ -65,14 +64,6 @@ export class GeoJSONSource extends Champlain.TileSource {
return 0;
}
- vfunc_get_id() {
- return 'GeoJSONSource';
- }
-
- vfunc_get_name() {
- return 'GeoJSONSource';
- }
-
vfunc_fill_tile(tile) {
if (tile.get_state() === Champlain.State.DONE)
return;
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/mapMarker.js b/src/mapMarker.js
index 8e3842cc..bd54881a 100644
--- a/src/mapMarker.js
+++ b/src/mapMarker.js
@@ -20,12 +20,11 @@
*/
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';
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/placeViewImage.js b/src/placeViewImage.js
index 44670d59..abf5b2a6 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,18 @@ 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, ) {
+
+ }
+ /*
vfunc_get_preferred_height_for_width(width) {
if (this._pixbuf) {
let height = (this._pixbuf.height / this._pixbuf.width) * width;
@@ -97,6 +109,7 @@ export class PlaceViewImage extends Gtk.DrawingArea {
return [0, 0];
}
}
+ */
}
GObject.registerClass(PlaceViewImage);
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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]