core/tags/artist: Replace std:string with gchar *
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
d404579297
commit
c07d1e9024
|
@ -9,41 +9,42 @@ extern "C" {
|
||||||
|
|
||||||
static struct database artist_db;
|
static struct database artist_db;
|
||||||
|
|
||||||
|
static struct artist *__artist_alloc(gchar *name)
|
||||||
static db_entry *artist_alloc(const gchar *name)
|
|
||||||
{
|
{
|
||||||
struct artist *artist = new struct artist;
|
struct artist *artist = new struct artist;
|
||||||
gchar *lower = string_lowercase(name);
|
|
||||||
|
|
||||||
dbe_init(&artist->ar_dbe, artist);
|
dbe_init(&artist->ar_dbe, artist);
|
||||||
artist->ar_name = name;
|
artist->ar_name = name;
|
||||||
artist->ar_lower = lower;
|
artist->ar_lower = string_lowercase(name);
|
||||||
|
|
||||||
g_free(lower);
|
return artist;
|
||||||
return &artist->ar_dbe;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static db_entry *artist_alloc(const gchar *name)
|
||||||
|
{
|
||||||
|
return &__artist_alloc(g_strdup(name))->ar_dbe;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void artist_free(struct db_entry *dbe)
|
static void artist_free(struct db_entry *dbe)
|
||||||
{
|
{
|
||||||
|
g_free(ARTIST(dbe)->ar_lower);
|
||||||
delete ARTIST(dbe);
|
delete ARTIST(dbe);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *artist_key(struct db_entry *dbe)
|
static gchar *artist_key(struct db_entry *dbe)
|
||||||
{
|
{
|
||||||
return g_strdup(ARTIST(dbe)->ar_name.c_str());
|
return ARTIST(dbe)->ar_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct db_entry *artist_read(struct file *file)
|
struct db_entry *artist_read(struct file *file)
|
||||||
{
|
{
|
||||||
gchar *name = file_readl(file);
|
return &__artist_alloc(file_readl(file))->ar_dbe;
|
||||||
struct db_entry *dbe = artist_alloc(name);
|
|
||||||
g_free(name);
|
|
||||||
return dbe;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void artist_write(struct file *file, struct db_entry *dbe)
|
static void artist_write(struct file *file, struct db_entry *dbe)
|
||||||
{
|
{
|
||||||
file_writef(file, "%s", ARTIST(dbe)->ar_name.c_str());
|
file_writef(file, "%s", ARTIST(dbe)->ar_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,9 +69,9 @@ void artist_db_deinit()
|
||||||
db_deinit(&artist_db);
|
db_deinit(&artist_db);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct artist *artist_find(const std::string &name)
|
struct artist *artist_find(const gchar *name)
|
||||||
{
|
{
|
||||||
return ARTIST(db_find(&artist_db, name.c_str()));
|
return ARTIST(db_find(&artist_db, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct artist *artist_get(const unsigned int index)
|
struct artist *artist_get(const unsigned int index)
|
||||||
|
@ -80,7 +81,7 @@ struct artist *artist_get(const unsigned int index)
|
||||||
|
|
||||||
int artist_compare(struct artist *lhs, struct artist *rhs)
|
int artist_compare(struct artist *lhs, struct artist *rhs)
|
||||||
{
|
{
|
||||||
return string_compare(lhs->ar_lower.c_str(), rhs->ar_lower.c_str());
|
return string_compare(lhs->ar_lower, rhs->ar_lower);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_TESTING
|
#ifdef CONFIG_TESTING
|
||||||
|
|
|
@ -86,7 +86,7 @@ static void track_setup(struct db_entry *dbe)
|
||||||
struct track *track = (struct track *)dbe;
|
struct track *track = (struct track *)dbe;
|
||||||
|
|
||||||
filter_add(track->tr_lower.c_str(), track->dbe_index);
|
filter_add(track->tr_lower.c_str(), track->dbe_index);
|
||||||
filter_add(track->tr_artist->ar_lower.c_str(), track->dbe_index);
|
filter_add(track->tr_artist->ar_lower, track->dbe_index);
|
||||||
filter_add(track->tr_album->al_lower, track->dbe_index);
|
filter_add(track->tr_album->al_lower, track->dbe_index);
|
||||||
track->tr_library->li_size++;
|
track->tr_library->li_size++;
|
||||||
}
|
}
|
||||||
|
|
14
gui/gst.cpp
14
gui/gst.cpp
|
@ -61,18 +61,22 @@ public:
|
||||||
{
|
{
|
||||||
gchar *uri = gst_filename_to_uri(track_path(track).c_str(), NULL);
|
gchar *uri = gst_filename_to_uri(track_path(track).c_str(), NULL);
|
||||||
gchar *len = string_sec2str(track->tr_length);
|
gchar *len = string_sec2str(track->tr_length);
|
||||||
gchar *from;
|
gchar *str;
|
||||||
|
|
||||||
gst_change_state(GST_STATE_NULL);
|
gst_change_state(GST_STATE_NULL);
|
||||||
g_object_set(G_OBJECT(gst_player), "uri", uri, NULL);
|
g_object_set(G_OBJECT(gst_player), "uri", uri, NULL);
|
||||||
g_free(uri);
|
g_free(uri);
|
||||||
|
|
||||||
from = g_strdup_printf("From: %s", track->tr_album->al_name);
|
str = g_strdup_printf("From: %s", track->tr_album->al_name);
|
||||||
set_markup(o_album, "x-large", from);
|
set_markup(o_album, "x-large", str);
|
||||||
g_free(from);
|
g_free(str);
|
||||||
|
|
||||||
|
str = g_strdup_printf("By: %s", track->tr_artist->ar_name);
|
||||||
|
set_markup(o_artist, "x-large", str);
|
||||||
|
g_free(str);
|
||||||
|
|
||||||
set_markup(o_artist, "x-large", "By: " + track->tr_artist->ar_name);
|
|
||||||
set_markup(o_title, "xx-large", track->tr_title);
|
set_markup(o_title, "xx-large", track->tr_title);
|
||||||
|
|
||||||
o_duration->set_text(len);
|
o_duration->set_text(len);
|
||||||
g_free(len);
|
g_free(len);
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,8 @@ void QueueModel::get_value_vfunc(const Gtk::TreeIter &iter, int column,
|
||||||
g_free(str);
|
g_free(str);
|
||||||
return;
|
return;
|
||||||
case 3:
|
case 3:
|
||||||
return set_val(track->tr_artist->ar_name, value);
|
field = track->tr_artist->ar_name;
|
||||||
|
return set_val(field, value);
|
||||||
case 4:
|
case 4:
|
||||||
field = track->tr_album->al_name;
|
field = track->tr_album->al_name;
|
||||||
return set_val(field, value);
|
return set_val(field, value);
|
||||||
|
|
|
@ -14,8 +14,8 @@ extern "C" {
|
||||||
* to the tag database.
|
* to the tag database.
|
||||||
*/
|
*/
|
||||||
struct artist {
|
struct artist {
|
||||||
std::string ar_name; /* This artist's name. */
|
gchar *ar_name; /* This artist's name. */
|
||||||
std::string ar_lower; /* This artist's name (lowercased). */
|
gchar *ar_lower; /* This artist's name (lowercased). */
|
||||||
struct db_entry ar_dbe;
|
struct db_entry ar_dbe;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ void artist_db_init();
|
||||||
void artist_db_deinit();
|
void artist_db_deinit();
|
||||||
|
|
||||||
/* Called to find an artist tag by name. */
|
/* Called to find an artist tag by name. */
|
||||||
struct artist *artist_find(const std::string &);
|
struct artist *artist_find(const gchar *);
|
||||||
|
|
||||||
/* Called to get an artist tag with a specific index. */
|
/* Called to get an artist tag with a specific index. */
|
||||||
struct artist *artist_get(const unsigned int);
|
struct artist *artist_get(const unsigned int);
|
||||||
|
|
|
@ -9,7 +9,7 @@ static void test_verify_empty(struct artist *artist)
|
||||||
const struct db_ops *artist_ops = test_artist_ops();
|
const struct db_ops *artist_ops = test_artist_ops();
|
||||||
test_equal(artist->ar_name, "");
|
test_equal(artist->ar_name, "");
|
||||||
test_equal(artist->ar_lower, "");
|
test_equal(artist->ar_lower, "");
|
||||||
test_str_equal(artist_ops->dbe_key(&artist->ar_dbe), "");
|
test_equal(artist_ops->dbe_key(&artist->ar_dbe), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_verify_koji(struct artist *artist)
|
static void test_verify_koji(struct artist *artist)
|
||||||
|
@ -17,7 +17,7 @@ static void test_verify_koji(struct artist *artist)
|
||||||
const struct db_ops *artist_ops = test_artist_ops();
|
const struct db_ops *artist_ops = test_artist_ops();
|
||||||
test_equal(artist->ar_name, "Koji Kondo");
|
test_equal(artist->ar_name, "Koji Kondo");
|
||||||
test_equal(artist->ar_lower, "koji kondo");
|
test_equal(artist->ar_lower, "koji kondo");
|
||||||
test_str_equal(artist_ops->dbe_key(&artist->ar_dbe), "Koji Kondo");
|
test_equal(artist_ops->dbe_key(&artist->ar_dbe), "Koji Kondo");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_artist()
|
static void test_artist()
|
||||||
|
@ -32,21 +32,24 @@ static void test_artist()
|
||||||
|
|
||||||
file_init(&f, "artist_tag", 0);
|
file_init(&f, "artist_tag", 0);
|
||||||
file_open(&f, OPEN_WRITE);
|
file_open(&f, OPEN_WRITE);
|
||||||
file_writef(&f, "1 \n1 ");
|
file_writef(&f, "1 \n2 ");
|
||||||
artist_ops->dbe_write(&f, &artist->ar_dbe);
|
artist_ops->dbe_write(&f, &artist->ar_dbe);
|
||||||
file_close(&f);
|
file_close(&f);
|
||||||
|
g_free(artist->ar_name);
|
||||||
artist_ops->dbe_free(&artist->ar_dbe);
|
artist_ops->dbe_free(&artist->ar_dbe);
|
||||||
|
|
||||||
file_open(&f, OPEN_READ);
|
file_open(&f, OPEN_READ);
|
||||||
file_readf(&f, "%u", &i);
|
file_readf(&f, "%u", &i);
|
||||||
artist = ARTIST(artist_ops->dbe_read(&f));
|
artist = ARTIST(artist_ops->dbe_read(&f));
|
||||||
test_verify_empty(artist);
|
test_verify_empty(artist);
|
||||||
|
g_free(artist->ar_name);
|
||||||
artist_ops->dbe_free(&artist->ar_dbe);
|
artist_ops->dbe_free(&artist->ar_dbe);
|
||||||
|
|
||||||
file_readf(&f, "%u", &i);
|
file_readf(&f, "%u", &i);
|
||||||
artist = ARTIST(artist_ops->dbe_read(&f));
|
artist = ARTIST(artist_ops->dbe_read(&f));
|
||||||
file_close(&f);
|
file_close(&f);
|
||||||
test_verify_koji(artist);
|
test_verify_koji(artist);
|
||||||
|
g_free(artist->ar_name);
|
||||||
artist_ops->dbe_free(&artist->ar_dbe);
|
artist_ops->dbe_free(&artist->ar_dbe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +65,8 @@ static void test_artist_compare()
|
||||||
test_equal(artist_compare(koji, hajime), 1);
|
test_equal(artist_compare(koji, hajime), 1);
|
||||||
test_equal(artist_compare(hajime, koji), -1);
|
test_equal(artist_compare(hajime, koji), -1);
|
||||||
|
|
||||||
|
g_free(koji->ar_name);
|
||||||
|
g_free(hajime->ar_name);
|
||||||
artist_ops->dbe_free(&koji->ar_dbe);
|
artist_ops->dbe_free(&koji->ar_dbe);
|
||||||
artist_ops->dbe_free(&hajime->ar_dbe);
|
artist_ops->dbe_free(&hajime->ar_dbe);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue