Skip to content

Commit

Permalink
fix: open signal while already open (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr authored Nov 21, 2022
1 parent c8af2e5 commit b679d22
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit b679d22

Please sign in to comment.