• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

修订版a72754d7aef090b41e97c6a6d727bcda1d9d1503 (tree)
时间2016-10-20 23:24:27
作者Shyouzou Sugitani <shy@user...>
CommiterShyouzou Sugitani

Log Message

misc fixes(2)

更改概述

差异

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
1+Thu October 20 2016 Shyouzou Sugitani <shy@users.osdn.me>
2+ * deprecatedになっているGtkのWidgetを使用しないようにした.
3+ (Gtk::ActionGroupとGtk::UIManagerの2つ.)
4+
15 Mon October 17 2016 Shyouzou Sugitani <shy@users.osdn.me>
26 * Pix.create_pixbuf_from_fileの引数:is_pnrのデフォルト値を
37 falseに変更した.
--- a/lib/ninix/kinoko.rb
+++ b/lib/ninix/kinoko.rb
@@ -32,41 +32,24 @@ module Kinoko
3232
3333 def initialize(accelgroup)
3434 @parent = nil
35- ui_info = <<-EOS
36- <ui>
37- <popup name='popup'>
38- <menuitem action='Settings'/>
39- <menu action='Skin'>
40- </menu>
41- <separator/>
42- <menuitem action='Exit'/>
43- </popup>
44- </ui>
45- EOS
46- @__menu_list = {
47- 'settings' => [['Settings', nil, _('Settings...(_O)'), nil,
48- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'edit_preferences')}],
49- '/ui/popup/Settings'],
50- 'skin' => [['Skin', nil, _('Skin(_K)'), nil, '', lambda {|a, b| }],
51- nil, '/ui/popup/Skin'],
52- 'exit' => [['Exit', nil, _('Exit(_Q)'), nil,
53- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'close')}],
54- '/ui/popup/Exit'],
55- }
56- actions = Gtk::ActionGroup.new('Actions')
57- entry = []
58- for value in @__menu_list.values()
59- entry << value[0]
35+ @__menu_list = {}
36+ @__popup_menu = Gtk::Menu.new
37+ item = Gtk::MenuItem.new(:label => _('Settings...(_O)'), :use_underline => true)
38+ item.signal_connect('activate') do |a, b|
39+ @parent.handle_request('NOTIFY', 'edit_preferences')
6040 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)
41+ @__popup_menu.add(item)
42+ @__menu_list['settings'] = item
43+ item = Gtk::MenuItem.new(:label => _('Skin(_K)'), :use_underline => true)
44+ @__popup_menu.add(item)
45+ @__menu_list['skin'] = item
46+ item = Gtk::MenuItem.new(:label => _('Exit(_Q)'), :use_underline => true)
47+ item.signal_connect('activate') do |a, b|
48+ @parent.handle_request('NOTIFY', 'close')
6949 end
50+ @__popup_menu.add(item)
51+ @__menu_list['exit'] = item
52+ @__popup_menu.show_all
7053 end
7154
7255 def set_responsible(parent)
@@ -92,11 +75,11 @@ module Kinoko
9275 menu.add(item)
9376 item.show()
9477 end
95- @__menu_list[key][1].set_submenu(menu)
78+ @__menu_list[key].set_submenu(menu)
9679 menu.show()
97- @__menu_list[key][1].show()
80+ @__menu_list[key].show()
9881 else
99- @__menu_list[key][1].hide()
82+ @__menu_list[key].hide()
10083 end
10184 end
10285 end
--- a/lib/ninix/menu.rb
+++ b/lib/ninix/menu.rb
@@ -25,137 +25,6 @@ module Menu
2525
2626 def initialize
2727 @parent = nil
28- ui_info = "
29- <ui>
30- <popup name='popup'>
31- <menu action='Recommend'>
32- </menu>
33- <menu action='Portal'>
34- </menu>
35- <separator/>
36- <menuitem action='Stick'/>
37- <separator/>
38- <menu action='Options'>
39- <menuitem action='Update'/>
40- <menuitem action='Vanish'/>
41- <menuitem action='Preferences'/>
42- <menuitem action='Console'/>
43- <menuitem action='Manager'/>
44- </menu>
45- <separator/>
46- <menu action='Change'>
47- </menu>
48- <menu action='Summon'>
49- </menu>
50- <menu action='Shell'>
51- </menu>
52- <menu action='Costume'>
53- </menu>
54- <menu action='Balloon'>
55- </menu>
56- <separator/>
57- <menu action='Information'>
58- <menuitem action='Usage'/>
59- <menuitem action='Version'/>
60- </menu>
61- <separator/>
62- <menu action='Nekodorif'>
63- </menu>
64- <menu action='Kinoko'>
65- </menu>
66- <separator/>
67- <menuitem action='Close'/>
68- <menuitem action='Quit'/>
69- </popup>
70- </ui>
71- "
72- @__menu_list = {
73- 'Portal' => {
74- 'entry' => ['Portal', nil, _('Portal sites(_P)'), nil,
75- '', lambda {|a, b| }],
76- 'visible' => true},
77- 'Recommend' => {
78- 'entry' => ['Recommend', nil, _('Recommend sites(_R)'), nil,
79- '', lambda {|a, b| }],
80- 'visible' => true},
81- 'Options' => {
82- 'entry' => ['Options', nil, _('Options(_F)'), nil,
83- '', lambda {|a, b| }],
84- 'visible' => true},
85- 'Options/Update' => {
86- 'entry' => ['Update', nil, _('Network Update(_U)'), nil,
87- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'network_update')}],
88- 'visible' => true},
89- 'Options/Vanish' => {
90- 'entry' => ['Vanish', nil, _('Vanish(_F)'), nil,
91- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'vanish')}],
92- 'visible' => true},
93- 'Options/Preferences' => {
94- 'entry' => ['Preferences', nil, _('Preferences...(_O)'), nil,
95- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'edit_preferences')}],
96- 'visible' => true},
97- 'Options/Console' => {
98- 'entry' => ['Console', nil, _('Console(_C)'), nil,
99- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'open_console')}],
100- 'visible' => true},
101- 'Options/Manager' => {
102- 'entry' => ['Manager', nil, _('Ghost Manager(_M)'), nil,
103- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'open_ghost_manager')}],
104- 'visible' => true},
105- 'Information' => {
106- 'entry' => ['Information', nil, _('Information(_I)'), nil,
107- '', lambda {|a, b| }],
108- 'visible' => true},
109- 'Information/Usage' => {
110- 'entry' => ['Usage', nil, _('Usage graph(_A)'), nil,
111- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'show_usage')}],
112- 'visible' => true},
113- 'Information/Version' => {
114- 'entry' => ['Version', nil, _('Version(_V)'), nil,
115- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'about')}],
116- 'visible' => true},
117- 'Close' => {
118- 'entry' => ['Close', nil, _('Close(_W)'), nil,
119- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'close_sakura')}],
120- 'visible' => true},
121- 'Quit' => {
122- 'entry' => ['Quit', nil, _('Quit(_Q)'), nil,
123- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'close_all')}],
124- 'visible' => true},
125- 'Change' => {
126- 'entry' => ['Change', nil, _('Change(_G)'), nil,
127- '', lambda {|a, b| }],
128- 'visible' => true},
129- 'Summon' => {
130- 'entry' => ['Summon', nil, _('Summon(_X)'), nil,
131- '', lambda {|a, b| }],
132- 'visible' => true},
133- 'Shell' => {
134- 'entry' => ['Shell', nil, _('Shell(_S)'), nil,
135- '', lambda {|a, b| }],
136- 'visible' => true},
137- 'Balloon' => {
138- 'entry' => ['Balloon', nil, _('Balloon(_B)'), nil,
139- '', lambda {|a, b| }],
140- 'visible' => true},
141- 'Costume' => {
142- 'entry' => ['Costume', nil, _('Costume(_C)'), nil,
143- '', lambda {|a, b| }],
144- 'visible' => true},
145- 'Stick' => {
146- 'entry' => ['Stick', nil, _('Stick(_Y)'), nil,
147- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'stick_window')},
148- false],
149- 'visible' => true},
150- 'Nekodorif' => {
151- 'entry' => ['Nekodorif', nil, _('Nekodorif(_N)'), nil,
152- '', lambda {|a, b| }],
153- 'visible' => true},
154- 'Kinoko' => {
155- 'entry' => ['Kinoko', nil, _('Kinoko(_K)'), nil,
156- '', lambda {|a, b| }],
157- 'visible' => true},
158- }
15928 @__fontcolor = {
16029 'normal' => [0, 0, 0],
16130 'hover' => [255, 255, 255]
@@ -171,26 +40,126 @@ module Menu
17140 'foreground' => nil,
17241 'sidebar' => nil
17342 }
174- actions = Gtk::ActionGroup.new('Actions')
175- entry = []
176- for key in @__menu_list.keys
177- value = @__menu_list[key]
178- if key != 'Stick'
179- entry << value['entry']
180- end
181- end
182- actions.add_actions(entry)
183- actions.add_toggle_actions([@__menu_list['Stick']['entry']])
184- @ui_manager = Gtk::UIManager.new()
185- @ui_manager.insert_action_group(actions, 0)
186- @ui_manager.add_ui(ui_info)
187- @__popup_menu = @ui_manager.get_widget('/popup')
43+ @__menu_list = {}
44+ @__popup_menu = Gtk::Menu.new
45+ item = Gtk::MenuItem.new(:label => _('Recommend sites(_R)'), :use_underline => true)
46+ @__popup_menu.add(item)
47+ @__menu_list['Recommend'] = {:entry => item, :visible => true}
48+ item = Gtk::MenuItem.new(:label => _('Portal sites(_P)'), :use_underline => true)
49+ @__popup_menu.add(item)
50+ @__menu_list['Portal'] = {:entry => item, :visible => true}
51+ item = Gtk::SeparatorMenuItem.new()
52+ @__popup_menu.add(item)
53+ item = Gtk::CheckMenuItem.new(:label => _('Stick(_Y)'), :use_underline => true)
54+ item.set_active(false)
55+ item.signal_connect('activate') do |a, b|
56+ @parent.handle_request('NOTIFY', 'stick_window')
57+ end
58+ @__popup_menu.add(item)
59+ @__menu_list['Stick'] = {:entry => item, :visible => true}
60+ item = Gtk::SeparatorMenuItem.new()
61+ @__popup_menu.add(item)
62+ item = Gtk::MenuItem.new(:label => _('Options(_F)'), :use_underline => true)
63+ @__popup_menu.add(item)
64+ @__menu_list['Options'] = {:entry => item, :visible => true}
65+ menu = Gtk::Menu.new()
66+ item.set_submenu(menu)
67+
68+ item = Gtk::MenuItem.new(:label => _('Network Update(_U)'), :use_underline => true)
69+ item.signal_connect('activate') do |a, b|
70+ @parent.handle_request('NOTIFY', 'network_update')
71+ end
72+ menu.add(item)
73+ @__menu_list['Options/Update'] = {:entry => item, :visible => true}
74+ item = Gtk::MenuItem.new(:label => _('Vanish(_F)'), :use_underline => true)
75+ item.signal_connect('activate') do |a, b|
76+ @parent.handle_request('NOTIFY', 'vanish')
77+ end
78+ menu.add(item)
79+ @__menu_list['Options/Vanish'] = {:entry => item, :visible => true}
80+ item = Gtk::MenuItem.new(:label => _('Preferences...(_O)'), :use_underline => true)
81+ item.signal_connect('activate') do |a, b|
82+ @parent.handle_request('NOTIFY', 'edit_preferences')
83+ end
84+ menu.add(item)
85+ @__menu_list['Options/Preferences'] = {:entry => item, :visible => true}
86+ item = Gtk::MenuItem.new(:label => _('Console(_C)'), :use_underline => true)
87+ item.signal_connect('activate') do |a, b|
88+ @parent.handle_request('NOTIFY', 'open_console')
89+ end
90+ menu.add(item)
91+ @__menu_list['Options/Console'] = {:entry => item, :visible => true}
92+ item = Gtk::MenuItem.new(:label => _('Ghost Manager(_M)'), :use_underline => true)
93+ item.signal_connect('activate') do |a, b|
94+ @parent.handle_request('NOTIFY', 'open_ghost_manager')
95+ end
96+ menu.add(item)
97+ @__menu_list['Options/Manager'] = {:entry => item, :visible => true}
98+ item = Gtk::SeparatorMenuItem.new()
99+ @__popup_menu.add(item)
100+ item = Gtk::MenuItem.new(:label => _('Change(_G)'), :use_underline => true)
101+ @__popup_menu.add(item)
102+ @__menu_list['Change'] = {:entry => item, :visible => true}
103+ item = Gtk::MenuItem.new(:label => _('Summon(_X)'), :use_underline => true)
104+ @__popup_menu.add(item)
105+ @__menu_list['Summon'] = {:entry => item, :visible => true}
106+ item = Gtk::MenuItem.new(:label => _('Shell(_S)'), :use_underline => true)
107+ @__popup_menu.add(item)
108+ @__menu_list['Shell'] = {:entry => item, :visible => true}
109+ item = Gtk::MenuItem.new(:label => _('Costume(_C)'), :use_underline => true)
110+ @__popup_menu.add(item)
111+ @__menu_list['Costume'] = {:entry => item, :visible => true}
112+ item = Gtk::MenuItem.new(:label => _('Balloon(_B)'), :use_underline => true)
113+ @__popup_menu.add(item)
114+ @__menu_list['Balloon'] = {:entry => item, :visible => true}
115+ item = Gtk::SeparatorMenuItem.new()
116+ @__popup_menu.add(item)
117+ item = Gtk::MenuItem.new(:label => _('Information(_I)'), :use_underline => true)
118+ @__popup_menu.add(item)
119+ @__menu_list['Information'] = {:entry => item, :visible => true}
120+ menu = Gtk::Menu.new()
121+ item.set_submenu(menu)
122+ item = Gtk::MenuItem.new(:label => _('Usage graph(_A)'), :use_underline => true)
123+ item.signal_connect('activate') do |a, b|
124+ @parent.handle_request('NOTIFY', 'show_usage')
125+ end
126+ menu.add(item)
127+ @__menu_list['Information/Usage'] = {:entry => item, :visible => true}
128+ item = Gtk::MenuItem.new(:label => _('Version(_V)'), :use_underline => true)
129+ item.signal_connect('activate') do |a, b|
130+ @parent.handle_request('NOTIFY', 'about')
131+ end
132+ menu.add(item)
133+ @__menu_list['Information/Version'] = {:entry => item, :visible => true}
134+ item = Gtk::SeparatorMenuItem.new()
135+ @__popup_menu.add(item)
136+ item = Gtk::MenuItem.new(:label => _('Nekodorif(_N)'), :use_underline => true)
137+ @__popup_menu.add(item)
138+ @__menu_list['Nekodorif'] = {:entry => item, :visible => true}
139+ item = Gtk::MenuItem.new(:label => _('Kinoko(_K)'), :use_underline => true)
140+ @__popup_menu.add(item)
141+ @__menu_list['Kinoko'] = {:entry => item, :visible => true}
142+ item = Gtk::SeparatorMenuItem.new()
143+ @__popup_menu.add(item)
144+ item = Gtk::MenuItem.new(:label => _('Close(_W)'), :use_underline => true)
145+ item.signal_connect('activate') do |a, b|
146+ @parent.handle_request('NOTIFY', 'close_sakura')
147+ end
148+ @__popup_menu.add(item)
149+ @__menu_list['Close'] = {:entry => item, :visible => true}
150+ item = Gtk::MenuItem.new(:label => _('Quit(_Q)'), :use_underline => true)
151+ item.signal_connect('activate') do |a, b|
152+ @parent.handle_request('NOTIFY', 'close_all')
153+ end
154+ @__popup_menu.add(item)
155+ @__menu_list['Quit'] = {:entry => item, :visible => true}
156+ @__popup_menu.show_all
188157 provider = create_css_provider_for(@__popup_menu)
189158 @__popup_menu.signal_connect('realize', provider) do |i, *a, provider|
190159 next set_stylecontext_with_sidebar(i, *a, :provider => provider)
191160 end
192161 for key in @__menu_list.keys
193- item = @ui_manager.get_widget(['/popup/', key].join(''))
162+ item = @__menu_list[key][:entry]
194163 provider = create_css_provider_for(item)
195164 item.signal_connect('draw', provider) do |i, *a, provider|
196165 next set_stylecontext(i, *a, :provider => provider)
@@ -287,7 +256,7 @@ module Menu
287256
288257 def __set_mayuna_menu(side)
289258 if @__mayuna_menu.length > side and not @__mayuna_menu[side].nil?
290- menuitem = @ui_manager.get_widget(['/popup/', 'Costume'].join(''))
259+ menuitem = @__menu_list['Costume'][:entry]
291260 menuitem.set_submenu(@__mayuna_menu[side])
292261 __set_visible('Costume', true)
293262 else
@@ -422,7 +391,7 @@ module Menu
422391 def popup(button, side)
423392 @__popup_menu.unrealize()
424393 for key in @__menu_list.keys
425- item = @ui_manager.get_widget(['/popup/', key].join(''))
394+ item = @__menu_list[key][:entry]
426395 submenu = item.submenu
427396 submenu.unrealize() unless submenu.nil?
428397 end
@@ -458,8 +427,8 @@ module Menu
458427 __set_nekodorif_menu()
459428 __set_kinoko_menu()
460429 for key in @__menu_list.keys
461- item = @ui_manager.get_widget(['/popup/', key].join(''))
462- visible = @__menu_list[key]['visible']
430+ item = @__menu_list[key][:entry]
431+ visible = @__menu_list[key][:visible]
463432 unless item.nil?
464433 if visible
465434 item.show()
@@ -475,7 +444,7 @@ module Menu
475444 def __set_caption(name, caption)
476445 fail "assert" unless @__menu_list.include?(name)
477446 fail "assert" unless caption.is_a?(String)
478- item = @ui_manager.get_widget(['/popup/', name].join(''))
447+ item = @__menu_list[name][:entry]
479448 unless item.nil?
480449 label = item.get_children()[0]
481450 label.set_text_with_mnemonic(caption)
@@ -485,7 +454,7 @@ module Menu
485454 def __set_visible(name, visible)
486455 fail "assert" unless @__menu_list.include?(name)
487456 fail "assert" unless [false, true].include?(visible)
488- @__menu_list[name]['visible'] = visible
457+ @__menu_list[name][:visible] = visible
489458 end
490459
491460 def __set_portal_menu(side, portal)
@@ -559,7 +528,7 @@ module Menu
559528 menu.add(item)
560529 item.show()
561530 end
562- menuitem = @ui_manager.get_widget(['/popup/', 'Portal'].join(''))
531+ menuitem = @__menu_list['Portal'][:entry]
563532 menuitem.set_submenu(menu)
564533 provider = create_css_provider_for(menu)
565534 menu.signal_connect('realize', provider) do |i, *a, provider|
@@ -639,7 +608,7 @@ module Menu
639608 menu.add(item)
640609 item.show()
641610 end
642- menuitem = @ui_manager.get_widget(['/popup/', 'Recommend'].join(''))
611+ menuitem = @__menu_list['Recommend'][:entry]
643612 menuitem.set_submenu(menu)
644613 provider = create_css_provider_for(menu)
645614 menu.signal_connect('realize', provider) do |i, *a, provider|
@@ -791,7 +760,7 @@ module Menu
791760 ghost_menu << item
792761 end
793762 end
794- menuitem = @ui_manager.get_widget(['/popup/', path].join(''))
763+ menuitem = @__menu_list[path][:entry]
795764 menuitem.set_submenu(ghost_menu)
796765 provider = create_css_provider_for(ghost_menu)
797766 ghost_menu.signal_connect('realize', provider) do |i, *a, provider|
@@ -802,13 +771,13 @@ module Menu
802771
803772 def __set_shell_menu
804773 shell_menu = @parent.handle_request('GET', 'get_shell_menu')
805- menuitem = @ui_manager.get_widget(['/popup/', 'Shell'].join(''))
774+ menuitem = @__menu_list['Shell'][:entry]
806775 menuitem.set_submenu(shell_menu)
807776 end
808777
809778 def __set_balloon_menu
810779 balloon_menu = @parent.handle_request('GET', 'get_balloon_menu')
811- menuitem = @ui_manager.get_widget(['/popup/', 'Balloon'].join(''))
780+ menuitem = @__menu_list['Balloon'][:entry]
812781 menuitem.set_submenu(balloon_menu)
813782 end
814783
@@ -872,7 +841,7 @@ module Menu
872841 ##if working
873842 ## item.set_sensitive(false)
874843 end
875- menuitem = @ui_manager.get_widget(['/popup/', 'Nekodorif'].join(''))
844+ menuitem = @__menu_list['Nekodorif'][:entry]
876845 menuitem.set_submenu(nekodorif_menu)
877846 provider = create_css_provider_for(nekodorif_menu)
878847 nekodorif_menu.signal_connect('realize', provider) do |i, *a, provider|
@@ -900,7 +869,7 @@ module Menu
900869 ##if working
901870 ## item.set_sensitive(false)
902871 end
903- menuitem = @ui_manager.get_widget(['/popup/', 'Kinoko'].join(''))
872+ menuitem = @__menu_list['Kinoko'][:entry]
904873 menuitem.set_submenu(kinoko_menu)
905874 provider = create_css_provider_for(kinoko_menu)
906875 kinoko_menu.signal_connect('realize', provider) do |i, *a, provider|
@@ -909,7 +878,7 @@ module Menu
909878 end
910879
911880 def get_stick
912- item = @ui_manager.get_widget(['/popup/', 'Stick'].join(''))
881+ item = @__menu_list['Stick'][:entry]
913882 if not item.nil? and item.active?
914883 return true
915884 else
--- a/lib/ninix/nekodorif.rb
+++ b/lib/ninix/nekodorif.rb
@@ -62,43 +62,25 @@ module Nekodorif
6262
6363 def initialize(accelgroup)
6464 @parent = nil
65- ui_info = <<-EOS
66- <ui>
67- <popup name='popup'>
68- <menuitem action='Settings'/>
69- <menu action='Katochan'>
70- </menu>
71- <separator/>
72- <menuitem action='Exit'/>
73- </popup>
74- </ui>
75- EOS
76- @__menu_list = {
77- 'settings' => [['Settings', nil, _('Settings...(_O)'), nil,
78- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'edit_preferences')}],
79- '/ui/popup/Settings'],
80- 'katochan' => [['Katochan', nil, _('Katochan(_K)'), nil,
81- '', lambda {|a, b| }],
82- '/ui/popup/Katochan'],
83- 'exit' => [['Exit', nil,_('Exit(_Q)'), nil,
84- '', lambda {|a, b| @parent.handle_request('NOTIFY', 'close')}],
85- '/ui/popup/Exit'],
86- }
8765 @__katochan_list = nil
88- actions = Gtk::ActionGroup.new('Actions')
89- entry = []
90- for value in @__menu_list.values()
91- entry << value[0]
92- end
93- actions.add_actions(entry)
94- ui_manager = Gtk::UIManager.new()
95- ui_manager.insert_action_group(actions, 0)
96- ui_manager.add_ui(ui_info)
97- @__popup_menu = ui_manager.get_widget('/ui/popup')
98- for key in @__menu_list.keys
99- path = @__menu_list[key][-1]
100- @__menu_list[key][1] = ui_manager.get_widget(path)
101- end
66+ @__menu_list = {}
67+ @__popup_menu = Gtk::Menu.new
68+ item = Gtk::MenuItem.new(:label => _('Settings...(_O)'), :use_underline => true)
69+ item.signal_connect('activate') do |a, b|
70+ @parent.handle_request('NOTIFY', 'edit_preferences')
71+ end
72+ @__popup_menu.add(item)
73+ @__menu_list['settings'] = item
74+ item = Gtk::MenuItem.new(:label => _('Katochan(_K)'), :use_underline => true)
75+ @__popup_menu.add(item)
76+ @__menu_list['katochan'] = item
77+ item = Gtk::MenuItem.new(:label => _('Exit(_Q)'), :use_underline => true)
78+ item.signal_connect('activate') do |a, b|
79+ @parent.handle_request('NOTIFY', 'close')
80+ end
81+ @__popup_menu.add(item)
82+ @__menu_list['exit'] = item
83+ @__popup_menu.show_all
10284 end
10385
10486 def set_responsible(parent)
@@ -124,11 +106,11 @@ module Nekodorif
124106 menu.add(item)
125107 item.show()
126108 end
127- @__menu_list[key][1].set_submenu(menu)
109+ @__menu_list[key].set_submenu(menu)
128110 menu.show()
129- @__menu_list[key][1].show()
111+ @__menu_list[key].show()
130112 else
131- @__menu_list[key][1].hide()
113+ @__menu_list[key].hide()
132114 end
133115 end
134116 end
--- a/lib/ninix/ngm.rb
+++ b/lib/ninix/ngm.rb
@@ -379,84 +379,6 @@ module NGM
379379
380380 def initialize
381381 @parent = nil
382- @ui_info = "
383- <ui>
384- <menubar name='MenuBar'>
385- <menu action='FileMenu'>
386- <menuitem action='Search'/>
387- <menuitem action='Search Forward'/>
388- <separator/>
389- <menuitem action='Settings'/>
390- <separator/>
391- <menuitem action='DB Network Update'/>
392- <separator/>
393- <menuitem action='Close'/>
394- </menu>
395- <menu action='ViewMenu'>
396- <menuitem action='Mask'/>
397- <menuitem action='Reset to Default'/>
398- <menuitem action='Show All'/>
399- </menu>
400- <menu action='ArchiveMenu'>
401- </menu>
402- <menu action='HelpMenu'>
403- </menu>
404- </menubar>
405- </ui>"
406- @entries = [
407- [ 'FileMenu', nil,
408- _('_File'), nil,
409- '',
410- lambda {|a, b| } ],
411- [ 'ViewMenu', nil,
412- _('_View'), nil,
413- '',
414- lambda {|a, b| } ],
415- [ 'ArchiveMenu', nil,
416- _('_Archive'), nil,
417- '',
418- lambda {|a, b| } ],
419- [ 'HelpMenu', nil,
420- _('_Help'), nil,
421- '',
422- lambda {|a, b| } ],
423- [ 'Search', nil, # name, stock id
424- _('Search(_F)'), '<control>F', # label, accelerator
425- 'Search', # tooltip
426- lambda {|a, b| open_search_dialog()} ],
427- [ 'Search Forward', nil,
428- _('Search Forward(_S)'), 'F3',
429- nil,
430- lambda {|a, b| search_forward()} ],
431- [ 'Settings', nil,
432- _('Settings(_O)'), nil,
433- nil,
434- lambda {|a, b| @parent.handle_request(
435- 'NOTIFY', 'open_preference_dialog')} ],
436- [ 'DB Network Update', nil,
437- _('DB Network Update(_N)'), nil,
438- nil,
439- lambda {|a, b| network_update()} ],
440- [ 'Close', nil,
441- _('Close(_X)'), nil,
442- nil,
443- lambda {|a, b| close()} ],
444- [ 'Mask', nil,
445- _('Mask(_M)'), nil,
446- nil,
447- lambda {|a, b| @parent.handle_request(
448- 'NOTIFY', 'open_mask_dialog')} ],
449- [ 'Reset to Default', nil,
450- _('Reset to Default(_Y)'), nil,
451- nil,
452- lambda {|a, b| @parent.handle_request(
453- 'NOTIFY', 'reset_to_default')} ],
454- [ 'Show All', nil,
455- _('Show All(_Z)'), nil,
456- nil,
457- lambda {|a, b| @parent.handle_request(
458- 'NOTIFY', 'show_all')} ],
459- ]
460382 @opened = false
461383 @textview = [nil, nil]
462384 @darea = [nil, nil]
@@ -500,20 +422,77 @@ module NGM
500422 end
501423 @window.set_window_position(Gtk::WindowPosition::CENTER)
502424 @window.gravity = Gdk::Gravity::CENTER
503- actions = Gtk::ActionGroup.new('Actions')
504- actions.add_actions(@entries)
505- ui = Gtk::UIManager.new()
506- ui.insert_action_group(actions, 0)
507- @window.add_accel_group(ui.accel_group)
508- begin
509- mergeid = ui.add_ui(@ui_info)
510- rescue => e #except GObject.GError as msg:
511- Logging::Logging.error('building menus failed: ' + e.message)
512- end
425+ accelgroup = Gtk::AccelGroup.new()
426+ @window.add_accel_group(accelgroup)
427+ menubar = Gtk::MenuBar.new()
428+ item = Gtk::MenuItem.new(:label => _('_File'), :use_underline => true)
429+ menubar.add(item)
430+ menu = Gtk::Menu.new()
431+ item.set_submenu(menu)
432+ item = Gtk::MenuItem.new(:label => _('Search(_F)'), :use_underline => true)
433+ item.signal_connect('activate') do |a, b|
434+ open_search_dialog()
435+ end
436+ item.add_accelerator('activate', accelgroup, Gdk::Keyval::KEY_f,
437+ Gdk::ModifierType::CONTROL_MASK,
438+ Gtk::AccelFlags::VISIBLE)
439+ menu.add(item)
440+ item = Gtk::MenuItem.new(:label => _('Search Forward(_S)'), :use_underline => true)
441+ item.signal_connect('activate') do |a, b|
442+ search_forward()
443+ end
444+ item.add_accelerator('activate', accelgroup, Gdk::Keyval::KEY_F3,
445+ nil,
446+ Gtk::AccelFlags::VISIBLE)
447+ menu.add(item)
448+ item = Gtk::SeparatorMenuItem.new()
449+ menu.add(item)
450+ item = Gtk::MenuItem.new(:label => _('Settings(_O)'), :use_underline => true)
451+ item.signal_connect('activate') do |a, b|
452+ @parent.handle_request('NOTIFY', 'open_preference_dialog')
453+ end
454+ menu.add(item)
455+ item = Gtk::SeparatorMenuItem.new()
456+ menu.add(item)
457+ item = Gtk::MenuItem.new(:label => _('DB Network Update(_N)'), :use_underline => true)
458+ item.signal_connect('activate') do |a, b|
459+ network_update()
460+ end
461+ menu.add(item)
462+ item = Gtk::SeparatorMenuItem.new()
463+ menu.add(item)
464+ item = Gtk::MenuItem.new(:label => _('Close(_X)'), :use_underline => true)
465+ item.signal_connect('activate') do |a, b|
466+ close()
467+ end
468+ menu.add(item)
469+ item = Gtk::MenuItem.new(:label => _('_View'), :use_underline => true)
470+ menu = Gtk::Menu.new
471+ item.set_submenu(menu)
472+ item = Gtk::MenuItem.new(:label => _('Mask(_M)'), :use_underline => true)
473+ item.signal_connect('activate') do |a, b|
474+ @parent.handle_request('NOTIFY', 'open_mask_dialog')
475+ end
476+ menu.add(item)
477+ item = Gtk::MenuItem.new(:label => _('Reset to Default(_Y)'), :use_underline => true)
478+ item.signal_connect('activate') do |a, b|
479+ @parent.handle_request('NOTIFY', 'reset_to_default')
480+ end
481+ menu.add(item)
482+ item = Gtk::MenuItem.new(:label => _('Show All(_Z)'), :use_underline => true)
483+ item.signal_connect('activate') do |a, b|
484+ @parent.handle_request('NOTIFY', 'show_all')
485+ end
486+ menu.add(item)
487+ item = Gtk::MenuItem.new(:label => _('_Archive'), :use_underline => true)
488+ menubar.add(item)
489+ item = Gtk::MenuItem.new(:label => _('_Help'), :use_underline => true)
490+ menubar.add(item)
491+ menubar.show_all
513492 vbox = Gtk::Box.new(orientation=Gtk::Orientation::VERTICAL)
514493 @window.add(vbox)
515494 vbox.show()
516- vbox.pack_start(ui.get_widget('/MenuBar'), :expand => false, :fill => false, :padding => 0)
495+ vbox.pack_start(menubar, :expand => false, :fill => false, :padding => 0)
517496 separator = Gtk::Separator.new(:horizontal)
518497 vbox.pack_start(separator, :expand => false, :fill => true, :padding => 0)
519498 separator.show()