Permalink
Browse files

fix sorting issue after restart together with scroll sync issue betwe…

…en artist and tile view - issue #257
  • Loading branch information...
1 parent d93ea16 commit b2eabeb8eb22ce9d91eab1b8bcf24bb104a3a607 @fossfreedom committed Jan 19, 2014
Showing with 55 additions and 33 deletions.
  1. +35 −15 coverart_album.py
  2. +12 −10 coverart_artistview.py
  3. +4 −0 coverart_browser_source.py
  4. +4 −8 coverart_controllers.py
View
@@ -928,20 +928,44 @@ def finish(data):
return ALBUM_LOAD_CHUNK, process, None, error, finish
- def sort(self, key=None, reverse=False):
+ def sort(self):
'''
Changes the sorting strategy for the model.
-
- :param key: `str`attribute of the `Album` class by which the sort
- should be performed.
- :param reverse: `bool` indicating whether the sort order should be
- reversed from the current one.
'''
-
+
+ gs = GSetting()
+ source_settings = gs.get_setting(gs.Path.PLUGIN)
+ key = source_settings[gs.PluginKey.SORT_BY]
+ order = source_settings[gs.PluginKey.SORT_ORDER]
+
+ print ("current")
+ print (self._sortkey)
+
+ print ("registry")
+ print (key)
+ print (order)
+
+ if key == self._sortkey['type']:
+ key = None
+ else:
+ self._sortkey['type'] = key
+
+ if order != self._sortkey['order']:
+ reverse = True
+ self._sortkey['order'] = order
+ else:
+ reverse = False
+
def key_function(album):
keys = [getattr(album, prop) for prop in props]
return keys
+ if not key and not reverse:
+ print ("nothing to sort")
+ return
+
+ print (key)
+ print (reverse)
if key:
props = sort_keys[key]
self._albums.key = key_function
@@ -1519,8 +1543,7 @@ def cover_update(data, coverobject):
async = rb.Loader()
async.get_url(uri, cover_update, coverobject)
-
-
+
class AlbumCoverManager(CoverManager):
# properties
add_shadow = GObject.property(type=bool, default=False)
@@ -1781,13 +1804,10 @@ def _connect_signals(self):
def _sort_album(self, widget, param):
- toolbar_type, key, reverse = param
+ toolbar_type = param
- if toolbar_type == "album":
- if reverse == None:
- self.model.sort(key=key)
- else:
- self.model.sort(reverse=reverse)
+ if not toolbar_type or toolbar_type == "album":
+ self.model.sort()
def _load_finished_callback(self, *args):
self.artist_man.loader.load_artists()
@@ -464,7 +464,9 @@ def get_from_path(self, path):
return self.store[path][self.columns['artist_album']]
def get_path(self, artist):
- return self.store.get_path(
+ print (artist.name)
+ print (self._iters[artist.name]['iter'])
+ return self._tree_store.get_path(
self._iters[artist.name]['iter'])
def get_from_ext_db_key(self, key):
@@ -736,9 +738,9 @@ def _connect_signals(self):
def _sort_artist(self, widget, param):
- toolbar_type, key, reverse = param
+ toolbar_type = param
- if toolbar_type == "artist":
+ if not toolbar_type or toolbar_type == "artist":
self.model.sort()
def _load_finished_callback(self, *args):
@@ -907,15 +909,9 @@ def _query_tooltip( self, widget, x, y, key, tooltip ):
src_height = pixbuf.get_height()
factor = min(float(256) / float(src_width), float(256) / float(src_height))
- print (factor)
new_width = int(src_width * factor + 0.5)
new_height = int(src_height * factor + 0.5)
-
- print (new_width)
- print (new_height)
- print (src_width)
- print (src_height)
-
+
pixbuf = create_pixbuf_from_file_at_size(
active_object.cover.original, new_width, new_height)
@@ -1091,8 +1087,14 @@ def switch_to_view(self, source, album):
self.show_policy.initialise(source.album_manager)
if album:
+ print ("switch to artist view")
+ print (album)
artist = self.artist_manager.model.get(album.artist)
path = self.artist_manager.model.get_path(artist)
+ print (artist)
+ print (path)
+ path = self.artist_manager.model.store.convert_child_path_to_path(path)
+ print (path)
if path:
self.scroll_to_cell(path, self._artist_col)
self.expand_row(path, False)
@@ -1068,6 +1068,9 @@ def __init__(self, source, window):
@property
def current_view(self):
return self._views[self.view_name]
+
+ def get_view(self, view_name):
+ return self._views[view_name]
def _connect_signals(self):
self.connect('notify::view-name', self.on_notify_view_name)
@@ -1098,6 +1101,7 @@ def on_notify_view_name(self, *args):
self._views[self.view_name].switch_to_view(self.source, current_album)
self._views[self.view_name].emit('update-toolbar')
+ self._views[self.view_name].get_default_manager().emit('sort', None)
if self._views[self.view_name].use_plugin_window:
self.source.paned.expand(self._views[self.view_name].panedposition)
@@ -418,7 +418,7 @@ def do_action(self):
settings = gs.get_setting(gs.Path.PLUGIN)
settings[gs.PluginKey.SORT_BY] = sort
- self._viewmgr.current_view.get_default_manager().emit('sort', ("album",sort, None))
+ self._viewmgr.current_view.get_default_manager().emit('sort', "album")
def get_current_image(self):
sort = self.values[self.current_key]
@@ -472,7 +472,7 @@ def do_action(self):
settings = gs.get_setting(gs.Path.PLUGIN)
settings[gs.PluginKey.SORT_BY_ARTIST] = sort
- self._viewmgr.current_view.get_default_manager().emit('sort', ("artist", sort, None))
+ self._viewmgr.current_view.get_default_manager().emit('sort', "artist")
def get_current_image(self):
sort = self.values[self.current_key]
@@ -681,13 +681,9 @@ def update_images(self, *args):
def do_action(self):
sort_order = self.values[self.current_key]
-
- if not sort_order or\
- sort_order != self.settings[self.key]:
- self._viewmgr.current_view.get_default_manager().emit('sort', (self.toolbar_type,None, True)) #(reverse=True)
-
self.settings[self.key] = sort_order
-
+ self._viewmgr.current_view.get_default_manager().emit('sort', self.toolbar_type)
+
def get_current_image(self):
return self._images[self.get_current_key_index()]

0 comments on commit b2eabeb

Please sign in to comment.