… | |
… | |
2 | |
2 | |
3 | use strict; |
3 | use strict; |
4 | |
4 | |
5 | use CFPlus::UI; |
5 | use CFPlus::UI; |
6 | |
6 | |
7 | our @ISA = CFPlus::UI::FancyFrame::; |
7 | our @ISA = CFPlus::UI::Toplevel::; |
8 | |
8 | |
9 | my @ALLOWED_MODIFIER_KEYS = ( |
9 | my @ALLOWED_MODIFIER_KEYS = ( |
10 | CFPlus::SDLK_LSHIFT, |
10 | CFPlus::SDLK_LSHIFT, |
11 | CFPlus::SDLK_LCTRL , |
11 | CFPlus::SDLK_LCTRL , |
12 | CFPlus::SDLK_LALT , |
12 | CFPlus::SDLK_LALT , |
… | |
… | |
129 | $self |
129 | $self |
130 | } |
130 | } |
131 | |
131 | |
132 | sub cfg_bind { |
132 | sub cfg_bind { |
133 | my ($self, $mod, $sym, $cmds) = @_; |
133 | my ($self, $mod, $sym, $cmds) = @_; |
134 | $::CFG->{profile}{default}{bindings}{$mod}{$sym} = $cmds; |
134 | $::PROFILE->{bindings}{$mod}{$sym} = $cmds; |
135 | ::update_bindings (); |
135 | ::update_bindings (); |
136 | } |
136 | } |
137 | |
137 | |
138 | sub cfg_unbind { |
138 | sub cfg_unbind { |
139 | my ($self, $mod, $sym, $cmds) = @_; |
139 | my ($self, $mod, $sym, $cmds) = @_; |
140 | delete $::CFG->{profile}{default}{bindings}{$mod}{$sym}; |
140 | delete $::PROFILE->{bindings}{$mod}{$sym}; |
141 | ::update_bindings (); |
141 | ::update_bindings (); |
142 | } |
142 | } |
143 | |
143 | |
144 | sub commit { |
144 | sub commit { |
145 | my ($self) = @_; |
145 | my ($self) = @_; |
… | |
… | |
184 | |
184 | |
185 | return if $self->{binder}; |
185 | return if $self->{binder}; |
186 | |
186 | |
187 | Scalar::Util::weaken $self; |
187 | Scalar::Util::weaken $self; |
188 | |
188 | |
189 | $self->{binder} = new CFPlus::UI::FancyFrame |
189 | $self->{binder} = new CFPlus::UI::Toplevel |
190 | title => "Bind Action", |
190 | title => "Bind Action", |
191 | x => "center", |
191 | x => "center", |
192 | y => "center", |
192 | y => "center", |
193 | z => 1000, |
193 | z => 1000, |
194 | has_close_button => 1, |
194 | has_close_button => 1, |
… | |
… | |
230 | $self->{binding} = [$mod, $sym]; |
230 | $self->{binding} = [$mod, $sym]; |
231 | $self->update_binding_widgets; |
231 | $self->update_binding_widgets; |
232 | $self->commit if $commit; |
232 | $self->commit if $commit; |
233 | $end_cb->() if $end_cb; |
233 | $end_cb->() if $end_cb; |
234 | |
234 | |
|
|
235 | if (my $binder = delete $self->{binder}) { |
235 | (delete $self->{binder})->destroy; |
236 | $binder->destroy; |
|
|
237 | } |
236 | 1 |
238 | 1 |
237 | }, |
239 | }, |
238 | on_focus_out => sub { |
240 | on_focus_out => sub { |
239 | # segfaults and worse :() |
241 | # segfaults and worse :() |
240 | #(delete $self->{binder})->destroy if $self->{binder}; |
242 | #(delete $self->{binder})->destroy if $self->{binder}; |