Changeset 5422
- Timestamp:
- 06/20/09 21:41:35 (3 years ago)
- Location:
- trunk/Padre-Plugin-Ecliptic/lib/Padre/Plugin
- Files:
-
- 2 edited
-
Ecliptic.pm (modified) (2 diffs)
-
Ecliptic/QuickFixDialog.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre-Plugin-Ecliptic/lib/Padre/Plugin/Ecliptic.pm
r5207 r5422 13 13 # is a subclass of Padre::Plugin 14 14 use base 'Padre::Plugin'; 15 16 17 # accessors 18 use Class::XSAccessor accessors => { 19 quick_fix_items => 'quick_fix_items', # Public Quick fix items 20 }; 21 15 22 16 23 # … … 236 243 my $self = shift; 237 244 245 if(not defined $self->quick_fix_items) { 246 my @empty_list = (); 247 $self->quick_fix_items(\@empty_list); 248 249 my @items = ( 250 { 251 text => '123...', 252 listener => sub { 253 print "123...\n"; 254 } 255 }, 256 { 257 text => '456...', 258 listener => sub { 259 print "456...\n"; 260 } 261 }, 262 ); 263 264 push @{$self->quick_fix_items}, @items; 265 266 } 267 238 268 #Create and show the dialog 239 269 require Padre::Plugin::Ecliptic::QuickFixDialog; -
trunk/Padre-Plugin-Ecliptic/lib/Padre/Plugin/Ecliptic/QuickFixDialog.pm
r5207 r5422 19 19 _sizer => '_sizer', # window sizer 20 20 _list => '_list', # key bindings list 21 _listeners => '_listeners', # hash of quick fix listener 21 22 }; 22 23 … … 106 107 }); 107 108 109 Wx::Event::EVT_LIST_ITEM_ACTIVATED( $self, $self->_list, sub { 110 111 my $selection = $self->_list->GetFirstSelected; 112 if($selection != -1) { 113 my $listener = $self->_listeners->{$selection}; 114 if($listener) { 115 &{$listener}(); 116 } 117 } 118 return; 119 }); 120 108 121 } 109 122 … … 132 145 $self->_list->SetColumnWidth( 0, $list_width - 5 ); 133 146 134 my $item; 147 # add list items from callbacks 148 my %listeners = (); 149 my $item_count = 0; 150 foreach my $item (@{ $self->_plugin->quick_fix_items }) { 151 # add the list item 152 $self->_list->InsertStringItem($item_count, $item->{text}); 135 153 136 $item = Wx::ListItem->new(); 137 $item->SetText("Inline variable..."); 138 $self->_list->InsertItem($item); 154 # and register its action 155 $listeners{$item_count} = $item->{listener}; 156 157 #next item... 158 $item_count++; 159 } 160 $self->_listeners(\%listeners); 161 162 #XXX- any empty quick fix must display "No suggestions" like Eclipse 139 163 140 $item = Wx::ListItem->new(); 141 $item->SetText("Toggle Comment..."); 142 $self->_list->InsertItem($item); 143 144 if($self->_list->GetItemCount()) { 164 if($item_count) { 145 165 $self->_list->Select(0, 1); 146 166 }
Note: See TracChangeset
for help on using the changeset viewer.
