• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

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

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


コミットメタ情報

リビジョンa689d76504790521946f98ef88f6d553b7322ae8 (tree)
日時2015-03-22 21:21:38
作者Shyouzou Sugitani <shy@user...>
コミッターShyouzou Sugitani

ログメッセージ

update error checking(3)

変更サマリ

差分

--- a/lib/ninix/balloon.rb
+++ b/lib/ninix/balloon.rb
@@ -45,18 +45,16 @@ module Balloon
4545 @parent = parent
4646 end
4747
48- def handle_request(event_type, event, *arglist, **argdict)
48+ def handle_request(event_type, event, *arglist)
4949 #assert event_type in ['GET', 'NOTIFY']
5050 handlers = {
5151 'reset_user_interaction' => 'reset_user_interaction',
5252 }
53-# handler = handlers.get(event)
54-# if handler == nil
5553 if !handlers.include?(event)
5654 result = @parent.handle_request(
57- event_type, event, *arglist, **argdict)
55+ event_type, event, *arglist)
5856 else
59- result = handler(*arglist, **argdict)
57+ result = handlers[event].call(*arglist)
6058 end
6159 if event_type == 'GET'
6260 return result
@@ -142,7 +140,6 @@ module Balloon
142140 communicate3 = nil
143141 for key in balloon.keys
144142 value = balloon[key]
145-# for key, value in balloon.items()
146143 if ['arrow0', 'arrow1'].include?(key)
147144 balloon0[key] = value
148145 balloon1[key] = value
@@ -182,7 +179,7 @@ module Balloon
182179 end
183180
184181 def add_window(side)
185-# assert @window.length == side
182+ #assert @window.length == side
186183 if side == 0
187184 name = 'balloon.sakura'
188185 id_format = 's'
@@ -198,8 +195,7 @@ module Balloon
198195 end
199196 gtk_window = create_gtk_window(name)
200197 balloon_window = BalloonWindow.new(
201- gtk_window, side, @desc, balloon,
202- id_format)
198+ gtk_window, side, @desc, balloon, id_format)
203199 balloon_window.set_responsible(self)
204200 @window << balloon_window
205201 end
@@ -569,7 +565,7 @@ module Balloon
569565 @parent = parent
570566 end
571567
572-# @property
568+ #@property
573569 def scale
574570 scaling = @parent.handle_request('GET', 'get_preference', 'balloon_scaling')
575571 scale = @parent.handle_request('GET', 'get_preference', 'surface_scale')
@@ -580,12 +576,12 @@ module Balloon
580576 end
581577 end
582578
583-# @property
579+ #@property
584580 def direction
585581 return @__direction
586582 end
587583
588-# @direction.setter
584+ #@direction.setter
589585 def direction(direction)
590586 if @__direction != direction
591587 @__direction = direction # 0: left, 1: right
@@ -658,7 +654,7 @@ module Balloon
658654
659655 def reset_sstp_marker
660656 if @side == 0
661-# assert @balloon_surface != nil
657+ #assert @balloon_surface != nil
662658 w = @balloon_surface.width
663659 h = @balloon_surface.height
664660 # sstp marker position
@@ -677,7 +673,7 @@ module Balloon
677673 def reset_arrow
678674 # arrow positions
679675 @arrow = []
680-# assert @balloon_surface != nil
676+ #assert @balloon_surface != nil
681677 w = @balloon_surface.width
682678 h = @balloon_surface.height
683679 x = config_adjust('arrow0.x', w, -10)
@@ -767,7 +763,7 @@ module Balloon
767763 def get_balloon_size(scaling=true)
768764 w = @width
769765 h = @height
770-# scale = @scale
766+ #scale = @scale
771767 if scaling
772768 w = (w * scale / 100.0).to_i
773769 h = (h * scale / 100.0).to_i
@@ -787,13 +783,13 @@ module Balloon
787783 balloon_id = @id_format + (0 + @__direction).to_i.to_s
788784 @balloon_surface = get_image_surface(balloon_id)
789785 end
790-# assert @balloon_surface != nil
786+ #assert @balloon_surface != nil
791787 @balloon_id = balloon_id
792788 # change surface and window position
793789 x, y = @position
794790 @width = @balloon_surface.width
795791 @height = @balloon_surface.height
796-# scale = @scale
792+ #scale = @scale
797793 w = (@width * scale / 100.0).to_i
798794 h = (@height * scale / 100.0).to_i
799795 @window.update_size(w, h)
@@ -825,18 +821,6 @@ module Balloon
825821 return value.to_i
826822 end
827823
828- def __get_with_type(name, conv, default_value)
829- path, config = @balloon[@balloon_id]
830- value = config.get_with_type(name, conv)
831- if value == nil
832- value = @desc.get_with_type(name, conv)
833- if value == nil
834- value = default_value
835- end
836- end
837- return conv(value)
838- end
839-
840824 def __get(name, default_value)
841825 path, config = @balloon[@balloon_id]
842826 value = config.get(name)
@@ -849,18 +833,6 @@ module Balloon
849833 return value
850834 end
851835
852-# def __get_with_scaling(name, conv, default_value)
853-# path, config = @balloon[@balloon_id]
854-# value = config.get_with_type(name, conv)
855-# if value == nil
856-# value = @desc.get_with_type(name, conv)
857-# if value == nil
858-# value = default_value
859-# end
860-# end
861-# return conv(value * scale / 100)
862-# end
863-
864836 def __get_with_scaling(name, default_value)
865837 path, config = @balloon[@balloon_id]
866838 value = config.get(name)
@@ -910,11 +882,7 @@ module Balloon
910882 end
911883
912884 def is_shown
913- if @__shown
914- return 1
915- else
916- return 0
917- end
885+ return @__shown
918886 end
919887
920888 def show
@@ -960,15 +928,14 @@ module Balloon
960928 end
961929 @sstp_message = message.to_s + " (" + sender.to_s + ")"
962930 x, y, w, h = @sstp_region
963-# @sstp_layout.set_text(@sstp_message, -1)
964931 @sstp_layout.set_text(@sstp_message)
965932 message_width, message_height = @sstp_layout.pixel_size
966933 if message_width > w
967- @sstp_message = '... ({0})'.format(sender)
934+ @sstp_message = '... (' + sender + ')'
968935 i = 0
969936 while 1
970937 i += 1
971- s = '{0}... ({1})'.format(message[0, i], sender)
938+ s = message[0, i] + '... (' + sender + ')'
972939 @sstp_layout.set_text(s, -1)
973940 message_width, message_height = \
974941 @sstp_layout.get_pixel_size()
@@ -999,13 +966,10 @@ module Balloon
999966 end
1000967 # draw sstp message
1001968 x, y, w, h = @sstp_region
1002-# @sstp_layout.set_text(@sstp_message, -1)
1003969 @sstp_layout.set_text(@sstp_message)
1004970 cr.set_source_rgba(*@sstp_message_color)
1005971 cr.move_to(x, y)
1006972 cr.show_pango_layout(@sstp_layout)
1007-# PangoCairo.update_layout(cr, @sstp_layout)
1008-# PangoCairo.show_layout(cr, @sstp_layout)
1009973 cr.restore()
1010974 end
1011975
@@ -1134,8 +1098,6 @@ module Balloon
11341098 cr.set_source_rgba(*@text_normal_color)
11351099 cr.move_to(x, y)
11361100 cr.show_pango_layout(@layout)
1137-# PangoCairo.update_layout(cr, @layout)
1138-# PangoCairo.show_layout(cr, @layout)
11391101 if @sstp_surface != nil
11401102 for l, c in @sstp_marker
11411103 if l == i
@@ -1221,8 +1183,7 @@ module Balloon
12211183 cr.fill()
12221184 cr.move_to(x, y)
12231185 cr.set_source_rgba(*@text_active_color)
1224- PangoCairo.update_layout(cr, @layout)
1225- PangoCairo.show_layout(cr, @layout)
1186+ cr.show_pango_layout(@layout)
12261187 end
12271188 end
12281189 end
@@ -1234,7 +1195,7 @@ module Balloon
12341195 for i in 0..(@link_buffer.length - 1)
12351196 sl = @link_buffer[i][0]
12361197 el = @link_buffer[i][2]
1237- if @lineno <= sl <= @lineno + @lines
1198+ if @lineno <= sl and sl <= @lineno + @lines
12381199 sn = @link_buffer[i][1]
12391200 en = @link_buffer[i][3]
12401201 for n in sl..el
@@ -1258,7 +1219,7 @@ module Balloon
12581219 @layout.set_markup(markup, -1)
12591220 text_w, text_h = @layout.get_pixel_size()
12601221 w = text_w
1261- if x <= px < x + w and y <= py < y + h
1222+ if x <= px and px < x + w and y <= py and py < y + h
12621223 new_selection = i
12631224 break
12641225 end
@@ -1270,8 +1231,8 @@ module Balloon
12701231 sl, sn, el, en, link_id, raw_text, text = \
12711232 @link_buffer[new_selection]
12721233 @parent.handle_request(
1273- 'NOTIFY', 'notify_event',
1274- 'OnChoiceEnter', raw_text, link_id, @selection)
1234+ 'NOTIFY', 'notify_event',
1235+ 'OnChoiceEnter', raw_text, link_id, @selection)
12751236 end
12761237 else
12771238 if @selection != nil
@@ -1290,9 +1251,9 @@ module Balloon
12901251 if event.hint?
12911252 _, x, y, state = widget.window.get_device_position(event.device)
12921253 else
1293- x, y, state = event.x, event.y, event.get_state()
1254+ x, y, state = event.x, event.y, event.state
12941255 end
1295-# scale = @scale
1256+ #scale = @scale
12961257 px, py = @window.winpos_to_surfacepos(x, y, scale)
12971258 if @link_buffer
12981259 if check_link_region(px, py)
@@ -1300,7 +1261,7 @@ module Balloon
13001261 end
13011262 end
13021263 if not @parent.handle_request('GET', 'busy')
1303- if state & Gdk.ModifierType.BUTTON1_MASK
1264+ if (state & Gdk::Window::ModifierType::BUTTON1_MASK).nonzero?
13041265 if @x_root != nil and \
13051266 @y_root != nil
13061267 @dragged = true
@@ -1309,8 +1270,8 @@ module Balloon
13091270 @x_fractions = x_delta - x_delta.to_i
13101271 @y_fractions = y_delta - y_delta.to_i
13111272 @parent.handle_request(
1312- 'NOTIFY', 'update_balloon_offset',
1313- @side, x_delta.to_i, y_delta.to_i)
1273+ 'NOTIFY', 'update_balloon_offset',
1274+ @side, x_delta.to_i, y_delta.to_i)
13141275 @x_root = event.x_root
13151276 @y_root = event.y_root
13161277 end
@@ -1321,14 +1282,14 @@ module Balloon
13211282
13221283 def scroll(darea, event)
13231284 px, py = @window.winpos_to_surfacepos(
1324- event.x.to_i, event.y.to_i, scale)
1325- if event.direction == Gdk.ScrollDirection.UP
1285+ event.x.to_i, event.y.to_i, scale)
1286+ if event.direction == Gdk::EventScroll::UP
13261287 if @lineno > 0
13271288 @lineno = [@lineno - 2, 0].max
13281289 check_link_region(px, py)
13291290 @darea.queue_draw()
13301291 end
1331- elsif event.direction == Gdk.ScrollDirection.DOWN
1292+ elsif event.direction == Gdk::EventScroll::DOWN
13321293 if @lineno + @lines < @text_buffer.length
13331294 @lineno = [@lineno + 2,
13341295 @text_buffer.length - @lines].min
@@ -1353,12 +1314,12 @@ module Balloon
13531314 end
13541315 # arrows
13551316 px, py = @window.winpos_to_surfacepos(
1356- event.x.to_i, event.y.to_i, scale)
1317+ event.x.to_i, event.y.to_i, scale)
13571318 # up arrow
13581319 w = @arrow0_surface.get_width()
13591320 h = @arrow0_surface.get_height()
13601321 x, y = @arrow[0]
1361- if x <= px <= x + w and y <= py <= y + h
1322+ if x <= px and px <= x + w and y <= py and py <= y + h
13621323 if @lineno > 0
13631324 @lineno = [@lineno - 2, 0].max
13641325 @darea.queue_draw()
@@ -1369,7 +1330,7 @@ module Balloon
13691330 w = @arrow1_surface.get_width()
13701331 h = @arrow1_surface.get_height()
13711332 x, y = @arrow[1]
1372- if x <= px <= x + w and y <= py <= y + h
1333+ if x <= px and px <= x + w and y <= py and py <= y + h
13731334 if @lineno + @lines < @text_buffer.length
13741335 @lineno = [@lineno + 2,
13751336 @text_buffer.length - @lines].min
@@ -1395,7 +1356,7 @@ module Balloon
13951356
13961357 def button_release(window, event)
13971358 x, y = @window.winpos_to_surfacepos(
1398- event.x.to_i, event.y.to_i, scale)
1359+ event.x.to_i, event.y.to_i, scale)
13991360 if @dragged
14001361 @dragged = false
14011362 end
@@ -1582,7 +1543,7 @@ module Balloon
15821543 return
15831544 end
15841545 line = @text_buffer.length - 1
1585- if @lineno <= line && line < @lineno + @lines
1546+ if @lineno <= line and line < @lineno + @lines
15861547 x, y, w, h = @line_regions[line - @lineno]
15871548 if @text_buffer[line].end_with?('\n[half]')
15881549 offset = line - @lineno + 1
@@ -1654,10 +1615,10 @@ module Balloon
16541615 drag_data_received(w, e)
16551616 end
16561617 # DnD data types
1657-# dnd_targets = [Gtk.TargetEntry.new('text/plain', 0, 0)]
1658-# @window.drag_dest_set(Gtk.DestDefaults.ALL, dnd_targets,
1659-# Gdk.DragAction.COPY)
1660-# @window.drag_dest_add_text_targets()
1618+ dnd_targets = [['text/plain', 0, 0]]
1619+ @window.drag_dest_set(Gtk::Drag::DestDefaults::ALL, dnd_targets,
1620+ Gdk::DragContext::Action::COPY)
1621+ @window.drag_dest_add_text_targets()
16611622 @window.set_events(Gdk::Event::BUTTON_PRESS_MASK)
16621623 @window.set_modal(true)
16631624 @window.set_window_position(Gtk::Window::Position::CENTER)
@@ -1709,7 +1670,7 @@ module Balloon
17091670 else
17101671 box = Gtk::HBox.new(spacing=10)
17111672 box.set_border_width(10)
1712- if ENTRY
1673+ if not ENTRY.empty?
17131674 label = Gtk::Label.new(label=ENTRY)
17141675 box.pack_start(label, false, true, 0)
17151676 label.show()
@@ -1726,15 +1687,25 @@ module Balloon
17261687
17271688 def redraw(widget, cr, surface)
17281689 cr.set_source_surface(surface, 0, 0)
1729- cr.set_operator(cairo.OPERATOR_SOURCE)
1690+ cr.set_operator(Cairo::OPERATOR_SOURCE)
17301691 cr.paint()
1731- region = Gdk.cairo_region_create_from_surface(cr.get_target())
1692+ w, h = @window.size
1693+ image_surface = cr.target.map_to_image
1694+ region = Cairo::Region.new()
1695+ data = image_surface.data
1696+ for i in 0..(data.size / 4 - 1)
1697+ if (data[i * 4 + 3].ord) != 0
1698+ x = i % image_surface.width
1699+ y = i / image_surface.width
1700+ region.union!(x, y, 1, 1)
1701+ end
1702+ end
17321703 # XXX: to avoid losing focus in the text input region
17331704 x = @entry.get_margin_left()
17341705 y = @entry.get_margin_top()
17351706 w = @entry.get_allocated_width()
17361707 h = @entry.get_allocated_height()
1737- region.union(cairo.RectangleInt(x, y, w, h))
1708+ region.union!(x, y, w, h)
17381709 @window.input_shape_combine_region(region)
17391710 end
17401711
@@ -1752,7 +1723,7 @@ module Balloon
17521723 end
17531724
17541725 def key_press(widget, event)
1755- if event.keyval == Gdk.KEY_Escape
1726+ if event.keyval == Gdk::Keyval::GDK_KEY_Escape
17561727 @window.hide()
17571728 cancel()
17581729 return true
@@ -1763,8 +1734,8 @@ module Balloon
17631734 def button_press(widget, event)
17641735 if [1, 2].include?(event.button)
17651736 @window.begin_move_drag(
1766- event.button, event.x_root.to_i, event.y_root.to_i,
1767- Gtk.get_current_event_time())
1737+ event.button, event.x_root.to_i, event.y_root.to_i,
1738+ Gtk.current_event_time())
17681739 end
17691740 return true
17701741 end
@@ -1780,14 +1751,14 @@ module Balloon
17801751 @window.show()
17811752 end
17821753
1783-# @abc.abstractmethod
1754+ #@abc.abstractmethod
17841755 def enter
1785-# pass
1756+ #pass
17861757 end
17871758
1788-# @abc.abstractmethod
1759+ #@abc.abstractmethod
17891760 def cancel
1790-# pass
1761+ #pass
17911762 end
17921763 end
17931764
@@ -1810,7 +1781,7 @@ module Balloon
18101781 end
18111782
18121783 def key_press(widget, event)
1813- if event.keyval == Gdk.KEY_Escape
1784+ if event.keyval == Gdk::Keyval::GDK_KEY_Escape
18141785 @window.hide()
18151786 cancel()
18161787 @parent.handle_request('NOTIFY', 'reset_user_interaction')
--- a/lib/ninix/config.rb
+++ b/lib/ninix/config.rb
@@ -16,19 +16,6 @@ module NConfig
1616
1717 class Config < Hash
1818
19- def get_with_type(name, conv, default=nil)
20- value = self.get(name)
21- if value == nil
22- return default
23- end
24- ##assert conv is not None
25- begin
26- return conv(value)
27- rescue
28- return default # XXX
29- end
30- end
31-
3219 def get(name, default=nil)
3320 if name.class == Array
3421 keylist = name
@@ -42,11 +29,6 @@ module NConfig
4229 end
4330 return default
4431 end
45-
46-# def __str__
47-# return ''.join(
48-# ['{0},{1}\n'.format(key, value) for key, value in self.items()])
49-# end
5032 end
5133
5234 def self.create_from_file(path)
--- a/lib/ninix/home.rb
+++ b/lib/ninix/home.rb
@@ -181,7 +181,7 @@ module Home
181181 next
182182 end
183183 if balloon_info.include?('balloon_dir') # XXX
184- logging.warninig('Oops: balloon id confliction')
184+ #logging.warninig('Oops: balloon id confliction')
185185 next
186186 else
187187 balloon_info['balloon_dir'] = [subdir, NConfig.null_config()]
@@ -325,7 +325,7 @@ module Home
325325 end
326326 line = line.encode('UTF-8', :invalid => :replace)
327327 if not line.include?('=')
328- error = 'line {0:d}: syntax error'.format(lineno)
328+ error = 'line ' + lineno.to_s + ': syntax error'
329329 break
330330 end
331331 x = line.split('=', 2)
@@ -341,7 +341,7 @@ module Home
341341 kinoko[name] = value.to_i
342342 end
343343 if error
344- logging.error('Error: {0}\n{1} (skipped)'.format(error, path))
344+ #logging.error('Error: {0}\n{1} (skipped)'.format(error, path))
345345 return nil
346346 end
347347 end
@@ -669,7 +669,7 @@ module Home
669669 begin
670670 charset = temp.split(',', 2)[1].strip().force_encoding('ascii')
671671 rescue #except:
672- pass
672+ #pass
673673 end
674674 next
675675 end
@@ -687,8 +687,7 @@ module Home
687687 buf << temp[0, temp.length - 2]
688688 end
689689 if not opened
690- logging.error(
691- 'syntax error: unbalnced "}" in surfaces.txt.')
690+ #logging.error('syntax error: unbalnced "}" in surfaces.txt.')
692691 end
693692 match = re_alias.match(key)
694693 if match
@@ -702,7 +701,7 @@ module Home
702701 begin
703702 key = key[0, -10]
704703 rescue #except:
705- pass
704+ #pass
706705 end
707706 value = {}
708707 for line in buf
@@ -722,13 +721,13 @@ module Home
722721 begin
723722 key = [key[0, 7], key[7, key.length - 1].to_i.to_s].join('')
724723 rescue #except ValueError:
725- pass
724+ #pass
726725 end
727726 else
728727 begin
729728 key = ['surface', key.to_i.to_s].join('')
730729 rescue #except ValueError:
731- pass
730+ #pass
732731 end
733732 end
734733 config_list << [key, NConfig.create_from_buffer(buf, charset)]
@@ -769,8 +768,8 @@ module Home
769768 x = x.to_i
770769 y = y.to_i
771770 rescue #except ValueError:
772- logging.error(
773- 'invalid element spec for {0}: {1}'.format(key, config[key]))
771+ #logging.error(
772+ # 'invalid element spec for {0}: {1}'.format(key, config[key]))
774773 next
775774 end
776775 buf << [key, method, filename, x, y]
--- a/lib/ninix/kinoko.rb
+++ b/lib/ninix/kinoko.rb
@@ -44,12 +44,12 @@ module Kinoko
4444 EOS
4545 @__menu_list = {
4646 'settings' => [['Settings', nil, _('Settings...(_O)'), nil,
47- '', lambda {|a, b| return @parent.handle_request('NOTIFY', 'edit_preferences')}],
47+ '', lambda {|a, b| @parent.handle_request('NOTIFY', 'edit_preferences')}],
4848 '/ui/popup/Settings'],
4949 'skin' => [['Skin', nil, _('Skin(_K)'), nil],
5050 nil, '/ui/popup/Skin'],
5151 'exit' => [['Exit', nil, _('Exit(_Q)'), nil,
52- '', lambda {|a, b| return @parent.handle_request('NOTIFY', 'close')}],
52+ '', lambda {|a, b| @parent.handle_request('NOTIFY', 'close')}],
5353 '/ui/popup/Exit'],
5454 }
5555 actions = Gtk::ActionGroup.new('Actions')
@@ -155,7 +155,7 @@ module Kinoko
155155 @skin.set_position() ## FIXME
156156 end
157157 else
158- ##logging.debug('OBSERVER(kinoko): ignore - {0}'.format(event))
158+ #logging.debug('OBSERVER(kinoko): ignore - {0}'.format(event))
159159 end
160160 end
161161
--- a/lib/ninix/nekodorif.rb
+++ b/lib/ninix/nekodorif.rb
@@ -158,7 +158,7 @@ module Nekodorif
158158 elsif event == 'finalize'
159159 finalize()
160160 else
161- ##logging.debug('OBSERVER(nekodorif): ignore - {0}'.format(event))
161+ #logging.debug('OBSERVER(nekodorif): ignore - {0}'.format(event))
162162 end
163163 end
164164
--- a/lib/ninix/seriko.rb
+++ b/lib/ninix/seriko.rb
@@ -103,12 +103,12 @@ module Seriko
103103 @prev_tick = current_tick
104104 update_frame(window)
105105 if @dirty
106- @dirty = false
107106 window.update_frame_buffer()
107+ @dirty = false
108108 end
109109 if @move != nil
110- @move = nil
111110 window.move_surface(*@move)
111+ @move = nil
112112 end
113113 @timeout_id = GLib::Timeout.add((1000.0 / @fps).to_i) { update(window) } # [msec]
114114 return false
--- a/lib/ninix/surface.rb
+++ b/lib/ninix/surface.rb
@@ -15,6 +15,7 @@
1515
1616 require "gtk3"
1717
18+require "ninix/keymap"
1819 require "ninix/pix"
1920 require "ninix/seriko"
2021
@@ -34,20 +35,19 @@ module Surface
3435 @parent = parent
3536 end
3637
37- def handle_request(event_type, event, *arglist, **argdict)
38+ def handle_request(event_type, event, *arglist)
3839 ##assert ['GET', 'NOTIFY'].include?(event_type)
3940 handlers = {
4041 'stick_window' => 'window_stick',
4142 }
4243 if handlers.include?(event)
43- result = handlers[event].call #( *arglist, **argdict)
44+ result = handlers[event].call # no argument
4445 else
45-# handler = handlers.get(event, getattr(self, event, None))
46-# if handler == nil
47- result = @parent.handle_request(
48- event_type, event, *arglist, **argdict)
49-# else
50-# result = handler(*arglist, **argdict)
46+ if Surface.method_defined?(event)
47+ result = method(event).call(*arglist)
48+ else
49+ result = @parent.handle_request(event_type, event, *arglist)
50+ end
5151 end
5252 if event_type == 'GET'
5353 return result
@@ -103,8 +103,8 @@ module Surface
103103
104104 def window_iconify(flag)
105105 gtk_window = @window[0].window
106- iconified = gtk_window.window.state & \
107- Gdk::EventWindowState::ICONIFIED
106+ iconified = (gtk_window.window.state & \
107+ Gdk::EventWindowState::ICONIFIED).nonzero?
108108 if flag and not iconified
109109 gtk_window.iconify()
110110 elsif not flag and iconified
@@ -116,18 +116,18 @@ module Surface
116116 if not @parent.handle_request('GET', 'is_running')
117117 return
118118 end
119- if not (event.changed_mask & Gdk::EventWindowState::ICONIFIED)
119+ if (event.changed_mask & Gdk::EventWindowState::ICONIFIED).zero?
120120 return
121121 end
122- if event.new_window_state & Gdk::EventWindowState::ICONIFIED
122+ if (event.new_window_state & Gdk::EventWindowState::ICONIFIED).nonzero?
123123 if window == @window[0].get_window
124124 @parent.handle_request('NOTIFY', 'notify_iconified')
125125 end
126126 for surface_window in @window
127127 gtk_window = surface_window.get_window
128128 if gtk_window != window and \
129- not gtk_window.window.state & \
130- Gdk::EventWindowState::ICONIFIED
129+ (gtk_window.window.state & \
130+ Gdk::EventWindowState::ICONIFIED).nonzero?
131131 gtk_window.iconify()
132132 end
133133 end
@@ -135,8 +135,8 @@ module Surface
135135 for surface_window in @window
136136 gtk_window = surface_window.get_window
137137 if gtk_window != window and \
138- gtk_window.window.state & \
139- Gdk::EventWindowState::ICONIFIED
138+ (gtk_window.window.state & \
139+ Gdk::EventWindowState::ICONIFIED).nonzero?
140140 gtk_window.deiconify()
141141 end
142142 end
@@ -152,24 +152,25 @@ module Surface
152152 end
153153
154154 def key_press(window, event)
155- name = @keymap_old.get(event.keyval, event.string)
156- keycode = @keymap_new.get(event.keyval, event.string)
157- if event.type == Gdk.EventType.KEY_RELEASE
155+ name = Keymap::Keymap_old[event.keyval]
156+ keycode = Keymap::Keymap_new[event.keyval]
157+ if event.event_type == Gdk::Event::KEY_RELEASE
158158 @key_press_count = 0
159159 return true
160160 end
161- if not (event.type == Gdk.EventType.KEY_PRESS)
161+ if not (event.event_type == Gdk::Event::KEY_PRESS)
162162 return false
163163 end
164164 @key_press_count += 1
165- if event.state & \
166- (Gdk::Window::ModifierType::CONTROL_MASK | Gdk::Window::ModifierType::SHIFT_MASK)
165+ if (event.state & \
166+ (Gdk::Window::ModifierType::CONTROL_MASK | \
167+ Gdk::Window::ModifierType::SHIFT_MASK)).nonzero?
167168 if name == 'f12'
168- logging.info('reset surface position')
169+ #logging.info('reset surface position')
169170 reset_position()
170171 end
171172 if name == 'f10'
172- logging.info('reset balloon offset')
173+ #logging.info('reset balloon offset')
173174 for side in 0..@window.length-1
174175 set_balloon_offset(side, nil)
175176 end
@@ -177,8 +178,8 @@ module Surface
177178 end
178179 if name or keycode
179180 @parent.handle_request(
180- 'NOTIFY', 'notify_event', 'OnKeyPress', name, keycode,
181- @key_press_count)
181+ 'NOTIFY', 'notify_event', 'OnKeyPress', name, keycode,
182+ @key_press_count)
182183 end
183184 return true
184185 end
@@ -193,16 +194,12 @@ module Surface
193194 end
194195 end
195196
196- #re_surface_id = re.compile('^surface([0-9]+)$')
197- #RE_SURFACE_ID = re.compile('^surface([0-9]+)$')
198197 RE_SURFACE_ID = Regexp.new('^surface([0-9]+)$')
199198
200199 def get_seriko(surface)
201200 seriko = {}
202201 for basename in surface.keys
203202 path, config = surface[basename]
204-# for basename, (path, config) in surface.items()
205- #match = re_surface_id.match(basename)
206203 match = RE_SURFACE_ID.match(basename)
207204 if not match
208205 next
@@ -236,7 +233,6 @@ module Surface
236233 maxheight = 0
237234 for basename in surface.keys
238235 path, config = surface[basename]
239-# for basename, (path, config) in surface.items()
240236 if path == nil
241237 next
242238 end
@@ -247,9 +243,8 @@ module Surface
247243 if not File.exists?(dgp_path)
248244 ddp_path = [name, '.ddp'].join('')
249245 if not File.exists?(ddp_path)
250-# logging.error(
251-# '{0}: file not found (ignored)'.format(path))
252- print(path + ': file not found (ignored)' + "\n")
246+ #logging.error(
247+ # '{0}: file not found (ignored)'.format(path))
253248 next
254249 else
255250 path = ddp_path
@@ -262,7 +257,6 @@ module Surface
262257 w, h = Pix.get_png_size(path)
263258 maxwidth = [maxwidth, w].max
264259 maxheight = [maxheight, h].max
265- #match = re_surface_id.match(basename)
266260 match = RE_SURFACE_ID.match(basename)
267261 if not match
268262 next
@@ -274,16 +268,13 @@ module Surface
274268 composite_surface = {}
275269 for basename in surface.keys
276270 path, config = surface[basename]
277-# for basename, (path, config) in surface.items()
278- #match = re_surface_id.match(basename)
279271 match = RE_SURFACE_ID.match(basename)
280272 if not match
281273 next
282274 end
283275 key = match[1]
284276 if config.include?('element0')
285-# logging.debug('surface {0}'.format(key))
286- print('surface ' + key.to_s, "\n")
277+ #logging.debug('surface {0}'.format(key))
287278 composite_surface[key] = compose_elements(elements, config)
288279 end
289280 end
@@ -292,7 +283,7 @@ module Surface
292283 for key in [default_sakura, default_kero]
293284 if not surfaces.include?(key.to_s)
294285 raise SystemExit(
295- 'cannot load default surface #' + key.to_s + ' (abort)\n')
286+ 'cannot load default surface #' + key.to_s + ' (abort)\n')
296287 end
297288 end
298289 @__surfaces = surfaces
@@ -300,8 +291,6 @@ module Surface
300291 region = {}
301292 for basename in surface.keys
302293 path, config = surface[basename]
303-# for basename, (path, config) in surface.items()
304- #match = re_surface_id.match(basename)
305294 match = RE_SURFACE_ID.match(basename)
306295 if not match
307296 next
@@ -320,12 +309,10 @@ module Surface
320309 next
321310 end
322311 begin
323- for value in values[0, 4]
324- x1 = value[0].to_i
325- y1 = value[1].to_i
326- x2 = value[2].to_i
327- y2 = value[3].to_i
328- end
312+ x1 = values[0].to_i
313+ y1 = values[1].to_i
314+ x2 = values[2].to_i
315+ y2 = values[3].to_i
329316 rescue # except ValueError:
330317 next
331318 end
@@ -338,14 +325,13 @@ module Surface
338325 next
339326 end
340327 begin
341- for value in rect.split(',')
342- x1 = value[0].to_i
343- y1 = value[1].to_i
344- x2 = value[2].to_i
345- y2 = value[3].to_i
346- end
328+ values = rect.split(',')
329+ x1 = values[0].to_i
330+ y1 = values[1].to_i
331+ x2 = values[2].to_i
332+ y2 = values[3].to_i
347333 rescue # except ValueError:
348- pass
334+ #pass
349335 end
350336 buf << [part.capitalize(), x1, y1, x2, y2].join('')
351337 end
@@ -356,8 +342,6 @@ module Surface
356342 mayuna = {}
357343 for basename in surface.keys
358344 path, config = surface[basename]
359-# for basename, (path, config) in surface.items()
360- #match = re_surface_id.match(basename)
361345 match = RE_SURFACE_ID.match(basename)
362346 if not match
363347 next
@@ -409,22 +393,16 @@ module Surface
409393 end
410394
411395 def get_menu_fontcolor
412- fontcolor_r = @desc.get_with_type(
413- 'menu.background.font.color.r', int, 0)
414- fontcolor_g = @desc.get_with_type(
415- 'menu.background.font.color.g', int, 0)
416- fontcolor_b = @desc.get_with_type(
417- 'menu.background.font.color.b', int, 0)
396+ fontcolor_r = @desc.get('menu.background.font.color.r', 0).to_i
397+ fontcolor_g = @desc.get('menu.background.font.color.g', 0).to_i
398+ fontcolor_b = @desc.get('menu.background.font.color.b', 0).to_i
418399 fontcolor_r = [0, [255, fontcolor_r].min].max
419400 fontcolor_g = [0, [255, fontcolor_g].min].max
420401 fontcolor_b = [0, [255, fontcolor_b].min].max
421402 background = [fontcolor_r, fontcolor_g, fontcolor_b]
422- fontcolor_r = @desc.get_with_type(
423- 'menu.foreground.font.color.r', int, 0)
424- fontcolor_g = @desc.get_with_type(
425- 'menu.foreground.font.color.g', int, 0)
426- fontcolor_b = @desc.get_with_type(
427- 'menu.foreground.font.color.b', int, 0)
403+ fontcolor_r = @desc.get('menu.foreground.font.color.r', 0).to_i
404+ fontcolor_g = @desc.get('menu.foreground.font.color.g', 0).to_i
405+ fontcolor_b = @desc.get('menu.foreground.font.color.b', 0).to_i
428406 fontcolor_r = [0, [255, fontcolor_r].min].max
429407 fontcolor_g = [0, [255, fontcolor_g].min].max
430408 fontcolor_b = [0, [255, fontcolor_b].min].max
@@ -455,9 +433,9 @@ module Surface
455433 bind = {}
456434 for index in 0..127
457435 group = @desc.get(
458- name + '.bindgroup' + index.to_i.to_s + '.name', nil)
436+ name + '.bindgroup' + index.to_i.to_s + '.name', nil)
459437 default = @desc.get(
460- name + '.bindgroup' + index.to_i.to_s + '.default', 0)
438+ name + '.bindgroup' + index.to_i.to_s + '.default', 0)
461439 if group != nil
462440 bind[index] = [group, default]
463441 end
@@ -471,7 +449,7 @@ module Surface
471449 begin
472450 key = key.to_i
473451 rescue # except:
474- pass
452+ #pass
475453 else
476454 if bind.include?(key)
477455 group = bind[key][0].split(',')
@@ -488,10 +466,10 @@ module Surface
488466 tooltips = @__tooltips[name]
489467 end
490468 surface_window = SurfaceWindow.new(
491- gtk_window, side, @desc, surface_alias, @__surface, tooltips,
492- @__surfaces, seriko, @__region, mayuna, bind,
493- default_id, @maxsize)
494- surface_window.set_responsible(self)#.handle_request)
469+ gtk_window, side, @desc, surface_alias, @__surface, tooltips,
470+ @__surfaces, seriko, @__region, mayuna, bind,
471+ default_id, @maxsize)
472+ surface_window.set_responsible(self)
495473 @window << surface_window
496474 end
497475
@@ -517,7 +495,6 @@ module Surface
517495 for value in config[key].split(',')
518496 spec << value.strip()
519497 end
520-# spec = [value.strip() for value in config[key].split(',')]
521498 begin
522499 method, filename, x, y = spec
523500 x = x.to_i
@@ -550,12 +527,10 @@ module Surface
550527 error = 'unknown method for ' + key + ': ' + method
551528 break
552529 end
553-# logging.debug(key + ': ' + meyhod + ' ' + filename + ', x=' + x.to_i.to_s + ', y=' + y.to_i.to_s)
554- print(key + ': ' + method + ' ' + filename + ', x=' + x.to_i.to_s + ', y=' + y.to_i.to_s, "\n")
530+ #logging.debug(key + ': ' + meyhod + ' ' + filename + ', x=' + x.to_i.to_s + ', y=' + y.to_i.to_s)
555531 end
556532 if error != nil
557-# logging.error(error)
558- print(error, "\n")
533+ #logging.error(error)
559534 surface_list = []
560535 end
561536 return surface_list
@@ -676,11 +651,11 @@ module Surface
676651 x = left + scrn_w - w
677652 else
678653 b0w, b0h = @parent.handle_request(
679- 'GET', 'get_balloon_size', side - 1)
654+ 'GET', 'get_balloon_size', side - 1)
680655 b1w, b1h = @parent.handle_request(
681- 'GET', 'get_balloon_size', side)
656+ 'GET', 'get_balloon_size', side)
682657 bpx, bpy = @parent.handle_request(
683- 'GET', 'get_balloon_windowposition', side)
658+ 'GET', 'get_balloon_windowposition', side)
684659 o0x, o0y = get_balloon_offset(side - 1)
685660 o1x, o1y = get_balloon_offset(side)
686661 offset = [0, b1w - (b0w - o0x)].max
@@ -925,8 +900,14 @@ module Surface
925900 end
926901 x1, y1 = get_position(1)
927902 s1w, s1h = get_surface_size(1)
928- if (x0 < x1 + s1w / 2 < x0 + s0w and y0 < y1 + s1h / 2 < y0 + s0h) or \
929- (x1 < x0 + s0w / 2 < x1 + s1w and y1 < y0 + s0h / 2 < y1 + s1h)
903+ if (x0 < x1 + s1w / 2 and
904+ x1 + s1w / 2 < x0 + s0w and
905+ y0 < y1 + s1h / 2 and
906+ y1 + s1h / 2 < y0 + s0h) or
907+ (x1 < x0 + s0w / 2 and
908+ x0 + s0w / 2 < x1 + s1w and
909+ y1 < y0 + s0h / 2 and
910+ y0 + s0h / 2 < y1 + s1h)
930911 kasanari = true
931912 else
932913 kasanari = false
@@ -955,7 +936,7 @@ module Surface
955936 @surfaces = surfaces
956937 @image_surface = nil # XXX
957938 @seriko = Seriko::Controller.new(seriko)
958- @seriko.set_responsible(self)#.handle_request)
939+ @seriko.set_responsible(self)
959940 @region = region
960941 @mayuna = mayuna
961942 @bind = bind
@@ -1007,11 +988,10 @@ module Surface
1007988 end
1008989 end
1009990 # DnD data types
1010-## FIXME
1011-# dnd_targets = [Gtk.TargetEntry.new('text/uri-list', 0, 0)]
1012-# @darea.drag_dest_set(Gtk.DestDefaults.ALL, dnd_targets,
1013-# Gdk.DragAction.COPY)
1014-# @darea.drag_dest_add_uri_targets()
991+ dnd_targets = [['text/uri-list', 0, 0]]
992+ @darea.drag_dest_set(Gtk::Drag::DestDefaults::ALL, dnd_targets,
993+ Gdk::DragContext::Action::COPY)
994+ @darea.drag_dest_add_uri_targets()
1015995 end
1016996
1017997 def get_seriko
@@ -1031,8 +1011,8 @@ module Surface
10311011 @parent.handle_request('NOTIFY', 'reset_position') # XXX
10321012 left, top, scrn_w, scrn_h = Pix.get_workarea()
10331013 @parent.handle_request(
1034- 'NOTIFY', 'notify_event', 'OnDisplayChange',
1035- Gdk.Visual.get_best_depth(), scrn_w, scrn_h)
1014+ 'NOTIFY', 'notify_event', 'OnDisplayChange',
1015+ Gdk.Visual.get_best_depth(), scrn_w, scrn_h)
10361016 end
10371017 end
10381018
@@ -1040,19 +1020,18 @@ module Surface
10401020 @parent = parent
10411021 end
10421022
1043- def handle_request(event_type, event, *arglist, **argdict)
1023+ def handle_request(event_type, event, *arglist)
10441024 ##assert ['GET', 'NOTIFY'].include?(event_type)
10451025 handlers = {
10461026 }
10471027 if handlers.include?(event)
1048- result = handlers[event].call #( *arglist, **argdict)
1028+ result = handlers[event].call # no argument
10491029 else
1050-# handler = handlers.get(event, getattr(self, event, nil))
1051-# if handler == nil
1052- result = @parent.handle_request(
1053- event_type, event, *arglist, **argdict)
1054-# else
1055-# result = handler(*arglist, **argdict)
1030+ if SurfaceWindow.method_defined?(event)
1031+ result = method(event).call(*arglist)
1032+ else
1033+ result = @parent.handle_request(event_type, event, *arglist)
1034+ end
10561035 end
10571036 if event_type == 'GET'
10581037 return result
@@ -1067,7 +1046,7 @@ module Surface
10671046 def direction=(direction)
10681047 @__direction = direction # 0: left, 1: right
10691048 @parent.handle_request(
1070- 'NOTIFY', 'set_balloon_direction', @side, direction)
1049+ 'NOTIFY', 'set_balloon_direction', @side, direction)
10711050 end
10721051
10731052 # @property
@@ -1082,18 +1061,10 @@ module Surface
10821061 side = @side
10831062 if side == 0
10841063 name = 'sakura'
1085-# x = config.get_with_type(
1086-# name + '.balloon.offsetx', int)
1087-# y = config.get_with_type(
1088-# name + '.balloon.offsety', int)
10891064 x = config.get(name + '.balloon.offsetx').to_i
10901065 y = config.get(name + '.balloon.offsety').to_i
10911066 elsif side == 1
10921067 name = 'kero'
1093-# x = config.get_with_type(
1094-# name + '.balloon.offsetx', int)
1095-# y = config.get_with_type(
1096-# name + '.balloon.offsety', int)
10971068 x = config.get(name + '.balloon.offsetx').to_i
10981069 y = config.get(name + '.balloon.offsety').to_i
10991070 else
@@ -1101,8 +1072,6 @@ module Surface
11011072 x, y = nil, nil # XXX
11021073 end
11031074 if x == nil
1104-# x = @desc.get_with_type(
1105-# name + '.balloon.offsetx', int, 0)
11061075 x = @desc.get(name + '.balloon.offsetx')
11071076 if x == nil
11081077 x = 0
@@ -1111,8 +1080,6 @@ module Surface
11111080 end
11121081 end
11131082 if y == nil
1114-# y = @desc.get_with_type(
1115-# name + '.balloon.offsety', int, 0)
11161083 y = @desc.get(name + '.balloon.offsety')
11171084 if y == nil
11181085 y = 0
@@ -1143,8 +1110,8 @@ module Surface
11431110 end
11441111 if filelist
11451112 @parent.handle_request(
1146- 'NOTIFY', 'enqueue_event',
1147- 'OnFileDrop2', chr(1).join(filelist), @side)
1113+ 'NOTIFY', 'enqueue_event',
1114+ 'OnFileDrop2', chr(1).join(filelist), @side)
11481115 end
11491116 end
11501117
@@ -1185,7 +1152,7 @@ module Surface
11851152 @seriko.terminate(self)
11861153 end
11871154 if ['-1', '-2'].include?(surface_id)
1188- pass
1155+ #pass
11891156 elsif not @surfaces.include?(surface_id)
11901157 @surface_id = @default_id
11911158 else
@@ -1222,13 +1189,13 @@ module Surface
12221189 w, h = get_surface_size(@surface_id)
12231190 new_x, new_y = get_position()
12241191 @parent.handle_request(
1225- 'NOTIFY', 'notify_event',
1226- 'OnSurfaceChange',
1227- @parent.handle_request('GET', 'get_surface_id', 0),
1228- @parent.handle_request('GET', 'get_surface_id', 1),
1229- [@side, @surface_id, w, h].join(','),
1230- prev_id.to_s,
1231- [new_x, new_y, new_x + w, new_y + h].join(','))
1192+ 'NOTIFY', 'notify_event',
1193+ 'OnSurfaceChange',
1194+ @parent.handle_request('GET', 'get_surface_id', 0),
1195+ @parent.handle_request('GET', 'get_surface_id', 1),
1196+ [@side, @surface_id, w, h].join(','),
1197+ prev_id.to_s,
1198+ [new_x, new_y, new_x + w, new_y + h].join(','))
12321199 update_frame_buffer() #XXX
12331200 end
12341201
@@ -1277,10 +1244,9 @@ module Surface
12771244 end
12781245 begin
12791246 surface = Pix.create_surface_from_file(
1280- @surfaces[surface_id][0], is_pnr=is_pnr, use_pna=use_pna)
1247+ @surfaces[surface_id][0], is_pnr=is_pnr, use_pna=use_pna)
12811248 rescue # except:
1282-# logging.debug('cannot load surface #{0}'.format(surface_id))
1283- print('cannot load surface #' + surface_id, "\n")
1249+ #logging.debug('cannot load surface #{0}'.format(surface_id))
12841250 return Pix.create_blank_surface(100, 100)
12851251 end
12861252 for element, x, y, method in @surfaces[surface_id][1, @surfaces[surface_id].length - 1]
@@ -1291,10 +1257,10 @@ module Surface
12911257 else
12921258 is_pnr = true
12931259 use_pna = @parent.handle_request(
1294- 'GET', 'get_preference', 'use_pna')
1260+ 'GET', 'get_preference', 'use_pna')
12951261 end
12961262 overlay = Pix.create_surface_from_file(
1297- element, is_pnr=is_pnr, use_pna=use_pna)
1263+ element, is_pnr=is_pnr, use_pna=use_pna)
12981264 rescue # except:
12991265 next
13001266 end
@@ -1322,8 +1288,7 @@ module Surface
13221288
13231289 def get_image_surface(surface_id, is_asis=false)
13241290 if not @surfaces.include?(surface_id)
1325-# logging.debug('cannot load surface #{0}'.format(surface_id))
1326- print('cannot load surface #' + surface_id.to_s, "\n")
1291+ #logging.debug('cannot load surface #{0}'.format(surface_id))
13271292 return Pix.create_blank_surface(100, 100)
13281293 end
13291294 return create_surface_from_file(surface_id, is_asis=is_asis)
@@ -1347,13 +1312,10 @@ module Surface
13471312 font_desc = Pango::FontDescription.new
13481313 font_desc.set_size(8 * Pango::SCALE)
13491314 layout = cr.create_pango_layout
1350-# layout = Pango::Layout.new(@darea.pango_context)
13511315 layout.set_font_description(font_desc)
13521316 layout.set_wrap(Pango::WRAP_WORD_CHAR) # XXX
13531317 layout.set_text(part)
13541318 cr.show_pango_layout(layout)
1355-# PangoCairo.update_layout(cr, layout)
1356-# PangoCairo.show_layout(cr, layout)
13571319 end
13581320 cr.set_operator(Cairo::OPERATOR_ATOP)
13591321 cr.set_source_rgba(0.2, 0.0, 0.0, 0.4) # XXX
@@ -1415,7 +1377,7 @@ module Surface
14151377 for surface_id, x, y, method in @seriko.iter_overlays()
14161378 begin
14171379 overlay_surface = get_image_surface(
1418- surface_id, is_asis=(method == 'asis'))
1380+ surface_id, is_asis=(method == 'asis'))
14191381 rescue # except:
14201382 next
14211383 end
@@ -1437,7 +1399,7 @@ module Surface
14371399 else
14381400 cr.paint()
14391401 end
1440-# del cr
1402+ #del cr
14411403 end
14421404 @image_surface = new_surface
14431405 @darea.queue_draw()
@@ -1471,7 +1433,7 @@ module Surface
14711433 if @side < 2
14721434 args = [@side, xoffset, yoffset]
14731435 @parent.handle_request(
1474- 'NOTIFY', 'notify_observer', 'move surface', args) # animation
1436+ 'NOTIFY', 'notify_observer', 'move surface', args) # animation
14751437 end
14761438 end
14771439
@@ -1526,33 +1488,45 @@ module Surface
15261488 end
15271489 for part, x1, y1, x2, y2 in @collisions
15281490 if x1 <= x and x <= x2 and y1 <= y and y <= y2
1529- ##logging.debug('{0} touched'.format(part))
1491+ #logging.debug('{0} touched'.format(part))
15301492 return part
15311493 end
15321494 end
15331495 return ''
15341496 end
15351497
1536- def __get_with_scaling(name, conv)
1498+ def __get_with_scaling(name)
15371499 basename = ['surface', @surface_id].join('')
15381500 path, config = @surface_info[basename]
1539- value = config.get_with_type(name, conv)
1501+ value = config.get(name)
15401502 if value != nil
15411503 scale = get_scale
1542- value = conv(value * scale / 100)
1504+ value = value.to_f * scale / 100
15431505 end
15441506 return value
15451507 end
15461508
15471509 def get_center
1548- centerx = __get_with_scaling('point.centerx', int)
1549- centery = __get_with_scaling('point.centery', int)
1510+ centerx = __get_with_scaling('point.centerx')
1511+ centery = __get_with_scaling('point.centery')
1512+ if centerx
1513+ centerx = centerx.to_i
1514+ end
1515+ if centery
1516+ centery = centery.to_i
1517+ end
15501518 return centerx, centery
15511519 end
15521520
15531521 def get_kinoko_center
1554- centerx = __get_with_scaling('point.kinoko.centerx', int)
1555- centery = __get_with_scaling('point.kinoko.centery', int)
1522+ centerx = __get_with_scaling('point.kinoko.centerx')
1523+ centery = __get_with_scaling('point.kinoko.centery')
1524+ if centerx
1525+ centerx = centerx.to_i
1526+ end
1527+ if centery
1528+ centery = centery.to_i
1529+ end
15561530 return centerx, centery
15571531 end
15581532
@@ -1582,7 +1556,7 @@ module Surface
15821556 end
15831557 base_y = new_y + oy
15841558 @parent.handle_request(
1585- 'NOTIFY', 'set_balloon_position', @side, base_x, base_y)
1559+ 'NOTIFY', 'set_balloon_position', @side, base_x, base_y)
15861560 @parent.handle_request('NOTIFY', 'notify_observer', 'set position')
15871561 @parent.handle_request('NOTIFY', 'check_mikire_kasanari')
15881562 end
@@ -1615,7 +1589,7 @@ module Surface
16151589 sy = top
16161590 set_position(sx, sy)
16171591 else # free
1618- pass
1592+ #pass
16191593 end
16201594 end
16211595
@@ -1652,69 +1626,65 @@ module Surface
16521626 @window.hide()
16531627 @__shown = false
16541628 @parent.handle_request(
1655- 'NOTIFY', 'notify_observer', 'hide', (@side))
1629+ 'NOTIFY', 'notify_observer', 'hide', (@side))
16561630 end
16571631 end
16581632
16591633 def raise_
1660- @window.get_window().raise_()
1634+ @window.window.raise_()
16611635 @parent.handle_request('NOTIFY', 'notify_observer', 'raise', (@side))
16621636 end
16631637
16641638 def lower
1665- @window.get_window().lower()
1639+ @window.window.lower()
16661640 @parent.handle_request('NOTIFY', 'notify_observer', 'lower', (@side))
16671641 end
16681642
16691643 def button_press(window, event)
16701644 @parent.handle_request('NOTIFY', 'reset_idle_time')
16711645 x, y = @window.winpos_to_surfacepos(
1672- event.x.to_i, event.y.to_i, get_scale)
1646+ event.x.to_i, event.y.to_i, get_scale)
16731647 @x_root = event.x_root
16741648 @y_root = event.y_root
16751649 # automagical raise
16761650 @parent.handle_request('NOTIFY', 'notify_observer', 'raise', (@side))
16771651 if event.event_type == Gdk::Event::BUTTON2_PRESS
1678- click_count = 2
1679- else
1680- click_count = 1
1681- end
1682- ## FIXME
1683- #delivered, click_count = event.get_click_count()
1684- #if delivered
1685- if true
1686- @click_count = click_count
1687- if [1, 2, 3].include?(event.button)
1688- num_button = [0, 2, 1][event.button - 1]
1689- @parent.handle_request('NOTIFY', 'notify_event', 'OnMouseDown',
1690- x, y, 0, @side, @__current_part,
1691- num_button,
1692- 'mouse') # FIXME
1693- end
1694- if [2, 8, 9].include?(event.button)
1695- ex_button = {
1696- 2 => 'middle',
1697- 8 => 'xbutton1',
1698- 9 => 'xbutton2'
1699- }[event.button]
1700- @parent.handle_request('NOTIFY', 'notify_event', 'OnMouseDownEx',
1701- x, y, 0, @side, @__current_part,
1702- ex_button,
1703- 'mouse') # FIXME
1704- end
1652+ @click_count = 2
1653+ else # XXX
1654+ @click_count = 1
1655+ end
1656+ if [1, 2, 3].include?(event.button)
1657+ num_button = [0, 2, 1][event.button - 1]
1658+ @parent.handle_request('NOTIFY', 'notify_event', 'OnMouseDown',
1659+ x, y, 0, @side, @__current_part,
1660+ num_button,
1661+ 'mouse') # FIXME
1662+ end
1663+ if [2, 8, 9].include?(event.button)
1664+ ex_button = {
1665+ 2 => 'middle',
1666+ 8 => 'xbutton1',
1667+ 9 => 'xbutton2'
1668+ }[event.button]
1669+ @parent.handle_request('NOTIFY', 'notify_event', 'OnMouseDownEx',
1670+ x, y, 0, @side, @__current_part,
1671+ ex_button,
1672+ 'mouse') # FIXME
17051673 end
17061674 return true
17071675 end
17081676
1677+ CURSOR_HAND1 = Gdk::Cursor.new(Gdk::Cursor::Type::HAND1)
1678+
17091679 def button_release(window, event)
17101680 x, y = @window.winpos_to_surfacepos(
1711- event.x.to_i, event.y.to_i, get_scale)
1681+ event.x.to_i, event.y.to_i, get_scale)
17121682 if @dragged
17131683 @dragged = false
17141684 set_alignment_current()
17151685 @parent.handle_request(
1716- 'NOTIFY', 'notify_event',
1717- 'OnMouseDragEnd', x, y, '', @side, @__current_part, '')
1686+ 'NOTIFY', 'notify_event',
1687+ 'OnMouseDragEnd', x, y, '', @side, @__current_part, '')
17181688 end
17191689 @x_root = nil
17201690 @y_root = nil
@@ -1738,10 +1708,10 @@ module Surface
17381708 if part != @__current_part
17391709 if part == ''
17401710 @window.set_tooltip_text('')
1741- @darea.get_window().set_cursor(nil)
1711+ @darea.window.set_cursor(nil)
17421712 @parent.handle_request(
1743- 'NOTIFY', 'notify_event',
1744- 'OnMouseLeave', x, y, '', @side, @__current_part)
1713+ 'NOTIFY', 'notify_event',
1714+ 'OnMouseLeave', x, y, '', @side, @__current_part)
17451715 else
17461716 if @tooltips.include?(part)
17471717 tooltip = @tooltips[part]
@@ -1749,23 +1719,22 @@ module Surface
17491719 else
17501720 @window.set_tooltip_text('')
17511721 end
1752- cursor = Gdk.Cursor.new(Gdk.CursorType.HAND1)
1753- @darea.get_window().set_cursor(cursor)
1722+ @darea.window.set_cursor(CURSOR_HAND1)
17541723 @parent.handle_request(
1755- 'NOTIFY', 'notify_event',
1756- 'OnMouseEnter', x, y, '', @side, part)
1724+ 'NOTIFY', 'notify_event',
1725+ 'OnMouseEnter', x, y, '', @side, part)
17571726 end
17581727 end
17591728 @__current_part = part
17601729 if not @parent.handle_request('GET', 'busy')
1761- if state & Gdk.ModifierType.BUTTON1_MASK
1730+ if (state & Gdk::Window::ModifierType::BUTTON1_MASK).nonzero?
17621731 if @x_root != nil and \
17631732 @y_root != nil
17641733 if not @dragged
17651734 @parent.handle_request(
1766- 'NOTIFY', 'notify_event',
1767- 'OnMouseDragStart', x, y, '',
1768- @side, @__current_part, '')
1735+ 'NOTIFY', 'notify_event',
1736+ 'OnMouseDragStart', x, y, '',
1737+ @side, @__current_part, '')
17691738 end
17701739 @dragged = true
17711740 x_delta = (event.x_root - @x_root).to_i
@@ -1775,9 +1744,9 @@ module Surface
17751744 @x_root = event.x_root
17761745 @y_root = event.y_root
17771746 end
1778- elsif state & Gdk.ModifierType.BUTTON2_MASK or \
1779- state & Gdk.ModifierType.BUTTON3_MASK
1780- pass
1747+ elsif (state & Gdk::Window::ModifierType::BUTTON2_MASK).nonzero? or \
1748+ (state & Gdk::Window::ModifierType::BUTTON3_MASK).nonzero?
1749+ #pass
17811750 else
17821751 @parent.handle_request('NOTIFY', 'notify_surface_mouse_motion',
17831752 @side, x, y, part)
@@ -1788,10 +1757,10 @@ module Surface
17881757
17891758 def scroll(darea, event)
17901759 x, y = @window.winpos_to_surfacepos(
1791- event.x.to_i, event.y.to_i, get_scale)
1792- if event.direction == Gdk.ScrollDirection.UP
1760+ event.x.to_i, event.y.to_i, get_scale)
1761+ if event.direction == Gdk::EventScroll::UP
17931762 count = 1
1794- elsif event.direction == Gdk.ScrollDirection.DOWN
1763+ elsif event.direction == Gdk::EventScroll::DOWN
17951764 count = -1
17961765 else
17971766 count = 0
@@ -1838,13 +1807,13 @@ module Surface
18381807 x, y = @window.winpos_to_surfacepos(x, y, get_scale)
18391808 if @__current_part != '' # XXX
18401809 @parent.handle_request(
1841- 'NOTIFY', 'notify_event',
1842- 'OnMouseLeave', x, y, '', @side, @__current_part)
1810+ 'NOTIFY', 'notify_event',
1811+ 'OnMouseLeave', x, y, '', @side, @__current_part)
18431812 @__current_part = ''
18441813 end
18451814 @parent.handle_request(
1846- 'NOTIFY', 'notify_event',
1847- 'OnMouseLeaveAll', x, y, '', @side, '')
1815+ 'NOTIFY', 'notify_event',
1816+ 'OnMouseLeaveAll', x, y, '', @side, '')
18481817 return true
18491818 end
18501819 end
--- a/test/test-balloon.rb
+++ b/test/test-balloon.rb
@@ -14,8 +14,8 @@ module NinixTest
1414 balloon.new_(*balloons[key])
1515 balloon.set_balloon(0, 0)
1616 balloon.set_balloon(1, 0)
17- balloon.set_position(0, 200, 200)
18- balloon.set_position(1, 100, 100)
17+ balloon.set_position(0, 400, 200)
18+ balloon.set_position(1, 200, 100)
1919 balloon.show(0)
2020 balloon.show(1)
2121 balloon.show_sstp_message("TEST: SSTP", "TEST class")
--- a/test/test-kinoko.rb
+++ b/test/test-kinoko.rb
@@ -44,6 +44,9 @@ module NinixTest
4444 def attach_observer(arg) # dummy
4545 end
4646
47+ def detach_observer(arg) # dummy
48+ end
49+
4750 def get_surface_scale() # dummy
4851 return 100
4952 end