Changeset 12390
- Timestamp:
- 08/29/10 09:30:52 (18 months ago)
- File:
-
- 1 edited
-
trunk/Padre/lib/Padre/Wx/Dialog/KeyBindings.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/Wx/Dialog/KeyBindings.pm
r12389 r12390 328 328 } else { 329 329 $shortcuts->{$shortcut} = Padre->ide->actions->{$name}; 330 $self->{bindings}->{$name}->{shortcut} = $shortcut;331 330 warn "Set shortcut '$shortcut' for action '$name'\n"; 332 331 … … 367 366 my $main = $self->GetParent; 368 367 368 # re-create menu to activate shortcuts 369 369 delete $main->{menu}; 370 370 $main->{menu} = Padre::Wx::Menubar->new($main); … … 376 376 } 377 377 378 # Private method to update the key bindings list 378 # Private method to update the key bindings list view 379 379 sub _update_list { 380 380 my $self = shift; … … 386 386 387 387 my $index = -1; 388 my $bindings = $self->{bindings}; 389 my $alternateColor = Wx::Colour->new( 0xED, 0xF5, 0xFF ); 390 my @sorted_binding_keys = sort { $a cmp $b } keys %$bindings; 391 foreach my $name (@sorted_binding_keys) { 392 393 # Fetch key binding and label 394 my $binding = $bindings->{$name}; 395 my $label = $binding->{label}; 388 my $actions = Padre->ide->actions; 389 my $alternate_color = Wx::Colour->new( 0xED, 0xF5, 0xFF ); 390 my @sorted_action_names = sort { $a cmp $b } keys %$actions; 391 for ( my $i = 0; $i < scalar @sorted_action_names; $i++ ) { 392 my $action_name = $sorted_action_names[$i]; 393 my $action = $actions->{$action_name}; 394 my $shortcut = defined $action->shortcut ? $action->shortcut : ''; 396 395 397 396 # Ignore the key binding if it does not match the filter 398 next if $ label!~ /$filter/i;397 next if $action->label_text !~ /$filter/i; 399 398 400 399 # Add the key binding to the list control 401 $list->InsertStringItem( ++$index, $name );402 $list->SetItem( $i ndex, 1, $binding->{label});403 $list->SetItem( $i ndex, 2, $binding->{shortcut});400 $list->InsertStringItem( $i, $action_name ); 401 $list->SetItem( $i, 1, $action->label_text ); 402 $list->SetItem( $i, 2, $shortcut ); 404 403 405 404 # Alternating table colors 406 $list->SetItemBackgroundColour( $i ndex, $alternateColor ) unless $index% 2;405 $list->SetItemBackgroundColour( $i, $alternate_color ) unless $i % 2; 407 406 } 408 407 … … 425 424 } 426 425 427 # Private method to initialize a key bindings hash from Padre actions428 sub _init_key_bindings {429 my $self = shift;430 431 my $bindings = {};432 my %actions = %{ Padre::ide->actions };433 foreach my $name ( keys %actions ) {434 my $action = $actions{$name};435 my $shortcut = $action->shortcut ? $action->shortcut : '';436 warn "Duplicate action name: '" . $action->label_text . "'\n" if exists $bindings->{ $action->label_text };437 $bindings->{$name} = {438 label => $action->label_text,439 shortcut => $shortcut,440 };441 }442 $self->{bindings} = $bindings;443 444 return;445 }446 447 426 # Private method to resize list columns 448 427 sub _resize_columns { … … 462 441 my $self = shift; 463 442 464 # Initialize Key Bindings465 $self->_init_key_bindings;466 467 443 # Set focus on the filter text field 468 444 $self->{filter}->SetFocus;
Note: See TracChangeset
for help on using the changeset viewer.
