Implement initial audiobook UX (some of which is a bit of a WIP).
- Renamed various components and moved them to src/components. - Renamed KOTO_PREFERRED_MODEL* to KOTO_PREFERRED_PLAYLIST* - Renamed koto string utility functions to always be prefixed with koto_utils_string_ for consistency. - Added configuration options for show / hiding various album information, as well as preferred sort type. - Changed db schema to reflect various metadata changes (sorry). - Implemented genre, narrator, year aggregation from KotoTrack to KotoAlbum for use in KotoAlbumInfo and audiobooks. - Rearchitected our playlist functionality for KotoAlbums to always have an inner KotoPlaylist that is used. - Added various getters / setters for new koto_album functionality. - Implement aggregation of KotoAlbum pointer aggregation in the KotoArtist as a GQueue and GListStore instead of GList so we can get all the albums associated with an artist and use the GListStore for the audiobook view. - Implement some initial album sorting in Artists (more work to do on this front). - Many improvements to file indexing logic for CD and position detection, various new koto_track_helpers. - Add new logic for knowing when to hide playlists given we generate them for each Album now. - Fix missing updates of KotoPlaylist in KotoNav. - Added playback position to KotoPlayerbar, renamed bar refs to self. - New Playlist state saving. - Updated track ticking logic for track in KotoPlaybackEngine. - Fixed playback position detection in our KotoPlaybackEngine by swapping from GST_FORMAT_DEFAULT to GST_FORMAT_TIME. - Changed our get_progress to divide by GST_SECOND. - Fixed missing type checks in various KotoPlaybackEngine functions. Fixes #13. Fixes #14. Fixes #15.
This commit is contained in:
parent
93f3f45adf
commit
77b4e900e6
86 changed files with 4926 additions and 824 deletions
|
@ -1,158 +0,0 @@
|
|||
/* koto-track-item.c
|
||||
*
|
||||
* Copyright 2021 Joshua Strobl
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtk-4.0/gtk/gtk.h>
|
||||
#include "indexer/structs.h"
|
||||
#include "playlist/add-remove-track-popover.h"
|
||||
#include "koto-button.h"
|
||||
#include "koto-track-item.h"
|
||||
|
||||
extern KotoAddRemoveTrackPopover * koto_add_remove_track_popup;
|
||||
|
||||
struct _KotoTrackItem {
|
||||
GtkBox parent_instance;
|
||||
KotoTrack * track;
|
||||
|
||||
GtkWidget * track_label;
|
||||
};
|
||||
|
||||
struct _KotoTrackItemClass {
|
||||
GtkBoxClass parent_class;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_TRACK,
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec * props[N_PROPERTIES] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(KotoTrackItem, koto_track_item, GTK_TYPE_BOX);
|
||||
|
||||
static void koto_track_item_get_property(
|
||||
GObject * obj,
|
||||
guint prop_id,
|
||||
GValue * val,
|
||||
GParamSpec * spec
|
||||
);
|
||||
|
||||
static void koto_track_item_set_property(
|
||||
GObject * obj,
|
||||
guint prop_id,
|
||||
const GValue * val,
|
||||
GParamSpec * spec
|
||||
);
|
||||
|
||||
static void koto_track_item_class_init(KotoTrackItemClass * c) {
|
||||
GObjectClass * gobject_class;
|
||||
|
||||
gobject_class = G_OBJECT_CLASS(c);
|
||||
gobject_class->set_property = koto_track_item_set_property;
|
||||
gobject_class->get_property = koto_track_item_get_property;
|
||||
|
||||
props[PROP_TRACK] = g_param_spec_object(
|
||||
"track",
|
||||
"Track",
|
||||
"Track",
|
||||
KOTO_TYPE_TRACK,
|
||||
G_PARAM_CONSTRUCT | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE
|
||||
);
|
||||
|
||||
g_object_class_install_properties(gobject_class, N_PROPERTIES, props);
|
||||
}
|
||||
|
||||
static void koto_track_item_get_property(
|
||||
GObject * obj,
|
||||
guint prop_id,
|
||||
GValue * val,
|
||||
GParamSpec * spec
|
||||
) {
|
||||
KotoTrackItem * self = KOTO_TRACK_ITEM(obj);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_TRACK:
|
||||
g_value_set_object(val, self->track);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void koto_track_item_set_property(
|
||||
GObject * obj,
|
||||
guint prop_id,
|
||||
const GValue * val,
|
||||
GParamSpec * spec
|
||||
) {
|
||||
KotoTrackItem * self = KOTO_TRACK_ITEM(obj);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_TRACK:
|
||||
koto_track_item_set_track(self, (KotoTrack*) g_value_get_object(val));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void koto_track_item_init(KotoTrackItem * self) {
|
||||
self->track_label = gtk_label_new(NULL); // Create with no track name
|
||||
gtk_label_set_xalign(GTK_LABEL(self->track_label), 0.0);
|
||||
|
||||
gtk_widget_add_css_class(GTK_WIDGET(self), "track-item");
|
||||
gtk_widget_set_hexpand(GTK_WIDGET(self), TRUE);
|
||||
gtk_widget_set_hexpand(GTK_WIDGET(self->track_label), TRUE);
|
||||
|
||||
gtk_box_prepend(GTK_BOX(self), self->track_label);
|
||||
}
|
||||
|
||||
KotoTrack * koto_track_item_get_track(KotoTrackItem * self) {
|
||||
if (!KOTO_IS_TRACK_ITEM(self)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return self->track;
|
||||
}
|
||||
|
||||
void koto_track_item_set_track(
|
||||
KotoTrackItem * self,
|
||||
KotoTrack * track
|
||||
) {
|
||||
if (track == NULL) { // Not a track
|
||||
return;
|
||||
}
|
||||
|
||||
self->track = track;
|
||||
gchar * track_name;
|
||||
|
||||
g_object_get(self->track, "parsed-name", &track_name, NULL);
|
||||
gtk_label_set_text(GTK_LABEL(self->track_label), track_name); // Update the text
|
||||
}
|
||||
|
||||
KotoTrackItem * koto_track_item_new(KotoTrack * track) {
|
||||
return g_object_new(
|
||||
KOTO_TYPE_TRACK_ITEM,
|
||||
"track",
|
||||
track,
|
||||
NULL
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue