core: Remove struct core_init_data and pass parameters directly
The core_init_data only held three items, most of which don't get set during testing. Removing this struct means several tests no longer need to define a "dummy" initdata object to pass around during init. Implements #92: Remove core_init_data Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
5247bf2de0
commit
a15ad67029
11
core/core.c
11
core/core.c
|
@ -1,10 +1,8 @@
|
|||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/audio.h>
|
||||
#include <core/core.h>
|
||||
#include <core/idle.h>
|
||||
#include <core/playlist.h>
|
||||
#include <core/settings.h>
|
||||
#include <core/tags/tags.h>
|
||||
|
||||
|
@ -18,13 +16,14 @@ static bool core_defragment(void *data)
|
|||
return true;
|
||||
}
|
||||
|
||||
void core_init(int *argc, char ***argv, struct core_init_data *init)
|
||||
void core_init(int *argc, char ***argv, struct playlist_callbacks *playlist_cb,
|
||||
struct audio_callbacks *audio_cb, enum idle_sync_t idle_sync)
|
||||
{
|
||||
idle_init(init->idle_sync);
|
||||
idle_init(idle_sync);
|
||||
settings_init();
|
||||
tags_init();
|
||||
playlist_init(init->playlist_cb);
|
||||
audio_init(argc, argv, init->audio_cb);
|
||||
playlist_init(playlist_cb);
|
||||
audio_init(argc, argv, audio_cb);
|
||||
|
||||
idle_schedule(IDLE_SYNC, core_defragment, NULL);
|
||||
}
|
||||
|
|
|
@ -32,12 +32,7 @@ const static gchar *OCARINA_APP = "org.gtk.ocarina";
|
|||
const static gchar *OCARINA_APP = "org.gtk.ocarina-debug";
|
||||
#endif
|
||||
|
||||
static struct core_init_data init_data = {
|
||||
.playlist_cb = &playlist_cb,
|
||||
.audio_cb = &audio_cb,
|
||||
.idle_sync = IDLE_ASYNC,
|
||||
};
|
||||
|
||||
static enum idle_sync_t idle_sync = IDLE_ASYNC;
|
||||
static int startup_argc;
|
||||
static char **startup_argv;
|
||||
|
||||
|
@ -61,7 +56,7 @@ static int __ocarina_local_options(GApplication *application,
|
|||
GVariantDict *options, gpointer data)
|
||||
{
|
||||
if (g_variant_dict_contains(options, "sync"))
|
||||
init_data.idle_sync = IDLE_SYNC;
|
||||
idle_sync = IDLE_SYNC;
|
||||
if (!g_variant_dict_contains(options, "version"))
|
||||
return -1;
|
||||
g_printf("Ocarina %s\n", get_version());
|
||||
|
@ -103,7 +98,7 @@ static void __ocarina_startup(GApplication *application, gpointer data)
|
|||
gchar *icon = find_file_path("ocarina.png");
|
||||
|
||||
gui_builder_init(ui);
|
||||
core_init(&startup_argc, &startup_argv, &init_data);
|
||||
core_init(&startup_argc, &startup_argv, &playlist_cb, &audio_cb, idle_sync);
|
||||
gui_window_init(icon);
|
||||
gui_model_init();
|
||||
gui_filter_init();
|
||||
|
|
|
@ -3,18 +3,14 @@
|
|||
*/
|
||||
#ifndef OCARINA_CORE_CORE_H
|
||||
#define OCARINA_CORE_CORE_H
|
||||
#include <core/audio.h>
|
||||
#include <core/playlist.h>
|
||||
#include <core/idle.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct core_init_data {
|
||||
struct playlist_callbacks *playlist_cb;
|
||||
struct audio_callbacks *audio_cb;
|
||||
enum idle_sync_t idle_sync;
|
||||
};
|
||||
|
||||
|
||||
/* Called to initialize all core Ocarina components. */
|
||||
void core_init(int *, char ***, struct core_init_data *);
|
||||
void core_init(int *, char ***, struct playlist_callbacks *,
|
||||
struct audio_callbacks *, enum idle_sync_t);
|
||||
|
||||
/* Called to deinitialize all core Ocarina componentns. */
|
||||
void core_deinit();
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#ifndef OCARINA_CORE_PLAYLIST_H
|
||||
#define OCARINA_CORE_PLAYLIST_H
|
||||
#include <core/playlists/artist.h>
|
||||
#include <core/playlists/generic.h>
|
||||
#include <core/playlists/library.h>
|
||||
#include <core/playlists/system.h>
|
||||
#include <core/playlists/user.h>
|
||||
|
|
|
@ -47,10 +47,6 @@ static struct audio_callbacks test_audio_cb = {
|
|||
.audio_cb_config_pause = test_config_pause,
|
||||
};
|
||||
|
||||
static struct core_init_data test_init_data = {
|
||||
.audio_cb = &test_audio_cb,
|
||||
};
|
||||
|
||||
|
||||
static void test_init()
|
||||
{
|
||||
|
@ -59,7 +55,7 @@ static void test_init()
|
|||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_NULL);
|
||||
g_assert_null(audio_next());
|
||||
|
||||
core_init(NULL, NULL, &test_init_data);
|
||||
core_init(NULL, NULL, NULL, &test_audio_cb, IDLE_SYNC);
|
||||
|
||||
g_assert_false(audio_load(NULL));
|
||||
g_assert_null(audio_next());
|
||||
|
|
|
@ -22,14 +22,12 @@ static struct audio_callbacks test_audio_cb = {
|
|||
.audio_cb_config_pause = test_config_pause,
|
||||
};
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.audio_cb = &test_audio_cb,
|
||||
#ifdef CONFIG_ALBUM_ART_TEST
|
||||
.idle_sync = IDLE_ASYNC,
|
||||
enum idle_sync_t test_sync = IDLE_ASYNC;
|
||||
#else /* CONFIG_ALBUM_ART_TEST */
|
||||
.idle_sync = IDLE_SYNC,
|
||||
enum idle_sync_t test_sync = IDLE_SYNC;
|
||||
#endif /* CONFIG_ALBUM_ART_TEST */
|
||||
};
|
||||
|
||||
|
||||
static void test_artwork(void)
|
||||
{
|
||||
|
@ -77,7 +75,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, NULL, &init_data);
|
||||
core_init(&argc, NULL, NULL, &test_audio_cb, test_sync);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_model_init();
|
||||
gui_filter_init();
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
#include <gui/window.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.audio_cb = &audio_cb,
|
||||
};
|
||||
|
||||
static void test_audio_init()
|
||||
{
|
||||
g_assert_cmpstr(gtk_label_get_text(gui_album_tag()), ==, " ");
|
||||
|
@ -123,7 +119,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, &argv, &init_data);
|
||||
core_init(&argc, &argv, NULL, &audio_cb, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_model_init();
|
||||
gui_filter_init();
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include <gui/model.h>
|
||||
#include <gui/window.h>
|
||||
|
||||
static struct core_init_data init_data;
|
||||
|
||||
void test_filter()
|
||||
{
|
||||
struct track *track;
|
||||
|
@ -79,7 +77,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, NULL, &init_data);
|
||||
core_init(&argc, NULL, NULL, NULL, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_window_init("share/ocarina/ocarina.png");
|
||||
gui_model_init();
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
static const unsigned int N = 100;
|
||||
static unsigned int cur = -1;
|
||||
struct core_init_data init_data;
|
||||
|
||||
static bool inc_cur(void *data)
|
||||
{
|
||||
|
@ -45,7 +44,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, NULL, &init_data);
|
||||
core_init(&argc, NULL, NULL, NULL, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_test_init();
|
||||
while (idle_run_task()) {}
|
||||
|
|
|
@ -32,10 +32,6 @@ struct playlist_callbacks test_cb = {
|
|||
.pl_cb_updated = gui_model_update,
|
||||
};
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_cb = &test_cb,
|
||||
};
|
||||
|
||||
static void test_init()
|
||||
{
|
||||
GuiModel *model = gui_model_get();
|
||||
|
@ -271,7 +267,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, NULL, &init_data);
|
||||
core_init(&argc, NULL, &test_cb, NULL, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_model_init();
|
||||
while (idle_run_task()) {};
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include <gui/treeview.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
struct core_init_data init_data;
|
||||
|
||||
static void test_playlist()
|
||||
{
|
||||
GtkTreeIter iter, child;
|
||||
|
@ -59,7 +57,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, NULL, &init_data);
|
||||
core_init(&argc, NULL, NULL, NULL, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_model_init();
|
||||
gui_filter_init();
|
||||
|
|
|
@ -11,10 +11,6 @@
|
|||
#include <gui/treeview.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_cb = &playlist_cb,
|
||||
};
|
||||
|
||||
static void test_artist()
|
||||
{
|
||||
GtkTreeModel *model = gui_sidebar_model();
|
||||
|
@ -46,7 +42,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, &argv, &init_data);
|
||||
core_init(&argc, &argv, &playlist_cb, NULL, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_model_init();
|
||||
gui_filter_init();
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include <gui/treeview.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
struct core_init_data init_data;
|
||||
|
||||
static void test_library()
|
||||
{
|
||||
GtkTreeModel *model = gui_sidebar_model();
|
||||
|
@ -58,7 +56,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, &argv, &init_data);
|
||||
core_init(&argc, &argv, NULL, NULL, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_model_init();
|
||||
gui_filter_init();
|
||||
|
|
|
@ -22,11 +22,6 @@ static struct audio_callbacks test_audio_cb = {
|
|||
.audio_cb_config_pause = test_config_pause,
|
||||
};
|
||||
|
||||
struct core_init_data init_data = {
|
||||
.playlist_cb = &playlist_cb,
|
||||
.audio_cb = &test_audio_cb,
|
||||
};
|
||||
|
||||
static const gchar *toplevel[3] = { "Queued Tracks", "Collection", "History" };
|
||||
static const gchar *playlists[2] = {"Favorites", "Hidden" };
|
||||
static const gchar *dynamic[3] = {"Most Played", "Least Played", "Unplayed" };
|
||||
|
@ -102,7 +97,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, &argv, &init_data);
|
||||
core_init(&argc, &argv, &playlist_cb, &test_audio_cb, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_model_init();
|
||||
gui_filter_init();
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include <gui/treeview.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
struct core_init_data init_data;
|
||||
|
||||
static void test_user()
|
||||
{
|
||||
GtkTreeModel *model = gui_sidebar_model();
|
||||
|
@ -70,7 +68,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, &argv, &init_data);
|
||||
core_init(&argc, &argv, NULL, NULL, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_model_init();
|
||||
gui_filter_init();
|
||||
|
|
|
@ -16,7 +16,6 @@ const gchar *test_pl_names[8] = { "Collection",
|
|||
"", "Dynamic",
|
||||
"", "Library" };
|
||||
const gchar *test_dyn_names[3] = { "Least Played", "Most Played", "Unplayed" };
|
||||
struct core_init_data init_data;
|
||||
|
||||
static void test_sidebar()
|
||||
{
|
||||
|
@ -231,7 +230,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, &argv, &init_data);
|
||||
core_init(&argc, &argv, NULL, NULL, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_model_init();
|
||||
gui_filter_init();
|
||||
|
|
|
@ -25,8 +25,6 @@ const gchar *GUI_COL_SETTINGS[GUI_MODEL_N_COLUMNS] = {
|
|||
[GUI_MODEL_FONT] = "gui.queue.font",
|
||||
};
|
||||
|
||||
static struct core_init_data init_data;
|
||||
|
||||
void test_treeview_init()
|
||||
{
|
||||
GtkTreePath *path;
|
||||
|
@ -221,7 +219,7 @@ int main(int argc, char **argv)
|
|||
int ret;
|
||||
|
||||
gtk_init(&argc, NULL);
|
||||
core_init(&argc, NULL, &init_data);
|
||||
core_init(&argc, NULL, NULL, NULL, IDLE_SYNC);
|
||||
gui_builder_init("share/ocarina/ocarina.ui");
|
||||
gui_model_init();
|
||||
gui_filter_init();
|
||||
|
|
Loading…
Reference in New Issue