code: def activity_changed(self, selection, model):
          
          (model, iter) = selection.get_selected()
  
          # treat any selected case
          unsorted_selected = self._get_selected_category() == -1
          self.get_widget('activity_edit').set_sensitive(iter != None)
          self.get_widget('activity_remove').set_sensitive(iter != None)
docs: enables and disables action buttons depending on selected item