Ruby GTK3移行後のメインリポジトリ
Révision | a72754d7aef090b41e97c6a6d727bcda1d9d1503 (tree) |
---|---|
l'heure | 2016-10-20 23:24:27 |
Auteur | Shyouzou Sugitani <shy@user...> |
Commiter | Shyouzou Sugitani |
misc fixes(2)
@@ -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 | + | |
1 | 5 | Mon October 17 2016 Shyouzou Sugitani <shy@users.osdn.me> |
2 | 6 | * Pix.create_pixbuf_from_fileの引数:is_pnrのデフォルト値を |
3 | 7 | falseに変更した. |
@@ -32,41 +32,24 @@ module Kinoko | ||
32 | 32 | |
33 | 33 | def initialize(accelgroup) |
34 | 34 | @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') | |
60 | 40 | 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') | |
69 | 49 | end |
50 | + @__popup_menu.add(item) | |
51 | + @__menu_list['exit'] = item | |
52 | + @__popup_menu.show_all | |
70 | 53 | end |
71 | 54 | |
72 | 55 | def set_responsible(parent) |
@@ -92,11 +75,11 @@ module Kinoko | ||
92 | 75 | menu.add(item) |
93 | 76 | item.show() |
94 | 77 | end |
95 | - @__menu_list[key][1].set_submenu(menu) | |
78 | + @__menu_list[key].set_submenu(menu) | |
96 | 79 | menu.show() |
97 | - @__menu_list[key][1].show() | |
80 | + @__menu_list[key].show() | |
98 | 81 | else |
99 | - @__menu_list[key][1].hide() | |
82 | + @__menu_list[key].hide() | |
100 | 83 | end |
101 | 84 | end |
102 | 85 | end |
@@ -25,137 +25,6 @@ module Menu | ||
25 | 25 | |
26 | 26 | def initialize |
27 | 27 | @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 | - } | |
159 | 28 | @__fontcolor = { |
160 | 29 | 'normal' => [0, 0, 0], |
161 | 30 | 'hover' => [255, 255, 255] |
@@ -171,26 +40,126 @@ module Menu | ||
171 | 40 | 'foreground' => nil, |
172 | 41 | 'sidebar' => nil |
173 | 42 | } |
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 | |
188 | 157 | provider = create_css_provider_for(@__popup_menu) |
189 | 158 | @__popup_menu.signal_connect('realize', provider) do |i, *a, provider| |
190 | 159 | next set_stylecontext_with_sidebar(i, *a, :provider => provider) |
191 | 160 | end |
192 | 161 | for key in @__menu_list.keys |
193 | - item = @ui_manager.get_widget(['/popup/', key].join('')) | |
162 | + item = @__menu_list[key][:entry] | |
194 | 163 | provider = create_css_provider_for(item) |
195 | 164 | item.signal_connect('draw', provider) do |i, *a, provider| |
196 | 165 | next set_stylecontext(i, *a, :provider => provider) |
@@ -287,7 +256,7 @@ module Menu | ||
287 | 256 | |
288 | 257 | def __set_mayuna_menu(side) |
289 | 258 | 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] | |
291 | 260 | menuitem.set_submenu(@__mayuna_menu[side]) |
292 | 261 | __set_visible('Costume', true) |
293 | 262 | else |
@@ -422,7 +391,7 @@ module Menu | ||
422 | 391 | def popup(button, side) |
423 | 392 | @__popup_menu.unrealize() |
424 | 393 | for key in @__menu_list.keys |
425 | - item = @ui_manager.get_widget(['/popup/', key].join('')) | |
394 | + item = @__menu_list[key][:entry] | |
426 | 395 | submenu = item.submenu |
427 | 396 | submenu.unrealize() unless submenu.nil? |
428 | 397 | end |
@@ -458,8 +427,8 @@ module Menu | ||
458 | 427 | __set_nekodorif_menu() |
459 | 428 | __set_kinoko_menu() |
460 | 429 | 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] | |
463 | 432 | unless item.nil? |
464 | 433 | if visible |
465 | 434 | item.show() |
@@ -475,7 +444,7 @@ module Menu | ||
475 | 444 | def __set_caption(name, caption) |
476 | 445 | fail "assert" unless @__menu_list.include?(name) |
477 | 446 | fail "assert" unless caption.is_a?(String) |
478 | - item = @ui_manager.get_widget(['/popup/', name].join('')) | |
447 | + item = @__menu_list[name][:entry] | |
479 | 448 | unless item.nil? |
480 | 449 | label = item.get_children()[0] |
481 | 450 | label.set_text_with_mnemonic(caption) |
@@ -485,7 +454,7 @@ module Menu | ||
485 | 454 | def __set_visible(name, visible) |
486 | 455 | fail "assert" unless @__menu_list.include?(name) |
487 | 456 | fail "assert" unless [false, true].include?(visible) |
488 | - @__menu_list[name]['visible'] = visible | |
457 | + @__menu_list[name][:visible] = visible | |
489 | 458 | end |
490 | 459 | |
491 | 460 | def __set_portal_menu(side, portal) |
@@ -559,7 +528,7 @@ module Menu | ||
559 | 528 | menu.add(item) |
560 | 529 | item.show() |
561 | 530 | end |
562 | - menuitem = @ui_manager.get_widget(['/popup/', 'Portal'].join('')) | |
531 | + menuitem = @__menu_list['Portal'][:entry] | |
563 | 532 | menuitem.set_submenu(menu) |
564 | 533 | provider = create_css_provider_for(menu) |
565 | 534 | menu.signal_connect('realize', provider) do |i, *a, provider| |
@@ -639,7 +608,7 @@ module Menu | ||
639 | 608 | menu.add(item) |
640 | 609 | item.show() |
641 | 610 | end |
642 | - menuitem = @ui_manager.get_widget(['/popup/', 'Recommend'].join('')) | |
611 | + menuitem = @__menu_list['Recommend'][:entry] | |
643 | 612 | menuitem.set_submenu(menu) |
644 | 613 | provider = create_css_provider_for(menu) |
645 | 614 | menu.signal_connect('realize', provider) do |i, *a, provider| |
@@ -791,7 +760,7 @@ module Menu | ||
791 | 760 | ghost_menu << item |
792 | 761 | end |
793 | 762 | end |
794 | - menuitem = @ui_manager.get_widget(['/popup/', path].join('')) | |
763 | + menuitem = @__menu_list[path][:entry] | |
795 | 764 | menuitem.set_submenu(ghost_menu) |
796 | 765 | provider = create_css_provider_for(ghost_menu) |
797 | 766 | ghost_menu.signal_connect('realize', provider) do |i, *a, provider| |
@@ -802,13 +771,13 @@ module Menu | ||
802 | 771 | |
803 | 772 | def __set_shell_menu |
804 | 773 | shell_menu = @parent.handle_request('GET', 'get_shell_menu') |
805 | - menuitem = @ui_manager.get_widget(['/popup/', 'Shell'].join('')) | |
774 | + menuitem = @__menu_list['Shell'][:entry] | |
806 | 775 | menuitem.set_submenu(shell_menu) |
807 | 776 | end |
808 | 777 | |
809 | 778 | def __set_balloon_menu |
810 | 779 | balloon_menu = @parent.handle_request('GET', 'get_balloon_menu') |
811 | - menuitem = @ui_manager.get_widget(['/popup/', 'Balloon'].join('')) | |
780 | + menuitem = @__menu_list['Balloon'][:entry] | |
812 | 781 | menuitem.set_submenu(balloon_menu) |
813 | 782 | end |
814 | 783 |
@@ -872,7 +841,7 @@ module Menu | ||
872 | 841 | ##if working |
873 | 842 | ## item.set_sensitive(false) |
874 | 843 | end |
875 | - menuitem = @ui_manager.get_widget(['/popup/', 'Nekodorif'].join('')) | |
844 | + menuitem = @__menu_list['Nekodorif'][:entry] | |
876 | 845 | menuitem.set_submenu(nekodorif_menu) |
877 | 846 | provider = create_css_provider_for(nekodorif_menu) |
878 | 847 | nekodorif_menu.signal_connect('realize', provider) do |i, *a, provider| |
@@ -900,7 +869,7 @@ module Menu | ||
900 | 869 | ##if working |
901 | 870 | ## item.set_sensitive(false) |
902 | 871 | end |
903 | - menuitem = @ui_manager.get_widget(['/popup/', 'Kinoko'].join('')) | |
872 | + menuitem = @__menu_list['Kinoko'][:entry] | |
904 | 873 | menuitem.set_submenu(kinoko_menu) |
905 | 874 | provider = create_css_provider_for(kinoko_menu) |
906 | 875 | kinoko_menu.signal_connect('realize', provider) do |i, *a, provider| |
@@ -909,7 +878,7 @@ module Menu | ||
909 | 878 | end |
910 | 879 | |
911 | 880 | def get_stick |
912 | - item = @ui_manager.get_widget(['/popup/', 'Stick'].join('')) | |
881 | + item = @__menu_list['Stick'][:entry] | |
913 | 882 | if not item.nil? and item.active? |
914 | 883 | return true |
915 | 884 | else |
@@ -62,43 +62,25 @@ module Nekodorif | ||
62 | 62 | |
63 | 63 | def initialize(accelgroup) |
64 | 64 | @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 | - } | |
87 | 65 | @__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 | |
102 | 84 | end |
103 | 85 | |
104 | 86 | def set_responsible(parent) |
@@ -124,11 +106,11 @@ module Nekodorif | ||
124 | 106 | menu.add(item) |
125 | 107 | item.show() |
126 | 108 | end |
127 | - @__menu_list[key][1].set_submenu(menu) | |
109 | + @__menu_list[key].set_submenu(menu) | |
128 | 110 | menu.show() |
129 | - @__menu_list[key][1].show() | |
111 | + @__menu_list[key].show() | |
130 | 112 | else |
131 | - @__menu_list[key][1].hide() | |
113 | + @__menu_list[key].hide() | |
132 | 114 | end |
133 | 115 | end |
134 | 116 | end |
@@ -379,84 +379,6 @@ module NGM | ||
379 | 379 | |
380 | 380 | def initialize |
381 | 381 | @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 | - ] | |
460 | 382 | @opened = false |
461 | 383 | @textview = [nil, nil] |
462 | 384 | @darea = [nil, nil] |
@@ -500,20 +422,77 @@ module NGM | ||
500 | 422 | end |
501 | 423 | @window.set_window_position(Gtk::WindowPosition::CENTER) |
502 | 424 | @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 | |
513 | 492 | vbox = Gtk::Box.new(orientation=Gtk::Orientation::VERTICAL) |
514 | 493 | @window.add(vbox) |
515 | 494 | 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) | |
517 | 496 | separator = Gtk::Separator.new(:horizontal) |
518 | 497 | vbox.pack_start(separator, :expand => false, :fill => true, :padding => 0) |
519 | 498 | separator.show() |