• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Ruby GTK3移行後のメインリポジトリ


Commit MetaInfo

Revision151a0572fd896a9b542fbbc8771c712b3284672c (tree)
Zeit2014-05-01 23:52:11
AutorShyouzou Sugitani <shy@user...>
CommiterShyouzou Sugitani

Log Message

add kinoko.rb

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/lib/ninix/kinoko.rb
@@ -0,0 +1,599 @@
1+# -*- coding: utf-8 -*-
2+#
3+# Copyright (C) 2004-2014 by Shyouzou Sugitani <shy@users.sourceforge.jp>
4+#
5+# This program is free software; you can redistribute it and/or modify it
6+# under the terms of the GNU General Public License (version 2) as
7+# published by the Free Software Foundation. It is distributed in the
8+# hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
9+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10+# PURPOSE. See the GNU General Public License for more details.
11+#
12+
13+# TODO:
14+# - きのことサーフェスの間に他のウインドウが入ることができてしまうのを直す.
15+# - NAYUKI/2.0
16+# - 透明度の設定
17+
18+require 'gettext'
19+require "gtk3"
20+
21+require "ninix/config"
22+require "ninix/seriko"
23+require "ninix/pix"
24+
25+module Kinoko
26+
27+ class Menu
28+ include GetText
29+
30+ bindtextdomain("ninix-aya")
31+
32+ def initialize(accelgroup)
33+ @parent = nil
34+ ui_info = <<-EOS
35+ <ui>
36+ <popup name='popup'>
37+ <menuitem action='Settings'/>
38+ <menu action='Skin'>
39+ </menu>
40+ <separator/>
41+ <menuitem action='Exit'/>
42+ </popup>
43+ </ui>
44+ EOS
45+ @__menu_list = {
46+ 'settings' => [['Settings', nil, _('Settings...(_O)'), nil,
47+ '', lambda {|a, b| return @parent.handle_request('NOTIFY', 'edit_preferences')}],
48+ '/ui/popup/Settings'],
49+ 'skin' => [['Skin', nil, _('Skin(_K)'), nil],
50+ nil, '/ui/popup/Skin'],
51+ 'exit' => [['Exit', nil, _('Exit(_Q)'), nil,
52+ '', lambda {|a, b| return @parent.handle_request('NOTIFY', 'close')}],
53+ '/ui/popup/Exit'],
54+ }
55+ @__skin_list = nil
56+ actions = Gtk::ActionGroup.new('Actions')
57+ entry = []
58+ for value in @__menu_list.values()
59+ entry << value[0]
60+ end
61+ actions.add_actions(entry)
62+ ui_manager = Gtk::UIManager.new()
63+ ui_manager.insert_action_group(actions, 0)
64+ ui_manager.add_ui(ui_info)
65+ @__popup_menu = ui_manager.get_widget('/ui/popup')
66+ for key in @__menu_list.keys
67+ path = @__menu_list[key][-1]
68+ @__menu_list[key][1] = ui_manager.get_widget(path)
69+ end
70+ end
71+
72+ def set_responsible(parent)
73+ @parent = parent
74+ end
75+
76+ def popup(button)
77+ skin_list = @parent.handle_request('GET', 'get_skin_list')
78+ set_skin_menu(skin_list)
79+ @__popup_menu.popup(nil, nil, button, Gtk.current_event_time())
80+ end
81+
82+ def set_skin_menu(list) ## FIXME
83+ key = 'skin'
84+ if list
85+ menu = Gtk.Menu()
86+ for skin in list
87+ item = Gtk.MenuItem(skin['title'])
88+ item.signal_connect(
89+ 'activate',
90+ lambda {|a, k| return @parent.handle_request('NOTIFY', 'select_skin', k)},
91+ [skin])
92+ menu.add(item)
93+ item.show()
94+ end
95+ @__menu_list[key][1].set_submenu(menu)
96+ menu.show()
97+ @__menu_list[key][1].show()
98+ else
99+ @__menu_list[key][1].hide()
100+ end
101+ end
102+ end
103+
104+ class Nayuki
105+
106+ def initialize()
107+ end
108+ end
109+
110+ class Kinoko
111+
112+ def initialize(skin_list)
113+ @skin_list = skin_list
114+ @skin = nil
115+ end
116+
117+ def edit_preferences()
118+ end
119+
120+ def finalize()
121+ @__running = false
122+ self.target.detach_observer(self)
123+ if self.skin != nil
124+ self.skin.destroy()
125+ end
126+ end
127+
128+ def observer_update(event, args)
129+ if self.skin == nil
130+ return
131+ end
132+ if ['set position', 'set surface'].include?(event)
133+ self.skin.set_position()
134+ self.skin.show()
135+ elsif event == 'set scale'
136+ scale = self.target.get_surface_scale()
137+ self.skin.set_scale(scale)
138+ elsif event == 'hide'
139+ side = args
140+ if side == 0 # sakura side
141+ self.skin.hide()
142+ end
143+ elsif event == 'iconified'
144+ self.skin.hide()
145+ elsif event == 'deiconified'
146+ self.skin.show()
147+ elsif event == 'finalize'
148+ self.finalize()
149+ elsif event == 'move surface'
150+ side, xoffset, yoffset = args
151+ if side == 0 # sakura side
152+ self.skin.set_position(xoffset, yoffset)
153+ end
154+ elsif event == 'raise'
155+ side = args
156+ if side == 0 # sakura side
157+ self.skin.set_position() ## FIXME
158+ end
159+ else
160+ ##logging.debug('OBSERVER(kinoko): ignore - {0}'.format(event))
161+ end
162+ end
163+
164+ def load_skin()
165+ scale = @target.get_surface_scale()
166+ @skin = Skin.new(@accelgroup)
167+ @skin.set_responsible(@target)
168+ @skin.load(@data, scale)
169+ print("SKIN: ", @skin, "\n")
170+ end
171+
172+ def handle_request(event_type, event, *arglist, **argdict)
173+ #assert ['GET', 'NOTIFY'].include?(event_type)
174+ handlers = {
175+ 'get_target_window' => lambda {|a| return self.target.surface.window[0].window}, # XXX
176+ 'get_kinoko_position' => self.target.get_kinoko_position,
177+ }
178+ handler = handlers.get(event,
179+ getattr(self, event,
180+ lambda {|a| return nil})) ## FIXME
181+ result = handler(*arglist, **argdict)
182+ if event_type == 'GET'
183+ return result
184+ end
185+ end
186+
187+ def load(data, target)
188+ @data = data
189+ @target = target
190+ @target.attach_observer(self)
191+ @accelgroup = Gtk::AccelGroup.new()
192+ load_skin()
193+ if @skin == nil
194+ return 0
195+ else
196+ self.send_event('OnKinokoObjectCreate')
197+ end
198+ @__running = true
199+ GLib::Timeout.add(10) { do_idle_tasks } # 10[ms]
200+ return 1
201+ end
202+
203+ def do_idle_tasks()
204+ if @__running
205+ return true
206+ else
207+ return false
208+ end
209+ end
210+
211+ def close()
212+ self.finalize()
213+ self.send_event('OnKinokoObjectDestroy')
214+ end
215+
216+ def send_event(event)
217+ if not ['OnKinokoObjectCreate', 'OnKinokoObjectDestroy',
218+ 'OnKinokoObjectChanging', 'OnKinokoObjectChanged',
219+ 'OnKinokoObjectInstalled'].include?(event)
220+ ## 'OnBatteryLow', 'OnBatteryCritical',
221+ ## 'OnSysResourceLow', 'OnSysResourceCritical'
222+ return
223+ end
224+ args = [@data['title'],
225+ @data['ghost'],
226+ @data['category']]
227+ @target.notify_event(event, *args)
228+ end
229+
230+ def get_skin_list()
231+ return @skin_list
232+ end
233+
234+ def select_skin(args)
235+ self.send_event('OnKinokoObjectChanging')
236+ self.skin.destroy()
237+ self.data = args
238+ self.load_skin()
239+ if self.skin == nil
240+ return 0
241+ else
242+ self.send_event('OnKinokoObjectChanged')
243+ end
244+ return 1
245+ end
246+ end
247+
248+ class Skin
249+
250+ def initialize(accelgroup)
251+ @frame_buffer = []
252+ @accelgroup = accelgroup
253+ @parent = nil
254+ @__menu = Menu.new(@accelgroup)
255+ @__menu.set_responsible(self)
256+ end
257+
258+ def get_seriko
259+ return @seriko
260+ end
261+
262+ def set_responsible(parent)
263+ @parent = parent
264+ end
265+
266+ def handle_request(event_type, event, *arglist, **argdict)
267+ #assert ['GET', 'NOTIFY'].include?(event_type)
268+ handlers = {
269+ }
270+# handler = handlers.get(event, getattr(self, event, nil))
271+# if handler == nil
272+ if not handlers.include?(event)
273+ result = @parent.handle_request(event_type, event, *arglist, **argdict)
274+ else
275+# result = handler(*arglist, **argdict)
276+ ## FIXME
277+ result = class_eval(event) #( *arglist, **argdict)
278+ end
279+ if event_type == 'GET'
280+ return result
281+ end
282+ end
283+
284+ def load(data, scale)
285+ @data = data
286+ @__scale = scale
287+ @__shown = false
288+ @surface_id = 0 # dummy
289+ @window = Pix::TransparentWindow.new()
290+ ##self.window.set_title(''.join(('surface.', name)))
291+ @window.set_skip_taskbar_hint(true)
292+ @window.signal_connect('delete_event') do |w, e|
293+ delete(w, e)
294+ end
295+ @window.add_accel_group(@accelgroup) ## FIXME
296+ if @data['animation'] != nil
297+ path = File.join(@data['dir'], @data['animation'])
298+ actors = {'' => Seriko.get_actors(NConfig.create_from_file(path))}
299+ else
300+ base = File.basename(@data['base'], ".*")
301+ ext = File.extname(@data['base'])
302+ path = File.join(@data['dir'], base + 'a.txt')
303+ if File.exists?(path)
304+ actors = {'' => Seriko.get_actors(NConfig.create_from_file(path))}
305+ else
306+ actors = {'' => []}
307+ end
308+ end
309+ print("ACTORS: ", actors, "\n")
310+ @seriko = Seriko::Controler.new(actors)
311+ @seriko.set_responsible(self) ## FIXME
312+ path = File.join(@data['dir'], @data['base'])
313+ print("PATH: ", path, "\n")
314+ begin
315+ @image_surface = Pix.create_surface_from_file(path)
316+ w = [8, (@image_surface.width * @__scale / 100).to_i].max
317+ h = [8, (@image_surface.height * @__scale / 100).to_i].max
318+ rescue #except: ## FIXME
319+ @parent.handle_request('NOTIFY', 'close')
320+ return
321+ end
322+ print("SURFACE: ", w, " , ", h, "\n")
323+ @path = path
324+ @w, @h = w, h
325+ @darea = @window.darea # @window.get_child()
326+ @darea.set_events(Gdk::Event::EXPOSURE_MASK|
327+ Gdk::Event::BUTTON_PRESS_MASK|
328+ Gdk::Event::BUTTON_RELEASE_MASK|
329+ Gdk::Event::POINTER_MOTION_MASK|
330+ Gdk::Event::LEAVE_NOTIFY_MASK)
331+ @darea.signal_connect('button_press_event') do |w, e|
332+ button_press(w, e)
333+ end
334+ @darea.signal_connect('button_release_event') do |w, e|
335+ button_release(w, e)
336+ end
337+ @darea.signal_connect('motion_notify_event') do |w, e|
338+ motion_notify(w, e)
339+ end
340+ @darea.signal_connect('leave_notify_event') do |w, e|
341+ leave_notify(w, e)
342+ end
343+ @darea.signal_connect('draw') do |w, cr|
344+ redraw(w, cr)
345+ end
346+ @window.update_size(@w, @h)
347+ set_position()
348+ target_window = @parent.handle_request('GET', 'get_target_window')
349+ if @data['ontop']
350+ @window.set_transient_for(target_window)
351+ else
352+ target_window.set_transient_for(@window)
353+ end
354+ show()
355+ @seriko.reset(self, '') # XXX
356+ @seriko.start(self)
357+ @seriko.invoke_kinoko(self)
358+ end
359+
360+ def get_surface_id ## FIXME
361+ return @surface_id
362+ end
363+
364+ def get_preference(name) # dummy
365+ if name == 'animation_quality'
366+ return 1.0
367+ else
368+ return nil
369+ end
370+ end
371+
372+ def show()
373+ if not @__shown
374+ @window.show_all()
375+ @__shown = true
376+ end
377+ end
378+
379+ def hide()
380+ if @__shown
381+ @window.hide_all()
382+ @__shown = false
383+ end
384+ end
385+
386+ def append_actor(frame, actor)
387+ @seriko.append_actor(frame, actor)
388+ end
389+
390+ def set_position(xoffset=0, yoffset=0)
391+ base_x, base_y = @parent.handle_request('GET', 'get_kinoko_position', @data['baseposition'])
392+ a, b = [[0.5, 1], [0.5, 0], [0, 0.5], [1, 0.5], [0, 1],
393+ [1, 1], [0, 0], [1, 0], [0.5, 0.5]][@data['baseadjust']]
394+ offsetx = (@data['offsetx'] * @__scale / 100).to_i
395+ offsety = (@data['offsety'] * @__scale / 100).to_i
396+ @x = base_x - (@w * a).to_i + offsetx + xoffset
397+ @y = base_y - (@h * b).to_i + offsety + yoffset
398+ @window.move(@x, @y)
399+ end
400+
401+ def set_scale(scale)
402+ @__scale = scale
403+ reset_surface()
404+ set_position()
405+ end
406+
407+ def get_surface() ## FIXME
408+ return nil
409+ end
410+
411+ def redraw(widget, cr)
412+ scale = @__scale
413+ cr.scale(scale / 100.0, scale / 100.0)
414+ cr.set_source(@image_surface, 0, 0)
415+ cr.set_operator(Cairo::OPERATOR_SOURCE)
416+ cr.paint()
417+ print("REDRAW: ", cr, "\n")
418+ end
419+
420+ def get_image_surface(surface_id)
421+ path = File.join(@data['dir'],
422+ 'surface'+ surface_id.to_s + '.png')
423+ if File.exists?(path)
424+ surface = Pix.create_surface_from_file(path)
425+ else
426+ surface = nil
427+ end
428+ return surface
429+ end
430+
431+ def create_image_surface(surface_id)
432+ if surface_id != nil and surface_id != ''
433+ surface = get_image_surface(surface_id)
434+ else
435+ surface = Pix.create_surface_from_file(@path)
436+ end
437+ return surface
438+ end
439+
440+ def update_frame_buffer()
441+ print("UPDATE FRAME: ", @seriko.get_base_id, "\n")
442+ new_surface = create_image_surface(@seriko.get_base_id)
443+ #assert new_surface != nil
444+ # draw overlays
445+ for surface_id, x, y, method in @seriko.iter_overlays()
446+ print("OVERLAY: ", surface_id, x, y, method, "\n")
447+ if 1#begin
448+ overlay_surface = get_image_surface(surface_id)
449+ else#rescue #except:
450+ continue
451+ end
452+ # overlay surface
453+ cr = Cairo::Context.new(new_surface)
454+ cr.set_source(overlay_surface, x, y)
455+ cr.mask(overlay_surface, x, y)
456+ #del cr
457+ end
458+ #self.darea.queue_draw_area(0, 0, w, h)
459+ @image_surface = new_surface
460+ @darea.queue_draw()
461+ end
462+
463+ def terminate()
464+ @seriko.terminate(self)
465+ end
466+
467+ def add_overlay(actor, surface_id, x, y, method)
468+ @seriko.add_overlay(self, actor, surface_id, x, y, method)
469+ end
470+
471+ def remove_overlay(actor)
472+ @seriko.remove_overlay(actor)
473+ end
474+
475+ def move_surface(xoffset, yoffset)
476+ @window.move(@x + xoffset, @y + yoffset)
477+ end
478+
479+ def reset_surface() ## FIXME
480+ @seriko.reset(self, '') # XXX
481+ path = os.path.join(os.fsencode(@data['dir']),
482+ os.fsencode(@data['base']))
483+ w, h = ninix.pix.get_png_size(path)
484+ w = [8, (w * @__scale / 100).to_i].max
485+ h = [8, (h * @__scale / 100).to_i].max
486+ @w, @h = w, h # XXX
487+ @window.update_size(w, h)
488+ @window.queue_resize()
489+ @seriko.start(self)
490+ @seriko.invoke_kinoko(self)
491+ end
492+
493+ def set_surface(surface_id, restart=1) ## FIXME
494+ path = os.path.join(os.fsencode(@data['dir']),
495+ 'surface' + os.fsencode(str(surface_id)) + '.png')
496+ if os.path.exists(path)
497+ @path = path
498+ else
499+ #self.path = None
500+ @path = File.join(@data['dir'], @data['base'])
501+ end
502+ end
503+
504+ def invoke(actor_id, update=0)
505+ @seriko.invoke(self, actor_id, update)
506+ end
507+
508+ def delete() #widget, event)
509+ @parent.handle_request('NOTIFY', 'close')
510+ end
511+
512+ def destroy()
513+ @seriko.destroy()
514+ @window.destroy()
515+ end
516+
517+ def button_press(widget, event) ## FIXME
518+ @x_root = event.x_root
519+ @y_root = event.y_root
520+ if event.event_type == Gdk::Event::BUTTON_PRESS
521+ click = 1
522+ else
523+ click = 2
524+ end
525+ button = event.button
526+ if button == 3 and click == 1
527+ @__menu.popup(button)
528+ end
529+ return true
530+ end
531+
532+ def button_release(widget, event) ## FIXME
533+ end
534+
535+ def motion_notify(widget, event) ## FIXME
536+ end
537+
538+ def leave_notify(widget, event) ## FIXME
539+ end
540+ end
541+
542+ class TEST
543+
544+ def initialize(path)
545+ @win = Pix::TransparentWindow.new
546+ @win.signal_connect('destroy') do
547+ Gtk.main_quit
548+ end
549+ @win.darea.signal_connect('draw') do |w, cr|
550+ expose_cb(w, cr)
551+ end
552+ @surface = Pix.create_surface_from_file(path, true, true)
553+ @win.set_default_size(@surface.width, @surface.height)
554+ @win.show_all
555+ require "ninix/home"
556+ kinoko_list = Home.search_kinoko()
557+ kinoko = Kinoko.new(kinoko_list)
558+ print("K: ", kinoko, "\n")
559+ kinoko.load(kinoko_list.sample, self)
560+ Gtk.main
561+ end
562+
563+ def notify_event(event, *args) # dummy
564+ end
565+
566+ def handle_request(type, event, *a) # dummy
567+ if event == 'get_kinoko_position'
568+ return 0, 0
569+ end
570+ end
571+
572+ def attach_observer(arg) # dummy
573+ end
574+
575+ def get_surface_scale() # dummy
576+ return 100
577+ end
578+
579+ def expose_cb(widget, cr)
580+ cr.set_source(@surface, 0, 0)
581+ cr.set_operator(Cairo::OPERATOR_SOURCE)
582+ cr.paint
583+ region = Cairo::Region.new()
584+ data = @surface.data
585+ for i in 0..(data.size / 4 - 1)
586+ if (data[i * 4 + 3].ord) != 0
587+ x = i % @surface.width
588+ y = i / @surface.width
589+ region.union!(x, y, 1, 1)
590+ end
591+ end
592+ @win.input_shape_combine_region(region)
593+ end
594+ end
595+end
596+
597+$:.unshift(File.dirname(__FILE__))
598+
599+Kinoko::TEST.new(ARGV.shift)
--- a/lib/ninix/pix.rb
+++ b/lib/ninix/pix.rb
@@ -83,9 +83,12 @@ module Pix
8383 # ##self.input_shape_combine_region(region)
8484 # _gtkhack.gtkwindow_set_input_shape(self, cr.get_target())
8585
86-# def update_size(self, w, h):
86+ def update_size(w, h)
8787 # self.get_child().set_size_request(w, h) # XXX
8888 # self.queue_resize()
89+ @darea.set_size_request(w, h) # XXX
90+ queue_resize()
91+ end
8992
9093 # def size_allocate(self, widget, event):
9194 # new_x, new_y = self.__position
--- a/lib/ninix/seriko.rb
+++ b/lib/ninix/seriko.rb
@@ -22,13 +22,14 @@ module Seriko
2222
2323 def initialize(seriko)
2424 @seriko = seriko
25- self.request_parent = lambda {|a| return nil} # dummy
25+# self.request_parent = lambda {|a| return nil} # dummy
26+ @parent = nil
2627 @exclusive_actor = nil
2728 @base_id = nil
2829 @timeout_id = nil
2930 reset_overlays()
3031 @queue = []
31- @fps = Controler.DEFAULT_FPS
32+ @fps = DEFAULT_FPS
3233 @next_tick = 0
3334 @prev_tick = 0 # XXX
3435 @active = []
@@ -36,22 +37,27 @@ module Seriko
3637 @dirty = true
3738 end
3839
39- def set_responsible(request_method)
40- self.request_parent = request_method
40+ def set_responsible(parent) #(request_method)
41+ ##self.request_parent = request_method
42+ @parent = parent
4143 end
4244
4345 def set_base_id(window, surface_id)
4446 if surface_id == '-2'
4547 terminate(window)
46- @base_id = window.surface_id
48+ @base_id = window.get_surface_id
4749 elsif surface_id == '-1'
48- @base_id = window.surface_id
50+ @base_id = window.get_surface_id
4951 else
5052 @base_id = surface_id
5153 end
5254 @dirty = true
5355 end
5456
57+ def get_base_id()
58+ return @base_id
59+ end
60+
5561 def move_surface(xoffset, yoffset)
5662 @move = [xoffset, yoffset]
5763 end
@@ -68,7 +74,7 @@ module Seriko
6874 last_actor = actor
6975 frame, actor = get_actor_next(window)
7076 end
71- if last_actor != nil and last_actor.exclusive and \
77+ if last_actor != nil and last_actor.exclusive? and \
7278 last_actor.terminate_flag and @exclusive_actor == nil # XXX
7379 invoke_restart(window)
7480 end
@@ -76,18 +82,20 @@ module Seriko
7682
7783 def get_actor_next(window)
7884 if not @active.empty?
79- @active.sort(key=lambda {|x| return x[0]})
85+ @active.sort {|x| x[0]} # (key=lambda {|x| return x[0]})
8086 if @active[0][0] <= @next_tick
81- return @active.pop(0)
87+ return @active.shift
8288 end
8389 end
8490 return nil, nil
8591 end
8692
8793 def update(window)
88- current_tick = GLib.get_monotonic_time() # [microsec]
89- quality = self.request_parent('GET', 'get_preference', 'animation_quality')
90- @fps = Controler.DEFAULT_FPS * quality
94+ ##current_tick = GLib.get_monotonic_time() # [microsec]
95+ ## FIXME: GLib.get_monotonic_time
96+ current_tick = (Time.now.to_f * 1000000).to_i # [microsec]
97+ quality = @parent.handle_request('GET', 'get_preference', 'animation_quality')
98+ @fps = DEFAULT_FPS * quality
9199 if @prev_tick == 0 ## First time
92100 delta_tick = 1000.0 / @fps # [msec]
93101 else
@@ -104,8 +112,7 @@ module Seriko
104112 window.move_surface(*@move)
105113 @move = nil
106114 end
107- @timeout_id = GLib.timeout_add((1000.0 / @fps).to_i, # [msec]
108- @update, window)
115+ @timeout_id = GLib::Timeout.add((1000.0 / @fps).to_i) { update(window) } # [msec]
109116 return false
110117 end
111118
@@ -131,7 +138,6 @@ module Seriko
131138 begin
132139 del @overlays[actor]
133140 rescue # except KeyError:
134- pass
135141 end
136142 @dirty = true
137143 end
@@ -157,7 +163,7 @@ module Seriko
157163 @queue << actor
158164 return
159165 end
160- if actor.exclusive
166+ if actor.exclusive?
161167 lock_exclusive(window, actor)
162168 end
163169 actor.invoke(window, @next_tick)
@@ -261,11 +267,11 @@ module Seriko
261267 terminate(window)
262268 @next_tick = 0
263269 @prev_tick = 0 # XXX
264- set_base_id(window, window.surface_id)
270+ set_base_id(window, window.get_surface_id)
265271 if @seriko.include?(surface_id)
266272 @base_id = surface_id
267273 else
268- @base_id = window.surface_id
274+ @base_id = window.get_surface_id
269275 end
270276 @dirty = true # XXX
271277 end
@@ -276,8 +282,7 @@ module Seriko
276282 if @timeout_id != nil
277283 GLib.source_remove(@timeout_id)
278284 end
279- @timeout_id = GLib.timeout_add((1000.0 / @fps).to_i, # [msec]
280- @update, window)
285+ @timeout_id = GLib::Timeout.add((1000.0 / @fps).to_i) { update(window) } # [msec]
281286 end
282287
283288 def terminate(window)
@@ -311,7 +316,7 @@ module Seriko
311316 end
312317
313318 def iter_overlays()
314- actors = list(@overlays.keys())
319+ actors = @overlays.keys()
315320 temp = []
316321 for actor in actors
317322 temp << [actor.get_id(), actor]
@@ -323,13 +328,16 @@ module Seriko
323328 temp << actor
324329 end
325330 actors = temp
331+ result = []
326332 for actor in actors
327333 surface_id, x, y, method = @overlays[actor]
328334 ##logging.debug(
329335 ## 'actor={0:d}, id={1}, x={2:d}, y={3:d}'.format(
330336 ## actor.get_id(), surface_id, x, y))
331- yield surface_id, x, y, method
337+ #yield surface_id, x, y, method
338+ result << [surface_id, x, y, method]
332339 end
340+ return result
333341 end
334342 end
335343
@@ -343,7 +351,15 @@ module Seriko
343351 @last_method = nil
344352 @exclusive = 0
345353 @post_proc = nil
346- @terminate_flag = 1
354+ @terminate_flag = true
355+ end
356+
357+ def exclusive?
358+ if @exclusive != 0
359+ return true
360+ else
361+ return false
362+ end
347363 end
348364
349365 def set_post_proc(proc, args)
@@ -372,18 +388,17 @@ module Seriko
372388 end
373389
374390 def invoke(window, base_frame)
375- @terminate_flag = 0
391+ @terminate_flag = false
376392 end
377393
378394 def update(window, base_frame)
379395 if @terminate_flag
380- return False
396+ return false
381397 end
382- pass
383398 end
384399
385400 def terminate()
386- @terminate_flag = 1
401+ @terminate_flag = true
387402 if @post_proc != nil
388403 proc, args = @post_proc
389404 @post_proc = nil
@@ -405,23 +420,23 @@ module Seriko
405420 'interpolate', 'reduce', 'replace', 'asis']
406421
407422 def show_pattern(window, surface, method, args)
408- if Actor.OVERLAY_SET.include?(@last_method)
423+ if OVERLAY_SET.include?(@last_method)
409424 window.remove_overlay(self)
410425 end
411426 if method == 'move'
412- window.seriko.move_surface(args[0], args[1]) ## FIXME
413- elsif Actor.OVERLAY_SET.include?(method)
427+ window.get_seriko.move_surface(args[0], args[1]) ## FIXME
428+ elsif OVERLAY_SET.include?(method)
414429 window.add_overlay(self, surface, args[0], args[1], method)
415430 elsif method == 'base'
416- window.seriko.set_base_id(window, surface) ## FIXME
431+ window.get_seriko.set_base_id(window, surface) ## FIXME
417432 elsif method == 'start'
418433 window.invoke(args[0], update=1)
419434 elsif method == 'alternativestart'
420435 window.invoke(args.sample, update=1)
421436 elsif method == 'stop'
422- window.seriko.stop_actor(args[0]) ## FIXME
437+ window.get_seriko.stop_actor(args[0]) ## FIXME
423438 elsif method == 'alternativestop'
424- window.seriko.stop_actor(args.sample) ## FIXME
439+ window.get_seriko.stop_actor(args.sample) ## FIXME
425440 else
426441 raise RuntimeError('should not reach here')
427442 end
@@ -440,14 +455,14 @@ module Seriko
440455
441456 def invoke(window, base_frame)
442457 terminate()
443- @terminate_flag = 0
458+ @terminate_flag = false
444459 @pattern = 0
445460 update(window, base_frame)
446461 end
447462
448463 def update(window, base_frame)
449464 if @terminate_flag
450- return False
465+ return false
451466 end
452467 if @pattern == 0
453468 @surface_id = window.get_surface()
@@ -459,7 +474,7 @@ module Seriko
459474 end
460475 show_pattern(window, surface, method, args)
461476 window.append_actor(base_frame + interval, self)
462- return False
477+ return false
463478 end
464479 end
465480
@@ -479,14 +494,14 @@ module Seriko
479494
480495 def invoke(window, base_frame)
481496 terminate()
482- @terminate_flag = 0
497+ @terminate_flag = false
483498 reset()
484499 window.append_actor(base_frame + @wait, self)
485500 end
486501
487502 def update(window, base_frame)
488503 if @terminate_flag
489- return False
504+ return false
490505 end
491506 if @pattern == 0
492507 @surface_id = window.get_surface()
@@ -500,7 +515,7 @@ module Seriko
500515 end
501516 show_pattern(window, surface, method, args)
502517 window.append_actor(base_frame + @wait, self)
503- return False
518+ return false
504519 end
505520 end
506521
@@ -515,7 +530,7 @@ module Seriko
515530
516531 def invoke(window, base_frame)
517532 terminate()
518- @terminate_flag = 0
533+ @terminate_flag = false
519534 @wait = 0
520535 @pattern = 0
521536 update(window, base_frame)
@@ -523,7 +538,7 @@ module Seriko
523538
524539 def update(window, base_frame)
525540 if @terminate_flag
526- return False
541+ return false
527542 end
528543 if @pattern == 0
529544 @surface_id = window.get_surface()
@@ -540,7 +555,7 @@ module Seriko
540555 if @wait >= 0
541556 window.append_actor(base_frame + @wait, self)
542557 end
543- return False
558+ return false
544559 end
545560 end
546561
@@ -553,7 +568,7 @@ module Seriko
553568
554569 def invoke(window, base_frame)
555570 terminate()
556- @terminate_flag = 0
571+ @terminate_flag = false
557572 @wait = 0
558573 @pattern = 0
559574 update(window, base_frame)
@@ -561,7 +576,7 @@ module Seriko
561576
562577 def update(window, base_frame)
563578 if @terminate_flag
564- return False
579+ return false
565580 end
566581 if @pattern == 0
567582 @surface_id = window.get_surface()
@@ -578,7 +593,7 @@ module Seriko
578593 if @wait >= 0
579594 window.append_actor(base_frame + @wait, self)
580595 end
581- return False
596+ return false
582597 end
583598 end
584599
@@ -586,11 +601,9 @@ module Seriko
586601 class Mayuna < Actor
587602
588603 def set_exclusive()
589- pass
590604 end
591605
592606 def show_pattern(window, surface, method, args)
593- pass
594607 end
595608 end
596609