ffi-efl 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+ #! /usr/bin/env ruby
2
+ # -*- coding: UTF-8 -*-
3
+ #
4
+ require 'efl/evas'
5
+ require 'efl/elementary/elementary-ffi'
6
+ #
7
+ module Efl
8
+ module Elm
9
+ #
10
+ class << self
11
+ def init *args
12
+ a = args.select { |e| e.is_a? String }
13
+ return Efl::API.elm_init 0, FFI::MemoryPointer::NULL if a.length==0
14
+ ptr = FFI::MemoryPointer.new :pointer, a.length
15
+ a.each_with_index do |s,i|
16
+ ptr[i].write_pointer FFI::MemoryPointer.from_string(s)
17
+ end
18
+ Efl::API.elm_init a.length, ptr
19
+ end
20
+ end
21
+ #
22
+ class ElmWin
23
+ include Efl::Helper
24
+ @func_prefixes = [ 'elm_win_', 'elm_' ].freeze
25
+ def initialize parent, title, type=:elm_win_basic
26
+ @evas_object = Evas::EvasObject.new Efl::API.elm_win_add parent, title, type
27
+ @ptr = @evas_object.ptr
28
+ yield self,@evas_object if block_given?
29
+ end
30
+ def add e
31
+ eo = Evas::EvasObject.new Efl::API.send "elm_#{e}_add", @ptr
32
+ yield eo if block_given?
33
+ eo
34
+ end
35
+ def smart_callback_add event_str, cb, data=FFI::MemoryPointer::NULL
36
+ Efl::API.evas_object_smart_callback_add @ptr, event_str, cb, data
37
+ end
38
+ end
39
+ #
40
+ end
41
+ end
42
+ #
43
+ # EOF