ocarina: Create initial namespace
Namespaces make code easier to follow, and remove the need to mangle the beginning of function names by using ocarina_*() or libsaria_*(). In other words: "namespaces are one honking good idea. Let's have more of them!"
This commit is contained in:
parent
6b12cff613
commit
7c79aab787
|
@ -1,7 +1,12 @@
|
|||
#ifndef OCARINA_H
|
||||
#define OCARINA_H
|
||||
|
||||
void ocarina_quit();
|
||||
void ocarina_idle_add();
|
||||
namespace ocarina
|
||||
{
|
||||
|
||||
void quit();
|
||||
void idle_add();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,7 +25,7 @@ void cb_pause()
|
|||
void cb_idle_task_queued()
|
||||
{
|
||||
println("Ocarina IDLE_TASK_QUEUED callback!");
|
||||
ocarina_idle_add();
|
||||
ocarina::idle_add();
|
||||
}
|
||||
|
||||
void cb_library_refresh()
|
||||
|
|
|
@ -12,29 +12,34 @@
|
|||
#include <libsaria/print.h>
|
||||
#include <libsaria/idle.h>
|
||||
|
||||
static gboolean ocarina_idle(gpointer data)
|
||||
namespace ocarina
|
||||
{
|
||||
if (libsaria::idle::run_task() == 0)
|
||||
return FALSE; /* There are no idle events left */
|
||||
return TRUE; /* Process remaining idle events */
|
||||
}
|
||||
|
||||
void ocarina_idle_add()
|
||||
{
|
||||
g_idle_add(ocarina_idle, NULL);
|
||||
}
|
||||
static gboolean idle(gpointer data)
|
||||
{
|
||||
if (libsaria::idle::run_task() == 0)
|
||||
return FALSE; /* There are no idle events left */
|
||||
return TRUE; /* Process remaining idle events */
|
||||
}
|
||||
|
||||
void ocarina_init(int argc, char **argv)
|
||||
{
|
||||
window_init("Ocarina " + vers_str(), "images/ocarina.png");
|
||||
window_add(get_tabs());
|
||||
library_init();
|
||||
settings_init();
|
||||
}
|
||||
void idle_add()
|
||||
{
|
||||
g_idle_add(idle, NULL);
|
||||
}
|
||||
|
||||
void init(int argc, char **argv)
|
||||
{
|
||||
window_init("Ocarina " + vers_str(), "images/ocarina.png");
|
||||
window_add(get_tabs());
|
||||
library_init();
|
||||
settings_init();
|
||||
}
|
||||
|
||||
void quit()
|
||||
{
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
void ocarina_quit()
|
||||
{
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
@ -44,7 +49,7 @@ int main(int argc, char **argv)
|
|||
libsaria::init(argc, argv);
|
||||
setup_callbacks();
|
||||
gtk_init(&argc, &argv);
|
||||
ocarina_init(argc, argv);
|
||||
ocarina::init(argc, argv);
|
||||
|
||||
if (argc > 1)
|
||||
libsaria::audio::load(argv[1]);
|
||||
|
|
|
@ -10,7 +10,7 @@ static GtkWidget *window;
|
|||
|
||||
void destroy_window(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
ocarina_quit();
|
||||
ocarina::quit();
|
||||
}
|
||||
|
||||
void window_resize(int w, int h)
|
||||
|
|
Loading…
Reference in New Issue