ocarina: Initialize the window from window.cpp

Eventually this will support all the same features of the old ocarina
window...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-07-29 14:53:23 -04:00
parent 681aa4b611
commit 1ddcb9f2fc
7 changed files with 41 additions and 30 deletions

View File

@ -7,8 +7,8 @@
#include <string>
using namespace std;
#define GTK_CONNECT(widget, event, func, arg) \
g_signal_connect(widget, event, G_CALLBACK(func), arg)
GtkWidget *get_widget(const string &);
string lib_file(const string &);
void box_pack_start(GtkWidget *, GtkWidget *, gboolean, gboolean, guint);
void box_pack_end(GtkWidget *, GtkWidget *, gboolean, gboolean, guint);
@ -19,7 +19,6 @@ namespace ocarina
void quit();
void idle_add();
string lib_file(string);
void init_pipe();
};

View File

@ -4,9 +4,10 @@
#include <string>
using namespace std;
void init_window();
namespace ocarina
{
namespace window
{

View File

@ -4,6 +4,5 @@ import config
config.env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
config.env.ParseConfig('pkg-config --cflags --libs gmodule-export-2.0')
#files = config.get_cpp_files()
files = ["ocarina/ocarina.cpp"]
files = config.get_cpp_files()
Return('files')

View File

@ -22,11 +22,11 @@ static void set_increment(GtkWidget *volume, double incr)
gtk_adjustment_set_page_increment(adj, incr);
}
static void changed(GtkWidget *button, gdouble value, gpointer data)
/*static void changed(GtkWidget *button, gdouble value, gpointer data)
{
//libsaria::audio::set_volume(value);
resize(button);
}
}*/
GtkWidget *make_volume_button()
{
@ -36,6 +36,6 @@ GtkWidget *make_volume_button()
gtk_widget_show(volume);
set_increment(volume, 0.05);
resize(volume);
GTK_CONNECT(volume, "value-changed", changed, NULL);
//GTK_CONNECT(volume, "value-changed", changed, NULL);
return volume;
}

View File

@ -1,16 +1,16 @@
// Copyright (c) 2011 Bryan Schumaker
#include <version.h>
#include <libsaria/libsaria.h>
#include <libsaria/print.h>
#include <gtk/gtk.h>
#include <ocarina/ocarina.h>
#include <ocarina/window.h>
/*#include <libsaria/libsaria.h>
#include <libsaria/idle.h>
#include <ocarina/playlist.h>
#include <ocarina/ocarina.h>
#include <ocarina/window.h>
#include <ocarina/body.h>*/
static string lib_path;
@ -67,7 +67,7 @@ static void idle_add()
}
} */
string lib_file(string path)
string lib_file(const string &path)
{
string res = lib_path + "/" + path;
println("Expanding to path: " + res);
@ -105,8 +105,8 @@ static void init(int argc, char **argv)
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, lib_file("ocarina.xml").c_str(), NULL);
/* Connect signals to named widgets */
connect_signal("MainWindow", "destroy", gtk_main_quit, NULL);
/* Initialize window */
init_window();
/* Show any widgets that need showing */
/* ocarina::window::init();

View File

@ -5,9 +5,9 @@
#include <libsaria/audio.h>
static GtkWidget *alsa_devices = NULL;
static unsigned int num_alsa_devices = 0;
//static unsigned int num_alsa_devices = 0;
static void set_alsa_devices(bool using_alsa)
/*static void set_alsa_devices(bool using_alsa)
{
//list<string> *devices;
list<string>::iterator it;
@ -16,15 +16,15 @@ static void set_alsa_devices(bool using_alsa)
gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(alsa_devices), 0);
num_alsa_devices = 0;
if (using_alsa == true) {
if (using_alsa == true) {*/
/*devices = libsaria::audio::get_alsa_devices();
for (it = devices->begin(); it != devices->end(); it++)
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(alsa_devices), it->c_str());
num_alsa_devices = devices->size();*/
}
}
/* }
}*/
static void change_alsa_device(GtkComboBox *combo, gpointer data)
/*static void change_alsa_device(GtkComboBox *combo, gpointer data)
{
char *device = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(alsa_devices));
if (device != NULL) {
@ -32,15 +32,15 @@ static void change_alsa_device(GtkComboBox *combo, gpointer data)
//libsaria::audio::set_device(dev);
g_free(device);
}
}
}*/
static void toggle_alsa(GtkWidget *button, gpointer data)
/*static void toggle_alsa(GtkWidget *button, gpointer data)
{
bool active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
//libsaria::audio::use_alsa(active);
gtk_widget_set_sensitive(alsa_devices, active);
set_alsa_devices(active);
}
}*/
static void add_alsa_settings(GtkWidget *general)
{
@ -53,8 +53,8 @@ static void add_alsa_settings(GtkWidget *general)
//set_alsa_devices(using_alsa);
//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), using_alsa);
GTK_CONNECT(button, "toggled", toggle_alsa, NULL);
GTK_CONNECT(alsa_devices, "changed", change_alsa_device, NULL);
//GTK_CONNECT(button, "toggled", toggle_alsa, NULL);
//GTK_CONNECT(alsa_devices, "changed", change_alsa_device, NULL);
box_pack_start(alsa, button, FALSE, FALSE, 0);
box_pack_start(alsa, alsa_devices, TRUE, TRUE, 0);

View File

@ -21,10 +21,10 @@ static void resize(int w, int h)
gtk_window_resize(GTK_WINDOW(win), w, h);
}
static void destroy(GtkWidget *widget, GdkEvent *event, gpointer data)
/*static void destroy(GtkWidget *widget, GdkEvent *event, gpointer data)
{
ocarina::quit();
}
}*/
static gboolean configure(GtkWidget *widget, GdkEvent *event, gpointer data)
{
@ -128,14 +128,14 @@ namespace ocarina
{
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(win, "destroy", G_CALLBACK(destroy), NULL);
//g_signal_connect(win, "destroy", G_CALLBACK(destroy), NULL);
g_signal_connect(win, "configure-event", G_CALLBACK(configure), NULL);
g_signal_connect(win, "window-state-event", G_CALLBACK(window_state), NULL);
g_signal_connect(win, "key-press-event", G_CALLBACK(key_pressed), NULL);
g_signal_connect_after(win, "key-press-event", G_CALLBACK(key_pressed_after), NULL);
set_title("Ocarina " + vers_str());
set_icon(lib_file("ocarina.png"));
//set_icon(lib_file("ocarina.png"));
old_w = libsaria::prefs::init("ocarina.window.w", 800);
old_h = libsaria::prefs::init("ocarina.window.h", 600);
@ -163,3 +163,15 @@ namespace ocarina
}
} /* Namespace: ocarina */
void init_window()
{
GtkWidget *window = get_widget("MainWindow");
if (!window)
return;
g_signal_connect(window, "destroy", gtk_main_quit, NULL);
gtk_window_set_title(GTK_WINDOW(window), ("Ocarina " + vers_str()).c_str());
gtk_window_set_icon_from_file(GTK_WINDOW(window), lib_file("ocarina.png").c_str(), NULL);
}