Ticket #2256: listview.py.2.diff
File listview.py.2.diff, 4.0 KB (added by , 12 years ago) |
---|
-
deluge/ui/gtkui/listview.py
diff --git a/deluge/ui/gtkui/listview.py b/deluge/ui/gtkui/listview.py index 72613b3..8848bb6 100644
a b def __init__(self, name, column_indices): 147 147 self.sort_func = None 148 148 self.sort_id = None 149 149 150 # Values needed to update TreeViewColumns 151 self.type = None 152 self.renderer = None 153 self.text_index = 0 154 self.value_index = 0 155 self.pixbuf_index = 0 156 self.data_func = None 157 150 158 class TreeviewColumn(gtk.TreeViewColumn): 151 159 """ 152 160 TreeViewColumn does not signal right-click events, and we need them … … def remove_column(self, header): 424 432 for column in self.columns.values(): 425 433 if column.column_indices[0] > column_indices[0]: 426 434 # We need to shift this column_indices 427 for index in column.column_indices: 428 index = index - len(column_indices) 435 for i, index in enumerate(column.column_indices): 436 column.column_indices[i] = index - len(column_indices) 437 438 # Update the associated TreeViewColumn 439 self.update_column(column.name) 429 440 430 441 # Remove from the liststore columns list 431 442 for index in column_indices: … … def add_column(self, header, render, col_types, hidden, position, 466 477 self.columns[header].sort_func = sort_func 467 478 self.columns[header].sort_id = column_indices[sortid] 468 479 480 # Store creation details 481 self.columns[header].type = column_type 482 self.columns[header].renderer = render 483 self.columns[header].text_index = text 484 self.columns[header].value_index = value 485 self.columns[header].pixbuf_index = pixbuf 486 self.columns[header].data_func = function 487 469 488 # Create a new list with the added column 470 489 self.create_new_liststore() 471 490 … … def add_column(self, header, render, col_types, hidden, position, 553 572 554 573 return True 555 574 575 def update_column(self, header): 576 """Update TreeViewColumn based on ListView column mappings""" 577 column = self.columns[header] 578 tree_column = self.columns[header].column 579 580 if column.type == "text": 581 tree_column.set_attributes(column.renderer, 582 text=column.column_indices[column.text_index]) 583 elif column.type == "bool": 584 tree_column.set_attributes(column.renderer, 585 active=column.column_indices[0]) 586 elif column.type == "func": 587 if len(column.column_indices) > 1: 588 tree_column.set_cell_data_func(column.renderer, 589 column.data_func, tuple(column.column_indices)) 590 else: 591 tree_column.set_cell_data_func(column.renderer, 592 column.data_func, column.column_indices[0]) 593 elif column.type == "progress": 594 if column.data_func is None: 595 tree_column.set_attributes(column.renderer, 596 text=column.column_indices[column.text_index], 597 value=column.column_indices[column.value_index]) 598 else: 599 tree_column.set_cell_data_func(column.renderer, 600 column.data_func, tuple(column.column_indices)) 601 elif column.type == "texticon": 602 if column.data_func is not None: 603 tree_column.set_cell_data_func( 604 column.renderer[column.pixbuf_index], 605 column.data_func, 606 column.column_indices[column.pixbuf_index]) 607 608 tree_column.set_attributes( 609 column.renderer[column.text_index], 610 text=column.column_indices[column.text_index]) 611 612 return 613 556 614 def add_text_column(self, header, col_type=str, hidden=False, position=None, 557 615 status_field=None, sortid=0, column_type="text", 558 616 sort_func=None, default=True):