Compare commits
2 Commits
cae4e512f5
...
7833d6fa57
| Author | SHA1 | Date | |
|---|---|---|---|
| 7833d6fa57 | |||
| 52ccf6d080 |
@@ -18,8 +18,8 @@ Then you can run the program with
|
||||
crystal run src/gtktest.cr
|
||||
```
|
||||
|
||||
You can build for production with
|
||||
You can build for production with `make` and install with `make install`
|
||||
|
||||
```
|
||||
shards build -Dpreview_mt --release --no-debug
|
||||
```
|
||||
## Credits
|
||||
|
||||
Marker icon from [Paomedia on iconfinder](https://www.iconfinder.com/icons/299087/marker_map_icon)
|
||||
BIN
data/img/marker-icon.png
Normal file
BIN
data/img/marker-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
@@ -78,6 +78,7 @@ Adw.ApplicationWindow mainWindow {
|
||||
|
||||
Gtk.Label detailsTitle {
|
||||
halign: start;
|
||||
wrap: true;
|
||||
styles ["title-1"]
|
||||
}
|
||||
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/compiled/main.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/compiled/templates/businessrow.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">ui/compiled/templates/hourrow.ui</file>
|
||||
<file compressed="true">img/marker-icon.png</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
module Wince::Location
|
||||
extend self
|
||||
|
||||
@@client = Geoclue::Simple.new_sync("space.quietfeathers.Wince", Geoclue::AccuracyLevel::Street, nil)
|
||||
@@channel = Channel(Geoclue::Simple).new(1)
|
||||
@@client : Geoclue::Simple? = nil
|
||||
@@fiber : Fiber = spawn setup_client
|
||||
|
||||
def find_location()
|
||||
location = @@client.location
|
||||
[location.latitude, location.longitude]
|
||||
def setup_client
|
||||
@@channel.send Geoclue::Simple.new_sync("space.quietfeathers.Wince", Geoclue::AccuracyLevel::Street, nil)
|
||||
Fiber.yield
|
||||
end
|
||||
|
||||
# returns latlon if available, otherwise empty array
|
||||
def find_location
|
||||
if !@@fiber.dead?
|
||||
return [] of Float64
|
||||
end
|
||||
|
||||
if @@client.nil?
|
||||
@@client = @@channel.receive
|
||||
end
|
||||
|
||||
location = @@client.try do |c|
|
||||
[c.location.latitude, c.location.longitude]
|
||||
end || [] of Float64
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,10 +49,13 @@ module Wince
|
||||
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")
|
||||
pixbuf = GdkPixbuf::Pixbuf.new_from_resource("/wince/img/marker-icon.png")
|
||||
icon = Gtk::Image.new_from_pixbuf(pixbuf)
|
||||
@@marker = Shumate::Marker.new
|
||||
|
||||
@@marker.try do|m|
|
||||
m.height_request = 64
|
||||
m.width_request = 64
|
||||
m.child = icon
|
||||
marker_layer = Shumate::MarkerLayer.new(DETAILS_MAP.viewport)
|
||||
marker_layer.add_marker(m)
|
||||
@@ -62,7 +65,10 @@ module Wince
|
||||
|
||||
def handle_geolocate
|
||||
latlon = Location.find_location()
|
||||
LOCATION_ENTRY.text = "#{latlon[0]}, #{latlon[1]}"
|
||||
|
||||
if !latlon.empty?
|
||||
LOCATION_ENTRY.text = "#{latlon[0]}, #{latlon[1]}"
|
||||
end
|
||||
end
|
||||
|
||||
def yelp_response_to_business_ids(response : JSON::Any)
|
||||
@@ -171,7 +177,7 @@ module Wince
|
||||
|
||||
viewport = DETAILS_MAP.viewport
|
||||
viewport.set_location(latitude, longitude)
|
||||
viewport.zoom_level = 14
|
||||
viewport.zoom_level = 16
|
||||
|
||||
@@marker.try {|m| m.set_location(latitude, longitude) }
|
||||
end
|
||||
|
||||
@@ -29,5 +29,5 @@ module Wince
|
||||
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)
|
||||
APP = Adw::Application.new("space.quietfeathers.wince", Gio::ApplicationFlags::None)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user