Compare commits
1 Commits
fix-geoclu
...
bbc2cc5733
| Author | SHA1 | Date | |
|---|---|---|---|
| bbc2cc5733 |
@@ -1,13 +1,13 @@
|
|||||||
# NOTICE: This lockfile contains some overrides from shard.override.yml
|
# NOTICE: This lockfile contains some overrides from shard.override.yml
|
||||||
version: 2.0
|
version: 2.0
|
||||||
shards:
|
shards:
|
||||||
gi-crystal: # Overridden
|
gi-crystal:
|
||||||
git: https://github.com/hugopl/gi-crystal.git
|
git: https://github.com/hugopl/gi-crystal.git
|
||||||
version: 0.15.0+git.commit.bcf127b37c309a52f4b17566e9663029c16dcbb2
|
version: 0.14.0+git.commit.569f8d4b77effe312c642fc60929000e3e9514e2
|
||||||
|
|
||||||
gtk4: # Overridden
|
gtk4: # Overridden
|
||||||
git: https://github.com/hugopl/gtk4.cr.git
|
git: https://github.com/hugopl/gtk4.cr.git
|
||||||
version: 0.12.0+git.commit.a46b9295a7cffcc4ed2af596276c17196b2948fb
|
version: 0.12.0+git.commit.ef2eb03b38b25ea2780e83cf50af3a6807ac6293
|
||||||
|
|
||||||
libadwaita:
|
libadwaita:
|
||||||
git: https://github.com/geopjr/libadwaita.cr.git
|
git: https://github.com/geopjr/libadwaita.cr.git
|
||||||
|
|||||||
@@ -2,6 +2,3 @@ dependencies:
|
|||||||
gtk4:
|
gtk4:
|
||||||
github: hugopl/gtk4.cr
|
github: hugopl/gtk4.cr
|
||||||
branch: master
|
branch: master
|
||||||
gi-crystal:
|
|
||||||
github: hugopl/gi-crystal
|
|
||||||
branch: master
|
|
||||||
|
|||||||
@@ -1,29 +1,25 @@
|
|||||||
module Wince::Location
|
module Wince::Location
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
|
@@channel = Channel(Geoclue::Simple).new(1)
|
||||||
@@client : Geoclue::Simple? = nil
|
@@client : Geoclue::Simple? = nil
|
||||||
|
@@fiber : Fiber = spawn setup_client
|
||||||
|
|
||||||
def setup_client
|
def setup_client
|
||||||
callback = ->(object : GObject::Object | Nil, result : Gio::AsyncResult) {
|
@@channel.send Geoclue::Simple.new_sync("space.quietfeathers.Wince", Geoclue::AccuracyLevel::Street, nil)
|
||||||
@@client = Geoclue::Simple.new_finish(result)
|
Fiber.yield
|
||||||
puts "location callback"
|
|
||||||
}
|
|
||||||
|
|
||||||
Geoclue::Simple.new(
|
|
||||||
"space.quietfeathers.Wince",
|
|
||||||
Geoclue::AccuracyLevel::Street,
|
|
||||||
nil,
|
|
||||||
callback,
|
|
||||||
nil
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns latlon if available, otherwise empty array
|
# returns latlon if available, otherwise empty array
|
||||||
def find_location
|
def find_location
|
||||||
if @@client.nil?
|
if !@@fiber.dead?
|
||||||
return [] of Float64
|
return [] of Float64
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @@client.nil?
|
||||||
|
@@client = @@channel.receive
|
||||||
|
end
|
||||||
|
|
||||||
location = @@client.try do |c|
|
location = @@client.try do |c|
|
||||||
[c.location.latitude, c.location.longitude]
|
[c.location.latitude, c.location.longitude]
|
||||||
end || [] of Float64
|
end || [] of Float64
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
require "libadwaita"
|
require "libadwaita"
|
||||||
GICrystal.require("Geoclue", "2.0")
|
require "../lib/gi-crystal/src/auto/geoclue-2.0/*"
|
||||||
GICrystal.require("Shumate", "1.0")
|
require "../lib/gi-crystal/src/auto/shumate-1.0/*"
|
||||||
|
|
||||||
require "./modules/prerequisites.cr"
|
require "./modules/prerequisites.cr"
|
||||||
require "./modules/views/main.cr"
|
require "./modules/views/main.cr"
|
||||||
|
|||||||
Reference in New Issue
Block a user