Ticket #317: gtkui_torrentview_update_sidebar_alternate.patch

File gtkui_torrentview_update_sidebar_alternate.patch, 5.3 KB (added by sadrul, 18 years ago)

alternate patch (mark dirty, less noisy)

  • deluge/ui/gtkui/torrentview.py

     
    120120        # Add the columns to the listview
    121121        self.add_text_column("torrent_id", hidden=True)
    122122        self.add_bool_column("filter", hidden=True)
     123        self.add_bool_column("dirty", hidden=True)
    123124        self.add_func_column("#", cell_data_queue, [int], status_field=["queue"])
    124125        self.add_texticon_column(_("Name"), status_field=["state", "name"],
    125126                                            function=cell_data_statusicon)
     
    252253        torrent_ids = []
    253254        for row in self.liststore:
    254255            # Only add this torrent_id if it's not filtered
    255             if row[self.columns["filter"].column_indices[0]] == True:
     256            if row[self.columns["filter"].column_indices[0]] == True or \
     257                    row[self.columns["dirty"].column_indices[0]] == True :
    256258                torrent_ids.append(row[self.columns["torrent_id"].column_indices[0]])
     259                row[self.columns["dirty"].column_indices[0]] = False
    257260
    258261        if torrent_ids == []:
    259262            return
     
    266269    def update_filter(self):
    267270        # Update the filter view
    268271        for row in self.liststore:
    269             filter_column = self.columns["filter"].column_indices[0]
    270             # Create a function to create a new liststore with only the
    271             # desired rows based on the filter.
    272             field, condition = self.filter
    273             if field == None and condition == None:
    274                 row[filter_column] = True
    275                 continue
     272            self.update_filter_row(row)
    276273
    277             value = row[self.get_state_field_column(field)]
     274    def update_filter_row(self, row):
     275        filter_column = self.columns["filter"].column_indices[0]
     276        # Create a function to create a new liststore with only the
     277        # desired rows based on the filter.
     278        field, condition = self.filter
     279        if field == None and condition == None:
     280            row[filter_column] = True
     281            return
    278282
    279             # Condition is True, so lets show this row, if not we hide it
    280             if value == condition:
    281                 row[filter_column] = True
    282             else:
    283                 row[filter_column] = False
    284            
     283        value = row[self.get_state_field_column(field)]
     284
     285        # Condition is True, so lets show this row, if not we hide it
     286        if value == condition:
     287            row[filter_column] = True
     288        else:
     289            row[filter_column] = False
     290       
    285291    def update(self):
    286292        # Send a status request
    287293        self.send_status_request()
     
    327333                                                column_index.index(index)]]
    328334                            except:
    329335                                pass
    330 
     336                self.update_filter_row(row)
    331337        # Update the toolbar buttons just in case some state has changed
    332338        component.get("ToolBar").update_buttons()
    333339        component.get("MenuBar").update_menu()
     
    364370                self.update()
    365371                self.update_filter()
    366372                break
     373
     374    def mark_dirty(self, torrent_id = None):
     375        for row in self.liststore:
     376            if not torrent_id or row[0] == torrent_id:
     377                print "marking %s dirty" % torrent_id
     378                row[self.columns["dirty"].column_indices[0]] = True
     379                if torrent_id: break
    367380           
    368381    def get_selected_torrent(self):
    369382        """Returns a torrent_id or None.  If multiple torrents are selected,
  • deluge/ui/gtkui/signals.py

     
    9797
    9898    def torrent_paused(self, torrent_id):
    9999        log.debug("torrent_paused signal received..")
     100        component.get("TorrentView").mark_dirty(torrent_id)
    100101        component.get("TorrentView").update()
    101102        component.get("ToolBar").update_buttons()
    102103        component.get("MenuBar").update_menu()
    103104   
    104105    def torrent_resumed(self, torrent_id):
    105106        log.debug("torrent_resumed signal received..")
     107        component.get("TorrentView").mark_dirty(torrent_id)
    106108        component.get("TorrentView").update()
    107109        component.get("ToolBar").update_buttons()
    108110        component.get("MenuBar").update_menu()
    109111           
    110112    def torrent_all_paused(self):
    111113        log.debug("torrent_all_paused signal received..")
     114        component.get("TorrentView").mark_dirty()
    112115        component.get("TorrentView").update()
    113116        component.get("ToolBar").update_buttons()
    114117        component.get("MenuBar").update_menu()
    115118       
    116119    def torrent_all_resumed(self):
    117120        log.debug("torrent_all_resumed signal received..")
     121        component.get("TorrentView").mark_dirty()
    118122        component.get("TorrentView").update()
    119123        component.get("ToolBar").update_buttons()
    120124        component.get("MenuBar").update_menu()
     
    126130   
    127131    def torrent_queue_changed(self):
    128132        log.debug("torrent_queue_changed signal received..")
     133        component.get("TorrentView").mark_dirty()
    129134        component.get("TorrentView").update()
    130135   
    131136    def torrent_resume_at_stop_ratio(self):