ocarina: Fix up include files and begin new window code

I combined the ocarina.h and gtk.h header files into one single file.  I
also began writing new window managing code under a window namespace for
code separation.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-03-10 10:33:01 -05:00 committed by Bryan Schumaker
parent 95cc9d272f
commit 5817effdde
29 changed files with 94 additions and 88 deletions

View File

@ -1,8 +1,7 @@
#ifndef OCARINA_BODY_H
#define OCARINA_BODY_H
#include <ocarina/gtk.h>
#include <ocarina/page.h>
#include <ocarina/ocarina.h>
GtkWidget *get_tabs();
GtkWidget *make_page(GtkWidget *);

View File

@ -4,7 +4,7 @@
#include <string>
using namespace std;
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
GtkWidget *make_button(const gchar *stockid,
void (* func)(GtkWidget *, GdkEvent *, gpointer),

View File

@ -1,7 +1,7 @@
#ifndef OCARINA_FOOTER
#define OCARINA_FOOTER
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <libsaria/track.h>
void footer_init();

View File

@ -1,15 +0,0 @@
#ifndef OCARINA_GTK_H
#define OCARINA_GTK_H
extern "C" {
#include <gtk/gtk.h>
}
#define GTK_CONNECT(widget, event, func, arg) \
g_signal_connect(widget, event, G_CALLBACK(func), arg)
void box_pack_start(GtkWidget *, GtkWidget *, gboolean, gboolean, guint);
void box_pack_end(GtkWidget *, GtkWidget *, gboolean, gboolean, guint);
void container_add(GtkWidget *, GtkWidget *);
#endif

View File

@ -1,7 +1,7 @@
#ifndef OCARINA_HEADER_H
#define OCARINA_HEADER_H
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
GtkWidget *get_header();
void header_init();

View File

@ -1,6 +1,19 @@
#ifndef OCARINA_H
#define OCARINA_H
#include <libsaria/print.h>
#include <gtk/gtk.h>
#include <string>
using namespace std;
#define GTK_CONNECT(widget, event, func, arg) \
g_signal_connect(widget, event, G_CALLBACK(func), arg)
void box_pack_start(GtkWidget *, GtkWidget *, gboolean, gboolean, guint);
void box_pack_end(GtkWidget *, GtkWidget *, gboolean, gboolean, guint);
void container_add(GtkWidget *, GtkWidget *);
namespace ocarina
{

View File

@ -1,26 +0,0 @@
#ifndef OCARINA_PAGE_H
#define OCARINA_PAGE_H
#include <ocarina/gtk.h>
class Page
{
private:
GtkWidget *table;
void add_content(GtkWidget *);
public:
Page(GtkWidget *);
~Page();
GtkWidget *get_page();
void add_header(GtkWidget *);
void add_footer(GtkWidget *);
void remove_header(GtkWidget *);
void remove_footer(GtkWidget *);
void hide();
void show();
};
#endif /* OCARINA_PAGE_H */

View File

@ -1,7 +1,7 @@
#ifndef OCARINA_SETTINGS_H
#define OCARINA_SETTINGS_H
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <string>
using namespace std;

View File

@ -1,7 +1,7 @@
#ifndef OCARINA_SHORTCUT_H
#define OCARINA_SHORTCUT_H
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <string>
using namespace std;

View File

@ -1,7 +1,7 @@
#ifndef OCARINA_SONGLIST_H
#define OCARINA_SONGLIST_H
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <libsaria/track.h>
#include <libsaria/playlist.h>
#include <libsaria/renderer.h>

View File

@ -1,16 +1,25 @@
#ifndef OCARINA_WINDOW_H
#define OCARINA_WINDOW_H
#include <ocarina/gtk.h>
#include <string>
using namespace std;
void window_resize(int, int);
namespace ocarina
{
namespace window
{
void init();
}; /* Namespace: window */
/*void window_resize(int, int);
void window_init(string, string);
void window_add(GtkWidget *);
void window_title(string);
void window_icon(string);
void window_focus();
void window_focus();*/
}; /* Namespace: ocarina */
#endif

View File

@ -1,6 +1,5 @@
// Copyright (c) 2011 Bryan Schumaker
#include <ocarina/gtk.h>
#include <ocarina/page.h>
#include <ocarina/ocarina.h>
#include <ocarina/header.h>
#include <ocarina/footer.h>
#include <libsaria/print.h>

View File

@ -1,5 +1,5 @@
// Copyright (c) 2011 Bryan Schumaker
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <ocarina/button.h>
#include <ocarina/ocarina.h>
#include <libsaria/prefs.h>

View File

@ -28,7 +28,7 @@ static void handle_callback(gpointer obj, callback_t type, gpointer data)
show_button_list(PLAY_BUTTON_LIST);
break;
case IDLE_TASK_QUEUED:
ocarina::idle_add();
//ocarina::idle_add();
break;
case LIBRARY_REFRESH:
ocarina::library::refresh();

View File

@ -1,5 +1,5 @@
// Copyright (c) 2011 Bryan Schumaker
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <ocarina/chooser.h>
namespace ocarina

View File

@ -1,5 +1,5 @@
// Copyright (c) 2011 Bryan Schumaker
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <ocarina/button.h>
#include <ocarina/shortcut.h>
#include <libsaria/audio.h>

View File

@ -1,6 +1,6 @@
// Copyright (c) 2011 Bryan Schumaker
#include <libsaria/track.h>
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include "footer.h"
#include <list>

View File

@ -1,5 +1,5 @@
// Copyright (c) 2011 Bryan Schumaker
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <libsaria/audio.h>
#include <libsaria/print.h>
#include "footer.h"

View File

@ -1,5 +1,5 @@
// Copyright (c) 2011 Bryan Schumaker
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
void box_pack_start(GtkWidget *box, GtkWidget *child, gboolean expand,
gboolean fill, guint padding)

View File

@ -1,7 +1,7 @@
// Copyright (c) 2011 Bryan Schumaker
#include <ocarina/library.h>
#include <ocarina/body.h>
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <ocarina/songlist.h>
#include <ocarina/shortcut.h>

View File

@ -1,7 +1,11 @@
// Copyright (c) 2011 Bryan Schumaker
#include <version.h>
#include <libsaria/libsaria.h>
#include <ocarina/ocarina.h>
#include <ocarina/window.h>
/*#include <version.h>
#include <ocarina/callback.h>
#include <ocarina/gtk.h>
#include <ocarina/body.h>
#include <ocarina/header.h>
#include <ocarina/footer.h>
@ -14,7 +18,7 @@
#include <libsaria/audio.h>
#include <libsaria/libsaria.h>
#include <libsaria/print.h>
#include <libsaria/idle.h>
#include <libsaria/idle.h>*/
static string path_prefix;
@ -28,18 +32,18 @@ void set_path_prefix(string prefix)
namespace ocarina
{
/*
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 */
}
return FALSE; *//* There are no idle events left */
/*return TRUE; *//* Process remaining idle events */
/*}
void idle_add()
{
g_idle_add(idle, NULL);
}
}*/
string full_path(string path)
{
@ -47,10 +51,10 @@ namespace ocarina
println("Expanding to path: " + res);
return res;
}
/*
void init(int argc, char **argv)
{
window_init("Ocarina " + vers_str(), full_path("images/ocarina.png"));
window::init("Ocarina " + vers_str(), full_path("images/ocarina.png"));
window_add(get_tabs());
settings_init();
ocarina::library::init();
@ -59,7 +63,7 @@ namespace ocarina
footer_init();
idle_add();
}
*/
void quit()
{
gtk_main_quit();
@ -67,12 +71,21 @@ namespace ocarina
}
static void init(int argc, char **argv)
{
gtk_init(&argc, &argv);
ocarina::window::init();
}
int main(int argc, char **argv)
{
println("Ocarina " + vers_str());
set_path_prefix(argv[0]);
libsaria::init("ocarina", argc, argv);
init(argc, argv);
gtk_main();
/* setup_callbacks();

View File

@ -1,7 +1,7 @@
// Copyright (c) 2011 Bryan Schumaker
#include <ocarina/queue.h>
#include <ocarina/body.h>
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <ocarina/songlist.h>
#include <ocarina/shortcut.h>
#include <libsaria/stack.h>

View File

@ -1,6 +1,6 @@
// Copyright (c) 2012 Bryan Schumaker
#include <ocarina/settings.h>
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <libsaria/audio.h>

View File

@ -6,7 +6,7 @@ using namespace std;
#include <ocarina/settings.h>
#include <ocarina/chooser.h>
#include <ocarina/button.h>
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <libsaria/library.h>
#include <libsaria/libpath.h>

View File

@ -1,7 +1,7 @@
// Copyright (c) 2011 Bryan Schumaker
#include <ocarina/settings.h>
#include <ocarina/body.h>
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
static GtkWidget *settings_tabs = NULL;
static GtkWidget *settings_page = NULL;

View File

@ -26,7 +26,7 @@ gboolean handle_shortcut(GtkWidget *widget, GdkEvent *event, gpointer data)
map<string, void (*)()>::iterator it;
if (key == "Escape") {
window_focus();
//window_focus();
return TRUE;
}

View File

@ -3,7 +3,7 @@
#include <sstream>
using namespace std;
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <ocarina/songlist.h>
#include <libsaria/controls.h>
#include <libsaria/print.h>

View File

@ -1,7 +1,7 @@
#ifndef OCARINA_SONGLIST_PRIVATE_H
#define OCARINA_SONGLIST_PRIVATE_H
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
void songlist_row_activated(GtkTreeView *, GtkTreePath *, GtkTreeViewColumn *, gpointer);
void songlist_button_click(GtkWidget *, GdkEvent *, gpointer);

View File

@ -1,19 +1,20 @@
// Copyright (c) 2011 Bryan Schumaker
#include <string>
using namespace std;
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <ocarina/window.h>
/*#include <ocarina/gtk.h>
#include <ocarina/ocarina.h>
#include <ocarina/window.h>
#include <ocarina/shortcut.h>
*/
static GtkWidget *win;
static GtkWidget *window;
void destroy_window(GtkWidget *widget, GdkEvent *event, gpointer data)
static void destroy(GtkWidget *widget, GdkEvent *event, gpointer data)
{
ocarina::quit();
}
/*
void window_resize(int w, int h)
{
gtk_window_resize(GTK_WINDOW(window), w, h);
@ -48,4 +49,17 @@ void window_add(GtkWidget *widget)
void window_focus()
{
gtk_window_set_focus(GTK_WINDOW(window), NULL);
}
}*/
namespace ocarina
{
void window::init()
{
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(win, "destroy", G_CALLBACK(destroy), NULL);
gtk_widget_show(win);
}
} /* Namespace: ocarina */