sublime_music.ui.util module
- sublime_music.ui.util.async_callback(future_fn, before_download=None, on_failure=None)[source]
Defines the
async_callback
decorator.When a function is annotated with this decorator, the function becomes the done callback for the given result-generating lambda function. The annotated function will be called with the result of the Result generated by said lambda function.
- sublime_music.ui.util.diff_model_store(store_to_edit, new_store)[source]
The diff here is that if there are any differences, then we refresh the entire list. This is because it is too hard to do editing.
- sublime_music.ui.util.diff_song_store(store_to_edit, new_store)[source]
Diffing song stores is nice, because we can easily make edits by modifying the underlying store.
- sublime_music.ui.util.dot_join(*items)[source]
Joins the given strings with a dot character. Filters out
None
values.>>> dot_join(None, "foo", "bar", None, "baz") 'foo • bar • baz'
- sublime_music.ui.util.format_sequence_duration(duration)[source]
Formats duration in English.
>>> format_sequence_duration(timedelta(seconds=90)) '1 minute, 30 seconds' >>> format_sequence_duration(timedelta(seconds=(60 * 60 + 120))) '1 hour, 2 minutes' >>> format_sequence_duration(None) '0 seconds'
- Parameters
duration (Optional[datetime.timedelta]) –
- Return type
- sublime_music.ui.util.format_song_duration(duration_secs)[source]
Formats the song duration as mins:seconds with the seconds being zero-padded if necessary.
>>> format_song_duration(80) '1:20' >>> format_song_duration(62) '1:02' >>> format_song_duration(timedelta(seconds=68.2)) '1:08' >>> format_song_duration(None) '-:--'
- Parameters
duration_secs (Optional[Union[int, datetime.timedelta]]) –
- Return type
- sublime_music.ui.util.pluralize(string, number, pluralized_form=None)[source]
Pluralize the given string given the count as a number.
>>> pluralize('foo', 1) 'foo' >>> pluralize('foo', 2) 'foos' >>> pluralize('foo', 0) 'foos'
- sublime_music.ui.util.show_song_popover(song_ids, x, y, relative_to, offline_mode, position=<enum GTK_POS_BOTTOM of type Gtk.PositionType>, on_download_state_change=<function <lambda>>, on_remove_downloads_click=<function <lambda>>, on_playlist_state_change=<function <lambda>>, show_remove_from_playlist_button=False, extra_menu_items=None)[source]