Rename KotoIndexedFile and "files" to KotoIndexedTrack and "tracks"
This commit is contained in:
parent
cf81682f8c
commit
b6db2003b8
13 changed files with 126 additions and 134 deletions
|
@ -35,7 +35,7 @@ struct _KotoIndexedAlbum {
|
|||
|
||||
gchar *name;
|
||||
gchar *art_path;
|
||||
GHashTable *files;
|
||||
GHashTable *tracks;
|
||||
|
||||
gboolean has_album_art;
|
||||
gboolean do_initial_index;
|
||||
|
@ -120,24 +120,24 @@ static void koto_indexed_album_init(KotoIndexedAlbum *self) {
|
|||
self->has_album_art = FALSE;
|
||||
}
|
||||
|
||||
void koto_indexed_album_add_file(KotoIndexedAlbum *self, KotoIndexedFile *file) {
|
||||
if (file == NULL) { // Not a file
|
||||
void koto_indexed_album_add_file(KotoIndexedAlbum *self, KotoIndexedTrack *track) {
|
||||
if (track == NULL) { // Not a file
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->files == NULL) { // No HashTable yet
|
||||
self->files = g_hash_table_new(g_str_hash, g_str_equal); // Create a new HashTable
|
||||
if (self->tracks == NULL) { // No HashTable yet
|
||||
self->tracks = g_hash_table_new(g_str_hash, g_str_equal); // Create a new HashTable
|
||||
}
|
||||
|
||||
gchar *file_name;
|
||||
g_object_get(file, "parsed-name", &file_name, NULL);
|
||||
gchar *track_name;
|
||||
g_object_get(track, "parsed-name", &track_name, NULL);
|
||||
|
||||
if (g_hash_table_contains(self->files, file_name)) { // If we have this file already
|
||||
g_free(file_name);
|
||||
if (g_hash_table_contains(self->tracks, track_name)) { // If we have this file already
|
||||
g_free(track_name);
|
||||
return;
|
||||
}
|
||||
|
||||
g_hash_table_insert(self->files, file_name, file); // Add the file
|
||||
g_hash_table_insert(self->tracks, track_name, track); // Add the file
|
||||
}
|
||||
|
||||
void koto_indexed_album_commit(KotoIndexedAlbum *self) {
|
||||
|
@ -288,8 +288,8 @@ void koto_indexed_album_find_tracks(KotoIndexedAlbum *self, magic_t magic_cookie
|
|||
gchar **possible_cd_split = g_strsplit(full_path, appended_slash_to_path, -1); // Split based on the album path
|
||||
guint *cd = (guint*) 1;
|
||||
|
||||
gchar *file_with_cd_sep = g_strdup(possible_cd_split[1]); // Duplicate
|
||||
gchar **split_on_cd = g_strsplit(file_with_cd_sep, G_DIR_SEPARATOR_S, -1); // Split based on separator (e.g. / )
|
||||
gchar *track_with_cd_sep = g_strdup(possible_cd_split[1]); // Duplicate
|
||||
gchar **split_on_cd = g_strsplit(track_with_cd_sep, G_DIR_SEPARATOR_S, -1); // Split based on separator (e.g. / )
|
||||
|
||||
if (g_strv_length(split_on_cd) > 1) {
|
||||
gchar *cdd = g_strdup(split_on_cd[0]);
|
||||
|
@ -306,15 +306,15 @@ void koto_indexed_album_find_tracks(KotoIndexedAlbum *self, magic_t magic_cookie
|
|||
}
|
||||
|
||||
g_strfreev(split_on_cd);
|
||||
g_free(file_with_cd_sep);
|
||||
g_free(track_with_cd_sep);
|
||||
|
||||
g_strfreev(possible_cd_split);
|
||||
g_free(appended_slash_to_path);
|
||||
|
||||
KotoIndexedFile *file = koto_indexed_file_new(self, full_path, cd);
|
||||
KotoIndexedTrack *track = koto_indexed_track_new(self, full_path, cd);
|
||||
|
||||
if (file != NULL) { // Is a file
|
||||
koto_indexed_album_add_file(self, file); // Add our file
|
||||
if (track != NULL) { // Is a file
|
||||
koto_indexed_album_add_file(self, track); // Add our file
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,11 +355,11 @@ gchar* koto_indexed_album_get_album_art(KotoIndexedAlbum *self) {
|
|||
}
|
||||
|
||||
GList* koto_indexed_album_get_files(KotoIndexedAlbum *self) {
|
||||
if (self->files == NULL) { // No HashTable yet
|
||||
self->files = g_hash_table_new(g_str_hash, g_str_equal); // Create a new HashTable
|
||||
if (self->tracks == NULL) { // No HashTable yet
|
||||
self->tracks = g_hash_table_new(g_str_hash, g_str_equal); // Create a new HashTable
|
||||
}
|
||||
|
||||
return g_hash_table_get_values(self->files);
|
||||
return g_hash_table_get_values(self->tracks);
|
||||
}
|
||||
|
||||
void koto_indexed_album_set_album_art(KotoIndexedAlbum *self, const gchar *album_art) {
|
||||
|
@ -376,27 +376,27 @@ void koto_indexed_album_set_album_art(KotoIndexedAlbum *self, const gchar *album
|
|||
self->has_album_art = TRUE;
|
||||
}
|
||||
|
||||
void koto_indexed_album_remove_file(KotoIndexedAlbum *self, KotoIndexedFile *file) {
|
||||
if (file == NULL) { // Not a file
|
||||
void koto_indexed_album_remove_file(KotoIndexedAlbum *self, KotoIndexedTrack *track) {
|
||||
if (track == NULL) { // Not a file
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->files == NULL) { // No HashTable yet
|
||||
self->files = g_hash_table_new(g_str_hash, g_str_equal); // Create a new HashTable
|
||||
if (self->tracks == NULL) { // No HashTable yet
|
||||
self->tracks = g_hash_table_new(g_str_hash, g_str_equal); // Create a new HashTable
|
||||
}
|
||||
|
||||
gchar *file_name;
|
||||
g_object_get(file, "parsed-name", &file_name, NULL);
|
||||
g_hash_table_remove(self->files, file_name);
|
||||
gchar *track_name;
|
||||
g_object_get(track, "parsed-name", &track_name, NULL);
|
||||
g_hash_table_remove(self->tracks, track_name);
|
||||
}
|
||||
|
||||
void koto_indexed_album_remove_file_by_name(KotoIndexedAlbum *self, const gchar *file_name) {
|
||||
if (file_name == NULL) {
|
||||
void koto_indexed_album_remove_file_by_name(KotoIndexedAlbum *self, const gchar *track_name) {
|
||||
if (track_name == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
KotoIndexedFile *file = g_hash_table_lookup(self->files, file_name); // Get the files
|
||||
koto_indexed_album_remove_file(self, file);
|
||||
KotoIndexedTrack *track = g_hash_table_lookup(self->tracks, track_name); // Get the files
|
||||
koto_indexed_album_remove_file(self, track);
|
||||
}
|
||||
|
||||
void koto_indexed_album_set_album_name(KotoIndexedAlbum *self, const gchar *album_name) {
|
||||
|
@ -412,13 +412,13 @@ void koto_indexed_album_set_album_name(KotoIndexedAlbum *self, const gchar *albu
|
|||
}
|
||||
|
||||
void koto_indexed_album_set_as_current_playlist(KotoIndexedAlbum *self) {
|
||||
if (self->files == NULL) { // No files to add to the playlist
|
||||
if (self->tracks == NULL) { // No files to add to the playlist
|
||||
return;
|
||||
}
|
||||
|
||||
KotoPlaylist *new_album_playlist = koto_playlist_new(); // Create a new playlist
|
||||
|
||||
GList *tracks_list_uuids = g_hash_table_get_keys(self->files); // Get the UUIDs
|
||||
GList *tracks_list_uuids = g_hash_table_get_keys(self->tracks); // Get the UUIDs
|
||||
for (guint i = 0; i < g_list_length(tracks_list_uuids); i++) { // For each of the tracks
|
||||
koto_playlist_add_track_by_uuid(new_album_playlist, (gchar*) g_list_nth_data(tracks_list_uuids, i)); // Add the UUID
|
||||
}
|
||||
|
|
|
@ -244,8 +244,8 @@ int process_tracks(void *data, int num_columns, char **fields, char **column_nam
|
|||
guint *disc_num = (guint*) g_ascii_strtoull(fields[6], NULL, 10);
|
||||
guint *position = (guint*) g_ascii_strtoull(fields[7], NULL, 10);
|
||||
|
||||
KotoIndexedFile *file = koto_indexed_file_new_with_uuid(track_uuid); // Create our file
|
||||
g_object_set(file,
|
||||
KotoIndexedTrack *track = koto_indexed_track_new_with_uuid(track_uuid); // Create our file
|
||||
g_object_set(track,
|
||||
"artist-uuid", artist_uuid,
|
||||
"album-uuid", album_uuid,
|
||||
"path", path,
|
||||
|
@ -255,7 +255,7 @@ int process_tracks(void *data, int num_columns, char **fields, char **column_nam
|
|||
"position", position,
|
||||
NULL);
|
||||
|
||||
koto_indexed_album_add_file(album, file); // Add the file
|
||||
koto_indexed_album_add_file(album, track); // Add the file
|
||||
|
||||
g_free(track_uuid);
|
||||
g_free(path);
|
||||
|
@ -389,16 +389,16 @@ void output_artists(gpointer artist_key, gpointer artist_ptr, gpointer data) {
|
|||
g_debug("Album Art: %s", artwork);
|
||||
g_debug("Album Name: %s", album_name);
|
||||
|
||||
GList *files = koto_indexed_album_get_files(album); // Get the files for the album
|
||||
GList *f;
|
||||
GList *tracks = koto_indexed_album_get_files(album); // Get the files for the album
|
||||
GList *t;
|
||||
|
||||
for (f = files; f != NULL; f = f->next) {
|
||||
KotoIndexedFile *file = (KotoIndexedFile*) f->data;
|
||||
for (t = tracks; t != NULL; t = t->next) {
|
||||
KotoIndexedTrack *track = (KotoIndexedTrack*) t->data;
|
||||
gchar *filepath;
|
||||
gchar *parsed_name;
|
||||
guint *pos;
|
||||
|
||||
g_object_get(file,
|
||||
g_object_get(track,
|
||||
"path", &filepath,
|
||||
"parsed-name", &parsed_name,
|
||||
"position", &pos,
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
indexer_sources = [
|
||||
'file.c',
|
||||
'file-indexer.c',
|
||||
]
|
||||
|
||||
indexer_deps = [
|
||||
dependency('glib-2.0', version: '>= 2.66'),
|
||||
dependency('gio-2.0', version: '>= 2.66'),
|
||||
]
|
|
@ -34,8 +34,8 @@ G_DECLARE_FINAL_TYPE (KotoIndexedArtist, koto_indexed_artist, KOTO, INDEXED_ARTI
|
|||
#define KOTO_TYPE_INDEXED_ALBUM koto_indexed_album_get_type()
|
||||
G_DECLARE_FINAL_TYPE (KotoIndexedAlbum, koto_indexed_album, KOTO, INDEXED_ALBUM, GObject);
|
||||
|
||||
#define KOTO_TYPE_INDEXED_FILE koto_indexed_file_get_type()
|
||||
G_DECLARE_FINAL_TYPE(KotoIndexedFile, koto_indexed_file, KOTO, INDEXED_FILE, GObject);
|
||||
#define KOTO_TYPE_INDEXED_TRACK koto_indexed_track_get_type()
|
||||
G_DECLARE_FINAL_TYPE(KotoIndexedTrack, koto_indexed_track, KOTO, INDEXED_TRACK, GObject);
|
||||
|
||||
/**
|
||||
* Library Functions
|
||||
|
@ -80,14 +80,14 @@ void output_artists(gpointer artist_key, gpointer artist_ptr, gpointer data);
|
|||
KotoIndexedAlbum* koto_indexed_album_new(KotoIndexedArtist *artist, const gchar *path);
|
||||
KotoIndexedAlbum* koto_indexed_album_new_with_uuid(KotoIndexedArtist *artist, const gchar *uuid);
|
||||
|
||||
void koto_indexed_album_add_file(KotoIndexedAlbum *self, KotoIndexedFile *file);
|
||||
void koto_indexed_album_add_file(KotoIndexedAlbum *self, KotoIndexedTrack *track);
|
||||
void koto_indexed_album_commit(KotoIndexedAlbum *self);
|
||||
void koto_indexed_album_find_album_art(KotoIndexedAlbum *self);
|
||||
void koto_indexed_album_find_tracks(KotoIndexedAlbum *self, magic_t magic_cookie, const gchar *path);
|
||||
gchar* koto_indexed_album_get_album_art(KotoIndexedAlbum *self);
|
||||
GList* koto_indexed_album_get_files(KotoIndexedAlbum *self);
|
||||
void koto_indexed_album_remove_file(KotoIndexedAlbum *self, KotoIndexedFile *file);
|
||||
void koto_indexed_album_remove_file_by_name(KotoIndexedAlbum *self, const gchar *file_name);
|
||||
void koto_indexed_album_remove_file(KotoIndexedAlbum *self, KotoIndexedTrack *track);
|
||||
void koto_indexed_album_remove_file_by_name(KotoIndexedAlbum *self, const gchar *track_name);
|
||||
void koto_indexed_album_set_album_art(KotoIndexedAlbum *self, const gchar *album_art);
|
||||
void koto_indexed_album_set_album_name(KotoIndexedAlbum *self, const gchar *album_name);
|
||||
void koto_indexed_album_set_as_current_playlist(KotoIndexedAlbum *self);
|
||||
|
@ -97,16 +97,16 @@ void koto_indexed_album_update_path(KotoIndexedAlbum *self, const gchar *path);
|
|||
* File / Track Functions
|
||||
**/
|
||||
|
||||
KotoIndexedFile* koto_indexed_file_new(KotoIndexedAlbum *album, const gchar *path, guint *cd);
|
||||
KotoIndexedFile* koto_indexed_file_new_with_uuid(const gchar *uuid);
|
||||
KotoIndexedTrack* koto_indexed_track_new(KotoIndexedAlbum *album, const gchar *path, guint *cd);
|
||||
KotoIndexedTrack* koto_indexed_track_new_with_uuid(const gchar *uuid);
|
||||
|
||||
void koto_indexed_file_commit(KotoIndexedFile *self);
|
||||
void koto_indexed_file_parse_name(KotoIndexedFile *self);
|
||||
void koto_indexed_file_set_file_name(KotoIndexedFile *self, gchar *new_file_name);
|
||||
void koto_indexed_file_set_cd(KotoIndexedFile *self, guint cd);
|
||||
void koto_indexed_file_set_parsed_name(KotoIndexedFile *self, gchar *new_parsed_name);
|
||||
void koto_indexed_file_set_position(KotoIndexedFile *self, guint pos);
|
||||
void koto_indexed_file_update_metadata(KotoIndexedFile *self);
|
||||
void koto_indexed_file_update_path(KotoIndexedFile *self, const gchar *new_path);
|
||||
void koto_indexed_track_commit(KotoIndexedTrack *self);
|
||||
void koto_indexed_track_parse_name(KotoIndexedTrack *self);
|
||||
void koto_indexed_track_set_file_name(KotoIndexedTrack *self, gchar *new_file_name);
|
||||
void koto_indexed_track_set_cd(KotoIndexedTrack *self, guint cd);
|
||||
void koto_indexed_track_set_parsed_name(KotoIndexedTrack *self, gchar *new_parsed_name);
|
||||
void koto_indexed_track_set_position(KotoIndexedTrack *self, guint pos);
|
||||
void koto_indexed_track_update_metadata(KotoIndexedTrack *self);
|
||||
void koto_indexed_track_update_path(KotoIndexedTrack *self, const gchar *new_path);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
extern sqlite3 *koto_db;
|
||||
|
||||
struct _KotoIndexedFile {
|
||||
struct _KotoIndexedTrack {
|
||||
GObject parent_instance;
|
||||
gchar *artist_uuid;
|
||||
gchar *album_uuid;
|
||||
|
@ -41,7 +41,7 @@ struct _KotoIndexedFile {
|
|||
gboolean do_initial_index;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(KotoIndexedFile, koto_indexed_file, G_TYPE_OBJECT);
|
||||
G_DEFINE_TYPE(KotoIndexedTrack, koto_indexed_track, G_TYPE_OBJECT);
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
@ -61,14 +61,14 @@ enum {
|
|||
|
||||
static GParamSpec *props[N_PROPERTIES] = { NULL };
|
||||
|
||||
static void koto_indexed_file_get_property(GObject *obj, guint prop_id, GValue *val, GParamSpec *spec);
|
||||
static void koto_indexed_file_set_property(GObject *obj, guint prop_id, const GValue *val, GParamSpec *spec);
|
||||
static void koto_indexed_track_get_property(GObject *obj, guint prop_id, GValue *val, GParamSpec *spec);
|
||||
static void koto_indexed_track_set_property(GObject *obj, guint prop_id, const GValue *val, GParamSpec *spec);
|
||||
|
||||
static void koto_indexed_file_class_init(KotoIndexedFileClass *c) {
|
||||
static void koto_indexed_track_class_init(KotoIndexedTrackClass *c) {
|
||||
GObjectClass *gobject_class;
|
||||
gobject_class = G_OBJECT_CLASS(c);
|
||||
gobject_class->set_property = koto_indexed_file_set_property;
|
||||
gobject_class->get_property = koto_indexed_file_get_property;
|
||||
gobject_class->set_property = koto_indexed_track_set_property;
|
||||
gobject_class->get_property = koto_indexed_track_get_property;
|
||||
|
||||
props[PROP_ARTIST_UUID] = g_param_spec_string(
|
||||
"artist-uuid",
|
||||
|
@ -165,12 +165,12 @@ static void koto_indexed_file_class_init(KotoIndexedFileClass *c) {
|
|||
g_object_class_install_properties(gobject_class, N_PROPERTIES, props);
|
||||
}
|
||||
|
||||
static void koto_indexed_file_init(KotoIndexedFile *self) {
|
||||
static void koto_indexed_track_init(KotoIndexedTrack *self) {
|
||||
self->acquired_metadata_from_id3 = FALSE;
|
||||
}
|
||||
|
||||
static void koto_indexed_file_get_property(GObject *obj, guint prop_id, GValue *val, GParamSpec *spec) {
|
||||
KotoIndexedFile *self = KOTO_INDEXED_FILE(obj);
|
||||
static void koto_indexed_track_get_property(GObject *obj, guint prop_id, GValue *val, GParamSpec *spec) {
|
||||
KotoIndexedTrack *self = KOTO_INDEXED_TRACK(obj);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_ARTIST_UUID:
|
||||
|
@ -209,8 +209,8 @@ static void koto_indexed_file_get_property(GObject *obj, guint prop_id, GValue *
|
|||
}
|
||||
}
|
||||
|
||||
static void koto_indexed_file_set_property(GObject *obj, guint prop_id, const GValue *val, GParamSpec *spec) {
|
||||
KotoIndexedFile *self = KOTO_INDEXED_FILE(obj);
|
||||
static void koto_indexed_track_set_property(GObject *obj, guint prop_id, const GValue *val, GParamSpec *spec) {
|
||||
KotoIndexedTrack *self = KOTO_INDEXED_TRACK(obj);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_ARTIST_UUID:
|
||||
|
@ -235,19 +235,19 @@ static void koto_indexed_file_set_property(GObject *obj, guint prop_id, const GV
|
|||
self->album = g_strdup(g_value_get_string(val));
|
||||
break;
|
||||
case PROP_PATH:
|
||||
koto_indexed_file_update_path(self, g_value_get_string(val)); // Update the path
|
||||
koto_indexed_track_update_path(self, g_value_get_string(val)); // Update the path
|
||||
break;
|
||||
case PROP_FILE_NAME:
|
||||
koto_indexed_file_set_file_name(self, g_strdup(g_value_get_string(val))); // Update the file name
|
||||
koto_indexed_track_set_file_name(self, g_strdup(g_value_get_string(val))); // Update the file name
|
||||
break;
|
||||
case PROP_PARSED_NAME:
|
||||
koto_indexed_file_set_parsed_name(self, g_strdup(g_value_get_string(val)));
|
||||
koto_indexed_track_set_parsed_name(self, g_strdup(g_value_get_string(val)));
|
||||
break;
|
||||
case PROP_CD:
|
||||
koto_indexed_file_set_cd(self, g_value_get_uint(val));
|
||||
koto_indexed_track_set_cd(self, g_value_get_uint(val));
|
||||
break;
|
||||
case PROP_POSITION:
|
||||
koto_indexed_file_set_position(self, g_value_get_uint(val));
|
||||
koto_indexed_track_set_position(self, g_value_get_uint(val));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec);
|
||||
|
@ -256,7 +256,7 @@ static void koto_indexed_file_set_property(GObject *obj, guint prop_id, const GV
|
|||
}
|
||||
|
||||
|
||||
void koto_indexed_file_commit(KotoIndexedFile *self) {
|
||||
void koto_indexed_track_commit(KotoIndexedTrack *self) {
|
||||
if ((self->artist_uuid == NULL) || (strcmp(self->artist_uuid, "") == 0)) { // No valid required artist UUID
|
||||
return;
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ void koto_indexed_file_commit(KotoIndexedFile *self) {
|
|||
g_free(commit_op_errmsg);
|
||||
}
|
||||
|
||||
void koto_indexed_file_parse_name(KotoIndexedFile *self) {
|
||||
void koto_indexed_track_parse_name(KotoIndexedTrack *self) {
|
||||
gchar *copied_file_name = g_strdelimit(g_strdup(self->file_name), "_", ' '); // Replace _ with whitespace for starters
|
||||
|
||||
if (self->artist != NULL && strcmp(self->artist, "") != 0) { // If we have artist set
|
||||
|
@ -315,12 +315,12 @@ void koto_indexed_file_parse_name(KotoIndexedFile *self) {
|
|||
file_without_ext = g_strdup(split[2]); // Set to our second item which is the rest of the song name without the prefixed numbers
|
||||
|
||||
if ((strcmp(num, "0") == 0) || (strcmp(num, "00") == 0)) { // Is exactly zero
|
||||
koto_indexed_file_set_position(self, 0); // Set position to 0
|
||||
koto_indexed_track_set_position(self, 0); // Set position to 0
|
||||
} else { // Either starts with 0 (like 09) or doesn't start with it at all
|
||||
guint64 potential_pos = g_ascii_strtoull(num, NULL, 10); // Attempt to convert
|
||||
|
||||
if (potential_pos != 0) { // Got a legitimate position
|
||||
koto_indexed_file_set_position(self, potential_pos);
|
||||
koto_indexed_track_set_position(self, potential_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -335,11 +335,11 @@ void koto_indexed_file_parse_name(KotoIndexedFile *self) {
|
|||
file_without_ext = g_strjoinv("", split); // Remove entirely
|
||||
g_strfreev(split);
|
||||
|
||||
koto_indexed_file_set_parsed_name(self, file_without_ext);
|
||||
koto_indexed_track_set_parsed_name(self, file_without_ext);
|
||||
g_free(file_without_ext);
|
||||
}
|
||||
|
||||
void koto_indexed_file_set_file_name(KotoIndexedFile *self, gchar *new_file_name) {
|
||||
void koto_indexed_track_set_file_name(KotoIndexedTrack *self, gchar *new_file_name) {
|
||||
if (new_file_name == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -356,11 +356,11 @@ void koto_indexed_file_set_file_name(KotoIndexedFile *self, gchar *new_file_name
|
|||
g_object_notify_by_pspec(G_OBJECT(self), props[PROP_FILE_NAME]);
|
||||
|
||||
if (!self->acquired_metadata_from_id3 && self->do_initial_index) { // Haven't acquired our information from ID3
|
||||
koto_indexed_file_parse_name(self); // Update our parsed name
|
||||
koto_indexed_track_parse_name(self); // Update our parsed name
|
||||
}
|
||||
}
|
||||
|
||||
void koto_indexed_file_set_cd(KotoIndexedFile *self, guint cd) {
|
||||
void koto_indexed_track_set_cd(KotoIndexedTrack *self, guint cd) {
|
||||
if (cd == 0) { // No change really
|
||||
return;
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ void koto_indexed_file_set_cd(KotoIndexedFile *self, guint cd) {
|
|||
g_object_notify_by_pspec(G_OBJECT(self), props[PROP_CD]);
|
||||
}
|
||||
|
||||
void koto_indexed_file_set_parsed_name(KotoIndexedFile *self, gchar *new_parsed_name) {
|
||||
void koto_indexed_track_set_parsed_name(KotoIndexedTrack *self, gchar *new_parsed_name) {
|
||||
if (new_parsed_name == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ void koto_indexed_file_set_parsed_name(KotoIndexedFile *self, gchar *new_parsed_
|
|||
g_object_notify_by_pspec(G_OBJECT(self), props[PROP_PARSED_NAME]);
|
||||
}
|
||||
|
||||
void koto_indexed_file_set_position(KotoIndexedFile *self, guint pos) {
|
||||
void koto_indexed_track_set_position(KotoIndexedTrack *self, guint pos) {
|
||||
if (pos == 0) { // No position change really
|
||||
return;
|
||||
}
|
||||
|
@ -395,25 +395,25 @@ void koto_indexed_file_set_position(KotoIndexedFile *self, guint pos) {
|
|||
g_object_notify_by_pspec(G_OBJECT(self), props[PROP_POSITION]);
|
||||
}
|
||||
|
||||
void koto_indexed_file_update_metadata(KotoIndexedFile *self) {
|
||||
void koto_indexed_track_update_metadata(KotoIndexedTrack *self) {
|
||||
TagLib_File *t_file = taglib_file_new(self->path); // Get a taglib file for this file
|
||||
|
||||
if ((t_file != NULL) && taglib_file_is_valid(t_file)) { // If we got the taglib file and it is valid
|
||||
self->acquired_metadata_from_id3 = TRUE;
|
||||
TagLib_Tag *tag = taglib_file_tag(t_file); // Get our tag
|
||||
koto_indexed_file_set_parsed_name(self, taglib_tag_title(tag)); // Set the title of the file
|
||||
koto_indexed_track_set_parsed_name(self, taglib_tag_title(tag)); // Set the title of the file
|
||||
self->artist = g_strdup(taglib_tag_artist((tag))); // Set the artist
|
||||
self->album = g_strdup(taglib_tag_album(tag)); // Set the album
|
||||
koto_indexed_file_set_position(self, (uint) taglib_tag_track(tag)); // Get the track, convert to uint and cast as a pointer
|
||||
koto_indexed_track_set_position(self, (uint) taglib_tag_track(tag)); // Get the track, convert to uint and cast as a pointer
|
||||
} else {
|
||||
koto_indexed_file_set_file_name(self, g_path_get_basename(self->path)); // Update our file name
|
||||
koto_indexed_track_set_file_name(self, g_path_get_basename(self->path)); // Update our file name
|
||||
}
|
||||
|
||||
taglib_tag_free_strings(); // Free strings
|
||||
taglib_file_free(t_file); // Free the file
|
||||
}
|
||||
|
||||
void koto_indexed_file_update_path(KotoIndexedFile *self, const gchar *new_path) {
|
||||
void koto_indexed_track_update_path(KotoIndexedTrack *self, const gchar *new_path) {
|
||||
if (new_path == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -425,13 +425,13 @@ void koto_indexed_file_update_path(KotoIndexedFile *self, const gchar *new_path)
|
|||
self->path = g_strdup(new_path); // Duplicate the path and set it
|
||||
|
||||
if (self->do_initial_index) {
|
||||
koto_indexed_file_update_metadata(self); // Attempt to get ID3 info
|
||||
koto_indexed_track_update_metadata(self); // Attempt to get ID3 info
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec(G_OBJECT(self), props[PROP_PATH]);
|
||||
}
|
||||
|
||||
KotoIndexedFile* koto_indexed_file_new(KotoIndexedAlbum *album, const gchar *path, guint *cd) {
|
||||
KotoIndexedTrack* koto_indexed_track_new(KotoIndexedAlbum *album, const gchar *path, guint *cd) {
|
||||
KotoIndexedArtist *artist;
|
||||
|
||||
gchar *artist_uuid;
|
||||
|
@ -450,7 +450,7 @@ KotoIndexedFile* koto_indexed_file_new(KotoIndexedAlbum *album, const gchar *pat
|
|||
"uuid", &album_uuid, // Get the album UUID from the album
|
||||
NULL);
|
||||
|
||||
KotoIndexedFile *file = g_object_new(KOTO_TYPE_INDEXED_FILE,
|
||||
KotoIndexedTrack *track = g_object_new(KOTO_TYPE_INDEXED_TRACK,
|
||||
"artist-uuid", artist_uuid,
|
||||
"album-uuid", album_uuid,
|
||||
"artist", artist_name,
|
||||
|
@ -462,12 +462,12 @@ KotoIndexedFile* koto_indexed_file_new(KotoIndexedAlbum *album, const gchar *pat
|
|||
NULL
|
||||
);
|
||||
|
||||
koto_indexed_file_commit(file); // Immediately commit to the database
|
||||
return file;
|
||||
koto_indexed_track_commit(track); // Immediately commit to the database
|
||||
return track;
|
||||
}
|
||||
|
||||
KotoIndexedFile* koto_indexed_file_new_with_uuid(const gchar *uuid) {
|
||||
return g_object_new(KOTO_TYPE_INDEXED_FILE,
|
||||
KotoIndexedTrack* koto_indexed_track_new_with_uuid(const gchar *uuid) {
|
||||
return g_object_new(KOTO_TYPE_INDEXED_TRACK,
|
||||
"uuid", g_strdup(uuid),
|
||||
NULL
|
||||
);
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
struct _KotoTrackItem {
|
||||
GtkBox parent_instance;
|
||||
KotoIndexedFile *track;
|
||||
KotoIndexedTrack *track;
|
||||
|
||||
GtkWidget *track_label;
|
||||
KotoButton *add_to_playlist_button;
|
||||
|
@ -54,7 +54,7 @@ static void koto_track_item_class_init(KotoTrackItemClass *c) {
|
|||
"track",
|
||||
"Track",
|
||||
"Track",
|
||||
KOTO_TYPE_INDEXED_FILE,
|
||||
KOTO_TYPE_INDEXED_TRACK,
|
||||
G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_READWRITE
|
||||
);
|
||||
|
||||
|
@ -79,7 +79,7 @@ static void koto_track_item_set_property(GObject *obj, guint prop_id, const GVal
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_TRACK:
|
||||
koto_track_item_set_track(self, (KotoIndexedFile*) g_value_get_object(val));
|
||||
koto_track_item_set_track(self, (KotoIndexedTrack*) g_value_get_object(val));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec);
|
||||
|
@ -101,21 +101,21 @@ static void koto_track_item_init(KotoTrackItem *self) {
|
|||
gtk_box_append(GTK_BOX(self), GTK_WIDGET(self->add_to_playlist_button));
|
||||
}
|
||||
|
||||
void koto_track_item_set_track(KotoTrackItem *self, KotoIndexedFile *file) {
|
||||
if (file == NULL) { // Not a file
|
||||
void koto_track_item_set_track(KotoTrackItem *self, KotoIndexedTrack *track) {
|
||||
if (track == NULL) { // Not a track
|
||||
return;
|
||||
}
|
||||
|
||||
self->track = file;
|
||||
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(KotoIndexedFile *file) {
|
||||
KotoTrackItem* koto_track_item_new(KotoIndexedTrack *track) {
|
||||
return g_object_new(KOTO_TYPE_TRACK_ITEM,
|
||||
"track",
|
||||
file,
|
||||
track,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ G_BEGIN_DECLS
|
|||
|
||||
G_DECLARE_FINAL_TYPE(KotoTrackItem, koto_track_item, KOTO, TRACK_ITEM, GtkBox)
|
||||
|
||||
KotoTrackItem* koto_track_item_new(KotoIndexedFile *file);
|
||||
void koto_track_item_set_track(KotoTrackItem *self, KotoIndexedFile *file);
|
||||
KotoTrackItem* koto_track_item_new(KotoIndexedTrack *track);
|
||||
void koto_track_item_set_track(KotoTrackItem *self, KotoIndexedTrack *track);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -4,8 +4,8 @@ koto_sources = [
|
|||
'db/db.c',
|
||||
'indexer/album.c',
|
||||
'indexer/artist.c',
|
||||
'indexer/file.c',
|
||||
'indexer/file-indexer.c',
|
||||
'indexer/track.c',
|
||||
'pages/music/album-view.c',
|
||||
'pages/music/artist-view.c',
|
||||
'pages/music/disc-view.c',
|
||||
|
|
|
@ -148,8 +148,8 @@ static void koto_album_view_set_property(GObject *obj, guint prop_id, const GVal
|
|||
}
|
||||
}
|
||||
|
||||
void koto_album_view_add_track_to_listbox(KotoIndexedAlbum *self, KotoIndexedFile *file) {
|
||||
(void) self; (void) file;
|
||||
void koto_album_view_add_track_to_listbox(KotoIndexedAlbum *self, KotoIndexedTrack *track) {
|
||||
(void) self; (void) track;
|
||||
}
|
||||
|
||||
void koto_album_view_hide_overlay_controls(GtkEventControllerFocus *controller, gpointer data) {
|
||||
|
@ -179,9 +179,9 @@ void koto_album_view_set_album(KotoAlbumView *self, KotoIndexedAlbum *album) {
|
|||
GList *tracks = koto_indexed_album_get_files(album); // Get the tracks for this album
|
||||
|
||||
for (guint i = 0; i < g_list_length(tracks); i++) {
|
||||
KotoIndexedFile *file = (KotoIndexedFile*) g_list_nth_data(tracks, i); // Get the
|
||||
KotoIndexedTrack *track = (KotoIndexedTrack*) g_list_nth_data(tracks, i); // Get the
|
||||
guint *disc_number;
|
||||
g_object_get(file, "cd", &disc_number, NULL);
|
||||
g_object_get(track, "cd", &disc_number, NULL);
|
||||
gchar *disc_num_as_str = g_strdup_printf("%u", GPOINTER_TO_UINT(disc_number));
|
||||
|
||||
if (g_hash_table_contains(discs, disc_num_as_str)) { // Already have this added
|
||||
|
|
|
@ -29,7 +29,7 @@ G_DECLARE_FINAL_TYPE(KotoAlbumView, koto_album_view, KOTO, ALBUM_VIEW, GObject)
|
|||
|
||||
KotoAlbumView* koto_album_view_new(KotoIndexedAlbum *album);
|
||||
GtkWidget* koto_album_view_get_main(KotoAlbumView *self);
|
||||
void koto_album_view_add_track_to_listbox(KotoIndexedAlbum *self, KotoIndexedFile *file);
|
||||
void koto_album_view_add_track_to_listbox(KotoIndexedAlbum *self, KotoIndexedTrack *track);
|
||||
void koto_album_view_hide_overlay_controls(GtkEventControllerFocus *controller, gpointer data);
|
||||
void koto_album_view_set_album(KotoAlbumView *self, KotoIndexedAlbum *album);
|
||||
void koto_album_view_show_overlay_controls(GtkEventControllerFocus *controller, gpointer data);
|
||||
|
|
|
@ -145,16 +145,16 @@ void koto_disc_view_set_album(KotoDiscView *self, KotoIndexedAlbum *album) {
|
|||
|
||||
GList *t;
|
||||
for (t = koto_indexed_album_get_files(self->album); t != NULL; t = t->next) { // For each file / track
|
||||
KotoIndexedFile *file = (KotoIndexedFile*) t->data;
|
||||
KotoIndexedTrack *track = (KotoIndexedTrack*) t->data;
|
||||
|
||||
guint *disc_number;
|
||||
g_object_get(file, "cd", &disc_number, NULL); // get the disc number
|
||||
g_object_get(track, "cd", &disc_number, NULL); // get the disc number
|
||||
|
||||
if (GPOINTER_TO_UINT(self->disc_number) != GPOINTER_TO_UINT(disc_number)) { // Track does not belong to this CD
|
||||
continue;
|
||||
}
|
||||
|
||||
KotoTrackItem *track_item = koto_track_item_new(file); // Create our new track item
|
||||
KotoTrackItem *track_item = koto_track_item_new(track); // Create our new track item
|
||||
gtk_list_box_prepend(GTK_LIST_BOX(self->list), GTK_WIDGET(track_item)); // Add to our tracks list box
|
||||
}
|
||||
}
|
||||
|
@ -181,8 +181,8 @@ int koto_album_view_sort_tracks(GtkListBoxRow *track1, GtkListBoxRow *track2, gp
|
|||
KotoTrackItem *track1_item = KOTO_TRACK_ITEM(gtk_list_box_row_get_child(track1));
|
||||
KotoTrackItem *track2_item = KOTO_TRACK_ITEM(gtk_list_box_row_get_child(track2));
|
||||
|
||||
KotoIndexedFile *track1_file;
|
||||
KotoIndexedFile *track2_file;
|
||||
KotoIndexedTrack *track1_file;
|
||||
KotoIndexedTrack *track2_file;
|
||||
|
||||
g_object_get(track1_item, "track", &track1_file, NULL);
|
||||
g_object_get(track2_item, "track", &track2_file, NULL);
|
||||
|
|
|
@ -122,9 +122,9 @@ static void koto_playlist_init(KotoPlaylist *self) {
|
|||
self->tracks = g_queue_new(); // Set as an empty GQueue
|
||||
}
|
||||
|
||||
void koto_playlist_add_track(KotoPlaylist *self, KotoIndexedFile *file) {
|
||||
void koto_playlist_add_track(KotoPlaylist *self, KotoIndexedTrack *track) {
|
||||
gchar *uuid = NULL;
|
||||
g_object_get(file, "uuid", &uuid, NULL); // Get the UUID
|
||||
g_object_get(track, "uuid", &uuid, NULL); // Get the UUID
|
||||
koto_playlist_add_track_by_uuid(self, uuid); // Add by the file's UUID
|
||||
}
|
||||
|
||||
|
@ -195,15 +195,16 @@ gchar* koto_playlist_go_to_previous(KotoPlaylist *self) {
|
|||
return koto_playlist_get_current_uuid(self); // Return the new UUID
|
||||
}
|
||||
|
||||
void koto_playlist_remove_track(KotoPlaylist *self, KotoIndexedFile *file) {
|
||||
gchar *file_uuid = NULL;
|
||||
g_object_get(file, "uuid", &file_uuid, NULL);
|
||||
void koto_playlist_remove_track(KotoPlaylist *self, KotoIndexedTrack *track) {
|
||||
gchar *track_uuid = NULL;
|
||||
g_object_get(track, "uuid", &track_uuid, NULL);
|
||||
|
||||
if (file_uuid == NULL) {
|
||||
return;
|
||||
if (track_uuid != NULL) {
|
||||
koto_playlist_remove_track_by_uuid(self, track_uuid);
|
||||
g_free(track_uuid);
|
||||
}
|
||||
|
||||
koto_playlist_remove_track_by_uuid(self, file_uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
void koto_playlist_remove_track_by_uuid(KotoPlaylist *self, gchar *uuid) {
|
||||
|
|
|
@ -35,7 +35,7 @@ G_DECLARE_FINAL_TYPE(KotoPlaylist, koto_playlist, KOTO, PLAYLIST, GObject);
|
|||
|
||||
KotoPlaylist* koto_playlist_new();
|
||||
KotoPlaylist* koto_playlist_new_with_uuid(const gchar *uuid);
|
||||
void koto_playlist_add_track(KotoPlaylist *self, KotoIndexedFile *file);
|
||||
void koto_playlist_add_track(KotoPlaylist *self, KotoIndexedTrack *track);
|
||||
void koto_playlist_add_track_by_uuid(KotoPlaylist *self, const gchar *uuid);
|
||||
void koto_playlist_debug(KotoPlaylist *self);
|
||||
void koto_playlist_debug_foreach(gpointer data, gpointer user_data);
|
||||
|
@ -48,7 +48,7 @@ GQueue* koto_playlist_get_tracks(KotoPlaylist *self);
|
|||
gchar* koto_playlist_get_uuid(KotoPlaylist *self);
|
||||
gchar* koto_playlist_go_to_next(KotoPlaylist *self);
|
||||
gchar* koto_playlist_go_to_previous(KotoPlaylist *self);
|
||||
void koto_playlist_remove_track(KotoPlaylist *self, KotoIndexedFile *file);
|
||||
void koto_playlist_remove_track(KotoPlaylist *self, KotoIndexedTrack *track);
|
||||
void koto_playlist_remove_track_by_uuid(KotoPlaylist *self, gchar *uuid);
|
||||
void koto_playlist_set_artwork(KotoPlaylist *self, const gchar *path);
|
||||
void koto_playlist_save_state(KotoPlaylist *self);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue