# HG changeset patch # User William Pitcock # Date 1214717888 18000 # Node ID 742abc97b3ab889abc0498e4a5e121373d89660e # Parent d8a07aa54bef6145d30543f4dd756c898856e426 Add preliminary Interface API. diff -r d8a07aa54bef -r 742abc97b3ab src/audacious/Makefile --- a/src/audacious/Makefile Sun Jun 29 00:29:04 2008 -0500 +++ b/src/audacious/Makefile Sun Jun 29 00:38:08 2008 -0500 @@ -19,6 +19,7 @@ general.c \ hook.c \ icons-stock.c \ + interface.c \ input.c \ logger.c \ main.c \ diff -r d8a07aa54bef -r 742abc97b3ab src/audacious/interface.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/interface.c Sun Jun 29 00:38:08 2008 -0500 @@ -0,0 +1,62 @@ +/* + * Audacious2 + * Copyright (c) 2008 William Pitcock + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * The Audacious team does not consider modular code linking to + * Audacious or using our public API to be a derived work. + */ + +#include +#include + +#include "interface.h" + +static mowgli_dictionary_t *interface_dict_ = NULL; + +void +interface_register(Interface *i) +{ + if (interface_dict_ == NULL) + interface_dict_ = mowgli_dictionary_create(g_ascii_strcasecmp); + + mowgli_dictionary_add(interface_dict_, i->id, i); +} + +void +interface_deregister(Interface *i) +{ + g_return_if_fail(interface_dict_ != NULL); + + mowgli_dictionary_delete(interface_dict_, i->id); +} + +/* + * TODO: + * - set up InterfaceOps struct for the Interface to use + */ +void +interface_run(Interface *i) +{ + i->init(); +} + +Interface * +interface_get(gchar *id) +{ + if (interface_dict_ == NULL) + return NULL; + + return mowgli_dictionary_retrieve(interface_dict_, id); +} diff -r d8a07aa54bef -r 742abc97b3ab src/audacious/interface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/interface.h Sun Jun 29 00:38:08 2008 -0500 @@ -0,0 +1,43 @@ +/* + * Audacious2 + * Copyright (c) 2008 William Pitcock + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * The Audacious team does not consider modular code linking to + * Audacious or using our public API to be a derived work. + */ + +/* + * This is the Interface API. + * + * Everything here is like totally subject to change. + * --nenolod + */ + +#ifndef __AUDACIOUS2_INTERFACE_H__ +#define __AUDACIOUS2_INTERFACE_H__ + +typedef struct { + gchar *id; /* simple ID like 'skinned' */ + gchar *desc; /* description like 'Skinned Interface' */ + gboolean (*init)(void); /* init UI */ + gboolean (*fini)(void); /* shutdown UI */ +} Interface; + +void interface_register(Interface *i); +void interface_deregister(Interface *i); +void interface_run(Interface *i); +Interface *interface_get(gchar *id); + +#endif