[ontv] Use set_selected_channel instead of direct access
- From: Olof Kindgren <olki src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ontv] Use set_selected_channel instead of direct access
- Date: Thu, 27 Jan 2011 11:46:47 +0000 (UTC)
commit da9ecab96eb9dc8b3409726a9c0e13d4556e2863
Author: Olof Kindgren <olki src gnome org>
Date: Thu Jan 27 12:45:00 2011 +0100
Use set_selected_channel instead of direct access
Avoid using objects in listings directly. This patch creates a
set_channel_selected_function that can be used instead of using
append/remove directly on the selected_channels list
ontv/dialogs.py | 9 +++------
ontv/listings.py | 6 ++++++
2 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/ontv/dialogs.py b/ontv/dialogs.py
index f423959..5dab49f 100644
--- a/ontv/dialogs.py
+++ b/ontv/dialogs.py
@@ -247,10 +247,7 @@ class PreferencesDialog:
def on_channels_treeview_toggled(self, model, path):
channel = model[path][0]
channel.selected = not channel.selected
- if channel.selected:
- self.listings.selected_channels.append(channel.name)
- else:
- self.listings.selected_channels.remove(channel.name)
+ self.listings.set_channel_selected(channel.name, channel.selected)
model.row_changed(path, model.get_iter(path))
@@ -469,7 +466,7 @@ class PreferencesDialog:
channel = self.listings.channels[channel_name]
channel.selected = False
self.unselected_channels_filter.refilter()
- self.listings.selected_channels.remove(channel_name)
+ self.listings.set_channel_selected(channel_name, False)
self.selected_channels_model.remove(iter)
self.pw.update()
self.listings.save()
@@ -482,7 +479,7 @@ class PreferencesDialog:
channel = model.get_value(filter.convert_iter_to_child_iter(iter), 0)
channel.selected = True
- self.listings.selected_channels.append(channel.name)
+ self.listings.set_channel_selected(channel.name, True)
self.selected_channels_model.append([channel.name])
self.unselected_channels_filter.refilter()
self.pw.update()
diff --git a/ontv/listings.py b/ontv/listings.py
index eb9e602..554b9c2 100644
--- a/ontv/listings.py
+++ b/ontv/listings.py
@@ -89,6 +89,12 @@ class Listings(object):
print("Loaded listings from file: %s" % self.file)
return self
+ def set_channel_selected(self, channel, selected):
+ if selected:
+ self.selected_channels.append(channel)
+ else:
+ self.selected_channels.remove(channel)
+
def search_program(self, search_terms, channel):
matches = []
for term in search_terms:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]