ocarina: Begin switching to GtkBuilder for the UI
I feel that hand-written UI code is slowing me down, so I'm going to switch to using glade / GtkBuilder to manage the UI as much as possible. So far, I create, show, and destroy a window. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
bfb00ec812
commit
59b79b6575
|
@ -42,7 +42,7 @@ def symlink(target, source, env):
|
||||||
SConscript(['include/Sconscript'])
|
SConscript(['include/Sconscript'])
|
||||||
ocarina = env.Program('bin/ocarina-player', directory(["libsaria", "ocarina"]))
|
ocarina = env.Program('bin/ocarina-player', directory(["libsaria", "ocarina"]))
|
||||||
oc_link = env.Command("ocarina.bin", "bin/ocarina-player", symlink)
|
oc_link = env.Command("ocarina.bin", "bin/ocarina-player", symlink)
|
||||||
oc_other = app_directory("ocarina", ["scripts", "images"])
|
oc_other = app_directory("ocarina", ["scripts", "images", "xml"])
|
||||||
Default([ocarina, oc_link, oc_other])
|
Default([ocarina, oc_link, oc_other])
|
||||||
env.Alias("ocarina", [ocarina, oc_link, oc_other])
|
env.Alias("ocarina", [ocarina, oc_link, oc_other])
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
import config
|
import config
|
||||||
|
|
||||||
config.env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
|
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 = config.get_cpp_files()
|
||||||
|
files = ["ocarina/ocarina.cpp"]
|
||||||
Return('files')
|
Return('files')
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
// Copyright (c) 2011 Bryan Schumaker
|
// Copyright (c) 2011 Bryan Schumaker
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
#include <libsaria/libsaria.h>
|
#include <libsaria/libsaria.h>
|
||||||
|
#include <libsaria/print.h>
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
/*#include <libsaria/libsaria.h>
|
||||||
#include <libsaria/idle.h>
|
#include <libsaria/idle.h>
|
||||||
|
|
||||||
#include <ocarina/playlist.h>
|
#include <ocarina/playlist.h>
|
||||||
#include <ocarina/ocarina.h>
|
#include <ocarina/ocarina.h>
|
||||||
#include <ocarina/window.h>
|
#include <ocarina/window.h>
|
||||||
#include <ocarina/body.h>
|
#include <ocarina/body.h>*/
|
||||||
|
|
||||||
static string lib_path;
|
static string lib_path;
|
||||||
static bool using_idle = false;
|
static GtkBuilder *builder;
|
||||||
|
//static bool using_idle = false;
|
||||||
|
|
||||||
static void find_exe_path(string &res)
|
static void find_exe_path(string &res)
|
||||||
{
|
{
|
||||||
|
@ -41,7 +47,7 @@ static void find_lib_path()
|
||||||
println("Lib directory? %s", lib_path.c_str());
|
println("Lib directory? %s", lib_path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean idle(gpointer data)
|
/*static gboolean idle(gpointer data)
|
||||||
{
|
{
|
||||||
libsaria::idle::run_task();
|
libsaria::idle::run_task();
|
||||||
using_idle = (libsaria::idle::size() != 0);
|
using_idle = (libsaria::idle::size() != 0);
|
||||||
|
@ -59,41 +65,55 @@ static void idle_add()
|
||||||
g_idle_add(idle, NULL);
|
g_idle_add(idle, NULL);
|
||||||
using_idle = true;
|
using_idle = true;
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
|
||||||
namespace ocarina
|
string lib_file(string path)
|
||||||
{
|
{
|
||||||
|
string res = lib_path + "/" + path;
|
||||||
string lib_file(string path)
|
println("Expanding to path: " + res);
|
||||||
{
|
return res;
|
||||||
string res = lib_path + "/" + path;
|
|
||||||
println("Expanding to path: " + res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
gtk_main_quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static gboolean timeout_poll(gpointer data)
|
static gboolean timeout_poll(gpointer data)
|
||||||
{
|
{
|
||||||
idle_add();
|
idle_add();
|
||||||
ocarina::body::set_now_playing();
|
ocarina::body::set_now_playing();
|
||||||
ocarina::body::update_controls();
|
ocarina::body::update_controls();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
GtkWidget *get_widget(const string &name)
|
||||||
|
{
|
||||||
|
GtkWidget *widget = GTK_WIDGET(gtk_builder_get_object(builder, name.c_str()));
|
||||||
|
if (!widget)
|
||||||
|
println(name + " is not a widget!");
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void connect_signal(const string &name, const string &signal, GCallback func, void *data)
|
||||||
|
{
|
||||||
|
GtkWidget *widget = get_widget(name);
|
||||||
|
if (widget)
|
||||||
|
g_signal_connect(widget, signal.c_str(), func, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init(int argc, char **argv)
|
static void init(int argc, char **argv)
|
||||||
{
|
{
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
ocarina::window::init();
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* Show any widgets that need showing */
|
||||||
|
/* ocarina::window::init();
|
||||||
ocarina::body::init();
|
ocarina::body::init();
|
||||||
ocarina::playlist::init();
|
ocarina::playlist::init();
|
||||||
ocarina::init_pipe();
|
ocarina::init_pipe();
|
||||||
gtk_timeout_add(100, timeout_poll, NULL);
|
gtk_timeout_add(100, timeout_poll, NULL);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
import shutil
|
||||||
|
from config import *
|
||||||
|
|
||||||
|
lib = "../lib/" + application + "/%s"
|
||||||
|
|
||||||
|
def copy_xml(target, source, env):
|
||||||
|
dst = str(target[0].rfile())
|
||||||
|
src = str(source[0].rfile())
|
||||||
|
shutil.copy(src, dst)
|
||||||
|
|
||||||
|
files = []
|
||||||
|
if application == "ocarina":
|
||||||
|
dst = lib % "ocarina.xml"
|
||||||
|
files.append(AlwaysBuild(env.Command(dst, "ocarina.xml", copy_xml)))
|
||||||
|
|
||||||
|
Return('files')
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
|
<object class="GtkWindow" id="MainWindow">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
Loading…
Reference in New Issue