summaryrefslogtreecommitdiffstats
path: root/test/test_ecore_pipe.rb
diff options
context:
space:
mode:
authorMarius Hanne <marius.hanne@sourceagency.org>2013-02-23 20:32:50 +0100
committerMarius Hanne <marius.hanne@sourceagency.org>2013-02-23 20:49:45 +0100
commit08de292b856e0e182db831ee7a6348695a19c103 (patch)
treea58cf76c782c7c3a13457347fa362b60a66184b6 /test/test_ecore_pipe.rb
parentc26b2ad177a6636ebdcea9b89c52017de8089fca (diff)
downloadffi-efl-08de292b856e0e182db831ee7a6348695a19c103.zip
ffi-efl-08de292b856e0e182db831ee7a6348695a19c103.tar.gz
examples for Ecore pipe. Thanks to jeremyz for the original -native version!
Diffstat (limited to 'test/test_ecore_pipe.rb')
-rw-r--r--test/test_ecore_pipe.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/test_ecore_pipe.rb b/test/test_ecore_pipe.rb
new file mode 100644
index 0000000..e2786b3
--- /dev/null
+++ b/test/test_ecore_pipe.rb
@@ -0,0 +1,56 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/ecore'
+require 'efl/elm/elm_win'
+require 'efl/elm/elm_bg'
+require 'efl/elm/elm_label'
+#
+include Efl
+#
+class MyWin < Elm::ElmWin
+ #
+ attr_reader :pipe
+ def initialize
+ super(nil, "Pipe test") do
+ title_set "Hello, World!"
+ resize 200, 100
+ show
+ end
+ @bg = Elm::ElmBg.new(self) do
+ size_hint_weight_expand
+ show
+ end
+ resize_object_add @bg
+ #
+ @label = Elm::ElmLabel.new(self) do
+ text_set "Hello World"
+ size_hint_weight_expand
+ show
+ end
+ resize_object_add @label
+ #
+ @pipe = Ecore.ecore_pipe_add(method(:pipe_cb), nil)
+ end
+ #
+ def pipe_cb date, buffer, n
+ @label.text_set buffer.read_string[0..n-1]
+ end
+end
+#
+Elm.init
+#
+@win = MyWin.new
+#
+pid = fork do
+ Ecore.ecore_pipe_read_close(@win.pipe)
+ [ "hello", "dying", "old", "planet", "earth"].each do |w|
+ sleep 1
+ Ecore.ecore_pipe_write @win.pipe, w, w.length
+ end
+end
+Elm.run
+Ecore.ecore_pipe_del @win.pipe
+Elm.shutdown
+#
+# EOF