From bdaae5b6704e29919ec7f284b9e3abe54f96f2f8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 17 Jun 2010 13:07:17 +0200 Subject: Added CMake build system --- src/gui/CMakeLists.txt | 13 +++ src/gui/CoreConnector.vala | 73 +++++++++++++++++ src/gui/Ephraim.vala | 27 ++++++ src/gui/ephraim.glade | 200 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 313 insertions(+) create mode 100644 src/gui/CMakeLists.txt create mode 100644 src/gui/CoreConnector.vala create mode 100644 src/gui/Ephraim.vala create mode 100644 src/gui/ephraim.glade (limited to 'src/gui') diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt new file mode 100644 index 0000000..8839e16 --- /dev/null +++ b/src/gui/CMakeLists.txt @@ -0,0 +1,13 @@ +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ephraim_BINARY_DIR}) + +vala_precompile(VALA_C + "Ephraim.vala" + "CoreConnector.vala" +PACKAGES + gtk+-2.0 + erl_interface +OPTIONS + --thread +) + +add_executable("ephraim-gtk" ${VALA_C}) diff --git a/src/gui/CoreConnector.vala b/src/gui/CoreConnector.vala new file mode 100644 index 0000000..08ed43f --- /dev/null +++ b/src/gui/CoreConnector.vala @@ -0,0 +1,73 @@ +public class CoreConnector { + unowned Thread thread; + bool running; + + private class TermStore { + public Erl.Term term; + } + + static construct { + Erl.init(); + } + + public CoreConnector() { + running = false; + } + + public bool start() { + if(running) + return true; + + running = true; + + try { + thread = Thread.create(receive, true); + return true; + } catch(ThreadError e) { + return false; + } + } + + public void stop() { + if(!running) + return; + + running = false; + thread.join(); + } + + private void* receive() { + Erl.Node node = Erl.Node("ephraim-gtk", "magiccookie", 0); + Erl.Connection con = node.connect("ephraim-core@avalon.local"); + + con.reg_send("ephraim", Erl.mk_self_pid(node)); + + while(running) { + TermStore response = new TermStore(); + Erl.ReceiveType ret = con.receive(out response.term, 1000); + + switch(ret) { + case Erl.ReceiveType.ERROR: + if(Erl.errno == Erl.Error.TIMEDOUT) + break; + + running = false; + break; + case Erl.ReceiveType.TICK: + // Do nothing + break; + case Erl.ReceiveType.MSG: + Idle.add(() => {handleTerm(response); return false;}); + break; + } + } + + return null; + } + + private void handleTerm(TermStore store) { + unowned Erl.Term term = store.term; + Erl.print_term(stdout, term); + stdout.printf("\n"); + } +} diff --git a/src/gui/Ephraim.vala b/src/gui/Ephraim.vala new file mode 100644 index 0000000..a52c4df --- /dev/null +++ b/src/gui/Ephraim.vala @@ -0,0 +1,27 @@ +public class Ephraim { + public static int main(string[] args) { + Gtk.init(ref args); + + Gtk.Builder builder = new Gtk.Builder(); + try { + builder.add_from_file("ephraim.glade"); + } catch(Error e) { + return 1; + } + + CoreConnector coreconn = new CoreConnector(); + + if(!coreconn.start()) + return 1; + + unowned Gtk.Window window = builder.get_object("MainWindow") as Gtk.Window; + window.hide.connect(Gtk.main_quit); + window.show(); + + Gtk.main(); + + coreconn.stop(); + + return 0; + } +} diff --git a/src/gui/ephraim.glade b/src/gui/ephraim.glade new file mode 100644 index 0000000..b1b3455 --- /dev/null +++ b/src/gui/ephraim.glade @@ -0,0 +1,200 @@ + + + + + + + + True + vertical + + + True + + + True + _Datei + True + + + True + + + gtk-new + True + True + True + + + + + gtk-open + True + True + True + + + + + gtk-save + True + True + True + + + + + gtk-save-as + True + True + True + + + + + True + + + + + gtk-quit + True + True + True + + + + + + + + + True + _Bearbeiten + True + + + True + + + gtk-cut + True + True + True + + + + + gtk-copy + True + True + True + + + + + gtk-paste + True + True + True + + + + + gtk-delete + True + True + True + + + + + + + + + True + _Ansicht + True + + + + + True + _Hilfe + True + + + True + + + gtk-about + True + True + True + + + + + + + + + False + 0 + + + + + True + True + + + True + True + RosterStore + + + False + True + + + + + True + True + True + + + + + + + + + + + + + + + + + + + + + True + True + + + + + 1 + + + + + + + -- cgit v1.2.3