From ca7a0bfa5dd63fc45df0a46800a76d7048e70f2b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 17 Jun 2010 02:23:53 +0200 Subject: Started writing GUI --- gui/CoreConnector.vala | 72 ++++++++++++++++++ gui/Ephraim.vala | 31 ++++++++ gui/ephraim.glade | 200 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 303 insertions(+) create mode 100644 gui/CoreConnector.vala create mode 100644 gui/Ephraim.vala create mode 100644 gui/ephraim.glade (limited to 'gui') diff --git a/gui/CoreConnector.vala b/gui/CoreConnector.vala new file mode 100644 index 0000000..a3f0910 --- /dev/null +++ b/gui/CoreConnector.vala @@ -0,0 +1,72 @@ +using Erl; + + +public class CoreConnector { + unowned Thread thread; + bool running; + + private class TermStore { + public Erl.Term term; + } + + 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 Term term = store.term; + Erl.print_term(stdout, term); + stdout.printf("\n"); + } +} diff --git a/gui/Ephraim.vala b/gui/Ephraim.vala new file mode 100644 index 0000000..d05e449 --- /dev/null +++ b/gui/Ephraim.vala @@ -0,0 +1,31 @@ +using Gtk; + + +public class Ephraim { + public static int main(string[] args) { + Gtk.init(ref args); + Erl.init(); + + 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/gui/ephraim.glade b/gui/ephraim.glade new file mode 100644 index 0000000..b1b3455 --- /dev/null +++ b/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