Skip to content

Commit 624a1fe

Browse files
committed
refactor: rework bootstrapper window visibility
1 parent e3e047e commit 624a1fe

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

cmd/vinegar/bootstrapper.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ func (b *bootstrapper) message(msg string, args ...any) {
7676
}
7777

7878
func (b *bootstrapper) run(args ...string) error {
79+
gtkutil.IdleAdd(func() {
80+
b.app.AddWindow(&b.win.Window)
81+
b.win.Present()
82+
})
83+
defer gtkutil.IdleAdd(func() {
84+
b.app.RemoveWindow(&b.win.Window)
85+
b.win.SetVisible(false) // Incase bailed out
86+
})
87+
7988
if err := b.setup(); err != nil {
8089
return fmt.Errorf("setup: %w", err)
8190
}

cmd/vinegar/bootstrapper_setup.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ func (b *bootstrapper) setup() error {
2222
return nil
2323
}
2424

25-
gtkutil.IdleAdd(func() {
26-
b.app.AddWindow(&b.win.Window)
27-
b.win.Present()
28-
})
29-
3025
pfxFirstRun := !b.pfx.Exists()
3126

3227
if err := b.setupPrefix(); err != nil {

cmd/vinegar/manager_actions.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ func (m *manager) run() error {
3939
defer show()
4040

4141
if m.pfx.Exists() && len(m.boot.procs) == 0 {
42-
if err := m.app.boot.setup(); err != nil {
43-
return fmt.Errorf("setup: %w", err)
42+
visible := func() {
43+
if !m.boot.win.GetVisible() {
44+
show()
45+
}
4446
}
45-
46-
// When command is finally executed
47-
h := m.app.boot.win.ConnectSignal("notify::visible", &show)
47+
h := m.app.boot.win.ConnectSignal("notify::visible", &visible)
4848
defer func() { m.app.boot.win.DisconnectSignal(h) }()
4949
return m.app.boot.run()
5050
}

0 commit comments

Comments
 (0)