Skip to content

Commit

Permalink
some cleanup and fix up of common padding options, also ensure view i…
Browse files Browse the repository at this point in the history
…s correctly redisplayed with switching between views - issue #331
  • Loading branch information
fossfreedom committed Jun 21, 2015
1 parent 6f48e02 commit a0b4b0e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 54 deletions.
23 changes: 16 additions & 7 deletions coverart_artistview.py
Expand Up @@ -530,6 +530,8 @@ def sort(self):
'rating_artist': ('rating', 'album_sort')
}

print (key, order)

props = sort_keys[key]

def key_function(album):
Expand All @@ -538,9 +540,9 @@ def key_function(album):

# remember the current sort then remove the sort order
# because sorting will only work in unsorted lists
sortSettings = self.store.get_sort_column_id()
#sortSettings = self.store.get_sort_column_id()

self.store.set_sort_column_id(-1, Gtk.SortType.ASCENDING)
#self.store.set_sort_column_id(-1, Gtk.SortType.ASCENDING)

for artist in self._iters:
albums.clear()
Expand Down Expand Up @@ -569,8 +571,9 @@ def key_function(album):
next_iter = self._tree_store.iter_next(next_iter)

# now we have finished sorting, reapply the sort
if sortSettings[0]:
self.store.set_sort_column_id(*sortSettings)
#if sortSettings[0]:
# self.store.set_sort_column_id(*sortSettings)


@idle_iterator
def _recreate_text(self):
Expand Down Expand Up @@ -852,8 +855,8 @@ class ArtistView(Gtk.Stack, AbstractView):
}


def __init__(self, *args, **kwargs):
super(ArtistView, self).__init__(*args, **kwargs)
def __init__(self):
super(ArtistView, self).__init__()

self._external_plugins = None
self.gs = GSetting()
Expand All @@ -863,6 +866,7 @@ def __init__(self, *args, **kwargs):

def initialise(self, source):
if self._has_initialised:
print ("already initialised")
return

self._has_initialised = True
Expand Down Expand Up @@ -934,7 +938,9 @@ def switch_to_view(self, source, album):
self.initialise(source)
self.show_policy.initialise(source.album_manager)

self.iconview.scroll_to_album(album)
print(self.get_visible_child_name())#'iconview')
print (self.get_children())
#self.iconview.scroll_to_album(album)


def do_update_toolbar(self, *args):
Expand Down Expand Up @@ -1015,6 +1021,9 @@ def initialise(self, source):
self._connect_properties()
self._connect_signals()

self.emit('initialise')


def _connect_properties(self):
setting = self.gs.get_setting(self.gs.Path.PLUGIN)
setting.bind(self.gs.PluginKey.ICON_AUTOMATIC, self,
Expand Down
8 changes: 4 additions & 4 deletions coverart_browser_source.py
Expand Up @@ -1316,9 +1316,7 @@ def __init__(self, source, window):
self._views[ListView.name] = ListView()
self._views[QueueView.name] = QueueView()
self._views[PlaySourceView.name] = PlaySourceView()
ui.add_from_file(rb.find_plugin_file(source.plugin,
'ui/coverart_artistview.ui'))
self._views[ArtistView.name] = ui.get_object('artist_view')
self._views[ArtistView.name] = ArtistView()
self._lastview = None

self.controller = ViewController(source.shell, self)
Expand Down Expand Up @@ -1356,9 +1354,11 @@ def on_notify_view_name(self, *args):

if self._views[self.view_name].use_plugin_window:
child = self.window.get_child()

if child:
if isinstance(child, Gtk.Viewport):
child.remove(child.get_child()) # Gtk adds a viewport automatically for a Gtk.Stack
self.window.remove(child)

self.window.add(self._views[self.view_name].view)
self.window.show_all()
self.click_count = 0
Expand Down
36 changes: 4 additions & 32 deletions coverart_covericonview.py
Expand Up @@ -309,12 +309,9 @@ def _album_updated(self, model, album_path, album_iter):
class CoverIconView(EnhancedIconView, AbstractView):
__gtype_name__ = "CoverIconView"

icon_spacing = GObject.property(type=int, default=0)
icon_padding = GObject.property(type=int, default=0)
icon_automatic = GObject.property(type=bool, default=True)

display_text_enabled = GObject.property(type=bool, default=False)
display_text_pos = GObject.property(type=bool, default=False)
icon_automatic = GObject.property(type=bool, default=True)

name = 'coverview'
panedposition = PanedCollapsible.Paned.COLLAPSE
Expand Down Expand Up @@ -401,21 +398,11 @@ def initialise(self, source):
self._connect_signals()

self._activate_markup()
self.on_notify_icon_padding()
self.on_notify_icon_spacing()

self.emit('initialise')

def _connect_properties(self):
setting = self.gs.get_setting(self.gs.Path.PLUGIN)
setting.bind(
self.gs.PluginKey.ICON_SPACING,
self,
'icon_spacing',
Gio.SettingsBindFlags.GET)
setting.bind(
self.gs.PluginKey.ICON_PADDING,
self,
'icon_padding',
Gio.SettingsBindFlags.GET)

setting.bind(self.gs.PluginKey.DISPLAY_TEXT, self,
'display_text_enabled', Gio.SettingsBindFlags.GET)
Expand All @@ -433,10 +420,7 @@ def _connect_signals(self):
self.connect("item-clicked", self.item_clicked_callback)
self.connect("selection-changed", self.selectionchanged_callback)
self.connect("item-activated", self.item_activated_callback)
self.connect('notify::icon-spacing',
self.on_notify_icon_spacing)
self.connect('notify::icon-padding',
self.on_notify_icon_padding)

self.connect("motion-notify-event", self.on_pointer_motion)
self.connect('notify::display-text-enabled',
self._activate_markup)
Expand Down Expand Up @@ -734,18 +718,6 @@ def item_activated_callback(self, iconview, path):

return True

def on_notify_icon_padding(self, *args):
'''
Callback called when the icon-padding gsetting value is changed
'''
self.set_item_padding(self.icon_padding)

def on_notify_icon_spacing(self, *args):
'''
Callback called when the icon-spacing gsetting value is changed
'''
self.set_row_spacing(self.icon_spacing)
self.set_column_spacing(self.icon_spacing)

def _activate_markup(self, *args):
'''
Expand Down
40 changes: 39 additions & 1 deletion coverart_widgets.py
Expand Up @@ -1015,10 +1015,14 @@ class EnhancedIconView(Gtk.IconView):

# signals
__gsignals__ = {
'item-clicked': (GObject.SIGNAL_RUN_LAST, None, (object, object))
'item-clicked': (GObject.SIGNAL_RUN_LAST, None, (object, object)),
'initialise': (GObject.SIGNAL_RUN_FIRST, None, ())
}

object_column = GObject.property(type=int, default=-1)
icon_spacing = GObject.property(type=int, default=0)
icon_padding = GObject.property(type=int, default=0)


def __init__(self, *args, **kwargs):
super(EnhancedIconView, self).__init__(*args, **kwargs)
Expand All @@ -1028,6 +1032,40 @@ def __init__(self, *args, **kwargs):
self.source = None
self.ext_menu_pos = 0

def do_initialise(self):
setting = self.gs.get_setting(self.gs.Path.PLUGIN)
setting.bind(
self.gs.PluginKey.ICON_SPACING,
self,
'icon_spacing',
Gio.SettingsBindFlags.GET)
setting.bind(
self.gs.PluginKey.ICON_PADDING,
self,
'icon_padding',
Gio.SettingsBindFlags.GET)

self.connect('notify::icon-spacing',
self.on_notify_icon_spacing)
self.connect('notify::icon-padding',
self.on_notify_icon_padding)

self.on_notify_icon_padding()
self.on_notify_icon_spacing()

def on_notify_icon_padding(self, *args):
'''
Callback called when the icon-padding gsetting value is changed
'''
self.set_item_padding(self.icon_padding)

def on_notify_icon_spacing(self, *args):
'''
Callback called when the icon-spacing gsetting value is changed
'''
self.set_row_spacing(self.icon_spacing)
self.set_column_spacing(self.icon_spacing)

def do_size_allocate(self, allocation):
'''
Forces the reallocation of the IconView columns when the width of the
Expand Down
10 changes: 0 additions & 10 deletions ui/coverart_artistview.ui

This file was deleted.

0 comments on commit a0b4b0e

Please sign in to comment.