On Wed, 2005-06-29 at 20:39 +1000, Nicholas Gill (mythagel) wrote:
> Because the code works by adding items to the action and event queues, i
> can't think of a clean way to specify the event type when adding a uri.
>
> At present i'm enumerating the directory and calling rhythmdb_entry_new
> for each one, which doesn't perform well nor act properly in the ui.
>
> Any ideas on how to implement specifying an entry type to
> rhythmdb_add_uri? i'm happy to implement it but i don't know how i
> should go about it.
Below is something that I think should work, but I haven't actually
tried it, so it might not. In any case, it should give you an idea of
where to start.
struct RecursiveEntryCreationData
{
char *uri;
RhythmDB *db;
RhythmDBEntryType type;
};
static void
add_entry_with_type (const char *uri, RecursiveEntryCreationData *data)
{
RhythmDBEntry *entry = rhythmdb_entry_new (RHYTHMDB (data->db),
RHYTHMDB_ENTRY_TYPE_IPOD,
uri);
/* do other things with the entry */
rhythmdb_commit (RHYTHMDB (data->db));
}
static gpointer
add_uri_with_type (struct RecursiveEntryCreationData *data)
{
rb_uri_handle_recursively (data->uri, (GFunc)add_entry_with_type,
FALSE, data)
g_object_unref (G_OBJECT (data->db));
g_free (data->uri);
g_free (data);
return NULL;
}
void
create_entries_with_type (RhythmDB *db, const char *uri,
RhythmDBEntryType type)
{
struct RecursiveEntryCreationData *data = g_new0 (struct
RecursiveEntryCreationData, 1);
data->uri = g_strdup (uri);
data->db = db;
data->type = type;
g_object_ref (G_OBJECT (data->db));
rhythmdb_thread_create (db, (GThreadFunc) add_uri_with_type, data);
}
James "Doc" Livingston
--
If USENET is anarchy, IRC is a paranoid schizophrenic after 6 days on
speed. -- Chris "Saundo" Saunderson in asr.
Attachment:
signature.asc
Description: This is a digitally signed message part