It defaults to a None pointer, but calling add_children() will set one
up with an empty set. I also implement functions for adding, removing,
and verifying child playlists.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is similar to a Gtk.FilterListModel, except we already know exactly
which rows are part of the model or not. So we can skip the entire
filtering step and show rows directly instead.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This includes implementing the __contains__() magic method, and adding
signals that are emitted when rows are added, removed, or directly set.
This will allow us to build a model around the rows represented by the
set.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I'm going to expand on this and use it for more than just filtering
Gtk.FilterListModels. Renaming it to something more generic is the first
step.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
It is much easier to pass a single boolean value instead of a Gtk
constant for specifying the icon size.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is used to set the tooltip text to fixed strings based on the
active status of the button. I also update the tooltip text on the
Favorite button in the Now Playing widget at the same time.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I add accelerators for play, pause, next track, previous track, setting
autopause, adding the current track to the favorites playlist, and
scrolling to the current track in the tracklist.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I create can-activate-* properties to indicate if a specific accelerator
can be activated. At the same time, I introduce functions intended to be
called by accelerators to activate each of our widgets.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
All I needed the frame for was to add rounded corners to the
Gtk.Picture, but this had some problems with the Frame expanding beyond
the edges of the picture in some cases. I can get the same effect by
adding the "card" css class to the Picture so hopefully this will work
better.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is a keybinding function that calls into the primary button
activate() function. At the same time, I add an "activate-primary"
signal that is emitted when the primary button is activated.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I add accelerators for opening files, changing the volume, toggling
background mode, and running the settings editor.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I made these functions part of the public interface with option
arguments so they can be used in accelerator callbacks for increasing or
decreasing the volume.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I use the current focus widget to set the "user-editing" property, which
can be used to enable or disable accelerator actions.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is inspried by the Gio.ActionEntry struct, which I can't figure out
how to get working in Python. I add on a few extra helpful features,
such as:
- Automatically creating a Gio.SimpleAction
- Tracking the desired accelerator keys
- Binding the "enabled" state to a specificed property at construction
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Otherwise we could lose the changes if the app crashes.
Fixes: #63 ("The database isn't being committed enough")
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Otherwise we could have data loss if the application crashes.
Fixes: #63 ("The database isn't being committed enough")
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Leaving the database in a dirty state could cause unintentional data
loss if the app crashes.
Fixes: #63 ("The database isn't being committed enough")
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This lets us skip a handful of database calls if we detect that we're
setting the active playlist to the same value.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I do this unconditionally, so even if the track is already on the
playlist we set it as active. I think this is what the user would
expect, but I'm open to revising this approach later.
Fixes: #62 ("Queueing tracks doesn't activate the Queued Tracks playlist")
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And wire up the bg-enabled and bg-volume properties from the header to
the playbin properties with the same name.
Implements: #50 ("Background Music Mode")
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This links together our ReplayGain filter with a volume element that is
set to the user configured background volume when background listening
mode is enabled, and 100% when background listening mode is disabled.
Implements: #50 ("Background Music Mode")
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I also update the button tooltip to display the background listening
status along with the current volume level.
Implements: #50 ("Background Music Mode")
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And wire up the properties so we can save the user's current setting.
Implements: #50 ("Background Music Mode")
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This widget will be added to the Volume popover and allow configuring a
lower volume for background listening while focusing on tasks.
Implements: #50 ("Background Music Mode")
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This will be added to a ListBox with the volume controls. Expanding the
row will enable ReplayGain and give the user a menu to select ReplayGain
mode.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The plan is to convert the volume control panel into a Gtk.ListBox for a
more modern appearance.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is nice to have so users know what to expect from each button. I do
take some liberties, such as putting version numbers of our dependencies
as the tooltip for the Title widget. I also display the current volume
level in the volume button tooltip.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I split the function into two. Calling env_string() will return the
string we generate with the versions of the various modules we depend
on. Calling print_env() will print this string.
I need env_string() so we can set the environment as a tooltip in the
header.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Future proof. If we update the database schema, then we'll bump the
user_version field. If the user then tries to open the new database with
an old Emmental version then there could be a lot of issues. Let's
detect this and raise an error with a description of the problem.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
These are used to manually rearrange the Tracks in the Playlist. The
buttons are only marked sensitive if one item is selected.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The Add Tracks button is a popover button configured to display a list
of playlists that tracks could be added to. I take some extra care to
make sure we only display playlists that have their user-tracks property
set to True, and to hide the currently visible playlist from the list.
Additionally, I create a horizontal size group so the Add and Remove
buttons are the same size.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The button is placed inside a Gtk.Overlay, and is hidden by default. The
button will be shown when tracks are selected if the current Playlist
has its "user-tracks" property set to True.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This widget displays the number of visible tracks, number of selected
tracks, and runtime of the current playlist. I wire it up to these
properties from the trackview.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is a Popover Button containing a Gtk.ListView to display the Sort
Order Model for the currently visible Playlist.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This Widget is intended to be used as the child widget in a Gtk.ListView
to display and change the sort order of the current playlist. I use
arrow buttons from the icon library to represent sort order
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is a Gio.ListStore with some extra functions for enabling,
disabling, rearranging, and reversing sort fields. It also has a
sort-string property for getting the current sort order to save
to the database.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The SortField object is used to represent a single column in the
Tracklist that the user could sort by.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is an ImageToggle button that has been configured to cycle between
3 states corresponding to no looping, playlist looping, and track
looping.
I also update the Tracklist to look for changes in the visible Playlist
to update the Loop button.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The OSD will eventually contain buttons for modifying playlists, but for
now it just has functions and properties for mananging the current track
selection.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And wire this up to not only the Now Playing "jump" signal, but also the
next track pickers so we scroll when tracks are changed.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The MediumName TrackRow is used to combine the album and medium names
into a single string. This means we won't need to have a separate medium
name column that is empty for most tracks.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The AlbumCover shows a cover.jpg image for a specific Album in a column.
I also need to do some special handling so generate a tooltip to show a
larger version of the image.
I try to cache the AlbumCover Texture to cut down on disk accesses,
since we'll usually end up loading the same image several times for each
track in an album.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is an InscriptionRow that binds a Track's Album's property to the
Gtk.Inscription. I use it to display album artist and release information
in columns.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
These are specially configured TrackRows that take a non-string Track
property and convert it into a string displayed in the Inscription. I
use them to add Length, Play Count, Last Started, Last Played, and
Filepath columns to the TrackView.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The TrackRow widget is used to bind Tracks to a generic Widget. The
InscriptionRow builds on this to create a Gtk.Inscription that can be
used in derived classes. Finally, the TrackString widget implements
binding a string Track property directly to the Inscription.
I use these widgets to create a Title and Artist column in the
TrackView.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The TrackView sets up a scrollable Gtk.ColumnView inside a nice looking
frame. It also creates a FilterListModel for filtering tracks in a
separate layer from the Playlist so we don't affect choosing the next
track.
Finally, I add the TrackView to the TrackList Card.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
For now it only has the Gtk.CenterBox child with an entry.Filter widget,
but this will be expanded on in future patches. I also take the chance
to bind the factory:visible-playlist property to the playlist displayed
in the tracklist.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And connect to the Player EOS and about-to-finish signals so we can
select the next track when the current one finishes (or slightly before
for gapless playback).
Implements: #7 (Add MPRIS2 Support)
Implements: #48 (Implement Intelligent ReplayGain)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
It takes an additional user= parameter to indicate if the user is asking
for the next track or if it is coming from the audio player (such as an
EOS / about-to-finish signal). This lets us handle the next_track() call
slightly differently for the user case.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And also a can-go-previous property to set the correct sensitivity on
the "Previous" button and for notifying MPRIS.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And add some special handling so a previous.Previous() playlist type is
created for the db_previous playlist.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And add some special handling for setting the active playlist and
visible playlist to the same db playlist. I also add active-loop and
active-shuffle properties that are wired up to the MPRIS2 "Shuffle" and
"LoopStatus" player properties.
Implements: #7 (Add MPRIS2 Support)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I either create or reuse an existing Playlist object when the
db-visible property changes to a new value.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This Playlist implements some special handling for the Previous
Playlist. This includes adding a previous_tracks() function and
properties to indicate if the Playlist has a previous or next track.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
We need to do some bookkeeping inside the Playlist before notifying the
Factory that a track has been requested.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This property is updated whenever the items in the Playlist change or if
the current-track property is changed. It can be used to know in advance
if calling next_track() can be expected to return a valid Track
instance.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And add a "shuffle" property to the Playlist class. I use a TrackidSet
instance to keep track of which trackids have already been picked, and
to select a random trackid from the remaining options.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I add a "loop" property to the Playlist class that can be set to "None",
"Playlist", or "Track" (to match the MPRIS2 loop property). I can then
tune the behavior of next_track() based on how loop is configured.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This sets the current_trackid field on the database playlist object to
the trackid of the provided track.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The move_track_up() and move_track_down() functions are used to manually
arrange the tracks in a playlist.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This model builds on the TrackidModel to make it more Playlist and Track
focused instead of trackid centric.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The TrackidModel takes a TrackidSet and presents it as a Gio.ListModel
that maps trackids into Track objects. Tracks can be found by value
using the bisect() function, which sorts the trackids by number by
default (this can be changed by overriding the do_get_sort_key()
function).
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The playlist factory has properties for the currently selected,
currently active, and previous playlists. It will eventually create
Gio.ListModel instances representing the tracks in each of these playlists,
in sorted order.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Setting this to True will cause the Player to change state to PAUSED
during the next emission of the "file-loaded" signal.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I attach these to the Now Playing card so the "add to favorites" button
can be correctly marked as sensitive and enabled when a Track is
selected for playback.
Additionally, I look for a notification from the Track table to say it
has been loaded. This lets me set the Player to load up the current_track
if one is set.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This is much faster than removing tracks from their playlists one at a
time. I also clear and reload the Tracks table to clear out pointers to
old Tracks.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This includes both creating new Tracks and updating existing Tracks when
their tags have changed. New tracks are added to playlists using
idle=True so Gtk can spread out UI updates for each playlist so we don't
slow things down too much for the user.
This patch also adds a library argument to the Tagger thread
get_result() function which we pass to the Tagger class to be used by
Tracks.creat(). I also add an mtime argument to the Tagger thread
tag_file() function to pass down to the audio.tagger layer so we can
skip updating tracks that have not changed since the last scan.
Implements: #41 (Check for new or modified tags during startup)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I expand on the libraries_view to include additional playlist
properties, and configure the default sort order to sort by filepath.
I then set up the library_tracks_view to make it easy to select tracks
that belong to a specific Library.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I expand on the years_view to include additional playlist properties,
and configure the default sort order to stort by release date first.
I then set up the year_tracks_view to make it easy to select tracks that
belong to a specific year.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I expand on the decades_view to include additional playlist properties,
and configure the default sort order to sort by year first.
I then set up the decade_tracks_view to make it easy to select tracks
that belong to a specific decade.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I expand on the genres_view to include additional playlist properties,
and configure the default sort order to sort by artist, album, and track
number.
I then configure the Genres table to use the system_tracks table to
manage each genre's associated tracks and set up the genre_tracks_view
to make it easy for Tracks to find their Genres.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I expand on the media_view to include additional playlist properties,
and configure the default sort order to sort by track number.
I then set up the medium_tracks_view to make it easy to select tracks
that belong to a specific medium.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I expand on the albums_view to include additional playlist properties,
and configure the default sort order to sort by track numbers in an
intuitive way.
I then set up the album_tracks_view to make it easy to select tracks
that belong to a specific album.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I expand on the artists_view to include additional playlist properties,
and configure the default sort_order to sort albums in an intuitive way.
I then configure the Artists table to us the system_tracks table to
manage each artist's associated tracks and set up the artist_tracks_view
to make it easy for Tracks to find their Artists.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I need to do something slightly different for each Playlist.
* Collection: I load tracks from the collection_view, which filters
tracks to those where the library is enabled but not deleting.
* Favorite Tracks: I load tracks from the favorites_view, which filters
tracks based on the tracks.favorite and library.deleting column.
* Most Played Tracks: I load tracks with a playcount greater than the
average playcount of all tracks (rounded up to the nearest integer).
* New Tracks: I load tracks that have been added within the last week.
* Previous Tracks: I load tracks that have been played since startup
using the system_tracks table. I take care to clear these entries
in the table during startup.
* Queued Tracks: Load tracks from the user_tracks table.
* Unplayed Tracks: I load tracks with a playcount equal to 0 and remove
when they are played.
* User-Defined Playlists: Load tracks from the track_playlist_link
table.
Additionally, I implement move_track_up() and move_track_down() support
for user playlists and queued tracks.
Finally, I update the have-next-track property to take into account if
the Collection has tracks too.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I need to do something slightly different for each system Playlist:
* Collection: I disallow setting loop to "None".
* Favorite Tracks: I set the user-tracks property to "True"
* Most Played Tracks: I add playcount as the first sort field.
* Previous Tracks: I disallow changing loop, shuffle, and sort-order.
* Queued Tracks: I set the user-tracks and tracks-movable properties to "True"
User created playlists also set the user-tracks and tracks-movable
properties to "True". I also disable autodelete on the Table so
playlists aren't deleted unexpectedly.
New Tracks and Unplayed Tracks have no special properties set.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
* loop is based on the mpris loop property, and can be set to "None",
"Track", or "Playlist".
* shuffle is a boolean True / False value.
* sort-order saves a user-configured sort order for each playlist.
* current-trackid is an integer referring to the trackid of the currently
playing track.
* user-tracks: is a boolean representing if the user should be allowed
to manually add and remove tracks.
I also use the sort-order property to implement a get_track_order()
function to get the sort keys for tracks in a Playlist.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I implement add_track(), get_trackids(), and remove_track() functions that
either modify the 'system_playlist_tracks' table or call a virtual function
depending on the value of the 'system-tracks' property.
I also add the "autodelete" property. When set to True, Playlists will
be deleted when they have 0 tracks remaining.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Playlists use a tracks.TrackidSet to manage a set of trackids
representing the Tracks in this Playlist.
I have two functions for loading tracks: load_tracks() and
reload_tracks(). Calling load_tracks() checks if the tracks have been
loaded first before doing any work, but calling reload_tracks() will
force the Playlist to go to the database to load the latest tracks.
Finally, I add a have-next-track property to the main database
connection. This is set to True whenever the active playlist has one or
more tracks.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>