Skip to content

Commit

Permalink
Save sort preference in the stations popover
Browse files Browse the repository at this point in the history
Closes #232
  • Loading branch information
kirinthos authored and TingPing committed Oct 6, 2015
1 parent 029668d commit 9d316e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions pithos/PreferencesPithosDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def __load_preferences(self):
"audio_quality": default_audio_quality,
"pandora_one": False,
"force_client": None,
"sort_stations": False,
}

try:
Expand Down
8 changes: 4 additions & 4 deletions pithos/StationsPopover.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def __init__(self):
box2 = Gtk.Box()
self.search = Gtk.SearchEntry()
self.sorted = False
sort = Gtk.ToggleButton.new()
sort.add(Gtk.Image.new_from_icon_name("view-sort-ascending-symbolic", Gtk.IconSize.BUTTON))
sort.connect("toggled", self.sort_changed)
self.sort = Gtk.ToggleButton.new()
self.sort.add(Gtk.Image.new_from_icon_name("view-sort-ascending-symbolic", Gtk.IconSize.BUTTON))
self.sort.connect("toggled", self.sort_changed)
box2.pack_start(self.search, True, True, 0)
box2.add(sort)
box2.add(self.sort)

self.listbox = Gtk.ListBox()
self.listbox.connect('button-press-event', self.on_button_press)
Expand Down
5 changes: 5 additions & 0 deletions pithos/pithos.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ def bgcolor_data_func(column, cell, model, iter, data=None):
self.stations_popover = StationsPopover()
self.stations_popover.set_relative_to(self.stations_button)
self.stations_popover.set_model(self.stations_model)
self.stations_popover.sort.set_active(self.preferences['sort_stations'])
self.stations_popover.sort.connect('toggled', self.sort_toggled)
self.stations_popover.listbox.connect('row-activated', self.active_station_changed)
self.stations_button.set_popover(self.stations_popover)
self.stations_label = self.builder.get_object('stationslabel')
Expand Down Expand Up @@ -896,6 +898,9 @@ def destroy_ui_loop(self):
def active_station_changed(self, listbox, row):
self.station_changed(row.station)

def sort_toggled(self, widget):
self.preferences['sort_stations'] = self.stations_popover.sorted

def format_time(self, time_int):
if time_int is None:
return None
Expand Down

0 comments on commit 9d316e3

Please sign in to comment.