Ruby GTK3移行後のメインリポジトリ
リビジョン | 8848b96c209616ab197818cbd66dfb23e0c544f2 (tree) |
---|---|
日時 | 2015-05-05 01:15:54 |
作者 | Shyouzou Sugitani <shy@user...> |
コミッター | Shyouzou Sugitani |
assorted fixes(8)
@@ -281,12 +281,12 @@ module Menu | ||
281 | 281 | |
282 | 282 | def create_mayuna_menu(mayuna_menu) |
283 | 283 | @__mayuna_menu = [] |
284 | - for side in mayuna_menu | |
284 | + for side in mayuna_menu.keys | |
285 | 285 | if side == 'sakura' |
286 | 286 | index = 0 |
287 | 287 | elsif side == 'kero' |
288 | 288 | index = 1 |
289 | - elsif side.startswith('char') | |
289 | + elsif side.start_with?('char') | |
290 | 290 | begin |
291 | 291 | index = side[4, side.length].to_i |
292 | 292 | rescue #except: |
@@ -213,7 +213,7 @@ module Sakura | ||
213 | 213 | |
214 | 214 | def get_shell_menu() |
215 | 215 | current_key = get_current_shell() |
216 | - for key in @shells | |
216 | + for key in @shells.keys | |
217 | 217 | menuitem = @shells[key].menuitem |
218 | 218 | menuitem.set_sensitive(key != current_key) # not working |
219 | 219 | end |
@@ -669,9 +669,9 @@ module Sakura | ||
669 | 669 | end |
670 | 670 | |
671 | 671 | def is_URL(s) |
672 | - return (s.startswith('http://') or \ | |
673 | - s.startswith('ftp://') or \ | |
674 | - s.startswith('file:/')) | |
672 | + return (s.start_with?('http://') or \ | |
673 | + s.start_with?('ftp://') or \ | |
674 | + s.start_with?('file:/')) | |
675 | 675 | end |
676 | 676 | |
677 | 677 | def is_anchor(link_id) |
@@ -1184,8 +1184,8 @@ module Sakura | ||
1184 | 1184 | RESET_EVENT = ['OnVanishSelecting', 'OnVanishCancel'] ## FIXME |
1185 | 1185 | |
1186 | 1186 | def notify_event(event, *arglist, event_type: 'GET', default: nil) |
1187 | - if @time_critical_session and event.startswith('OnMouse') | |
1188 | - return 0 | |
1187 | + if @time_critical_session and event.start_with?('OnMouse') | |
1188 | + return false | |
1189 | 1189 | end |
1190 | 1190 | if RESET_EVENT.include?(event) |
1191 | 1191 | reset_script(true) |
@@ -1233,7 +1233,7 @@ module Sakura | ||
1233 | 1233 | start_script(script) |
1234 | 1234 | @balloon.hide_sstp_message() |
1235 | 1235 | end |
1236 | - return 1 | |
1236 | + return true | |
1237 | 1237 | end |
1238 | 1238 | if event == 'OnClose' and arglist[0] == 'shutdown' # XXX |
1239 | 1239 | @force_quit = true |
@@ -1253,7 +1253,7 @@ module Sakura | ||
1253 | 1253 | get_current_shell_name(), |
1254 | 1254 | false, communication, |
1255 | 1255 | nil, false, script, arglist) |
1256 | - return 0 | |
1256 | + return false | |
1257 | 1257 | end |
1258 | 1258 | #logging.debug('=> "{0}"'.format(script)) |
1259 | 1259 | if @__temp_mode == 2 |
@@ -1262,7 +1262,7 @@ module Sakura | ||
1262 | 1262 | end |
1263 | 1263 | if @passivemode and \ |
1264 | 1264 | (event == 'OnSecondChange' or event == 'OnMinuteChange') |
1265 | - return 0 | |
1265 | + return false | |
1266 | 1266 | end |
1267 | 1267 | start_script(script) |
1268 | 1268 | @balloon.hide_sstp_message() |
@@ -1279,7 +1279,7 @@ module Sakura | ||
1279 | 1279 | nil, false, script, arglist) |
1280 | 1280 | end |
1281 | 1281 | @script_finally << proc |
1282 | - return 1 | |
1282 | + return true | |
1283 | 1283 | end |
1284 | 1284 | |
1285 | 1285 | def get_prefix() |
@@ -1340,7 +1340,7 @@ module Sakura | ||
1340 | 1340 | if not ['lefttop', 'righttop', 'centertop'].include?(align_background) |
1341 | 1341 | align_background = 'lefttop' |
1342 | 1342 | end |
1343 | - align_background = align_background[0..-3].encode('ascii') # XXX | |
1343 | + align_background = align_background[0..-4].encode('ascii') # XXX | |
1344 | 1344 | align = getstring('menu.sidebar.alignment') |
1345 | 1345 | if not align.empty? |
1346 | 1346 | align_sidebar = align |
@@ -1356,7 +1356,7 @@ module Sakura | ||
1356 | 1356 | if not ['lefttop', 'righttop', 'centertop'].include?(align_foreground) |
1357 | 1357 | align_foreground = 'lefttop' |
1358 | 1358 | end |
1359 | - align_foreground = align_foreground[0..-3].encode('ascii') # XXX | |
1359 | + align_foreground = align_foreground[0..-4].encode('ascii') # XXX | |
1360 | 1360 | return path_background, path_sidebar, path_foreground, \ |
1361 | 1361 | align_background, align_sidebar, align_foreground |
1362 | 1362 | end |
@@ -1920,22 +1920,23 @@ module Sakura | ||
1920 | 1920 | return |
1921 | 1921 | end |
1922 | 1922 | @last_script = script |
1923 | - @script_origin = origin or self.FROM_GHOST | |
1923 | + @script_origin = origin or FROM_GHOST | |
1924 | 1924 | reset_script(true) |
1925 | 1925 | @__current_script = script |
1926 | - if not script.rstrip().endswith('\e') | |
1926 | + if not script.rstrip().end_with?('\e') | |
1927 | 1927 | script = ''.join([script, '\e']) |
1928 | 1928 | end |
1929 | 1929 | @processed_script = [] |
1930 | 1930 | @script_position = 0 |
1931 | 1931 | while 1 |
1932 | 1932 | begin |
1933 | - @processed_script.extend(@script_parser.parse(script)) | |
1933 | + #@processed_script.extend(@script_parser.parse(script)) | |
1934 | + @processed_script << @script_parser.parse(script) | |
1934 | 1935 | rescue #except ninix.script.ParserError as e: |
1935 | 1936 | #logging.error('-' * 50) |
1936 | 1937 | #logging.error('{0}'.format(e)) # 'UTF-8' |
1937 | - done, script = e | |
1938 | - @processed_script.extend(done) | |
1938 | + #done, script = e | |
1939 | + #@processed_script.extend(done) | |
1939 | 1940 | else |
1940 | 1941 | break |
1941 | 1942 | end |
@@ -1948,14 +1949,14 @@ module Sakura | ||
1948 | 1949 | set_synchronized_session([], reset=true) |
1949 | 1950 | @balloon.hide_all() |
1950 | 1951 | node = @processed_script[0] |
1951 | - if node[0] == Script.SCRIPT_TAG and node[1] == '\C' | |
1952 | + if node[0] == Script::SCRIPT_TAG and node[1] == '\C' | |
1952 | 1953 | @processed_script.pop(0) |
1953 | 1954 | @script_position = node[-1] |
1954 | 1955 | else |
1955 | 1956 | @balloon.clear_text_all() |
1956 | 1957 | end |
1957 | 1958 | @balloon.set_balloon_default() |
1958 | - @current_time = time.localtime(time.time()) | |
1959 | + @current_time = Time.new.to_a | |
1959 | 1960 | reset_idle_time() |
1960 | 1961 | if @parent.handle_request('GET', 'get_preference', 'raise_before_talk') |
1961 | 1962 | raise_all() |
@@ -2381,7 +2382,7 @@ module Sakura | ||
2381 | 2382 | select_balloon(key, desc, balloon) |
2382 | 2383 | end |
2383 | 2384 | elsif args[0, 2] == ['change', 'shell'] and argc > 2 |
2384 | - for key in @shells | |
2385 | + for key in @shells.keys | |
2385 | 2386 | shell_name = @shells[key].baseinfo[0] |
2386 | 2387 | if shell_name == args[2] |
2387 | 2388 | select_shell(key) |
@@ -2637,7 +2638,7 @@ module Sakura | ||
2637 | 2638 | flag = args[3] |
2638 | 2639 | end |
2639 | 2640 | bind = @surface.window[@script_side].bind # XXX |
2640 | - for key in bind | |
2641 | + for key in bind.keys | |
2641 | 2642 | group = bind[key][0].split(',') |
2642 | 2643 | if category != group[0] |
2643 | 2644 | next |
@@ -2784,7 +2785,7 @@ module Sakura | ||
2784 | 2785 | end |
2785 | 2786 | node = @processed_script.pop(0) |
2786 | 2787 | @script_position = node[-1] |
2787 | - if node[0] == Script.SCRIPT_TAG | |
2788 | + if node[0] == Script::SCRIPT_TAG | |
2788 | 2789 | name, args = node[1], node[2..-1] |
2789 | 2790 | if @__script_tag.include?(name) and \ |
2790 | 2791 | Sakura.method_defined?(@__script_tag[name]) |
@@ -2792,7 +2793,7 @@ module Sakura | ||
2792 | 2793 | else |
2793 | 2794 | #pass ## FIMXE |
2794 | 2795 | end |
2795 | - elsif node[0] == Script.SCRIPT_TEXT | |
2796 | + elsif node[0] == Script::SCRIPT_TEXT | |
2796 | 2797 | text = expand_meta(node[1]) |
2797 | 2798 | if @anchor |
2798 | 2799 | @anchor[1] = ''.join([@anchor[1], text]) |
@@ -2851,15 +2852,15 @@ module Sakura | ||
2851 | 2852 | if chunk[0] == Script.TEXT_STRING |
2852 | 2853 | buf << chunk[1] |
2853 | 2854 | elsif chunk[1] == '%month' |
2854 | - buf << @current_time[1].to_s | |
2855 | + buf << @current_time[4].to_s | |
2855 | 2856 | elsif chunk[1] == '%day' |
2856 | - buf << @current_time[2].to_s | |
2857 | - elsif chunk[1] == '%hour' | |
2858 | 2857 | buf << @current_time[3].to_s |
2858 | + elsif chunk[1] == '%hour' | |
2859 | + buf << @current_time[2].to_s | |
2859 | 2860 | elsif chunk[1] == '%minute' |
2860 | - buf << @current_time[4].to_s | |
2861 | + buf << @current_time[1].to_s | |
2861 | 2862 | elsif chunk[1] == '%second' |
2862 | - buf << @current_time[5].to_s | |
2863 | + buf << @current_time[0].to_s | |
2863 | 2864 | elsif ['%username', '%c'].include?(chunk[1]) |
2864 | 2865 | buf << get_username() |
2865 | 2866 | elsif chunk[1] == '%selfname' |
@@ -2877,7 +2878,7 @@ module Sakura | ||
2877 | 2878 | left, top, scrn_w, scrn_h = Pix.get_workarea() |
2878 | 2879 | buf << scrn_h.to_s |
2879 | 2880 | elsif chunk[1] == '%et' |
2880 | - buf << '{0:d}万年'.format(@current_time[7]) | |
2881 | + buf << '{0:d}万年'.format(@current_time[5]) | |
2881 | 2882 | elsif chunk[1] == '%wronghour' |
2882 | 2883 | wrongtime = time.time() + random.choice([-2, -1, 1, 2]) * 3600 |
2883 | 2884 | buf << time.localtime(wrongtime)[3].to_s |
@@ -22,7 +22,7 @@ require "ninix/seriko" | ||
22 | 22 | module Surface |
23 | 23 | |
24 | 24 | class Surface |
25 | - attr_reader :name | |
25 | + attr_reader :name, :prefix | |
26 | 26 | |
27 | 27 | def initialize |
28 | 28 | @window = [] |
@@ -367,21 +367,21 @@ module Surface | ||
367 | 367 | top_dir = @prefix |
368 | 368 | name = @desc.get('menu.background.bitmap.filename') |
369 | 369 | if name |
370 | - name = name.replace('\\', '/') | |
370 | + name = name.gsub('\\', '/') | |
371 | 371 | path_background = File.join(top_dir, name) |
372 | 372 | else |
373 | 373 | path_background = nil |
374 | 374 | end |
375 | 375 | name = @desc.get('menu.sidebar.bitmap.filename') |
376 | 376 | if name |
377 | - name = name.replace('\\', '/') | |
377 | + name = name.gsub('\\', '/') | |
378 | 378 | path_sidebar = File.join(top_dir, name) |
379 | 379 | else |
380 | 380 | path_sidebar = nil |
381 | 381 | end |
382 | 382 | name = @desc.get('menu.foreground.bitmap.filename') |
383 | 383 | if name |
384 | - name = name.replace('\\', '/') | |
384 | + name = name.gsub('\\', '/') | |
385 | 385 | path_foreground = File.join(top_dir, name) |
386 | 386 | else |
387 | 387 | path_foreground = nil |
@@ -749,13 +749,13 @@ module Surface | ||
749 | 749 | |
750 | 750 | def raise_all |
751 | 751 | for side in 0..@window.length-1 |
752 | - @window[side].raise_() | |
752 | + @window[side].raise | |
753 | 753 | end |
754 | 754 | end |
755 | 755 | |
756 | - def raise_(side) | |
756 | + def raise(side) | |
757 | 757 | if @window.length > side |
758 | - @window[side].raise_() | |
758 | + @window[side].raise | |
759 | 759 | end |
760 | 760 | end |
761 | 761 |
@@ -1635,8 +1635,8 @@ module Surface | ||
1635 | 1635 | end |
1636 | 1636 | end |
1637 | 1637 | |
1638 | - def raise_ | |
1639 | - @window.window.raise_() | |
1638 | + def raise | |
1639 | + @window.window.raise | |
1640 | 1640 | @parent.handle_request('NOTIFY', 'notify_observer', 'raise', (@side)) |
1641 | 1641 | end |
1642 | 1642 |
@@ -462,7 +462,7 @@ module Ninix_Main | ||
462 | 462 | f = open(path, 'r', encoding='utf-8') |
463 | 463 | line = f.readline() |
464 | 464 | line = line.rstrip('\r\n') |
465 | - if not line.startswith('#plugin:') | |
465 | + if not line.start_with('#plugin:') | |
466 | 466 | return {} |
467 | 467 | end |
468 | 468 | begin |
@@ -506,7 +506,7 @@ module Ninix_Main | ||
506 | 506 | data = @queue[plugin_dir].get() |
507 | 507 | @queue[plugin_dir].task_done() |
508 | 508 | if isinstance(data, str) |
509 | - if data.startswith('DIALOG:') | |
509 | + if data.start_with('DIALOG:') | |
510 | 510 | message = data[7..-1] |
511 | 511 | open_dialog(plugin_dir, message) |
512 | 512 | next |
@@ -1025,9 +1025,12 @@ module Ninix_Main | ||
1025 | 1025 | end |
1026 | 1026 | |
1027 | 1027 | def get_ghost_menus |
1028 | + menus = [] | |
1028 | 1029 | for value in @ghosts.values() |
1029 | - yield value.menuitem | |
1030 | + #yield value.menuitem | |
1031 | + menus << value.menuitem | |
1030 | 1032 | end |
1033 | + return menus | |
1031 | 1034 | end |
1032 | 1035 | |
1033 | 1036 | def get_shell_menu |
@@ -1036,7 +1039,7 @@ module Ninix_Main | ||
1036 | 1039 | |
1037 | 1040 | def get_balloon_menu |
1038 | 1041 | current_key = get_current_balloon_directory() |
1039 | - for key in @balloons | |
1042 | + for key in @balloons.keys | |
1040 | 1043 | menuitem = @balloons[key].menuitem |
1041 | 1044 | menuitem.set_sensitive(key != current_key) # not working |
1042 | 1045 | end |
@@ -1050,7 +1053,7 @@ module Ninix_Main | ||
1050 | 1053 | |
1051 | 1054 | def create_balloon_menu |
1052 | 1055 | balloon_menuitems = {} # OrderedDict() |
1053 | - for key in @balloons.keys() | |
1056 | + for key in @balloons.keys | |
1054 | 1057 | balloon_menuitems[key] = @balloons[key].menuitem |
1055 | 1058 | end |
1056 | 1059 | return @__menu.create_meme_menu(balloon_menuitems) |
@@ -1103,7 +1106,7 @@ module Ninix_Main | ||
1103 | 1106 | |
1104 | 1107 | def get_balloon_list ## FIXME |
1105 | 1108 | balloon_list = [] |
1106 | - for key in @balloons.keys() | |
1109 | + for key in @balloons.keys | |
1107 | 1110 | desc, balloon = @balloons[key].baseinfo |
1108 | 1111 | subdir = balloon['balloon_dir'][0] |
1109 | 1112 | name = desc.get('name', :default => subdir) |
@@ -1114,6 +1117,7 @@ module Ninix_Main | ||
1114 | 1117 | |
1115 | 1118 | def get_plugin_list ## FIXME |
1116 | 1119 | plugin_list = [] |
1120 | + return plugin_list ## FIXME | |
1117 | 1121 | for i, plugin in enumerate(@plugins) |
1118 | 1122 | plugin_name = plugin[0] |
1119 | 1123 | menu_items = plugin[3] |
@@ -1180,7 +1184,7 @@ module Ninix_Main | ||
1180 | 1184 | end |
1181 | 1185 | |
1182 | 1186 | def find_ghost_by_name(name) |
1183 | - for key in @ghosts | |
1187 | + for key in @ghosts.keys | |
1184 | 1188 | sakura = @ghosts[key].instance |
1185 | 1189 | begin |
1186 | 1190 | if sakura.get_name(default=nil) == name |
@@ -1198,7 +1202,7 @@ module Ninix_Main | ||
1198 | 1202 | end |
1199 | 1203 | |
1200 | 1204 | def find_balloon_by_name(name) |
1201 | - for key in @balloons | |
1205 | + for key in @balloons.keys | |
1202 | 1206 | desc, balloon = @balloons[key].baseinfo |
1203 | 1207 | begin |
1204 | 1208 | if desc.get('name') == name |
@@ -1645,7 +1649,7 @@ module Ninix_Main | ||
1645 | 1649 | sakura.save_history() |
1646 | 1650 | end |
1647 | 1651 | history = {} |
1648 | - for key in @ghosts | |
1652 | + for key in @ghosts.keys | |
1649 | 1653 | sakura = @ghosts[key].instance |
1650 | 1654 | name = sakura.get_name(default=key) |
1651 | 1655 | ghost_time = 0 |