-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_window.glimmer.rb
111 lines (94 loc) · 3.19 KB
/
main_window.glimmer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
title "Passwords of #{Account.password_store.gpg_id}"
iconphoto Glimte.asset_path('fontawesome/appicon.png').to_s
width 1024
height 1024 / 1.618 # why not? :)
centered true
@flash = Views.shared_components.flash_message {
grid row: rows.next, row_weight: 0
}
@toolbar = Views.main_window_components.toolbar {
grid row: rows.next, row_weight: 0
padding 5
}
frame {
grid row: rows.next, row_weight: 1
padding 0
@accounts_list = Views.main_window_components.accounts_list {
grid row: 0, column: 0, row_weight: 1, column_weight: 1, column_uniform: 'accounts_list_and_view'
width 0
padding 5, 0, 5, 5
}
frame {
grid row: 0, column: 1, row_weight: 0, column_weight: 1, column_uniform: 'accounts_list_and_view'
width 0
padding 20, 20, 5, 5
@domain_view = Views.main_window_components.domain_view {
grid row: 0, column: 0, row_weight: 1
padding 0
visible <= [@accounts_list.view_model, :selection_is_account, '<=': -> (v) { v.nil? ? false : !v }]
}
@account_view = Views.main_window_components.account_view {
grid row: 0, column: 0
padding 0
visible <= [@accounts_list.view_model, :selection_is_account, '<=': -> (v) { v.nil? ? false : v }]
}
}
}
on 'FlashSuccessRequest',
'FlashInfoRequest',
'FlashAlertRequest',
'FlashExceptionAlertRequest',
redirect_to: @flash
on 'AccountsListReloadRequest',
'SearchEntryKeyUp',
'SearchEntryKeyDown',
'SearchStringChange',
redirect_to: @accounts_list
on('AccountsListSelect') do
@toolbar.raise_event 'SearchStringFocusRequest'
end
on 'AccountsListSelect', redirect_to: -> (_) { if @accounts_list.view_model.selection_is_account?
@account_view
else
@domain_view
end }
# TODO: it breaks the DeleteAccount entry focus. Better way to keep focus on the search entry?
# on('FocusIn') { @toolbar.raise_event('SearchStringFocusRequest') }
on('AddAccountWindowRequest') do
Views.add_account_window
end
on('KeyPress') do |event|
# event_proxy = EventProxy.new(event)
# event_proxy.ctrl? && event_proxy.keysym?('a')
# event_proxy.keypress?('ctrl a')
case [event.keysym.downcase, event.state]
when ['up', 0]
@accounts_list.raise_event('AccountsListPrevItemRequest')
when ['down', 0]
@accounts_list.raise_event('AccountsListNextItemRequest')
when ['escape', 0]
@toolbar.raise_event('SearchStringClearRequest')
when ['c', 4], ['insert', 4]
@account_view.raise_event('CopyPasswordRequest') if @account_view.visible?
when ['b', 4]
@account_view.raise_event('CopyAccountNameRequest') if @account_view.visible?
when ['d', 4]
if @domain_view.visible?
@domain_view.raise_event('CopyDomainNameRequest')
else
@account_view.raise_event('CopyDomainNameRequest')
end
when ['n', 4]
Views.add_account_window
when ['e', 4]
# edit account
when ['delete', 0]
if @domain_view.visible?
@domain_view.raise_event('DeleteDomainRequest')
else
@account_view.raise_event('DeleteAccountRequest')
end
when ['q', 4]
Glimte.exit
end
end