Compare commits

...

2 Commits

8 changed files with 119 additions and 5 deletions

23
Makefile Normal file
View File

@@ -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

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="27.495001mm"
height="27.494635mm"
viewBox="0 0 27.495001 27.494636"
version="1.1"
id="svg5"
xml:space="preserve"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs2"><linearGradient
id="linearGradient1299"><stop
style="stop-color:#ff2323;stop-opacity:1;"
offset="0"
id="stop1295" /><stop
style="stop-color:#ca5aaa;stop-opacity:1;"
offset="1"
id="stop1297" /></linearGradient><linearGradient
xlink:href="#linearGradient1299"
id="linearGradient1301"
x1="10.067801"
y1="22.259319"
x2="24.352367"
y2="22.259319"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-1.5278011,-6.6120943)" /></defs><g
id="layer1"
transform="translate(-1.9349249,-1.8999069)"><circle
style="fill:#2f2d39;fill-opacity:1;stroke:#272730;stroke-width:1.4;stroke-dasharray:none;stroke-opacity:1"
id="path507"
cx="15.682425"
cy="15.647223"
r="11.547338" /><path
id="path3470"
style="fill:url(#linearGradient1301);fill-opacity:1;stroke-width:0.264583"
d="m 18.39274,9.0775417 a 4.431921,4.431921 0 0 0 -4.43228,4.4317693 4.431921,4.431921 0 0 0 0.31264,1.632976 l -5.4518611,4.655529 c -0.33702,0.287828 -0.37671,0.791079 -0.0889,1.128097 l 0.86248,1.009757 c 0.28782,0.337018 0.7910701,0.376712 1.1280901,0.08888 l 5.463231,-4.665865 c 0.002,-0.0014 0.003,-0.0028 0.005,-0.0041 a 4.431921,4.431921 0 0 0 2.20194,0.586527 4.431921,4.431921 0 0 0 4.43177,-4.431771 4.431921,4.431921 0 0 0 -4.43177,-4.4317693 z m -0.0109,1.6903363 a 2.8280926,2.8280926 0 0 1 2.82826,2.827733 2.8280926,2.8280926 0 0 1 -2.82826,2.828251 2.8280926,2.8280926 0 0 1 -2.82773,-2.828251 2.8280926,2.8280926 0 0 1 2.82773,-2.827733 z" /></g></svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -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;

View File

@@ -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;

View File

@@ -9,10 +9,9 @@ targets:
main: src/wince.cr
dependencies:
gtk4:
github: hugopl/gtk4.cr
libadwaita:
github: GeopJr/libadwaita.cr
branch: main
crystal: 1.6.2

View File

@@ -1,10 +1,10 @@
module Wince::Location
extend self
client = Geoclue::Simple.new()
@@client = Geoclue::Simple.new_sync("space.quietfeathers.Wince", Geoclue::AccuracyLevel::Street, nil)
def find_location()
location = client.location
location = @@client.location
[location.latitude, location.longitude]
end
end

View File

@@ -3,6 +3,7 @@ require "time"
require "../templates/businessrow.cr"
require "../templates/hourrow.cr"
require "../api/location.cr"
require "../api/yelp.cr"
require "../utils/utils.cr"
@@ -11,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)
@@ -38,11 +40,29 @@ 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
puts "no, not yet"
latlon = Location.find_location()
LOCATION_ENTRY.text = "#{latlon[0]}, #{latlon[1]}"
end
def yelp_response_to_business_ids(response : JSON::Any)
@@ -132,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
@@ -143,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")

View File

@@ -1,4 +1,6 @@
require "libadwaita"
require "../lib/libadwaita/lib/gi-crystal/src/auto/geoclue-2.0/*"
require "../lib/libadwaita/lib/gi-crystal/src/auto/shumate-1.0/*"
require "./modules/prerequisites.cr"
require "./modules/views/main.cr"
@@ -25,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