Changeset 279:192aeea89424 for src
- Timestamp:
- 07/07/12 09:37:31 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/checklist.py
r268 r279 141 141 self._fileListModel = gtk.ListStore(str, str) 142 142 self._fileList = gtk.TreeView(model = self._fileListModel) 143 self._fileList.connect("button-press-event", 144 self._fileListButtonPressed) 143 145 column = gtk.TreeViewColumn(xstr("chklst_header"), 144 146 gtk.CellRendererText(), text = 0) … … 149 151 self._fileList.set_tooltip_column(1) 150 152 self._fileList.set_reorderable(True) 153 self._fileListPopupMenu = None 151 154 selection = self._fileList.get_selection() 152 155 selection.set_mode(SELECTION_MULTIPLE) 153 156 selection.connect("changed", self._fileListSelectionChanged) 157 158 self._buildFileListPopupMenu() 154 159 155 160 scrolledWindow = gtk.ScrolledWindow() … … 206 211 def _removeButtonClicked(self, button): 207 212 """Called when the Remove button is clicked.""" 213 self._removeSelected() 214 215 def _removeSelected(self): 216 """Remove the currently selected files.""" 208 217 selection = self._fileList.get_selection() 209 218 (model, paths) = selection.get_selected_rows() … … 250 259 anySelected = selection.count_selected_rows()>0 251 260 self._removeButton.set_sensitive(anySelected) 261 self._popupRemoveItem.set_sensitive(anySelected) 252 262 253 263 if anySelected: … … 261 271 262 272 self._moveUpButton.set_sensitive(minIndex>0) 273 self._popupMoveUpItem.set_sensitive(minIndex>0) 263 274 264 275 numRows = model.iter_n_children(None) 265 276 self._moveDownButton.set_sensitive(maxIndex<(numRows-1)) 277 self._popupMoveDownItem.set_sensitive(maxIndex<(numRows-1)) 266 278 else: 267 279 self._moveUpButton.set_sensitive(False) 280 self._popupMoveUpItem.set_sensitive(False) 268 281 self._moveDownButton.set_sensitive(False) 282 self._popupMoveDownItem.set_sensitive(False) 269 283 270 284 def _getAircraftType(self): … … 299 313 self._fileListModel.append([os.path.basename(path), path]) 300 314 315 def _fileListButtonPressed(self, widget, event): 316 """Called when a mouse button is pressed on the file list.""" 317 if event.type!=EVENT_BUTTON_PRESS or event.button!=3: 318 return 319 320 # (path, _, _, _) = self._flightList.get_path_at_pos(int(event.x), 321 # int(event.y)) 322 # selection = self._flightList.get_selection() 323 # selection.unselect_all() 324 # selection.select_path(path) 325 326 menu = self._fileListPopupMenu 327 if pygobject: 328 menu.popup(None, None, None, None, event.button, event.time) 329 else: 330 menu.popup(None, None, None, event.button, event.time) 331 332 def _buildFileListPopupMenu(self): 333 """Get the file list popup menu.""" 334 menu = gtk.Menu() 335 336 menuItem = gtk.MenuItem() 337 menuItem.set_label(xstr("chklst_remove")) 338 menuItem.set_use_underline(True) 339 menuItem.connect("activate", self._popupRemove) 340 menuItem.show() 341 self._popupRemoveItem = menuItem 342 343 menu.append(menuItem) 344 345 menuItem = gtk.MenuItem() 346 menuItem.set_label(xstr("chklst_moveUp")) 347 menuItem.set_use_underline(True) 348 menuItem.connect("activate", self._popupMoveUp) 349 menuItem.show() 350 self._popupMoveUpItem = menuItem 351 352 menu.append(menuItem) 353 354 menuItem = gtk.MenuItem() 355 menuItem.set_label(xstr("chklst_moveDown")) 356 menuItem.set_use_underline(True) 357 menuItem.connect("activate", self._popupMoveDown) 358 menuItem.show() 359 self._popupMoveDownItem = menuItem 360 361 menu.append(menuItem) 362 363 self._fileListPopupMenu = menu 364 365 def _popupRemove(self, menuItem): 366 """Remove the currently selected menu items.""" 367 self._removeSelected() 368 369 def _popupMoveUp(self, menuItem): 370 """Move up the currently selected menu items.""" 371 self._moveSelected(True) 372 373 def _popupMoveDown(self, menuItem): 374 """Move down the currently selected menu items.""" 375 self._moveSelected(False) 301 376 302 377 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.