summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--lib/efl/edje.rb10
-rw-r--r--spec/edje_spec.rb53
-rw-r--r--test/test_edje.rb71
4 files changed, 79 insertions, 57 deletions
diff --git a/TODO b/TODO
index 8057b65..137a191 100644
--- a/TODO
+++ b/TODO
@@ -28,7 +28,7 @@ Ecore
- ecore_evas_maximized_set
Edje
- - ...
+ - test/test_edje.rb crashes or freeze at exit
Elementary
- ...
diff --git a/lib/efl/edje.rb b/lib/efl/edje.rb
index e5a1033..d2b2e6b 100644
--- a/lib/efl/edje.rb
+++ b/lib/efl/edje.rb
@@ -40,6 +40,16 @@ module Efl
# EAPI Evas_Object *edje_object_part_table_child_get (Evas_Object *obj, const char *part, unsigned int col, unsigned int row);
Evas::RevasObject.new Native.edje_object_part_table_child_get @ptr, part, col, row
end
+ def file_get
+ f = FFI::MemoryPointer.new :pointer
+ g = FFI::MemoryPointer.new :pointer
+ Native.edje_object_file_get @ptr, f, g
+ [ f.read_pointer.read_string, g.read_pointer.read_string ]
+ end
+ def data_get k
+ Native.edje_object_data_get @ptr, k
+ end
+ alias :data :data_get
end
#
end
diff --git a/spec/edje_spec.rb b/spec/edje_spec.rb
index 1a82650..9bfe32e 100644
--- a/spec/edje_spec.rb
+++ b/spec/edje_spec.rb
@@ -5,10 +5,8 @@ EDC_FILE=File.join '/tmp','edje_spec.edc'
EDJE_FILE=File.join '/tmp','edje_spec.edj'
#
if __FILE__==$0
- if not File.exists? EDJE_FILE
- File.open(EDC_FILE,'w') do |f| f << DATA.read end
- system "edje_cc #{EDC_FILE}"
- end
+ File.open(EDC_FILE,'w') do |f| f << DATA.read end
+ system "edje_cc #{EDC_FILE}"
exit File.exists?(EDJE_FILE)
else
describe "generate #{EDJE_FILE}" do
@@ -94,8 +92,8 @@ describe Efl::Edje do
end
#
it "file_data_get should work" do
- Edje.file_data_get(EDJE_FILE, "key1").should == "value1"
- Edje.file_data_get(EDJE_FILE, "key6").should == nil
+ Edje.file_data_get(EDJE_FILE, "key1").should == "val1"
+ Edje.file_data_get(EDJE_FILE, "key2").should == nil
end
#
it "file_cache get/set should work" do
@@ -116,6 +114,7 @@ describe Efl::Edje do
describe Efl::Edje::REdje do
before(:all) do
Efl::Evas.init
+ Efl::Edje.init
realize_evas
@ed = @e.edje_object_add
@ed.file_set EDJE_FILE, "my_group"
@@ -126,6 +125,7 @@ describe Efl::Edje do
after(:all) do
@e.free
@pixels.free
+ Efl::Edje.shutdown
Efl::Evas.shutdown
end
#
@@ -142,14 +142,21 @@ describe Efl::Edje do
@ed.mirrored?.should be_false
@ed.mirrored_get.should be_false
end
+ #
+ it "data_get hould work" do
+ @ed.data("key2").should == "val2"
+ @ed.data_get("key2").should == "val2"
+ @ed.data_get("key1").should == nil
+ end
+ #
+ it "file_get should work" do
+ @ed.file_get[0].should == EDJE_FILE
+ @ed.file_get[1].should == "my_group"
+ end
# EAPI void edje_extern_object_min_size_set (Evas_Object *obj, Evas_Coord minw, Evas_Coord minh);
# EAPI void edje_extern_object_max_size_set (Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh);
# EAPI void edje_extern_object_aspect_set (Evas_Object *obj, Edje_Aspect_Control aspect, Evas_Coord aw, Evas_Coord ah);
# EAPI void edje_box_layout_register (const char *name, Evas_Object_Box_Layout func, void *(*layout_data_get)(void *), void (*layout_data_free)(void *), void (*free_data)(void *), void *data);
- # EAPI Evas_Object *edje_object_add (Evas *evas);
- # EAPI const char *edje_object_data_get (const Evas_Object *obj, const char *key);
- # EAPI Eina_Bool edje_object_file_set (Evas_Object *obj, const char *file, const char *group);
- # EAPI void edje_object_file_get (const Evas_Object *obj, const char **file, const char **group);
# EAPI Edje_Load_Error edje_object_load_error_get (const Evas_Object *obj);
# EAPI const char *edje_load_error_str (Edje_Load_Error error);
# EAPI Eina_Bool edje_object_preload (Evas_Object *obj, Eina_Bool cancel);
@@ -279,12 +286,14 @@ end
__END__
data {
- item: "key1" "value1";
- item: "key2" "value2";
+ item: "key1" "val1";
}
collections {
group {
name: "my_group";
+ data {
+ item: "key2" "val2";
+ }
parts {
part {
name: "background";
@@ -293,8 +302,14 @@ collections {
description {
state: "default" 0.0;
color: 255 255 255 255;
- rel1 { relative: 0.0 0.0; offset: 0 0; }
- rel2 { relative: 1.0 1.0; offset: -1 -1; }
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 0 0;
+ }
+ rel2 {
+ relative: 1.0 1.0;
+ offset: -1 -1;
+ }
}
}
part {
@@ -304,8 +319,14 @@ collections {
description {
state: "default" 0.0;
color: 255 0 0 255;
- rel1 { relative: 0.1 0.2; offset: 5 10; }
- rel2 { relative: 0.9 0.8; offset: -6 -11; }
+ rel1 {
+ relative: 0.1 0.2;
+ offset: 5 10;
+ }
+ rel2 {
+ relative: 0.9 0.8;
+ offset: -6 -11;
+ }
text {
font: "Sans";
size: 10;
diff --git a/test/test_edje.rb b/test/test_edje.rb
index 23d71f2..0a45037 100644
--- a/test/test_edje.rb
+++ b/test/test_edje.rb
@@ -1,15 +1,10 @@
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
-require 'efl/eina'
-require 'efl/evas'
require 'efl/ecore'
require 'efl/ecore_evas'
require 'efl/edje'
#
-Efl::Eina::init
-Efl::Evas::init
-Efl::Ecore::init
Efl::EcoreEvas::init
Efl::Edje::init
#
@@ -18,18 +13,21 @@ HEIGHT=240
EDC_FILE=File.join '/tmp','edje_test.edc'
EDJE_FILE=File.join '/tmp','edje_test.edj'
#
-if not File.exists? EDJE_FILE
- File.open(EDC_FILE,'w') do |f| f << DATA.read end
- system "edje_cc #{EDC_FILE}"
-end
+puts "write #{EDC_FILE}"
+content = DATA.read
+File.open(EDC_FILE,'w') do |f| f << content end
+puts "compile #{EDJE_FILE}"
+system "edje_cc #{EDC_FILE}"
#
def create_my_group canvas, txt
- #edje = edje_object_add(canvas);
edje = canvas.edje_object_add
if not edje.file_set EDJE_FILE, "my_group"
puts "unable to open #{EDJE_FILE}"
exit 1
end
+ puts "file and group : #{edje.file_get.join ' ; ' }"
+ puts "key1 : #{Efl::Native.edje_file_data_get EDJE_FILE, "key1"}"
+ puts "key2 : #{Efl::Native.edje_object_data_get edje, "key2"}"
edje.part_text_set "text", txt unless txt.nil?
edje.move 0, 0
edje.resize WIDTH, HEIGHT
@@ -41,6 +39,7 @@ txt = ( ARGV.length>0 ? ARGV[0] : nil )
#
window = Efl::EcoreEvas::REcoreEvas.new { |w|
w.resize WIDTH, HEIGHT
+ w.move 100, 100
}
#
canvas = window.get
@@ -52,28 +51,33 @@ Efl::Ecore.main_loop_begin
edje.free
window.free
#
+Efl::Edje::shutdown
+Efl::EcoreEvas::shutdown
__END__
-// compile: edje_cc edje_example.edc
+data {
+ item: "key1" "val1";
+}
collections {
group {
- name: "my_group"; // must be the same as in edje_example.c
+ name: "my_group";
+ data {
+ item: "key2" "val2";
+ }
parts {
part {
name: "background";
- type: RECT; // plain boring rectangle
- mouse_events: 0; // we don't need any mouse event on the background
- // just one state "default"
+ type: RECT;
+ mouse_events: 0;
description {
- state: "default" 0.0; // must always exist
- color: 255 255 255 255; // white
- // define part coordinates:
- rel1 { // top-left point at (0, 0) [WIDTH * 0 + 0, HEIGHT * 0 + 0]
+ state: "default" 0.0;
+ color: 255 255 255 255;
+ rel1 {
relative: 0.0 0.0;
offset: 0 0;
}
- rel2 { // bottom-right point at (WIDTH * 1.0 - 1, HEIGHT * 1.0 - 1)
+ rel2 {
relative: 1.0 1.0;
offset: -1 -1;
}
@@ -82,56 +86,43 @@ collections {
part {
name: "text";
type: TEXT;
- mouse_events: 1; // we want to change the color on mouse-over
- // 2 states, one "default" and another "over" to be used
- // on mouse over effect
+ mouse_events: 1;
description {
state: "default" 0.0;
- color: 255 0 0 255; // red
- // define part coordinates:
- rel1 { // top-left at (WIDTH * 0.1 + 5, HEIGHT * 0.2 + 10)
+ color: 255 0 0 255;
+ rel1 {
relative: 0.1 0.2;
offset: 5 10;
}
- rel2 { // bottom-right at (WIDTH * 0.9 - 6, HEIGHT * 0.8 - 11)
+ rel2 {
relative: 0.9 0.8;
offset: -6 -11;
}
- // define text specific state details
text {
- font: "Sans"; /* using fontconfig name! */
+ font: "Sans";
size: 10;
text: "hello world";
}
}
description {
state: "over" 0.0;
- inherit: "default" 0.0; // copy everything from "default" at this point
- color: 0 255 0 255; // override color, now it is green
+ inherit: "default" 0.0;
+ color: 0 255 0 255;
}
}
- // do programs to change color on text mouse in/out (over)
programs {
program {
- // what triggers this program:
signal: "mouse,in";
source: "text";
- // what this program does:
action: STATE_SET "over" 0.0;
target: "text";
- // do the state-set in a nice interpolation animation
- // using linear time in 0.1 second
transition: LINEAR 0.1;
}
program {
- // what triggers this program:
signal: "mouse,out";
source: "text";
- // what this program does:
action: STATE_SET "default" 0.0;
target: "text";
- // do the state-set in a nice interpolation animation
- // using linear time in 0.1 second
transition: LINEAR 0.1;
}
}