Skip to content

Commit

Permalink
add ability to see and adjust what is playing - issue #296
Browse files Browse the repository at this point in the history
  • Loading branch information
fossfreedom committed Jun 25, 2014
1 parent d9dc244 commit b183736
Show file tree
Hide file tree
Showing 36 changed files with 1,199 additions and 591 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ Browse your coverart albums in Rhythmbox v3 and later.
- Custom Genres are now saved in an alternative folder location to survive re-installation of the plugin
- Search Filter by Composer
- Introduce type-ahead Search filtering to improve searching usability
- Single click add-another-album-to-playing if another album is already playing
- Right-click add-to-playing option for albums and tracks if tracks are already playing
- Single click to append album to list of playing albums
- Right-click to append album to list of playing albums
- View and modify the list of album tracks being played
- Optional support for [SmallWindow](https://github.com/fossfreedom/smallwindow) plugin - allows Rhythmbox to be toggled between its standard application window and its smaller counterpart
- Translated into 26 languages and locales
- for developers - doxygen documentation: http://fossfreedom.github.io/coverart-browser/classes.html
Expand Down
1 change: 1 addition & 0 deletions TRANSLATE_README
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ intltool-extract --local --type=gettext/glade ui/coverart_exportembed.ui
intltool-extract --local --type=gettext/glade ui/coverart_iconview.ui
intltool-extract --local --type=gettext/glade ui/coverart_leftsidebar.ui
intltool-extract --local --type=gettext/glade ui/coverart_listwindow.ui
intltool-extract --local --type=gettext/glade ui/coverart_play_pop_rb3.ui
intltool-extract --local --type=gettext/glade ui/coverart_rightsidebar.ui
intltool-extract --local --type=gettext/glade ui/coverart_topbar.ui
intltool-extract --local --type=gettext/xml img/popups.xml.in
Expand Down
33 changes: 25 additions & 8 deletions coverart_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from coverart_browser_source import CoverArtBrowserSource
from coverart_listview import ListView
from coverart_queueview import QueueView
from coverart_playsourceview import PlaySourceView
from coverart_toolbar import TopToolbar

class CoverArtBrowserEntryType(RB.RhythmDBEntryType):
Expand All @@ -45,7 +46,6 @@ def __init__(self):
'''
RB.RhythmDBEntryType.__init__(self, name='CoverArtBrowserEntryType')


class CoverArtBrowserPlugin(GObject.Object, Peas.Activatable):
'''
Main class of the plugin. Manages the activation and deactivation of the
Expand All @@ -71,15 +71,16 @@ def do_activate(self):
self.shell = self.object
self.db = self.shell.props.db

entry_type = CoverArtBrowserEntryType()
self.db.register_entry_type(entry_type)
self.entry_type = CoverArtBrowserEntryType()
self.db.register_entry_type(self.entry_type)

cl = CoverLocale()
cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

entry_type.category = RB.RhythmDBEntryCategory.NORMAL
self.entry_type.category = RB.RhythmDBEntryCategory.NORMAL

group = RB.DisplayPageGroup.get_by_id('library')

# load plugin icon
theme = Gtk.IconTheme.get_default()
rb.append_plugin_source_path(theme, '/icons')
Expand All @@ -90,12 +91,12 @@ def do_activate(self):
self.source = CoverArtBrowserSource(
shell=self.shell,
name=_("CoverArt"),
entry_type=entry_type,
entry_type=self.entry_type,
plugin=self,
icon=Gio.FileIcon.new(iconfile),
query_model=self.shell.props.library_source.props.base_query_model)

self.shell.register_entry_type_for_source(self.source, entry_type)
self.shell.register_entry_type_for_source(self.source, self.entry_type)
self.shell.append_display_page(self.source, group)

self.source.props.query_model.connect('complete', self.load_complete)
Expand Down Expand Up @@ -203,7 +204,7 @@ def _create_menu(self):
app = Gio.Application.get_default()
self.app_id = 'coverart-browser'

self.locations = ['library-toolbar', 'queue-toolbar']
self.locations = ['library-toolbar', 'queue-toolbar', 'playsource-toolbar']
action_name = 'coverart-browser-views'
self.action = Gio.SimpleAction.new_stateful(
action_name, GLib.VariantType.new('s'),
Expand Down Expand Up @@ -246,6 +247,9 @@ def on_page_change(self, display_page_tree, page):
self.action.set_state(self._views.get_action_name(ListView.name))
elif page == self.shell.props.queue_source:
self.action.set_state(self._views.get_action_name(QueueView.name))
#elif page == self.source.playlist_source:
# self.action.set_state(self._views.get_action_name(PlaySourceView.name))


def view_change_cb(self, action, current):
'''
Expand All @@ -254,7 +258,9 @@ def view_change_cb(self, action, current):
'''
action.set_state(current)
view_name = self._views.get_view_name_for_action(current)
if view_name != ListView.name and view_name != QueueView.name:
if view_name != ListView.name and \
view_name != QueueView.name:# and \
#view_name != PlaySourceView.name:
gs = GSetting()
setting = gs.get_setting(gs.Path.PLUGIN)
setting[gs.PluginKey.VIEW_NAME] = view_name
Expand All @@ -266,3 +272,14 @@ def view_change_cb(self, action, current):
elif view_name == QueueView.name:
GLib.idle_add(self.shell.props.display_page_tree.select,
self.shell.props.queue_source)
#elif view_name == PlaySourceView.name:
# if not hasattr(self.source, 'playlist_source'):
# return

# print ("test selectable")
# path = self.shell.props.display_page_tree.props.model
# #self.source.activate()
# overlay = self.source.get_children()[0]

# GLib.idle_add(self.shell.props.display_page_tree.select,
# self.source.playlist_source)
18 changes: 17 additions & 1 deletion coverart_browser_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@
from coverart_artistview import ArtistView
from coverart_listview import ListView
from coverart_queueview import QueueView
from coverart_playsourceview import PlaySourceView
from coverart_toolbar import ToolbarManager
from coverart_artistinfo import ArtistInfoPane
from coverart_external_plugins import CreateExternalPluginMenu
from coverart_playlists import EchoNestPlaylist
from coverart_entryview import EntryViewPane
from coverart_play_source import CoverArtPlaySource
import coverart_rb3compat as rb3compat


Expand Down Expand Up @@ -152,7 +154,7 @@ def do_selected(self):
def do_impl_activate(self):
'''
Called by do_selected the first time the source is activated.
It creates all the source ui and connects the necesary signals for it
It creates all the source ui and connects the necessary signals for it
correct behavior.
'''
print("CoverArtBrowser DEBUG - do_impl_activate")
Expand All @@ -172,6 +174,16 @@ def do_impl_activate(self):
# define a query model that we'll use for playing
self.source_query_model = RB.RhythmDBQueryModel.new_empty(self.shell.props.db)

# define the associated playsource so we can interact with this query model
self.playlist_source = GObject.new(
CoverArtPlaySource,
name=_("CoverArt Playlist"),
shell=self.shell,
plugin=self.plugin,
entry_type=self.plugin.entry_type)
self.playlist_source.initialise(self.plugin, self.shell, self)
self.shell.append_display_page(self.playlist_source, self.plugin.source)

self._create_ui()
self._setup_source()
self._apply_settings()
Expand Down Expand Up @@ -1121,6 +1133,7 @@ def __init__(self, shell):
from coverart_artistview import ArtistView
from coverart_listview import ListView
from coverart_queueview import QueueView
from coverart_playsourceview import PlaySourceView
from coverart_browser_prefs import webkit_support

library_name = shell.props.library_source.props.name
Expand All @@ -1142,6 +1155,8 @@ def __init__(self, shell):
GLib.Variant.new_string('coverart-browser-list')]
self._values[QueueView.name] = [queue_name,
GLib.Variant.new_string('coverart-browser-queue')]
#self._values[PlaySourceView.name] = [_('CoverArt Playlist'),
# GLib.Variant.new_string('coverart-browser-playsource')]
cl.switch_locale(cl.Locale.RB)
print(self._values)

Expand Down Expand Up @@ -1204,6 +1219,7 @@ def __init__(self, source, window):
self._views[CoverFlowView.name] = CoverFlowView()
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')
Expand Down
38 changes: 25 additions & 13 deletions coverart_entryview.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ def update_selection(self, last_selected_album, click_count):
selected[0].artist,
selected[0].name)

self.entry_view.set_sorting_order('track-number', Gtk.SortType.ASCENDING)

for album in selected:
# add the album to the entry_view
self.entry_view.add_album(album)
Expand Down Expand Up @@ -388,6 +390,7 @@ def change_view(self, entry_view, show_coverart):


class BaseView(RB.EntryView):

def __init__(self, shell, source):
'''
Initializes the entryview.
Expand Down Expand Up @@ -423,6 +426,23 @@ def __init__(self, shell, source):
self.qm = RB.RhythmDBQueryModel.new_empty(self.shell.props.db)
self.set_model(self.qm)

self.connect_library_signals()
self.echonest_similar_playlist = None
self.echonest_similar_genre_playlist = None
self.lastfm_similar_playlist = None

self.connect('selection-changed', self.selection_changed)

self.artists = ""

print ("end constructor")

def __del__(self):
del self.action_group
del self.play_action
del self.queue_action

def connect_library_signals(self):
# connect the sort-order to the library source sort
library_view = self.shell.props.library_source.get_entry_view()
library_view.connect('notify::sort-order',
Expand All @@ -434,20 +454,8 @@ def __init__(self, shell, source):
self.connect('notify::sort-order', self._notify_sort_order,
library_view)

self.echonest_similar_playlist = None
self.echonest_similar_genre_playlist = None
self.lastfm_similar_playlist = None

self.set_columns_clickable(False)

self.connect('selection-changed', self.selection_changed)

self.artists = ""

def __del__(self):
del self.action_group
del self.play_action
del self.queue_action

def display_playing_tracks(self, show_playing):
pass
Expand Down Expand Up @@ -483,7 +491,7 @@ def add_album(self, album):

def clear(self):
print("CoverArtBrowser DEBUG - clear()")
# self.set_model(RB.RhythmDBQueryModel.new_empty(self.shell.props.db))

for row in self.qm:
self.qm.remove_entry(row[0])

Expand Down Expand Up @@ -557,6 +565,10 @@ def play_track_menu_item_callback(self, *args):

self.source.props.query_model = self.source_query_model

#library_view = self.shell.props.library_source.get_entry_view()
#library_view.set_sorting_order('track-number', Gtk.SortType.ASCENDING)
#self.set_sorting_order('track-number', Gtk.SortType.ASCENDING)

# Start the music
player = self.shell.props.shell_player
player.play_entry(entry, self.source)
Expand Down
Loading

0 comments on commit b183736

Please sign in to comment.