Add a button to the window

The button doesn't do anything yet, but I may eventually modify it for
playing and pausing music.
This commit is contained in:
Bryan Schumaker 2011-08-18 08:20:56 -04:00
parent 53d8718053
commit 7efcfddcde
7 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,13 @@
#include <ocarina/button.h>
GtkWidget *make_button(const gchar *stockid, GtkIconSize size)
{
GtkWidget *button = gtk_button_new();
GtkWidget *box = gtk_hbox_new(FALSE, 0);
GtkWidget *image = gtk_image_new_from_stock(stockid, size);
gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(button), box);
gtk_widget_show_all(button);
return button;
}

View File

@ -2,13 +2,18 @@
#include <iostream>
using namespace std;
#include <ocarina/button.h>
#include <ocarina/window.h>
#include <libsaria/libsaria.h>
void ocarina_init(int argc, char **argv)
{
GtkWidget *button;
const gchar *play = GTK_STOCK_MEDIA_PLAY;
gtk_init(&argc, &argv);
window_init();
button = make_button(play, GTK_ICON_SIZE_MENU);
window_add(button);
gtk_main();
}

View File

@ -21,3 +21,8 @@ void window_init()
window_resize(800, 600);
gtk_widget_show(window);
}
void window_add(GtkWidget *widget)
{
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(widget));
}

11
include/ocarina/button.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef OCARINA_BUTTON_H
#define OCARINA_BUTTON_H
#include <string>
using namespace std;
#include <ocarina/gtk.h>
GtkWidget *make_button(const gchar *, GtkIconSize);
#endif /* OCARINA_BUTTON_H */

8
include/ocarina/gtk.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef OCARINA_GTK_H
#define OCARINA_GTK_H
extern "C" {
#include <gtk/gtk.h>
}
#endif

View File

@ -0,0 +1,6 @@
#ifndef OCARINA_H
#define OCARINA_H
void ocarina_quit();
#endif

10
include/ocarina/window.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef OCARINA_WINDOW_H
#define OCARINA_WINDOW_H
#include <ocarina/gtk.h>
void window_resize(int, int);
void window_init();
void window_add(GtkWidget *);
#endif