From cae4e512f50315280039ca549a7d4d2d649ea1e7 Mon Sep 17 00:00:00 2001 From: Zoe Moore Date: Fri, 23 Dec 2022 23:00:00 -0800 Subject: [PATCH] Added icon and makefile --- Makefile | 23 +++++++++++++++ data/img/space.quietfeathers.wince.svg | 39 ++++++++++++++++++++++++++ data/space.quietfeathers.wince.desktop | 9 ++++++ data/ui/main.blp | 8 ++++++ src/modules/views/main.cr | 31 ++++++++++++++++++++ src/wince.cr | 1 + 6 files changed, 111 insertions(+) create mode 100644 Makefile create mode 100644 data/img/space.quietfeathers.wince.svg create mode 100644 data/space.quietfeathers.wince.desktop diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dcde2a8 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +.PHONY: all install uninstall build +PREFIX ?= /usr + +all: bindings build + +bindings: + shards install + ./bin/gi-crystal + +build: + shards build -Dpreview_mt --release --no-debug + +install: + install -D -m 0755 bin/wince $(PREFIX)/bin/wince + install -D -m 0644 data/space.quietfeathers.wince.desktop $(PREFIX)/share/applications/space.quietfeathers.wince.desktop + install -D -m 0644 data/img/space.quietfeathers.wince.svg $(PREFIX)/share/icons/hicolor/scalable/apps/space.quietfeathers.wince.svg + gtk-update-icon-cache /usr/share/icons/hicolor + +uninstall: + rm -f $(PREFIX)/bin/wince + rm -f $(PREFIX)/share/applications/space.quietfeathers.wince.desktop + rm -f $(PREFIX)/share/icons/hicolor/scalable/apps/space.quietfeathers.wince.svg + gtk-update-icon-cache /usr/share/icons/hicolor diff --git a/data/img/space.quietfeathers.wince.svg b/data/img/space.quietfeathers.wince.svg new file mode 100644 index 0000000..0cefbd0 --- /dev/null +++ b/data/img/space.quietfeathers.wince.svg @@ -0,0 +1,39 @@ + + + + diff --git a/data/space.quietfeathers.wince.desktop b/data/space.quietfeathers.wince.desktop new file mode 100644 index 0000000..e12fadf --- /dev/null +++ b/data/space.quietfeathers.wince.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +StartupWMClass=wince +Exec=wince %F +Name=wince +Comment=Search businesses and restaurants +Terminal=false +Icon=space.quietfeathers.wince +Categories=Utility; diff --git a/data/ui/main.blp b/data/ui/main.blp index 46ae1e9..baf208b 100644 --- a/data/ui/main.blp +++ b/data/ui/main.blp @@ -130,6 +130,14 @@ Adw.ApplicationWindow mainWindow { } } + Shumate.SimpleMap detailsMap { + margin-top: 8; + margin-start: 8; + margin-end: 8; + height-request: 220; + show-zoom-buttons: false; + } + Gtk.Label { styles ["heading"] halign: start; diff --git a/src/modules/views/main.cr b/src/modules/views/main.cr index 80d07e5..7670b52 100644 --- a/src/modules/views/main.cr +++ b/src/modules/views/main.cr @@ -12,6 +12,7 @@ module Wince @@business_rows = [] of BusinessRow @@hour_rows = [] of HourRow @@business_ids = [] of String + @@marker = nil def activate(app : Adw::Application) main_window = APP.window_by_id(@@main_window_id) @@ -39,9 +40,26 @@ module Wince handle_business_select end + setup_map + window.present end + def setup_map + DETAILS_MAP.map_source = Shumate::MapSourceRegistry + .new_with_defaults().by_id(Shumate::MAP_SOURCE_OSM_MAPNIK) + + icon = Gtk::Image.new_from_icon_name("view-pin-symbolic") + @@marker = Shumate::Marker.new + + @@marker.try do|m| + m.child = icon + marker_layer = Shumate::MarkerLayer.new(DETAILS_MAP.viewport) + marker_layer.add_marker(m) + DETAILS_MAP.add_overlay_layer(marker_layer) + end + end + def handle_geolocate latlon = Location.find_location() LOCATION_ENTRY.text = "#{latlon[0]}, #{latlon[1]}" @@ -134,6 +152,8 @@ module Wince @@hour_rows = format_hours(response_json["hours"]) @@hour_rows.each { |hour_row| DETAILS_HOURS_BOX.append(hour_row) } + set_map_location(response_json["coordinates"]) + # If we're in the small layout we want to show the back button if LEAFLET.folded DETAILS_BACK.visible = true @@ -145,6 +165,17 @@ module Wince LEAFLET.visible_child = DETAILS_SCROLL end + def set_map_location(coordinates : JSON::Any) + latitude = coordinates["latitude"].as_f + longitude = coordinates["longitude"].as_f + + viewport = DETAILS_MAP.viewport + viewport.set_location(latitude, longitude) + viewport.zoom_level = 14 + + @@marker.try {|m| m.set_location(latitude, longitude) } + end + def format_hours(hours_json : JSON::Any) Time::DayOfWeek.values.map do |day| hours = Utils.hours_for_day(hours_json, day, "\n") diff --git a/src/wince.cr b/src/wince.cr index 38a2e73..0abd5f4 100644 --- a/src/wince.cr +++ b/src/wince.cr @@ -27,6 +27,7 @@ module Wince DETAILS_URL = Gtk::LinkButton.cast(B_UI["detailsUrl"]) DETAILS_BACK = Gtk::Button.cast(B_UI["detailsBack"]) DETAILS_HOURS_BOX = Gtk::ListBox.cast(B_UI["detailsHoursBox"]) + DETAILS_MAP = Shumate::SimpleMap.cast(B_UI["detailsMap"]) APP = Adw::Application.new("dev.wince", Gio::ApplicationFlags::None) end