summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-06-17 02:23:53 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-06-17 02:23:53 +0200
commitca7a0bfa5dd63fc45df0a46800a76d7048e70f2b (patch)
tree9af785b9d1171999b5894251c88146faac1366fe
parentc3354ad1fd4f843d80ebdd290c8dbaf81919ca38 (diff)
downloadephraim-ca7a0bfa5dd63fc45df0a46800a76d7048e70f2b.tar
ephraim-ca7a0bfa5dd63fc45df0a46800a76d7048e70f2b.zip
Started writing GUI
-rw-r--r--.gitignore3
-rw-r--r--core/ephraim.erl (renamed from ephraim.erl)7
-rw-r--r--core/ephraim_conn.erl (renamed from ephraim_conn.erl)0
-rw-r--r--core/ephraim_conv.erl (renamed from ephraim_conv.erl)0
-rw-r--r--gui/CoreConnector.vala72
-rw-r--r--gui/Ephraim.vala31
-rw-r--r--gui/ephraim.glade200
7 files changed, 309 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 27d389a..c2a0d67 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.beam
-*~ \ No newline at end of file
+*~
+gui/Ephraim
diff --git a/ephraim.erl b/core/ephraim.erl
index 60902da..6a68de0 100644
--- a/ephraim.erl
+++ b/core/ephraim.erl
@@ -27,12 +27,13 @@ init() ->
-spec get_conv(#state{},exmpp_jid:jid()) -> {#state{},pid()}.
get_conv(State, JID) ->
- case dict:find(JID, State#state.convs) of
+ Key = exmpp_jid:to_lower(exmpp_jid:bare(JID)),
+ case dict:find(Key, State#state.convs) of
{ok, Conv} ->
{State, Conv};
error ->
- Conv = spawn(ephraim_conv, init, [JID]),
- Dict = dict:store(JID, Conv, State#state.convs),
+ Conv = spawn(ephraim_conv, init, [Key]),
+ Dict = dict:store(Key, Conv, State#state.convs),
{State#state{convs=Dict}, Conv}
end.
diff --git a/ephraim_conn.erl b/core/ephraim_conn.erl
index 18edd6a..18edd6a 100644
--- a/ephraim_conn.erl
+++ b/core/ephraim_conn.erl
diff --git a/ephraim_conv.erl b/core/ephraim_conv.erl
index 99c7668..99c7668 100644
--- a/ephraim_conv.erl
+++ b/core/ephraim_conv.erl
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 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkWindow" id="MainWindow">
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkMenuBar" id="menubar1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkMenuItem" id="menuitem1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Datei</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="menu1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem1">
+ <property name="label">gtk-new</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem2">
+ <property name="label">gtk-open</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem3">
+ <property name="label">gtk-save</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem4">
+ <property name="label">gtk-save-as</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="separatormenuitem1">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem5">
+ <property name="label">gtk-quit</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Bearbeiten</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="menu2">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem6">
+ <property name="label">gtk-cut</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem7">
+ <property name="label">gtk-copy</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem8">
+ <property name="label">gtk-paste</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem9">
+ <property name="label">gtk-delete</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Ansicht</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Hilfe</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="menu3">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem10">
+ <property name="label">gtk-about</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHPaned" id="RosterPane">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkTreeView" id="Roster">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">RosterStore</property>
+ </object>
+ <packing>
+ <property name="resize">False</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkNotebook" id="Conversations">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="scrollable">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkListStore" id="RosterStore"/>
+</interface>