Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: open signal while already open #124

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/collision/views/main.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Collision
@@main_window_id = 0_u32
@@activated = false

def activate(app : Adw::Application)
# Put window on focus if already exists.
Expand Down Expand Up @@ -62,6 +63,7 @@ module Collision

window.content = WINDOW_BOX
window.present
@@activated = true

LOGGER.debug { "Window activated" }
LOGGER.debug { "Settings: #{window_settings}" }
Expand Down Expand Up @@ -103,10 +105,10 @@ module Collision
# it sets the first one (since multiple can be passed)
# as the Collision::Welcomer's file.
def open_with(app : Adw::Application, files : Enumerable(Gio::File), hint : String)
activate(app)
activate(app) unless @@activated

if files.size > 0 && Collision.file?(files[0].path.not_nil!, false)
Collision::Welcomer.file = files[0]
(Collision::Welcomer.passed? ? Collision : Collision::Welcomer).file = files[0]
end

nil
Expand Down