From e7fc16f9bfda243b6a40aa39ae1234e9779bf7f9 Mon Sep 17 00:00:00 2001 From: Carlos Suárez Date: Feb 25 2024 19:26:21 +0000 Subject: New maps view --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc3c5d9..f3c9f93 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,8 +11,8 @@ stages: variables: METEO_REPO: "https://gitlab.com/bitseater/meteo.git" - DEPENS: "build-essential git meson ninja-build valac desktop-file-utils gettext libgtk-4-dev libadwaita-1-dev libsoup-3.0-dev libjson-glib-dev libshumate-dev" - DEPENS_RPM: "@development-tools fedora-packager rpmdevtools git gcc wget meson ninja-build vala vala-devel gtk4-devel libadwaita-devel libsoup-devel json-glib-devel libshumate-devel libappstream-glib" + DEPENS: "build-essential git meson ninja-build valac desktop-file-utils gettext libgtk-4-dev libadwaita-1-dev libsoup-3.0-dev libjson-glib-dev libwebkit2gtk-4.0-dev" + DEPENS_RPM: "@development-tools fedora-packager rpmdevtools git gcc wget meson ninja-build vala vala-devel gtk4-devel libadwaita-devel libsoup-devel json-glib-devel libwebkit2gtk-devel libappstream-glib" .build_template: &build_definition stage: build diff --git a/debian/control b/debian/control index bd65fee..54c631a 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Build-Depends: debhelper (>= 11), libsoup3-dev, libjson-glib-dev, libadwaita-1, - libshumate-dev + libwebkit2gtk-dev, Standards-Version: 4.4.0 Package: com.gitlab.bitseater.meteo diff --git a/meson.build b/meson.build index 77d146e..89d9068 100644 --- a/meson.build +++ b/meson.build @@ -36,9 +36,8 @@ gobj_dep = dependency('gobject-2.0') gtk_dep = dependency('gtk4') soup_dep = dependency('libsoup-3.0') json_dep = dependency('json-glib-1.0') -#webk_dep = dependency('webkit2gtk-4.0') +webk_dep = dependency('webkitgtk-6.0') adw_dep = dependency('libadwaita-1') -shu_dep = dependency('shumate-1.0') dependencies = [ gio_dep, @@ -48,8 +47,7 @@ dependencies = [ adw_dep, soup_dep, json_dep, - shu_dep, -# webk_dep + webk_dep ] # Arguments C - no gcc warnings @@ -79,7 +77,6 @@ executable( 'src/Widgets/Cities.vala', 'src/Widgets/Today.vala', 'src/Widgets/Forecast.vala', - 'src/Widgets/Maplayer.vala', 'src/Widgets/Mapview.vala', 'src/Utils/OWM_Today.vala', 'src/Utils/Utils.vala', diff --git a/po/es.mo b/po/es.mo deleted file mode 100644 index 8a86829..0000000 Binary files a/po/es.mo and /dev/null differ diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 81c3f41..3331d91 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -86,8 +86,6 @@ namespace Meteo { overlay.set_child (splitview); overlay.show (); if (setting.get_value ("actual").n_children () != 0) { - var mapview = new Meteo.Widgets.Mapview (this); - stack.add_named (mapview, "mapview"); var today = new Meteo.Widgets.Today (this); stack.add_titled_with_icon (today, "today", "Today", "document-open-recent-symbolic"); var forecast = new Meteo.Widgets.Forecast (this); @@ -109,7 +107,23 @@ namespace Meteo { mapbutton.add_css_class ("circular"); header.pack_start (mapbutton); mapbutton.clicked.connect (() => { - stack.visible_child_name = "mapview"; + //Open window with maps + var mapwin = new Adw.Window (); + mapwin.default_height = this.get_height () - 25; + mapwin.default_width = this.get_width () - 25; + mapwin.transient_for = this; + mapwin.modal = true; + mapwin.destroy_with_parent = true; + mapwin.hide_on_close = true; + var mapbar = new Adw.HeaderBar (); + mapbar.show_end_title_buttons = true; + mapbar.title_widget = new Adw.WindowTitle ("Meteo Map", ""); + var child = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + child.append (mapbar); + var mapview = new Meteo.Widgets.Mapview (this); + child.append (mapview); + mapwin.content = child; + mapwin.show (); }); var cities = new Meteo.Widgets.Cities (this); splitview.sidebar = cities; @@ -123,7 +137,7 @@ namespace Meteo { //Construct var condition = new Adw.BreakpointCondition.length ( Adw.BreakpointConditionLengthType.MAX_WIDTH, - 360, Adw.LengthUnit.SP + 361, Adw.LengthUnit.SP ); breakpoint = new Adw.Breakpoint (condition); breakpoint.add_setter (header, "title-widget", new Gtk.Label ("")); diff --git a/src/Widgets/Maplayer.vala b/src/Widgets/Maplayer.vala deleted file mode 100644 index e176a67..0000000 --- a/src/Widgets/Maplayer.vala +++ /dev/null @@ -1,90 +0,0 @@ -/* -* Copyright (c) Carlos Suárez (https://gitlab.com/bitseater) -* -* This program 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 3 of the License, or (at your option) any later version. -* -* This program 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 this program; If not, see . -* -* Authored by: Carlos Suárez -*/ -namespace Meteo.Widgets { - - public class Maplayer : Gtk.Box { - - // SPAIN - Real Observatorio de la Armada - private double DEFAULT_LATITUDE = 36.4616666666; - private double DEFAULT_LONGITUDE = -6.2055555555; - private double DEFAULT_ZOOM_LEVEL = 7; - - struct Mycity { - double lat; - double lon; - string country; - string state; - string name; - } - - public Maplayer (string url_layer, string url_map) { - orientation = Gtk.Orientation.VERTICAL; - - var setting = new Settings ("com.gitlab.bitseater.meteo"); - var city = Mycity (); - setting.get_value ("actual").get_child_value (0).@get ("(ddsss)", - out city.lat, - out city.lon, - out city.name, - out city.state, - out city.country); - if ((city.lat != 0) | (city.lon != 0)){ - DEFAULT_LATITUDE = city.lat; - DEFAULT_LONGITUDE = city.lon; - }; - - var renderer = new Shumate.RasterRenderer.from_url (url_layer) { - name = "OpenWeatherMap", - id = "OWM", - license = "© OpenWeatherMap", - license_uri = "http://openweathermap.org/terms", - min_zoom_level = 3, - max_zoom_level = 14, - tile_size = 100, - projection = Shumate.MapProjection.MERCATOR - }; - var layerer = new Shumate.RasterRenderer.from_url (url_map) { - name = "OpenStreetMap", - id = "OSM", - license = "© OpenStreetMap", - license_uri = "http://www.openstreetmap.org/copyright", - min_zoom_level = 2, - max_zoom_level = 9, - tile_size = 100, - projection = Shumate.MapProjection.MERCATOR - }; - var registry = new Shumate.MapSourceRegistry.with_defaults (); - registry.add (renderer); - - var mapsimple = new Shumate.SimpleMap () { - map_source = renderer, - show_zoom_buttons = true, - vexpand = true, - hexpand = true - }; - var layer = new Shumate.MapLayer (layerer, mapsimple.get_map ().get_viewport ()); - mapsimple.get_map ().add_layer(layer); - - var map = new Shumate.Map (); - map = mapsimple.map; - map.go_to_full (DEFAULT_LATITUDE, DEFAULT_LONGITUDE, DEFAULT_ZOOM_LEVEL); - append (mapsimple); - } - } -} \ No newline at end of file diff --git a/src/Widgets/Mapview.vala b/src/Widgets/Mapview.vala index f80d4d4..7a152ec 100644 --- a/src/Widgets/Mapview.vala +++ b/src/Widgets/Mapview.vala @@ -20,33 +20,49 @@ namespace Meteo.Widgets { public class Mapview : Gtk.Box { - public Mapview (MainWindow window) { - orientation = Gtk.Orientation.VERTICAL; - var showmap = new Gtk.Stack (); - showmap.transition_type = Gtk.StackTransitionType.CROSSFADE; - showmap.transition_duration = 1000; - showmap.hhomogeneous = true; - var switchmap = new Gtk.StackSwitcher (); - switchmap.stack = showmap; - - var setting = new Settings ("com.gitlab.bitseater.meteo"); - string apiid = setting.get_string ("apiid"); - string url_layer = "https://tile.openstreetmap.org/{z}/{x}/{y}.png"; - string url_press = "https://tile.openweathermap.org/map/pressure_new/{z}/{x}/{y}.png?appid=" + apiid; - string url_temp = "https://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid=" + apiid; - string url_wind = "https://tile.openweathermap.org/map/wind_new/{z}/{x}/{y}.png?appid=" + apiid; - string url_prec = "https://tile.openweathermap.org/map/precipitation_new/{z}/{x}/{y}.png?appid=" + apiid; - string url_cloud = "https://tile.openweathermap.org/map/clouds_new/{z}/{x}/{y}.png?appid=" + apiid; + struct Mycity { + double lat; + double lon; + string country; + string state; + string name; + } - showmap.add_titled (new Meteo.Widgets.Maplayer (url_layer, url_temp), "TEMP", _("Temperature")); - showmap.add_titled (new Meteo.Widgets.Maplayer (url_layer, url_cloud), "CLOU", _("Clouds")); - showmap.add_titled (new Meteo.Widgets.Maplayer (url_layer, url_prec), "PREC", _("Precipitation")); - showmap.add_titled (new Meteo.Widgets.Maplayer (url_layer, url_press), "PRES", _("Pressure")); - showmap.add_titled (new Meteo.Widgets.Maplayer (url_layer, url_wind), "WSPE", _("Wind Speed")); - showmap.visible_child_name = "TEMP"; + string plab; + string pslab; + string rlab; + string tlab; + string wlab; + string p36; + string pau; - prepend (switchmap); - append (showmap); + public Mapview (MainWindow window) { + var setting = new Settings ("com.gitlab.bitseater.meteo"); + var city = Mycity (); + setting.get_value ("actual").get_child_value (0).@get ("(ddsss)", + out city.lat, + out city.lon, + out city.name, + out city.state, + out city.country); + plab = _("Precipitation"); + pslab = _("Pressure"); + rlab = _("Radar"); + tlab = _("Temperature"); + wlab = _("Wind"); + p36 = _("Play 3600x"); + pau = _("Pause"); + string config = "?plab=" + plab + "&pslab=" + pslab + "&rlab=" + rlab + "&tlab=" +tlab + "&wlab=" + wlab + "&p36=" + p36 + "&pau=" + pau; + string endurl = "#5/" + Meteo.Utils.db_to_str(city.lat) + "/" + Meteo.Utils.db_to_str(city.lon); + string url = "https://bitseater.gitlab.io/meteomap/meteomap.html" + config + endurl; + print (url); + var map_view = new WebKit.WebView (); + map_view.halign = Gtk.Align.FILL; + map_view.valign = Gtk.Align.FILL; + map_view.load_uri (url); + map_view.hexpand = true; + map_view.vexpand = true; + append (map_view); } } } \ No newline at end of file